enable user handle leechwarn

This commit is contained in:
xiaomlove
2021-05-15 12:59:59 +08:00
parent 682cf806d7
commit 73f9920e1f
5 changed files with 22 additions and 9 deletions

View File

@@ -82,7 +82,8 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status'
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status',
'leechwarn', 'leechwarnuntil'
];
/**

View File

@@ -153,7 +153,7 @@ class ToolRepository extends BaseRepository
$filename = $backupResult['filename'];
$upload_result = $filesystem->put(basename($filename), fopen($filename, 'r'));
$backupResult['upload_result'] = $upload_result;
do_log("Final result: " . json_encode($backupResult));
return $backupResult;
}
}

View File

@@ -123,13 +123,25 @@ class UserRepository extends BaseRepository
public function enableUser(User $operator, $uid)
{
$targetUser = User::query()->findOrFail($uid, ['id', 'enabled', 'username']);
$targetUser = User::query()->findOrFail($uid, ['id', 'enabled', 'username', 'class']);
if ($targetUser->enabled == User::ENABLED_YES) {
throw new NexusException('Already enabled!');
}
$update = [
'enabled' => User::ENABLED_YES
];
if ($targetUser->class == User::CLASS_PEASANT) {
// warn users until 30 days
$until = now()->addDays(30)->toDateTimeString();
$update['leechwarn'] = 'yes';
$update['leechwarnuntil'] = $until;
} else {
$update['leechwarn'] = 'no';
$update['leechwarnuntil'] = null;
}
$modCommentText = sprintf("Enable by %s.", $operator->username);
$targetUser->updateWithModComment(['enabled' => User::ENABLED_YES], $modCommentText);
do_log("user: $uid, $modCommentText");
$targetUser->updateWithModComment($update, $modCommentText);
do_log("user: $uid, $modCommentText, update: " . nexus_json_encode($update));
return true;
}

View File

@@ -14,7 +14,7 @@ if ($langid)
}
require_once(get_langfile_path("", false, $CURLANGDIR));
cur_user_check ();
$type = $_GET['type'];
$type = $_GET['type'] ?? '';
if ($type == 'invite')
{
registration_check();
@@ -32,7 +32,7 @@ if ($type == 'invite')
$dom = $tldm[2];
}
$sq = sprintf("SELECT inviter FROM invites WHERE hash ='%s'",mysql_real_escape_string($code));
$sq = sprintf("SELECT inviter FROM invites WHERE valid = %s and hash ='%s'", \App\Models\Invite::VALID_YES, mysql_real_escape_string($code));
$res = sql_query($sq) or sqlerr(__FILE__, __LINE__);
$inv = mysql_fetch_assoc($res);
$inviter = htmlspecialchars($inv["inviter"]);
@@ -87,7 +87,7 @@ show_image_code ();
$ct_r = sql_query("SELECT id,name FROM countries ORDER BY name") or die;
while ($ct_a = mysql_fetch_array($ct_r))
$countries .= "<option value=$ct_a[id]" . ($ct_a['id'] == 8 ? " selected" : "") . ">$ct_a[name]</option>n";
tr($lang_signup['row_country'], "<select name=country>n$countries</select>", 1);
tr($lang_signup['row_country'], "<select name=country>n$countries</select>", 1);
//School select
if ($showschool == 'yes'){
$schools = "<option value=35>---- ".$lang_signup['select_none_selected']." ----</option>n";

View File

@@ -17,7 +17,7 @@ if ($passkey){
die("invalid passkey");
elseif ($user['enabled'] == 'no' || $user['parked'] == 'yes')
die("account disabed or parked");
elseif ($_GET['linktype'] == 'dl')
elseif (isset($_GET['linktype']) && $_GET['linktype'] == 'dl')
$dllink = true;
$inclbookmarked=intval($_GET['inclbookmarked'] ?? 0);
if($inclbookmarked == 1)