home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / oraclebrowser.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  21.1 KB  |  628 lines

  1. Oracle Browser 
  2.  
  3. A single script which will help you browse oracle objects in a schema (using all_ views). It helps to click your way through a database! After logging in, you can switch to other schemas. 
  4.  
  5.  
  6. <? if(!isset($PHP_AUTH_USER)) { 
  7.       Header( "WWW-authenticate: basic realm=\"$SID\""); 
  8.       Header( "HTTP/1.0 401 Unauthorized"); 
  9.       $title= "Login Instructions"; 
  10.           echo  "<blockquote> \n". 
  11.                      "You are not authorised to enter the site\n". 
  12.            "</blockquote> \n"; 
  13.       exit; 
  14.   } else { 
  15.     putenv( "ORACLE_SID=MAPSA"); 
  16.     putenv( "ORACLE_HOME=/u01/app/oracle/product/8.0.5"); 
  17.     if (!($conn=ora_logon( "$PHP_AUTH_USER@$SID",$PHP_AUTH_PW))) { 
  18.           Header( "WWW-authenticate: basic realm=\"$SID\""); 
  19.           Header( "HTTP/1.0 401 Unauthorized"); 
  20.           $title= "Login Instructions"; 
  21.           echo  "<blockquote> \n". 
  22.                      "You are not authorised to enter the site\n". 
  23.            "</blockquote> \n"; 
  24.                     exit; 
  25.             } 
  26.   } 
  27.  
  28. /* 
  29. || 
  30. || oraphp.php3 - v1.0 
  31. || Author : V.Satheesh Babu 
  32. || Date   : Aug 03, 1999 
  33. || License: GPL 
  34. || 
  35. || Allows user to navigate an Oracle database. This is a quick script 
  36. || put together in a very short time. So, code might not be formatted 
  37. || to anyone's liking. Comments and code are always welcome 
  38. ||  
  39. */ 
  40. include( "themes.php3"); 
  41. if(!isset($schema))  
  42.     $schema=strtoupper($PHP_AUTH_USER); 
  43. $title= "Oracle Schema Browser [$schema@$SID]"; 
  44. $header1=$title; 
  45. $ObjectDesc = array( 
  46.                                 "TABLE" =>  "Tables" 
  47.                                 , "VIEW" =>  "Views" 
  48.                                 , "INDEX" =>  "Indexes" 
  49.                                 , "TRIGGER" =>  "Triggers" 
  50.                                 , "SYNONYM" =>  "Synonyms" 
  51.                                 , "FUNCTION" =>  "Functions" 
  52.                                 , "PROCEDURE" =>  "Procedures" 
  53.                                 , "SEQUENCE" =>  "Sequences" 
  54.                                 , "PACKAGE" =>  "Packages" 
  55.                                 , "PACKAGE BODY" =>  "Package Bodies" 
  56.               ); 
  57. if(!isset($printqry)) 
  58.     $printqry= "off"; 
  59. $sidebar= "<P CLASS=\"FOOTER\" ALIGN=CENTER><small>[ "; 
  60. if (isset($objecttype)){ 
  61.     $sidebar .=  "<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=$printqry\">Top</A> "; 
  62. }else{ 
  63.     $sidebar .=  "Top "; 
  64. $sidebar .=  "| <A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=$printqry&changeschema=CHANGESCHEMA\">Schema</A> "; 
  65. while(list($key,$val)=each($ObjectDesc))  { 
  66.     if ( $key == $objecttype ) 
  67.     $sidebar .=  "| $val \n"; 
  68.     else 
  69.     $sidebar .=  "| <A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=$printqry&objecttype=$key\">$val</A> \n"; 
  70. if (isset($objecttype)) 
  71.     $others= "&objecttype=$objecttype"; 
  72. if (isset($objectnm)) 
  73.     $others.= "&objectnm=$objectnm"; 
  74. if (isset($oper)) 
  75.     $others.= "&oper=$oper"; 
  76. $sidebar .=  "]</small> </P>"; 
  77. reset($ObjectDesc); 
  78. ?> 
  79. <HTML> 
  80.   <HEAD> 
  81.      <? applyTheme(); ?> 
  82.   <TITLE> 
  83.      <? echo  "$title\n"; ?> 
  84.   </TITLE> 
  85.   </HEAD> 
  86.   <BODY> 
  87.       <? echo  "$sidebar\n"; ?> 
  88.     <H1> 
  89.        <? echo  "$header1\n"; ?> 
  90.     </H1> 
  91. <? 
  92. function printoraerr($in_cur){ 
  93.         global $conn; 
  94.          // function to check whether an oracle error occured 
  95.          // if it did, print the error 
  96.          // call this after every oracle call when a cursor is active 
  97.          // If it encountered an error, we exit immediately 
  98.         if(ora_errorcode($in_cur)) { 
  99.                 echo  "Oracle code - ".ora_error($in_cur). "<br>\n"; 
  100.                 ora_logoff($conn); 
  101.                 exit; 
  102.         } 
  103.         return; 
  104.  
  105. function exequery($w_qry) { 
  106.     global $conn,$printqry,$others,$SID,$PHP_SELF,$schema; 
  107.     $cursor=ora_open($conn); printoraerr($cursor); 
  108.     ora_parse($cursor,$w_qry,0); printoraerr($cursor); 
  109.     ora_exec($cursor); printoraerr($cursor); 
  110.     $numrows=0; 
  111.     $w_numcols=ora_numcols($cursor); 
  112.      // print headers 
  113.     echo  " 
  114.      <TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"2\"> 
  115.      <TR>\n"; 
  116.     for ($i=0;$i<$w_numcols;$i++) { 
  117.         $align=(ora_columntype($cursor,$i)== "NUMBER")? "RIGHT": "LEFT"; 
  118.         echo  "\t<TH VALIGN=TOP ALIGN=$align>".ora_columnname($cursor,$i). "</TH>\n"; 
  119.     } 
  120.     echo  "</TR>\n"; 
  121.  
  122.     while(ora_fetch($cursor)){ 
  123.             echo  "<TR>\n"; 
  124.             for ($i=0;$i<$w_numcols;$i++) { 
  125.                 $align=(ora_columntype($cursor,$i)== "NUMBER")? "RIGHT": "LEFT"; 
  126.                 if(ora_columntype($cursor,$i)== "LONG") 
  127.                 echo  "<TD VALIGN=TOP ALIGN=$align><PRE>".ora_getcolumn($cursor,$i). "</PRE></TD>\n"; 
  128.                 else 
  129.                 echo  "<TD VALIGN=TOP ALIGN=$align>".ora_getcolumn($cursor,$i). "</TD>\n"; 
  130.                 printoraerr($cursor); 
  131.             } 
  132.             $numrows++; 
  133.             echo  "</TR>\n"; 
  134.     } 
  135.     if ($numrows==0) 
  136.         echo  "<TR><TD COLSPAN=\"$w_numcols\"><B>Query returned no records</B></TD></TR>\n"; 
  137.     else { 
  138.         echo  "<TR>\n"; 
  139.         echo  "<TH COLSPAN=\"".($w_numcols-1). "\" ALIGN=RIGHT>Count</TH>\n"; 
  140.         echo  "<TH ALIGN=RIGHT>$numrows</TH>\n"; 
  141.         echo  "</TR>\n"; 
  142.     } 
  143.     echo  "</TABLE>\n"; 
  144.     ora_close($cursor); 
  145.     if ($printqry== "on") { 
  146.         echo  "<H4>Query</H4><P><pre>".htmlspecialchars($w_qry). "</pre></P> 
  147.         <P ALIGN=CENTER><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=off$others\"><small><u><i>Hide Query</i></u></small></A></P>\n"; 
  148.     } else { 
  149.         echo  "<P ALIGN=CENTER><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=on$others\"><small><u><i>Show Query</i></u></small></A></P>\n"; 
  150.     } 
  151.     return; 
  152.  
  153. function change_schema(){ 
  154.     global $conn,$printqry,$others,$SID,$PHP_SELF,$schema; 
  155.     $qry= "SELECT username FROM all_users ORDER BY username"; 
  156.     $cursor=ora_open($conn); printoraerr($cursor); 
  157.     ora_parse($cursor,$qry,0); printoraerr($cursor); 
  158.     ora_exec($cursor); printoraerr($cursor); 
  159.     echo  "<form name=\"choseschema\" action=\"$PHP_SELF\"> 
  160.          <input type=\"hidden\" name=\"printqry\" value=\"$printqry\"> 
  161.          <input type=\"hidden\" name=\"SID\" value=\"$SID\">"; 
  162.     if(isset($objecttype)) 
  163.         echo  "<input type=\"hidden\" name=\"objecttype\" value=\"$objecttype\">\n"; 
  164.     if(isset($oper)) 
  165.          echo  "<input type=\"hidden\" name=\"oper\" value=\"$oper\">\n"; 
  166.     if(isset($objectnm)) 
  167.          echo  "<input type=\"hidden\" name=\"objectnm\" value=\"$objectnm\">\n"; 
  168.     echo  "<select name=\"schema\">\n"; 
  169.     while(ora_fetch($cursor)){ 
  170.         $option=ora_getcolumn($cursor,0); 
  171.         if( "$option" ==  "$schema") 
  172.         echo  "<option value=\"$option\" SELECTED>$option</option>\n"; 
  173.         else 
  174.         echo  "<option value=\"$option\">$option</option>\n"; 
  175.     } 
  176.     echo  "</select>\n<input type=\"submit\"  value=\"Change Schema\">\n</form>\n"; 
  177.     ora_close($cursor); 
  178.     echo  "<P>Choose the schema you want and press the button. You will be  
  179.     taken to the front page and then onwards you can see <B>only</B> the  
  180.     objects owned by the new schema.</P>\n"; 
  181.     return; 
  182.  
  183. function user_sources() { 
  184.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID, $printqry,$schema; 
  185.     $qry= " 
  186. SELECT 
  187.     '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=$objecttype&oper=srcdesc&printqry=$printqry&objectnm='||I.name||'\">'||I.name||'</A>'  \"Name\", 
  188.     COUNT(I.line) \"Lines\" 
  189. FROM 
  190.     all_source I 
  191. WHERE I.type='$objecttype' 
  192.   AND I.owner='$schema' 
  193. GROUP BY 
  194.     I.name 
  195. ORDER BY 
  196.     I.name"; 
  197.     $desc = $ObjectDesc[$objecttype]; 
  198.     exequery($qry); 
  199.  
  200. function user_src_desc() { 
  201.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID,$schema; 
  202.     $qry= " 
  203. SELECT 
  204.     '<PRE>'||NVL(I.text,' ')||'</PRE>' \"Code\" 
  205. FROM 
  206.     all_source I 
  207. WHERE I.type='$objecttype' 
  208.   AND I.name='$objectnm' 
  209.   AND I.owner='$schema' 
  210. ORDER BY 
  211.     I.line"; 
  212.     echo  "<H3>$objectnm</H3>\n"; 
  213.     exequery($qry); 
  214.  
  215. function user_views() { 
  216.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID,$printqry,$schema; 
  217.     $qry= " 
  218. SELECT "; 
  219.   if ( isset($objectnm) ) 
  220.     $qry .=  " I.view_name  \"Name\",\n I.text \"Code\" "; 
  221.     else 
  222.     $qry .=  " '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=$objecttype&printqry=$printqry&oper=srcdesc&objectnm='||I.view_name||'\">'||I.view_name||'</A>'  \"Name\",\n I.text_length \"Code Size\" "; 
  223.     $qry .=  " 
  224. FROM 
  225.     all_views I "; 
  226.   if ( isset($objectnm) ) 
  227.         $qry .=  " WHERE I.view_name = '$objectnm' AND I.owner='$schema'"; 
  228.     else 
  229.         $qry .=  " WHERE  I.owner='$schema'"; 
  230.   $qry .=  "ORDER BY I.view_name"; 
  231.     $desc = $ObjectDesc[$objecttype]; 
  232.     exequery($qry); 
  233.  
  234. function user_synonyms() { 
  235.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID, $printqry,$schema; 
  236.     $qry= " 
  237. SELECT 
  238.     I.synonym_name  \"Synonym\", 
  239.     O.status \"Status\", 
  240.         '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm='||I.TABLE_NAME||'\">'|| 
  241.         I.table_name||'</A>' \"Table\", 
  242.     NVL(I.db_link,' ') \"DB Link\" 
  243. FROM 
  244.     all_objects O, all_synonyms I 
  245. WHERE 
  246.     O.object_name = I.synonym_name 
  247. AND 
  248.     O.object_type = 'SYNONYM' 
  249. AND  
  250.     O.OWNER='$schema' 
  251. AND  
  252.     I.OWNER='$schema' 
  253. ORDER BY 
  254.     I.synonym_name"; 
  255.     $desc = $ObjectDesc[$objecttype]; 
  256.     exequery($qry); 
  257.  
  258. function user_sequences() { 
  259.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID, $printqry,$schema; 
  260.     $qry= " 
  261. SELECT 
  262.     I.sequence_name  \"Sequence\", 
  263.         I.last_number \"Current\", 
  264.     O.status \"Status\", 
  265.     NVL(I.min_value,0) \"Min\", 
  266.     NVL(I.max_value,0) \"Max\", 
  267.     I.increment_by \"Incr.\", 
  268.     DECODE(I.cycle_flag,'Y','Yes','No') \"Cycle\", 
  269.     DECODE(I.order_flag,'Y','Yes','No') \"Order\", 
  270.         I.cache_size \"Cache\" 
  271. FROM 
  272.     all_objects O, all_sequences I 
  273. WHERE 
  274.     O.object_name = I.sequence_name 
  275. AND 
  276.     O.object_type = 'SEQUENCE' 
  277. AND 
  278.     O.owner='$schema' 
  279. AND 
  280.     I.sequence_owner='$schema' 
  281. ORDER BY 
  282.     I.sequence_name"; 
  283.     $desc = $ObjectDesc[$objecttype]; 
  284.     exequery($qry); 
  285.  
  286. function user_triggers() { 
  287.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID, $printqry,$schema; 
  288.     $qry= " 
  289. SELECT 
  290.     '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=$objecttype&printqry=$printqry&oper=srcdesc&objectnm='||I.trigger_name||'\">'||I.trigger_name||'</A>'  \"Name\", 
  291.     I.trigger_type    \"Type\", 
  292.     O.status \"Status\", 
  293.     I.status \"Enabled\", 
  294.         '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm='||I.TABLE_NAME||'\">'|| 
  295.         I.table_name||'</A>' \"Table\", 
  296.     I.triggering_event \"Trig Event\", 
  297.     '<PRE>'||NVL(I.description,' ')||'</PRE>' \"Description\" 
  298. FROM 
  299.     all_objects O, all_triggers I 
  300. WHERE 
  301.     O.object_name = I.trigger_name 
  302. AND 
  303.     O.object_type = 'TRIGGER' 
  304. AND 
  305.     O.owner = '$schema' 
  306. AND 
  307.     I.owner = '$schema' 
  308. ORDER BY 
  309.     I.trigger_name"; 
  310.     $desc = $ObjectDesc[$objecttype]; 
  311.     exequery($qry); 
  312.  
  313. function user_trig_desc() { 
  314.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm, $SID, $printqry,$schema; 
  315.     $qry= " 
  316. SELECT 
  317.     I.trigger_body    \"Code\" 
  318. FROM 
  319.      user_triggers I 
  320. WHERE 
  321.     I.trigger_name = '$objectnm'"; 
  322.     echo  "<H3>$objectnm</H3>\n"; 
  323.     exequery($qry); 
  324.  
  325. function user_indexes() { 
  326.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  327.     if ( $objecttype ==  "INDEX" && isset($objectnm))  
  328.     $qry = "SELECT * FROM user_indexes WHERE index_name='$objectnm' "; 
  329.     else 
  330.     $qry= " 
  331. SELECT  
  332.     '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=INDEX&printqry=$printqry&objectnm='||index_name||'\">'||index_name||'</A>' 
  333.  \"Name\",  
  334.     '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm='||table_name||'\">'|| 
  335.     table_name||'</A>'   \"Table\", 
  336.     column_name          \"Column\", 
  337.     column_length        \"Column length\" 
  338. FROM 
  339.     all_ind_columns 
  340. WHERE  
  341.     index_owner = '$schema' 
  342. ORDER BY  
  343.     column_position"; 
  344.     if ( $objecttype ==  "INDEX" && isset($objectnm))  { 
  345.     echo  "<H4>$objectnm</H4>\n"; 
  346.     } 
  347.     exequery($qry); 
  348.  
  349. function user_tables() { 
  350.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  351.     $qry= " 
  352. SELECT 
  353.          table_name  \"Name\", 
  354. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabdesc&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Desc\", 
  355. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabidx&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Indexes\", 
  356. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabcons&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Constraints\", 
  357. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabtrig&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Triggers\", 
  358. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabgrant&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Grants\", 
  359. '<A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&oper=tabstat&printqry=$printqry&objectnm='||TABLE_NAME||'\">X</A>' \"Stats\" 
  360. FROM all_tables "; 
  361.   if ( $objectnm ) 
  362.         $qry .=  " WHERE table_name = '$objectnm' AND owner='$schema'"; 
  363.     else 
  364.         $qry .=  " WHERE owner='$schema'"; 
  365.     $qry .=  "         ORDER BY 1"; 
  366.     exequery($qry); 
  367.  
  368. function user_tab_desc() { 
  369.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  370.   $qry =  " 
  371. SELECT 
  372.     I.column_name \"Column\", 
  373.     I.data_type||'('|| 
  374.     decode(I.data_type, 
  375.             'NUMBER',I.data_precision||','||I.data_scale 
  376.             ,I.data_length)||')' \"Data Type\", 
  377.     I.nullable \"Null?\", 
  378.     I.data_default \"Default\", 
  379.     nvl(C.comments,' ') \"Comments\" 
  380.  
  381. FROM 
  382.             all_col_comments C, all_tab_columns I 
  383. WHERE 
  384.             I.table_name='$objectnm' 
  385. AND 
  386.     C.owner = '$schema' 
  387. AND 
  388.     I.owner = '$schema' 
  389. AND  
  390.         C.table_name=I.table_name 
  391. AND    
  392.       C.column_name=I.column_name"; 
  393.  
  394.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  395.     echo  "<H4>Description</H4>\n"; 
  396.     exequery($qry); 
  397.  
  398. function user_tab_idx() { 
  399.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  400.     $qry= " 
  401. SELECT 
  402.         C.index_name    \"Index\", 
  403.         I.uniqueness    \"Unique\", 
  404.         C.column_name   \"Column\", 
  405.         C.column_position \"Position\" 
  406. FROM 
  407.         all_ind_columns C, all_indexes I 
  408. WHERE 
  409.         I.table_name='$objectnm' 
  410. AND 
  411.         I.table_owner='$schema' 
  412. AND 
  413.         I.index_owner='$schema' 
  414. AND 
  415.         C.index_name = I.index_name 
  416. ORDER BY 
  417.         C.index_name, 
  418.         C.column_position"; 
  419.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  420.     echo  "<H4>Indexes</H4>\n"; 
  421.     exequery($qry); 
  422.  
  423. function user_tab_cons() { 
  424.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  425.     $qry= " 
  426. SELECT 
  427.         C.constraint_name   \"Constraint\", 
  428.         decode(I.constraint_type,'C','Not Null', 
  429.                     'P', 'Primary Key', 
  430.                     'R', 'Referential', 
  431.                     'Unknown') 
  432.                     \"Type\", 
  433.         C.column_name   \"Column\", 
  434.         C.position \"Position\", 
  435.         I.status \"Status\" 
  436. FROM 
  437.         all_cons_columns C, all_constraints I 
  438. WHERE 
  439.         I.table_name='$objectnm' 
  440. AND 
  441. C.owner = '$schema' 
  442. AND 
  443. I.owner = '$schema' 
  444. AND 
  445.         C.constraint_name = I.constraint_name 
  446. ORDER BY 
  447.         C.constraint_name"; 
  448.  
  449.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  450.     echo  "<H4>Constraints</H4>\n"; 
  451.     exequery($qry); 
  452.  
  453. function user_tab_stat() { 
  454.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  455.     $qry= " 
  456. SELECT * 
  457. FROM 
  458.         all_tables I 
  459. WHERE 
  460.         I.table_name='$objectnm' 
  461. AND I.owner='$schema' 
  462. ORDER BY 1"; 
  463.  
  464.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  465.     echo  "<H4>Stats</H4>\n"; 
  466.     exequery($qry); 
  467.  
  468. function user_tab_grant() { 
  469.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  470.     $qry= " 
  471. SELECT 
  472.         I.grantee   \"Granted To\", 
  473.         decode(I.select_priv,'Y','Yes', 'No') \"Select\", 
  474.         decode(I.insert_priv,'Y','Yes', 'No') \"Insert\", 
  475.         decode(I.delete_priv,'Y','Yes', 'No') \"Update\", 
  476.         decode(I.update_priv,'Y','Yes', 'No') \"Delete\", 
  477.         decode(I.references_priv,'Y','Yes', 'No') \"Refer.\", 
  478.         decode(I.alter_priv,'Y','Yes', 'No') \"Alter\", 
  479.         decode(I.index_priv,'Y','Yes', 'No') \"Index\", 
  480.         I.grantor   \"Granted By\" 
  481. FROM 
  482.         all_tab_grants I 
  483. WHERE 
  484.         I.table_name='$objectnm' 
  485. AND 
  486.     I.owner='$schema' 
  487. ORDER BY 1"; 
  488.  
  489.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  490.     echo  "<H4>Grants</H4>\n"; 
  491.     exequery($qry); 
  492.  
  493. function user_tab_trig() { 
  494.     global $ObjectDesc,$objecttype,$PHP_SELF,$objectnm,$SID,$printqry,$schema; 
  495.     $qry= " 
  496. SELECT 
  497.     I.trigger_name  \"Trigger\", 
  498.     I.trigger_type    \"Type\", 
  499.     O.status \"Status\", 
  500.     I.status \"Enabled\", 
  501.     I.triggering_event \"Trig Event\" 
  502. FROM 
  503.     all_objects O, all_triggers I 
  504. WHERE 
  505.     I.table_name='$objectnm' 
  506. AND 
  507.     O.object_name = I.trigger_name 
  508. AND 
  509.     O.owner = '$schema' 
  510.     AND 
  511.         I.owner = '$schema' 
  512. AND 
  513.     O.object_type = 'TRIGGER' 
  514. ORDER BY 
  515.     I.trigger_name"; 
  516.  
  517.     echo  "<H3><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&objecttype=TABLE&printqry=$printqry&objectnm=$objectnm\">$objectnm</A></H3>\n"; 
  518.     echo  "<H4>Triggers</H4>\n"; 
  519.     exequery($qry); 
  520.  
  521. /* 
  522. || 
  523. || Main 
  524. || 
  525. */ 
  526. if ( $changeschema ==  "CHANGESCHEMA" ) { 
  527.     change_schema() ; 
  528. } elseif (isset($objecttype)){ 
  529.     echo  "<H2><A HREF=\"$PHP_SELF?schema=$schema&SID=$SID&printqry=$printqry&objecttype=$objecttype\">$ObjectDesc[$objecttype]</A></H2>\n"; 
  530. } else { 
  531.     echo  "<H2>Instance Parameters</H2>\n"; 
  532.     $qry= "SELECT name \"Parameter\", nvl(value,' ') \"Value\" from v\$parameter"; 
  533.     exequery($qry); 
  534.      /* 
  535.     echo "<H2>Memory(SGA) Parameters</H2>\n"; 
  536.     $qry="SELECT * from s_v\$sgastat"; 
  537.     exequery($qry); 
  538.     */ 
  539.     echo  "<H2>Credits</H2> 
  540.                 <H3>Author</H3> 
  541.                 <P><A HREF=\"http://www.csoft.net/~vsbabu/\">V.Satheesh Babu</A> - <I>Released under <A HREf=\"http://www.gnu.org/copyleft/gpl.html\">GNU Public License</A></I></P> 
  542.                 <H3>Version History</H3> 
  543.                 <OL> 
  544.                 <LI><B>Aug 01, 1999</B> -  Basic Browsing </LI> 
  545.                 <LI><B>Aug 03, 1999</B> -  Sequence, Packages and Views </LI> 
  546.                 <LI><B>Nov 01, 1999</B> -  Change schema </LI> 
  547.                 </OL> 
  548.                 <H3>Requirements</H3> 
  549.                 <OL> 
  550.                     <LI><A HREF=\"http://www.oracle.com\">Oracle</A> - with a logon with SELECT privileges on all_* tables</LI> 
  551.                     <LI><A HREF=\"http://www.php.net\">PHP</A> - with Oracle (ora_*) functions' support</LI> 
  552.                     <LI><A HREF=\"http://www.apache.org\">Apache</A> - wth PHP support :-)</LI> 
  553.                 </OL>\n"; 
  554.  
  555. if (!isset($orderby)) { 
  556.         $orderby=1; 
  557.  
  558. if ( $objecttype ==  "INDEX" ) user_indexes(); 
  559. if ( $objecttype ==  "TRIGGER" ) { 
  560.          if($oper== "srcdesc") 
  561.              user_trig_desc(); 
  562.          else 
  563.              user_triggers(); 
  564. if ( $objecttype ==  "SYNONYM" ) user_synonyms(); 
  565. if ( $objecttype ==  "SEQUENCE" ) user_sequences(); 
  566. if ( ($objecttype ==  "PROCEDURE") || 
  567.      ($objecttype ==  "FUNCTION" ) || 
  568.      ($objecttype ==  "PACKAGE" )  || 
  569.      ($objecttype ==  "PACKAGE BODY" )) { 
  570.          if($oper== "srcdesc") 
  571.              user_src_desc(); 
  572.          else 
  573.              user_sources(); 
  574. if ( $objecttype ==  "TABLE" ){ 
  575.     if ( !$objectnm ) 
  576.         user_tables(); 
  577.     else 
  578.         if($oper== "tabdesc") user_tab_desc(); 
  579.         else if($oper== "tabidx") user_tab_idx(); 
  580.         else if($oper== "tabcons") user_tab_cons(); 
  581.         else if($oper== "tabtrig") user_tab_trig(); 
  582.         else if($oper== "tabgrant") user_tab_grant(); 
  583.         else if($oper== "tabstat") user_tab_stat(); 
  584.         else user_tables(); 
  585.  
  586. if ( $objecttype ==  "VIEW" ) { 
  587.              user_views(); 
  588.  
  589. ora_logoff($conn); 
  590. ?> 
  591. </TD> 
  592. </TR> 
  593. </TABLE> 
  594. <HR> 
  595. <?  echo $sidebar; ?> 
  596. <center> 
  597. <? selthm(); ?> 
  598. </center> 
  599. </BODY> 
  600. </HTML> 
  601.  
  602.