Merge branch '1.6' into php8

This commit is contained in:
xiaomlove
2022-04-05 21:07:03 +08:00
4 changed files with 79 additions and 11 deletions
@@ -0,0 +1,56 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableFields = [
'comments' => ['editdate'],
'invites' => ['time_invited'],
'offers' => ['allowedtime'],
'peers' => ['last_action', 'prev_action'],
'posts' => ['editdate'],
'snatched' => ['last_action', 'completedat'],
'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'],
'users' => [
'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg',
'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until',
'leechwarnuntil', 'lastwarned',
],
];
foreach ($tableFields as $table => $fields) {
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
$modifies = [];
foreach ($fields as $field) {
if (isset($columnInfo[$field]) && $columnInfo[$field]['COLUMN_DEFAULT'] == '0000-00-00 00:00:00') {
$modifies[] = sprintf('modify `%s` datetime default null', $field);
}
}
if (!empty($modifies)) {
$sql = sprintf("alter table `%s` %s", $table, implode(', ', $modifies));
\Illuminate\Support\Facades\DB::statement($sql);
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};
+7 -6
View File
@@ -174,7 +174,7 @@ function ban_user_with_leech_warning_expired()
->where('enabled', \App\Models\User::ENABLED_YES)
->where('leechwarn', 'yes')
->where('leechwarnuntil', '<', $dt)
->get(['id', 'username', 'modcomment']);
->get(['id', 'username', 'modcomment', 'lang']);
if ($results->isEmpty()) {
return [];
}
@@ -193,7 +193,8 @@ function ban_user_with_leech_warning_expired()
}
$update = [
'enabled' => \App\Models\User::ENABLED_NO,
'leechwarnuntil' => null,
//old version site this field NOT NULL DEFAULT '0000-00-00 00:00:00'
// 'leechwarnuntil' => null,
];
\App\Models\User::query()->whereIn('id', $uidArr)->update($update);
\App\Models\UserBanLog::query()->insert($userBanLogData);
@@ -308,7 +309,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
//Priority Class 2: cleanup every 30 mins
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime2'");
$row = mysql_fetch_array($res);
if (!$row) {
if (!$row && !$forceAll) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime2',".sqlesc($now).")") or sqlerr(__FILE__, __LINE__);
$log = "no value for arg: 'lastcleantime2', return";
do_log($log);
@@ -334,7 +335,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
//Priority Class 3: cleanup every 60 mins
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime3'");
$row = mysql_fetch_array($res);
if (!$row) {
if (!$row && !$forceAll) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime3',$now)") or sqlerr(__FILE__, __LINE__);
$log = "no value for arg: 'lastcleantime3', return";
do_log($log);
@@ -494,7 +495,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
//Priority Class 4: cleanup every 24 hours
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime4'");
$row = mysql_fetch_array($res);
if (!$row) {
if (!$row && !$forceAll) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime4',$now)") or sqlerr(__FILE__, __LINE__);
$log = "no value for arg: 'lastcleantime4', return";
do_log($log);
@@ -822,7 +823,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
//Priority Class 5: cleanup every 15 days
$res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime5'");
$row = mysql_fetch_array($res);
if (!$row) {
if (!$row && !$forceAll) {
sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime5',$now)") or sqlerr(__FILE__, __LINE__);
$log = "no value for arg: 'lastcleantime5', return";
do_log($log);
+1 -1
View File
@@ -73,7 +73,7 @@ $announce_urls = array();
$announce_urls[] = $BASIC['announce_url'] ?: ($BASEURL . '/api/announce');
$SITE_ONLINE = $MAIN['site_online'];
$max_torrent_size = $MAIN['max_torrent_size'];
$max_torrent_size = (int)$MAIN['max_torrent_size'];
$announce_interval = (int)$MAIN['announce_interval'];
$annintertwoage = (int)$MAIN['annintertwoage'];
$annintertwo = (int)$MAIN['annintertwo'];
+15 -4
View File
@@ -331,7 +331,7 @@ class NexusDB
}
}
public static function getMysqlColumnInfo($table, $column)
public static function getMysqlColumnInfo($table, $column = null)
{
static $driver;
$config = nexus_config('nexus.mysql');
@@ -340,11 +340,22 @@ class NexusDB
$driver->connect($config['host'], $config['username'], $config['password'], 'information_schema', $config['port']);
}
$sql = sprintf(
"select * from COLUMNS where TABLE_SCHEMA = '%s' and TABLE_NAME = '%s' and COLUMN_NAME = '%s'",
$config['database'], $table, $column
"select * from COLUMNS where TABLE_SCHEMA = '%s' and TABLE_NAME = '%s'",
$config['database'], $table
);
if ($column !== null) {
$sql .= " and COLUMN_NAME = '$column'";
}
$res = $driver->query($sql);
return $driver->fetchAssoc($res);
if ($column !== null) {
return $driver->fetchAssoc($res);
}
$results = [];
while ($row = $driver->fetchAssoc($res)) {
$results[$row['COLUMN_NAME']] = $row;
}
return $results;
}