mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
r179
Отображение всех логов кеша в дебагере git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@179 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
2f7f5a5b65
commit
acc5253f71
4 changed files with 477 additions and 108 deletions
|
@ -255,20 +255,72 @@ class cache_common
|
||||||
{
|
{
|
||||||
return false;
|
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
|
class cache_memcache extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'Memcache';
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $memcache = null;
|
var $memcache = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
|
||||||
function cache_memcache ($cfg)
|
function cache_memcache ($cfg)
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
|
||||||
|
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: Memcached extension not installed');
|
die('Error: Memcached extension not installed');
|
||||||
|
@ -276,12 +328,16 @@ class cache_memcache extends cache_common
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
$this->memcache = new Memcache;
|
$this->memcache = new Memcache;
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect ()
|
function connect ()
|
||||||
{
|
{
|
||||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : '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']))
|
if (@$this->memcache->$connect_type($this->cfg['host'], $this->cfg['port']))
|
||||||
{
|
{
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
@ -293,23 +349,47 @@ class cache_memcache extends cache_common
|
||||||
{
|
{
|
||||||
die('Could not connect to memcached server');
|
die('Could not connect to memcached server');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
function get ($name)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
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;
|
return ($this->connected) ? $this->memcache->get($name) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set ($name, $value, $ttl = 0)
|
function set ($name, $value, $ttl = 0)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
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;
|
return ($this->connected) ? $this->memcache->set($name, $value, false, $ttl) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm ($name)
|
function rm ($name)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
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;
|
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(
|
var $cfg = array(
|
||||||
'db_file_path' => 'sqlite.db',
|
'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
|
class cache_redis extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'Redis';
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $redis = null;
|
var $redis = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
|
||||||
function cache_redis ($cfg)
|
function cache_redis ($cfg)
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
|
||||||
|
|
||||||
if (!$this->is_installed())
|
if (!$this->is_installed())
|
||||||
{
|
{
|
||||||
die('Error: Redis extension not installed');
|
die('Error: Redis extension not installed');
|
||||||
|
@ -645,10 +666,14 @@ class cache_redis extends cache_common
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
$this->redis = new Redis();
|
$this->redis = new Redis();
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect ()
|
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']))
|
if (@$this->redis->connect($this->cfg['host'], $this->cfg['port']))
|
||||||
{
|
{
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
@ -658,23 +683,42 @@ class cache_redis extends cache_common
|
||||||
{
|
{
|
||||||
die('Could not connect to redis server');
|
die('Could not connect to redis server');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
function get ($name)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
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;
|
return ($this->connected) ? unserialize($this->redis->get($name)) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set ($name, $value, $ttl = 0)
|
function set ($name, $value, $ttl = 0)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
|
|
||||||
|
$this->cur_query = "cache->set('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
|
||||||
if($this->redis->set($name, serialize($value)))
|
if($this->redis->set($name, serialize($value)))
|
||||||
{
|
{
|
||||||
if ($ttl > 0)
|
if ($ttl > 0)
|
||||||
{
|
{
|
||||||
$this->redis->expire($name, $ttl);
|
$this->redis->expire($name, $ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -686,6 +730,13 @@ class cache_redis extends cache_common
|
||||||
function rm ($name)
|
function rm ($name)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
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;
|
return ($this->connected) ? $this->redis->del($name) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +748,8 @@ class cache_redis extends cache_common
|
||||||
|
|
||||||
class cache_eaccelerator extends cache_common
|
class cache_eaccelerator extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'eAccelerator';
|
||||||
|
|
||||||
function cache_eaccelerator ()
|
function cache_eaccelerator ()
|
||||||
{
|
{
|
||||||
|
@ -705,20 +757,39 @@ class cache_eaccelerator extends cache_common
|
||||||
{
|
{
|
||||||
die('Error: eAccelerator extension not installed');
|
die('Error: eAccelerator extension not installed');
|
||||||
}
|
}
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
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);
|
return eaccelerator_get($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set ($name, $value, $ttl = 0)
|
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);
|
return eaccelerator_put($name, $value, $ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm ($name)
|
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);
|
return eaccelerator_rm($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,6 +802,7 @@ class cache_eaccelerator extends cache_common
|
||||||
class cache_apc extends cache_common
|
class cache_apc extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'APC';
|
||||||
|
|
||||||
function cache_apc ()
|
function cache_apc ()
|
||||||
{
|
{
|
||||||
|
@ -738,20 +810,39 @@ class cache_apc extends cache_common
|
||||||
{
|
{
|
||||||
die('Error: APC extension not installed');
|
die('Error: APC extension not installed');
|
||||||
}
|
}
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
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);
|
return apc_fetch($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set ($name, $value, $ttl = 0)
|
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);
|
return apc_store($name, $value, $ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm ($name)
|
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);
|
return apc_delete($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,6 +855,7 @@ class cache_apc extends cache_common
|
||||||
class cache_xcache extends cache_common
|
class cache_xcache extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'XCache';
|
||||||
|
|
||||||
function cache_xcache ()
|
function cache_xcache ()
|
||||||
{
|
{
|
||||||
|
@ -771,20 +863,39 @@ class cache_xcache extends cache_common
|
||||||
{
|
{
|
||||||
die('Error: XCache extension not installed');
|
die('Error: XCache extension not installed');
|
||||||
}
|
}
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
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);
|
return xcache_get($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set ($name, $value, $ttl = 0)
|
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);
|
return xcache_set($name, $value, $ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm ($name)
|
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);
|
return xcache_unset($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,24 +907,31 @@ class cache_xcache extends cache_common
|
||||||
|
|
||||||
class cache_file extends cache_common
|
class cache_file extends cache_common
|
||||||
{
|
{
|
||||||
var $used = true;
|
var $used = true;
|
||||||
|
var $engine = 'Filecache';
|
||||||
var $dir = null;
|
var $dir = null;
|
||||||
|
|
||||||
function cache_file ($dir)
|
function cache_file ($dir)
|
||||||
{
|
{
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get ($name)
|
function get ($name)
|
||||||
{
|
{
|
||||||
$filename = $this->dir . clean_filename($name) . '.php';
|
$filename = $this->dir . clean_filename($name) . '.php';
|
||||||
|
|
||||||
|
$this->cur_query = "cache->set('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
|
||||||
if(file_exists($filename))
|
if(file_exists($filename))
|
||||||
{
|
{
|
||||||
require($filename);
|
require($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
|
||||||
return (!empty($filecache['value'])) ? $filecache['value'] : false;
|
return (!empty($filecache['value'])) ? $filecache['value'] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,6 +942,9 @@ class cache_file extends cache_common
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->cur_query = "cache->set('$name')";
|
||||||
|
$this->debug('start');
|
||||||
|
|
||||||
$filename = $this->dir . clean_filename($name) . '.php';
|
$filename = $this->dir . clean_filename($name) . '.php';
|
||||||
$expire = TIMENOW + $ttl;
|
$expire = TIMENOW + $ttl;
|
||||||
$cache_data = array(
|
$cache_data = array(
|
||||||
|
@ -836,6 +957,10 @@ class cache_file extends cache_common
|
||||||
$filecache .= '$filecache = ' . var_export($cache_data, true) . ";\n";
|
$filecache .= '$filecache = ' . var_export($cache_data, true) . ";\n";
|
||||||
$filecache .= '?>';
|
$filecache .= '?>';
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) file_write($filecache, $filename, false, true, true);
|
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';
|
$filename = $this->dir . clean_filename($name) . '.php';
|
||||||
if (file_exists($filename))
|
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 (bool) unlink($filename);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -939,8 +1070,6 @@ class datastore_common
|
||||||
|
|
||||||
function &get ($title)
|
function &get ($title)
|
||||||
{
|
{
|
||||||
# if (in_array(BB_SCRIPT, array('forum', 'topic', 'ajax'))) bb_log(' ', "ds/". BB_SCRIPT ."/$title");
|
|
||||||
|
|
||||||
if (!isset($this->data[$title]))
|
if (!isset($this->data[$title]))
|
||||||
{
|
{
|
||||||
$this->enqueue($title);
|
$this->enqueue($title);
|
||||||
|
@ -999,6 +1128,60 @@ class datastore_common
|
||||||
trigger_error("Unknown datastore item: $title", E_USER_ERROR);
|
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
|
class datastore_memcache extends datastore_common
|
||||||
|
@ -1006,6 +1189,7 @@ class datastore_memcache extends datastore_common
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $memcache = null;
|
var $memcache = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
var $engine = 'Memcache';
|
||||||
|
|
||||||
function datastore_memcache ($cfg)
|
function datastore_memcache ($cfg)
|
||||||
{
|
{
|
||||||
|
@ -1018,12 +1202,16 @@ class datastore_memcache extends datastore_common
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
$this->memcache = new Memcache;
|
$this->memcache = new Memcache;
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect ()
|
function connect ()
|
||||||
{
|
{
|
||||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : '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']))
|
if (@$this->memcache->$connect_type($this->cfg['host'], $this->cfg['port']))
|
||||||
{
|
{
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
@ -1035,12 +1223,22 @@ class datastore_memcache extends datastore_common
|
||||||
{
|
{
|
||||||
die('Could not connect to memcached server');
|
die('Could not connect to memcached server');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
$this->data[$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) $this->memcache->set($title, $var);
|
return (bool) $this->memcache->set($title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,6 +1247,12 @@ class datastore_memcache extends datastore_common
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
foreach ($this->known_items as $title => $script_name)
|
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);
|
$this->memcache->delete($title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1064,6 +1268,12 @@ class datastore_memcache extends datastore_common
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
foreach ($items as $item)
|
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);
|
$this->data[$item] = $this->memcache->get($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1137,6 +1347,7 @@ class datastore_redis extends datastore_common
|
||||||
var $cfg = null;
|
var $cfg = null;
|
||||||
var $redis = null;
|
var $redis = null;
|
||||||
var $connected = false;
|
var $connected = false;
|
||||||
|
var $engine = 'Redis';
|
||||||
|
|
||||||
function datastore_redis ($cfg)
|
function datastore_redis ($cfg)
|
||||||
{
|
{
|
||||||
|
@ -1148,11 +1359,15 @@ class datastore_redis extends datastore_common
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cfg = $cfg;
|
$this->cfg = $cfg;
|
||||||
$this->redis = new Redis();;
|
$this->redis = new Redis();
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect ()
|
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']))
|
if (@$this->redis->connect($this->cfg['host'],$this->cfg['port']))
|
||||||
{
|
{
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
|
@ -1162,12 +1377,22 @@ class datastore_redis extends datastore_common
|
||||||
{
|
{
|
||||||
die('Could not connect to redis server');
|
die('Could not connect to redis server');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
$this->data[$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) $this->redis->set($title, serialize($var));
|
return (bool) $this->redis->set($title, serialize($var));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1176,6 +1401,12 @@ class datastore_redis extends datastore_common
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
foreach ($this->known_items as $title => $script_name)
|
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);
|
$this->redis->del($title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1191,6 +1422,12 @@ class datastore_redis extends datastore_common
|
||||||
if (!$this->connected) $this->connect();
|
if (!$this->connected) $this->connect();
|
||||||
foreach ($items as $item)
|
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));
|
$this->data[$item] = unserialize($this->redis->get($item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1203,9 +1440,27 @@ class datastore_redis extends datastore_common
|
||||||
|
|
||||||
class datastore_eaccelerator 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)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
$this->data[$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);
|
eaccelerator_put($title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,6 +1468,12 @@ class datastore_eaccelerator extends datastore_common
|
||||||
{
|
{
|
||||||
foreach ($this->known_items as $title => $script_name)
|
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);
|
eaccelerator_rm($title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,16 +1488,45 @@ class datastore_eaccelerator extends datastore_common
|
||||||
|
|
||||||
foreach ($items as $item)
|
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);
|
$this->data[$item] = eaccelerator_get($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_installed ()
|
||||||
|
{
|
||||||
|
return function_exists('eaccelerator_get');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class datastore_xcache extends datastore_common
|
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)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
$this->data[$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);
|
return (bool) xcache_set($title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,6 +1534,12 @@ class datastore_xcache extends datastore_common
|
||||||
{
|
{
|
||||||
foreach ($this->known_items as $title => $script_name)
|
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);
|
xcache_unset($title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1258,16 +1554,45 @@ class datastore_xcache extends datastore_common
|
||||||
|
|
||||||
foreach ($items as $item)
|
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);
|
$this->data[$item] = xcache_get($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_installed ()
|
||||||
|
{
|
||||||
|
return function_exists('xcache_get');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class datastore_apc extends datastore_common
|
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)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
$this->data[$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);
|
return (bool) apc_store($title, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1275,6 +1600,12 @@ class datastore_apc extends datastore_common
|
||||||
{
|
{
|
||||||
foreach ($this->known_items as $title => $script_name)
|
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);
|
apc_delete($title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1289,22 +1620,38 @@ class datastore_apc extends datastore_common
|
||||||
|
|
||||||
foreach ($items as $item)
|
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);
|
$this->data[$item] = apc_fetch($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_installed ()
|
||||||
|
{
|
||||||
|
return function_exists('apc_fetch');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class datastore_file extends datastore_common
|
class datastore_file extends datastore_common
|
||||||
{
|
{
|
||||||
var $dir = null;
|
var $dir = null;
|
||||||
|
var $engine = 'Filecache';
|
||||||
|
|
||||||
function datastore_file ($dir)
|
function datastore_file ($dir)
|
||||||
{
|
{
|
||||||
$this->dir = $dir;
|
$this->dir = $dir;
|
||||||
|
$this->dbg_enabled = sql_dbg_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function store ($title, $var)
|
function store ($title, $var)
|
||||||
{
|
{
|
||||||
|
$this->cur_query = "cache->set('$title')";
|
||||||
|
$this->debug('start');
|
||||||
|
|
||||||
$this->data[$title] = $var;
|
$this->data[$title] = $var;
|
||||||
|
|
||||||
$filename = $this->dir . clean_filename($title) . '.php';
|
$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 .= '$filestore = ' . var_export($var, true) . ";\n";
|
||||||
$filecache .= '?>';
|
$filecache .= '?>';
|
||||||
|
|
||||||
|
$this->debug('stop');
|
||||||
|
$this->cur_query = null;
|
||||||
|
$this->num_queries++;
|
||||||
|
|
||||||
return (bool) file_write($filecache, $filename, false, true, true);
|
return (bool) file_write($filecache, $filename, false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1351,6 +1702,12 @@ class datastore_file extends datastore_common
|
||||||
{
|
{
|
||||||
$filename = $this->dir . $item . '.php';
|
$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))
|
if(file_exists($filename))
|
||||||
{
|
{
|
||||||
require($filename);
|
require($filename);
|
||||||
|
@ -1439,18 +1796,18 @@ function sql_dbg_enabled ()
|
||||||
|
|
||||||
function short_query ($sql, $esc_html = false)
|
function short_query ($sql, $esc_html = false)
|
||||||
{
|
{
|
||||||
$max_len = 100;
|
$max_len = 100;
|
||||||
$sql = str_compact($sql);
|
$sql = str_compact($sql);
|
||||||
|
|
||||||
if (empty($_COOKIE['sql_log_full']))
|
if (empty($_COOKIE['sql_log_full']))
|
||||||
{
|
{
|
||||||
if (mb_strlen($sql, 'UTF-8') > $max_len)
|
if (mb_strlen($sql, 'UTF-8') > $max_len)
|
||||||
{
|
{
|
||||||
$sql = mb_substr($sql, 0, 50) .' [...cut...] '. mb_substr($sql, -50);
|
$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
|
// Functions
|
||||||
|
|
|
@ -57,7 +57,7 @@ $bb_cfg['css_ver'] = 1;
|
||||||
|
|
||||||
// Increase number of revision after update
|
// Increase number of revision after update
|
||||||
$bb_cfg['tp_version'] = '2.0.2';
|
$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['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
|
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
||||||
|
|
|
@ -12,19 +12,31 @@ function get_sql_log ()
|
||||||
}
|
}
|
||||||
foreach ($CACHES->obj as $cache_name => $cache_obj)
|
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($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)
|
function get_sql_log_html ($db_obj, $log_name)
|
||||||
{
|
{
|
||||||
if (empty($db_obj->dbg)) return '';
|
|
||||||
|
|
||||||
$log = '';
|
$log = '';
|
||||||
|
|
||||||
foreach ($db_obj->dbg as $i => $dbg)
|
foreach ($db_obj->dbg as $i => $dbg)
|
||||||
|
|
|
@ -118,7 +118,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
|
||||||
function sphPackI64 ( $v )
|
function sphPackI64 ( $v )
|
||||||
{
|
{
|
||||||
assert ( is_numeric($v) );
|
assert ( is_numeric($v) );
|
||||||
|
|
||||||
// x64
|
// x64
|
||||||
if ( PHP_INT_SIZE>=8 )
|
if ( PHP_INT_SIZE>=8 )
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ function sphPackI64 ( $v )
|
||||||
if ( is_int($v) )
|
if ( is_int($v) )
|
||||||
return pack ( "NN", $v < 0 ? -1 : 0, $v );
|
return pack ( "NN", $v < 0 ? -1 : 0, $v );
|
||||||
|
|
||||||
// x32, bcmath
|
// x32, bcmath
|
||||||
if ( function_exists("bcmul") )
|
if ( function_exists("bcmul") )
|
||||||
{
|
{
|
||||||
if ( bccomp ( $v, 0 ) == -1 )
|
if ( bccomp ( $v, 0 ) == -1 )
|
||||||
|
@ -167,16 +167,16 @@ function sphPackI64 ( $v )
|
||||||
function sphPackU64 ( $v )
|
function sphPackU64 ( $v )
|
||||||
{
|
{
|
||||||
assert ( is_numeric($v) );
|
assert ( is_numeric($v) );
|
||||||
|
|
||||||
// x64
|
// x64
|
||||||
if ( PHP_INT_SIZE>=8 )
|
if ( PHP_INT_SIZE>=8 )
|
||||||
{
|
{
|
||||||
assert ( $v>=0 );
|
assert ( $v>=0 );
|
||||||
|
|
||||||
// x64, int
|
// x64, int
|
||||||
if ( is_int($v) )
|
if ( is_int($v) )
|
||||||
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
|
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
|
||||||
|
|
||||||
// x64, bcmath
|
// x64, bcmath
|
||||||
if ( function_exists("bcmul") )
|
if ( function_exists("bcmul") )
|
||||||
{
|
{
|
||||||
|
@ -184,12 +184,12 @@ function sphPackU64 ( $v )
|
||||||
$l = bcmod ( $v, 4294967296 );
|
$l = bcmod ( $v, 4294967296 );
|
||||||
return pack ( "NN", $h, $l );
|
return pack ( "NN", $h, $l );
|
||||||
}
|
}
|
||||||
|
|
||||||
// x64, no-bcmath
|
// x64, no-bcmath
|
||||||
$p = max ( 0, strlen($v) - 13 );
|
$p = max ( 0, strlen($v) - 13 );
|
||||||
$lo = (int)substr ( $v, $p );
|
$lo = (int)substr ( $v, $p );
|
||||||
$hi = (int)substr ( $v, 0, $p );
|
$hi = (int)substr ( $v, 0, $p );
|
||||||
|
|
||||||
$m = $lo + $hi*1316134912;
|
$m = $lo + $hi*1316134912;
|
||||||
$l = $m % 4294967296;
|
$l = $m % 4294967296;
|
||||||
$h = $hi*2328 + (int)($m/4294967296);
|
$h = $hi*2328 + (int)($m/4294967296);
|
||||||
|
@ -200,7 +200,7 @@ function sphPackU64 ( $v )
|
||||||
// x32, int
|
// x32, int
|
||||||
if ( is_int($v) )
|
if ( is_int($v) )
|
||||||
return pack ( "NN", 0, $v );
|
return pack ( "NN", 0, $v );
|
||||||
|
|
||||||
// x32, bcmath
|
// x32, bcmath
|
||||||
if ( function_exists("bcmul") )
|
if ( function_exists("bcmul") )
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ function sphPackU64 ( $v )
|
||||||
$p = max(0, strlen($v) - 13);
|
$p = max(0, strlen($v) - 13);
|
||||||
$lo = (float)substr($v, $p);
|
$lo = (float)substr($v, $p);
|
||||||
$hi = (float)substr($v, 0, $p);
|
$hi = (float)substr($v, 0, $p);
|
||||||
|
|
||||||
$m = $lo + $hi*1316134912.0;
|
$m = $lo + $hi*1316134912.0;
|
||||||
$q = floor($m / 4294967296.0);
|
$q = floor($m / 4294967296.0);
|
||||||
$l = $m - ($q * 4294967296.0);
|
$l = $m - ($q * 4294967296.0);
|
||||||
|
@ -269,11 +269,11 @@ function sphUnpackU64 ( $v )
|
||||||
// x32, bcmath
|
// x32, bcmath
|
||||||
if ( function_exists("bcmul") )
|
if ( function_exists("bcmul") )
|
||||||
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
|
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
|
||||||
|
|
||||||
// x32, no-bcmath
|
// x32, no-bcmath
|
||||||
$hi = (float)$hi;
|
$hi = (float)$hi;
|
||||||
$lo = (float)$lo;
|
$lo = (float)$lo;
|
||||||
|
|
||||||
$q = floor($hi/10000000.0);
|
$q = floor($hi/10000000.0);
|
||||||
$r = $hi - $q*10000000.0;
|
$r = $hi - $q*10000000.0;
|
||||||
$m = $lo + $r*4967296.0;
|
$m = $lo + $r*4967296.0;
|
||||||
|
@ -316,7 +316,7 @@ function sphUnpackI64 ( $v )
|
||||||
return $lo;
|
return $lo;
|
||||||
return sprintf ( "%.0f", $lo - 4294967296.0 );
|
return sprintf ( "%.0f", $lo - 4294967296.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$neg = "";
|
$neg = "";
|
||||||
$c = 0;
|
$c = 0;
|
||||||
if ( $hi<0 )
|
if ( $hi<0 )
|
||||||
|
@ -325,7 +325,7 @@ function sphUnpackI64 ( $v )
|
||||||
$lo = ~$lo;
|
$lo = ~$lo;
|
||||||
$c = 1;
|
$c = 1;
|
||||||
$neg = "-";
|
$neg = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
$hi = sprintf ( "%u", $hi );
|
$hi = sprintf ( "%u", $hi );
|
||||||
$lo = sprintf ( "%u", $lo );
|
$lo = sprintf ( "%u", $lo );
|
||||||
|
@ -337,7 +337,7 @@ function sphUnpackI64 ( $v )
|
||||||
// x32, no-bcmath
|
// x32, no-bcmath
|
||||||
$hi = (float)$hi;
|
$hi = (float)$hi;
|
||||||
$lo = (float)$lo;
|
$lo = (float)$lo;
|
||||||
|
|
||||||
$q = floor($hi/10000000.0);
|
$q = floor($hi/10000000.0);
|
||||||
$r = $hi - $q*10000000.0;
|
$r = $hi - $q*10000000.0;
|
||||||
$m = $lo + $r*4967296.0;
|
$m = $lo + $r*4967296.0;
|
||||||
|
@ -375,7 +375,7 @@ function sphFixUint ( $value )
|
||||||
|
|
||||||
|
|
||||||
/// sphinx searchd client class
|
/// sphinx searchd client class
|
||||||
class SphinxClient extends cache_dbg_common
|
class SphinxClient extends cache_common
|
||||||
{
|
{
|
||||||
var $_host; ///< searchd host (default is "localhost")
|
var $_host; ///< searchd host (default is "localhost")
|
||||||
var $_port; ///< searchd port (default is 9312)
|
var $_port; ///< searchd port (default is 9312)
|
||||||
|
@ -505,7 +505,7 @@ class SphinxClient extends cache_dbg_common
|
||||||
$this->_path = $host;
|
$this->_path = $host;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert ( is_int($port) );
|
assert ( is_int($port) );
|
||||||
$this->_host = $host;
|
$this->_host = $host;
|
||||||
$this->_port = $port;
|
$this->_port = $port;
|
||||||
|
@ -588,14 +588,14 @@ class SphinxClient extends cache_dbg_common
|
||||||
$fp = @fsockopen ( $host, $port, $errno, $errstr );
|
$fp = @fsockopen ( $host, $port, $errno, $errstr );
|
||||||
else
|
else
|
||||||
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
|
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
|
||||||
|
|
||||||
if ( !$fp )
|
if ( !$fp )
|
||||||
{
|
{
|
||||||
if ( $this->_path )
|
if ( $this->_path )
|
||||||
$location = $this->_path;
|
$location = $this->_path;
|
||||||
else
|
else
|
||||||
$location = "{$this->_host}:{$this->_port}";
|
$location = "{$this->_host}:{$this->_port}";
|
||||||
|
|
||||||
$errstr = trim ( $errstr );
|
$errstr = trim ( $errstr );
|
||||||
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
|
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
|
||||||
$this->_connerror = true;
|
$this->_connerror = true;
|
||||||
|
@ -1248,7 +1248,7 @@ class SphinxClient extends cache_dbg_common
|
||||||
if ( $type==SPH_ATTR_FLOAT )
|
if ( $type==SPH_ATTR_FLOAT )
|
||||||
{
|
{
|
||||||
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
|
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;
|
$attrvals[$attr] = $fval;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1604,7 @@ class SphinxClient extends cache_dbg_common
|
||||||
|
|
||||||
fclose ( $this->_socket );
|
fclose ( $this->_socket );
|
||||||
$this->_socket = false;
|
$this->_socket = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue