mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
Merge branch 'promotion' into php8
This commit is contained in:
@@ -6,9 +6,8 @@ if(!defined('IN_TRACKER'))
|
||||
die('Hacking attempt!');
|
||||
|
||||
function printProgress($msg) {
|
||||
echo $msg.'...done<br />';
|
||||
ob_flush();
|
||||
flush();
|
||||
$br = php_sapi_name() == 'cli' ? "\n" : "<br />";
|
||||
echo sprintf("[%s] %s ... done!%s", date('Y-m-d H:i:s'), $msg, $br);
|
||||
}
|
||||
|
||||
function torrent_promotion_expire($days, $type = 2, $targettype = 1){
|
||||
|
||||
26
include/cleanup_cli.php
Normal file
26
include/cleanup_cli.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* do clean in cli
|
||||
*
|
||||
*/
|
||||
|
||||
require "bittorrent.php";
|
||||
require "cleanup.php";
|
||||
|
||||
$fd = fopen(sprintf('%s/nexus_cleanup_cli.lock', sys_get_temp_dir()), 'w+');
|
||||
if (!flock($fd, LOCK_EX|LOCK_NB)) {
|
||||
do_log("can not get lock, skip!");
|
||||
}
|
||||
register_shutdown_function(function () use ($fd) {
|
||||
fclose($fd);
|
||||
});
|
||||
|
||||
try {
|
||||
docleanup(0, true);
|
||||
do_log("[CLEANUP_CLI DONE!]");
|
||||
} catch (\Exception $exception) {
|
||||
do_log("ERROR: " . $exception->getMessage());
|
||||
throw new \RuntimeException($exception->getMessage());
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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'] ?? '',
|
||||
|
||||
Reference in New Issue
Block a user