Example #1
0
 public static function GetInstance($connenctionType = 'readonly', $databaseName = '')
 {
     if (!isset(self::$mInstance) || self::$mInstance->mConnenctionType != $connenctionType || self::$mInstance->mDatabaseName != $databaseName) {
         $thisClass = __CLASS__;
         self::$mInstance = new $thisClass($connenctionType, $databaseName);
     }
     return self::$mInstance;
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     $this->table = 'items';
 }
Example #3
0
 public function GetBasicClientDetailByClientHash(&$recordSet, $clh)
 {
     if ($clh != '') {
         $sql = "SELECT\r\n\t\t\t\t\t\ttbl_client.id_client AS 'id_client',\r\n\t\t\t\t\t\ttbl_client.client_name AS 'client_name',\r\n\t\t\t\t\t\ttbl_client.client_email AS 'client_email'\r\n\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tFROM\t\r\n\t\t\t\t\t\ttbl_client \r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\ttbl_client.client_hash = '" . mysql_escape_string($clh) . "' \r\n\t\t\t\t\tLIMIT 1";
         $errors = PDODB::getInstance()->Query($querySuccess, $sql, $recordSet, $recordSetSize);
     }
 }
 /**
  * Method to avoid DELETE with JOIN statement.
  *
  * wp-admin/includes/upgrade.php contains 'DELETE ... JOIN' statement.
  * This query can't be replaced with regular expression or udf, so we
  * replace all the statement with another. But this query was used in
  * the very old version of WordPress when it was upgraded. So we won't
  * have no chance that this method should be used.
  *
  * @access private
  */
 private function delete_workaround()
 {
     global $wpdb;
     $pattern = "DELETE o1 FROM {$wpdb->options} AS o1 JOIN {$wpdb->options} AS o2";
     $pattern2 = "DELETE a, b FROM {$wpdb->sitemeta} AS a, {$wpdb->sitemeta} AS b";
     $rewritten = "DELETE FROM {$wpdb->options} WHERE option_id IN (SELECT MIN(option_id) FROM {$wpdb->options} GROUP BY option_name HAVING COUNT(*) > 1)";
     if (stripos($this->_query, $pattern) !== false) {
         $this->_query = $rewritten;
     } else {
         if (stripos($this->_query, $pattern2) !== false) {
             $time = time();
             $prep_query = "SELECT a.meta_id AS aid, b.meta_id AS bid FROM {$wpdb->sitemeta} AS a INNER JOIN {$wpdb->sitemeta} AS b ON a.meta_key='_site_transient_timeout_'||substr(b.meta_key, 17) WHERE b.meta_key='_site_transient_'||substr(a.meta_key, 25) AND a.meta_value < {$time}";
             $_wpdb = new PDODB();
             $ids = $_wpdb->get_results($prep_query);
             foreach ($ids as $id) {
                 $ids_to_delete[] = $id->aid;
                 $ids_to_delete[] = $id->bid;
             }
             $rewritten = "DELETE FROM {$wpdb->sitemeta} WHERE meta_id IN (" . implode(',', $ids_to_delete) . ")";
             $this->_query = $rewritten;
         }
     }
 }
 public function __construct($config)
 {
     $this->config = $config;
     $this->_dao = PDODB::getInstance($config['db']);
 }
<?php

include_once "system_config.php";
include_once $server_path . "htdocs/titan_for_allpay/PDO_SQL.php";
include_once $server_path . 'htdocs/g_common.inc';
include_once $server_path . 'htdocs/g_rootch_root.inc';
include_once $server_path . 'htdocs/g_rootchTOP.inc';
//$_POST["send_data_"] = "616374696F6E5F747970653D71756572795F6461746126735F796561723D3230313326735F6D6F6E74683D313026735F6461793D323926735F686F75723D313626655F796561723D3230313326655F6D6F6E74683D313026655F6461793D323926655F686F75723D313626616C6C7061795F6769643D26616C6C7061795F6D69643D26736F72745F72756C653D3126636F727069643D3239303834383233";
$pdo_sql = new PDODB($db_host, $db_name, $db_user, $db_pwd);
$recive_str = web_js_decode($_POST["send_data_"]);
parse_str($recive_str, $recive_array);
$return_array = array("state" => "", "message" => "", "result" => "");
if (!isset($recive_array["action_type"]) && $return_array["state"] == "") {
    $return_array = array("state" => "ERROR", "message" => "請勿亂嘗試", "result" => "");
}
if ($return_array["state"] == "" && $recive_array["action_type"] == "query_data") {
    foreach ($recive_array as $key => $value) {
        ${$key} = $value;
    }
    $start_date = $s_year . $s_month . $s_day . $s_hour . "0000";
    $start_end = $e_year . $e_month . $e_day . $e_hour . "5959";
    $sql_syntax = "\n        CREATE TEMPORARY TABLE temp_merchant_info AS(\n            SELECT client,allpayMID,percen,corpname,webname,corpid  FROM o_user WHERE allpayMID!=7 [+++allpay_mid_rule+++]  [+++corpid+++] [+++allpay_gid_rule+++]\n        );";
    if ($corpid == "") {
        $sql_syntax = str_replace("[+++corpid+++]", "", $sql_syntax);
    } else {
        $sql_cropid = $pdo_sql->sql_injection($corpid);
        $sql_syntax = str_replace("[+++corpid+++]", "AND corpid={$sql_cropid}", $sql_syntax);
    }
    if ($allpay_gid == "") {
        $sql_syntax = str_replace("[+++allpay_gid_rule+++]", "", $sql_syntax);
    } else {
Example #7
0
<?php

header('Content-type: text/html; charset=utf-8');
$config = (require './config.php');
require './PDODB.class.php';
$_dao = PDODB::getInstance($config['db']);
$_backAddress = $_POST['BackAddress'];
$_backAccount = $_POST['BackAccount'];
$_backPwd = $_POST['BackPassword'];
$_FTPAddress = $_POST['FTPAddress'];
$_FTPAccount = $_POST['FTPAccount'];
$_FTPPwd = $_POST['FTPPassword'];
$sql = "insert into dos_webinfo (BackAddress,BackAccount,BackPassword,FTPAccount,FTPAddress,FTPPassword) values ('{$_backAddress}','{$_backAccount}','{$_backPwd}','{$_FTPAddress}','{$_FTPAccount}','{$_FTPPwd}')";
$result = $_dao->query($sql);
if ($result) {
    header("Location:./index.php");
}
 /**
  * Function to handle ALTER COLUMN.
  *
  * @access private
  * @param array of string $queries
  * @return string|array of string
  */
 private function handle_alter_command($queries)
 {
     $tokenized_query = $queries;
     $temp_table = 'temp_' . $tokenized_query['table_name'];
     if (isset($tokenized_query['default_value'])) {
         $def_value = $this->convert_field_types($tokenized_query['column_name'], $tokenized_query['default_value']);
         $def_value = 'DEFAULT ' . $def_value;
     } else {
         $def_value = null;
     }
     $_wpdb = new PDODB();
     $query_obj = $_wpdb->get_results("SELECT sql FROM sqlite_master WHERE tbl_name='{$tokenized_query['table_name']}'");
     $_wpdb = null;
     for ($i = 0; $i < count($query_obj); $i++) {
         $index_queries[$i] = $query_obj[$i]->sql;
     }
     $create_query = array_shift($index_queries);
     if (stripos($create_query, $tokenized_query['column_name']) === false) {
         return 'SELECT 1=1';
     }
     if (preg_match("/\\s*({$tokenized_query['column_name']})\\s*(.*)?(DEFAULT\\s*.*)[,)]/im", $create_query, $match)) {
         $col_name = trim($match[1]);
         $col_def = trim($match[2]);
         $col_def_esc = str_replace(array('(', ')'), array('\\(', '\\)'), $col_def);
         $checked_col_def = $this->convert_field_types($col_name, $col_def);
         $old_default = trim($match[3]);
         $pattern = "/{$col_name}\\s*{$col_def_esc}\\s*{$old_default}/im";
         if (is_null($def_value)) {
             $replacement = $col_name . ' ' . $checked_col_def;
         } else {
             $replacement = $col_name . ' ' . $checked_col_def . ' ' . $def_value;
         }
         $create_query = preg_replace($pattern, $replacement, $create_query);
         $create_query = str_ireplace($tokenized_query['table_name'], $temp_table, $create_query);
     } elseif (preg_match("/\\s*({$tokenized_query['column_name']})\\s*(.*)?[,)]/im", $create_query, $match)) {
         $col_name = trim($match[1]);
         $col_def = trim($match[2]);
         $col_def_esc = str_replace(array('(', ')'), array('\\(', '\\)'), $col_def);
         $checked_col_def = $this->convert_field_types($col_name, $col_def);
         $pattern = "/{$col_name}\\s*{$col_def_esc}/im";
         if (is_null($def_value)) {
             $replacement = $col_name . ' ' . $checked_col_def;
         } else {
             $replacement = $col_name . ' ' . $checked_col_def . ' ' . $def_value;
         }
         $create_query = preg_replace($pattern, $replacement, $create_query);
         $create_query = str_ireplace($tokenized_query['table_name'], $temp_table, $create_query);
     } else {
         return 'SELECT 1=1';
     }
     $query[] = $create_query;
     $query[] = "INSERT INTO {$temp_table} SELECT * FROM {$tokenized_query['table_name']}";
     $query[] = "DROP TABLE IF EXISTS {$tokenized_query['table_name']}";
     $query[] = "ALTER TABLE {$temp_table} RENAME TO {$tokenized_query['table_name']}";
     foreach ($index_queries as $index) {
         $query[] = $index;
     }
     return $query;
 }
 /**
  * Callback method for rewrite_key.
  *
  * @param array	$matches	an array of matches from the Regex
  * @access private
  */
 private function _rewrite_key($matches)
 {
     $index_name = trim($matches[2]);
     $col_name = trim($matches[3]);
     if (preg_match('/\\([0-9]+?\\)/', $col_name, $match)) {
         $col_name = preg_replace_callback('/\\([0-9]+?\\)/', array($this, '_remove_length'), $col_name);
     }
     $tbl_name = $this->table_name;
     $_wpdb = new PDODB();
     $results = $_wpdb->get_results("SELECT name FROM sqlite_master WHERE type='index'");
     $_wpdb = null;
     if ($results) {
         foreach ($results as $result) {
             if ($result->name == $index_name) {
                 $r = rand(0, 50);
                 $index_name = $index_name . "_{$r}";
                 break;
             }
         }
     }
     $this->index_queries[] = 'CREATE INDEX ' . $index_name . ' ON ' . $tbl_name . $col_name;
     return '';
 }
Example #10
0
 /**
  * Executes query returns the db resultset in an array
  * @param string $query The query string to execute
  * @param array $params The values to be set for the query
  * @param integer $QueryType The type of query
  * @return array
  */
 public static function ExecuteQueryArray($query, $params = null, $QueryType = QueryType::Text)
 {
     $PDODB = new PDODB();
     if ($QueryType == QueryType::Text) {
         $PDODB->ExecuteQuery($query, $params);
         return $PDODB->GetDataArray();
     } else {
         $query_str = SystemQueries::GetQuery($query);
         $PDODB->ExecuteQuery($query_str->query_text, $params);
         return $PDODB->GetDataArray();
     }
 }
 public function StoreNewClient($newClientData)
 {
     $insertId = 0;
     if (sizeof($newClientData) > 0) {
         //print_r( $newClientData ); exit;
         $errors = PDODB::getInstance('readwrite')->InsertQueryReturnId($insertId, $newClientData, 'tbl_client');
         if ($insertId > 0) {
             $emailResult = $this->SendConfirmationSignupEmail($newClientData['client_email'], $newClientData);
             //echo $emailResult; exit;
         }
     }
     return $insertId;
 }