diff --git a/common.php b/common.php index d9583595d..0cd90035a 100644 --- a/common.php +++ b/common.php @@ -7,8 +7,6 @@ * @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License */ -use TorrentPier\Env; - if (isset($_REQUEST['GLOBALS'])) { die(); } @@ -61,7 +59,7 @@ require_once __DIR__ . '/vendor/autoload.php'; */ function env(string $key, $default = null) { - return Env::get($key, $default); + return \TorrentPier\Env::get($key, $default); } // Get initial config @@ -317,7 +315,13 @@ function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false) } } -function hide_bb_path($path) +/** + * Hide BB_PATH + * + * @param string $path + * @return string + */ +function hide_bb_path(string $path): string { return ltrim(str_replace(BB_PATH, '', $path), '/\\'); } @@ -339,11 +343,6 @@ function sys($param) } } -function ver_compare($version1, $operator, $version2) -{ - return version_compare($version1, $version2, $operator); -} - function dbg_log($str, $file) { $dir = LOG_DIR . (defined('IN_TRACKER') ? '/dbg_tr/' : '/dbg_bb/') . date('m-d_H') . '/'; @@ -394,7 +393,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true) // Board or tracker init if (!defined('IN_TRACKER')) { - require INC_DIR . '/init_bb.php'; + require_once INC_DIR . '/init_bb.php'; } else { define('DUMMY_PEER', pack('Nn', \TorrentPier\Helpers\IPHelper::encodeIP($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000))); diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index f387c6792..e56a7bdc9 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -379,10 +379,12 @@ function html_ent_decode($txt, $quote_style = ENT_QUOTES, $charset = 'UTF-8') } /** + * Makes URL from path + * * @param string $path * @return string */ -function make_url($path = '') +function make_url(string $path = ''): string { return FULL_URL . preg_replace('#^\/?(.*?)\/?$#', '\1', $path); } @@ -390,7 +392,7 @@ function make_url($path = '') /** * Functions */ -require INC_DIR . '/functions.php'; +require_once INC_DIR . '/functions.php'; $bb_cfg = array_merge(bb_get_config(BB_CONFIG), $bb_cfg);