Minor fixes (#663)

This commit is contained in:
Roman Kelesidis 2023-03-28 12:17:42 +07:00 committed by GitHub
commit 642e49e77d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

View file

@ -7,8 +7,6 @@
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License * @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/ */
use TorrentPier\Env;
if (isset($_REQUEST['GLOBALS'])) { if (isset($_REQUEST['GLOBALS'])) {
die(); die();
} }
@ -61,7 +59,7 @@ require_once __DIR__ . '/vendor/autoload.php';
*/ */
function env(string $key, $default = null) function env(string $key, $default = null)
{ {
return Env::get($key, $default); return \TorrentPier\Env::get($key, $default);
} }
// Get initial config // 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), '/\\'); 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) function dbg_log($str, $file)
{ {
$dir = LOG_DIR . (defined('IN_TRACKER') ? '/dbg_tr/' : '/dbg_bb/') . date('m-d_H') . '/'; $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 // Board or tracker init
if (!defined('IN_TRACKER')) { if (!defined('IN_TRACKER')) {
require INC_DIR . '/init_bb.php'; require_once INC_DIR . '/init_bb.php';
} else { } else {
define('DUMMY_PEER', pack('Nn', \TorrentPier\Helpers\IPHelper::encodeIP($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000))); define('DUMMY_PEER', pack('Nn', \TorrentPier\Helpers\IPHelper::encodeIP($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000)));

View file

@ -379,10 +379,12 @@ function html_ent_decode($txt, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
} }
/** /**
* Makes URL from path
*
* @param string $path * @param string $path
* @return string * @return string
*/ */
function make_url($path = '') function make_url(string $path = ''): string
{ {
return FULL_URL . preg_replace('#^\/?(.*?)\/?$#', '\1', $path); return FULL_URL . preg_replace('#^\/?(.*?)\/?$#', '\1', $path);
} }
@ -390,7 +392,7 @@ function make_url($path = '')
/** /**
* Functions * Functions
*/ */
require INC_DIR . '/functions.php'; require_once INC_DIR . '/functions.php';
$bb_cfg = array_merge(bb_get_config(BB_CONFIG), $bb_cfg); $bb_cfg = array_merge(bb_get_config(BB_CONFIG), $bb_cfg);