mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
replace method id() by property id, empty by isset/strlen
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Gazelle\Search\Torrent;
|
||||
|
||||
use Gazelle\User;
|
||||
|
||||
class Report extends \Gazelle\Base {
|
||||
protected string $orderBy;
|
||||
protected string $title;
|
||||
@@ -95,17 +97,19 @@ class Report extends \Gazelle\Base {
|
||||
}
|
||||
}
|
||||
|
||||
public function setReporterId(int $reporterId): void {
|
||||
public function setReporter(User $reporter): static {
|
||||
$this->configure();
|
||||
$this->cond[] = "r.ReporterID = ?";
|
||||
$this->args[] = $reporterId;
|
||||
$this->args[] = $reporter->id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOrderBy(string $orderBy): void {
|
||||
public function setOrderBy(string $orderBy): static {
|
||||
$this->orderBy = "ORDER BY $orderBy";
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function canUnclaim(\Gazelle\User $user): bool {
|
||||
public function canUnclaim(User $user): bool {
|
||||
return $this->mode === 'staff' && $user->id === (int)$this->id;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,14 +32,14 @@ class Friend extends \Gazelle\BaseUser {
|
||||
}
|
||||
|
||||
public function add(\Gazelle\User $friend): int {
|
||||
if ($this->user->id === $friend->id()) {
|
||||
if ($this->user->id === $friend->id) {
|
||||
return -1;
|
||||
}
|
||||
self::$db->prepared_query("
|
||||
INSERT IGNORE INTO friends
|
||||
(UserID, FriendID)
|
||||
VALUES (?, ?)
|
||||
", $this->user->id, $friend->id()
|
||||
", $this->user->id, $friend->id
|
||||
);
|
||||
return self::$db->affected_rows();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class Friend extends \Gazelle\BaseUser {
|
||||
Comment = ?
|
||||
WHERE UserID = ?
|
||||
AND FriendID = ?
|
||||
", $comment, $this->user->id, $friend->id()
|
||||
", $comment, $this->user->id, $friend->id
|
||||
);
|
||||
return self::$db->affected_rows();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class Friend extends \Gazelle\BaseUser {
|
||||
DELETE FROM friends
|
||||
WHERE UserID = ?
|
||||
AND FriendID = ?
|
||||
", $this->user->id, $friend->id()
|
||||
", $this->user->id, $friend->id
|
||||
);
|
||||
return self::$db->affected_rows();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class Session extends \Gazelle\BaseUser {
|
||||
$info = $this->info();
|
||||
if (count($info) > 1) {
|
||||
foreach ($info as $id => $session) {
|
||||
if ($id != $sessionKey) {
|
||||
if ($id !== $sessionKey) {
|
||||
return $session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ if (isset($_GET['search'])) {
|
||||
$_GET['search'] = trim($_GET['search']);
|
||||
}
|
||||
|
||||
if (!empty($_GET['search'])) {
|
||||
if (isset($_GET['search'])) {
|
||||
if (preg_match(IP_REGEXP, $_GET['search'])) {
|
||||
$_GET['ip'] = $_GET['search'];
|
||||
} elseif (preg_match(EMAIL_REGEXP, $_GET['search'])) {
|
||||
@@ -69,36 +69,35 @@ $orderBy = [
|
||||
$dir = ['Ascending' => 'ASC', 'Descending' => 'DESC'];
|
||||
|
||||
// Arrays, regexps, and all that fun stuff we can use for validation, form generation, etc
|
||||
$orderByValue = ['inarray' => array_keys($orderBy)];
|
||||
$dirValue = ['inarray' => array_keys($dir)];
|
||||
|
||||
$dateChoice = ['inarray' => ['on', 'before', 'after', 'between']];
|
||||
$orderByValue = ['inarray' => array_keys($orderBy)];
|
||||
$dirValue = ['inarray' => array_keys($dir)];
|
||||
$dateChoice = ['inarray' => ['on', 'before', 'after', 'between']];
|
||||
$singledateChoice = ['inarray' => ['on', 'before', 'after']];
|
||||
$numberChoice = ['inarray' => ['equal', 'above', 'below', 'between', 'buffer']];
|
||||
$offNumberChoice = ['inarray' => ['equal', 'above', 'below', 'between', 'buffer', 'off']];
|
||||
$yesNo = ['inarray' => ['any', 'yes', 'no']];
|
||||
$nullable = ['inarray' => ['any', 'isnull', 'isnotnull']];
|
||||
$numberChoice = ['inarray' => ['equal', 'above', 'below', 'between', 'buffer']];
|
||||
$offNumberChoice = ['inarray' => ['equal', 'above', 'below', 'between', 'buffer', 'off']];
|
||||
$yesNo = ['inarray' => ['any', 'yes', 'no']];
|
||||
$nullable = ['inarray' => ['any', 'isnull', 'isnotnull']];
|
||||
|
||||
$emailHistoryChecked = false;
|
||||
$ipHistoryChecked = false;
|
||||
$disabledIpChecked = false;
|
||||
$trackerLiveSource = true;
|
||||
$ipHistoryChecked = false;
|
||||
$disabledIpChecked = false;
|
||||
$trackerLiveSource = true;
|
||||
|
||||
$paginator = new Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1));
|
||||
$stylesheet = new \Gazelle\Manager\Stylesheet()->list();
|
||||
$paginator = new Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1));
|
||||
$stylesheet = new Manager\Stylesheet()->list();
|
||||
|
||||
$matchMode = ($_GET['matchtype'] ?? 'fuzzy');
|
||||
$searchDisabledInvites = (isset($_GET['disabled_invites']) && $_GET['disabled_invites'] != '');
|
||||
$searchDisabledUploads = (isset($_GET['disabled_uploads']) && $_GET['disabled_uploads'] != '');
|
||||
$searchLockedAccount = (($_GET['lockedaccount'] ?? '') == 'locked');
|
||||
$showInvited = (($_GET['invited'] ?? 'off') !== 'off');
|
||||
$matchMode = $_GET['matchtype'] ?? 'fuzzy';
|
||||
$searchDisabledInvites = isset($_GET['disabled_invites']) && $_GET['disabled_invites'] != '';
|
||||
$searchDisabledUploads = isset($_GET['disabled_uploads']) && $_GET['disabled_uploads'] != '';
|
||||
$searchLockedAccount = ($_GET['lockedaccount'] ?? '') === 'locked';
|
||||
$showInvited = ($_GET['invited'] ?? 'off') !== 'off';
|
||||
|
||||
if (empty($_GET)) {
|
||||
if ($_GET === []) {
|
||||
$result = [];
|
||||
} else {
|
||||
$emailHistoryChecked = !empty($_GET['email_history']);
|
||||
$disabledIpChecked = !empty($_GET['disabled_ip']);
|
||||
$ipHistoryChecked = !empty($_GET['ip_history']);
|
||||
$emailHistoryChecked = isset($_GET['email_history']);
|
||||
$disabledIpChecked = isset($_GET['disabled_ip']);
|
||||
$ipHistoryChecked = isset($_GET['ip_history']);
|
||||
$trackerLiveSource = ($_GET['tracker-src'] ?? 'live') == 'live';
|
||||
$dateRegexp = ['regexp' => '/\d{4}-\d{2}-\d{2}/'];
|
||||
$userclassList = [];
|
||||
@@ -178,12 +177,12 @@ if (empty($_GET)) {
|
||||
LEFT JOIN relay.user_last_access AS ula ON (ula.user_id = um1."ID")
|
||||
';
|
||||
|
||||
if (!empty($_GET['username'])) {
|
||||
if (strlen($_GET['username'] ?? '')) {
|
||||
$where[] = $m->matchField('um1."Username"');
|
||||
$args[] = $_GET['username'];
|
||||
}
|
||||
|
||||
if (!empty($_GET['email'])) {
|
||||
if (strlen($_GET['email'] ?? '')) {
|
||||
if (isset($_GET['email_history'])) {
|
||||
$distinct = true;
|
||||
$join['he'] = 'INNER JOIN relay.users_history_emails AS he ON (he."UserID" = um1."ID")';
|
||||
@@ -194,7 +193,7 @@ if (empty($_GET)) {
|
||||
$args[] = $_GET['email'];
|
||||
}
|
||||
|
||||
if (isset($_GET['email_opt']) && isset($_GET['email_cnt']) && strlen($_GET['email_cnt'])) {
|
||||
if (strlen($_GET['email_opt'] ?? '') && strlen($_GET['email_cnt'] ?? '')) {
|
||||
$where[] = sprintf('um1."ID" IN (%s)',
|
||||
$m->op('
|
||||
SELECT "UserID" FROM relay.users_history_emails GROUP BY "UserID" HAVING count(DISTINCT "Email")
|
||||
@@ -204,7 +203,7 @@ if (empty($_GET)) {
|
||||
$args[] = (int)$_GET['email_cnt'];
|
||||
}
|
||||
|
||||
if (!empty($_GET['ip'])) {
|
||||
if (strlen($_GET['ip'] ?? '')) {
|
||||
if ($ipHistoryChecked) {
|
||||
$distinct = true;
|
||||
$join['hi'] = 'INNER JOIN relay.users_history_ips AS hi ON (hi."UserID" = um1."ID")';
|
||||
@@ -222,12 +221,12 @@ if (empty($_GET)) {
|
||||
$where[] = 'la."UserID" IS NULL';
|
||||
}
|
||||
|
||||
if (!empty($_GET['cc'])) {
|
||||
if (strlen($_GET['cc'] ?? '')) {
|
||||
$where[] = $m->op('um1.ipcc', $_GET['cc_op']);
|
||||
$args[] = trim($_GET['cc']);
|
||||
}
|
||||
|
||||
if (!empty($_GET['tracker_ip'])) {
|
||||
if (strlen($_GET['tracker_ip'] ?? '')) {
|
||||
$distinct = true;
|
||||
$join['xfu'] = $trackerLiveSource
|
||||
? 'INNER JOIN relay.xbt_files_users AS xfu ON (um1."ID" = xfu.uid)'
|
||||
@@ -236,27 +235,27 @@ if (empty($_GET)) {
|
||||
$args[] = trim($_GET['tracker_ip']);
|
||||
}
|
||||
|
||||
if (!empty($_GET['comment'])) {
|
||||
if (strlen($_GET['comment'] ?? '')) {
|
||||
$distinct = true;
|
||||
$join['audit'] = 'inner join user_audit_trail uat on (uat.id_user = um1."ID")';
|
||||
$where[] = "note_ts @@ plainto_tsquery('simple', ?)";
|
||||
$args[] = $_GET['comment'];
|
||||
}
|
||||
|
||||
if (!empty($_GET['lastfm'])) {
|
||||
if (strlen($_GET['lastfm'] ?? '')) {
|
||||
$distinct = true;
|
||||
$join['lfm'] = 'INNER JOIN relay.lastfm_users AS lfm ON (lfm."ID" = um1."ID")';
|
||||
$where[] = $m->matchField('lfm."Username"');
|
||||
$args[] = $_GET['lastfm'];
|
||||
}
|
||||
|
||||
if (isset($_GET['invites']) && !empty($_GET['invites']) && isset($_GET['invites1']) && strlen($_GET['invites1'])) {
|
||||
if (strlen($_GET['invites'] ?? '') && strlen($_GET['invites1'] ?? '')) {
|
||||
$op = $_GET['invites'];
|
||||
$where[] = $m->op('um1."Invites"', $op);
|
||||
$args = array_merge($args, [$_GET['invites1']], ($op === 'between' ? [$_GET['invites2']] : []));
|
||||
}
|
||||
|
||||
if ($showInvited && isset($_GET['invited1']) && strlen($_GET['invited1'])) {
|
||||
if ($showInvited && strlen($_GET['invited1'] ?? '')) {
|
||||
$op = $_GET['invited'];
|
||||
$where[] = 'um1.ID IN ('
|
||||
. $m->op('SELECT umi."ID"
|
||||
@@ -290,7 +289,7 @@ if (empty($_GET)) {
|
||||
$args[] = 'disable-upload';
|
||||
}
|
||||
|
||||
if (isset($_GET['joined']) && !empty($_GET['joined']) && isset($_GET['join1']) && !empty($_GET['join1'])) {
|
||||
if (strlen($_GET['joined'] ?? '') && strlen($_GET['join1'] ?? '')) {
|
||||
$op = $_GET['joined'];
|
||||
$where[] = $m->date('um1.created', $op);
|
||||
$args[] = $_GET['join1'];
|
||||
@@ -301,7 +300,7 @@ if (empty($_GET)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['lastactive']) && !empty($_GET['lastactive']) && isset($_GET['lastactive1']) && !empty($_GET['lastactive1'])) {
|
||||
if (strlen($_GET['lastactive'] ?? '') && strlen($_GET['lastactive1'] ?? '')) {
|
||||
$op = $_GET['lastactive'];
|
||||
$where[] = $m->date('ula.last_access', $op);
|
||||
$args[] = $_GET['lastactive1'];
|
||||
@@ -312,7 +311,7 @@ if (empty($_GET)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['ratio']) && !empty($_GET['ratio']) && isset($_GET['ratio1']) && strlen($_GET['ratio1'])) {
|
||||
if (strlen($_GET['ratio'] ?? '') && strlen($_GET['ratio1'] ?? '')) {
|
||||
$frac = explode('.', $_GET['ratio1']);
|
||||
$decimals = strlen(end($frac));
|
||||
if (!$decimals) {
|
||||
@@ -323,19 +322,19 @@ if (empty($_GET)) {
|
||||
$args = array_merge($args, [$decimals, $_GET['ratio1']], ($op === 'between' ? [$_GET['ratio2']] : []));
|
||||
}
|
||||
|
||||
if (isset($_GET['bounty']) && !empty($_GET['bounty']) && $_GET['bounty'] !== 'off' && isset($_GET['bounty1']) && strlen($_GET['bounty1'])) {
|
||||
if (strlen($_GET['bounty'] ?? '') && $_GET['bounty'] !== 'off' && strlen($_GET['bounty1'] ?? '')) {
|
||||
$op = $_GET['bounty'];
|
||||
$where[] = $m->op('(SELECT sum("Bounty") FROM relay.requests_votes rv WHERE rv."UserID" = um1."ID")', $op);
|
||||
$args = array_merge($args, [$_GET['bounty1'] * 1024 ** 3], ($op === 'between' ? [$_GET['bounty2'] * 1024 ** 3] : []));
|
||||
}
|
||||
|
||||
if (isset($_GET['downloads']) && !empty($_GET['downloads']) && $_GET['downloads'] !== 'off' && isset($_GET['downloads1']) && strlen($_GET['downloads1'])) {
|
||||
if (strlen($_GET['downloads'] ?? '') && $_GET['downloads'] !== 'off' && strlen($_GET['downloads1'] ?? '')) {
|
||||
$op = $_GET['downloads'];
|
||||
$where[] = $m->op('(SELECT count(DISTINCT "TorrentID") FROM relay.users_downloads ud WHERE ud."UserID" = um1."ID")', $op);
|
||||
$args = array_merge($args, [$_GET['downloads1']], ($op === 'between' ? [$_GET['downloads2']] : []));
|
||||
}
|
||||
|
||||
if (isset($_GET['seeding']) && $_GET['seeding'] !== 'off' && isset($_GET['seeding1'])) {
|
||||
if (strlen($_GET['seeding'] ?? '') && $_GET['seeding'] !== 'off' && strlen($_GET['seeding1'] ?? '')) {
|
||||
$op = $_GET['seeding'];
|
||||
$where[] = $m->op('(SELECT count(DISTINCT fid)
|
||||
FROM relay.xbt_files_users xfu
|
||||
@@ -344,13 +343,13 @@ if (empty($_GET)) {
|
||||
$args = array_merge($args, [$_GET['seeding1']], ($op === 'between' ? [$_GET['seeding2']] : []));
|
||||
}
|
||||
|
||||
if (isset($_GET['snatched']) && $_GET['snatched'] !== 'off' && isset($_GET['snatched1'])) {
|
||||
if (strlen($_GET['snatched'] ?? '') && $_GET['snatched'] !== 'off' && strlen($_GET['snatched1'] ?? '')) {
|
||||
$op = $_GET['snatched'];
|
||||
$where[] = $m->op('(SELECT count(DISTINCT fid) FROM relay.xbt_snatched AS xs WHERE xs.uid = um1."ID")', $op);
|
||||
$args = array_merge($args, [$_GET['snatched1']], ($op === 'between' ? [$_GET['snatched2']] : []));
|
||||
}
|
||||
|
||||
if (isset($_GET['uploaded']) && !empty($_GET['uploaded']) && isset($_GET['uploaded1']) && strlen($_GET['uploaded1'])) {
|
||||
if (strlen($_GET['uploaded'] ?? '') && strlen($_GET['uploaded1'] ?? '')) {
|
||||
$op = $_GET['uploaded'];
|
||||
if ($op === 'buffer') {
|
||||
$where[] = 'uls1."Uploaded" - uls1."Downloaded" BETWEEN ? AND ?';
|
||||
@@ -366,7 +365,7 @@ if (empty($_GET)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['downloaded']) && !empty($_GET['downloaded']) && isset($_GET['downloaded1']) && strlen($_GET['downloaded1'])) {
|
||||
if (strlen($_GET['downloaded'] ?? '') && strlen($_GET['downloaded1'] ?? '')) {
|
||||
$op = $_GET['downloaded'];
|
||||
$where[] = $m->op('uls1."Downloaded"', $op);
|
||||
$args[] = $_GET['downloaded1'] * 1024 ** 3;
|
||||
@@ -377,7 +376,7 @@ if (empty($_GET)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['enabled']) && $_GET['enabled'] != '') {
|
||||
if (strlen($_GET['enabled'] ?? '')) {
|
||||
$where[] = 'um1."Enabled" = ?';
|
||||
$args[] = $_GET['enabled'];
|
||||
}
|
||||
@@ -387,13 +386,13 @@ if (empty($_GET)) {
|
||||
$args = array_merge($args, $_GET['class']);
|
||||
}
|
||||
|
||||
if (isset($_GET['secclass']) && $_GET['secclass'] != '') {
|
||||
if (strlen($_GET['secclass'] ?? '')) {
|
||||
$join['ul'] = 'INNER JOIN relay.users_levels AS ul ON (um1."ID" = ul."UserID")';
|
||||
$where[] = 'ul."PermissionID" = ?';
|
||||
$args[] = $_GET['secclass'];
|
||||
}
|
||||
|
||||
if (isset($_GET['warned']) && !empty($_GET['warned'])) {
|
||||
if (isset($_GET['warned'])) {
|
||||
$where[] = $m->op('ui1."Warned"', $_GET['warned']);
|
||||
}
|
||||
|
||||
@@ -409,17 +408,17 @@ if (empty($_GET)) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['passkey']) && !empty($_GET['passkey'])) {
|
||||
if (strlen($_GET['passkey'] ?? '')) {
|
||||
$where[] = $m->matchField('um1.torrent_pass');
|
||||
$args[] = $_GET['passkey'];
|
||||
}
|
||||
|
||||
if (isset($_GET['avatar']) && !empty($_GET['avatar'])) {
|
||||
if (strlen($_GET['avatar'] ?? '')) {
|
||||
$where[] = $m->matchField('um1.avatar');
|
||||
$args[] = $_GET['avatar'];
|
||||
}
|
||||
|
||||
if (isset($_GET['stylesheet']) && !empty($_GET['stylesheet'])) {
|
||||
if (strlen($_GET['stylesheet'] ?? '')) {
|
||||
$where[] = $m->matchField('um1.stylesheet_id');
|
||||
$args[] = $_GET['stylesheet'];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ $user = new Manager\Invite()->findUserByKey($inviteKey, new Manager\User());
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($user->id != $Viewer->id()) {
|
||||
if ($user->id !== $Viewer->id) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,16 @@ namespace Gazelle;
|
||||
|
||||
$userMan = new Manager\User();
|
||||
|
||||
$user = $userMan->findById(($_REQUEST['id'] ?? '') === 'me' ? $Viewer->id() : (int)($_REQUEST['id'] ?? 0));
|
||||
$user = $userMan->findById(($_REQUEST['id'] ?? '') === 'me' ? $Viewer->id : (int)($_REQUEST['id'] ?? 0));
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
$UserID = $user->id;
|
||||
if ($UserID != $Viewer->id() && !$Viewer->permitted('users_edit_profiles')) {
|
||||
if ($user->id !== $Viewer->id && !$Viewer->permitted('users_edit_profiles')) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
$donor = new User\Donor($user);
|
||||
$profile = [
|
||||
$donor = new User\Donor($user);
|
||||
$profile = [
|
||||
'title' => $user->profileTitle(),
|
||||
'info' => new Util\Textarea('info', $user->profileInfo(), 42, 8),
|
||||
];
|
||||
@@ -30,17 +29,17 @@ foreach (range(1, 4) as $level) {
|
||||
];
|
||||
}
|
||||
}
|
||||
$navList = new Manager\UserNavigation()->fullList();
|
||||
$pushToken = new User\Notification($user)->pushToken();
|
||||
$navList = new Manager\UserNavigation()->fullList();
|
||||
$notifier = new User\Notification($user);
|
||||
|
||||
echo $Twig->render('user/setting.twig', [
|
||||
'donor' => $donor,
|
||||
'lastfm_username' => new Util\LastFM()->username($user),
|
||||
'nav_items' => $navList,
|
||||
'nav_items_user' => $user->navigationList(),
|
||||
'notify_config' => new User\Notification($user)->config(),
|
||||
'push_topic' => $pushToken,
|
||||
'notify_config' => $notifier->config(),
|
||||
'profile' => $profile,
|
||||
'push_topic' => $notifier->pushToken(),
|
||||
'release_order' => $user->releaseOrder(new ReleaseType()->extendedList()),
|
||||
'stylesheet' => new User\Stylesheet($user),
|
||||
'stylesheets' => new Manager\Stylesheet()->list(),
|
||||
|
||||
@@ -21,7 +21,7 @@ if (!isset($_REQUEST['id'])) {
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
$ownProfile = ($user->id === $Viewer->id());
|
||||
$ownProfile = $user->id === $Viewer->id;
|
||||
if (!$ownProfile && !$Viewer->permitted('users_edit_profiles')) {
|
||||
$irc::sendMessage(IRC_CHAN_MOD, "User {$Viewer->label()} tried to edit {$user->publicLocation()}");
|
||||
Error403::error();
|
||||
@@ -154,7 +154,7 @@ if ($avatar != $user->avatar()) {
|
||||
}
|
||||
|
||||
$ResetPassword = false;
|
||||
if (!empty($_POST['password']) && !empty($_POST['new_pass_1']) && !empty($_POST['new_pass_2'])) {
|
||||
if (isset($_POST['password']) && isset($_POST['new_pass_1']) && isset($_POST['new_pass_2'])) {
|
||||
if (!$user->validatePassword($_POST['password'])) {
|
||||
Error400::error('You did not enter the correct password.');
|
||||
} elseif (!Util\PasswordCheck::checkPasswordStrength($_POST['password'], $user)) {
|
||||
@@ -180,24 +180,25 @@ if (!empty($_POST['password']) && !empty($_POST['new_pass_1']) && !empty($_POST[
|
||||
}
|
||||
}
|
||||
|
||||
$option['DisableGrouping2'] = (!empty($_POST['disablegrouping']) ? 0 : 1);
|
||||
$option['TorrentGrouping'] = (!empty($_POST['torrentgrouping']) ? 1 : 0);
|
||||
$option['AutoSubscribe'] = isset($_POST['autosubscribe']) ? 1 : 0;
|
||||
$option['CoverArt'] = isset($_POST['coverart']) ? 1 : 0;
|
||||
$option['DisableAutoSave'] = isset($_POST['disableautosave']) ? 1 : 0;
|
||||
$option['DisableAvatars'] = isset($_POST['disableavatars']) ? 1 : 0;
|
||||
$option['DisableGrouping2'] = isset($_POST['disablegrouping']) ? 1 : 0;
|
||||
$option['DisablePMAvatars'] = isset($_POST['disablepmavatars']) ? 1 : 0;
|
||||
$option['DisableSmileys'] = isset($_POST['disablesmileys']) ? 1 : 0;
|
||||
$option['EnableMatureContent'] = isset($_POST['enablematurecontent']) ? 1 : 0;
|
||||
$option['ListUnreadPMsFirst'] = isset($_POST['list_unread_pms_first']) ? 1 : 0;
|
||||
$option['NoVoteLinks'] = isset($_POST['novotelinks']) ? 1 : 0;
|
||||
$option['ShowExtraCovers'] = isset($_POST['show_extra_covers']) ? 1 : 0;
|
||||
$option['ShowSnatched'] = isset($_POST['showsnatched']) ? 1 : 0;
|
||||
$option['ShowTorFilter'] = isset($_POST['showtfilter']) ? 1 : 0;
|
||||
$option['TorrentGrouping'] = isset($_POST['torrentgrouping']) ? 1 : 0;
|
||||
$option['UseOpenDyslexic'] = isset($_POST['useopendyslexic']) ? 1 : 0;
|
||||
|
||||
$option['PostsPerPage'] = (int)$_POST['postsperpage'];
|
||||
$option['CollageCovers'] = (int)$_POST['collagecovers'];
|
||||
$option['ShowTorFilter'] = (empty($_POST['showtfilter']) ? 0 : 1);
|
||||
$option['AutoSubscribe'] = (!empty($_POST['autosubscribe']) ? 1 : 0);
|
||||
$option['DisableSmileys'] = (int)isset($_POST['disablesmileys']);
|
||||
$option['EnableMatureContent'] = (!empty($_POST['enablematurecontent']) ? 1 : 0);
|
||||
$option['UseOpenDyslexic'] = (!empty($_POST['useopendyslexic']) ? 1 : 0);
|
||||
$option['DisableAvatars'] = (int)($_POST['disableavatars'] ?? 0);
|
||||
$option['Identicons'] = (int)($_POST['identicons'] ?? 0);
|
||||
$option['DisablePMAvatars'] = (!empty($_POST['disablepmavatars']) ? 1 : 0);
|
||||
$option['ListUnreadPMsFirst'] = (!empty($_POST['list_unread_pms_first']) ? 1 : 0);
|
||||
$option['ShowSnatched'] = (!empty($_POST['showsnatched']) ? 1 : 0);
|
||||
$option['DisableAutoSave'] = (!empty($_POST['disableautosave']) ? 1 : 0);
|
||||
$option['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
|
||||
$option['CoverArt'] = (int)!empty($_POST['coverart']);
|
||||
$option['ShowExtraCovers'] = (int)!empty($_POST['show_extra_covers']);
|
||||
$option['AutoComplete'] = $_POST['autocomplete'];
|
||||
|
||||
// user options
|
||||
@@ -206,7 +207,7 @@ foreach (['DefaultSearch', 'DisableFreeTorrentTop10'] as $opt) {
|
||||
$option[$opt] = $user->option($opt);
|
||||
}
|
||||
}
|
||||
if (empty($_POST['sorthide'])) {
|
||||
if (!isset($_POST['sorthide'])) {
|
||||
$option['SortHide'] = [];
|
||||
} else {
|
||||
$JSON = json_decode($_POST['sorthide']);
|
||||
@@ -216,7 +217,7 @@ if (empty($_POST['sorthide'])) {
|
||||
}
|
||||
}
|
||||
if ($Viewer->permitted('site_advanced_search')) {
|
||||
$option['SearchType'] = (int)!empty($_POST['search_type_advanced']);
|
||||
$option['SearchType'] = (int)isset($_POST['search_type_advanced']);
|
||||
} else {
|
||||
unset($option['SearchType']);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ $user = new Manager\User()->findById((int)($_REQUEST['userid'] ?? 0));
|
||||
if (is_null($user)) {
|
||||
Error404::error('No such user');
|
||||
}
|
||||
if ($user->id != $Viewer->id && !$Viewer->permitted('users_mod')) {
|
||||
if ($user->id !== $Viewer->id && !$Viewer->permitted('users_mod')) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ $visible = isset($_POST['Visible']) ? '1' : '0';
|
||||
$unlimitedDownload = isset($_POST['unlimitedDownload']);
|
||||
$invites = (int)$_POST['Invites'];
|
||||
$slogan = trim($_POST['slogan']);
|
||||
$changePassword = !empty($_POST['ChangePassword']);
|
||||
$changePassword = isset($_POST['ChangePassword']);
|
||||
$uploaded = 0;
|
||||
$downloaded = 0;
|
||||
$bonusPoints = null;
|
||||
@@ -88,7 +88,7 @@ $resetPasskey = isset($_POST['ResetPasskey']) ? 1 : 0;
|
||||
$resetAuthkey = isset($_POST['ResetAuthkey']) ? 1 : 0;
|
||||
$logoutSession = isset($_POST['Logout']) ? 1 : 0;
|
||||
$sendHackedMail = isset($_POST['SendHackedMail']) ? 1 : 0;
|
||||
if ($sendHackedMail && !empty(trim($_POST['HackedEmail']))) {
|
||||
if ($sendHackedMail && isset($_POST['HackedEmail'])) {
|
||||
$hackedEmail = trim($_POST['HackedEmail']);
|
||||
} else {
|
||||
$sendHackedMail = false;
|
||||
@@ -353,11 +353,11 @@ if ($Viewer->permittedAny('users_promote_below', 'users_promote_to')) {
|
||||
if ($currentClasses != $secondaryClasses) {
|
||||
$removedClasses = array_diff($currentClasses, $secondaryClasses);
|
||||
$addedClasses = array_diff($secondaryClasses, $currentClasses);
|
||||
if (!empty($removedClasses)) {
|
||||
if ($removedClasses !== []) {
|
||||
$names = array_map(fn (int $c): string => $userMan->userclassName($c), $removedClasses);
|
||||
$editSummary[] = 'secondary classes dropped: ' . implode(', ', $names);
|
||||
}
|
||||
if (!empty($addedClasses)) {
|
||||
if ($addedClasses !== []) {
|
||||
$names = array_map(fn (int $c): string => $userMan->userclassName($c), $addedClasses);
|
||||
$editSummary[] = "secondary classes added: " . implode(', ', $names);
|
||||
}
|
||||
|
||||
@@ -60,5 +60,5 @@ if ($filterId) {
|
||||
$filter->create($Viewer);
|
||||
}
|
||||
|
||||
$Cache->delete_multi(["u_notify_" . $Viewer->id(), "notify_artists_" . $Viewer->id()]);
|
||||
$Cache->delete_multi(["u_notify_{$Viewer->id}", "notify_artists_{$Viewer->id}"]);
|
||||
header('Location: user.php?action=notify');
|
||||
|
||||
@@ -9,12 +9,15 @@ $user = new Manager\User()->findById((int)$_GET['userid']);
|
||||
if (is_null($user)) {
|
||||
Error403::error();
|
||||
}
|
||||
if (!$Viewer->permitted('users_mod') && $user->id != $Viewer->id()) {
|
||||
if ($user->id !== $Viewer->id && !$Viewer->permitted('users_mod')) {
|
||||
Error403::error();
|
||||
}
|
||||
authorize();
|
||||
|
||||
new Manager\Notification()->push([$user->id],
|
||||
'Push!', 'You have been pushed by ' . $Viewer->username());
|
||||
new Manager\Notification()->push(
|
||||
[$user->id],
|
||||
'Push!',
|
||||
"You have been pushed by {$Viewer->username()}",
|
||||
);
|
||||
|
||||
header('Location: ' . $user->location() . '&action=edit');
|
||||
header("Location: {$user->location()}&action=edit");
|
||||
|
||||
@@ -11,7 +11,7 @@ if (!$Viewer->hasAttr('feature-seedbox') && !$Viewer->permitted('users_view_ips'
|
||||
}
|
||||
|
||||
if (!isset($_POST['action'])) {
|
||||
$userId = (int)($_GET['userid'] ?? $Viewer->id());
|
||||
$userId = (int)($_GET['userid'] ?? $Viewer->id);
|
||||
} else {
|
||||
authorize();
|
||||
$userId = (int)$_POST['userid'];
|
||||
@@ -20,7 +20,7 @@ $user = new Manager\User()->findById($userId);
|
||||
if (!$user) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($Viewer->id() != $userId && !$Viewer->permitted('users_view_ips')) {
|
||||
if ($userId !== $Viewer->id && !$Viewer->permitted('users_view_ips')) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ if (!$Viewer->hasAttr('feature-seedbox') && !$Viewer->permitted('users_view_ips'
|
||||
}
|
||||
|
||||
if (!isset($_POST['action'])) {
|
||||
$userId = (int)($_GET['userid'] ?? $Viewer->id());
|
||||
$userId = (int)($_GET['userid'] ?? $Viewer->id);
|
||||
} else {
|
||||
authorize();
|
||||
$userId = (int)$_POST['userid'];
|
||||
@@ -20,7 +20,7 @@ $user = new Manager\User()->findById($userId);
|
||||
if (!$user) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($Viewer->id() != $userId && !$Viewer->permitted('users_view_ips')) {
|
||||
if ($userId !== $Viewer->id && !$Viewer->permitted('users_view_ips')) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ if (!isset($_GET['id'])) {
|
||||
$user = $Viewer;
|
||||
} else {
|
||||
$userId = (int)$_GET['id'];
|
||||
if ($userId !== $Viewer->id() && !$Viewer->permittedAny('users_logout', 'users_view_ips')) {
|
||||
if ($userId !== $Viewer->id && !$Viewer->permittedAny('users_logout', 'users_view_ips')) {
|
||||
Error403::error();
|
||||
}
|
||||
$user = new Manager\User()->findById($userId);
|
||||
|
||||
@@ -6,7 +6,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Gazelle;
|
||||
|
||||
$userId = (int)($_GET['user_id'] ?? $Viewer->id());
|
||||
$userId = (int)($_GET['user_id'] ?? $Viewer->id);
|
||||
$user = new User($userId);
|
||||
|
||||
$tokenId = (int)($_GET['token_id'] ?? 0);
|
||||
@@ -16,7 +16,7 @@ $tokenName = '';
|
||||
|
||||
$_GET['do'] ??= '';
|
||||
|
||||
if (!empty($_GET['do']) && $userId !== $Viewer->id() && !$Viewer->permitted('users_mod')) {
|
||||
if (strlen($_GET['do']) && $userId !== $Viewer->id && !$Viewer->permitted('users_mod')) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ if ($_GET['do'] === 'revoke') {
|
||||
header("Location: {$user->location()}&action=edit");
|
||||
exit;
|
||||
} elseif ($_GET['do'] === 'generate') {
|
||||
$tokenName = $_POST['token_name'] ?? '';
|
||||
if (empty($tokenName)) {
|
||||
$tokenName = trim($_POST['token_name'] ?? '');
|
||||
if (!strlen($tokenName)) {
|
||||
$error = 'You must supply a name for the token.';
|
||||
} elseif ($user->hasApiTokenByName($tokenName)) {
|
||||
$error = 'You have already generated a token with that name.';
|
||||
|
||||
@@ -296,7 +296,7 @@ if ($Viewer->permitted('users_mod') && $user->onRatioWatch()) {
|
||||
<?php
|
||||
foreach (range(1, 4) as $level) {
|
||||
$profileInfo = $donor->profileInfo($level);
|
||||
if (!empty($profileInfo)) {
|
||||
if (is_string($profileInfo)) {
|
||||
?>
|
||||
<div class="box">
|
||||
<div class="head">
|
||||
|
||||
@@ -17,7 +17,7 @@ if (!isset($_GET['userid'])) {
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($user->id != $Viewer->id() && !$Viewer->permitted('users_mod')) {
|
||||
if ($user->id !== $Viewer->id && !$Viewer->permitted('users_mod')) {
|
||||
Error403::error();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ switch ($_REQUEST['dupeaction'] ?? '') {
|
||||
$target = $userMan->find($username);
|
||||
if (is_null($target)) {
|
||||
Error400::error("User '" . display_str($username) . "' not found.");
|
||||
} elseif ($source->id() === $target->id()) {
|
||||
} elseif ($source->id === $target->id) {
|
||||
Error400::error("Cannot link a user to themselves");
|
||||
}
|
||||
$userLink->dupe($target, $Viewer, $updateNote);
|
||||
|
||||
@@ -12,7 +12,7 @@ $user = new Manager\User()->findById((int)$_GET['id']);
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
$ownProfile = $user->id === $Viewer->id();
|
||||
$ownProfile = $user->id === $Viewer->id;
|
||||
if (!$Viewer->permitted('view-release-votes') && !$ownProfile) {
|
||||
Error403::error();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
|
||||
$ownProfile = $user->id === $Viewer->id();
|
||||
$showUnread = $ownProfile && (bool)($_GET['showunread'] ?? false);
|
||||
$ownProfile = $user->id === $Viewer->id;
|
||||
$showUnread = $ownProfile && (bool)($_GET['showunread'] ?? false);
|
||||
$showGrouped = $ownProfile && (bool)($_GET['group'] ?? false);
|
||||
|
||||
if ($showGrouped) {
|
||||
|
||||
@@ -10,29 +10,27 @@ $filter = $_GET['filter'] ?? '';
|
||||
$userMan = new Manager\User();
|
||||
if (empty($_GET['userid'])) {
|
||||
$user = $Viewer;
|
||||
$ownProfile = true;
|
||||
} else {
|
||||
$userId = (int)$_GET['userid'];
|
||||
if ($Viewer->id() !== $userId && !$Viewer->permitted('admin_reports')) {
|
||||
if ($userId !== $Viewer->id && !$Viewer->permitted('admin_reports')) {
|
||||
Error403::error();
|
||||
}
|
||||
$user = $userMan->findById($userId);
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
$ownProfile = ($user->id === $Viewer->id());
|
||||
}
|
||||
$ownProfile = $user->id === $Viewer->id;
|
||||
|
||||
if (!empty($filter) && !in_array($filter, ['resolved', 'open'])) {
|
||||
Error400::error('Invalid filter specified');
|
||||
}
|
||||
|
||||
$search = new Search\Torrent\Report($filter, '', new Manager\Torrent\ReportType(), $userMan);
|
||||
$search = new Search\Torrent\Report($filter, '', new Manager\Torrent\ReportType(), $userMan)
|
||||
->setReporter($user)
|
||||
->setOrderBy('r.ReportedTime DESC');
|
||||
|
||||
$paginator = new Util\Paginator(50, (int)($_REQUEST['page'] ?? 1));
|
||||
|
||||
$search->setReporterId($user->id());
|
||||
$search->setOrderBy('r.ReportedTime DESC');
|
||||
|
||||
$paginator->setTotal($search->total());
|
||||
|
||||
$torManager = new Manager\Torrent();
|
||||
@@ -45,5 +43,3 @@ echo $Twig->render('user/report-history.twig', [
|
||||
'user' => $user,
|
||||
'viewer' => $Viewer,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ if (!isset($_GET['userid'])) {
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($user->id !== $Viewer->id() && !$Viewer->permitted('admin_fl_history')) {
|
||||
if ($user->id !== $Viewer->id && !$Viewer->permitted('admin_fl_history')) {
|
||||
Error403::error();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
$forumSearch = new Search\Forum($user);
|
||||
if ($Viewer->id() != $user->id) {
|
||||
if ($user->id !== $Viewer->id) {
|
||||
$forumSearch->setViewer($Viewer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user