Skip to content

Commit 076aeeb

Browse files
committed
cleanup comment
1 parent efb635c commit 076aeeb

File tree

2 files changed

+41
-22
lines changed

2 files changed

+41
-22
lines changed

include/cleanup.php

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function ban_user_with_leech_warning_expired()
175175
->where('enabled', \App\Models\User::ENABLED_YES)
176176
->where('leechwarn', 'yes')
177177
->where('leechwarnuntil', '<', $dt)
178-
->get(['id', 'username', 'modcomment', 'lang']);
178+
->get(['id', 'username', 'lang']);
179179
if ($results->isEmpty()) {
180180
return [];
181181
}
@@ -206,28 +206,37 @@ function ban_user_with_leech_warning_expired()
206206

207207
function disable_user(\Illuminate\Database\Eloquent\Builder $query, $reasonKey)
208208
{
209-
$results = $query->where('enabled', \App\Models\User::ENABLED_YES)->get(['id', 'username', 'modcomment', 'lang']);
209+
$results = $query->where('enabled', \App\Models\User::ENABLED_YES)->get(['id', 'username', 'lang']);
210210
if ($results->isEmpty()) {
211211
return [];
212212
}
213213
$results->load('language');
214214
$uidArr = [];
215215
$userBanLogData = [];
216+
$userModifyLogs = [];
216217
foreach ($results as $user) {
217218
$uid = $user->id;
218219
$uidArr[] = $uid;
220+
$reason = nexus_trans($reasonKey, [], $user->locale);
219221
$userBanLogData[] = [
220222
'uid' => $uid,
221223
'username' => $user->username,
222-
'reason' => nexus_trans($reasonKey, [], $user->locale),
224+
'reason' => $reason,
225+
];
226+
$userModifyLogs[] = [
227+
'user_id' => $uid,
228+
'content' => sprintf("[CLEANUP] %s", $reason),
229+
'created_at' => date("Y-m-d H:i:s"),
230+
'updated_at' => date("Y-m-d H:i:s"),
223231
];
224232
}
225233
$sql = sprintf(
226-
"update users set enabled = '%s', modcomment = concat_ws('\n', '%s [CLEANUP] %s', modcomment) where id in (%s)",
227-
\App\Models\User::ENABLED_NO, date('Y-m-d'), addslashes($reasonKey), implode(', ', $uidArr)
234+
"update users set enabled = '%s' where id in (%s)",
235+
\App\Models\User::ENABLED_NO, implode(', ', $uidArr)
228236
);
229237
sql_query($sql);
230238
\App\Models\UserBanLog::query()->insert($userBanLogData);
239+
\App\Models\UserModifyLog::query()->insert($userModifyLogs);
231240
do_log("[DISABLE_USER]($reasonKey): " . implode(', ', $uidArr));
232241
return $uidArr;
233242
}
@@ -697,55 +706,65 @@ function docleanup($forceAll = 0, $printProgress = false) {
697706
}
698707

699708
//remove VIP status if time's up
700-
$res = sql_query("SELECT id, modcomment, class FROM users WHERE vip_added='yes' AND vip_until < NOW()") or sqlerr(__FILE__, __LINE__);
701-
if (mysql_num_rows($res) > 0)
709+
$res = sql_query("SELECT id, class FROM users WHERE vip_added='yes' AND vip_until < NOW()") or sqlerr(__FILE__, __LINE__);
710+
$userModifyLogs = [];
711+
if (mysql_num_rows($res) > 0)
702712
{
703713
while ($arr = mysql_fetch_assoc($res))
704714
{
705715
$dt = sqlesc(date("Y-m-d H:i:s"));
706716
$subject = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_vip_status_removed']);
707717
$msg = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_vip_status_removed_body']);
708-
///---AUTOSYSTEM MODCOMMENT---//
709-
$modcomment = htmlspecialchars($arr["modcomment"]);
710-
$modcomment = date("Y-m-d") . " - VIP status removed by - AutoSystem.\n". $modcomment;
711-
$modcom = sqlesc($modcomment);
712-
///---end
718+
$userModifyLogs[] = [
719+
'user_id' => $arr['id'],
720+
'content' => "VIP status removed by - AutoSystem",
721+
'created_at' => date("Y-m-d H:i:s"),
722+
'updated_at' => date("Y-m-d H:i:s"),
723+
];
713724
if ($arr['class'] > \App\Models\User::CLASS_VIP) {
714725
/**
715726
* @since 1.8
716727
* never demotion VIP above
717728
*/
718-
sql_query("UPDATE users SET vip_added = 'no', vip_until = null, modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
729+
sql_query("UPDATE users SET vip_added = 'no', vip_until = null WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
719730
} else {
720-
sql_query("UPDATE users SET class = '1', vip_added = 'no', vip_until = null, modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
731+
sql_query("UPDATE users SET class = '1', vip_added = 'no', vip_until = null WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
721732
sql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, {$arr['id']}, $dt, $msg, $subject)") or sqlerr(__FILE__, __LINE__);
722733
}
723734
}
724735
}
736+
if (!empty($userModifyLogs)) {
737+
\App\Models\UserModifyLog::query()->insert($userModifyLogs);
738+
}
725739
$log = "remove VIP status if time's up";
726740
do_log($log);
727741
if ($printProgress) {
728742
printProgress($log);
729743
}
730744

731745
//remove donor status if time's up
732-
$res = sql_query("SELECT id, modcomment FROM users WHERE donor='yes' AND donoruntil is not null and donoruntil != '0000-00-00 00:00:00' and donoruntil < NOW()") or sqlerr(__FILE__, __LINE__);
746+
$userModifyLogs = [];
747+
$res = sql_query("SELECT id FROM users WHERE donor='yes' AND donoruntil is not null and donoruntil != '0000-00-00 00:00:00' and donoruntil < NOW()") or sqlerr(__FILE__, __LINE__);
733748
if (mysql_num_rows($res) > 0)
734749
{
735750
while ($arr = mysql_fetch_assoc($res))
736751
{
737752
$dt = sqlesc(date("Y-m-d H:i:s"));
738753
$subject = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_donor_status_removed']);
739754
$msg = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_donor_status_removed_body']);
740-
///---AUTOSYSTEM MODCOMMENT---//
741-
$modcomment = htmlspecialchars($arr["modcomment"]);
742-
$modcomment = date("Y-m-d") . " - donor status removed by - AutoSystem.\n". $modcomment;
743-
$modcom = sqlesc($modcomment);
744-
///---end
745-
sql_query("UPDATE users SET donor = 'no', modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
755+
$userModifyLogs[] = [
756+
'user_id' => $arr['id'],
757+
'content' => "donor status removed by - AutoSystem",
758+
'created_at' => date("Y-m-d H:i:s"),
759+
'updated_at' => date("Y-m-d H:i:s"),
760+
];
761+
sql_query("UPDATE users SET donor = 'no' WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__);
746762
sql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, {$arr['id']}, $dt, $msg, $subject)") or sqlerr(__FILE__, __LINE__);
747763
}
748764
}
765+
if (!empty($userModifyLogs)) {
766+
\App\Models\UserModifyLog::query()->insert($userModifyLogs);
767+
}
749768
$log = "remove donor status if time's up";
750769
do_log($log);
751770
if ($printProgress) {

include/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3366,7 +3366,7 @@ function linkcolor($num) {
33663366
}
33673367

33683368
function writecomment($userid, $comment, $oldModcomment = null) {
3369-
\App\Models\UserModifyLog::query()->create(['user_id' => $userid, 'content' => date("Y-m-d") . " - " . $comment]);
3369+
\App\Models\UserModifyLog::query()->create(['user_id' => $userid, 'content' => $comment]);
33703370
// if (is_null($oldModcomment)) {
33713371
// $res = sql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__);
33723372
// $arr = mysql_fetch_assoc($res);

0 commit comments

Comments
 (0)