php 7 future

This commit is contained in:
Vasily Komrakov 2017-01-11 21:30:24 +03:00
commit efcd7ae71f
34 changed files with 649 additions and 654 deletions

View file

@ -4,10 +4,10 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_apc extends datastore_common
{
var $engine = 'APC';
var $prefix = null;
public $engine = 'APC';
public $prefix = null;
function datastore_apc ($prefix = null)
public function __construct ($prefix = null)
{
if (!$this->is_installed())
{
@ -17,7 +17,7 @@ class datastore_apc extends datastore_common
$this->prefix = $prefix;
}
function store ($title, $var)
public function store ($title, $var)
{
$this->data[$title] = $var;
@ -30,7 +30,7 @@ class datastore_apc extends datastore_common
return (bool) apc_store($this->prefix . $title, $var);
}
function clean ()
public function clean ()
{
foreach ($this->known_items as $title => $script_name)
{
@ -44,7 +44,7 @@ class datastore_apc extends datastore_common
}
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items)
{
@ -64,8 +64,8 @@ class datastore_apc extends datastore_common
}
}
function is_installed ()
public function is_installed ()
{
return function_exists('apc_fetch');
}
}
}

View file

@ -7,24 +7,24 @@ class datastore_common
/**
* Директория с builder-скриптами (внутри INC_DIR)
*/
var $ds_dir = 'datastore/';
public $ds_dir = 'datastore/';
/**
* Готовая к употреблению data
* array('title' => data)
*/
var $data = array();
public $data = array();
/**
* Список элементов, которые будут извлечены из хранилища при первом же запросе get()
* до этого момента они ставятся в очередь $queued_items для дальнейшего извлечения _fetch()'ем
* всех элементов одним запросом
* array('title1', 'title2'...)
*/
var $queued_items = array();
public $queued_items = array();
/**
* 'title' => 'builder script name' inside "includes/datastore" dir
*/
var $known_items = array(
public $known_items = array(
'cat_forums' => 'build_cat_forums.php',
'jumpbox' => 'build_cat_forums.php',
'viewtopic_forum_select' => 'build_cat_forums.php',
@ -41,12 +41,12 @@ class datastore_common
/**
* Constructor
*/
function datastore_common () {}
public function __construct () {}
/**
* @param array(item1_title, item2_title...) or single item's title
*/
function enqueue ($items)
public function enqueue ($items)
{
foreach ((array) $items as $item)
{
@ -58,7 +58,7 @@ class datastore_common
}
}
function &get ($title)
public function &get ($title)
{
if (!isset($this->data[$title]))
{
@ -68,9 +68,9 @@ class datastore_common
return $this->data[$title];
}
function store ($item_name, $item_data) {}
public function store ($item_name, $item_data) {}
function rm ($items)
public function rm ($items)
{
foreach ((array) $items as $item)
{
@ -78,7 +78,7 @@ class datastore_common
}
}
function update ($items)
public function update ($items)
{
if ($items == 'all')
{
@ -90,7 +90,7 @@ class datastore_common
}
}
function _fetch ()
public function _fetch ()
{
$this->_fetch_from_store();
@ -105,9 +105,9 @@ class datastore_common
$this->queued_items = array();
}
function _fetch_from_store () {}
public function _fetch_from_store () {}
function _build_item ($title)
public function _build_item ($title)
{
if (!empty($this->known_items[$title]))
{
@ -119,18 +119,18 @@ class datastore_common
}
}
var $num_queries = 0;
var $sql_starttime = 0;
var $sql_inittime = 0;
var $sql_timetotal = 0;
var $cur_query_time = 0;
public $num_queries = 0;
public $sql_starttime = 0;
public $sql_inittime = 0;
public $sql_timetotal = 0;
public $cur_query_time = 0;
var $dbg = array();
var $dbg_id = 0;
var $dbg_enabled = false;
var $cur_query = null;
public $dbg = array();
public $dbg_id = 0;
public $dbg_enabled = false;
public $cur_query = null;
function debug ($mode, $cur_query = null)
public function debug ($mode, $cur_query = null)
{
if (!$this->dbg_enabled) return;
@ -156,7 +156,7 @@ class datastore_common
}
}
function debug_find_source ($mode = '')
public function debug_find_source ($mode = '')
{
foreach (debug_backtrace() as $trace)
{
@ -172,4 +172,4 @@ class datastore_common
}
return 'src not found';
}
}
}

View file

@ -4,18 +4,18 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_file extends datastore_common
{
var $dir = null;
var $prefix = null;
var $engine = 'Filecache';
public $dir = null;
public $prefix = null;
public $engine = 'Filecache';
function datastore_file ($dir, $prefix = null)
public function __construct ($dir, $prefix = null)
{
$this->prefix = $prefix;
$this->dir = $dir;
$this->dbg_enabled = sql_dbg_enabled();
}
function store ($title, $var)
public function store ($title, $var)
{
$this->cur_query = "cache->set('$title')";
$this->debug('start');
@ -36,7 +36,7 @@ class datastore_file extends datastore_common
return (bool) file_write($filecache, $filename, false, true, true);
}
function clean ()
public function clean ()
{
$dir = $this->dir;
@ -58,7 +58,7 @@ class datastore_file extends datastore_common
}
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items)
{
@ -84,4 +84,4 @@ class datastore_file extends datastore_common
}
}
}
}
}

View file

@ -4,13 +4,13 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_memcache extends datastore_common
{
var $cfg = null;
var $memcache = null;
var $connected = false;
var $engine = 'Memcache';
var $prefix = null;
public $cfg = null;
public $memcache = null;
public $connected = false;
public $engine = 'Memcache';
public $prefix = null;
function datastore_memcache ($cfg, $prefix = null)
public function __construct ($cfg, $prefix = null)
{
if (!$this->is_installed())
{
@ -23,7 +23,7 @@ class datastore_memcache extends datastore_common
$this->dbg_enabled = sql_dbg_enabled();
}
function connect ()
public function connect ()
{
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
@ -46,7 +46,7 @@ class datastore_memcache extends datastore_common
$this->cur_query = null;
}
function store ($title, $var)
public function store ($title, $var)
{
if (!$this->connected) $this->connect();
$this->data[$title] = $var;
@ -60,7 +60,7 @@ class datastore_memcache extends datastore_common
return (bool) $this->memcache->set($this->prefix . $title, $var);
}
function clean ()
public function clean ()
{
if (!$this->connected) $this->connect();
foreach ($this->known_items as $title => $script_name)
@ -75,7 +75,7 @@ class datastore_memcache extends datastore_common
}
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items)
{
@ -96,8 +96,8 @@ class datastore_memcache extends datastore_common
}
}
function is_installed ()
public function is_installed ()
{
return class_exists('Memcache');
}
}
}

View file

@ -4,13 +4,13 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_redis extends datastore_common
{
var $cfg = null;
var $redis = null;
var $prefix = null;
var $connected = false;
var $engine = 'Redis';
public $cfg = null;
public $redis = null;
public $prefix = null;
public $connected = false;
public $engine = 'Redis';
function datastore_redis ($cfg, $prefix = null)
public function __construct ($cfg, $prefix = null)
{
if (!$this->is_installed())
{
@ -23,7 +23,7 @@ class datastore_redis extends datastore_common
$this->prefix = $prefix;
}
function connect ()
public function connect ()
{
$this->cur_query = 'connect '. $this->cfg['host'] .':'. $this->cfg['port'];
$this->debug('start');
@ -42,7 +42,7 @@ class datastore_redis extends datastore_common
$this->cur_query = null;
}
function store ($title, $var)
public function store ($title, $var)
{
if (!$this->connected) $this->connect();
$this->data[$title] = $var;
@ -56,7 +56,7 @@ class datastore_redis extends datastore_common
return (bool) $this->redis->set($this->prefix . $title, serialize($var));
}
function clean ()
public function clean ()
{
if (!$this->connected) $this->connect();
foreach ($this->known_items as $title => $script_name)
@ -71,7 +71,7 @@ class datastore_redis extends datastore_common
}
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items)
{
@ -92,8 +92,8 @@ class datastore_redis extends datastore_common
}
}
function is_installed ()
public function is_installed ()
{
return class_exists('Redis');
}
}
}

View file

@ -4,10 +4,10 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_sqlite extends datastore_common
{
var $engine = 'SQLite';
var $db = null;
var $prefix = null;
var $cfg = array(
public $engine = 'SQLite';
public $db = null;
public $prefix = null;
public $cfg = array(
'db_file_path' => '/path/to/datastore.db.sqlite',
'table_name' => 'datastore',
'table_schema' => 'CREATE TABLE datastore (
@ -20,14 +20,14 @@ class datastore_sqlite extends datastore_common
'log_name' => 'DATASTORE',
);
function datastore_sqlite ($cfg, $prefix = null)
public function __construct ($cfg, $prefix = null)
{
$this->cfg = array_merge($this->cfg, $cfg);
$this->db = new sqlite_common($this->cfg);
$this->prefix = $prefix;
}
function store ($item_name, $item_data)
public function store ($item_name, $item_data)
{
$this->data[$item_name] = $item_data;
@ -39,12 +39,12 @@ class datastore_sqlite extends datastore_common
return (bool) $result;
}
function clean ()
public function clean ()
{
$this->db->query("DELETE FROM ". $this->cfg['table_name']);
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items) return;
@ -63,4 +63,4 @@ class datastore_sqlite extends datastore_common
}
$this->db->debug('stop');
}
}
}

View file

@ -4,10 +4,10 @@ if (!defined('BB_ROOT')) die(basename(__FILE__));
class datastore_xcache extends datastore_common
{
var $prefix = null;
var $engine = 'XCache';
public $prefix = null;
public $engine = 'XCache';
function datastore_xcache ($prefix = null)
public function __construct ($prefix = null)
{
if (!$this->is_installed())
{
@ -18,7 +18,7 @@ class datastore_xcache extends datastore_common
$this->prefix = $prefix;
}
function store ($title, $var)
public function store ($title, $var)
{
$this->data[$title] = $var;
@ -31,7 +31,7 @@ class datastore_xcache extends datastore_common
return (bool) xcache_set($this->prefix . $title, $var);
}
function clean ()
public function clean ()
{
foreach ($this->known_items as $title => $script_name)
{
@ -45,7 +45,7 @@ class datastore_xcache extends datastore_common
}
}
function _fetch_from_store ()
public function _fetch_from_store ()
{
if (!$items = $this->queued_items)
{
@ -65,8 +65,8 @@ class datastore_xcache extends datastore_common
}
}
function is_installed ()
public function is_installed ()
{
return function_exists('xcache_get');
}
}
}