diff --git a/include/core.php b/include/core.php
index 640eefe6..e73519d1 100644
--- a/include/core.php
+++ b/include/core.php
@@ -3,6 +3,8 @@ ini_set('error_reporting', E_ALL);
ini_set('display_errors', 0);
require_once __DIR__ . '/constants.php';
require_once $rootpath . 'vendor/autoload.php';
+$USERUPDATESET = array();
+$query_name=array();
\Nexus\Nexus::boot();
if (!file_exists($rootpath . '.env')) {
$installScriptRelativePath = 'install/install.php';
@@ -27,8 +29,6 @@ if (!isRunningInConsole() && !in_array($script, ['announce', 'scrape', 'torrentr
}
define('TIMENOW', time());
-$USERUPDATESET = array();
-$query_name=array();
define ("UC_PEASANT", 0);
define ("UC_USER", 1);
diff --git a/include/functions.php b/include/functions.php
index 3f1aecd7..86ad48b7 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2008,8 +2008,8 @@ function userlogin() {
$nip = ip2long($ip);
if ($nip) //$nip would be false for IPv6 address
{
- $res = sql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) > 0)
+ $res = sql_query("SELECT * FROM bans WHERE first <= $nip AND last >= $nip") or sqlerr(__FILE__, __LINE__);
+ if (mysql_num_rows($res) > 0)
{
header("HTTP/1.1 403 Forbidden");
print("
".$lang_functions['text_unauthorized_ip']."\n");
@@ -2042,7 +2042,6 @@ function userlogin() {
// error_reporting(E_ALL & ~E_NOTICE);
// error_reporting(-1);
// }
-
return $loginResult = true;
}
@@ -2932,13 +2931,24 @@ function stdfoot() {
$yearfounded = ($year ? $year : 2007);
print(" (c) "." ".$SITENAME." ".($icplicense_main ? " ".$icplicense_main." " : "").(date("Y") != $yearfounded ? $yearfounded."-" : "").date("Y")." ".VERSION."
");
printf ("[page created in %s sec", sprintf("%.3f", $totaltime));
- print (" with ".count($query_name)." db queries, ".$Cache->getCacheReadTimes()." reads and ".$Cache->getCacheWriteTimes()." writes of Redis and ".mksize(memory_get_usage())." ram]");
+ $debugQuery = $enablesqldebug_tweak == 'yes' && get_user_class() >= $sqldebug_tweak;
+ if ($debugQuery) {
+ $query_name_laravel = last_query(true);
+ $dbQueryCount = count($query_name) + count($query_name_laravel);
+ } else {
+ $query_name_laravel = [];
+ $dbQueryCount = count($query_name) + last_query('COUNT');
+ }
+ print (" with ".$dbQueryCount." db queries, ".$Cache->getCacheReadTimes()." reads and ".$Cache->getCacheWriteTimes()." writes of Redis and ".mksize(memory_get_usage())." ram]");
print ("\n");
- if ($enablesqldebug_tweak == 'yes' && get_user_class() >= $sqldebug_tweak) {
+ if ($debugQuery) {
print("SQL query list:
");
foreach($query_name as $query) {
print(sprintf('- %s [%s]
', htmlspecialchars($query['query']), $query['time']));
}
+ foreach($query_name_laravel as $query) {
+ print(sprintf('- %s [%s ms]
', htmlspecialchars($query['raw_query']), $query['time']));
+ }
print("
");
print("Redis key read:
");
foreach($Cache->getKeyHits('read') as $keyName => $hits) {
diff --git a/include/globalfunctions.php b/include/globalfunctions.php
index 7fb9b3d8..040329bd 100644
--- a/include/globalfunctions.php
+++ b/include/globalfunctions.php
@@ -82,7 +82,7 @@ function sql_query($query)
$end = microtime(true);
$query_name[] = [
'query' => $query,
- 'time' => sprintf('%.3f ms', ($end - $begin) * 1000),
+ 'time' => sprintf('%.2f ms', ($end - $begin) * 1000),
];
return $result;
}
@@ -626,26 +626,15 @@ function last_query($all = false)
} else {
$connection = \Illuminate\Support\Facades\DB::connection(config('database.default'));
}
- $pdo = $connection->getPdo();
}
- $queries = $connection->getQueryLog();
- if (!$all) {
- $queries = [last($queries)];
- }
- $queryFormatted = [];
- foreach ($queries as $query) {
- $sqlWithPlaceholders = str_replace(['%', '?'], ['%%', '%s'], $query['query']);
- $bindings = $query['bindings'];
- $realSql = $sqlWithPlaceholders;
- if (count($bindings) > 0) {
- $realSql = vsprintf($sqlWithPlaceholders, array_map([$pdo, 'quote'], $bindings));
- }
- $queryFormatted[] = $realSql;
+ if ($all === 'COUNT') {
+ return count($connection->getQueryLog());
}
+ $queries = $connection->getRawQueryLog();
if ($all) {
- return nexus_json_encode($queryFormatted);
+ return $queries;
}
- return $queryFormatted[0];
+ return isset($queries[0]) ? last($queries) : '';
}
function format_datetime($datetime, $format = 'Y-m-d H:i')