/** * Perform mySQL query * * Added to the original function: logging of all queries * * @since 1.7 */ function query($query) { // Keep history of all queries $this->debug_log[] = $query; // Original function return parent::query($query); }
/** * Perform mySQL query * * Added to the original function: logging of all queries * * @since 1.7 */ function query($query) { $select_query = strtolower(trim(current(explode(' ', $query)))); // If it is a select query on URL (YOURLS_DB_TABLE_URL) table, send to SLAVE if ($select_query == 'select' && (strstr(strtolower($query), 'from `' . YOURLS_DB_TABLE_URL . '`') != '' || strstr(strtolower($query), 'from ' . YOURLS_DB_TABLE_URL) != '')) { $dbuser = YOURLS_SLAVE_DB_USER; $dbpassword = YOURLS_SLAVE_DB_PASS; $dbname = YOURLS_SLAVE_DB_NAME; $dbhost = YOURLS_SLAVE_DB_HOST; } else { $dbuser = YOURLS_DB_USER; $dbpassword = YOURLS_DB_PASS; $dbname = YOURLS_DB_NAME; $dbhost = YOURLS_DB_HOST; } $this->dbuser = $dbuser; $this->dbpassword = $dbpassword; $this->dbname = $dbname; // Get custom port if any if (false !== strpos($dbhost, ':')) { list($dbhost, $dbport) = explode(':', $dbhost); $dbhost = sprintf('%1$s;port=%2$d', $dbhost, $dbport); } $this->dbhost = $dbhost; // $this->encoding = $encoding; $dsn = 'mysql:host=' . $dbhost . ';dbname=' . $dbname; $this->dsn = $dsn; $this->connect($dsn, $dbuser, $dbpassword); // Keep history of all queries $this->debug_log[] = $query; // Original function return parent::query($query); }
require "config.php"; //这里的引用来自php.ini的公用include require "ez_sql/ez_sql_core.php"; require "ez_sql/ez_sql_pdo.php"; require "smarty/Smarty.class.php"; require "comm/class/SqlText.php"; require "comm/class/Page.php"; require "comm/class/Runtime.php"; require "comm/functions.php"; require "comm/share.php"; $curr_file_name = strtolower(self()); $runtime = new runtime(); $db = new ezSQL_pdo($db_cfg["connect"], $db_cfg["user"], $db_cfg["pwd"]); if (strpos($db_cfg["connect"], "mysql") !== false) { $db->query("SET NAMES " . constant("WEB_CHARSET")); } define("SMARTY_PATH", "smarty/"); $smarty = new Smarty(); $smarty->template_dir = "html/"; $smarty->compile_dir = constant("SMARTY_PATH") . "templates_c/"; $smarty->config_dir = constant("SMARTY_PATH") . "configs/"; $smarty->cache_dir = constant("SMARTY_PATH") . "cache/"; $page = new Page(); $page->pageIndexName = "page"; $page->firstText = "首页"; $page->prevText = "上一页"; $page->nextText = "下一页"; $page->lastText = "末页"; $novalid = array(); $novalid[] = "admin_articlesingle.php";