mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
fix imdb in new structure
This commit is contained in:
@@ -3,7 +3,6 @@ define('NEXUS_START', microtime(true));
|
||||
# IMPORTANT: Do not edit below unless you know what you are doing!
|
||||
define('IN_TRACKER', true);
|
||||
$rootpath= dirname(__DIR__) . '/';
|
||||
|
||||
require $rootpath . 'include/functions_announce.php';
|
||||
require $rootpath . 'include/globalfunctions.php';
|
||||
require $rootpath . 'include/core.php';
|
||||
|
||||
@@ -69,9 +69,7 @@ if (basename($_SERVER['SCRIPT_FILENAME']) == 'announce.php') {
|
||||
}
|
||||
$settings = get_setting();
|
||||
foreach ($settings as $name => $value) {
|
||||
$prefix = strtoupper(strstr($name, '.', true));
|
||||
$pureName = substr($name, strpos($name, '.') + 1);
|
||||
$GLOBALS[$prefix][$pureName] = $value;
|
||||
$GLOBALS[strtoupper($name)] = $value;
|
||||
}
|
||||
|
||||
$SITENAME = $BASIC['SITENAME'];
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<?php
|
||||
if(!defined('IN_TRACKER'))
|
||||
die('Hacking attempt!');
|
||||
if(!defined('IN_TRACKER')) {
|
||||
die('Hacking attempt!');
|
||||
}
|
||||
error_reporting(E_ALL);
|
||||
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);
|
||||
|
||||
require $rootpath . 'include/database/interface_db.php';
|
||||
require $rootpath . 'include/database/class_db_mysqli.php';
|
||||
|
||||
@@ -1339,6 +1339,7 @@ function check_email ($email) {
|
||||
}
|
||||
|
||||
function sent_mail($to,$fromname,$fromemail,$subject,$body,$type = "confirmation",$showmsg=true,$multiple=false,$multiplemail='',$hdr_encoding = 'UTF-8', $specialcase = '') {
|
||||
do_log("to: $to, fromname: $fromname, fromemail: $fromemail, subject: $subject, body: $body. type: $type");
|
||||
global $lang_functions;
|
||||
global $rootpath,$SITENAME,$SITEEMAIL,$smtptype,$smtp,$smtp_host,$smtp_port,$smtp_from,$smtpaddress,$smtpport,$accountname,$accountpassword;
|
||||
# Is the OS Windows or Mac or Linux?
|
||||
@@ -1423,24 +1424,31 @@ function sent_mail($to,$fromname,$fromemail,$subject,$body,$type = "confirmation
|
||||
|
||||
$setting = get_setting('smtp');
|
||||
// Create the Transport
|
||||
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
|
||||
->setUsername('your username')
|
||||
->setPassword('your password')
|
||||
$transport = (new Swift_SmtpTransport($setting['smtpaddress'], $setting['smtpport']))
|
||||
->setUsername($setting['accountname'])
|
||||
->setPassword($setting['accountpassword'])
|
||||
;
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new Swift_Message('Wonderful Subject'))
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
|
||||
->setBody('Here is the message itself')
|
||||
$message = (new Swift_Message($subject))
|
||||
->setFrom($fromemail, $fromname)
|
||||
->setTo([$to])
|
||||
->setBody($body)
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$result = $mailer->send($message);
|
||||
|
||||
try {
|
||||
$result = $mailer->send($message);
|
||||
if ($result == 0) {
|
||||
stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
do_log("send email fail: " . $e->getMessage() . ", trace: " . $e->getTraceAsString());
|
||||
stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']);
|
||||
}
|
||||
|
||||
}
|
||||
if ($showmsg) {
|
||||
|
||||
@@ -147,14 +147,16 @@ function dd($vars)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
function do_log($log)
|
||||
function do_log($log, $level = 'info')
|
||||
{
|
||||
global $TWEAK;
|
||||
if (!empty($TWEAK['logging'])) {
|
||||
$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",
|
||||
date('Y-m-d H:i:s'),
|
||||
$level,
|
||||
REQUEST_ID,
|
||||
$backtrace[0]['file'] ?? '',
|
||||
$backtrace[0]['line'] ?? '',
|
||||
$backtrace[1]['class'] ?? '',
|
||||
@@ -206,11 +208,10 @@ function __($name = null, $prefix = null)
|
||||
|
||||
function config($key, $default = null)
|
||||
{
|
||||
global $rootpath;
|
||||
static $configs;
|
||||
if (is_null($configs)) {
|
||||
//get all configuration from config file
|
||||
$files = glob($rootpath . 'config/*.php');
|
||||
$files = glob(ROOT_PATH . 'config/*.php');
|
||||
foreach ($files as $file) {
|
||||
$basename = basename($file);
|
||||
if ($basename == 'allconfig.php') {
|
||||
@@ -233,7 +234,7 @@ function config($key, $default = null)
|
||||
* @param null $name
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
function get_setting($name = null, $prefix = null)
|
||||
function get_setting($name = null)
|
||||
{
|
||||
static $settings;
|
||||
if (is_null($settings)) {
|
||||
@@ -246,36 +247,20 @@ function get_setting($name = null, $prefix = null)
|
||||
if (is_array($arr)) {
|
||||
$value = $arr;
|
||||
}
|
||||
$settings[$row['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;
|
||||
arr_set($settings, $row['name'], $value);
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
|
||||
if (is_null($name)) {
|
||||
return $settings;
|
||||
}
|
||||
return arr_get($settings, $name);
|
||||
}
|
||||
|
||||
function env($key, $default = null)
|
||||
{
|
||||
global $rootpath;
|
||||
static $env;
|
||||
if (is_null($env)) {
|
||||
$envFile = $rootpath . '.env';
|
||||
$envFile = ROOT_PATH . '.env';
|
||||
if (!file_exists($envFile)) {
|
||||
throw new \RuntimeException(".env file is not exists in the root path.");
|
||||
}
|
||||
@@ -325,6 +310,18 @@ function normalize_env($value)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from an array using "dot" notation.
|
||||
*
|
||||
* referance to Laravel
|
||||
*
|
||||
* @author xiaomlove<1939737565@qq.com>
|
||||
* @date 2021/1/14
|
||||
* @param $array
|
||||
* @param $key
|
||||
* @param null $default
|
||||
* @return mixed|null
|
||||
*/
|
||||
function arr_get($array, $key, $default = null)
|
||||
{
|
||||
if (strpos($key, '.') === false) {
|
||||
@@ -340,23 +337,44 @@ function arr_get($array, $key, $default = null)
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* From Laravel
|
||||
*
|
||||
* Set an array item to a given value using "dot" notation.
|
||||
*
|
||||
* If no key is given to the method, the entire array will be replaced.
|
||||
*
|
||||
* @param array $array
|
||||
* @param string|null $key
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
function arr_set(&$array, $key, $value)
|
||||
{
|
||||
$parts = explode('.', $key);
|
||||
$last = null;
|
||||
while (true) {
|
||||
$segment = array_pop($parts);
|
||||
if (empty($segment)) {
|
||||
return $array;
|
||||
}
|
||||
if (is_null($last)) {
|
||||
$array[$segment] = $value;
|
||||
} else {
|
||||
$array[$segment] = $array;
|
||||
unset($array[$last]);
|
||||
}
|
||||
$last = $segment;
|
||||
|
||||
if (is_null($key)) {
|
||||
return $array = $value;
|
||||
}
|
||||
|
||||
$keys = explode('.', $key);
|
||||
|
||||
foreach ($keys as $i => $key) {
|
||||
if (count($keys) === 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
unset($keys[$i]);
|
||||
|
||||
// If the key doesn't exist at this depth, we will just create an empty array
|
||||
// to hold the next value, allowing us to create the arrays to hold final
|
||||
// values at the correct depth. Then we'll keep digging into the array.
|
||||
if (! isset($array[$key]) || ! is_array($array[$key])) {
|
||||
$array[$key] = [];
|
||||
}
|
||||
|
||||
$array = &$array[$key];
|
||||
}
|
||||
|
||||
$array[array_shift($keys)] = $value;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user