From acc5253f7170bd611135c046cfc32f41b2857faf Mon Sep 17 00:00:00 2001 From: nanosimbiot Date: Sat, 30 Jul 2011 13:10:05 +0000 Subject: [PATCH] r179 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Отображение всех логов кеша в дебагере git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@179 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293 --- upload/common.php | 521 +++++++++++++++++++++++++----- upload/config.php | 2 +- upload/includes/functions_dev.php | 22 +- upload/includes/sphinxapi.php | 40 +-- 4 files changed, 477 insertions(+), 108 deletions(-) diff --git a/upload/common.php b/upload/common.php index 0262e89ed..7b691a135 100644 --- a/upload/common.php +++ b/upload/common.php @@ -255,20 +255,72 @@ class cache_common { return false; } + + var $num_queries = 0; + var $sql_starttime = 0; + var $sql_inittime = 0; + var $sql_timetotal = 0; + var $cur_query_time = 0; + + var $dbg = array(); + var $dbg_id = 0; + var $dbg_enabled = false; + var $cur_query = null; + + function debug ($mode, $cur_query = null) + { + if (!$this->dbg_enabled) return; + + $id =& $this->dbg_id; + $dbg =& $this->dbg[$id]; + + if ($mode == 'start') + { + $this->sql_starttime = utime(); + + $dbg['sql'] = isset($cur_query) ? short_query($cur_query) : short_query($this->cur_query); + $dbg['src'] = $this->debug_find_source(); + $dbg['file'] = $this->debug_find_source('file'); + $dbg['line'] = $this->debug_find_source('line'); + $dbg['time'] = ''; + } + else if ($mode == 'stop') + { + $this->cur_query_time = utime() - $this->sql_starttime; + $this->sql_timetotal += $this->cur_query_time; + $dbg['time'] = $this->cur_query_time; + $id++; + } + } + + function debug_find_source ($mode = '') + { + foreach (debug_backtrace() as $trace) + { + if ($trace['file'] !== __FILE__) + { + switch ($mode) + { + case 'file': return $trace['file']; + case 'line': return $trace['line']; + default: return hide_bb_path($trace['file']) .'('. $trace['line'] .')'; + } + } + } + return 'src not found'; + } } class cache_memcache extends cache_common { var $used = true; - + var $engine = 'Memcache'; var $cfg = null; var $memcache = null; var $connected = false; function cache_memcache ($cfg) { - global $bb_cfg; - if (!$this->is_installed()) { die('Error: Memcached extension not installed'); @@ -276,12 +328,16 @@ class cache_memcache extends cache_common $this->cfg = $cfg; $this->memcache = new Memcache; + $this->dbg_enabled = sql_dbg_enabled(); } function connect () { $connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect'; + $this->cur_query = $connect_type .' '. $this->cfg['host'] .':'. $this->cfg['port']; + $this->debug('start'); + if (@$this->memcache->$connect_type($this->cfg['host'], $this->cfg['port'])) { $this->connected = true; @@ -293,23 +349,47 @@ class cache_memcache extends cache_common { die('Could not connect to memcached server'); } + + $this->debug('stop'); + $this->cur_query = null; } function get ($name) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->get('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return ($this->connected) ? $this->memcache->get($name) : false; } function set ($name, $value, $ttl = 0) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return ($this->connected) ? $this->memcache->set($name, $value, false, $ttl) : false; } function rm ($name) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return ($this->connected) ? $this->memcache->delete($name) : false; } @@ -417,7 +497,7 @@ class cache_sqlite extends cache_common } } -class sqlite_common extends cache_dbg_common +class sqlite_common extends cache_common { var $cfg = array( 'db_file_path' => 'sqlite.db', @@ -569,75 +649,16 @@ class sqlite_common extends cache_dbg_common } } -class cache_dbg_common -{ - var $num_queries = 0; - var $sql_starttime = 0; - var $sql_inittime = 0; - var $sql_timetotal = 0; - var $cur_query_time = 0; - - var $dbg = array(); - var $dbg_id = 0; - var $dbg_enabled = false; - var $cur_query = null; - - function debug ($mode, $cur_query = null) - { - if (!$this->dbg_enabled) return; - - $id =& $this->dbg_id; - $dbg =& $this->dbg[$id]; - - if ($mode == 'start') - { - $this->sql_starttime = utime(); - - $dbg['sql'] = isset($cur_query) ? short_query($cur_query) : short_query($this->cur_query); - $dbg['src'] = $this->debug_find_source(); - $dbg['file'] = $this->debug_find_source('file'); - $dbg['line'] = $this->debug_find_source('line'); - $dbg['time'] = ''; - } - else if ($mode == 'stop') - { - $this->cur_query_time = utime() - $this->sql_starttime; - $this->sql_timetotal += $this->cur_query_time; - $dbg['time'] = $this->cur_query_time; - $id++; - } - } - - function debug_find_source ($mode = '') - { - foreach (debug_backtrace() as $trace) - { - if ($trace['file'] !== __FILE__) - { - switch ($mode) - { - case 'file': return $trace['file']; - case 'line': return $trace['line']; - default: return hide_bb_path($trace['file']) .'('. $trace['line'] .')'; - } - } - } - return 'src not found'; - } -} - class cache_redis extends cache_common { var $used = true; - + var $engine = 'Redis'; var $cfg = null; var $redis = null; var $connected = false; function cache_redis ($cfg) { - global $bb_cfg; - if (!$this->is_installed()) { die('Error: Redis extension not installed'); @@ -645,10 +666,14 @@ class cache_redis extends cache_common $this->cfg = $cfg; $this->redis = new Redis(); + $this->dbg_enabled = sql_dbg_enabled(); } function connect () { + $this->cur_query = 'connect '. $this->cfg['host'] .':'. $this->cfg['port']; + $this->debug('start'); + if (@$this->redis->connect($this->cfg['host'], $this->cfg['port'])) { $this->connected = true; @@ -658,23 +683,42 @@ class cache_redis extends cache_common { die('Could not connect to redis server'); } + + $this->debug('stop'); + $this->cur_query = null; } function get ($name) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->get('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return ($this->connected) ? unserialize($this->redis->get($name)) : false; } function set ($name, $value, $ttl = 0) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + if($this->redis->set($name, serialize($value))) { if ($ttl > 0) { $this->redis->expire($name, $ttl); } + + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return true; } else @@ -686,6 +730,13 @@ class cache_redis extends cache_common function rm ($name) { if (!$this->connected) $this->connect(); + + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return ($this->connected) ? $this->redis->del($name) : false; } @@ -697,7 +748,8 @@ class cache_redis extends cache_common class cache_eaccelerator extends cache_common { - var $used = true; + var $used = true; + var $engine = 'eAccelerator'; function cache_eaccelerator () { @@ -705,20 +757,39 @@ class cache_eaccelerator extends cache_common { die('Error: eAccelerator extension not installed'); } + $this->dbg_enabled = sql_dbg_enabled(); } function get ($name) { + $this->cur_query = "cache->get('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return eaccelerator_get($name); } function set ($name, $value, $ttl = 0) { + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return eaccelerator_put($name, $value, $ttl); } function rm ($name) { + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return eaccelerator_rm($name); } @@ -731,6 +802,7 @@ class cache_eaccelerator extends cache_common class cache_apc extends cache_common { var $used = true; + var $engine = 'APC'; function cache_apc () { @@ -738,20 +810,39 @@ class cache_apc extends cache_common { die('Error: APC extension not installed'); } + $this->dbg_enabled = sql_dbg_enabled(); } function get ($name) { + $this->cur_query = "cache->get('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return apc_fetch($name); } function set ($name, $value, $ttl = 0) { + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return apc_store($name, $value, $ttl); } function rm ($name) { + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return apc_delete($name); } @@ -764,6 +855,7 @@ class cache_apc extends cache_common class cache_xcache extends cache_common { var $used = true; + var $engine = 'XCache'; function cache_xcache () { @@ -771,20 +863,39 @@ class cache_xcache extends cache_common { die('Error: XCache extension not installed'); } + $this->dbg_enabled = sql_dbg_enabled(); } function get ($name) { + $this->cur_query = "cache->get('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return xcache_get($name); } function set ($name, $value, $ttl = 0) { + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return xcache_set($name, $value, $ttl); } function rm ($name) { + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return xcache_unset($name); } @@ -796,24 +907,31 @@ class cache_xcache extends cache_common class cache_file extends cache_common { - var $used = true; - - var $dir = null; + var $used = true; + var $engine = 'Filecache'; + var $dir = null; function cache_file ($dir) { $this->dir = $dir; + $this->dbg_enabled = sql_dbg_enabled(); } function get ($name) { $filename = $this->dir . clean_filename($name) . '.php'; + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + if(file_exists($filename)) { require($filename); } + $this->debug('stop'); + $this->cur_query = null; + return (!empty($filecache['value'])) ? $filecache['value'] : false; } @@ -824,6 +942,9 @@ class cache_file extends cache_common return false; } + $this->cur_query = "cache->set('$name')"; + $this->debug('start'); + $filename = $this->dir . clean_filename($name) . '.php'; $expire = TIMENOW + $ttl; $cache_data = array( @@ -836,6 +957,10 @@ class cache_file extends cache_common $filecache .= '$filecache = ' . var_export($cache_data, true) . ";\n"; $filecache .= '?>'; + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) file_write($filecache, $filename, false, true, true); } @@ -844,6 +969,12 @@ class cache_file extends cache_common $filename = $this->dir . clean_filename($name) . '.php'; if (file_exists($filename)) { + $this->cur_query = "cache->rm('$name')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) unlink($filename); } return false; @@ -939,8 +1070,6 @@ class datastore_common function &get ($title) { -# if (in_array(BB_SCRIPT, array('forum', 'topic', 'ajax'))) bb_log(' ', "ds/". BB_SCRIPT ."/$title"); - if (!isset($this->data[$title])) { $this->enqueue($title); @@ -999,6 +1128,60 @@ class datastore_common trigger_error("Unknown datastore item: $title", E_USER_ERROR); } } + + var $num_queries = 0; + var $sql_starttime = 0; + var $sql_inittime = 0; + var $sql_timetotal = 0; + var $cur_query_time = 0; + + var $dbg = array(); + var $dbg_id = 0; + var $dbg_enabled = false; + var $cur_query = null; + + function debug ($mode, $cur_query = null) + { + if (!$this->dbg_enabled) return; + + $id =& $this->dbg_id; + $dbg =& $this->dbg[$id]; + + if ($mode == 'start') + { + $this->sql_starttime = utime(); + + $dbg['sql'] = isset($cur_query) ? short_query($cur_query) : short_query($this->cur_query); + $dbg['src'] = $this->debug_find_source(); + $dbg['file'] = $this->debug_find_source('file'); + $dbg['line'] = $this->debug_find_source('line'); + $dbg['time'] = ''; + } + else if ($mode == 'stop') + { + $this->cur_query_time = utime() - $this->sql_starttime; + $this->sql_timetotal += $this->cur_query_time; + $dbg['time'] = $this->cur_query_time; + $id++; + } + } + + function debug_find_source ($mode = '') + { + foreach (debug_backtrace() as $trace) + { + if ($trace['file'] !== __FILE__) + { + switch ($mode) + { + case 'file': return $trace['file']; + case 'line': return $trace['line']; + default: return hide_bb_path($trace['file']) .'('. $trace['line'] .')'; + } + } + } + return 'src not found'; + } } class datastore_memcache extends datastore_common @@ -1006,6 +1189,7 @@ class datastore_memcache extends datastore_common var $cfg = null; var $memcache = null; var $connected = false; + var $engine = 'Memcache'; function datastore_memcache ($cfg) { @@ -1018,12 +1202,16 @@ class datastore_memcache extends datastore_common $this->cfg = $cfg; $this->memcache = new Memcache; + $this->dbg_enabled = sql_dbg_enabled(); } function connect () { $connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect'; + $this->cur_query = $connect_type .' '. $this->cfg['host'] .':'. $this->cfg['port']; + $this->debug('start'); + if (@$this->memcache->$connect_type($this->cfg['host'], $this->cfg['port'])) { $this->connected = true; @@ -1035,12 +1223,22 @@ class datastore_memcache extends datastore_common { die('Could not connect to memcached server'); } + + $this->debug('stop'); + $this->cur_query = null; } function store ($title, $var) { if (!$this->connected) $this->connect(); $this->data[$title] = $var; + + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) $this->memcache->set($title, $var); } @@ -1049,6 +1247,12 @@ class datastore_memcache extends datastore_common if (!$this->connected) $this->connect(); foreach ($this->known_items as $title => $script_name) { + $this->cur_query = "cache->rm('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->memcache->delete($title); } } @@ -1064,6 +1268,12 @@ class datastore_memcache extends datastore_common if (!$this->connected) $this->connect(); foreach ($items as $item) { + $this->cur_query = "cache->get('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->data[$item] = $this->memcache->get($item); } } @@ -1137,6 +1347,7 @@ class datastore_redis extends datastore_common var $cfg = null; var $redis = null; var $connected = false; + var $engine = 'Redis'; function datastore_redis ($cfg) { @@ -1148,11 +1359,15 @@ class datastore_redis extends datastore_common } $this->cfg = $cfg; - $this->redis = new Redis();; + $this->redis = new Redis(); + $this->dbg_enabled = sql_dbg_enabled(); } function connect () { + $this->cur_query = 'connect '. $this->cfg['host'] .':'. $this->cfg['port']; + $this->debug('start'); + if (@$this->redis->connect($this->cfg['host'],$this->cfg['port'])) { $this->connected = true; @@ -1162,12 +1377,22 @@ class datastore_redis extends datastore_common { die('Could not connect to redis server'); } + + $this->debug('stop'); + $this->cur_query = null; } function store ($title, $var) { if (!$this->connected) $this->connect(); $this->data[$title] = $var; + + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) $this->redis->set($title, serialize($var)); } @@ -1176,6 +1401,12 @@ class datastore_redis extends datastore_common if (!$this->connected) $this->connect(); foreach ($this->known_items as $title => $script_name) { + $this->cur_query = "cache->rm('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->redis->del($title); } } @@ -1191,6 +1422,12 @@ class datastore_redis extends datastore_common if (!$this->connected) $this->connect(); foreach ($items as $item) { + $this->cur_query = "cache->get('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->data[$item] = unserialize($this->redis->get($item)); } } @@ -1203,9 +1440,27 @@ class datastore_redis extends datastore_common class datastore_eaccelerator extends datastore_common { + var $engine = 'eAccelerator'; + + function datastore_eaccelerator () + { + if (!$this->is_installed()) + { + die('Error: eAccelerator extension not installed'); + } + $this->dbg_enabled = sql_dbg_enabled(); + } + function store ($title, $var) { $this->data[$title] = $var; + + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + eaccelerator_put($title, $var); } @@ -1213,6 +1468,12 @@ class datastore_eaccelerator extends datastore_common { foreach ($this->known_items as $title => $script_name) { + $this->cur_query = "cache->rm('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + eaccelerator_rm($title); } } @@ -1227,16 +1488,45 @@ class datastore_eaccelerator extends datastore_common foreach ($items as $item) { + $this->cur_query = "cache->get('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->data[$item] = eaccelerator_get($item); } } + + function is_installed () + { + return function_exists('eaccelerator_get'); + } } class datastore_xcache extends datastore_common { + var $engine = 'XCache'; + + function cache_xcache () + { + if (!$this->is_installed()) + { + die('Error: XCache extension not installed'); + } + $this->dbg_enabled = sql_dbg_enabled(); + } + function store ($title, $var) { $this->data[$title] = $var; + + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) xcache_set($title, $var); } @@ -1244,6 +1534,12 @@ class datastore_xcache extends datastore_common { foreach ($this->known_items as $title => $script_name) { + $this->cur_query = "cache->rm('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + xcache_unset($title); } } @@ -1258,16 +1554,45 @@ class datastore_xcache extends datastore_common foreach ($items as $item) { + $this->cur_query = "cache->set('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->data[$item] = xcache_get($item); } } + + function is_installed () + { + return function_exists('xcache_get'); + } } class datastore_apc extends datastore_common { + var $engine = 'APC'; + + function datastore_apc () + { + if (!$this->is_installed()) + { + die('Error: APC extension not installed'); + } + $this->dbg_enabled = sql_dbg_enabled(); + } + function store ($title, $var) { $this->data[$title] = $var; + + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) apc_store($title, $var); } @@ -1275,6 +1600,12 @@ class datastore_apc extends datastore_common { foreach ($this->known_items as $title => $script_name) { + $this->cur_query = "cache->rm('$title')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + apc_delete($title); } } @@ -1289,22 +1620,38 @@ class datastore_apc extends datastore_common foreach ($items as $item) { + $this->cur_query = "cache->get('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + $this->data[$item] = apc_fetch($item); } } + + function is_installed () + { + return function_exists('apc_fetch'); + } } class datastore_file extends datastore_common { - var $dir = null; + var $dir = null; + var $engine = 'Filecache'; function datastore_file ($dir) { $this->dir = $dir; + $this->dbg_enabled = sql_dbg_enabled(); } function store ($title, $var) { + $this->cur_query = "cache->set('$title')"; + $this->debug('start'); + $this->data[$title] = $var; $filename = $this->dir . clean_filename($title) . '.php'; @@ -1314,6 +1661,10 @@ class datastore_file extends datastore_common $filecache .= '$filestore = ' . var_export($var, true) . ";\n"; $filecache .= '?>'; + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + return (bool) file_write($filecache, $filename, false, true, true); } @@ -1351,6 +1702,12 @@ class datastore_file extends datastore_common { $filename = $this->dir . $item . '.php'; + $this->cur_query = "cache->get('$item')"; + $this->debug('start'); + $this->debug('stop'); + $this->cur_query = null; + $this->num_queries++; + if(file_exists($filename)) { require($filename); @@ -1439,18 +1796,18 @@ function sql_dbg_enabled () function short_query ($sql, $esc_html = false) { - $max_len = 100; - $sql = str_compact($sql); + $max_len = 100; + $sql = str_compact($sql); - if (empty($_COOKIE['sql_log_full'])) - { - if (mb_strlen($sql, 'UTF-8') > $max_len) - { - $sql = mb_substr($sql, 0, 50) .' [...cut...] '. mb_substr($sql, -50); - } - } + if (empty($_COOKIE['sql_log_full'])) + { + if (mb_strlen($sql, 'UTF-8') > $max_len) + { + $sql = mb_substr($sql, 0, 50) .' [...cut...] '. mb_substr($sql, -50); + } + } - return ($esc_html) ? htmlCHR($sql, true) : $sql; + return ($esc_html) ? htmlCHR($sql, true) : $sql; } // Functions diff --git a/upload/config.php b/upload/config.php index 2952c85fd..4baac9967 100644 --- a/upload/config.php +++ b/upload/config.php @@ -57,7 +57,7 @@ $bb_cfg['css_ver'] = 1; // Increase number of revision after update $bb_cfg['tp_version'] = '2.0.2'; -$bb_cfg['tp_release_state'] = 'TP II r178'; +$bb_cfg['tp_release_state'] = 'TP II r179'; $bb_cfg['tp_release_date'] = '30-07-2011'; $bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger diff --git a/upload/includes/functions_dev.php b/upload/includes/functions_dev.php index f31920512..f2d57a43e 100644 --- a/upload/includes/functions_dev.php +++ b/upload/includes/functions_dev.php @@ -12,19 +12,31 @@ function get_sql_log () } foreach ($CACHES->obj as $cache_name => $cache_obj) { - $log .= !empty($cache_obj->db) ? get_sql_log_html($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]") : ''; + if(!empty($cache_obj->db)) + { + $log .= get_sql_log_html($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]"); + } + elseif(!empty($cache_obj->engine)) + { + $log .= get_sql_log_html($cache_obj, "cache: $cache_name [{$cache_obj->engine}]"); + } } $log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : ''; - $log .= !empty($datastore->db) ? get_sql_log_html($datastore->db, '$datastore ['.$datastore->engine.']') : ''; + if(!empty($datastore->db->dbg)) + { + $log .= get_sql_log_html($datastore->db, '$datastore ['.$datastore->engine.']'); + } + else if(!empty($datastore->dbg)) + { + $log .= get_sql_log_html($datastore, '$datastore ['.$datastore->engine.']'); + } - return $log; + return $log; } function get_sql_log_html ($db_obj, $log_name) { - if (empty($db_obj->dbg)) return ''; - $log = ''; foreach ($db_obj->dbg as $i => $dbg) diff --git a/upload/includes/sphinxapi.php b/upload/includes/sphinxapi.php index ce08b7b22..54d83a2b3 100644 --- a/upload/includes/sphinxapi.php +++ b/upload/includes/sphinxapi.php @@ -118,7 +118,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 ); function sphPackI64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { @@ -130,7 +130,7 @@ function sphPackI64 ( $v ) if ( is_int($v) ) return pack ( "NN", $v < 0 ? -1 : 0, $v ); - // x32, bcmath + // x32, bcmath if ( function_exists("bcmul") ) { if ( bccomp ( $v, 0 ) == -1 ) @@ -167,16 +167,16 @@ function sphPackI64 ( $v ) function sphPackU64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { assert ( $v>=0 ); - + // x64, int if ( is_int($v) ) return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); - + // x64, bcmath if ( function_exists("bcmul") ) { @@ -184,12 +184,12 @@ function sphPackU64 ( $v ) $l = bcmod ( $v, 4294967296 ); return pack ( "NN", $h, $l ); } - + // x64, no-bcmath $p = max ( 0, strlen($v) - 13 ); $lo = (int)substr ( $v, $p ); $hi = (int)substr ( $v, 0, $p ); - + $m = $lo + $hi*1316134912; $l = $m % 4294967296; $h = $hi*2328 + (int)($m/4294967296); @@ -200,7 +200,7 @@ function sphPackU64 ( $v ) // x32, int if ( is_int($v) ) return pack ( "NN", 0, $v ); - + // x32, bcmath if ( function_exists("bcmul") ) { @@ -213,7 +213,7 @@ function sphPackU64 ( $v ) $p = max(0, strlen($v) - 13); $lo = (float)substr($v, $p); $hi = (float)substr($v, 0, $p); - + $m = $lo + $hi*1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); @@ -269,11 +269,11 @@ function sphUnpackU64 ( $v ) // x32, bcmath if ( function_exists("bcmul") ) return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); - + // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -316,7 +316,7 @@ function sphUnpackI64 ( $v ) return $lo; return sprintf ( "%.0f", $lo - 4294967296.0 ); } - + $neg = ""; $c = 0; if ( $hi<0 ) @@ -325,7 +325,7 @@ function sphUnpackI64 ( $v ) $lo = ~$lo; $c = 1; $neg = "-"; - } + } $hi = sprintf ( "%u", $hi ); $lo = sprintf ( "%u", $lo ); @@ -337,7 +337,7 @@ function sphUnpackI64 ( $v ) // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -375,7 +375,7 @@ function sphFixUint ( $value ) /// sphinx searchd client class -class SphinxClient extends cache_dbg_common +class SphinxClient extends cache_common { var $_host; ///< searchd host (default is "localhost") var $_port; ///< searchd port (default is 9312) @@ -505,7 +505,7 @@ class SphinxClient extends cache_dbg_common $this->_path = $host; return; } - + assert ( is_int($port) ); $this->_host = $host; $this->_port = $port; @@ -588,14 +588,14 @@ class SphinxClient extends cache_dbg_common $fp = @fsockopen ( $host, $port, $errno, $errstr ); else $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); - + if ( !$fp ) { if ( $this->_path ) $location = $this->_path; else $location = "{$this->_host}:{$this->_port}"; - + $errstr = trim ( $errstr ); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; @@ -1248,7 +1248,7 @@ class SphinxClient extends cache_dbg_common if ( $type==SPH_ATTR_FLOAT ) { list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); + list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); $attrvals[$attr] = $fval; continue; } @@ -1604,7 +1604,7 @@ class SphinxClient extends cache_dbg_common fclose ( $this->_socket ); $this->_socket = false; - + return true; }