function uploadImageData($db, $file, $currentPictureId, $table, $id)
 {
     // insert the new record into the media's table and load the
     // corresponding blob with the media's data
     // (we use oracle's pseudo column rowid which identifies a row
     // within a table (but not within a database) to refer to the
     // right record later on)
     $sql = "DECLARE\n                        obj ORDSYS.ORDImage;\n                        iblob BLOB;\n                BEGIN\n                        SELECT image INTO obj FROM {$table}\n                        WHERE {$id} = {$currentPictureId} FOR UPDATE;\n\n                        iblob := obj.source.localData;\n                        :extblob := iblob;\n\n                        UPDATE {$table} SET image = obj WHERE {$id} = {$currentPictureId};\n                END;";
     // the function OCINewDescriptor allocates storage to hold descriptors or
     // lob locators.
     // see http://www.php.net/manual/en/function.ocinewdescriptor.php
     $blob = OCINewDescriptor($db, OCI_D_LOB);
     $sql = strtr($sql, chr(13) . chr(10), " ");
     $stmt = OCIParse($db, $sql);
     // the function OCIBindByName binds a PHP variable to a oracle placeholder
     // (whether the variable will be used for input or output will be determined
     // run-time, and the necessary storage space will be allocated)
     // see http://www.php.net/manual/en/function.ocibindbyname.php
     OCIBindByName($stmt, ':extblob', $blob, -1, OCI_B_BLOB);
     echo "{$this->log} - {$sql} <br />";
     OCIExecute($stmt, OCI_DEFAULT);
     // read the files data and load it into the blob
     $blob->savefile($file);
     OCIFreeStatement($stmt);
     $blob->free();
 }
Esempio n. 2
0
function add_image($name, $imagetype, $file)
{
    if (!is_null($file)) {
        if ($file["error"] != 0 || $file["size"] == 0) {
            error("Incorrect Image");
        } else {
            if ($file["size"] < 1024 * 1024) {
                global $DB;
                $imageid = get_dbid("images", "imageid");
                $image = fread(fopen($file["tmp_name"], "r"), filesize($file["tmp_name"]));
                if ($DB['TYPE'] == "ORACLE") {
                    DBstart();
                    $lobimage = OCINewDescriptor($DB['DB'], OCI_D_LOB);
                    $stid = OCIParse($DB['DB'], "insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . ",EMPTY_BLOB())" . " return image into :image");
                    if (!$stid) {
                        $e = ocierror($stid);
                        error("Parse SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
                        return false;
                    }
                    OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
                    if (!OCIExecute($stid, OCI_DEFAULT)) {
                        $e = ocierror($stid);
                        error("Execute SQL error [" . $e["message"] . "] in [" . $e["sqltext"] . "]");
                        return false;
                    }
                    $result = DBend($lobimage->save($image));
                    if (!$result) {
                        error("Couldn't save image!\n");
                        return false;
                    }
                    $lobimage->free();
                    OCIFreeStatement($stid);
                    return $stid;
                } else {
                    if ($DB['TYPE'] == "POSTGRESQL") {
                        $image = pg_escape_bytea($image);
                    } else {
                        if ($DB['TYPE'] == "SQLITE3") {
                            $image = bin2hex($image);
                        }
                    }
                }
                return DBexecute("insert into images (imageid,name,imagetype,image)" . " values ({$imageid}," . zbx_dbstr($name) . "," . $imagetype . "," . zbx_dbstr($image) . ")");
            } else {
                error("Image size must be less than 1Mb");
            }
        }
    } else {
        error("Select image to download");
    }
    return false;
}
Esempio n. 3
0
 /**
  * Performs an SQL query.
  *
  * @param  string  $query
  * @param  mixed   $limit
  * @param  boolean $warnOnFailure
  * @access public
  */
 function query($query, $limit = false, $warnOnFailure = true)
 {
     if ($limit != false) {
         $query = sprintf('SELECT * FROM (%s) WHERE ROWNUM <= %d', $query, $limit);
     }
     if ($this->config['debug_level'] > 1) {
         $this->debugQuery($query);
     }
     @OCIFreeStatement($this->result);
     $this->result = @OCIParse($this->connection, $query);
     if (!$this->result) {
         $error = OCIError($this->result);
         phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR);
     }
     @OCIExecute($this->result);
     if (!$this->result && $warnOnFailure) {
         $error = OCIError($this->result);
         phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR);
     }
 }
Esempio n. 4
0
 function sql_freeresult($query_id = 0)
 {
     if (!$query_id) {
         $query_id = $this->query_result;
     }
     if ($query_id) {
         $result = @OCIFreeStatement($query_id);
         return $result;
     } else {
         return false;
     }
 }
 /**
  *	This function will execute the SQL statement and return the records as an associative array. Optionally, you
  *	can limit the number of records that are returned. Optionally, you can also specify which record to start
  *	from.
  *
  *	@param $sql	The SQL statement to use.
  *	@param $limit	(optional) How many records to return
  *	@param $offset	(optional) Where to start from
  *
  *	@returns	The records matching the SQL statement as an associative array.
  */
 function getRecords($sql, $limit = -1, $offset = -1)
 {
     $sql = $this->_prepareSqlForLimit($sql, $limit, $offset);
     $result = $this->_connectAndExec($sql);
     $type = YDConfig::get('YD_DB_FETCHTYPE') == YD_DB_FETCH_NUM ? OCI_NUM : OCI_ASSOC;
     $dataset = array();
     while (ocifetchinto($result, $line, $type)) {
         array_push($dataset, $this->_lowerKeyNames($line));
     }
     OCIFreeStatement($result);
     return $dataset;
 }
 /**
  *	This function will execute the SQL statement and return the records as an associative array.
  *
  *	@param $sql	The SQL statement to use.
  *
  *	@returns	The records matching the SQL statement as an associative array.
  */
 function getRecords($sql)
 {
     $result = $this->_connectAndExec($sql);
     $dataset = array();
     while (ocifetchinto($result, $line, OCI_ASSOC)) {
         array_push($dataset, $this->_lowerKeyNames($line));
     }
     OCIFreeStatement($result);
     return $dataset;
 }
 function GetLastInsertID($sTable)
 {
     if (!($res = OCIParse($this->conn, "select currval(seq_{$sTable})"))) {
         trigger_error("Error parsing insert ID query!");
         return $this->ReportError($this->conn);
     }
     if (OCIExecute($res)) {
         @OCIFetchInto($res, $Record, OCI_NUM | OCI_ASSOC | OCI_RETURN_NULLS);
         @OCIFreeStatement($res);
         return $Record[0];
     }
     trigger_error("Error executing insert ID query!");
     return $this->ReportError($res);
 }
Esempio n. 8
0
 public function write($id, $data)
 {
     $query = "MERGE INTO " . self::$_table["saveHandler"]["options"]["name"] . " M ";
     $query .= "USING (SELECT '" . $id . "' AS ID, :TIME AS LIFETIME, :DADOS AS DATAVAL FROM DUAL) N ";
     $query .= "ON (M." . self::$_table["saveHandler"]["options"]["primary"][0] . " = N.ID ) ";
     $query .= "WHEN MATCHED THEN ";
     $query .= "UPDATE SET M." . self::$_table["saveHandler"]["options"]["lifetimeColumn"] . " = N.LIFETIME, ";
     $query .= "M." . self::$_table["saveHandler"]["options"]["dataColumn"] . " = N.DATAVAL ";
     $query .= "WHEN NOT MATCHED THEN INSERT( " . self::$_table["saveHandler"]["options"]["primary"][0] . ", ";
     $query .= self::$_table["saveHandler"]["options"]["lifetimeColumn"] . ", ";
     $query .= self::$_table["saveHandler"]["options"]["dataColumn"] . " ) ";
     $query .= "VALUES(N.ID, N.LIFETIME, N.DATAVAL) ";
     $stmt = OCIParse(self::$_db, $query);
     $clob = OCINewDescriptor(self::$_db, OCI_D_LOB);
     OCIBindByName($stmt, ':TIME', time());
     OCIBindByName($stmt, ':DADOS', $clob, -1, OCI_B_CLOB);
     $clob->WriteTemporary($data, OCI_TEMP_CLOB);
     $exe = OCIExecute($stmt, OCI_DEFAULT);
     if ($exe === true) {
         $ret = true;
         OCICommit(self::$_db);
     } else {
         $ret = false;
         OCIRollback(self::$_db);
     }
     $clob->close();
     $clob->free();
     OCIFreeStatement($stmt);
     return $ret;
 }
Esempio n. 9
0
function DBCloseConnection($statement)
{
    // Libera todos los recursos asociados a la sentencia..
    OCIFreeStatement($statement);
}
Esempio n. 10
0
// create SQL statement
$sql = "Select * from Classes";
// parse SQL statement
$sql_statement = OCIParse($conn, $sql);
// execute SQL query
OCIExecute($sql_statement);
// get number of columns for use later
$num_columns = OCINumCols($sql_statement);
// start results formatting
echo "<TABLE BORDER=1>";
echo "<TR><TH>SCU Core Class</TH><TH>Alternate Class</TH><TH>University</TH></TR>";
// format results by row
while (OCIFetch($sql_statement)) {
    echo "<TR>";
    for ($i = 1; $i <= $num_columns; $i++) {
        $column_value = OCIResult($sql_statement, $i);
        echo "<TD>{$column_value}</TD>";
    }
    echo "</TR>";
}
echo "</TABLE>";
OCIFreeStatement($sql_statement);
OCILogoff($conn);
?>
<html>
 <head>
 <title>Step 1</title>
 </head>
 <body>
</body>
</html>
Esempio n. 11
0
$username = $_POST['username'];
$password = $_POST['pwd'];
if ($password == null) {
    echo '<font color="' . red . '">Password cannot be blank. Please enter a valid password</font>';
    echo "<br/><br/>";
    echo "<a href='http://uisacad.uis.edu/~kmulpu2/PasswordReset.html'>Back To Password Reset Page</a>";
    exit;
}
$connection = ocilogon("tanis2", "oracle", "oracle.uis.edu");
$sqlquery = "UPDATE CREDENTIALS SET password='******' WHERE username='******'";
$sql_id = ociparse($connection, $sqlquery);
if (!$sql_id) {
    $e = oci_error($connection);
    echo "The following error occured:";
    print htmlentities($e['message']);
    exit;
}
$returnValue = ociexecute($sql_id, OCI_DEFAULT);
if ($returnValue == 1) {
    echo '<font color="' . blue . '">Password was reset successfully</font>';
    ocicommit($connection);
    echo "<br/><br/>";
    echo "<a href='http://uisacad.uis.edu/~kmulpu2/DillardsReporting.html'>Back To Login Page</a>";
} else {
    echo '<font color="' . red . '">Unable to reset password due to server issues. Please try again later</font>';
}
OCIFreeStatement($sql_id);
OCILogoff($connection);
?>
</body>
</html>
Esempio n. 12
0
 function _close()
 {
     if ($this->connection->_stmt === $this->_queryID) {
         $this->connection->_stmt = false;
     }
     if (!empty($this->_refservicior)) {
         OCIFreeServicior($this->_refservicior);
         $this->_refservicior = false;
     }
     @OCIFreeStatement($this->_queryID);
     $this->_queryID = false;
 }
 /** returns array of assoc array's */
 function result($stmt = FALSE, $from = FALSE, $to = FALSE)
 {
     if (!$stmt) {
         $stmt = $this->stmt;
     }
     $result = array();
     if (!$from && !$to) {
         while (@ocifetchinto($stmt, $arr, OCI_ASSOC + OCI_RETURN_NULLS)) {
             $result[] = $arr;
         }
     } else {
         $counter = 0;
         while (@ocifetchinto($stmt, $arr, OCI_ASSOC + OCI_RETURN_NULLS)) {
             if ($counter >= $from && $counter <= $to) {
                 $result[] = $arr;
             }
             $counter++;
         }
     }
     @OCIFreeStatement($stmt);
     return $result;
 }
Esempio n. 14
0
function dbi_free_result($res)
{
    if ($res === true) {
        // Not needed for UPDATE, DELETE, etc
        return;
    }
    if (strcmp($GLOBALS['db_type'], 'mysql') == 0) {
        return mysql_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'mysqli') == 0) {
        return mysqli_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'mssql') == 0) {
        return mssql_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'oracle') == 0) {
        // Not supported. Ingore.
        if ($GLOBALS['oracle_statement'] >= 0) {
            OCIFreeStatement($GLOBALS['oracle_statement']);
            $GLOBALS['oracle_statement'] = -1;
        }
    } elseif (strcmp($GLOBALS['db_type'], 'postgresql') == 0) {
        return pg_freeresult($res);
    } elseif (strcmp($GLOBALS['db_type'], 'odbc') == 0) {
        return odbc_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'ibm_db2') == 0) {
        return db2_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'ibase') == 0) {
        return ibase_free_result($res);
    } elseif (strcmp($GLOBALS['db_type'], 'sqlite') == 0) {
        // Not supported
    } else {
        dbi_fatal_error('dbi_free_result (): ' . translate('db_type not defined.'));
    }
}
Esempio n. 15
0
        //execute SQL statement
        $row = oci_fetch_array($objQuery, OCI_ASSOC);
        if ($row !== null) {
            //test for an empty return
            echo "fname:" . $row[0];
            $fname = "";
            if ($row["obs_photo"]) {
                $fname = PATH_ROOT . "\\species\\t_" . $row["obs_photo"];
            } else {
                if ($row["lscape_photo"]) {
                    $fname = PATH_ROOT . "\\landscape\\t_" . $row["lscape_photo"];
                }
            }
            echo "fname:" . $row;
            echo "fname:" . $row["lscape_photo"];
            OCIFreeStatement($objQuery);
            if ($fname != "") {
                //Header('Content-Type: image/jpeg');
                //readfile($fname);
                echo $fname;
            }
        } else {
            $Error = "the system cannot find the file";
            //error in query
        }
    } else {
        $Error = "failed to connect to the database";
        //error in connection
    }
} else {
    $Error = "missing parameter in querystring";
Esempio n. 16
0
                    $nrow = OCIFetchStatement($stmt2, $output);
                    $cl = "class='fundo_mesclado'";
                    if ($nrow > 0) {
                        print "<br><div align=\"center\"><table border=\"0\"><tr><td class='titulo'><p align=\"center\">Ocorrência da Autorização</font></p></td></tr>";
                        for ($i = 0; $i < $nrow; $i++) {
                            reset($output);
                            print "<tr>";
                            while ($column = each($output)) {
                                $data = $column['value'];
                                print "<td {$cl}><p align=\"center\">{$data[$i]}</font></p></td>";
                            }
                            print "</tr>";
                        }
                        print "</table></div>";
                    }
                    OCIFreeStatement($stmt2);
                    $sql = "\n              select count(*) serv_apr\n              from servico_da_autorizacao sa\n              where sa.nrautorizacao = {$v_nrautorizacao}\n                    and sa.CDSITUACAO = 'AP' ";
                    $result = $db->query($sql);
                    $row = $db->fetch_array($result);
                    if ($row['SERV_APR'] > 0) {
                        //emite se tiver algum serviço aprovado
                        P_EMISSAO_AUTORIZACAO($v_nrautorizacao, $emissor, 'N', '');
                    }
                }
                break;
            }
        }
    }
}
// fim clicou no botão
OCILogoff($conn);
Esempio n. 17
0
 /**
  * Free the internal resources associated with $result.
  *
  * @param $result oci8 result identifier or DB statement identifier
  *
  * @return bool TRUE on success, FALSE if $result is invalid
  */
 function freeResult($result)
 {
     if (is_resource($result)) {
         return @OCIFreeStatement($result);
     }
     if (!isset($this->prepare_tokens[(int)$result])) {
         return false;
     }
     unset($this->prepare_tokens[(int)$result]);
     unset($this->prepare_types[(int)$result]);
     unset($this->manip_query[(int)$result]);
     return true;
 }
Esempio n. 18
0
 function _close()
 {
     OCIFreeStatement($this->_queryID);
     $this->_queryID = false;
 }
Esempio n. 19
0
 function tableInfo($result, $mode = null)
 {
     $count = 0;
     $res = array();
     /*
      * depending on $mode, metadata returns the following values:
      *
      * - mode is false (default):
      * $res[]:
      *   [0]["table"]       table name
      *   [0]["name"]        field name
      *   [0]["type"]        field type
      *   [0]["len"]         field length
      *   [0]["nullable"]    field can be null (boolean)
      *   [0]["format"]      field precision if NUMBER
      *   [0]["default"]     field default value
      *
      * - mode is DB_TABLEINFO_ORDER
      * $res[]:
      *   ["num_fields"]     number of fields
      *   [0]["table"]       table name
      *   [0]["name"]        field name
      *   [0]["type"]        field type
      *   [0]["len"]         field length
      *   [0]["nullable"]    field can be null (boolean)
      *   [0]["format"]      field precision if NUMBER
      *   [0]["default"]     field default value
      *   ['order'][field name] index of field named "field name"
      *   The last one is used, if you have a field name, but no index.
      *   Test:  if (isset($result['order']['myfield'])) { ...
      *
      * - mode is DB_TABLEINFO_ORDERTABLE
      *    the same as above. but additionally
      *   ["ordertable"][table name][field name] index of field
      *      named "field name"
      *
      *      this is, because if you have fields from different
      *      tables with the same field name * they override each
      *      other with DB_TABLEINFO_ORDER
      *
      *      you can combine DB_TABLEINFO_ORDER and
      *      DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER |
      *      DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL
      */
     // if $result is a string, we collect info for a table only
     if (is_string($result)) {
         $result = strtoupper($result);
         $q_fields = "select column_name, data_type, data_length, data_precision,\n                         nullable, data_default from user_tab_columns\n                         where table_name='{$result}' order by column_id";
         if (!($stmt = OCIParse($this->connection, $q_fields))) {
             return $this->oci8RaiseError();
         }
         if (!OCIExecute($stmt, OCI_DEFAULT)) {
             return $this->oci8RaiseError($stmt);
         }
         while (OCIFetch($stmt)) {
             $res[$count]['table'] = $result;
             $res[$count]['name'] = @OCIResult($stmt, 1);
             $res[$count]['type'] = @OCIResult($stmt, 2);
             $res[$count]['len'] = @OCIResult($stmt, 3);
             $res[$count]['format'] = @OCIResult($stmt, 4);
             $res[$count]['nullable'] = @OCIResult($stmt, 5) == 'Y' ? true : false;
             $res[$count]['default'] = @OCIResult($stmt, 6);
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$count]['name']] = $count;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$count]['table']][$res[$count]['name']] = $count;
             }
             $count++;
         }
         $res['num_fields'] = $count;
         @OCIFreeStatement($stmt);
     } else {
         // else we want information about a resultset
         if ($result === $this->last_stmt) {
             $count = @OCINumCols($result);
             for ($i = 0; $i < $count; $i++) {
                 $res[$i]['name'] = @OCIColumnName($result, $i + 1);
                 $res[$i]['type'] = @OCIColumnType($result, $i + 1);
                 $res[$i]['len'] = @OCIColumnSize($result, $i + 1);
                 $q_fields = "select table_name, data_precision, nullable, data_default from user_tab_columns where column_name='" . $res[$i]['name'] . "'";
                 if (!($stmt = OCIParse($this->connection, $q_fields))) {
                     return $this->oci8RaiseError();
                 }
                 if (!OCIExecute($stmt, OCI_DEFAULT)) {
                     return $this->oci8RaiseError($stmt);
                 }
                 OCIFetch($stmt);
                 $res[$i]['table'] = OCIResult($stmt, 1);
                 $res[$i]['format'] = OCIResult($stmt, 2);
                 $res[$i]['nullable'] = OCIResult($stmt, 3) == 'Y' ? true : false;
                 $res[$i]['default'] = OCIResult($stmt, 4);
                 OCIFreeStatement($stmt);
                 if ($mode & DB_TABLEINFO_ORDER) {
                     $res['order'][$res[$i]['name']] = $i;
                 }
                 if ($mode & DB_TABLEINFO_ORDERTABLE) {
                     $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
                 }
             }
             $res['num_fields'] = $count;
         } else {
             return $this->raiseError(DB_ERROR_NOT_CAPABLE);
         }
     }
     return $res;
 }
Esempio n. 20
0
 function nextid($seqname)
 {
     $this->connect();
     $Query_ID = @OCIParse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
     if (!@OCIExecute($Query_ID)) {
         $this->Error = @OCIError($Query_ID);
         if (2289 == $this->Error["code"]) {
             $Query_ID = OCIParse($this->Link_ID, "CREATE SEQUENCE {$seqname}");
             if (!OCIExecute($Query_ID)) {
                 $this->Error = OCIError($Query_ID);
                 $this->halt("<BR> nextid() function - unable to create sequence<br>" . $this->Error["message"]);
             } else {
                 $Query_ID = OCIParse($this->Link_ID, "SELECT {$seqname}.NEXTVAL FROM DUAL");
                 OCIExecute($Query_ID);
             }
         }
     }
     if (OCIFetch($Query_ID)) {
         $next_id = OCIResult($Query_ID, "NEXTVAL");
     } else {
         $next_id = 0;
     }
     OCIFreeStatement($Query_ID);
     return $next_id;
 }
Esempio n. 21
0
 public function freeResult($name)
 {
     OCIFreeStatement($this->result[$name]);
     unset($this->result[$name]);
 }
             pesquisa = window.open('pesqusu.php','pesquisa','dependant=yes,width=550,height=200,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,left=0,top=0,copyhistory=yes');
          }
          
          function pesq_funcionario() {
             pesquisa = window.open('pesq_funcionario.php','pesquisa','dependant=yes,width=550,height=200,directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,left=0,top=0,copyhistory=yes');
          }


         </script>
<?php 
        $today = date("d/m/Y");
        print "\n       </head>\n         <div align=\"center\"><center>\n         <body onLoad=\"placeFocus();\"  topmargin=\"4\" leftmargin=\"0\">\n           ";
        print "\n        <p align=\"center\"><img src=\"img/barra.jpg\" width=\"603\" height=\"3\"><BR><font class='tela'><em><strong>Relatório de Pré-Autorização</strong></em></font><br>\n         <img src=\"img/barra.jpg\" width=\"603\" height=\"3\"></p>\n        <form action=\"rel_pre_autorizacao.php\" target=\"principal\" method=\"POST\" name=\"yourform\" onSubmit=\"return disableForm(this);\">\n           <table>\n             <tr>\n             <td>\n              <font class=\"nome_campo\" >Autorizações de:</font>\n              </td>\n              <td>\n                <input onKeyUp=\"DateFormat(this,this.value); autoTab(this, 10, event); \" onBlur=\"DateFormat(this,this.value)\" type=\"text\" size=\"10\" maxlength=\"10\" name=\"dtin\" value=\"{$today}\">\n              <font class=\"nome_campo\"> à </font>\n                <input onKeyUp=\"DateFormat(this,this.value); return autoTab(this, 10, event);\" onBlur=\"DateFormat(this,this.value)\" type=\"text\" size=\"10\" maxlength=\"10\" name=\"dtfi\" value=\"{$today}\">\n              </td>\n              </tr> ";
        print "\n                  <tr>\n                    <td>\n                     <font class=\"nome_campo\">Código do Usuário:</font>\n                    </td>\n                    <td>\n                     <input onKeyUp=\"CodeFormat(this,this.value); return autoTab(this, 20, event);\"\n                       type=\"text\" size=\"20\" maxlength=\"20\" name=\"data1\">";
        if ($aoconsulta_usuario == 'S') {
            print "<a href=\"#\" onClick=\"javascript:abre_janela()\"><IMG SRC=\"pesq.gif\" alt=\"Pesquisa o Usuário pelo Nome\" BORDER=0></a>";
        }
        print "\n                    </td>\n                  </tr>\n                  <tr>\n                    <td>\n                     <font class=\"nome_campo\">Funcionário:</font>\n                    </td>\n                    <td>\n                     <input type=\"text\" size=\"20\" maxlength=\"20\" name=\"cdfuncionario\">\n                       <a href=\"#\" onClick=\"javascript:pesq_funcionario()\"><IMG SRC=\"pesq.gif\" alt=\"Pesquisa o Funcionário pelo Nome\" BORDER=0></a>\n                    </td>\n                  </tr>\n                  </table>";
        print "<blockquote><blockquote><blockquote>\n        <blockquote>\n               <p align=left>\n               <font class=\"nome_campo\" >   ";
        print "\n               <input type=\"radio\" name=\"r1\" value=\"U\"> Utilizadas\n           <br><input type=\"radio\" name=\"r1\" value=\"AB\"> Abertas\n           <br><input type=\"radio\" name=\"r1\" value=\"AP\"> Aprovadas\n           <br><input type=\"radio\" name=\"r1\" value=\"CA\"> Canceladas\n           <br><input type=\"radio\" name=\"r1\" value=\"RE\"> Reprovadas\n           <br><input type=\"radio\" name=\"r1\" value=\"%\" checked >Todas\n           </font>\n           </p>\n           </blockquote></blockquote></blockquote></blockquote></blockquote>\n           <blockquote><blockquote><blockquote><blockquote>";
        print "\n          <p align=left>\n          <font class=\"nome_campo\" >\n              <input type=\"radio\" name=\"r2\" value=\"1\"> Autorizações de Consultas\n          <br><input type=\"radio\" name=\"r2\" value=\"2\"> Autorizações de Exames\n          <br><input type=\"radio\" name=\"r2\" value=\"2\"> Autorizações de Internação\n          <br><input type=\"radio\" name=\"r2\" value=\"%\" checked>Todas\n          </font>\n          </p>\n           </blockquote></blockquote></blockquote></blockquote></blockquote>\n";
        print "\n          <br><input Onclick=\"return validate3();\" type=\"submit\" name=\"submit\" value=\"Pesquisar\">\n           <p align=\"center\"><img src=\"img/barra.jpg\" width=\"603\" height=\"3\"></p>\n\n        </form>\n      </body>\n      </html>";
    } else {
        if ($RESULT == '0') {
            OCIlogoff($conn);
            print "<SCRIPT LANGUAGE=JAVASCRIPT>\n               alert('Você não está autorizado a acessar esta página!');\n               window.history.back(1);\n                    </SCRIPT>";
        }
    }
    OCIFreeStatement($stmt1);
    OCIlogoff($conn);
}
Esempio n. 23
0
 /**
  * Returns information about a table or a result set
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * NOTE: flags won't contain index information.
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A DB_Error object on failure.
  *
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $res = array();
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $result = strtoupper($result);
         $q_fields = 'SELECT column_name, data_type, data_length, ' . 'nullable ' . 'FROM user_tab_columns ' . "WHERE table_name='{$result}' ORDER BY column_id";
         $this->last_query = $q_fields;
         if (!($stmt = @OCIParse($this->connection, $q_fields))) {
             return $this->oci8RaiseError(DB_ERROR_NEED_MORE_DATA);
         }
         if (!@OCIExecute($stmt, OCI_DEFAULT)) {
             return $this->oci8RaiseError($stmt);
         }
         $i = 0;
         while (@OCIFetch($stmt)) {
             $res[$i] = array('table' => $case_func($result), 'name' => $case_func(@OCIResult($stmt, 1)), 'type' => @OCIResult($stmt, 2), 'len' => @OCIResult($stmt, 3), 'flags' => @OCIResult($stmt, 4) == 'N' ? 'not_null' : '');
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
             $i++;
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         @OCIFreeStatement($stmt);
     } else {
         if (isset($result->result)) {
             /*
              * Probably received a result object.
              * Extract the result resource identifier.
              */
             $result = $result->result;
         }
         $res = array();
         if ($result === $this->last_stmt) {
             $count = @OCINumCols($result);
             if ($mode) {
                 $res['num_fields'] = $count;
             }
             for ($i = 0; $i < $count; $i++) {
                 $res[$i] = array('table' => '', 'name' => $case_func(@OCIColumnName($result, $i + 1)), 'type' => @OCIColumnType($result, $i + 1), 'len' => @OCIColumnSize($result, $i + 1), 'flags' => '');
                 if ($mode & DB_TABLEINFO_ORDER) {
                     $res['order'][$res[$i]['name']] = $i;
                 }
                 if ($mode & DB_TABLEINFO_ORDERTABLE) {
                     $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
                 }
             }
         } else {
             return $this->raiseError(DB_ERROR_NOT_CAPABLE);
         }
     }
     return $res;
 }
Esempio n. 24
0
 /**
  * Execute an SQL query with blob fields processing
  * @param String sql
  * @param Array blobs
  * @param Array blobTypes
  * @return Boolean
  */
 public function execWithBlobProcessing($sql, $blobs, $blobTypes = array())
 {
     set_error_handler("empty_error_handler");
     $locs = array();
     if (count($blobs)) {
         $idx = 1;
         $sql .= " returning ";
         $blobfields = "";
         $blobvars = "";
         foreach ($blobs as $ekey => $value) {
             if (count($locs)) {
                 $blobfields .= ",";
                 $blobvars .= ",";
             }
             $blobfields .= $ekey;
             $blobvars .= ":bnd" . $idx;
             $locs[$ekey] = OCINewDescriptor($this->conn, OCI_D_LOB);
             $idx++;
         }
         $sql .= $blobfields . " into " . $blobvars;
     }
     $stmt = OCIParse($this->conn, $sql);
     $idx = 1;
     foreach ($locs as $ekey => $value) {
         OCIBindByName($stmt, ":bnd" . $idx, $locs[$ekey], -1, OCI_B_BLOB);
         $idx++;
     }
     $result = OCIExecute($stmt, OCI_DEFAULT) !== false;
     foreach ($locs as $ekey => $value) {
         $locs[$ekey]->save($blobs[$ekey]);
         $locs[$ekey]->free();
     }
     OCICommit($this->conn);
     OCIFreeStatement($stmt);
     set_error_handler("runner_error_handler");
     return $result;
 }
 function _close()
 {
     if ($this->connection->_stmt === $this->_queryID) {
         $this->connection->_stmt = false;
     }
     OCIFreeStatement($this->_queryID);
     $this->_queryID = false;
 }
Esempio n. 26
0
 /**
  * Returns information about a table or a result set.
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * NOTE: flags won't contain index information.
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         if (MDB2::isError($connect = $db->connect())) {
             return $connect;
         }
         $result = strtoupper($result);
         $q_fields = 'SELECT column_name, data_type, data_length, ' . 'nullable ' . 'FROM user_tab_columns ' . "WHERE table_name='{$result}' ORDER BY column_id";
         $db->last_query = $q_fields;
         if (!($stmt = @OCIParse($db->connection, $q_fields))) {
             return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
         }
         if (!@OCIExecute($stmt, OCI_DEFAULT)) {
             return $db->raiseError($stmt);
         }
         $i = 0;
         while (@OCIFetch($stmt)) {
             $res[$i]['table'] = $case_func($result);
             $res[$i]['name'] = $case_func(@OCIResult($stmt, 1));
             $res[$i]['type'] = @OCIResult($stmt, 2);
             $res[$i]['len'] = @OCIResult($stmt, 3);
             $res[$i]['flags'] = @OCIResult($stmt, 4) == 'N' ? 'not_null' : '';
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
             $i++;
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         @OCIFreeStatement($stmt);
     } else {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->getResource();
         if (empty($id)) {
             return $db->raiseError();
         }
         #            if ($result === $db->last_stmt) {
         $count = @OCINumCols($id);
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = '';
             $res[$i]['name'] = $case_func(@OCIColumnName($id, $i + 1));
             $res[$i]['type'] = @OCIColumnType($id, $i + 1);
             $res[$i]['len'] = @OCIColumnSize($id, $i + 1);
             $res[$i]['flags'] = '';
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
         if ($mode) {
             $res['num_fields'] = $i;
         }
         #            } else {
         #                return $db->raiseError(MDB2_ERROR_NOT_CAPABLE);
         #            }
     }
     return $res;
 }
Esempio n. 27
0
/**
 * Frees a result set.
 *
 * @param resource $res The database query resource returned from
 *                      the {@link dbi_query()} function.
 *
 * @return bool True on success
 */
function dbi_free_result($res)
{
    if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
        return mysql_free_result($res);
    } else {
        if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
            return mysqli_free_result($res);
        } else {
            if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
                return mssql_free_result($res);
            } else {
                if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
                    // Not supported.  Ingore.
                    if ($GLOBALS["oracle_statement"] >= 0) {
                        OCIFreeStatement($GLOBALS["oracle_statement"]);
                        $GLOBALS["oracle_statement"] = -1;
                    }
                } else {
                    if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
                        return pg_freeresult($res);
                    } else {
                        if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
                            return odbc_free_result($res);
                        } else {
                            if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) {
                                return db2_free_result($res);
                            } else {
                                if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
                                    return ibase_free_result($res);
                                } else {
                                    dbi_fatal_error("dbi_free_result(): db_type not defined.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 28
0
 /**
  * Release resources allocated for the specified prepared query.
  *
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function free()
 {
     if (is_null($this->positions)) {
         return $this->db->raiseError(MDB2_ERROR, null, null, 'Prepared statement has already been freed', __FUNCTION__);
     }
     $result = MDB2_OK;
     if (!is_null($this->statement) && !@OCIFreeStatement($this->statement)) {
         $result = $this->db->raiseError(null, null, null, 'Could not free statement', __FUNCTION__);
     }
     parent::free();
     return $result;
 }
	function _close()
	{
		if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false;
		if (!empty($this->_refcursor)) {
			OCIFreeCursor($this->_refcursor);
			$this->_refcursor = false;
		}
		@OCIFreeStatement($this->_queryID);
 		$this->_queryID = false;

	}
Esempio n. 30
0
 function convert_value($var)
 {
     global $db;
     $table = $var[table];
     $cs = strtoupper($var[cs]);
     $cd = $var[cd];
     $vd = $var[vd];
     $sql = "select {$cs} from {$table} where {$cd}='{$vd}'";
     if ($var[print_query] == "1") {
         echo "{$sql}";
     }
     //	echo $sql;
     $stmt = @OCIParse($this->conn, $sql);
     @OCIExecute($stmt, OCI_DEFAULT);
     @OCIFetch($stmt);
     $result = @OCIResult($stmt, $cs);
     @OCIFreeStatement($stmt);
     return $result;
 }