Browse Source

Switching to invite.php from Apollo (with some changes from Oppaitime integrated)

ElectraHeart 7 years ago
parent
commit
706328912b
1 changed files with 183 additions and 175 deletions
  1. 183
    175
      sections/user/invite.php

+ 183
- 175
sections/user/invite.php View File

@@ -1,96 +1,97 @@
1 1
 <?
2
+
2 3
 if (isset($_GET['userid']) && check_perms('users_view_invites')) {
3
-  if (!is_number($_GET['userid'])) {
4
-    error(403);
5
-  }
4
+	if (!is_number($_GET['userid'])) {
5
+		error(403);
6
+	}
6 7
 
7
-  $UserID=$_GET['userid'];
8
-  $Sneaky = true;
8
+	$UserID=$_GET['userid'];
9
+	$Sneaky = true;
9 10
 } else {
10
-  if (!$UserCount = $Cache->get_value('stats_user_count')) {
11
-    $DB->query("
12
-      SELECT COUNT(ID)
13
-      FROM users_main
14
-      WHERE Enabled = '1'");
15
-    list($UserCount) = $DB->next_record();
16
-    $Cache->cache_value('stats_user_count', $UserCount, 0);
17
-  }
18
-
19
-  $UserID = $LoggedUser['ID'];
20
-  $Sneaky = false;
11
+	if (!$UserCount = $Cache->get_value('stats_user_count')) {
12
+		$DB->query("
13
+			SELECT COUNT(ID)
14
+			FROM users_main
15
+			WHERE Enabled = '1'");
16
+		list($UserCount) = $DB->next_record();
17
+		$Cache->cache_value('stats_user_count', $UserCount, 0);
18
+	}
19
+
20
+	$UserID = $LoggedUser['ID'];
21
+	$Sneaky = false;
21 22
 }
22 23
 
23 24
 list($UserID, $Username, $PermissionID) = array_values(Users::user_info($UserID));
24 25
 
25 26
 
26 27
 $DB->query("
27
-  SELECT InviteKey, Email, Expires
28
-  FROM invites
29
-  WHERE InviterID = '$UserID'
30
-  ORDER BY Expires");
31
-$Pending = $DB->to_array();
28
+	SELECT InviteKey, Email, Expires
29
+	FROM invites
30
+	WHERE InviterID = '$UserID'
31
+	ORDER BY Expires");
32
+$Pending = 	$DB->to_array();
32 33
 
33
-$OrderWays = array('username', 'email', 'joined', 'lastseen', 'uploaded', 'downloaded', 'ratio');
34
+$OrderWays = array('username', 'email',	'joined', 'lastseen', 'uploaded', 'downloaded', 'ratio');
34 35
 
35 36
 if (empty($_GET['order'])) {
36
-  $CurrentOrder = 'id';
37
-  $CurrentSort = 'desc';
38
-  $NewSort = 'asc';
37
+	$CurrentOrder = 'id';
38
+	$CurrentSort = 'asc';
39
+	$NewSort = 'desc';
39 40
 } else {
40
-  if (in_array($_GET['order'], $OrderWays)) {
41
-    $CurrentOrder = $_GET['order'];
42
-    if ($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') {
43
-      $CurrentSort = $_GET['sort'];
44
-      $NewSort = ($_GET['sort'] == 'asc' ? 'desc' : 'asc');
45
-    } else {
46
-      error(404);
47
-    }
48
-  } else {
49
-    error(404);
50
-  }
41
+	if (in_array($_GET['order'], $OrderWays)) {
42
+		$CurrentOrder = $_GET['order'];
43
+		if ($_GET['sort'] == 'asc' || $_GET['sort'] == 'desc') {
44
+			$CurrentSort = $_GET['sort'];
45
+			$NewSort = ($_GET['sort'] == 'asc' ? 'desc' : 'asc');
46
+		} else {
47
+			error(404);
48
+		}
49
+	} else {
50
+		error(404);
51
+	}
51 52
 }
52 53
 
53 54
 switch ($CurrentOrder) {
54
-  case 'username':
55
-    $OrderBy = "um.Username";
56
-    break;
57
-  case 'email':
58
-    $OrderBy = "um.Email";
59
-    break;
60
-  case 'joined':
61
-    $OrderBy = "ui.JoinDate";
62
-    break;
63
-  case 'lastseen':
64
-    $OrderBy = "um.LastAccess";
65
-    break;
66
-  case 'uploaded':
67
-    $OrderBy = "um.Uploaded";
68
-    break;
69
-  case 'downloaded':
70
-    $OrderBy = "um.Downloaded";
71
-    break;
72
-  case 'ratio':
73
-    $OrderBy = "(um.Uploaded / um.Downloaded)";
74
-    break;
75
-  default:
76
-    $OrderBy = "um.ID";
77
-    break;
55
+	case 'username':
56
+		$OrderBy = "um.Username";
57
+		break;
58
+	case 'email':
59
+		$OrderBy = "um.Email";
60
+		break;
61
+	case 'joined':
62
+		$OrderBy = "ui.JoinDate";
63
+		break;
64
+	case 'lastseen':
65
+		$OrderBy = "um.LastAccess";
66
+		break;
67
+	case 'uploaded':
68
+		$OrderBy = "um.Uploaded";
69
+		break;
70
+	case 'downloaded':
71
+		$OrderBy = "um.Downloaded";
72
+		break;
73
+	case 'ratio':
74
+		$OrderBy = "(um.Uploaded / um.Downloaded)";
75
+		break;
76
+	default:
77
+		$OrderBy = "um.ID";
78
+		break;
78 79
 }
79 80
 
80 81
 $CurrentURL = Format::get_url(array('action', 'order', 'sort'));
81 82
 
82 83
 $DB->query("
83
-  SELECT
84
-    ID,
85
-    Email,
86
-    Uploaded,
87
-    Downloaded,
88
-    JoinDate,
89
-    LastAccess
90
-  FROM users_main AS um
91
-    LEFT JOIN users_info AS ui ON ui.UserID = um.ID
92
-  WHERE ui.Inviter = '$UserID'
93
-  ORDER BY $OrderBy $CurrentSort");
84
+	SELECT
85
+		ID,
86
+		Email,
87
+		Uploaded,
88
+		Downloaded,
89
+		JoinDate,
90
+		LastAccess
91
+	FROM users_main AS um
92
+		LEFT JOIN users_info AS ui ON ui.UserID = um.ID
93
+	WHERE ui.Inviter = '$UserID'
94
+	ORDER BY $OrderBy $CurrentSort");
94 95
 
95 96
 $Invited = $DB->to_array();
96 97
 
@@ -100,138 +101,145 @@ if (check_perms('users_mod') || check_perms('admin_advanced_user_search')) {
100 101
 }
101 102
 
102 103
 View::show_header('Invites', $JSIncludes);
104
+
103 105
 ?>
104 106
 <div class="thin">
105
-  <div class="header">
106
-    <h2><?=Users::format_username($UserID, false, false, false)?> &gt; Invites</h2>
107
-    <div class="linkbox">
108
-      <a href="user.php?action=invitetree<? if ($Sneaky) { echo '&amp;userid='.$UserID; } ?>" class="brackets">Invite tree</a>
109
-    </div>
110
-  </div>
107
+	<div class="header">
108
+		<h2><?=Users::format_username($UserID, false, false, false)?> &gt; Invites</h2>
109
+		<div class="linkbox">
110
+			<a href="user.php?action=invitetree<? if ($Sneaky) { echo '&amp;userid='.$UserID; } ?>" class="brackets">Invite tree</a>
111
+		</div>
112
+	</div>
111 113
 <? if ($UserCount >= USER_LIMIT && !check_perms('site_can_invite_always')) { ?>
112
-  <div class="box pad notice">
113
-    <p>Because the user limit has been reached you are unable to send invites at this time.</p>
114
-  </div>
114
+	<div class="box pad notice">
115
+		<p>Because the user limit has been reached you are unable to send invites at this time.</p>
116
+	</div>
115 117
 <? }
116 118
 
117 119
 /*
118
-  Users cannot send invites if they:
119
-    -Are on ratio watch
120
-    -Have disabled leeching
121
-    -Have disabled invites
122
-    -Have no invites (Unless have unlimited)
123
-    -Cannot 'invite always' and the user limit is reached
120
+	Users cannot send invites if they:
121
+		-Are on ratio watch
122
+		-Have disabled leeching
123
+		-Have disabled invites
124
+		-Have no invites (Unless have unlimited)
125
+		-Cannot 'invite always' and the user limit is reached
124 126
 */
125 127
 
126 128
 $DB->query("
127
-  SELECT can_leech
128
-  FROM users_main
129
-  WHERE ID = $UserID");
129
+	SELECT can_leech
130
+	FROM users_main
131
+	WHERE ID = $UserID");
130 132
 list($CanLeech) = $DB->next_record();
131 133
 
132
-if (!$Sneaky
133
-  && !$LoggedUser['RatioWatch']
134
-  && $CanLeech
135
-  && empty($LoggedUser['DisableInvites'])
136
-  && ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
137
-  && ($UserCount <= USER_LIMIT || USER_LIMIT == 0 || check_perms('site_can_invite_always'))
138
-  ) { ?>
139
-  <div class="box pad">
140
-    <p>Do not trade or sell invites under any circumstances.</p>
141
-    <p>You may invite anyone so long as you and they both lack malicious intent, but keep in mind that you are responsible for anyone you invite. If you invite someone you don't know well and they surprise you by breaking the rules or being a generally poor user, you will likely end up punished for it. For that reason, we stongly recommend you only invite people you personally know and trust.
142
-    <p>Do not send an invite to anyone who has previously had a <?=SITE_NAME?> account. Please direct them to <?=BOT_DISABLED_CHAN?> on <?=BOT_SERVER?> if they wish to reactivate their account.</p>
143
-    <p><em>Do not send an invite if you have not read or do not understand the information above.</em></p>
144
-  </div>
145
-  <div class="box box2">
146
-    <form class="send_form pad" name="invite" action="user.php" method="post">
147
-      <input type="hidden" name="action" value="take_invite" />
148
-      <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
149
-      <div class="field_div">
150
-        <div class="label">Email address:</div>
151
-        <div class="input">
152
-          <input type="email" name="email" size="60" />
153
-          <input type="submit" value="Invite" />
154
-        </div>
155
-      </div>
156
-<?  if (check_perms('users_invite_notes')) { ?>
157
-      <div class="field_div">
158
-        <div class="label">Staff Note:</div>
159
-        <div class="input">
160
-          <input type="text" name="reason" size="60" maxlength="255" />
161
-        </div>
162
-      </div>
163
-<?  } ?>
164
-    </form>
165
-  </div>
134
+
135
+	if (!$Sneaky
136
+		&& !$LoggedUser['RatioWatch']
137
+		&& $CanLeech
138
+		&& empty($LoggedUser['DisableInvites'])
139
+		&& ($LoggedUser['Invites'] > 0 || check_perms('site_send_unlimited_invites'))
140
+		&& ($UserCount <= USER_LIMIT || USER_LIMIT == 0 || check_perms('site_can_invite_always'))
141
+	) { ?>
142
+	<div class="box pad">
143
+		<p>Please note that selling, trading, or publicly giving away our invitations&#8202;&mdash;&#8202;or responding to public invite requests&#8202;&mdash;&#8202;is strictly forbidden, and may result in you and your entire invite tree being banned.</p>
144
+		<p>Do not send an invite to anyone who has previously had an <?=SITE_NAME?> account. Please direct them to <?=BOT_DISABLED_CHAN?> on <?=BOT_SERVER?> if they wish to reactivate their account.</p>
145
+		<p>Remember that you are responsible for ALL invitees, and your account and/or privileges may be disabled due to your invitees' actions. You should know and trust the person you're inviting. If you aren't familiar enough with the user to trust them, do not invite them.</p>
146
+		<p><em>Do not send an invite if you have not read or do not understand the information above.</em></p>
147
+	</div>
148
+	<div class="box box2">
149
+		<form class="send_form pad" name="invite" action="user.php" method="post">
150
+			<input type="hidden" name="action" value="take_invite" />
151
+			<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
152
+			<div class="field_div">
153
+				<div class="label">Email address:</div>
154
+				<div class="input">
155
+					<input type="email" name="email" size="60" />
156
+					<input type="submit" value="Invite" />
157
+				</div>
158
+			</div>
159
+<?	if (check_perms('users_invite_notes')) { ?>
160
+			<div class="field_div">
161
+				<div class="label">Staff Note:</div>
162
+				<div class="input">
163
+					<input type="text" name="reason" size="60" maxlength="255" />
164
+				</div>
165
+			</div>
166
+<?	} ?>
167
+		</form>
168
+	</div>
166 169
 
167 170
 <?
168 171
 } elseif (!empty($LoggedUser['DisableInvites'])) { ?>
169
-  <div class="box pad" style="text-align: center;">
170
-    <strong class="important_text">Your invites have been disabled. Please read <a href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more information.</strong>
171
-  </div>
172
+	<div class="box pad" style="text-align: center;">
173
+		<strong class="important_text">Your invites have been disabled. Please read <a href="wiki.php?action=article&amp;id=116">this article</a> for more information.</strong>
174
+	</div>
172 175
 <?
173 176
 } elseif ($LoggedUser['RatioWatch'] || !$CanLeech) { ?>
174
-  <div class="box pad" style="text-align: center;">
175
-    <strong class="important_text">You may not send invites while on Ratio Watch or while your leeching privileges are disabled. Please read <a href="wiki.php?action=article&amp;name=cantinvite">this article</a> for more information.</strong>
176
-  </div>
177
+	<div class="box pad" style="text-align: center;">
178
+		<strong class="important_text">You may not send invites while on Ratio Watch or while your leeching privileges are disabled. Please read <a href="wiki.php?action=article&amp;id=116">this article</a> for more information.</strong>
179
+	</div>
177 180
 <?
178 181
 }
179 182
 
180 183
 if (!empty($Pending)) {
181 184
 ?>
182
-  <h3>Pending invites</h3>
183
-  <div class="box">
184
-    <table width="100%">
185
-      <tr class="colhead">
186
-        <td>Email address</td>
187
-        <td>Expires in</td>
188
-        <td>Delete invite</td>
189
-      </tr>
185
+	<h3>Pending invites</h3>
186
+	<div class="box pad">
187
+		<table width="100%">
188
+			<tr class="colhead">
189
+				<td>Email address</td>
190
+				<td>Expires in</td>
191
+				<td>Invite link</td>
192
+				<td>Delete invite</td>
193
+			</tr>
190 194
 <?
191
-  foreach ($Pending as $Invite) {
192
-    list($InviteKey, $Email, $Expires) = $Invite;
193
-    $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
195
+	$Row = 'a';
196
+	foreach ($Pending as $Invite) {
197
+		list($InviteKey, $Email, $Expires) = $Invite;
198
+		$Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';
199
+		$Row = $Row === 'a' ? 'b' : 'a';
194 200
 ?>
195
-      <tr class="row">
196
-        <td><?=display_str($Email)?></td>
197
-        <td><?=time_diff($Expires)?></td>
198
-        <td><a href="user.php?action=delete_invite&amp;invite=<?=$InviteKey?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
199
-      </tr>
200
-<?  } ?>
201
-    </table>
202
-  </div>
201
+			<tr class="row<?=$Row?>">
202
+				<td><?=display_str($Email)?></td>
203
+				<td><?=time_diff($Expires)?></td>
204
+				<td><a href="register.php?invite=<?=$InviteKey?>">Invite link</a></td>
205
+				<td><a href="user.php?action=delete_invite&amp;invite=<?=$InviteKey?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this invite?');">Delete invite</a></td>
206
+			</tr>
207
+<?	} ?>
208
+		</table>
209
+	</div>
203 210
 <?
204 211
 }
205 212
 
206 213
 ?>
207
-  <h3>Invitee list</h3>
208
-  <div class="box">
209
-    <table width="100%", class="invite_table">
210
-      <tr class="colhead">
211
-        <td><a href="user.php?action=invite&amp;order=username&amp;sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Username</a></td>
212
-        <td><a href="user.php?action=invite&amp;order=email&amp;sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Email</a></td>
213
-        <td><a href="user.php?action=invite&amp;order=joined&amp;sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Joined</a></td>
214
-        <td><a href="user.php?action=invite&amp;order=lastseen&amp;sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Last Seen</a></td>
215
-        <td><a href="user.php?action=invite&amp;order=uploaded&amp;sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Uploaded</a></td>
216
-        <td><a href="user.php?action=invite&amp;order=downloaded&amp;sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Downloaded</a></td>
217
-        <td><a href="user.php?action=invite&amp;order=ratio&amp;sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Ratio</a></td>
218
-      </tr>
214
+	<h3>Invitee list</h3>
215
+	<div class="box pad">
216
+		<table width="100%">
217
+			<tr class="colhead">
218
+				<td><a href="user.php?action=invite&amp;order=username&amp;sort=<?=(($CurrentOrder == 'username') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Username</a></td>
219
+				<td><a href="user.php?action=invite&amp;order=email&amp;sort=<?=(($CurrentOrder == 'email') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Email</a></td>
220
+				<td><a href="user.php?action=invite&amp;order=joined&amp;sort=<?=(($CurrentOrder == 'joined') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Joined</a></td>
221
+				<td><a href="user.php?action=invite&amp;order=lastseen&amp;sort=<?=(($CurrentOrder == 'lastseen') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Last Seen</a></td>
222
+				<td><a href="user.php?action=invite&amp;order=uploaded&amp;sort=<?=(($CurrentOrder == 'uploaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Uploaded</a></td>
223
+				<td><a href="user.php?action=invite&amp;order=downloaded&amp;sort=<?=(($CurrentOrder == 'downloaded') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Downloaded</a></td>
224
+				<td><a href="user.php?action=invite&amp;order=ratio&amp;sort=<?=(($CurrentOrder == 'ratio') ? $NewSort : 'desc')?>&amp;<?=$CurrentURL ?>">Ratio</a></td>
225
+			</tr>
219 226
 <?
220
-  foreach ($Invited as $User) {
221
-    list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
222
-    $Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]'
227
+	$Row = 'a';
228
+	foreach ($Invited as $User) {
229
+		list($ID, $Email, $Uploaded, $Downloaded, $JoinDate, $LastAccess) = $User;
230
+		$Row = $Row === 'a' ? 'b' : 'a';
223 231
 ?>
224
-      <tr class="row">
225
-        <td><?=Users::format_username($ID, true, true, true, true)?></td>
226
-        <td><?=display_str($Email)?></td>
227
-        <td><?=time_diff($JoinDate, 1)?></td>
228
-        <td><?=time_diff($LastAccess, 1);?></td>
229
-        <td><?=Format::get_size($Uploaded)?></td>
230
-        <td><?=Format::get_size($Downloaded)?></td>
231
-        <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?></td>
232
-      </tr>
233
-<?  } ?>
234
-    </table>
235
-  </div>
232
+			<tr class="row<?=$Row?>">
233
+				<td><?=Users::format_username($ID, true, true, true, true)?></td>
234
+				<td><?=display_str($Email)?></td>
235
+				<td><?=time_diff($JoinDate, 1)?></td>
236
+				<td><?=time_diff($LastAccess, 1);?></td>
237
+				<td><?=Format::get_size($Uploaded)?></td>
238
+				<td><?=Format::get_size($Downloaded)?></td>
239
+				<td><?=Format::get_ratio_html($Uploaded, $Downloaded)?></td>
240
+			</tr>
241
+<?	} ?>
242
+		</table>
243
+	</div>
236 244
 </div>
237 245
 <? View::show_footer(); ?>

Loading…
Cancel
Save