mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-30 17:17:22 +08:00
settings load from database and i18n from config files
This commit is contained in:
@@ -19,7 +19,7 @@ class RedisCache {
|
|||||||
public $redis;
|
public $redis;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$success = $this->connect($host = 'localhost', $port = 6379); // Connect to Redis
|
$success = $this->connect(); // Connect to Redis
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$this->isEnabled = 1;
|
$this->isEnabled = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -27,33 +27,33 @@ class RedisCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function connect($host, $port)
|
private function connect()
|
||||||
{
|
{
|
||||||
global $BASIC, $TWEAK;
|
$config = config('database.redis');
|
||||||
$redis = new Redis();
|
$redis = new Redis();
|
||||||
$params = [
|
$params = [
|
||||||
$BASIC['redis_host'],
|
$config['host'],
|
||||||
];
|
];
|
||||||
if (!empty($BASIC['redis_port'])) {
|
if (!empty($config['port'])) {
|
||||||
$params[] = $BASIC['redis_port'];
|
$params[] = $config['port'];
|
||||||
}
|
}
|
||||||
if (!empty($BASIC['redis_timeout'])) {
|
if (!empty($config['timeout'])) {
|
||||||
$params[] = $BASIC['redis_timeout'];
|
$params[] = $config['timeout'];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$connectResult = $redis->connect(...$params);
|
$connectResult = $redis->connect(...$params);
|
||||||
$auth = [];
|
$auth = [];
|
||||||
if (!empty($BASIC['redis_password'])) {
|
if (!empty($config['password'])) {
|
||||||
$auth['pass'] = $BASIC['redis_password'];
|
$auth['pass'] = $config['password'];
|
||||||
if (!empty($BASIC['redis_username'])) {
|
if (!empty($config['username'])) {
|
||||||
$auth['user'] = $BASIC['redis_username'];
|
$auth['user'] = $config['username'];
|
||||||
}
|
}
|
||||||
$connectResult = $connectResult && $redis->auth($auth);
|
$connectResult = $connectResult && $redis->auth($auth);
|
||||||
}
|
}
|
||||||
if ($connectResult) {
|
if ($connectResult) {
|
||||||
$this->redis = $redis;
|
$this->redis = $redis;
|
||||||
if (is_numeric($BASIC['redis_database'])) {
|
if (is_numeric($config['database'])) {
|
||||||
$redis->select($BASIC['redis_database']);
|
$redis->select($config['database']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $connectResult;
|
return $connectResult;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
|
|||||||
@@ -10,5 +10,9 @@ $showversion = " - Powered by ".PROJECTNAME;
|
|||||||
$rootpath=realpath(dirname(__FILE__) . '/..');
|
$rootpath=realpath(dirname(__FILE__) . '/..');
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . $rootpath);
|
set_include_path(get_include_path() . PATH_SEPARATOR . $rootpath);
|
||||||
$rootpath .= "/";
|
$rootpath .= "/";
|
||||||
|
require $rootpath . 'include/functions.php';
|
||||||
|
require $rootpath . 'include/globalfunctions.php';
|
||||||
|
require $rootpath . get_langfile_path("functions.php");
|
||||||
require $rootpath . 'include/core.php';
|
require $rootpath . 'include/core.php';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,6 @@ define('NEXUS_START', microtime(true));
|
|||||||
define('IN_TRACKER', true);
|
define('IN_TRACKER', true);
|
||||||
$rootpath=realpath(dirname(__FILE__) . '/..')."/";
|
$rootpath=realpath(dirname(__FILE__) . '/..')."/";
|
||||||
|
|
||||||
require $rootpath . 'include/config.php';
|
|
||||||
require $rootpath . 'include/functions.php';
|
|
||||||
require $rootpath . 'include/globalfunctions.php';
|
|
||||||
require $rootpath . get_langfile_path("functions.php");
|
|
||||||
|
|
||||||
require $rootpath . 'include/database/interface_db.php';
|
|
||||||
require $rootpath . 'include/database/class_db_mysqli.php';
|
|
||||||
require $rootpath . 'include/database/class_db.php';
|
|
||||||
require $rootpath . 'include/database/helpers.php';
|
|
||||||
require $rootpath . 'include/database/class_exception.php';
|
|
||||||
|
|
||||||
require $rootpath . 'classes/class_cache_redis.php';
|
|
||||||
|
|
||||||
require $rootpath . 'include/core.php';
|
|
||||||
require $rootpath . 'include/functions_announce.php';
|
require $rootpath . 'include/functions_announce.php';
|
||||||
|
require $rootpath . 'include/globalfunctions.php';
|
||||||
|
require $rootpath . 'include/core.php';
|
||||||
|
|||||||
+32
-30
@@ -2,33 +2,22 @@
|
|||||||
# IMPORTANT: Do not edit below unless you know what you are doing!
|
# IMPORTANT: Do not edit below unless you know what you are doing!
|
||||||
if(!defined('IN_TRACKER'))
|
if(!defined('IN_TRACKER'))
|
||||||
die('Hacking attempt!');
|
die('Hacking attempt!');
|
||||||
|
/*
|
||||||
$CONFIGURATIONS = array('ACCOUNT', 'ADVERTISEMENT', 'ATTACHMENT', 'AUTHORITY', 'BASIC', 'BONUS', 'CODE', 'MAIN', 'SECURITY', 'SMTP', 'TORRENT', 'TWEAK');
|
$CONFIGURATIONS = array('ACCOUNT', 'ADVERTISEMENT', 'ATTACHMENT', 'AUTHORITY', 'BASIC', 'BONUS', 'CODE', 'MAIN', 'SECURITY', 'SMTP', 'TORRENT', 'TWEAK');
|
||||||
|
|
||||||
function ReadConfig ($configname = NULL) {
|
function ReadConfig ($configname = NULL) {
|
||||||
static $allConfig;
|
|
||||||
|
|
||||||
global $CONFIGURATIONS;
|
global $CONFIGURATIONS;
|
||||||
|
if ($configname) {
|
||||||
if (is_null($allConfig)) {
|
$configname = basename($configname);
|
||||||
$configs = config();
|
$tmp = oldReadConfig($configname);
|
||||||
foreach ($configs as $name => $value) {
|
WriteConfig($configname, $tmp);
|
||||||
$prefix = strtoupper(strstr($name, '.', true));
|
@unlink('./config/'.$configname);
|
||||||
$pureName = substr($name, strpos($name, '.') + 1);
|
return $tmp;
|
||||||
$GLOBALS[$prefix][$pureName] = $value;
|
} else {
|
||||||
|
foreach ($CONFIGURATIONS as $CONFIGURATION) {
|
||||||
|
$GLOBALS[$CONFIGURATION] = ReadConfig($CONFIGURATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dd($GLOBALS);
|
|
||||||
// if ($configname) {
|
|
||||||
// $configname = basename($configname);
|
|
||||||
// $tmp = oldReadConfig($configname);
|
|
||||||
// WriteConfig($configname, $tmp);
|
|
||||||
// @unlink('./config/'.$configname);
|
|
||||||
// return $tmp;
|
|
||||||
// } else {
|
|
||||||
// foreach ($CONFIGURATIONS as $CONFIGURATION) {
|
|
||||||
// $GLOBALS[$CONFIGURATION] = ReadConfig($CONFIGURATION);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function oldReadConfig ($configname) {
|
function oldReadConfig ($configname) {
|
||||||
@@ -41,8 +30,7 @@ function oldReadConfig ($configname) {
|
|||||||
$configname = basename($configname);
|
$configname = basename($configname);
|
||||||
$path = './config/'.$configname;
|
$path = './config/'.$configname;
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
do_log($path);
|
die("Error! File <b>".htmlspecialchars($configname)."</b> doesn't exist!</font><br /><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br /><br />chmod 777 config/<br />chmod 777 config/".$configname);
|
||||||
die("Error! File <b>".htmlspecialchars($configname)."</b> doesn't exist!</font><br /><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br /><br />chmod 777 config/<br />chmod 777 config/".$configname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fp = fopen($path, 'r');
|
$fp = fopen($path, 'r');
|
||||||
@@ -65,13 +53,27 @@ function oldReadConfig ($configname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadConfig();
|
|
||||||
|
|
||||||
//if (file_exists('config/allconfig.php')) {
|
if (file_exists('config/allconfig.php')) {
|
||||||
// require('config/allconfig.php');
|
require('config/allconfig.php');
|
||||||
//} else {
|
} else {
|
||||||
// ReadConfig();
|
ReadConfig();
|
||||||
//}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//load settings from database
|
||||||
|
if (basename($_SERVER['SCRIPT_FILENAME']) == 'announce.php') {
|
||||||
|
dbconn_announce();
|
||||||
|
} else {
|
||||||
|
dbconn();
|
||||||
|
}
|
||||||
|
$settings = get_setting();
|
||||||
|
foreach ($settings as $name => $value) {
|
||||||
|
$prefix = strtoupper(strstr($name, '.', true));
|
||||||
|
$pureName = substr($name, strpos($name, '.') + 1);
|
||||||
|
$GLOBALS[$prefix][$pureName] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$SITENAME = $BASIC['SITENAME'];
|
$SITENAME = $BASIC['SITENAME'];
|
||||||
$BASEURL = $BASIC['BASEURL'];
|
$BASEURL = $BASIC['BASEURL'];
|
||||||
$announce_urls = array();
|
$announce_urls = array();
|
||||||
|
|||||||
+1
-6
@@ -3,9 +3,6 @@ if(!defined('IN_TRACKER'))
|
|||||||
die('Hacking attempt!');
|
die('Hacking attempt!');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
require $rootpath . 'include/functions.php';
|
|
||||||
require $rootpath . 'include/globalfunctions.php';
|
|
||||||
|
|
||||||
require $rootpath . 'include/database/interface_db.php';
|
require $rootpath . 'include/database/interface_db.php';
|
||||||
require $rootpath . 'include/database/class_db_mysqli.php';
|
require $rootpath . 'include/database/class_db_mysqli.php';
|
||||||
require $rootpath . 'include/database/class_db.php';
|
require $rootpath . 'include/database/class_db.php';
|
||||||
@@ -14,12 +11,10 @@ require $rootpath . 'include/database/class_exception.php';
|
|||||||
|
|
||||||
require $rootpath . 'classes/class_advertisement.php';
|
require $rootpath . 'classes/class_advertisement.php';
|
||||||
require $rootpath . 'classes/class_cache_redis.php';
|
require $rootpath . 'classes/class_cache_redis.php';
|
||||||
|
|
||||||
require $rootpath . 'include/config.php';
|
require $rootpath . 'include/config.php';
|
||||||
require $rootpath . get_langfile_path("functions.php");
|
|
||||||
|
|
||||||
|
|
||||||
ini_set('display_errors', $TWEAK['display_errors']);
|
ini_set('display_errors', $TWEAK['display_errors']);
|
||||||
|
|
||||||
$Cache = new RedisCache(); //Load the caching class
|
$Cache = new RedisCache(); //Load the caching class
|
||||||
$Cache->setLanguageFolderArray(get_langfolder_list());
|
$Cache->setLanguageFolderArray(get_langfolder_list());
|
||||||
define('TIMENOW', time());
|
define('TIMENOW', time());
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ class DB
|
|||||||
|
|
||||||
private static $queries = [];
|
private static $queries = [];
|
||||||
|
|
||||||
|
private $isConnected = false;
|
||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -39,9 +41,11 @@ class DB
|
|||||||
|
|
||||||
public function connect($host, $username, $password, $database, $port)
|
public function connect($host, $username, $password, $database, $port)
|
||||||
{
|
{
|
||||||
if (is_null($this->driver)) {
|
if (!$this->isConnected) {
|
||||||
$this->driver->connect($host, $username, $password, $database, $port);
|
$this->driver->connect($host, $username, $password, $database, $port);
|
||||||
|
$this->isConnected = true;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query(string $sql)
|
public function query(string $sql)
|
||||||
@@ -112,7 +116,7 @@ class DB
|
|||||||
|
|
||||||
public function isConnected()
|
public function isConnected()
|
||||||
{
|
{
|
||||||
return !is_null($this->driver);
|
return $this->isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-241
@@ -1720,32 +1720,20 @@ function dbconn($autoclean = false)
|
|||||||
if (DB::getInstance()->isConnected()) {
|
if (DB::getInstance()->isConnected()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
global $lang_functions;
|
$config = config('database.mysql');
|
||||||
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
|
if (!mysql_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']))
|
||||||
global $useCronTriggerCleanUp;
|
|
||||||
global $BASIC;
|
|
||||||
|
|
||||||
if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass, $BASIC['mysql_db'], $BASIC['mysql_port']))
|
|
||||||
{
|
{
|
||||||
switch (mysql_errno())
|
die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
|
||||||
{
|
|
||||||
case 1040:
|
|
||||||
case 2002:
|
|
||||||
die("<html><head><meta http-equiv=refresh content=\"10 $_SERVER[REQUEST_URI]\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>".$lang_functions['std_server_load_very_high']."</h3></td></tr></table></body></html>");
|
|
||||||
default:
|
|
||||||
die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mysql_query("SET NAMES UTF8");
|
mysql_query("SET NAMES UTF8");
|
||||||
mysql_query("SET collation_connection = 'utf8_general_ci'");
|
mysql_query("SET collation_connection = 'utf8_general_ci'");
|
||||||
mysql_query("SET sql_mode=''");
|
mysql_query("SET sql_mode=''");
|
||||||
mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());
|
|
||||||
|
|
||||||
userlogin();
|
userlogin();
|
||||||
|
|
||||||
if (!$useCronTriggerCleanUp && $autoclean) {
|
// if (!$useCronTriggerCleanUp && $autoclean) {
|
||||||
register_shutdown_function("autoclean");
|
// register_shutdown_function("autoclean");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
function get_user_row($id)
|
function get_user_row($id)
|
||||||
{
|
{
|
||||||
@@ -1773,9 +1761,6 @@ function get_user_row($id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function userlogin() {
|
function userlogin() {
|
||||||
if (isset($GLOBALS['CURUSER'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
global $lang_functions;
|
global $lang_functions;
|
||||||
global $Cache;
|
global $Cache;
|
||||||
global $SITE_ONLINE, $oldip;
|
global $SITE_ONLINE, $oldip;
|
||||||
@@ -4363,224 +4348,4 @@ function return_category_image($categoryid, $link="")
|
|||||||
return $catimg;
|
return $catimg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function strip_magic_quotes($arr)
|
|
||||||
{
|
|
||||||
foreach ($arr as $k => $v)
|
|
||||||
{
|
|
||||||
if (is_array($v))
|
|
||||||
{
|
|
||||||
$arr[$k] = strip_magic_quotes($v);
|
|
||||||
} else {
|
|
||||||
$arr[$k] = stripslashes($v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
|
|
||||||
{
|
|
||||||
if (!empty($_GET)) {
|
|
||||||
$_GET = strip_magic_quotes($_GET);
|
|
||||||
}
|
|
||||||
if (!empty($_POST)) {
|
|
||||||
$_POST = strip_magic_quotes($_POST);
|
|
||||||
}
|
|
||||||
if (!empty($_COOKIE)) {
|
|
||||||
$_COOKIE = strip_magic_quotes($_COOKIE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_langfolder_list()
|
|
||||||
{
|
|
||||||
//do not access db for speed up, or for flexibility
|
|
||||||
return array("en", "chs", "cht", "ko", "ja");
|
|
||||||
}
|
|
||||||
|
|
||||||
function dd($vars)
|
|
||||||
{
|
|
||||||
echo '<pre>';
|
|
||||||
array_map(function ($var) {
|
|
||||||
var_dump($var);
|
|
||||||
}, func_get_args());
|
|
||||||
echo '</pre>';
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_log($log)
|
|
||||||
{
|
|
||||||
global $TWEAK;
|
|
||||||
if (!empty($TWEAK['logging'])) {
|
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
|
||||||
$content = sprintf(
|
|
||||||
"[%s] %s:%s %s%s%s %s%s",
|
|
||||||
date('Y-m-d H:i:s'),
|
|
||||||
$backtrace[0]['file'] ?? '',
|
|
||||||
$backtrace[0]['line'] ?? '',
|
|
||||||
$backtrace[1]['class'] ?? '',
|
|
||||||
$backtrace[1]['type'] ?? '',
|
|
||||||
$backtrace[1]['function'] ?? '',
|
|
||||||
$log,
|
|
||||||
PHP_EOL
|
|
||||||
);
|
|
||||||
file_put_contents($TWEAK['logging'], $content, FILE_APPEND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get translation for given name
|
|
||||||
*
|
|
||||||
* @author xiaomlove
|
|
||||||
* @date 2021/1/11
|
|
||||||
* @param null $name
|
|
||||||
* @param null $prefix
|
|
||||||
* @return mixed|string
|
|
||||||
*/
|
|
||||||
function __($name = null, $prefix = null)
|
|
||||||
{
|
|
||||||
static $i18n;
|
|
||||||
static $i18nWithoutPrefix;
|
|
||||||
$userLocale = get_langfolder_cookie();
|
|
||||||
$defaultLocale = 'en';
|
|
||||||
if (is_null($prefix)) {
|
|
||||||
//get prefix from scripe name
|
|
||||||
$prefix = basename($_SERVER['SCRIPT_NAME']);
|
|
||||||
$prefix = strstr($prefix, '.php', true);
|
|
||||||
}
|
|
||||||
if (is_null($i18n)) {
|
|
||||||
//get all in18 may be used, incldue user locale and default locale, and name in('_target', 'functions') (because they are common) or prefixed with given prefix
|
|
||||||
$sql = "select locale, name, translation from i18n where locale in (" . sqlesc($userLocale) . ", " . sqlesc($defaultLocale) . ") and (name in ('_target', 'functions') or name like '{$prefix}%')";
|
|
||||||
$result = sql_query($sql);
|
|
||||||
while ($row = mysql_fetch_assoc($result)) {
|
|
||||||
$i18n[$row['locale']][$row['name']] = $row['translation'];
|
|
||||||
$i18nWithoutPrefix[$row['locale']][substr($row['name'], strpos($row['name'], '.') + 1)] = $row['translation'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is_null($name)) {
|
|
||||||
return $i18nWithoutPrefix[$userLocale] ?? $i18nWithoutPrefix[$defaultLocale] ?? [];
|
|
||||||
}
|
|
||||||
$name = "$prefix.$name";
|
|
||||||
return $i18n[$userLocale][$name] ?? $i18n[$defaultLocale][$name] ?? '';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function config($key, $default = null)
|
|
||||||
{
|
|
||||||
static $configs;
|
|
||||||
if (is_null($configs)) {
|
|
||||||
//get all configuration from config file
|
|
||||||
$files = glob($rootpath . 'config/*.php');
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$basename = basename($file);
|
|
||||||
if ($basename != 'allconfig.php') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$values = require $file;
|
|
||||||
$configPrefix = strstr($basename, '.php', true);
|
|
||||||
foreach ($values as $key => $value) {
|
|
||||||
$configs["$configPrefix.$key"] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $configs[$key] ?? $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get setting for given name and prefix
|
|
||||||
*
|
|
||||||
* $name == null and $prefix == null, return all
|
|
||||||
* $name == null and $prefix != null, return with specified prefix, but the result's prefix will be stripped
|
|
||||||
*
|
|
||||||
* @author xiaomlove
|
|
||||||
* @date 2021/1/11
|
|
||||||
* @param null $name
|
|
||||||
* @param null $prefix
|
|
||||||
* @return array|mixed|string
|
|
||||||
*/
|
|
||||||
function get_setting($name = null, $prefix = null)
|
|
||||||
{
|
|
||||||
static $settings;
|
|
||||||
if (is_null($settings)) {
|
|
||||||
//get all settings from database
|
|
||||||
$sql = "select config_name, config_value from configs";
|
|
||||||
$result = sql_query($sql);
|
|
||||||
while ($row = mysql_fetch_assoc($result)) {
|
|
||||||
$value = $row['config_value'];
|
|
||||||
$arr = json_decode($value, true);
|
|
||||||
if (is_array($arr)) {
|
|
||||||
$value = $arr;
|
|
||||||
}
|
|
||||||
$settings[$row['config_name']] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!is_null($name)) {
|
|
||||||
if (!is_null($prefix)) {
|
|
||||||
$name = "$prefix.$name";
|
|
||||||
}
|
|
||||||
return $settings[$name] ?? null;
|
|
||||||
}
|
|
||||||
if (is_null($prefix)) {
|
|
||||||
return $settings;
|
|
||||||
}
|
|
||||||
$filtered = [];
|
|
||||||
foreach ($settings as $name => $value) {
|
|
||||||
if (preg_match("/^$prefix/", $name)) {
|
|
||||||
$nameWithoutPrefix = substr($name, strpos($name, '.') + 1);
|
|
||||||
$filtered[$nameWithoutPrefix] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $filtered;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function env($key, $default = null)
|
|
||||||
{
|
|
||||||
static $env;
|
|
||||||
if (is_null($env)) {
|
|
||||||
$envFile = $rootpath . '.env';
|
|
||||||
if (!file_exists($envFile)) {
|
|
||||||
throw new \RuntimeException(".env file is not exists in the root path.");
|
|
||||||
}
|
|
||||||
$fp = fopen($envFile, 'r');
|
|
||||||
if ($fp === false) {
|
|
||||||
throw new \RuntimeException(".env file: $envFile is not readable.");
|
|
||||||
}
|
|
||||||
while ($line = trim(fgets($fp))) {
|
|
||||||
if (empty($line)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$pos = strpos($line, '=');
|
|
||||||
$key = normalize_env(mb_substr($line, 0, $pos, 'utf-8'));
|
|
||||||
$value = normalize_env(mb_substr($line, $pos + 1, null, 'utf-8'));
|
|
||||||
$env[$key] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $env[$key] ?? $default;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalize_env($value)
|
|
||||||
{
|
|
||||||
$value = trim($value);
|
|
||||||
$toStrip = ['\'', '"'];
|
|
||||||
if (in_array(mb_substr($value, 0, 1, 'utf-8'), $toStrip)) {
|
|
||||||
$value = mb_substr($value, 1, null, 'utf-8');
|
|
||||||
}
|
|
||||||
if (in_array(mb_substr($value, -1, 'utf-8'), $toStrip)) {
|
|
||||||
$value = mb_substr($value, 0, -1, 'utf-8');
|
|
||||||
}
|
|
||||||
switch (strtolower($value)) {
|
|
||||||
case 'true':
|
|
||||||
return true;
|
|
||||||
case 'false':
|
|
||||||
return false;
|
|
||||||
case 'null':
|
|
||||||
return null;
|
|
||||||
default:
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -2,21 +2,18 @@
|
|||||||
# IMPORTANT: Do not edit below unless you know what you are doing!
|
# IMPORTANT: Do not edit below unless you know what you are doing!
|
||||||
if(!defined('IN_TRACKER'))
|
if(!defined('IN_TRACKER'))
|
||||||
die('Hacking attempt!');
|
die('Hacking attempt!');
|
||||||
include_once($rootpath . 'include/globalfunctions.php');
|
|
||||||
include_once($rootpath . 'include/config.php');
|
|
||||||
|
|
||||||
function dbconn_announce() {
|
function dbconn_announce() {
|
||||||
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
|
|
||||||
global $BASIC;
|
|
||||||
|
|
||||||
if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass, $BASIC['mysql_db'], $BASIC['mysql_port']))
|
$config = config('database.mysql');
|
||||||
|
|
||||||
|
if (!@mysql_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']))
|
||||||
{
|
{
|
||||||
die('dbconn: mysql_connect: ' . mysql_error());
|
die('dbconn: mysql_connect: ' . mysql_error());
|
||||||
}
|
}
|
||||||
mysql_query("SET NAMES UTF8");
|
mysql_query("SET NAMES UTF8");
|
||||||
mysql_query("SET collation_connection = 'utf8_general_ci'");
|
mysql_query("SET collation_connection = 'utf8_general_ci'");
|
||||||
mysql_query("SET sql_mode=''");
|
mysql_query("SET sql_mode=''");
|
||||||
mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hash_where_arr($name, $hash_arr) {
|
function hash_where_arr($name, $hash_arr) {
|
||||||
|
|||||||
+252
-2
@@ -67,12 +67,12 @@ function getip() {
|
|||||||
|
|
||||||
function sql_query($query)
|
function sql_query($query)
|
||||||
{
|
{
|
||||||
$begin = getmicrotime();
|
$begin = microtime(true);
|
||||||
global $query_name;
|
global $query_name;
|
||||||
$result = mysql_query($query);
|
$result = mysql_query($query);
|
||||||
$query_name[] = [
|
$query_name[] = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'time' => sprintf('%.3f', getmicrotime() - $begin),
|
'time' => microtime(true) - $begin,
|
||||||
];
|
];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -93,4 +93,254 @@ function hash_where($name, $hash) {
|
|||||||
$shhash = preg_replace('/ *$/s', "", $hash);
|
$shhash = preg_replace('/ *$/s', "", $hash);
|
||||||
return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")";
|
return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function strip_magic_quotes($arr)
|
||||||
|
{
|
||||||
|
foreach ($arr as $k => $v)
|
||||||
|
{
|
||||||
|
if (is_array($v))
|
||||||
|
{
|
||||||
|
$arr[$k] = strip_magic_quotes($v);
|
||||||
|
} else {
|
||||||
|
$arr[$k] = stripslashes($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
|
||||||
|
{
|
||||||
|
if (!empty($_GET)) {
|
||||||
|
$_GET = strip_magic_quotes($_GET);
|
||||||
|
}
|
||||||
|
if (!empty($_POST)) {
|
||||||
|
$_POST = strip_magic_quotes($_POST);
|
||||||
|
}
|
||||||
|
if (!empty($_COOKIE)) {
|
||||||
|
$_COOKIE = strip_magic_quotes($_COOKIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_langfolder_list()
|
||||||
|
{
|
||||||
|
//do not access db for speed up, or for flexibility
|
||||||
|
return array("en", "chs", "cht", "ko", "ja");
|
||||||
|
}
|
||||||
|
|
||||||
|
function printLine($line, $exist = false)
|
||||||
|
{
|
||||||
|
echo "[" . date('Y-m-d H:i:s') . "] $line<br />";
|
||||||
|
if ($exist) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dd($vars)
|
||||||
|
{
|
||||||
|
echo '<pre>';
|
||||||
|
array_map(function ($var) {
|
||||||
|
var_dump($var);
|
||||||
|
}, func_get_args());
|
||||||
|
echo '</pre>';
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_log($log)
|
||||||
|
{
|
||||||
|
global $TWEAK;
|
||||||
|
if (!empty($TWEAK['logging'])) {
|
||||||
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
|
$content = sprintf(
|
||||||
|
"[%s] %s:%s %s%s%s %s%s",
|
||||||
|
date('Y-m-d H:i:s'),
|
||||||
|
$backtrace[0]['file'] ?? '',
|
||||||
|
$backtrace[0]['line'] ?? '',
|
||||||
|
$backtrace[1]['class'] ?? '',
|
||||||
|
$backtrace[1]['type'] ?? '',
|
||||||
|
$backtrace[1]['function'] ?? '',
|
||||||
|
$log,
|
||||||
|
PHP_EOL
|
||||||
|
);
|
||||||
|
file_put_contents($TWEAK['logging'], $content, FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get translation for given name
|
||||||
|
*
|
||||||
|
* @author xiaomlove
|
||||||
|
* @date 2021/1/11
|
||||||
|
* @param null $name
|
||||||
|
* @param null $prefix
|
||||||
|
* @return mixed|string
|
||||||
|
*/
|
||||||
|
function __($name = null, $prefix = null)
|
||||||
|
{
|
||||||
|
static $i18n;
|
||||||
|
static $i18nWithoutPrefix;
|
||||||
|
$userLocale = get_langfolder_cookie();
|
||||||
|
$defaultLocale = 'en';
|
||||||
|
if (is_null($prefix)) {
|
||||||
|
//get prefix from scripe name
|
||||||
|
$prefix = basename($_SERVER['SCRIPT_NAME']);
|
||||||
|
$prefix = strstr($prefix, '.php', true);
|
||||||
|
}
|
||||||
|
if (is_null($i18n)) {
|
||||||
|
//get all in18 may be used, incldue user locale and default locale, and name in('_target', 'functions') (because they are common) or prefixed with given prefix
|
||||||
|
$sql = "select locale, name, translation from i18n where locale in (" . sqlesc($userLocale) . ", " . sqlesc($defaultLocale) . ") and (name in ('_target', 'functions') or name like '{$prefix}%')";
|
||||||
|
$result = sql_query($sql);
|
||||||
|
while ($row = mysql_fetch_assoc($result)) {
|
||||||
|
$i18n[$row['locale']][$row['name']] = $row['translation'];
|
||||||
|
$i18nWithoutPrefix[$row['locale']][substr($row['name'], strpos($row['name'], '.') + 1)] = $row['translation'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_null($name)) {
|
||||||
|
return $i18nWithoutPrefix[$userLocale] ?? $i18nWithoutPrefix[$defaultLocale] ?? [];
|
||||||
|
}
|
||||||
|
$name = "$prefix.$name";
|
||||||
|
return $i18n[$userLocale][$name] ?? $i18n[$defaultLocale][$name] ?? '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function config($key, $default = null)
|
||||||
|
{
|
||||||
|
global $rootpath;
|
||||||
|
static $configs;
|
||||||
|
if (is_null($configs)) {
|
||||||
|
//get all configuration from config file
|
||||||
|
$files = glob($rootpath . 'config/*.php');
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$basename = basename($file);
|
||||||
|
if ($basename == 'allconfig.php') {
|
||||||
|
//exclude the NexusPHP default config file
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$values = require $file;
|
||||||
|
$configPrefix = strstr($basename, '.php', true);
|
||||||
|
$configs[$configPrefix] = $values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr_get($configs, $key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get setting for given name and prefix
|
||||||
|
*
|
||||||
|
* $name == null and $prefix == null, return all
|
||||||
|
* $name == null and $prefix != null, return with specified prefix, but the result's prefix will be stripped
|
||||||
|
*
|
||||||
|
* @author xiaomlove
|
||||||
|
* @date 2021/1/11
|
||||||
|
* @param null $name
|
||||||
|
* @param null $prefix
|
||||||
|
* @return array|mixed|string
|
||||||
|
*/
|
||||||
|
function get_setting($name = null, $prefix = null)
|
||||||
|
{
|
||||||
|
static $settings;
|
||||||
|
if (is_null($settings)) {
|
||||||
|
//get all settings from database
|
||||||
|
$sql = "select config_name, config_value from configs";
|
||||||
|
$result = sql_query($sql);
|
||||||
|
while ($row = mysql_fetch_assoc($result)) {
|
||||||
|
$value = $row['config_value'];
|
||||||
|
$arr = json_decode($value, true);
|
||||||
|
if (is_array($arr)) {
|
||||||
|
$value = $arr;
|
||||||
|
}
|
||||||
|
$settings[$row['config_name']] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!is_null($name)) {
|
||||||
|
if (!is_null($prefix)) {
|
||||||
|
$name = "$prefix.$name";
|
||||||
|
}
|
||||||
|
return $settings[$name] ?? null;
|
||||||
|
}
|
||||||
|
if (is_null($prefix)) {
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
$filtered = [];
|
||||||
|
foreach ($settings as $name => $value) {
|
||||||
|
if (preg_match("/^$prefix/", $name)) {
|
||||||
|
$nameWithoutPrefix = substr($name, strpos($name, '.') + 1);
|
||||||
|
$filtered[$nameWithoutPrefix] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $filtered;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function env($key, $default = null)
|
||||||
|
{
|
||||||
|
global $rootpath;
|
||||||
|
static $env;
|
||||||
|
if (is_null($env)) {
|
||||||
|
$envFile = $rootpath . '.env';
|
||||||
|
if (!file_exists($envFile)) {
|
||||||
|
throw new \RuntimeException(".env file is not exists in the root path.");
|
||||||
|
}
|
||||||
|
$fp = fopen($envFile, 'r');
|
||||||
|
if ($fp === false) {
|
||||||
|
throw new \RuntimeException(".env file: $envFile is not readable.");
|
||||||
|
}
|
||||||
|
while ($line = trim(fgets($fp))) {
|
||||||
|
if (empty($line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$pos = strpos($line, '=');
|
||||||
|
if ($pos <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (mb_substr($line, 0, 1, 'utf-8') == '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$lineKey = normalize_env(mb_substr($line, 0, $pos, 'utf-8'));
|
||||||
|
$lineValue = normalize_env(mb_substr($line, $pos + 1, null, 'utf-8'));
|
||||||
|
$env[$lineKey] = $lineValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $env[$key] ?? $default;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalize_env($value)
|
||||||
|
{
|
||||||
|
$value = trim($value);
|
||||||
|
$toStrip = ['\'', '"'];
|
||||||
|
if (in_array(mb_substr($value, 0, 1, 'utf-8'), $toStrip)) {
|
||||||
|
$value = mb_substr($value, 1, null, 'utf-8');
|
||||||
|
}
|
||||||
|
if (in_array(mb_substr($value, -1, null,'utf-8'), $toStrip)) {
|
||||||
|
$value = mb_substr($value, 0, -1, 'utf-8');
|
||||||
|
}
|
||||||
|
switch (strtolower($value)) {
|
||||||
|
case 'true':
|
||||||
|
return true;
|
||||||
|
case 'false':
|
||||||
|
return false;
|
||||||
|
case 'null':
|
||||||
|
return null;
|
||||||
|
default:
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function arr_get($array, $key, $default = null)
|
||||||
|
{
|
||||||
|
if (strpos($key, '.') === false) {
|
||||||
|
return $array[$key] ?? $default;
|
||||||
|
}
|
||||||
|
foreach (explode('.', $key) as $segment) {
|
||||||
|
if (isset($array[$segment])) {
|
||||||
|
$array = $array[$segment];
|
||||||
|
} else {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
+4
-4
@@ -9,7 +9,7 @@ $type = unesc($_GET["type"] ?? '');
|
|||||||
|
|
||||||
registration_check('invitesystem',true,false);
|
registration_check('invitesystem',true,false);
|
||||||
|
|
||||||
if (($CURUSER[id] != $id && get_user_class() < $viewinvite_class) || !is_valid_id($id))
|
if (($CURUSER['id'] != $id && get_user_class() < $viewinvite_class) || !is_valid_id($id))
|
||||||
stderr($lang_invite['std_sorry'],$lang_invite['std_permission_denied']);
|
stderr($lang_invite['std_sorry'],$lang_invite['std_permission_denied']);
|
||||||
if (get_user_class() < $sendinvite_class)
|
if (get_user_class() < $sendinvite_class)
|
||||||
stderr($lang_invite['std_sorry'],$lang_invite['std_only'].get_user_class_name($sendinvite_class,false,true,true).$lang_invite['std_or_above_can_invite'],false);
|
stderr($lang_invite['std_sorry'],$lang_invite['std_only'].get_user_class_name($sendinvite_class,false,true,true).$lang_invite['std_or_above_can_invite'],false);
|
||||||
@@ -19,7 +19,7 @@ stdhead($lang_invite['head_invites']);
|
|||||||
print("<table width=700 class=main border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
|
print("<table width=700 class=main border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
|
||||||
|
|
||||||
print("<h1 align=center><a href=\"invite.php?id=".$id."\">".$user['username'].$lang_invite['text_invite_system']."</a></h1>");
|
print("<h1 align=center><a href=\"invite.php?id=".$id."\">".$user['username'].$lang_invite['text_invite_system']."</a></h1>");
|
||||||
$sent = htmlspecialchars($_GET['sent']);
|
$sent = htmlspecialchars($_GET['sent'] ?? '');
|
||||||
if ($sent == 1){
|
if ($sent == 1){
|
||||||
$msg = $lang_invite['text_invite_code_sent'];
|
$msg = $lang_invite['text_invite_code_sent'];
|
||||||
print("<p align=center><font color=red>".$msg."</font></p>");
|
print("<p align=center><font color=red>".$msg."</font></p>");
|
||||||
@@ -108,7 +108,7 @@ if ($type == 'new'){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($CURUSER[id] == $id || get_user_class() >= UC_SYSOP)
|
if ($CURUSER['id'] == $id || get_user_class() >= UC_SYSOP)
|
||||||
{
|
{
|
||||||
|
|
||||||
$pendingcount = number_format(get_row_count("users", "WHERE status='pending' AND invited_by=$CURUSER[id]"));
|
$pendingcount = number_format(get_row_count("users", "WHERE status='pending' AND invited_by=$CURUSER[id]"));
|
||||||
@@ -117,7 +117,7 @@ if ($type == 'new'){
|
|||||||
print("<tr><td colspan=7 align=right><input type=submit style='height: 20px' value=".$lang_invite['submit_confirm_users']."></td></tr>");
|
print("<tr><td colspan=7 align=right><input type=submit style='height: 20px' value=".$lang_invite['submit_confirm_users']."></td></tr>");
|
||||||
}
|
}
|
||||||
print("</form>");
|
print("</form>");
|
||||||
print("<tr><td colspan=7 align=center><form method=post action=invite.php?id=".htmlspecialchars($id)."&type=new><input type=submit ".($CURUSER[invites] <= 0 ? "disabled " : "")." value='".$lang_invite['sumbit_invite_someone']."'></form></td></tr>");
|
print("<tr><td colspan=7 align=center><form method=post action=invite.php?id=".htmlspecialchars($id)."&type=new><input type=submit ".($CURUSER['invites'] <= 0 ? "disabled " : "")." value='".$lang_invite['sumbit_invite_someone']."'></form></td></tr>");
|
||||||
}
|
}
|
||||||
print("</table>");
|
print("</table>");
|
||||||
|
|
||||||
|
|||||||
@@ -676,6 +676,12 @@ $lang_settings = array
|
|||||||
'text_email_notification_note' => "是否允许用户在收取新短讯、评论等时候收到邮件提示。",
|
'text_email_notification_note' => "是否允许用户在收取新短讯、评论等时候收到邮件提示。",
|
||||||
'text_users_get' => "首次升级至此等级的用户将获得",
|
'text_users_get' => "首次升级至此等级的用户将获得",
|
||||||
'text_invitations_default' => "个邀请名额。默认",
|
'text_invitations_default' => "个邀请名额。默认",
|
||||||
|
'row_use_cron_trigger_cleanup' => '使用定时器进行清理',
|
||||||
|
'text_use_cron_trigger_cleanup_note' => '确保已经配置好定时任务',
|
||||||
|
'row_display_errors' => '显示错误',
|
||||||
|
'text_display_errors_note' => '在网页上展示错误信息',
|
||||||
|
'row_logging' => '运行日志路径',
|
||||||
|
'text_logging_note' => '请填写你的运行时日志路径',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -676,6 +676,12 @@ $lang_settings = array
|
|||||||
'text_email_notification_note' => "是否允許用戶在收取新短訊、評論等時候收到郵件輔助說明。",
|
'text_email_notification_note' => "是否允許用戶在收取新短訊、評論等時候收到郵件輔助說明。",
|
||||||
'text_users_get' => "首次升級至此等級的用戶將獲得",
|
'text_users_get' => "首次升級至此等級的用戶將獲得",
|
||||||
'text_invitations_default' => "個邀請名額。預設",
|
'text_invitations_default' => "個邀請名額。預設",
|
||||||
|
'row_use_cron_trigger_cleanup' => '使用定時器進行清理',
|
||||||
|
'text_use_cron_trigger_cleanup_note' => '確保已經配置好定時任務',
|
||||||
|
'row_display_errors' => '顯示錯誤',
|
||||||
|
'text_display_errors_note' => '在網頁上展示錯誤信息',
|
||||||
|
'row_logging' => '運行日誌路徑',
|
||||||
|
'text_logging_note' => '請填寫妳的運行時日誌路徑',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -676,6 +676,12 @@ $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_use_cron_trigger_cleanup' => 'Use cron trigger cleanup',
|
||||||
|
'text_use_cron_trigger_cleanup_note' => 'Make sure have configure crontab job',
|
||||||
|
'row_display_errors' => 'Display errors',
|
||||||
|
'text_display_errors_note' => 'Display errors message on page',
|
||||||
|
'row_logging' => 'Runtime log path',
|
||||||
|
'text_logging_note' => 'Please enter your runtime log path',
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
+30
-38
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require "include/bittorrent.php";
|
require "include/bittorrent.php";
|
||||||
dbconn();
|
dbconn();
|
||||||
//require_once(get_langfile_path());
|
require_once(get_langfile_path());
|
||||||
$lang_settings = __();
|
|
||||||
loggedinorreturn();
|
loggedinorreturn();
|
||||||
parked();
|
parked();
|
||||||
|
|
||||||
@@ -72,24 +71,17 @@ elseif ($action == 'savesettings_basic') // save basic
|
|||||||
stdhead($lang_settings['head_save_basic_settings']);
|
stdhead($lang_settings['head_save_basic_settings']);
|
||||||
$validConfig = array(
|
$validConfig = array(
|
||||||
'SITENAME', 'BASEURL', 'announce_url',
|
'SITENAME', 'BASEURL', 'announce_url',
|
||||||
'mysql_host', 'mysql_user', 'mysql_pass', 'mysql_db', 'mysql_port',
|
|
||||||
'redis_host', 'redis_port', 'redis_database'
|
|
||||||
);
|
);
|
||||||
GetVar($validConfig);
|
GetVar($validConfig);
|
||||||
if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_port)) {
|
$BASIC = [];
|
||||||
stdmsg($lang_settings['std_error'], $lang_settings['std_mysql_connect_error'].$lang_settings['std_click']."<a class=\"altlink\" href=\"settings.php\">".$lang_settings['std_here']."</a>".$lang_settings['std_to_go_back']);
|
foreach($validConfig as $config) {
|
||||||
} else {
|
$BASIC[$config] = $$config ?? null;
|
||||||
dbconn();
|
|
||||||
$BASIC = [];
|
|
||||||
foreach($validConfig as $config) {
|
|
||||||
$BASIC[$config] = $$config;
|
|
||||||
}
|
|
||||||
// WriteConfig('BASIC', $BASIC);
|
|
||||||
saveConfig('basic', $BASIC);
|
|
||||||
$actiontime = date("F j, Y, g:i a");
|
|
||||||
write_log("Tracker basic settings updated by $CURUSER[username]. $actiontime",'mod');
|
|
||||||
go_back();
|
|
||||||
}
|
}
|
||||||
|
// WriteConfig('BASIC', $BASIC);
|
||||||
|
saveConfig('basic', $BASIC);
|
||||||
|
$actiontime = date("F j, Y, g:i a");
|
||||||
|
write_log("Tracker basic settings updated by $CURUSER[username]. $actiontime",'mod');
|
||||||
|
go_back();
|
||||||
}
|
}
|
||||||
elseif ($action == 'savesettings_code') // save database
|
elseif ($action == 'savesettings_code') // save database
|
||||||
{
|
{
|
||||||
@@ -182,7 +174,7 @@ elseif ($action == 'savesettings_security') // save security
|
|||||||
GetVar($validConfig);
|
GetVar($validConfig);
|
||||||
$SECURITY = [];
|
$SECURITY = [];
|
||||||
foreach($validConfig as $config) {
|
foreach($validConfig as $config) {
|
||||||
$SECURITY[$config] = $$config;
|
$SECURITY[$config] = $$config ?? null;
|
||||||
}
|
}
|
||||||
// WriteConfig('SECURITY', $SECURITY);
|
// WriteConfig('SECURITY', $SECURITY);
|
||||||
saveConfig('security', $SECURITY);
|
saveConfig('security', $SECURITY);
|
||||||
@@ -255,7 +247,7 @@ elseif ($action == 'savesettings_advertisement') // save advertisement
|
|||||||
}
|
}
|
||||||
elseif ($action == 'tweaksettings') // tweak settings
|
elseif ($action == 'tweaksettings') // tweak settings
|
||||||
{
|
{
|
||||||
$TWEAK = config(null, 'tweak');
|
$TWEAK = get_setting(null, 'tweak');
|
||||||
stdhead($lang_settings['head_tweak_settings']);
|
stdhead($lang_settings['head_tweak_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_tweak' />");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_tweak' />");
|
||||||
@@ -280,7 +272,7 @@ elseif ($action == 'tweaksettings') // tweak settings
|
|||||||
}
|
}
|
||||||
elseif ($action == 'smtpsettings') // stmp settings
|
elseif ($action == 'smtpsettings') // stmp settings
|
||||||
{
|
{
|
||||||
$SMTP = config(null, 'smtp');
|
$SMTP = get_setting(null, 'smtp');
|
||||||
stdhead($lang_settings['head_smtp_settings']);
|
stdhead($lang_settings['head_smtp_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print("<tbody>");
|
print("<tbody>");
|
||||||
@@ -310,7 +302,7 @@ print("</tbody>");
|
|||||||
}
|
}
|
||||||
elseif ($action == 'securitysettings') //security settings
|
elseif ($action == 'securitysettings') //security settings
|
||||||
{
|
{
|
||||||
$SECURITY = config(null, 'security');
|
$SECURITY = get_setting(null, 'security');
|
||||||
stdhead($lang_settings['head_security_settings']);
|
stdhead($lang_settings['head_security_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_security'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_security'>");
|
||||||
@@ -328,7 +320,7 @@ elseif ($action == 'securitysettings') //security settings
|
|||||||
}
|
}
|
||||||
elseif ($action == 'authoritysettings') //Authority settings
|
elseif ($action == 'authoritysettings') //Authority settings
|
||||||
{
|
{
|
||||||
$AUTHORITY = config(null, 'authority');
|
$AUTHORITY = get_setting(null, 'authority');
|
||||||
stdhead($lang_settings['head_authority_settings']);
|
stdhead($lang_settings['head_authority_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
$maxclass = UC_SYSOP;
|
$maxclass = UC_SYSOP;
|
||||||
@@ -387,26 +379,26 @@ elseif ($action == 'basicsettings') // basic settings
|
|||||||
{
|
{
|
||||||
stdhead($lang_settings['head_basic_settings']);
|
stdhead($lang_settings['head_basic_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
$config = config(null, 'basic');
|
$config = get_setting(null, 'basic');
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_basic'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_basic'>");
|
||||||
tr($lang_settings['row_site_name'],"<input type='text' style=\"width: 300px\" name=SITENAME value='".($config["SITENAME"] ? $config["SITENAME"]: "Nexus")."'> ".$lang_settings['text_site_name_note'], 1);
|
tr($lang_settings['row_site_name'],"<input type='text' style=\"width: 300px\" name=SITENAME value='".($config["SITENAME"] ? $config["SITENAME"]: "Nexus")."'> ".$lang_settings['text_site_name_note'], 1);
|
||||||
tr($lang_settings['row_base_url'],"<input type='text' style=\"width: 300px\" name=BASEURL value='".($config["BASEURL"] ? $config["BASEURL"] : $_SERVER["HTTP_HOST"])."'> ".$lang_settings['text_it_should_be'] . $_SERVER["HTTP_HOST"] . $lang_settings['text_base_url_note'], 1);
|
tr($lang_settings['row_base_url'],"<input type='text' style=\"width: 300px\" name=BASEURL value='".($config["BASEURL"] ? $config["BASEURL"] : $_SERVER["HTTP_HOST"])."'> ".$lang_settings['text_it_should_be'] . $_SERVER["HTTP_HOST"] . $lang_settings['text_base_url_note'], 1);
|
||||||
tr($lang_settings['row_announce_url'],"<input type='text' style=\"width: 300px\" name=announce_url value='".($config["announce_url"] ? $config["announce_url"] : $_SERVER["HTTP_HOST"]."/announce.php")."'> ".$lang_settings['text_it_should_be'] . $_SERVER["HTTP_HOST"]."/announce.php", 1);
|
tr($lang_settings['row_announce_url'],"<input type='text' style=\"width: 300px\" name=announce_url value='".($config["announce_url"] ? $config["announce_url"] : $_SERVER["HTTP_HOST"]."/announce.php")."'> ".$lang_settings['text_it_should_be'] . $_SERVER["HTTP_HOST"]."/announce.php", 1);
|
||||||
tr($lang_settings['row_mysql_host'],"<input type='text' style=\"width: 300px\" name=mysql_host value='".($config["mysql_host"] ? $config["mysql_host"] : "localhost")."'> ".$lang_settings['text_mysql_host_note'], 1);
|
// tr($lang_settings['row_mysql_host'],"<input type='text' style=\"width: 300px\" name=mysql_host value='".($config["mysql_host"] ? $config["mysql_host"] : "localhost")."'> ".$lang_settings['text_mysql_host_note'], 1);
|
||||||
tr($lang_settings['row_mysql_user'],"<input type='text' style=\"width: 300px\" name=mysql_user value='".($config["mysql_user"] ? $config["mysql_user"] : "root")."'> ".$lang_settings['text_mysql_user_note'], 1);
|
// tr($lang_settings['row_mysql_user'],"<input type='text' style=\"width: 300px\" name=mysql_user value='".($config["mysql_user"] ? $config["mysql_user"] : "root")."'> ".$lang_settings['text_mysql_user_note'], 1);
|
||||||
tr($lang_settings['row_mysql_password'],"<input type='password' style=\"width: 300px\" name=mysql_pass value=''> ".$lang_settings['text_mysql_password_note'], 1);
|
// tr($lang_settings['row_mysql_password'],"<input type='password' style=\"width: 300px\" name=mysql_pass value=''> ".$lang_settings['text_mysql_password_note'], 1);
|
||||||
tr($lang_settings['row_mysql_database_name'],"<input type='text' style=\"width: 300px\" name=mysql_db value='".($config["mysql_db"] ? $config["mysql_db"] : "nexus")."'> ".$lang_settings['text_mysql_database_name_note'], 1);
|
// tr($lang_settings['row_mysql_database_name'],"<input type='text' style=\"width: 300px\" name=mysql_db value='".($config["mysql_db"] ? $config["mysql_db"] : "nexus")."'> ".$lang_settings['text_mysql_database_name_note'], 1);
|
||||||
tr($lang_settings['row_mysql_database_port'],"<input type='text' style=\"width: 300px\" name=mysql_port value='".($config["mysql_port"] ? $config["mysql_port"] : "3306")."'> ".$lang_settings['text_mysql_database_port_note'], 1);
|
// tr($lang_settings['row_mysql_database_port'],"<input type='text' style=\"width: 300px\" name=mysql_port value='".($config["mysql_port"] ? $config["mysql_port"] : "3306")."'> ".$lang_settings['text_mysql_database_port_note'], 1);
|
||||||
tr($lang_settings['row_redis_host'],"<input type='text' style=\"width: 300px\" name=redis_host value='".($config["redis_host"] ? $config["redis_host"] : "127.0.0.1")."'> ".$lang_settings['text_row_redis_host_note'], 1);
|
// tr($lang_settings['row_redis_host'],"<input type='text' style=\"width: 300px\" name=redis_host value='".($config["redis_host"] ? $config["redis_host"] : "127.0.0.1")."'> ".$lang_settings['text_row_redis_host_note'], 1);
|
||||||
tr($lang_settings['row_redis_port'],"<input type='text' style=\"width: 300px\" name=redis_port value='".($config["redis_port"] ? $config["redis_port"] : "6379")."'> ".$lang_settings['text_row_redis_port_note'], 1);
|
// tr($lang_settings['row_redis_port'],"<input type='text' style=\"width: 300px\" name=redis_port value='".($config["redis_port"] ? $config["redis_port"] : "6379")."'> ".$lang_settings['text_row_redis_port_note'], 1);
|
||||||
tr($lang_settings['row_redis_database'],"<input type='text' style=\"width: 300px\" name=redis_database value='".($config["redis_database"] ? $config["redis_database"] : "0")."'> ".$lang_settings['text_row_redis_database'], 1);
|
// tr($lang_settings['row_redis_database'],"<input type='text' style=\"width: 300px\" name=redis_database value='".($config["redis_database"] ? $config["redis_database"] : "0")."'> ".$lang_settings['text_row_redis_database'], 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>");
|
||||||
}
|
}
|
||||||
elseif ($action == 'attachmentsettings') // basic settings
|
elseif ($action == 'attachmentsettings') // basic settings
|
||||||
{
|
{
|
||||||
$ATTACHMENT = config(null, 'attachment');
|
$ATTACHMENT = get_setting(null, 'attachment');
|
||||||
stdhead($lang_settings['head_attachment_settings']);
|
stdhead($lang_settings['head_attachment_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_attachment'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_attachment'>");
|
||||||
@@ -428,7 +420,7 @@ elseif ($action == 'attachmentsettings') // basic settings
|
|||||||
}
|
}
|
||||||
elseif ($action == 'advertisementsettings')
|
elseif ($action == 'advertisementsettings')
|
||||||
{
|
{
|
||||||
$ADVERTISEMENT = config(null, 'advertisement');
|
$ADVERTISEMENT = get_setting(null, 'advertisement');
|
||||||
stdhead($lang_settings['head_advertisement_settings']);
|
stdhead($lang_settings['head_advertisement_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_advertisement'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_advertisement'>");
|
||||||
@@ -442,7 +434,7 @@ elseif ($action == 'advertisementsettings')
|
|||||||
}
|
}
|
||||||
elseif ($action == 'codesettings') // code settings
|
elseif ($action == 'codesettings') // code settings
|
||||||
{
|
{
|
||||||
$CODE = config(null, 'code');
|
$CODE = get_setting(null, 'code');
|
||||||
stdhead($lang_settings['head_code_settings']);
|
stdhead($lang_settings['head_code_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_code'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_code'>");
|
||||||
@@ -454,7 +446,7 @@ elseif ($action == 'codesettings') // code settings
|
|||||||
print ("</form>");
|
print ("</form>");
|
||||||
}
|
}
|
||||||
elseif ($action == 'bonussettings'){
|
elseif ($action == 'bonussettings'){
|
||||||
$BONUS = config(null, 'bonus');
|
$BONUS = get_setting(null, 'bonus');
|
||||||
stdhead($lang_settings['head_bonus_settings']);
|
stdhead($lang_settings['head_bonus_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_bonus'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_bonus'>");
|
||||||
@@ -488,7 +480,7 @@ elseif ($action == 'bonussettings'){
|
|||||||
print ("</form>");
|
print ("</form>");
|
||||||
}
|
}
|
||||||
elseif ($action == 'accountsettings'){
|
elseif ($action == 'accountsettings'){
|
||||||
$ACCOUNT = config(null, 'account');
|
$ACCOUNT = get_setting(null, 'account');
|
||||||
stdhead($lang_settings['head_account_settings']);
|
stdhead($lang_settings['head_account_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
$maxclass = UC_VIP;
|
$maxclass = UC_VIP;
|
||||||
@@ -532,7 +524,7 @@ elseif ($action == 'accountsettings'){
|
|||||||
}
|
}
|
||||||
elseif ($action == 'torrentsettings')
|
elseif ($action == 'torrentsettings')
|
||||||
{
|
{
|
||||||
$TORRENT = config(null, 'torrent');
|
$TORRENT = get_setting(null, 'torrent');
|
||||||
stdhead($lang_settings['head_torrent_settings']);
|
stdhead($lang_settings['head_torrent_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_torrent'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_torrent'>");
|
||||||
@@ -564,7 +556,7 @@ elseif ($action == 'torrentsettings')
|
|||||||
}
|
}
|
||||||
elseif ($action == 'mainsettings') // main settings
|
elseif ($action == 'mainsettings') // main settings
|
||||||
{
|
{
|
||||||
$MAIN = config(null, 'main');
|
$MAIN = get_setting(null, 'main');
|
||||||
stdhead($lang_settings['head_main_settings']);
|
stdhead($lang_settings['head_main_settings']);
|
||||||
print ($notice);
|
print ($notice);
|
||||||
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_main'>");
|
print ("<form method='post' action='".$_SERVER["SCRIPT_NAME"]."'><input type='hidden' name='action' value='savesettings_main'>");
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ if ($_SERVER["REQUEST_METHOD"] != "POST")
|
|||||||
|
|
||||||
$origmsg = intval($_POST["origmsg"] ?? 0);
|
$origmsg = intval($_POST["origmsg"] ?? 0);
|
||||||
$msg = trim($_POST["body"]);
|
$msg = trim($_POST["body"]);
|
||||||
if ($_POST['forward'] == 1) //this is forwarding
|
if (isset($_POST['forward']) && $_POST['forward'] == 1) //this is forwarding
|
||||||
{
|
{
|
||||||
if (!$origmsg)
|
if (!$origmsg)
|
||||||
stderr($lang_takemessage['std_error'], $lang_takemessage['std_invalid_id']);
|
stderr($lang_takemessage['std_error'], $lang_takemessage['std_invalid_id']);
|
||||||
|
|||||||
Reference in New Issue
Block a user