function tep_db_query($query, $link = 'db_link') { global ${$link}; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { error_log('QUERY: ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $result = mysqli_query(${$link}, $query) or tep_db_error($query, mysqli_errno(${$link}), mysqli_error(${$link})); return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $logger; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (!is_object($logger)) { $logger = new logger(); } $logger->write($query, 'QUERY'); } $result = mysqli_query(${$link}, $query) or tep_db_error($query, mysqli_errno(${$link}), mysqli_error(${$link})); return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysql_error(); error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $logger; /*if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { if (!is_object($logger)) $logger = new logger; $logger->write($query, 'QUERY'); }*/ $start_time = microtime(true); $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); $time = microtime(true) - $start_time; $count++; /*if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { if (mysql_error()) $logger->write(mysql_error(), 'ERROR'); }*/ return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $logger; mysql_query("set names 'utf8'"); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (!is_object($logger)) { $logger = new logger(); } $logger->write($query, 'QUERY'); } $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (mysql_error()) { $logger->write(mysql_error(), 'ERROR'); } } return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $queries_count; $queries_count++; $start_time = microtime(true); $start_date_str = date('Ymd'); $start_time_str = date('h:i:s'); $result = @mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(${$link}), mysql_error(${$link})); $queries_duration = microtime(true) - $start_time; if ($queries_duration >= 5) { $db_time_file = @fopen(SESSION_WRITE_DIRECTORY . '/dbtimes_' . $start_date_str . '.txt', 'a'); if ($db_time_file) { //echo 'YES'; fwrite($db_time_file, '[' . date('h:i:s') . '] (' . $start_time_str . ', admin) ' . $queries_duration . ' ' . $query . ' [' . $_SERVER["REQUEST_URI"] . ']' . PHP_EOL); fclose($db_time_file); } } return $result; }
function tep_db_query($query, $link = 'db_link') { // LINE CHANGED: Added $debug global ${$link}, $debug; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $start_time = microtime(true); $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); if (class_exists('KissER')) { KissER::q(round(microtime(true) - $start_time, 4), $query); } if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysql_error(); error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } // LINE ADDED $debug['QUERIES'][] = $query; return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $debug; $query_start = microtime(); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysql_error(); error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } if (DISPLAY_QUERIES == 'true' || DISPLAY_PAGE_PARSE_TIME == 'true') { $_start = explode(' ', $query_start); $_end = explode(' ', microtime()); $_time = number_format($_end[1] + $_end[0] - ($_start[1] + $_start[0]), 6); $debug['QUERIES'][] = $query; $debug['TIME'][] = $_time; } return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}, $logger; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (!is_object($logger)) { $logger = new logger(); } $logger->write($query, 'QUERY'); } $query = preg_replace('/\\s+/', ' ', $query); //$start_time = microtime(true); $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); //$stop_time = microtime(true); //echo '<br><br>Total Records: '.mysql_num_rows($result); //echo '<br>Time taken: '.number_format($stop_time-$start_time,4); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (mysql_error()) { $logger->write(mysql_error(), 'ERROR'); } } return $result; }
function db_config() { $sql = 'SELECT configuration_group_id AS id FROM ' . TABLE_CONFIGURATION_GROUP . " WHERE configuration_group_title='Elm@r'"; $rs = tep_db_query($sql); if ($rs) { if ($row = tep_db_fetch_array($rs)) { $gid = $row['id']; echo "Elm@r-Konfigurationsgruppe gefunden: {$gid}\n"; } } if (empty($gid)) { $sql = 'INSERT INTO ' . TABLE_CONFIGURATION_GROUP . "(configuration_group_title, configuration_group_description) VALUES('Elm@r', 'Shop- und Produktdaten gemäß shopinfo.xml-Standard')"; $rs = tep_db_query($sql); if ($rs == 1) { $gid = tep_db_insert_id(); echo "Elm@r-Konfigurationsgruppe eingefügt: {$gid}\n"; } else { echo "Einfügen der Elm@r-Konfigurationsgruppe hat nicht geklappt:\n"; tep_db_error($sql, mysql_errno(), mysql_error()); } } $sql = 'SELECT COUNT(*) AS cnt FROM ' . TABLE_CONFIGURATION . ' WHERE configuration_key=\'MODULE_ELMAR_WARN_ELMAR_RENAME\''; $rs = tep_db_query($sql); if ($rs && ($row = tep_db_fetch_array($rs)) && $row['cnt'] > 0) { echo "Elm@r-Konfigurationswert vorhanden.\n"; } else { $sql = 'INSERT INTO ' . TABLE_CONFIGURATION . "(configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Verzeichnis-umbenennen-Warnung', 'MODULE_ELMAR_WARN_ELMAR_RENAME', 'False', 'Warnen, wenn das elmar-Verzeichnis noch nicht umbenannt wurde (siehe readme.html).', {$gid}, 1, 'tep_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())"; $rs = tep_db_query($sql); if ($rs == 1) { echo "Elm@r-Konfigurationswert eingefügt.\n"; } else { echo "Einfügen eines Elm@r-Konfigurationswerts hat nicht geklappt.\n"; tep_db_error($sql, mysql_errno(), mysql_error()); } } }
function tep_db_query($db_query) { global $db_link; $result = mysql_query($db_query, $db_link) or tep_db_error($db_query, mysql_errno(), mysql_error()); return $result; }
function tep_db_query($query, $link = 'db_link') { global ${$link}; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } switch (MH_DBTYPE) { case 'MYSQL': $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysql_error(); error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } return $result; break; case 'MYSQLI': $result = mysqli_query(${$link}, $query) or tep_db_error($query, mysqli_errno(${$link}), mysqli_error(${$link})); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysqli_error(${$link}); error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); } return $result; break; default: echo 'DB Type not supported'; } }
function tep_db_query($query, $link = 'db_link') { global ${$link}; $result = mysql_query($query, ${$link}) or tep_db_error($query, mysql_errno(), mysql_error()); return $result; }
/** * @param $query * @param string $link * @return resource */ function tep_db_list_query($query, $link = 'db_list_link') { global ${$link_list}; if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { if (STORE_PAGE_PARSE_TIME_PATH == 'relative') { $log_file = DIR_FS_CATALOG . STORE_PAGE_PARSE_TIME_LOG; } else { $log_file = STORE_PAGE_PARSE_TIME_LOG; } error_log('QUERY ' . $query . "\n", 3, $log_file); } // xD3bug($query,1,'127.0.0.1'); $result = mysql_query($query, ${$link_list}) or tep_db_error($query, mysql_errno(), mysql_error()); if (defined('STORE_DB_TRANSACTIONS') && STORE_DB_TRANSACTIONS == 'true') { $result_error = mysql_error(); if (STORE_PAGE_PARSE_TIME_PATH == 'relative') { $log_file = DIR_FS_CATALOG . STORE_PAGE_PARSE_TIME_LOG; } else { $log_file = STORE_PAGE_PARSE_TIME_LOG; } error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, $log_file); } return $result; }
if (session_id() != "" || isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 2592000, '/'); } session_destroy(); } if (isset($_SESSION['username'])) { //echo "You have been logged out!"; if (isset($_SESSION['last_login'])) { $last_login = $_SESSION['last_login']; $ip_address = $_SESSION['ip_address']; $username = $_SESSION['username']; $con = tep_db_connect(); if (!$con) { global ${$link}; destroy_session_and_data(); tep_db_error('Could not connect', mysqli_errno(${$link}), mysqli_error(${$link})); } $query = tep_db_query("UPDATE users SET last_login='******' WHERE username='******'"); if (!$query) { destroy_session_and_data(); die('Error: ' . mysql_error()); } $query = tep_db_query("UPDATE users SET ip_address= INET_ATON('{$ip_address}') WHERE username='******'"); if (!$query) { destroy_session_and_data(); die('Error: ' . mysql_error()); } } destroy_session_and_data(); } ?>
function tep_db_query($query) { global $session_userinfo, $db; $query_bgn = list($old_usec, $old_sec) = explode(' ', microtime()); $result = mysql_query($query, $db) or tep_db_error($query, mysql_errno(), mysql_error()); $query_end = list($new_usec, $new_sec) = explode(' ', microtime()); $runtime = (double) $new_usec + (double) $new_sec - ((double) $old_usec + (double) $old_sec); if ($runtime > 1) { //when query is too slow, log it to to a file $username = isset($session_userinfo) ? $session_userinfo['username'] : '******'; use_class('logger'); $logger = new logger('general', 'query_slow', false); $logger->write('User: '******'REQUEST_URI']); if (isset($_POST) && count($_POST) > 0) { $logger->write('--- POST vars sent ---'); foreach ($_POST as $pk => $pv) { $logger->write("{$pk} = {$pv}"); } $logger->write('--- POST vars end ---'); } $logger->write('Total Execution Time: ' . $runtime . ' seconds'); $logger->write($query); $logger->close(); } return $result; }
function tep_db_select_db($database) { if (!mysql_select_db($database)) { tep_db_error(mysql_error()); } }