mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
prepare for v1.6.0-beta
This commit is contained in:
+8
-1
@@ -6,4 +6,11 @@ MYSQL_DATABASE=nexusphp
|
|||||||
|
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=127.0.0.1
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_DATABASE=0
|
REDIS_DATABASE=0
|
||||||
|
|
||||||
|
USE_CRON_TRIGGER_CLEANUP=false
|
||||||
|
|
||||||
|
LOG_FILE=/tmp/nexus.log
|
||||||
|
LOG_SPLIT=daily
|
||||||
|
|
||||||
|
TIMEZONE=PRC
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'timezone' => env('TIMEZONE', 'PRC'),
|
||||||
|
|
||||||
|
'log_file' => env('LOG_FILE', '/tmp/nexus.log'),
|
||||||
|
|
||||||
|
'log_split' => env('LOG_SPLIT', 'daily'),
|
||||||
|
|
||||||
|
'use_cron_trigger_cleanup' => env('USE_CRON_TRIGGER_CLEANUP', false),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -4,6 +4,7 @@ if(!defined('IN_TRACKER'))
|
|||||||
die('Hacking attempt!');
|
die('Hacking attempt!');
|
||||||
|
|
||||||
function printProgress($msg) {
|
function printProgress($msg) {
|
||||||
|
do_log($msg);
|
||||||
echo $msg.'...done<br />';
|
echo $msg.'...done<br />';
|
||||||
ob_flush();
|
ob_flush();
|
||||||
flush();
|
flush();
|
||||||
|
|||||||
+1
-1
@@ -401,7 +401,7 @@ $SUBSPATH = "subs";
|
|||||||
//Make sure you have wget installed on your OS
|
//Make sure you have wget installed on your OS
|
||||||
//replace "http://www.nexusphp.com/" with your own site address
|
//replace "http://www.nexusphp.com/" with your own site address
|
||||||
|
|
||||||
$useCronTriggerCleanUp = config('use_cron_trigger_clean_up', false);
|
$useCronTriggerCleanUp = config('nexus.use_cron_trigger_cleanup', false);
|
||||||
//some promotion rules
|
//some promotion rules
|
||||||
//$promotionrules_torrent = array(0 => array("mediumid" => array(1), "promotion" => 5), 1 => array("mediumid" => array(3), "promotion" => 5), 2 => array("catid" => array(402), "standardid" => array(3), "promotion" => 4), 3 => array("catid" => array(403), "standardid" => array(3), "promotion" => 4));
|
//$promotionrules_torrent = array(0 => array("mediumid" => array(1), "promotion" => 5), 1 => array("mediumid" => array(3), "promotion" => 5), 2 => array("catid" => array(402), "standardid" => array(3), "promotion" => 4), 3 => array("catid" => array(403), "standardid" => array(3), "promotion" => 4));
|
||||||
$promotionrules_torrent = array();
|
$promotionrules_torrent = array();
|
||||||
|
|||||||
+14
-11
@@ -2,6 +2,18 @@
|
|||||||
if(!defined('IN_TRACKER')) {
|
if(!defined('IN_TRACKER')) {
|
||||||
die('Hacking attempt!');
|
die('Hacking attempt!');
|
||||||
}
|
}
|
||||||
|
define('ROOT_PATH', $rootpath);
|
||||||
|
define('VERSION_NUMBER', '1.6.0');
|
||||||
|
define('IS_ANNOUNCE', (basename($_SERVER['SCRIPT_FILENAME']) == 'announce.php'));
|
||||||
|
if (!empty($_SERVER['HTTP_X_REQUEST_ID'])) {
|
||||||
|
define('REQUEST_ID', $_SERVER['HTTP_X_REQUEST_ID']);
|
||||||
|
} else {
|
||||||
|
define('REQUEST_ID', intval(NEXUS_START * 10000));
|
||||||
|
}
|
||||||
|
ini_set('date.timezone', config('nexus.timezone'));
|
||||||
|
ini_set('error_reporting', E_ALL);
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
|
||||||
if (!file_exists($rootpath . '.env')) {
|
if (!file_exists($rootpath . '.env')) {
|
||||||
$installScriptRelativePath = 'install/install.php';
|
$installScriptRelativePath = 'install/install.php';
|
||||||
$installScriptFile = $rootpath . "public/$installScriptRelativePath";
|
$installScriptFile = $rootpath . "public/$installScriptRelativePath";
|
||||||
@@ -10,16 +22,8 @@ if (!file_exists($rootpath . '.env')) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
if (!empty($_SERVER['HTTP_X_REQUEST_ID'])) {
|
|
||||||
define('REQUEST_ID', $_SERVER['HTTP_X_REQUEST_ID']);
|
|
||||||
} else {
|
|
||||||
define('REQUEST_ID', intval(NEXUS_START * 10000));
|
|
||||||
}
|
|
||||||
define('ROOT_PATH', $rootpath);
|
|
||||||
define('VERSION_NUMBER', '1.6.0');
|
|
||||||
define('IS_ANNOUNCE', (basename($_SERVER['SCRIPT_FILENAME']) == 'announce.php'));
|
|
||||||
require $rootpath . 'vendor/autoload.php';
|
require $rootpath . 'vendor/autoload.php';
|
||||||
require $rootpath . 'nexus/Database/helpers.php';
|
require $rootpath . 'nexus/Database/helpers.php';
|
||||||
require $rootpath . 'classes/class_advertisement.php';
|
require $rootpath . 'classes/class_advertisement.php';
|
||||||
@@ -31,7 +35,6 @@ if (!IS_ANNOUNCE) {
|
|||||||
$Cache = new class_cache_redis(); //Load the caching class
|
$Cache = new class_cache_redis(); //Load the caching class
|
||||||
$Cache->setLanguageFolderArray(get_langfolder_list());
|
$Cache->setLanguageFolderArray(get_langfolder_list());
|
||||||
define('TIMENOW', time());
|
define('TIMENOW', time());
|
||||||
define('TIMENOW_STRING', date('Y-m-d H:i:s'));
|
|
||||||
$USERUPDATESET = array();
|
$USERUPDATESET = array();
|
||||||
$query_name=array();
|
$query_name=array();
|
||||||
|
|
||||||
|
|||||||
@@ -1870,19 +1870,21 @@ function userlogin() {
|
|||||||
function autoclean() {
|
function autoclean() {
|
||||||
global $autoclean_interval_one, $rootpath;
|
global $autoclean_interval_one, $rootpath;
|
||||||
$now = TIMENOW;
|
$now = TIMENOW;
|
||||||
|
|
||||||
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
|
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
|
||||||
$row = mysql_fetch_array($res);
|
$row = mysql_fetch_array($res);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
|
do_log("SELECT value_u FROM avps WHERE arg = 'lastcleantime', empty");
|
||||||
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)") or sqlerr(__FILE__, __LINE__);
|
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)") or sqlerr(__FILE__, __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$ts = $row[0];
|
$ts = $row[0];
|
||||||
if ($ts + $autoclean_interval_one > $now) {
|
if ($ts + $autoclean_interval_one > $now) {
|
||||||
|
do_log("ts: {$ts} + autoclean_interval_one: $autoclean_interval_one > now: $now");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts") or sqlerr(__FILE__, __LINE__);
|
sql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts") or sqlerr(__FILE__, __LINE__);
|
||||||
if (!mysql_affected_rows()) {
|
if (!mysql_affected_rows()) {
|
||||||
|
do_log("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts, affectedRows = 0");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
require_once($rootpath . 'include/cleanup.php');
|
require_once($rootpath . 'include/cleanup.php');
|
||||||
|
|||||||
@@ -5,15 +5,7 @@ if(!defined('IN_TRACKER'))
|
|||||||
|
|
||||||
function dbconn_announce() {
|
function dbconn_announce() {
|
||||||
|
|
||||||
$config = config('database.mysql');
|
\Nexus\Database\DB::getInstance()->autoConnect();
|
||||||
|
|
||||||
if (!@mysql_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']))
|
|
||||||
{
|
|
||||||
die('dbconn: mysql_connect: ' . mysql_error());
|
|
||||||
}
|
|
||||||
mysql_query("SET NAMES UTF8");
|
|
||||||
mysql_query("SET collation_connection = 'utf8_general_ci'");
|
|
||||||
mysql_query("SET sql_mode=''");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hash_where_arr($name, $hash_arr) {
|
function hash_where_arr($name, $hash_arr) {
|
||||||
|
|||||||
@@ -147,18 +147,14 @@ function dd($vars)
|
|||||||
|
|
||||||
function do_log($log, $level = 'info')
|
function do_log($log, $level = 'info')
|
||||||
{
|
{
|
||||||
global $TWEAK;
|
$logFile = getLogFile();
|
||||||
$logging = sys_get_temp_dir() . '/nexus_' . date('Y-m-d') . '.log';
|
if (($fd = fopen($logFile, 'a')) !== false) {
|
||||||
if (!empty($TWEAK['logging'])) {
|
|
||||||
$logging = $TWEAK['logging'];
|
|
||||||
}
|
|
||||||
if (($fd = fopen($logging, 'a')) !== false) {
|
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
$content = sprintf(
|
$content = sprintf(
|
||||||
"[%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'),
|
date('Y-m-d H:i:s'),
|
||||||
$level,
|
$level,
|
||||||
REQUEST_ID,
|
defined('REQUEST_ID') ? REQUEST_ID : '',
|
||||||
$backtrace[0]['file'] ?? '',
|
$backtrace[0]['file'] ?? '',
|
||||||
$backtrace[0]['line'] ?? '',
|
$backtrace[0]['line'] ?? '',
|
||||||
$backtrace[1]['class'] ?? '',
|
$backtrace[1]['class'] ?? '',
|
||||||
@@ -172,6 +168,43 @@ function do_log($log, $level = 'info')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLogFile()
|
||||||
|
{
|
||||||
|
static $logFile;
|
||||||
|
if (!is_null($logFile)) {
|
||||||
|
return $logFile;
|
||||||
|
}
|
||||||
|
$config = config('nexus');
|
||||||
|
$logFile = sys_get_temp_dir() . '/nexus_' . date('Y-m-d') . '.log';
|
||||||
|
if (!empty($config['log_file'])) {
|
||||||
|
$logFile = $config['log_file'];
|
||||||
|
}
|
||||||
|
$validSplit = ['daily', 'monthly'];
|
||||||
|
if (empty($config['log_split']) || !in_array($config['log_split'], $validSplit)) {
|
||||||
|
return $logFile;
|
||||||
|
}
|
||||||
|
$lastDotPos = strrpos($logFile, '.');
|
||||||
|
if ($lastDotPos !== false) {
|
||||||
|
$prefix = substr($logFile, 0, $lastDotPos);
|
||||||
|
$suffix = substr($logFile, $lastDotPos);
|
||||||
|
} else {
|
||||||
|
$prefix = $logFile;
|
||||||
|
$suffix = '';
|
||||||
|
}
|
||||||
|
switch ($config['log_split']) {
|
||||||
|
case 'daily':
|
||||||
|
$logFile = sprintf('%s-%s%s', $prefix, date('Y-m-d'), $suffix);
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
$logFile = sprintf('%s-%s%s', $prefix, date('Ym'), $suffix);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $logFile;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function config($key, $default = null)
|
function config($key, $default = null)
|
||||||
{
|
{
|
||||||
static $configs;
|
static $configs;
|
||||||
|
|||||||
@@ -680,8 +680,6 @@ $lang_settings = array
|
|||||||
'text_email_notification_note' => "是否允许用户在收取新短讯、评论等时候收到邮件提示。",
|
'text_email_notification_note' => "是否允许用户在收取新短讯、评论等时候收到邮件提示。",
|
||||||
'text_users_get' => "首次升级至此等级的用户将获得",
|
'text_users_get' => "首次升级至此等级的用户将获得",
|
||||||
'text_invitations_default' => "个邀请名额。默认",
|
'text_invitations_default' => "个邀请名额。默认",
|
||||||
'row_logging' => '运行日志路径',
|
|
||||||
'text_logging_note' => '请填写你的运行时日志路径',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -680,8 +680,6 @@ $lang_settings = array
|
|||||||
'text_email_notification_note' => "是否允許用戶在收取新短訊、評論等時候收到郵件輔助說明。",
|
'text_email_notification_note' => "是否允許用戶在收取新短訊、評論等時候收到郵件輔助說明。",
|
||||||
'text_users_get' => "首次升級至此等級的用戶將獲得",
|
'text_users_get' => "首次升級至此等級的用戶將獲得",
|
||||||
'text_invitations_default' => "個邀請名額。預設",
|
'text_invitations_default' => "個邀請名額。預設",
|
||||||
'row_logging' => '運行日誌路徑',
|
|
||||||
'text_logging_note' => '請填寫妳的運行時日誌路徑',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -680,8 +680,6 @@ $lang_settings = array
|
|||||||
'text_email_notification_note' => "Allow users to receive email notification when he gets new pm, comment, etc.",
|
'text_email_notification_note' => "Allow users to receive email notification when he gets new pm, comment, etc.",
|
||||||
'text_users_get' => "Users would get ",
|
'text_users_get' => "Users would get ",
|
||||||
'text_invitations_default' => " invitations the first time he is promoted to this class. Default ",
|
'text_invitations_default' => " invitations the first time he is promoted to this class. Default ",
|
||||||
'row_logging' => 'Runtime log path',
|
|
||||||
'text_logging_note' => 'Please enter your runtime log path',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ class DB
|
|||||||
|
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
private static $queries = [];
|
|
||||||
|
|
||||||
private $isConnected = false;
|
private $isConnected = false;
|
||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
@@ -55,8 +53,6 @@ class DB
|
|||||||
$this->driver->query("SET collation_connection = 'utf8_general_ci'");
|
$this->driver->query("SET collation_connection = 'utf8_general_ci'");
|
||||||
$this->driver->query("SET sql_mode=''");
|
$this->driver->query("SET sql_mode=''");
|
||||||
$this->isConnected = true;
|
$this->isConnected = true;
|
||||||
$log = json_encode(func_get_args());
|
|
||||||
do_log($log);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +62,6 @@ class DB
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$config = config('database.mysql');
|
$config = config('database.mysql');
|
||||||
do_log(json_encode($config));
|
|
||||||
return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ class Install
|
|||||||
|
|
||||||
private $minimumPhpVersion = '7.2.0';
|
private $minimumPhpVersion = '7.2.0';
|
||||||
|
|
||||||
|
private $progressKeyPrefix = '__step';
|
||||||
|
|
||||||
protected $steps = ['环境检测', '添加 .env 文件', '创建数据表', '导入数据', '创建管理员账号'];
|
protected $steps = ['环境检测', '添加 .env 文件', '创建数据表', '导入数据', '创建管理员账号'];
|
||||||
|
|
||||||
protected $initializeTables = [
|
protected $initializeTables = [
|
||||||
@@ -18,9 +20,15 @@ class Install
|
|||||||
'searchbox', 'secondicons', 'sources', 'standards', 'stylesheets', 'sysoppanel', 'teams', 'torrents_state', 'uploadspeed', 'agent_allowed_family',
|
'searchbox', 'secondicons', 'sources', 'standards', 'stylesheets', 'sysoppanel', 'teams', 'torrents_state', 'uploadspeed', 'agent_allowed_family',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $envNames = ['MYSQL_HOST', 'MYSQL_PORT', 'MYSQL_USERNAME', 'MYSQL_PASSWORD', 'MYSQL_DATABASE', 'REDIS_HOST', 'REDIS_PORT', 'REDIS_DATABASE'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
if (!session_id()) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
$this->currentStep = min(intval($_REQUEST['step'] ?? 1) ?: 1, count($this->steps) + 1);
|
$this->currentStep = min(intval($_REQUEST['step'] ?? 1) ?: 1, count($this->steps) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +37,31 @@ class Install
|
|||||||
return $this->currentStep;
|
return $this->currentStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canAccessStep($step)
|
||||||
|
{
|
||||||
|
for ($i = 1; $i < $step; $i++) {
|
||||||
|
$progressKey = $this->getProgressKey($i);
|
||||||
|
if (!isset($_SESSION[$progressKey])) {
|
||||||
|
do_log("check step: $i, session doesn't have, session: " . json_encode($_SESSION));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
do_log("check step: $step, can access, session: " . json_encode($_SESSION));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doneStep($step)
|
||||||
|
{
|
||||||
|
$progressKey = $this->getProgressKey($step);
|
||||||
|
do_log("doneStep: $step, $progressKey = 1");
|
||||||
|
$_SESSION[$progressKey] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getProgressKey($step)
|
||||||
|
{
|
||||||
|
return $this->progressKeyPrefix . $step;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLogFile()
|
public function getLogFile()
|
||||||
{
|
{
|
||||||
return sprintf('%s/nexus_install_%s.log', sys_get_temp_dir(), date('Ymd'));
|
return sprintf('%s/nexus_install_%s.log', sys_get_temp_dir(), date('Ymd'));
|
||||||
@@ -221,6 +254,7 @@ class Install
|
|||||||
|
|
||||||
public function nextStep()
|
public function nextStep()
|
||||||
{
|
{
|
||||||
|
$this->doneStep($this->currentStep);
|
||||||
$this->gotoStep($this->currentStep + 1);
|
$this->gotoStep($this->currentStep + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,13 +342,14 @@ class Install
|
|||||||
}
|
}
|
||||||
$mergeData = array_merge($envExampleData, $envData);
|
$mergeData = array_merge($envExampleData, $envData);
|
||||||
$formControls = [];
|
$formControls = [];
|
||||||
foreach ($mergeData as $key => $value) {
|
foreach ($this->envNames as $name) {
|
||||||
if (isset($_POST[$key])) {
|
$value = $mergeData[$name];
|
||||||
$value = $_POST[$key];
|
if (isset($_POST[$name])) {
|
||||||
|
$value = $_POST[$name];
|
||||||
}
|
}
|
||||||
$formControls[] = [
|
$formControls[] = [
|
||||||
'label' => $key,
|
'label' => $name,
|
||||||
'name' => $key,
|
'name' => $name,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -324,6 +359,10 @@ class Install
|
|||||||
|
|
||||||
public function createAdministrator($username, $email, $password, $confirmPassword)
|
public function createAdministrator($username, $email, $password, $confirmPassword)
|
||||||
{
|
{
|
||||||
|
$count = get_row_count('users', 'where class = 16');
|
||||||
|
if ($count > 0) {
|
||||||
|
throw new \InvalidArgumentException("Administrator already exists");
|
||||||
|
}
|
||||||
if (!validusername($username)) {
|
if (!validusername($username)) {
|
||||||
throw new \InvalidArgumentException("Innvalid username: $username");
|
throw new \InvalidArgumentException("Innvalid username: $username");
|
||||||
}
|
}
|
||||||
@@ -398,7 +437,7 @@ class Install
|
|||||||
}
|
}
|
||||||
fwrite($fp, $content);
|
fwrite($fp, $content);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$this->doLog("[CREATE ENV] $envFile with content: \n $content");
|
$this->doLog("[CREATE ENV] $envFile with content: $content");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,6 +503,12 @@ class Install
|
|||||||
if (!in_array($table, $this->initializeTables)) {
|
if (!in_array($table, $this->initializeTables)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
//if table not empty, skip
|
||||||
|
$count = get_row_count($table);
|
||||||
|
if ($count > 0) {
|
||||||
|
$this->doLog("[IMPORT DATA] $table, not empty, skip");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->doLog("[IMPORT DATA] $table, $sql");
|
$this->doLog("[IMPORT DATA] $table, $sql");
|
||||||
sql_query("truncate table $table");
|
sql_query("truncate table $table");
|
||||||
sql_query($sql);
|
sql_query($sql);
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
ini_set('error_reporting', E_ALL);
|
ini_set('error_reporting', E_ALL);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
if (!session_id()) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
$rootpath = dirname(dirname(__DIR__)) . '/';
|
$rootpath = dirname(dirname(__DIR__)) . '/';
|
||||||
define('ROOT_PATH', $rootpath);
|
define('ROOT_PATH', $rootpath);
|
||||||
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
|
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
|
||||||
@@ -15,6 +12,10 @@ require $rootpath . 'nexus/Database/helpers.php';
|
|||||||
$install = new \Nexus\Install\Install();
|
$install = new \Nexus\Install\Install();
|
||||||
$currentStep = $install->currentStep();
|
$currentStep = $install->currentStep();
|
||||||
$maxStep = $install->maxStep();
|
$maxStep = $install->maxStep();
|
||||||
|
if (!$install->canAccessStep($currentStep)) {
|
||||||
|
$install->gotoStep(1);
|
||||||
|
}
|
||||||
|
$error = $copy = '';
|
||||||
|
|
||||||
//step 1
|
//step 1
|
||||||
if ($currentStep == 1) {
|
if ($currentStep == 1) {
|
||||||
@@ -35,7 +36,7 @@ if ($currentStep == 2) {
|
|||||||
$install->createEnvFile($_POST);
|
$install->createEnvFile($_POST);
|
||||||
$install->nextStep();
|
$install->nextStep();
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$_SESSION['error'] = $exception->getMessage();
|
$error = $exception->getMessage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -60,7 +61,7 @@ if ($currentStep == 3) {
|
|||||||
$install->createTable($shouldCreateTable);
|
$install->createTable($shouldCreateTable);
|
||||||
$install->nextStep();
|
$install->nextStep();
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$_SESSION['error'] = $exception->getMessage();
|
$error = $exception->getMessage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -90,7 +91,7 @@ if ($currentStep == 3) {
|
|||||||
// sql_query($sqlAlter);
|
// sql_query($sqlAlter);
|
||||||
// }
|
// }
|
||||||
// } catch (\Exception $e) {
|
// } catch (\Exception $e) {
|
||||||
// $_SESSION['error'] = $e->getMessage();
|
// $error = $e->getMessage();
|
||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@@ -113,7 +114,7 @@ if ($currentStep == 4) {
|
|||||||
$install->importInitialData();
|
$install->importInitialData();
|
||||||
$install->nextStep();
|
$install->nextStep();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$_SESSION['error'] = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -126,7 +127,7 @@ if ($currentStep == 5) {
|
|||||||
$install->createAdministrator($_POST['username'], $_POST['email'], $_POST['password'], $_POST['confirm_password']);
|
$install->createAdministrator($_POST['username'], $_POST['email'], $_POST['password'], $_POST['confirm_password']);
|
||||||
$install->nextStep();
|
$install->nextStep();
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$_SESSION['error'] = $exception->getMessage();
|
$error = $exception->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$pass = true;
|
$pass = true;
|
||||||
@@ -134,7 +135,7 @@ if ($currentStep == 5) {
|
|||||||
['label' => '用户名', 'name' => 'username', 'value' => $_POST['username'] ?? ''],
|
['label' => '用户名', 'name' => 'username', 'value' => $_POST['username'] ?? ''],
|
||||||
['label' => '邮箱', 'name' => 'email', 'value' => $_POST['email'] ?? ''],
|
['label' => '邮箱', 'name' => 'email', 'value' => $_POST['email'] ?? ''],
|
||||||
['label' => '密码', 'name' => 'password', 'value' => $_POST['password'] ?? ''],
|
['label' => '密码', 'name' => 'password', 'value' => $_POST['password'] ?? ''],
|
||||||
['label' => '重复密码', 'name' => 'confirm_password', 'value' => $_POST['confirm_password'] ?? ''],
|
['label' => '确认密码', 'name' => 'confirm_password', 'value' => $_POST['confirm_password'] ?? ''],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -186,13 +187,13 @@ if ($currentStep == 5) {
|
|||||||
}
|
}
|
||||||
echo'</div>';
|
echo'</div>';
|
||||||
|
|
||||||
if (!empty($_SESSION['error'])) {
|
if (!empty($error)) {
|
||||||
echo sprintf('<div class="text-center text-red-500 p-4">Error: %s</div>', nl2br($_SESSION['error']));
|
echo sprintf('<div class="text-center text-red-500 p-4">Error: %s</div>', nl2br($error));
|
||||||
unset($_SESSION['error']);
|
unset($error);
|
||||||
}
|
}
|
||||||
if (!empty($_SESSION['copy'])) {
|
if (!empty($copy)) {
|
||||||
echo sprintf('<div class="text-center"><textarea class="w-1/2 h-40 border">%s</textarea></div>', $_SESSION['copy']);
|
echo sprintf('<div class="text-center"><textarea class="w-1/2 h-40 border">%s</textarea></div>', $copy);
|
||||||
unset($_SESSION['copy']);
|
unset($copy);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="mt-10 text-center">
|
<div class="mt-10 text-center">
|
||||||
@@ -207,7 +208,7 @@ if ($currentStep == 5) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-10 text-center">
|
<div class="mt-10 text-center">
|
||||||
欢迎使用 NexusPHP 安装程序,如有疑问,点击<a href="http://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取参考。
|
欢迎使用 NexusPHP 安装程序,如有疑问,点击<a href="http://nexusphp.org/" target="_blank" class="text-blue-500 p-1">这里</a>获取帮助。
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
+2
-3
@@ -41,7 +41,7 @@ if ($action == 'savesettings_main') // save main
|
|||||||
'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket',
|
'showpolls','showstats','showlastxtorrents', 'showtrackerload','showshoutbox','showfunbox','showoffer','sptime','showhelpbox','enablebitbucket',
|
||||||
'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem',
|
'smalldescription','altname','extforum','extforumurl','defaultlang','defstylesheet', 'donation','spsct','browsecat','specialcat','waitsystem',
|
||||||
'maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start',
|
'maxdlsystem','bitbucket','torrentnameprefix', 'showforumstats','verification','invite_count','invite_timeout', 'seeding_leeching_time_calc_start',
|
||||||
'startsubid', 'logo', 'use_cron_trigger_cleanup', 'showlastxforumposts'
|
'startsubid', 'logo', 'showlastxforumposts'
|
||||||
);
|
);
|
||||||
GetVar($validConfig);
|
GetVar($validConfig);
|
||||||
$MAIN = [];
|
$MAIN = [];
|
||||||
@@ -185,7 +185,7 @@ elseif ($action == 'savesettings_authority') // save user authority
|
|||||||
elseif ($action == 'savesettings_tweak') // save tweak
|
elseif ($action == 'savesettings_tweak') // save tweak
|
||||||
{
|
{
|
||||||
stdhead($lang_settings['head_save_tweak_settings']);
|
stdhead($lang_settings['head_save_tweak_settings']);
|
||||||
$validConfig = array('where','iplog1','bonus','datefounded', 'enablelocation', 'titlekeywords', 'metakeywords', 'metadescription', 'enablesqldebug', 'sqldebug', 'cssdate', 'enabletooltip', 'prolinkimg', 'analyticscode', 'logging');
|
$validConfig = array('where','iplog1','bonus','datefounded', 'enablelocation', 'titlekeywords', 'metakeywords', 'metadescription', 'enablesqldebug', 'sqldebug', 'cssdate', 'enabletooltip', 'prolinkimg', 'analyticscode');
|
||||||
GetVar($validConfig);
|
GetVar($validConfig);
|
||||||
$TWEAK = [];
|
$TWEAK = [];
|
||||||
foreach($validConfig as $config) {
|
foreach($validConfig as $config) {
|
||||||
@@ -245,7 +245,6 @@ elseif ($action == 'tweaksettings') // tweak settings
|
|||||||
tr($lang_settings['row_see_sql_debug'], "<input type='checkbox' name='enablesqldebug' value='yes'".($TWEAK['enablesqldebug'] == 'yes' ? " checked='checked'" : "")." />".$lang_settings['text_allow'].classlist('sqldebug',UC_STAFFLEADER,$TWEAK['sqldebug'], UC_MODERATOR).$lang_settings['text_see_sql_list'].get_user_class_name(UC_SYSOP,false,true,true),1);
|
tr($lang_settings['row_see_sql_debug'], "<input type='checkbox' name='enablesqldebug' value='yes'".($TWEAK['enablesqldebug'] == 'yes' ? " checked='checked'" : "")." />".$lang_settings['text_allow'].classlist('sqldebug',UC_STAFFLEADER,$TWEAK['sqldebug'], UC_MODERATOR).$lang_settings['text_see_sql_list'].get_user_class_name(UC_SYSOP,false,true,true),1);
|
||||||
tr($lang_settings['row_tracker_founded_date'],"<input type='text' style=\"width: 300px\" name=datefounded value='".($TWEAK["datefounded"] ? $TWEAK["datefounded"] : '2007-12-24')."'> <br />".$lang_settings['text_tracker_founded_date_note'], 1);
|
tr($lang_settings['row_tracker_founded_date'],"<input type='text' style=\"width: 300px\" name=datefounded value='".($TWEAK["datefounded"] ? $TWEAK["datefounded"] : '2007-12-24')."'> <br />".$lang_settings['text_tracker_founded_date_note'], 1);
|
||||||
tr($lang_settings['row_css_date'],"<input type='text' style=\"width: 300px\" name=cssdate value='".($TWEAK["cssdate"] ? $TWEAK["cssdate"] : '')."'> <br />".$lang_settings['text_css_date'], 1);
|
tr($lang_settings['row_css_date'],"<input type='text' style=\"width: 300px\" name=cssdate value='".($TWEAK["cssdate"] ? $TWEAK["cssdate"] : '')."'> <br />".$lang_settings['text_css_date'], 1);
|
||||||
tr($lang_settings['row_logging'],"<input type='text' style=\"width: 300px\" name=logging value='".($TWEAK["logging"] ? $TWEAK["logging"] : '')."'> <br />".$lang_settings['text_logging_note'], 1);
|
|
||||||
|
|
||||||
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
|
tr($lang_settings['row_save_settings'],"<input type='submit' name='save' value='".$lang_settings['submit_save_settings']."'>", 1);
|
||||||
print ("</form>");
|
print ("</form>");
|
||||||
|
|||||||
Reference in New Issue
Block a user