Exemplo n.º 1
1
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
    if ($show_errors) {
        error_reporting(E_ALL);
    } else {
        error_reporting(E_PARSE);
    }
    // Connect to the Sybase database management system
    $link = @sybase_pconnect("192.168.231.144", "testuser", "testpass");
    if (!$link) {
        die(sybase_get_last_message());
    }
    // Make 'testdb' the current database
    $db_selected = @sybase_select_db("testdb");
    if (!$db_selected) {
        die(sybase_get_last_message());
    }
    // Print results in HTML
    print "<html><body>\n";
    // Print SQL query to test sqlmap '--string' command line option
    //print "<b>SQL query:</b> " . $query . "<br>\n";
    // Perform SQL injection affected query
    $result = sybase_query($query);
    if (!$result) {
        if ($show_errors) {
            print "<b>SQL error:</b> " . sybase_get_last_message() . "<br>\n";
        }
        exit(1);
    }
    if (!$show_output) {
        exit(1);
    }
    print "<b>SQL results:</b>\n";
    print "<table border=\"1\">\n";
    while ($line = sybase_fetch_assoc($result)) {
        print "<tr>";
        foreach ($line as $col_value) {
            print "<td>" . $col_value . "</td>";
        }
        print "</tr>\n";
        if (!$all_results) {
            break;
        }
    }
    print "</table>\n";
    print "</body></html>";
}
 /**
  * Gets the DBMS' native error message produced by the last query
  *
  * @return string  the DBMS' error message
  */
 function errorNative()
 {
     return @sybase_get_last_message();
 }
 function ErrorMsg()
 {
     if ($this->_logsql) {
         return $this->_errorMsg;
     }
     if (function_exists('sybase_get_last_message')) {
         $this->_errorMsg = sybase_get_last_message();
     } else {
         $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : 'SYBASE error messages not supported on this platform';
     }
     return $this->_errorMsg;
 }
Exemplo n.º 4
0
 function ErrorMsg()
 {
     if ($this->_logsql) {
         return $this->_errorMsg;
     }
     $this->_errorMsg = sybase_get_last_message();
     return $this->_errorMsg;
 }
Exemplo n.º 5
0
 function ErrorMsg()
 {
     $this->_errorMsg = sybase_get_last_message();
     return $this->_errorMsg;
 }
Exemplo n.º 6
0
 protected function _set_stmt_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = 'HY000';
     }
     $this->_set_error(-1, sybase_get_last_message(), $state, $mode, $func);
 }
Exemplo n.º 7
0
 public function set_driver_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = 'HY000';
     }
     $this->set_error(-1, sybase_get_last_message(), $state, $mode, $func);
 }
 /**
  * Execute any statement
  *
  * @param   string sql
  * @param   bool buffered default TRUE
  * @return  rdbms.sybase.SybaseResultSet or TRUE if no resultset was created
  * @throws  rdbms.SQLException
  */
 protected function query0($sql, $buffered = TRUE)
 {
     if (!is_resource($this->handle)) {
         if (!($this->flags & DB_AUTOCONNECT)) {
             throw new SQLStateException('Not connected');
         }
         $c = $this->connect();
         // Check for subsequent connection errors
         if (FALSE === $c) {
             throw new SQLStateException('Previously failed to connect');
         }
     }
     if (!$buffered) {
         $result = @sybase_unbuffered_query($sql, $this->handle, FALSE);
     } else {
         if ($this->flags & DB_UNBUFFERED) {
             $result = @sybase_unbuffered_query($sql, $this->handle, $this->flags & DB_STORE_RESULT);
         } else {
             $result = @sybase_query($sql, $this->handle);
         }
     }
     if (FALSE === $result) {
         $message = 'Statement failed: ' . trim(sybase_get_last_message()) . ' @ ' . $this->dsn->getHost();
         if (!is_resource($error = sybase_query('select @@error', $this->handle))) {
             // The only case selecting @@error should fail is if we receive a
             // disconnect. We could also check on the warnings stack if we can
             // find the following:
             //
             // Sybase:  Client message:  Read from SQL server failed. (severity 78)
             //
             // but that seems a bit errorprone.
             throw new SQLConnectionClosedException($message, $sql);
         }
         $code = current(sybase_fetch_row($error));
         switch ($code) {
             case 1205:
                 // Deadlock
                 throw new SQLDeadlockException($message, $sql, $code);
             default:
                 // Other error
                 throw new SQLStatementFailedException($message, $sql, $code);
         }
     }
     return TRUE === $result ? $result : new SybaseResultSet($result, $this->tz);
 }
Exemplo n.º 9
0
 /**
  * Error
  *
  * Returns an array containing code and message of the last
  * database error that has occured.
  *
  * @return	array
  */
 public function error()
 {
     //return array('code' => $query->code, 'message' => sybase_get_last_message());
     return array('code' => '', 'message' => sybase_get_last_message());
 }
Exemplo n.º 10
0
 /**
  * Return the last error message
  * @return string
  */
 protected function get_error()
 {
     return sybase_get_last_message();
 }
Exemplo n.º 11
0
 /**
  * Returns the error string.
  * 
  * @return string
  */
 function error()
 {
     return sybase_get_last_message();
 }
Exemplo n.º 12
0
 public function error()
 {
     if (!empty($this->connect)) {
         return sybase_get_last_message();
     } else {
         return false;
     }
 }
Exemplo n.º 13
0
 function _setDbError($query, $errors = null)
 {
     return $this->_setLastError('Error! ', sybase_get_last_message() . strip_tags($errors), $query);
 }