From a4845b451462664273fb6d324e3ffc41a6d21a1d Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 26 Jun 2018 15:09:47 +0300 Subject: [PATCH] PHP 7+ deprecations of old cache systems Signed-off-by: Yuriy Pikhtarev --- common.php | 12 +-- index.php | 52 +++++------ install/sql/mysql.sql | 4 +- .../attach_mod/includes/functions_attach.php | 12 --- library/config.php | 10 +- library/defines.php | 3 - library/includes/functions.php | 92 ------------------- src/Legacy/Cache/Apc.php | 72 --------------- src/Legacy/Cache/Xcache.php | 74 --------------- src/Legacy/Caches.php | 14 --- src/Legacy/Datastore/Apc.php | 78 ---------------- src/Legacy/Datastore/Xcache.php | 79 ---------------- src/Legacy/Emailer.php | 4 +- src/Legacy/Torrent.php | 9 +- 14 files changed, 39 insertions(+), 476 deletions(-) delete mode 100644 src/Legacy/Cache/Apc.php delete mode 100644 src/Legacy/Cache/Xcache.php delete mode 100644 src/Legacy/Datastore/Apc.php delete mode 100644 src/Legacy/Datastore/Xcache.php diff --git a/common.php b/common.php index f4f9ea4d2..1460c5f85 100644 --- a/common.php +++ b/common.php @@ -193,14 +193,6 @@ switch ($bb_cfg['datastore_type']) { $datastore = new TorrentPier\Legacy\Datastore\Redis($bb_cfg['cache']['redis'], $bb_cfg['cache']['prefix']); break; - case 'apc': - $datastore = new TorrentPier\Legacy\Datastore\Apc($bb_cfg['cache']['prefix']); - break; - - case 'xcache': - $datastore = new TorrentPier\Legacy\Datastore\Xcache($bb_cfg['cache']['prefix']); - break; - case 'filecache': default: $datastore = new TorrentPier\Legacy\Datastore\File($bb_cfg['cache']['db_dir'] . 'datastore/', $bb_cfg['cache']['prefix']); @@ -394,10 +386,10 @@ function sys($param) return function_exists('sys_getloadavg') ? implode(' ', sys_getloadavg()) : 0; break; case 'mem': - return function_exists('memory_get_usage') ? memory_get_usage() : 0; + return memory_get_usage(); break; case 'mem_peak': - return function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0; + return memory_get_peak_usage(); break; default: trigger_error("invalid param: $param", E_USER_ERROR); diff --git a/index.php b/index.php index b737b60b2..31ca4eac5 100644 --- a/index.php +++ b/index.php @@ -37,11 +37,11 @@ $user->session_start(); // Init main vars $viewcat = isset($_GET['c']) ? (int)$_GET['c'] : 0; -$lastvisit = (IS_GUEST) ? TIMENOW : $userdata['user_lastvisit']; +$lastvisit = IS_GUEST ? TIMENOW : $userdata['user_lastvisit']; // Caching output $req_page = 'index_page'; -$req_page .= ($viewcat) ? "_c{$viewcat}" : ''; +$req_page .= $viewcat ? "_c{$viewcat}" : ''; define('REQUESTED_PAGE', $req_page); caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . $bb_cfg['default_lang']); @@ -74,28 +74,28 @@ $only_new = $user->opt_js['only_new']; // Validate requested category id if ($viewcat && !($viewcat =& $forums['c'][$viewcat]['cat_id'])) { - redirect("index.php"); + redirect('index.php'); } // Forums $forums_join_sql = 'f.cat_id = c.cat_id'; -$forums_join_sql .= ($viewcat) ? " +$forums_join_sql .= $viewcat ? " AND f.cat_id = $viewcat " : ''; -$forums_join_sql .= ($excluded_forums_csv) ? " +$forums_join_sql .= $excluded_forums_csv ? " AND f.forum_id NOT IN($excluded_forums_csv) AND f.forum_parent NOT IN($excluded_forums_csv) " : ''; // Posts -$posts_join_sql = "p.post_id = f.forum_last_post_id"; +$posts_join_sql = 'p.post_id = f.forum_last_post_id'; $posts_join_sql .= ($only_new == ONLY_NEW_POSTS) ? " AND p.post_time > $lastvisit " : ''; $join_p_type = ($only_new == ONLY_NEW_POSTS) ? 'INNER JOIN' : 'LEFT JOIN'; // Topics -$topics_join_sql = "t.topic_last_post_id = p.post_id"; +$topics_join_sql = 't.topic_last_post_id = p.post_id'; $topics_join_sql .= ($only_new == ONLY_NEW_TOPICS) ? " AND t.topic_time > $lastvisit " : ''; @@ -108,13 +108,13 @@ $sql = " t.topic_id AS last_topic_id, t.topic_title AS last_topic_title, u.user_id AS last_post_user_id, u.user_rank AS last_post_user_rank, IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username - FROM " . BB_CATEGORIES . " c - INNER JOIN " . BB_FORUMS . " f ON($forums_join_sql) + FROM " . BB_CATEGORIES . ' c + INNER JOIN ' . BB_FORUMS . " f ON($forums_join_sql) $join_p_type " . BB_POSTS . " p ON($posts_join_sql) $join_t_type " . BB_TOPICS . " t ON($topics_join_sql) - LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id) + LEFT JOIN " . BB_USERS . ' u ON(u.user_id = p.poster_id) ORDER BY c.cat_order, f.forum_order -"; +'; $replace_in_parent = array( 'last_post_id', @@ -191,11 +191,11 @@ foreach ($cat_forums as $cid => $c) { $template->assign_block_vars('h_c', array( 'H_C_ID' => $cid, 'H_C_TITLE' => $cat_title_html[$cid], - 'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '', + 'H_C_CHEKED' => in_array($cid, preg_split('/[-]+/', $hide_cat_opt)) ? 'checked' : '', )); $template->assign_vars(array( - 'H_C_AL_MESS' => ($hide_cat_opt && !$showhide), + 'H_C_AL_MESS' => $hide_cat_opt && !$showhide, )); if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) { @@ -216,10 +216,10 @@ foreach ($cat_forums as $cid => $c) { $forums_count++; $new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : ''; - $folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"]; + $folder_image = $is_sf ? $images["icon_minipost{$new}"] : $images["forum{$new}"]; if ($f['forum_status'] == FORUM_LOCKED) { - $folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked']; + $folder_image = $is_sf ? $images['icon_minipost'] : $images['forum_locked']; } if ($is_sf) { @@ -240,7 +240,7 @@ foreach ($cat_forums as $cid => $c) { 'TOPICS' => commify($f['forum_topics']), 'LAST_SF_ID' => $f['last_sf_id'] ?? null, 'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '', - 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'], + 'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD'], )); if ($f['last_post_id']) { @@ -257,9 +257,9 @@ foreach ($cat_forums as $cid => $c) { $template->assign_vars(array( 'SHOW_FORUMS' => $forums_count, - 'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST), - 'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : $lang['HOME'], - 'NO_FORUMS_MSG' => ($only_new) ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], + 'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST, + 'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'], + 'NO_FORUMS_MSG' => $only_new ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']), 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']), @@ -294,13 +294,13 @@ $template->assign_vars(array( 'FORUM_LOCKED_IMG' => $images['forum_locked'], 'SHOW_ONLY_NEW_MENU' => true, - 'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS), - 'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS), + 'ONLY_NEW_POSTS_ON' => $only_new == ONLY_NEW_POSTS, + 'ONLY_NEW_TOPICS_ON' => $only_new == ONLY_NEW_TOPICS, - 'U_SEARCH_NEW' => "search.php?new=1", + 'U_SEARCH_NEW' => 'search.php?new=1', 'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&o=1", - 'U_SEARCH_LATEST' => "search.php?search_id=latest", - 'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered", + 'U_SEARCH_LATEST' => 'search.php?search_id=latest', + 'U_SEARCH_UNANSWERED' => 'search.php?search_id=unanswered', 'SHOW_LAST_TOPIC' => $show_last_topic, )); @@ -365,7 +365,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { } $week_list[] = profile_url($week) . ' (' . birthday_age($week['user_birthday']) . ')'; } - $week_all = ($week_all) ? ' ...' : ''; + $week_all = $week_all ? ' ...' : ''; $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], implode(', ', $week_list)) . $week_all; } else { $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday_check_day']); @@ -380,7 +380,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { } $today_list[] = profile_url($today) . ' (' . birthday_age($today['user_birthday']) . ')'; } - $today_all = ($today_all) ? ' ...' : ''; + $today_all = $today_all ? ' ...' : ''; $today_list = $lang['BIRTHDAY_TODAY'] . implode(', ', $today_list) . $today_all; } else { $today_list = $lang['NOBIRTHDAY_TODAY']; diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index ffbe08e4b..e92f1fc59 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -964,7 +964,7 @@ CREATE TABLE IF NOT EXISTS `bb_posts_text` ( -- Records of bb_posts_text -- ---------------------------- INSERT INTO `bb_posts_text` VALUES ('1', - 'Благодарим вас за установку новой версии TorrentPier Aurochs!\n\nЧто делать дальше? Сперва настройте ваш сайт в администраторском разделе. Измените базовые опции: заголовок сайта, число сообщений на страницу, часовой пояс, язык по-умолчанию, настройки сидбонусов, дней рождения и т.д. Создайте несколько форумов, а также не забудьте переименовать или удалить этот. Обязательно настройте возможность создания релизов в созданных вами разделах и добавьте [url=https://torrentpier.com/threads/25867/]шаблоны оформления раздач[/url] для них. Если у вас возникнут вопросы или потребность в дополнительных модификациях, [url=https://torrentpier.com/forum/]посетите наш форум[/url].\n\nТакже напоминаем, что у проекта TorrentPier есть несколько сайтов, которые могут оказаться полезны для вас:\n[list]\n[*]Форум: https://torrentpier.com/forum/\n[*]Демо-версия: https://demo.torrentpier.com/\n[*]Инструкция: https://docs.torrentpier.com/\n[*]Центр загрузки: https://get.torrentpier.com/\n[*]Перевод на другие языки: https://crowdin.com/project/torrentpier\n[/list]\nНе забудьте добавить их себе в закладки и регулярно проверять наличие новых версий движка на нашем форуме, для своевременного обновления.\n\nНе сомневаемся, вам под силу создать самый лучший трекер. Удачи!'); + 'Благодарим вас за установку новой версии TorrentPier Bison!\n\nЧто делать дальше? Сперва настройте ваш сайт в администраторском разделе. Измените базовые опции: заголовок сайта, число сообщений на страницу, часовой пояс, язык по-умолчанию, настройки сидбонусов, дней рождения и т.д. Создайте несколько форумов, а также не забудьте переименовать или удалить этот. Обязательно настройте возможность создания релизов в созданных вами разделах и добавьте [url=https://torrentpier.com/threads/25867/]шаблоны оформления раздач[/url] для них. Если у вас возникнут вопросы или потребность в дополнительных модификациях, [url=https://torrentpier.com/forum/]посетите наш форум[/url].\n\nТакже напоминаем, что у проекта TorrentPier есть несколько сайтов, которые могут оказаться полезны для вас:\n[list]\n[*]Форум: https://torrentpier.com/forum/\n[*]Демо-версия: https://demo.torrentpier.com/\n[*]Инструкция: https://docs.torrentpier.com/\n[*]Центр загрузки: https://get.torrentpier.com/\n[*]Перевод на другие языки: https://crowdin.com/project/torrentpier\n[/list]\nНе забудьте добавить их себе в закладки и регулярно проверять наличие новых версий движка на нашем форуме, для своевременного обновления.\n\nНе сомневаемся, вам под силу создать самый лучший трекер. Удачи!'); -- ---------------------------- -- Table structure for `bb_privmsgs` @@ -1224,7 +1224,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics` ( -- Records of bb_topics -- ---------------------------- INSERT INTO `bb_topics` VALUES - ('1', '1', 'Добро пожаловать в TorrentPier Aurochs', '2', UNIX_TIMESTAMP(), '2', '0', '0', '0', '0', '1', '1', '0', '0', + ('1', '1', 'Добро пожаловать в TorrentPier Bison', '2', UNIX_TIMESTAMP(), '2', '0', '0', '0', '0', '1', '1', '0', '0', '0', '1414658247', '0'); -- ---------------------------- diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index daf1cb0d8..8c6957ae4 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -11,18 +11,6 @@ * All Attachment Functions needed everywhere */ -/** - * html_entity_decode replacement (from php manual) - */ -if (!function_exists('html_entity_decode')) { - function html_entity_decode($given_html, $quote_style = ENT_QUOTES) - { - $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)); - $trans_table['''] = "'"; - return (strtr($given_html, $trans_table)); - } -} - /** * A simple dectobase64 function */ diff --git a/library/config.php b/library/config.php index 2f80b053f..b85fe174f 100644 --- a/library/config.php +++ b/library/config.php @@ -55,7 +55,7 @@ $bb_cfg['db_alias'] = [ $bb_cfg['cache'] = [ 'pconnect' => true, 'db_dir' => realpath(BB_ROOT) . '/internal_data/cache/filecache/', - 'prefix' => 'tp_', // Префикс кеша ('tp_') + 'prefix' => 'tp_', 'memcache' => [ 'host' => '127.0.0.1', 'port' => 11211, @@ -67,7 +67,7 @@ $bb_cfg['cache'] = [ 'port' => 6379, 'con_required' => true, ], - // Available cache types: memcache, sqlite, redis, apc, xcache (default of filecache) + // Available cache types: memcache, sqlite, redis, (filecache by default) 'engines' => [ 'bb_cache' => ['filecache', []], 'bb_config' => ['filecache', []], @@ -80,12 +80,12 @@ $bb_cfg['cache'] = [ ]; // Datastore -// Available datastore types: memcache, sqlite, redis, apc, xcache (default filecache) +// Available datastore types: memcache, sqlite, redis (filecache by default) $bb_cfg['datastore_type'] = 'filecache'; // Server $bb_cfg['server_name'] = $domain_name; // The domain name from which this board runs -$bb_cfg['server_port'] = (!empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : 80; // The port your server is running on +$bb_cfg['server_port'] = !empty($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; // The port your server is running on $bb_cfg['script_path'] = '/'; // The path where FORUM is located relative to the domain name // GZip @@ -494,7 +494,7 @@ $bb_cfg['group_members_per_page'] = 50; $bb_cfg['tidy_post'] = (!in_array('tidy', get_loaded_extensions(), true)) ? false : true; // Misc -$bb_cfg['mem_on_start'] = MEM_USAGE ? memory_get_usage() : 0; +$bb_cfg['mem_on_start'] = memory_get_usage(); $bb_cfg['translate_dates'] = true; // in displaying time $bb_cfg['use_word_censor'] = true; diff --git a/library/defines.php b/library/defines.php index 556db87fd..316734203 100644 --- a/library/defines.php +++ b/library/defines.php @@ -75,9 +75,6 @@ define('BB_DISABLED', TRIGGERS_DIR . '/$off'); define('CRON_ALLOWED', TRIGGERS_DIR . '/cron_allowed'); define('CRON_RUNNING', TRIGGERS_DIR . '/cron_running'); -// Misc -define('MEM_USAGE', function_exists('memory_get_usage')); - // Gzip define('GZIP_OUTPUT_ALLOWED', extension_loaded('zlib') && !ini_get('zlib.output_compression')); define('UA_GZIP_SUPPORTED', isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false); diff --git a/library/includes/functions.php b/library/includes/functions.php index 31d4fd11a..0ae93dc9b 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1475,98 +1475,6 @@ function topic_attachment_image($switch_attachment) return ' '; } -/** - * array_combine() - * - * @package PHP_Compat - * @link http://php.net/function.array_combine - * @author Aidan Lister - * @version $Revision: 1.21 $ - * @since PHP 5 - */ -if (!function_exists('array_combine')) { - function array_combine($keys, $values) - { - if (!is_array($keys)) { - user_error('array_combine() expects parameter 1 to be array, ' . - gettype($keys) . ' given', E_USER_WARNING); - return; - } - - if (!is_array($values)) { - user_error('array_combine() expects parameter 2 to be array, ' . - gettype($values) . ' given', E_USER_WARNING); - return; - } - - $key_count = count($keys); - $value_count = count($values); - if ($key_count !== $value_count) { - user_error('array_combine() both parameters should have equal number of elements', E_USER_WARNING); - return false; - } - - if ($key_count === 0 || $value_count === 0) { - user_error('array_combine() both parameters should have number of elements at least 0', E_USER_WARNING); - return false; - } - - $keys = array_values($keys); - $values = array_values($values); - - $combined = array(); - for ($i = 0; $i < $key_count; $i++) { - $combined[$keys[$i]] = $values[$i]; - } - - return $combined; - } -} - -/** - * array_intersect_key() - * - * @package PHP_Compat - * @link http://php.net/function.array_intersect_key - * @author Tom Buskens - * @version $Revision: 1.4 $ - * @since PHP 5.0.2 - */ -if (!function_exists('array_intersect_key')) { - function array_intersect_key() - { - $args = func_get_args(); - if (count($args) < 2) { - user_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING); - return; - } - - // Check arrays - $array_count = count($args); - foreach ($args as $i => $iValue) { - if (!is_array($args[$i])) { - user_error('array_intersect_key() Argument #' . - ($i + 1) . ' is not an array', E_USER_WARNING); - return; - } - } - - // Compare entries - $result = array(); - foreach ($args[0] as $key1 => $value1) { - for ($i = 1; $i !== $array_count; $i++) { - foreach ($args[$i] as $key2 => $value2) { - if ((string)$key1 === (string)$key2) { - $result[$key1] = $value1; - } - } - } - } - - return $result; - } -} - function clear_dl_list($topics_csv) { DB()->query("DELETE FROM " . BB_BT_DLSTATUS . " WHERE topic_id IN($topics_csv)"); diff --git a/src/Legacy/Cache/Apc.php b/src/Legacy/Cache/Apc.php deleted file mode 100644 index 9cd1fc828..000000000 --- a/src/Legacy/Cache/Apc.php +++ /dev/null @@ -1,72 +0,0 @@ -is_installed()) { - die('Error: APC extension not installed'); - } - $this->dbg_enabled = sql_dbg_enabled(); - $this->prefix = $prefix; - } - - public function get($name, $get_miss_key_callback = '', $ttl = 0) - { - $this->cur_query = "cache->get('$name')"; - $this->debug('start'); - $this->debug('stop'); - $this->cur_query = null; - $this->num_queries++; - - return apc_fetch($this->prefix . $name); - } - - public 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($this->prefix . $name, $value, $ttl); - } - - public function rm($name = '') - { - if ($name) { - $this->cur_query = "cache->rm('$name')"; - $this->debug('start'); - $this->debug('stop'); - $this->cur_query = null; - $this->num_queries++; - - return apc_delete($this->prefix . $name); - } - - return apc_clear_cache(); - } - - public function is_installed() - { - return \function_exists('apc_fetch'); - } -} diff --git a/src/Legacy/Cache/Xcache.php b/src/Legacy/Cache/Xcache.php deleted file mode 100644 index 3192b0862..000000000 --- a/src/Legacy/Cache/Xcache.php +++ /dev/null @@ -1,74 +0,0 @@ -is_installed()) { - die('Error: XCache extension not installed'); - } - $this->dbg_enabled = sql_dbg_enabled(); - $this->prefix = $prefix; - } - - public function get($name, $get_miss_key_callback = '', $ttl = 0) - { - $this->cur_query = "cache->get('$name')"; - $this->debug('start'); - $this->debug('stop'); - $this->cur_query = null; - $this->num_queries++; - - return xcache_get($this->prefix . $name); - } - - public 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($this->prefix . $name, $value, $ttl); - } - - public function rm($name = '') - { - if ($name) { - $this->cur_query = "cache->rm('$name')"; - $this->debug('start'); - $this->debug('stop'); - $this->cur_query = null; - $this->num_queries++; - - return xcache_unset($this->prefix . $name); - } - - xcache_clear_cache(XC_TYPE_PHP, 0); - xcache_clear_cache(XC_TYPE_VAR, 0); - return; - } - - public function is_installed() - { - return \function_exists('xcache_get'); - } -} diff --git a/src/Legacy/Caches.php b/src/Legacy/Caches.php index a1f44ead2..9292d7c6a 100644 --- a/src/Legacy/Caches.php +++ b/src/Legacy/Caches.php @@ -71,20 +71,6 @@ class Caches $this->ref[$cache_name] =& $this->obj[$cache_name]; break; - case 'apc': - if (!isset($this->obj[$cache_name])) { - $this->obj[$cache_name] = new Cache\Apc($this->cfg['prefix']); - } - $this->ref[$cache_name] =& $this->obj[$cache_name]; - break; - - case 'xcache': - if (!isset($this->obj[$cache_name])) { - $this->obj[$cache_name] = new Cache\Xcache($this->cfg['prefix']); - } - $this->ref[$cache_name] =& $this->obj[$cache_name]; - break; - default: //filecache if (!isset($this->obj[$cache_name])) { $this->obj[$cache_name] = new Cache\File($this->cfg['db_dir'] . $cache_name . '/', $this->cfg['prefix']); diff --git a/src/Legacy/Datastore/Apc.php b/src/Legacy/Datastore/Apc.php deleted file mode 100644 index 79960165e..000000000 --- a/src/Legacy/Datastore/Apc.php +++ /dev/null @@ -1,78 +0,0 @@ -is_installed()) { - die('Error: APC extension not installed'); - } - $this->dbg_enabled = sql_dbg_enabled(); - $this->prefix = $prefix; - } - - public 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($this->prefix . $title, $var); - } - - public function clean() - { - 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($this->prefix . $title); - } - } - - public function _fetch_from_store() - { - if (!$items = $this->queued_items) { - $src = $this->_debug_find_caller('enqueue'); - trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR); - } - - 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($this->prefix . $item); - } - } - - public function is_installed() - { - return \function_exists('apc_fetch'); - } -} diff --git a/src/Legacy/Datastore/Xcache.php b/src/Legacy/Datastore/Xcache.php deleted file mode 100644 index d63083a91..000000000 --- a/src/Legacy/Datastore/Xcache.php +++ /dev/null @@ -1,79 +0,0 @@ -is_installed()) { - die('Error: XCache extension not installed'); - } - - $this->dbg_enabled = sql_dbg_enabled(); - $this->prefix = $prefix; - } - - public 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($this->prefix . $title, $var); - } - - public function clean() - { - 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($this->prefix . $title); - } - } - - public function _fetch_from_store() - { - if (!$items = $this->queued_items) { - $src = $this->_debug_find_caller('enqueue'); - trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR); - } - - 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($this->prefix . $item); - } - } - - public function is_installed() - { - return \function_exists('xcache_get'); - } -} diff --git a/src/Legacy/Emailer.php b/src/Legacy/Emailer.php index ceee01cac..cb07e5e28 100644 --- a/src/Legacy/Emailer.php +++ b/src/Legacy/Emailer.php @@ -26,12 +26,12 @@ class Emailer /** * Обычное текстовое сообщение */ - const FORMAT_TEXT = 'text/plain'; + public const FORMAT_TEXT = 'text/plain'; /** * HTML-сообщение */ - const FORMAT_HTML = 'text/html'; + public const FORMAT_HTML = 'text/html'; /** @var string текст сообщения */ private $message; diff --git a/src/Legacy/Torrent.php b/src/Legacy/Torrent.php index b357cfc1e..6c376dbf8 100644 --- a/src/Legacy/Torrent.php +++ b/src/Legacy/Torrent.php @@ -717,7 +717,6 @@ class Torrent $header = "GET /$get HTTP/1.1\r\nConnection: Close\r\n\r\n"; $attempts = $success = $response = 0; - $start_time = microtime(true); while (!$success && $attempts++ < $max_attempts) { @@ -737,14 +736,10 @@ class Torrent while (!feof($file)) { $response .= fread($file, 1024); } - $data_start = strpos($response, "\r\n\r\n") + 4; + $data_end = strrpos($response, "\n"); - if ($data_end > $data_start) { - $data = substr($response, $data_start, $data_end - $data_start); - } else { - $data = ""; - } $status = substr($response, $data_end + 1); + if ($status == "success") { $success = true; }