Пример #1
0
 /**
  * Execute an sqlQuery.
  *
  * Execute a query the query string and database connexion object need
  * to be passe has parameters or be previously define.
  *
  * @param string $sql   String with the SQL Query.
  * @param object sqlConnect $dbCon   Connexion object if not previously define in the contructor.
  * @return ResultSet $rquery
  * @access public
  */
 function query($sql = "", $dbCon = 0)
 {
     if ($dbCon != 0) {
         $this->dbCon = $dbCon;
     }
     if (strlen($sql) > 0) {
         $this->sql_query = trim($sql);
     }
     if (!is_resource($this->dbCon->id)) {
         $this->setError("Query Error: No open or valid connexion has been provide to execute the query: " . $this->sql_query);
         return false;
     }
     if (empty($this->sql_query)) {
         //    $this->setError("No query to execute.:".var_export(get_object_vars($this), true));
         $this->setLog(" query(): No query to execute.");
         return false;
     }
     if ($this->max_rows) {
         if (!$this->pos) {
             $this->pos = 0;
         }
         $qpos = " limit " . $this->pos . ", " . $this->max_rows;
     } else {
         if (!$this->pos) {
             $this->pos = "";
         }
         $qpos = $this->pos;
     }
     /** Temporary for ";" compatibility with postgresql **/
     //  if (substr($this->sql_query, -1,1) == ";") {
     //      $this->sql_query = substr($this->sql_query, 0, strlen($this->sql_query)-1) ;
     //  }
     // This is to fix the mysql_select_db problem when connexion have same username.
     if ($this->dbCon->getAllwaysSelectDb()) {
         $this->dbCon->setDatabase($this->dbCon->getDatabase());
         //echo $this->dbCon->getDatabase();
     }
     // convert quote from postgresql queries
     // this was a bad idea, break wordpress install for example!!!
     //$this->sql_query=str_replace('"', '`',$this->sql_query);
     if ($this->dbCon->getUseCluster()) {
         if (preg_match("/^select/i", $this->sql_query)) {
             $this->query_connexion = $this->dbCon->id;
         } else {
             $this->query_connexion = $this->dbCon->wid;
         }
     } else {
         $this->query_connexion = $this->dbCon->id;
     }
     if (preg_match("/^select/i", $this->sql_query)) {
         $rquery = mysql_query($this->sql_query . " " . $this->sql_order . " " . $qpos, $this->query_connexion);
         $this->setLog($this->sql_query . " " . $this->sql_order . " " . $qpos);
     } else {
         $rquery = mysql_query($this->sql_query, $this->query_connexion);
         $this->setLog($this->sql_query);
     }
     $sqlerror = "";
     if (!is_resource($rquery)) {
         $sqlerror = mysql_error($this->query_connexion);
         if (!empty($sqlerror)) {
             $this->setError("<b>SQL Query Error :</b>" . mysql_errno($this->query_connexion) . " - " . $sqlerror . " (" . $this->sql_query . ")");
         }
     }
     if (!$this->max_rows) {
         $this->num_rows = @mysql_num_rows($rquery);
     }
     //$this->insert_id = mysql_insert_id() ;
     $this->insert_id = 0;
     $this->result = $rquery;
     $this->cursor = 0;
     if ($this->dbCon->getBackupSync()) {
         if (preg_match("/^alter/i", $this->sql_query) || preg_match("/^create/i", $this->sql_query) || preg_match("/^drop/i", $this->sql_query)) {
             if ($this->dbCon->getUseDatabase()) {
                 $qInsSync = "insert into " . $this->dbCon->getTableBackupSync() . " ( actiontime, sqlstatement, dbname) values ( '" . time() . "', '" . addslashes($this->sql_query) . "', '" . $this->dbCon->db . "') ";
                 $rquery = mysql_query($qInsSync, $this->dbCon->id);
             } else {
                 $file = $this->dbCon->getProjectDirectory() . "/" . $this->dbCon->getTableBackupSync() . ".struct.sql";
                 $fp = fopen($file, "a");
                 $syncquery = $this->sql_query . ";\n";
                 fwrite($fp, $syncquery, strlen($syncquery));
                 fclose($fp);
             }
         }
         if (preg_match("/^insert/i", $this->sql_query) || preg_match("/^update/i", $this->sql_query) || preg_match("/^delete/i", $this->sql_query)) {
             if ($this->dbCon->getUseDatabase()) {
                 $qInsSync = "insert into " . $this->dbCon->getTableBackupSync() . " ( actiontime, sqlstatement, dbname) values ( '" . time() . "', '" . addslashes($this->sql_query) . "', '" . $this->dbCon->db . "') ";
                 $rquery = mysql_query($qInsSync, $this->dbCon->id);
             } else {
                 $file = $this->dbCon->getProjectDirectory() . "/" . $this->dbCon->getTableBackupSync() . ".data.sql";
                 $fp = fopen($file, "a");
                 $syncquery = $this->sql_query . ";\n";
                 fwrite($fp, $syncquery, strlen($syncquery));
                 fclose($fp);
             }
         }
     }
     return $rquery;
 }
Пример #2
0
//  Change the default events parameters times out
//  $cfg_event_param_garbage_time_out = 3600;
//  $cfg_event_param_garbage_interval = 3400;
//Radria usage statistics:
$cfg_radria_stat_usage = true;
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if (file_exists($GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php')) {
    include_once $GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php';
}
$cfg_web_path = dirname($_SERVER['PHP_SELF']);
if (!ereg("/\$", $cfg_web_path)) {
    $cfg_web_path .= "/";
}
session_set_cookie_params(0, $cfg_web_path);
session_start();
//include("includes/lang_".$cfg_lang.".inc.php") ;
//$_SESSION["cfg_lang"] = $cfg_lang ;
// Database connexions :
//Uncomment bellow if you plan to use a database
$conx = new sqlConnect("@login", "@password");
$conx->setHostname("@hostname");
$conx->setDatabase("@database");
// Directory where pas is located
$conx->setBaseDirectory($cfg_local_pasdir);
// Directory where the project is located unless your config.php file is outside your project tree is should be "./"
$conx->setProjectDirectory($cfg_full_path . "./");
//$conx->start() ;
include "includes/globalvar.inc.php";
if (file_exists("includes/extraconfig_postdb.inc.php")) {
    include_once "includes/extraconfig_postdb.inc.php";
}
Пример #3
0
 /**
  * Execute an sqlQuery.
  *
  * Execute a query the query string and database connexion object need
  * to be passe has parameters or be previously define.
  *
  * @param string $sql   String with the SQL Query.
  * @param object sqlConnect $dbCon   Connexion object if not previously define in the contructor.
  * @return ResultSet $rquery
  * @access public
  */
 function query($sql = "", $dbCon = 0)
 {
     if ($dbCon != 0) {
         $this->dbCon = $dbCon;
     }
     if (strlen($sql) > 0) {
         $this->sql_query = trim($sql);
     }
     if (!is_resource($this->dbCon->id)) {
         $this->setError("Query Error: No open or valid connexion has been provide to execute the query: " . $this->sql_query);
     }
     if ($this->sql_query == "") {
         if (is_array($this->table)) {
             reset($this->table);
             $this->sql_query = "select * from ";
             while (list($key, $table) = each($this->table)) {
                 $this->sql_query .= $table . ",";
             }
             $this->sql_query = ereg_replace(",\$", "", $this->sql_query);
         } else {
             $this->sql_query = "select * from {$this->table}";
         }
     }
     if ($this->max_rows) {
         if (!$this->pos) {
             $this->pos = 0;
         }
         $qpos = " limit " . $this->pos . ", " . $this->max_rows;
     } else {
         if (!$this->pos) {
             $this->pos = "";
         }
         $qpos = $this->pos;
     }
     if ($this->dbCon->getAllwaysSelectDb()) {
         $this->dbCon->setDatabase($this->dbCon->getDatabase());
     }
     $rquery = odbc_exec($this->dbCon->id, "{$this->sql_query} {$this->sql_order} {$qpos}");
     if (!is_resource($rquery)) {
         $sqlerror = odbc_errormsg();
         if ($sqlerror) {
             $this->setError("<b>SQL Query Error :</b>" . $sqlerror . " ({$this->sql_query} {$this->sql_order} {$qpos})");
         }
     }
     if (!$this->max_rows) {
         $this->num_rows = @odbc_num_rows($rquery);
     }
     $this->insert_id = 0;
     $this->result = $rquery;
     $this->cursor = 0;
     if ($this->dbCon->getBackupSync()) {
         if (eregi("^alter", $this->sql_query) || eregi("^create", $this->sql_query) || eregi("^drop", $this->sql_query)) {
             if ($this->dbCon->getUseDatabase()) {
                 $qInsSync = "insert into " . $this->dbCon->getTableBackupSync() . " ( actiontime, sqlstatement, dbname) values ( '" . time() . "', '" . addslashes($this->sql_query) . "', '" . $this->dbCon->db . "') ";
                 $rquery = odbc_exec($this->dbCon->id, $qInsSync);
             } else {
                 $file = $this->dbCon->getProjectDirectory() . "/" . $this->dbCon->getTableBackupSync() . ".struct.sql";
                 $fp = fopen($file, "a");
                 $syncquery = $this->sql_query . ";\n";
                 fwrite($fp, $syncquery, strlen($syncquery));
                 fclose($fp);
             }
         }
         if (eregi("^insert", $this->sql_query) || eregi("^update", $this->sql_query) || eregi("^delete", $this->sql_query)) {
             if ($this->dbCon->getUseDatabase()) {
                 $qInsSync = "insert into " . $this->dbCon->getTableBackupSync() . " ( actiontime, sqlstatement, dbname) values ( '" . time() . "', '" . addslashes($this->sql_query) . "', '" . $this->dbCon->db . "') ";
                 $rquery = odbc_exec($this->dbCon->id, $qInsSync);
             } else {
                 $file = $this->dbCon->getProjectDirectory() . "/" . $this->dbCon->getTableBackupSync() . ".data.sql";
                 $fp = fopen($file, "a");
                 $syncquery = $this->sql_query . ";\n";
                 fwrite($fp, $syncquery, strlen($syncquery));
                 fclose($fp);
             }
         }
     }
     return $rquery;
 }
Пример #4
0
$cfg_notrefererequestkey = "XX5X5XC7C5CFF7FC7C65FCD7FGGFD7FR22462";
//Radria anonymous usage statistics:
$cfg_radria_stat_usage = true;
// Turn off errors display on production site
// or when using the pas pagebuilder
//error_reporting(0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if (file_exists($GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php')) {
    include_once $GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php';
}
$cfg_web_path = dirname($_SERVER['PHP_SELF']);
if (!ereg("/\$", $cfg_web_path)) {
    $cfg_web_path .= "/";
}
session_set_cookie_params(0, $cfg_web_path);
session_start();
//include("includes/lang_".$cfg_lang.".inc.php") ;
//$_SESSION["cfg_lang"] = $cfg_lang ;
// Database connexions :
$conx = new sqlConnect("radria", "sample");
$conx->setHostname("localhost");
$conx->setDatabase("RadriaSample");
// Directory where pas is located
$conx->setBaseDirectory($cfg_local_pasdir);
// Directory where the project is located unless your config.php file is outside your project tree is should be "./"
$conx->setProjectDirectory($cfg_full_path . "./");
$conx->start();
include "includes/globalvar.inc.php";
if (file_exists("includes/extraconfig_postdb.inc.php")) {
    include_once "includes/extraconfig_postdb.inc.php";
}
Пример #5
0
$cfg_notrefererequestkey = "@refererkey";
//Radria anonymous usage statistics:
$cfg_radria_stat_usage = true;
// Turn off errors display on production site
// or when using the pas pagebuilder
//error_reporting(0);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if (file_exists($GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php')) {
    include_once $GLOBALS['cfg_full_path'] . 'includes/extraconfig.inc.php';
}
$cfg_web_path = dirname($_SERVER['PHP_SELF']);
if (!ereg("/\$", $cfg_web_path)) {
    $cfg_web_path .= "/";
}
session_set_cookie_params(0, $cfg_web_path);
session_start();
//include("includes/lang_".$cfg_lang.".inc.php") ;
//$_SESSION["cfg_lang"] = $cfg_lang ;
// Database connexions :
$conx = new sqlConnect("ofuzdev", "d3v5");
$conx->setHostname("localhost");
$conx->setDatabase("ofuz");
// Directory where pas is located
$conx->setBaseDirectory($cfg_local_pasdir);
// Directory where the project is located unless your config.php file is outside your project tree is should be "./"
$conx->setProjectDirectory($cfg_full_path . "./");
$conx->start();
include "includes/globalvar.inc.php";
if (file_exists("includes/extraconfig_postdb.inc.php")) {
    include_once "includes/extraconfig_postdb.inc.php";
}