diff --git a/include/cleanup.php b/include/cleanup.php index 335898c8..f327f2ce 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -6,9 +6,8 @@ if(!defined('IN_TRACKER')) die('Hacking attempt!'); function printProgress($msg) { - echo $msg.'...done
'; - ob_flush(); - flush(); + $br = php_sapi_name() == 'cli' ? "\n" : "
"; + echo sprintf("[%s] %s ... done!%s", date('Y-m-d H:i:s'), $msg, $br); } function torrent_promotion_expire($days, $type = 2, $targettype = 1){ diff --git a/include/cleanup_cli.php b/include/cleanup_cli.php new file mode 100644 index 00000000..0091787d --- /dev/null +++ b/include/cleanup_cli.php @@ -0,0 +1,26 @@ +getMessage()); + throw new \RuntimeException($exception->getMessage()); +} + diff --git a/include/config.php b/include/config.php index ff97c422..883a5180 100644 --- a/include/config.php +++ b/include/config.php @@ -69,7 +69,7 @@ foreach ($settings as $name => $value) { $SITENAME = $BASIC['SITENAME']; //$BASEURL = $BASIC['BASEURL']; -$BASEURL = $_SERVER['HTTP_HOST']; +$BASEURL = $_SERVER['HTTP_HOST'] ?? ''; $announce_urls = array(); //$announce_urls[] = $BASIC['announce_url']; $announce_urls[] = $BASEURL . '/announce.php'; diff --git a/include/globalfunctions.php b/include/globalfunctions.php index e5cd3d42..924cbac5 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -47,7 +47,7 @@ function getip() { } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { - $ip = $_SERVER['REMOTE_ADDR']; + $ip = $_SERVER['REMOTE_ADDR'] ?? ''; } } else { if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) { @@ -55,7 +55,7 @@ function getip() { } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) { $ip = getenv('HTTP_CLIENT_IP'); } else { - $ip = getenv('REMOTE_ADDR'); + $ip = getenv('REMOTE_ADDR') ?? ''; } } @@ -159,8 +159,9 @@ function do_log($log, $level = 'info') if (($fd = fopen($logFile, 'a')) === false) { $fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a'); } - static $uid, $passkey, $env; + static $uid, $passkey, $env, $sequence; if (is_null($uid)) { + $sequence = 0; if (IN_NEXUS) { global $CURUSER; $user = $CURUSER; @@ -173,14 +174,18 @@ function do_log($log, $level = 'info') $passkey = $user->passkey ?? $_REQUEST['passkey'] ?? ''; $env = env('APP_ENV'); } + } else { + $sequence++; } $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $content = sprintf( - "[%s] [%s] [%s] [%s] %s.%s %s:%s %s%s%s %s%s", + "[%s] [%s] [%s] [%s] [%s] [%s] %s.%s %s:%s %s%s%s %s%s", date('Y-m-d H:i:s'), defined('REQUEST_ID') ? REQUEST_ID : '', $uid, $passkey, + $sequence, + sprintf('%.3f', microtime(true) - NEXUS_START), $env, $level, $backtrace[0]['file'] ?? '', $backtrace[0]['line'] ?? '',