Browse Source

Upload files to 'classes'

Stortebeker 6 years ago
parent
commit
b42dc58822
5 changed files with 327 additions and 319 deletions
  1. 109
    112
      classes/permissions_form.php
  2. 25
    24
      classes/proxies.class.php
  3. 2
    2
      classes/regex.php
  4. 26
    24
      classes/reports.class.php
  5. 165
    157
      classes/requests.class.php

+ 109
- 112
classes/permissions_form.php View File

1
-<?
1
+<?php
2
 
2
 
3
 /********************************************************************************
3
 /********************************************************************************
4
  ************ Permissions form ********************** user.php and tools.php ****
4
  ************ Permissions form ********************** user.php and tools.php ****
112
   'site_tag_aliases_read' => 'Can view the list of tag aliases.'
112
   'site_tag_aliases_read' => 'Can view the list of tag aliases.'
113
 );
113
 );
114
 
114
 
115
-function permissions_form() {
116
-?>
115
+function permissions_form()
116
+{
117
+    ?>
117
 <div class="permissions">
118
 <div class="permissions">
118
   <div class="permission_container">
119
   <div class="permission_container">
119
     <table>
120
     <table>
122
       </tr>
123
       </tr>
123
       <tr>
124
       <tr>
124
         <td>
125
         <td>
125
-<?
126
-          display_perm('site_leech','Can leech.');
127
-          display_perm('site_upload','Can upload.');
128
-          display_perm('site_vote','Can vote on requests.');
129
-          display_perm('site_submit_requests','Can submit requests.');
130
-          display_perm('site_advanced_search','Can use advanced search.');
131
-          display_perm('site_top10','Can access top 10.');
132
-          display_perm('site_torrents_notify','Can access torrents notifications system.');
133
-          display_perm('site_collages_create','Can create collages.');
134
-          display_perm('site_collages_manage','Can manage collages (add torrents, sorting).');
135
-          display_perm('site_collages_delete','Can delete collages.');
136
-          display_perm('site_collages_subscribe','Can access collage subscriptions.');
137
-          display_perm('site_collages_personal','Can have a personal collage.');
138
-          display_perm('site_collages_renamepersonal','Can rename own personal collages.');
139
-          display_perm('site_advanced_top10','Can access advanced top 10.');
140
-          display_perm('site_make_bookmarks','Can make bookmarks.');
141
-          display_perm('site_edit_wiki','Can edit wiki pages.');
142
-          display_perm('site_can_invite_always', 'Can invite users even when invites are closed.');
143
-          display_perm('site_send_unlimited_invites', 'Can send unlimited invites.');
144
-          display_perm('site_moderate_requests', 'Can moderate any request.');
145
-          display_perm('site_delete_artist', 'Can delete artists (must be able to delete torrents+requests).');
146
-          display_perm('forums_polls_create','Can create polls in the forums.');
147
-          display_perm('forums_polls_moderate','Can feature and close polls.');
148
-          display_perm('site_moderate_forums', 'Can moderate the forums.');
149
-          display_perm('site_admin_forums', 'Can administrate the forums.');
150
-          display_perm('site_view_flow', 'Can view site stats and data pools.');
151
-          display_perm('site_view_full_log', 'Can view the full site log.');
152
-          display_perm('site_view_torrent_snatchlist', 'Can view torrent snatch lists.');
153
-          display_perm('site_recommend_own', 'Can add own torrents to recommendations list.');
154
-          display_perm('site_manage_recommendations', 'Can edit recommendations list.');
155
-          display_perm('site_delete_tag', 'Can delete tags.');
156
-          display_perm('site_disable_ip_history', 'Disable IP history.');
157
-          display_perm('zip_downloader', 'Download multiple torrents at once.');
158
-          display_perm('site_debug', 'View site debug tables.');
159
-          display_perm('site_proxy_images', 'Proxy images through the server.');
160
-          display_perm('site_search_many', 'Can go past low limit of search results.');
161
-          display_perm('site_collages_recover', 'Can recover \'deleted\' collages.');
162
-          display_perm('site_forums_double_post', 'Can double post in the forums.');
163
-          display_perm('project_team', 'Part of the project team.');
164
-          display_perm('site_tag_aliases_read', 'Can view the list of tag aliases.');
165
-          display_perm('site_ratio_watch_immunity', 'Immune from being put on ratio watch.');
166
-?>
126
+    <?php
127
+          display_perm('site_leech', 'Can leech.');
128
+    display_perm('site_upload', 'Can upload.');
129
+    display_perm('site_vote', 'Can vote on requests.');
130
+    display_perm('site_submit_requests', 'Can submit requests.');
131
+    display_perm('site_advanced_search', 'Can use advanced search.');
132
+    display_perm('site_top10', 'Can access top 10.');
133
+    display_perm('site_torrents_notify', 'Can access torrents notifications system.');
134
+    display_perm('site_collages_create', 'Can create collages.');
135
+    display_perm('site_collages_manage', 'Can manage collages (add torrents, sorting).');
136
+    display_perm('site_collages_delete', 'Can delete collages.');
137
+    display_perm('site_collages_subscribe', 'Can access collage subscriptions.');
138
+    display_perm('site_collages_personal', 'Can have a personal collage.');
139
+    display_perm('site_collages_renamepersonal', 'Can rename own personal collages.');
140
+    display_perm('site_advanced_top10', 'Can access advanced top 10.');
141
+    display_perm('site_make_bookmarks', 'Can make bookmarks.');
142
+    display_perm('site_edit_wiki', 'Can edit wiki pages.');
143
+    display_perm('site_can_invite_always', 'Can invite users even when invites are closed.');
144
+    display_perm('site_send_unlimited_invites', 'Can send unlimited invites.');
145
+    display_perm('site_moderate_requests', 'Can moderate any request.');
146
+    display_perm('site_delete_artist', 'Can delete artists (must be able to delete torrents+requests).');
147
+    display_perm('forums_polls_create', 'Can create polls in the forums.');
148
+    display_perm('forums_polls_moderate', 'Can feature and close polls.');
149
+    display_perm('site_moderate_forums', 'Can moderate the forums.');
150
+    display_perm('site_admin_forums', 'Can administrate the forums.');
151
+    display_perm('site_view_flow', 'Can view site stats and data pools.');
152
+    display_perm('site_view_full_log', 'Can view the full site log.');
153
+    display_perm('site_view_torrent_snatchlist', 'Can view torrent snatch lists.');
154
+    display_perm('site_recommend_own', 'Can add own torrents to recommendations list.');
155
+    display_perm('site_manage_recommendations', 'Can edit recommendations list.');
156
+    display_perm('site_delete_tag', 'Can delete tags.');
157
+    display_perm('site_disable_ip_history', 'Disable IP history.');
158
+    display_perm('zip_downloader', 'Download multiple torrents at once.');
159
+    display_perm('site_debug', 'View site debug tables.');
160
+    display_perm('site_proxy_images', 'Proxy images through the server.');
161
+    display_perm('site_search_many', 'Can go past low limit of search results.');
162
+    display_perm('site_collages_recover', 'Can recover \'deleted\' collages.');
163
+    display_perm('site_forums_double_post', 'Can double post in the forums.');
164
+    display_perm('project_team', 'Part of the project team.');
165
+    display_perm('site_tag_aliases_read', 'Can view the list of tag aliases.');
166
+    display_perm('site_ratio_watch_immunity', 'Immune from being put on ratio watch.'); ?>
167
         </td>
167
         </td>
168
       </tr>
168
       </tr>
169
     </table>
169
     </table>
175
       </tr>
175
       </tr>
176
       <tr>
176
       <tr>
177
         <td>
177
         <td>
178
-<?
178
+    <?php
179
           display_perm('users_edit_usernames', 'Can edit usernames.');
179
           display_perm('users_edit_usernames', 'Can edit usernames.');
180
-          display_perm('users_edit_ratio', 'Can edit anyone\'s upload/download amounts.');
181
-          display_perm('users_edit_own_ratio', 'Can edit own upload/download amounts.');
182
-          display_perm('users_edit_titles', 'Can edit titles.');
183
-          display_perm('users_edit_avatars', 'Can edit avatars.');
184
-          display_perm('users_edit_invites', 'Can edit invite numbers and cancel sent invites.');
185
-          display_perm('users_edit_watch_hours', 'Can edit contrib watch hours.');
186
-          display_perm('users_edit_reset_keys', 'Can reset any passkey/authkey.');
187
-          display_perm('users_edit_profiles', 'Can edit anyone\'s profile.');
188
-          display_perm('users_edit_badges', 'Can edit anyone\'s badges.');
189
-          display_perm('users_view_friends', 'Can view anyone\'s friends.');
190
-          display_perm('users_reset_own_keys', 'Can reset own passkey/authkey.');
191
-          display_perm('users_edit_password', 'Can change password.');
192
-          display_perm('users_promote_below', 'Can promote users to below current level.');
193
-          display_perm('users_promote_to', 'Can promote users up to current level.');
194
-          display_perm('users_give_donor', 'Can give donor access.');
195
-          display_perm('users_warn', 'Can warn users.');
196
-          display_perm('users_disable_users', 'Can disable users.');
197
-          display_perm('users_disable_posts', 'Can disable users\' posting privileges.');
198
-          display_perm('users_disable_any', 'Can disable any users\' rights.');
199
-          display_perm('users_delete_users', 'Can delete anyone\'s account');
200
-          display_perm('users_view_invites', 'Can view who user has invited');
201
-          display_perm('users_view_seedleech', 'Can view what a user is seeding or leeching');
202
-          display_perm('users_view_uploaded', 'Can view a user\'s uploads, regardless of privacy level');
203
-          display_perm('users_view_keys', 'Can view passkeys');
204
-          display_perm('users_view_ips', 'Can view IP addresses');
205
-          display_perm('users_view_email', 'Can view email addresses');
206
-          display_perm('users_invite_notes', 'Can add a staff note when inviting someone.');
207
-          display_perm('users_override_paranoia', 'Can override paranoia');
208
-          display_perm('users_make_invisible', 'Can make users invisible');
209
-          display_perm('users_logout', 'Can log users out');
210
-          display_perm('users_mod', 'Can access basic moderator tools (Admin comment)');
211
-?>
180
+    display_perm('users_edit_ratio', 'Can edit anyone\'s upload/download amounts.');
181
+    display_perm('users_edit_own_ratio', 'Can edit own upload/download amounts.');
182
+    display_perm('users_edit_titles', 'Can edit titles.');
183
+    display_perm('users_edit_avatars', 'Can edit avatars.');
184
+    display_perm('users_edit_invites', 'Can edit invite numbers and cancel sent invites.');
185
+    display_perm('users_edit_watch_hours', 'Can edit contrib watch hours.');
186
+    display_perm('users_edit_reset_keys', 'Can reset any passkey/authkey.');
187
+    display_perm('users_edit_profiles', 'Can edit anyone\'s profile.');
188
+    display_perm('users_edit_badges', 'Can edit anyone\'s badges.');
189
+    display_perm('users_view_friends', 'Can view anyone\'s friends.');
190
+    display_perm('users_reset_own_keys', 'Can reset own passkey/authkey.');
191
+    display_perm('users_edit_password', 'Can change password.');
192
+    display_perm('users_promote_below', 'Can promote users to below current level.');
193
+    display_perm('users_promote_to', 'Can promote users up to current level.');
194
+    display_perm('users_give_donor', 'Can give donor access.');
195
+    display_perm('users_warn', 'Can warn users.');
196
+    display_perm('users_disable_users', 'Can disable users.');
197
+    display_perm('users_disable_posts', 'Can disable users\' posting privileges.');
198
+    display_perm('users_disable_any', 'Can disable any users\' rights.');
199
+    display_perm('users_delete_users', 'Can delete anyone\'s account');
200
+    display_perm('users_view_invites', 'Can view who user has invited');
201
+    display_perm('users_view_seedleech', 'Can view what a user is seeding or leeching');
202
+    display_perm('users_view_uploaded', 'Can view a user\'s uploads, regardless of privacy level');
203
+    display_perm('users_view_keys', 'Can view passkeys');
204
+    display_perm('users_view_ips', 'Can view IP addresses');
205
+    display_perm('users_view_email', 'Can view email addresses');
206
+    display_perm('users_invite_notes', 'Can add a staff note when inviting someone.');
207
+    display_perm('users_override_paranoia', 'Can override paranoia');
208
+    display_perm('users_make_invisible', 'Can make users invisible');
209
+    display_perm('users_logout', 'Can log users out');
210
+    display_perm('users_mod', 'Can access basic moderator tools (Admin comment)'); ?>
212
           *Everything is only applicable to users with the same or lower class level
211
           *Everything is only applicable to users with the same or lower class level
213
         </td>
212
         </td>
214
       </tr>
213
       </tr>
221
       </tr>
220
       </tr>
222
       <tr>
221
       <tr>
223
         <td>
222
         <td>
224
-<?
223
+    <?php
225
           display_perm('torrents_edit', 'Can edit any torrent');
224
           display_perm('torrents_edit', 'Can edit any torrent');
226
-          display_perm('torrents_delete', 'Can delete torrents');
227
-          display_perm('torrents_delete_fast', 'Can delete more than 3 torrents at a time.');
228
-          display_perm('torrents_freeleech', 'Can make torrents freeleech');
229
-          display_perm('torrents_search_fast', 'Unlimit search frequency (for scripts).');
230
-          display_perm('torrents_add_artist', 'Can add artists to any group.');
231
-          display_perm('edit_unknowns', 'Can edit unknown release information.');
232
-          display_perm('torrents_edit_vanityhouse', 'Can mark groups as part of Vanity House.');
233
-          display_perm('artist_edit_vanityhouse', 'Can mark artists as part of Vanity House.');
234
-          display_perm('torrents_hide_dnu', 'Hide the Do Not Upload list by default.');
235
-          display_perm('torrents_fix_ghosts', 'Can fix ghost groups on artist pages.');
236
-          display_perm('screenshots_add', 'Can add screenshots to any torrent and delete their own screenshots.');
237
-          display_perm('screenshots_delete', 'Can delete any screenshot from any torrent.');
238
-?>
225
+    display_perm('torrents_delete', 'Can delete torrents');
226
+    display_perm('torrents_delete_fast', 'Can delete more than 3 torrents at a time.');
227
+    display_perm('torrents_freeleech', 'Can make torrents freeleech');
228
+    display_perm('torrents_search_fast', 'Unlimit search frequency (for scripts).');
229
+    display_perm('torrents_add_artist', 'Can add artists to any group.');
230
+    display_perm('edit_unknowns', 'Can edit unknown release information.');
231
+    display_perm('torrents_edit_vanityhouse', 'Can mark groups as part of Vanity House.');
232
+    display_perm('artist_edit_vanityhouse', 'Can mark artists as part of Vanity House.');
233
+    display_perm('torrents_hide_dnu', 'Hide the Do Not Upload list by default.');
234
+    display_perm('torrents_fix_ghosts', 'Can fix ghost groups on artist pages.');
235
+    display_perm('screenshots_add', 'Can add screenshots to any torrent and delete their own screenshots.');
236
+    display_perm('screenshots_delete', 'Can delete any screenshot from any torrent.'); ?>
239
         </td>
237
         </td>
240
       </tr>
238
       </tr>
241
     </table>
239
     </table>
247
       </tr>
245
       </tr>
248
       <tr>
246
       <tr>
249
         <td>
247
         <td>
250
-<?
248
+    <?php
251
           display_perm('admin_manage_news', 'Can manage site news');
249
           display_perm('admin_manage_news', 'Can manage site news');
252
-          display_perm('admin_manage_blog', 'Can manage the site blog');
253
-          display_perm('admin_manage_polls', 'Can manage polls');
254
-          display_perm('admin_manage_forums', 'Can manage forums (add/edit/delete)');
255
-          display_perm('admin_manage_fls', 'Can manage FLS');
256
-          display_perm('admin_reports', 'Can access reports system');
257
-          display_perm('admin_advanced_user_search', 'Can access advanced user search');
258
-          display_perm('admin_create_users', 'Can create users through an administrative form');
259
-          display_perm('admin_donor_log', 'Can view the donor log');
260
-          display_perm('admin_manage_ipbans', 'Can manage IP bans');
261
-          display_perm('admin_dnu', 'Can manage do not upload list');
262
-          display_perm('admin_clear_cache', 'Can clear cached pages');
263
-          display_perm('admin_whitelist', 'Can manage the list of allowed clients.');
264
-          display_perm('admin_manage_permissions', 'Can edit permission classes/user permissions.');
265
-          display_perm('admin_schedule', 'Can run the site schedule.');
266
-          display_perm('admin_login_watch', 'Can manage login watch.');
267
-          display_perm('admin_manage_wiki', 'Can manage wiki access.');
268
-          display_perm('admin_update_geoip', 'Can update geoIP data.');
269
-?>
250
+    display_perm('admin_manage_blog', 'Can manage the site blog');
251
+    display_perm('admin_manage_polls', 'Can manage polls');
252
+    display_perm('admin_manage_forums', 'Can manage forums (add/edit/delete)');
253
+    display_perm('admin_manage_fls', 'Can manage FLS');
254
+    display_perm('admin_reports', 'Can access reports system');
255
+    display_perm('admin_advanced_user_search', 'Can access advanced user search');
256
+    display_perm('admin_create_users', 'Can create users through an administrative form');
257
+    display_perm('admin_donor_log', 'Can view the donor log');
258
+    display_perm('admin_manage_ipbans', 'Can manage IP bans');
259
+    display_perm('admin_dnu', 'Can manage do not upload list');
260
+    display_perm('admin_clear_cache', 'Can clear cached pages');
261
+    display_perm('admin_whitelist', 'Can manage the list of allowed clients.');
262
+    display_perm('admin_manage_permissions', 'Can edit permission classes/user permissions.');
263
+    display_perm('admin_schedule', 'Can run the site schedule.');
264
+    display_perm('admin_login_watch', 'Can manage login watch.');
265
+    display_perm('admin_manage_wiki', 'Can manage wiki access.');
266
+    display_perm('admin_update_geoip', 'Can update geoIP data.'); ?>
270
         </td>
267
         </td>
271
       </tr>
268
       </tr>
272
     </table>
269
     </table>
273
   </div>
270
   </div>
274
   <div class="submit_container"><input type="submit" name="submit" value="Save Permission Class" /></div>
271
   <div class="submit_container"><input type="submit" name="submit" value="Save Permission Class" /></div>
275
 </div>
272
 </div>
276
-<?
273
+    <?php
277
 }
274
 }

+ 25
- 24
classes/proxies.class.php View File

1
-<?
1
+<?php
2
 //Useful: http://www.robtex.com/cnet/
2
 //Useful: http://www.robtex.com/cnet/
3
 $AllowedProxies = array(
3
 $AllowedProxies = array(
4
   //Opera Turbo (may include Opera-owned IP addresses that aren't used for Turbo, but shouldn't run much risk of exploitation)
4
   //Opera Turbo (may include Opera-owned IP addresses that aren't used for Turbo, but shouldn't run much risk of exploitation)
13
   '195.189.143.*', //Norway
13
   '195.189.143.*', //Norway
14
 );
14
 );
15
 
15
 
16
-function proxyCheck($IP) {
17
-  global $AllowedProxies;
18
-  for ($i = 0, $il = count($AllowedProxies); $i < $il; ++$i) {
19
-    //based on the wildcard principle it should never be shorter
20
-    if (strlen($IP) < strlen($AllowedProxies[$i])) {
21
-      continue;
22
-    }
16
+function proxyCheck($IP)
17
+{
18
+    global $AllowedProxies;
19
+    for ($i = 0, $il = count($AllowedProxies); $i < $il; ++$i) {
20
+        //based on the wildcard principle it should never be shorter
21
+        if (strlen($IP) < strlen($AllowedProxies[$i])) {
22
+            continue;
23
+        }
23
 
24
 
24
-    //since we're matching bit for bit iterating from the start
25
-    for ($j = 0, $jl = strlen($IP); $j < $jl; ++$j) {
26
-      //completed iteration and no inequality
27
-      if ($j == $jl - 1 && $IP[$j] === $AllowedProxies[$i][$j]) {
28
-        return true;
29
-      }
25
+        //since we're matching bit for bit iterating from the start
26
+        for ($j = 0, $jl = strlen($IP); $j < $jl; ++$j) {
27
+            //completed iteration and no inequality
28
+            if ($j == $jl - 1 && $IP[$j] === $AllowedProxies[$i][$j]) {
29
+                return true;
30
+            }
30
 
31
 
31
-      //wildcard
32
-      if ($AllowedProxies[$i][$j] === '*') {
33
-        return true;
34
-      }
32
+            //wildcard
33
+            if ($AllowedProxies[$i][$j] === '*') {
34
+                return true;
35
+            }
35
 
36
 
36
-      //inequality found
37
-      if ($IP[$j] !== $AllowedProxies[$i][$j]) {
38
-        break;
39
-      }
37
+            //inequality found
38
+            if ($IP[$j] !== $AllowedProxies[$i][$j]) {
39
+                break;
40
+            }
41
+        }
40
     }
42
     }
41
-  }
42
-  return false;
43
+    return false;
43
 }
44
 }

+ 2
- 2
classes/regex.php View File

1
-<?
1
+<?php
2
 //resource_type://username:password@domain:port/path?query_string#anchor
2
 //resource_type://username:password@domain:port/path?query_string#anchor
3
 define('RESOURCE_REGEX', '(https?|ftps?):\/\/');
3
 define('RESOURCE_REGEX', '(https?|ftps?):\/\/');
4
 define('IP_REGEX', '(\d{1,3}\.){3}\d{1,3}');
4
 define('IP_REGEX', '(\d{1,3}\.){3}\d{1,3}');
6
 define('PORT_REGEX', ':\d{1,5}');
6
 define('PORT_REGEX', ':\d{1,5}');
7
 define('URL_REGEX', '('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')('.PORT_REGEX.')?(\/\S*)*');
7
 define('URL_REGEX', '('.RESOURCE_REGEX.')('.IP_REGEX.'|'.DOMAIN_REGEX.')('.PORT_REGEX.')?(\/\S*)*');
8
 define('USERNAME_REGEX', '/^[a-z0-9_]{2,20}$/iD');
8
 define('USERNAME_REGEX', '/^[a-z0-9_]{2,20}$/iD');
9
-define('EMAIL_REGEX','[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX);
9
+define('EMAIL_REGEX', '[_a-z0-9-]+([.+][_a-z0-9-]+)*@'.DOMAIN_REGEX);
10
 define('IMAGE_REGEX', URL_REGEX.'\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?');
10
 define('IMAGE_REGEX', URL_REGEX.'\/\S+\.(jpg|jpeg|tif|tiff|png|gif|bmp)(\?\S*)?');
11
 define('VIDEO_REGEX', URL_REGEX.'\/\S+\.(webm)(\?\S*)?');
11
 define('VIDEO_REGEX', URL_REGEX.'\/\S+\.(webm)(\?\S*)?');
12
 define('CSS_REGEX', URL_REGEX.'\/\S+\.css(\?\S*)?');
12
 define('CSS_REGEX', URL_REGEX.'\/\S+\.css(\?\S*)?');

+ 26
- 24
classes/reports.class.php View File

1
 <?php
1
 <?php
2
-class Reports {
3
-  /**
4
-   * This function formats a string containing a torrent's remaster information
5
-   * to be used in Reports v2.
6
-   *
7
-   * @param boolean  $Remastered - whether the torrent contains remaster information
8
-   * @param string   $RemasterTitle - the title of the remaster information
9
-   * @param string   $RemasterYear - the year of the remaster information
10
-   */
11
-  public static function format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear) {
12
-    if ($Remastered) {
13
-      $RemasterDisplayString = ' &lt;';
14
-      if ($RemasterTitle != '' && $RemasterYear != '') {
15
-        $RemasterDisplayString .= "$RemasterTitle - $RemasterYear";
16
-      } elseif ($RemasterTitle != '' && $RemasterYear == '') {
17
-        $RemasterDisplayString .= $RemasterTitle;
18
-      } elseif ($RemasterTitle == '' && $RemasterYear != '') {
19
-        $RemasterDisplayString .= $RemasterYear;
20
-      }
21
-      $RemasterDisplayString .= '&gt;';
22
-    } else {
23
-      $RemasterDisplayString = '';
2
+class Reports
3
+{
4
+    /**
5
+     * This function formats a string containing a torrent's remaster information
6
+     * to be used in Reports v2.
7
+     *
8
+     * @param boolean  $Remastered - whether the torrent contains remaster information
9
+     * @param string   $RemasterTitle - the title of the remaster information
10
+     * @param string   $RemasterYear - the year of the remaster information
11
+     */
12
+    public static function format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear)
13
+    {
14
+        if ($Remastered) {
15
+            $RemasterDisplayString = ' &lt;';
16
+            if ($RemasterTitle != '' && $RemasterYear != '') {
17
+                $RemasterDisplayString .= "$RemasterTitle - $RemasterYear";
18
+            } elseif ($RemasterTitle != '' && $RemasterYear == '') {
19
+                $RemasterDisplayString .= $RemasterTitle;
20
+            } elseif ($RemasterTitle == '' && $RemasterYear != '') {
21
+                $RemasterDisplayString .= $RemasterYear;
22
+            }
23
+            $RemasterDisplayString .= '&gt;';
24
+        } else {
25
+            $RemasterDisplayString = '';
26
+        }
27
+        return $RemasterDisplayString;
24
     }
28
     }
25
-    return $RemasterDisplayString;
26
-  }
27
 }
29
 }

+ 165
- 157
classes/requests.class.php View File

1
-<?
2
-class Requests {
3
-  /**
4
-   * Update the sphinx requests delta table for a request.
5
-   *
6
-   * @param $RequestID
7
-   */
8
-  public static function update_sphinx_requests($RequestID) {
9
-    $QueryID = G::$DB->get_query_id();
10
-
11
-    G::$DB->query("
1
+<?php
2
+class Requests
3
+{
4
+    /**
5
+     * Update the sphinx requests delta table for a request.
6
+     *
7
+     * @param $RequestID
8
+     */
9
+    public static function update_sphinx_requests($RequestID)
10
+    {
11
+        $QueryID = G::$DB->get_query_id();
12
+
13
+        G::$DB->query("
12
       SELECT REPLACE(t.Name, '.', '_')
14
       SELECT REPLACE(t.Name, '.', '_')
13
       FROM tags AS t
15
       FROM tags AS t
14
         JOIN requests_tags AS rt ON t.ID = rt.TagID
16
         JOIN requests_tags AS rt ON t.ID = rt.TagID
15
       WHERE rt.RequestID = $RequestID");
17
       WHERE rt.RequestID = $RequestID");
16
-    $TagList = G::$DB->collect(0, false);
17
-    $TagList = db_string(implode(' ', $TagList));
18
+        $TagList = G::$DB->collect(0, false);
19
+        $TagList = db_string(implode(' ', $TagList));
18
 
20
 
19
-    G::$DB->query("
21
+        G::$DB->query("
20
       REPLACE INTO sphinx_requests_delta (
22
       REPLACE INTO sphinx_requests_delta (
21
         ID, UserID, TimeAdded, LastVote, CategoryID, Title, TagList,
23
         ID, UserID, TimeAdded, LastVote, CategoryID, Title, TagList,
22
         CatalogueNumber, DLSiteID, FillerID, TorrentID,
24
         CatalogueNumber, DLSiteID, FillerID, TorrentID,
31
         LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
33
         LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
32
       WHERE ID = $RequestID
34
       WHERE ID = $RequestID
33
       GROUP BY r.ID");
35
       GROUP BY r.ID");
34
-    G::$DB->query("
36
+        G::$DB->query("
35
       UPDATE sphinx_requests_delta
37
       UPDATE sphinx_requests_delta
36
       SET ArtistList = (
38
       SET ArtistList = (
37
           SELECT GROUP_CONCAT(ag.Name SEPARATOR ' ')
39
           SELECT GROUP_CONCAT(ag.Name SEPARATOR ' ')
41
           GROUP BY NULL
43
           GROUP BY NULL
42
           )
44
           )
43
       WHERE ID = $RequestID");
45
       WHERE ID = $RequestID");
44
-    G::$DB->set_query_id($QueryID);
45
-
46
-    G::$Cache->delete_value("request_$RequestID");
47
-  }
48
-
49
-
50
-
51
-  /**
52
-   * Function to get data from an array of $RequestIDs. Order of keys doesn't matter (let's keep it that way).
53
-   *
54
-   * @param array $RequestIDs
55
-   * @param boolean $Return if set to false, data won't be returned (ie. if we just want to prime the cache.)
56
-   * @return The array of requests.
57
-   * Format: array(RequestID => Associative array)
58
-   * To see what's exactly inside each associate array, peek inside the function. It won't bite.
59
-   */
60
-  //
61
-  //In places where the output from this is merged with sphinx filters, it will be in a different order.
62
-  public static function get_requests($RequestIDs, $Return = true) {
63
-    $Found = $NotFound = array_fill_keys($RequestIDs, false);
64
-    // Try to fetch the requests from the cache first.
65
-    foreach ($RequestIDs as $i => $RequestID) {
66
-      if (!is_number($RequestID)) {
67
-        unset($RequestIDs[$i], $Found[$GroupID], $NotFound[$GroupID]);
68
-        continue;
69
-      }
70
-      $Data = G::$Cache->get_value("request_$RequestID");
71
-      if (!empty($Data)) {
72
-        unset($NotFound[$RequestID]);
73
-        $Found[$RequestID] = $Data;
74
-      }
75
-    }
76
-    // Make sure there's something in $RequestIDs, otherwise the SQL will break
77
-    if (count($RequestIDs) === 0) {
78
-      return [];
46
+        G::$DB->set_query_id($QueryID);
47
+
48
+        G::$Cache->delete_value("request_$RequestID");
79
     }
49
     }
80
-    $IDs = implode(',', array_keys($NotFound));
81
 
50
 
82
-    /*
83
-      Don't change without ensuring you change everything else that uses get_requests()
84
-    */
85
 
51
 
86
-    if (count($NotFound) > 0) {
87
-      $QueryID = G::$DB->get_query_id();
88
 
52
 
89
-      G::$DB->query("
53
+    /**
54
+     * Function to get data from an array of $RequestIDs. Order of keys doesn't matter (let's keep it that way).
55
+     *
56
+     * @param array $RequestIDs
57
+     * @param boolean $Return if set to false, data won't be returned (ie. if we just want to prime the cache.)
58
+     * @return The array of requests.
59
+     * Format: array(RequestID => Associative array)
60
+     * To see what's exactly inside each associate array, peek inside the function. It won't bite.
61
+     */
62
+    //
63
+    //In places where the output from this is merged with sphinx filters, it will be in a different order.
64
+    public static function get_requests($RequestIDs, $Return = true)
65
+    {
66
+        $Found = $NotFound = array_fill_keys($RequestIDs, false);
67
+        // Try to fetch the requests from the cache first.
68
+        foreach ($RequestIDs as $i => $RequestID) {
69
+            if (!is_number($RequestID)) {
70
+                unset($RequestIDs[$i], $Found[$GroupID], $NotFound[$GroupID]);
71
+                continue;
72
+            }
73
+            $Data = G::$Cache->get_value("request_$RequestID");
74
+            if (!empty($Data)) {
75
+                unset($NotFound[$RequestID]);
76
+                $Found[$RequestID] = $Data;
77
+            }
78
+        }
79
+        // Make sure there's something in $RequestIDs, otherwise the SQL will break
80
+        if (count($RequestIDs) === 0) {
81
+            return [];
82
+        }
83
+        $IDs = implode(',', array_keys($NotFound));
84
+
85
+        /*
86
+        Don't change without ensuring you change everything else that uses get_requests()
87
+        */
88
+
89
+        if (count($NotFound) > 0) {
90
+            $QueryID = G::$DB->get_query_id();
91
+
92
+            G::$DB->query("
90
         SELECT
93
         SELECT
91
           ID,
94
           ID,
92
           UserID,
95
           UserID,
107
         FROM requests
110
         FROM requests
108
         WHERE ID IN ($IDs)
111
         WHERE ID IN ($IDs)
109
         ORDER BY ID");
112
         ORDER BY ID");
110
-      $Requests = G::$DB->to_array(false, MYSQLI_ASSOC, true);
111
-      $Tags = self::get_tags(G::$DB->collect('ID', false));
112
-      foreach ($Requests as $Request) {
113
-        $Request['AnonymousFill'] = false;
114
-        if ($Request['FillerID']) {
115
-          G::$DB->query("
113
+            $Requests = G::$DB->to_array(false, MYSQLI_ASSOC, true);
114
+            $Tags = self::get_tags(G::$DB->collect('ID', false));
115
+            foreach ($Requests as $Request) {
116
+                $Request['AnonymousFill'] = false;
117
+                if ($Request['FillerID']) {
118
+                    G::$DB->query("
116
             SELECT Anonymous
119
             SELECT Anonymous
117
             FROM torrents
120
             FROM torrents
118
             WHERE ID = ".$Request['TorrentID']);
121
             WHERE ID = ".$Request['TorrentID']);
119
-          list($Anonymous) = G::$DB->next_record();
120
-          if ($Anonymous) $Request['AnonymousFill'] = true;
122
+                    list($Anonymous) = G::$DB->next_record();
123
+                    if ($Anonymous) {
124
+                        $Request['AnonymousFill'] = true;
125
+                    }
126
+                }
127
+                unset($NotFound[$Request['ID']]);
128
+                $Request['Tags'] = isset($Tags[$Request['ID']]) ? $Tags[$Request['ID']] : [];
129
+                $Found[$Request['ID']] = $Request;
130
+                G::$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
131
+            }
132
+            G::$DB->set_query_id($QueryID);
133
+
134
+            // Orphan requests. There shouldn't ever be any
135
+            if (count($NotFound) > 0) {
136
+                foreach (array_keys($NotFound) as $GroupID) {
137
+                    unset($Found[$GroupID]);
138
+                }
139
+            }
121
         }
140
         }
122
-        unset($NotFound[$Request['ID']]);
123
-        $Request['Tags'] = isset($Tags[$Request['ID']]) ? $Tags[$Request['ID']] : [];
124
-        $Found[$Request['ID']] = $Request;
125
-        G::$Cache->cache_value('request_'.$Request['ID'], $Request, 0);
126
-      }
127
-      G::$DB->set_query_id($QueryID);
128
-
129
-      // Orphan requests. There shouldn't ever be any
130
-      if (count($NotFound) > 0) {
131
-        foreach (array_keys($NotFound) as $GroupID) {
132
-          unset($Found[$GroupID]);
141
+
142
+        if ($Return) { // If we're interested in the data, and not just caching it
143
+            return $Found;
133
         }
144
         }
134
-      }
135
     }
145
     }
136
 
146
 
137
-    if ($Return) { // If we're interested in the data, and not just caching it
138
-      return $Found;
139
-    }
140
-  }
141
-
142
-  /**
143
-   * Return a single request. Wrapper for get_requests
144
-   *
145
-   * @param int $RequestID
146
-   * @return request array or false if request doesn't exist. See get_requests for a description of the format
147
-   */
148
-  public static function get_request($RequestID) {
149
-    $Request = self::get_requests(array($RequestID));
150
-    if (isset($Request[$RequestID])) {
151
-      return $Request[$RequestID];
147
+    /**
148
+     * Return a single request. Wrapper for get_requests
149
+     *
150
+     * @param int $RequestID
151
+     * @return request array or false if request doesn't exist. See get_requests for a description of the format
152
+     */
153
+    public static function get_request($RequestID)
154
+    {
155
+        $Request = self::get_requests(array($RequestID));
156
+        if (isset($Request[$RequestID])) {
157
+            return $Request[$RequestID];
158
+        }
159
+        return false;
152
     }
160
     }
153
-    return false;
154
-  }
155
-
156
-  public static function get_artists($RequestID) {
157
-    $Artists = G::$Cache->get_value("request_artists_$RequestID");
158
-    if (is_array($Artists)) {
159
-      $Results = $Artists;
160
-    } else {
161
-      $Results = [];
162
-      $QueryID = G::$DB->get_query_id();
163
-      G::$DB->query("
161
+
162
+    public static function get_artists($RequestID)
163
+    {
164
+        $Artists = G::$Cache->get_value("request_artists_$RequestID");
165
+        if (is_array($Artists)) {
166
+            $Results = $Artists;
167
+        } else {
168
+            $Results = [];
169
+            $QueryID = G::$DB->get_query_id();
170
+            G::$DB->query("
164
         SELECT
171
         SELECT
165
           ra.ArtistID,
172
           ra.ArtistID,
166
           ag.Name
173
           ag.Name
168
           JOIN artists_group AS ag ON ra.ArtistID = ag.ArtistID
175
           JOIN artists_group AS ag ON ra.ArtistID = ag.ArtistID
169
         WHERE ra.RequestID = $RequestID
176
         WHERE ra.RequestID = $RequestID
170
         ORDER BY ag.Name ASC;");
177
         ORDER BY ag.Name ASC;");
171
-      $ArtistRaw = G::$DB->to_array();
172
-      G::$DB->set_query_id($QueryID);
173
-      foreach ($ArtistRaw as $ArtistRow) {
174
-        list($ArtistID, $ArtistName) = $ArtistRow;
175
-        $Results[] = array('id' => $ArtistID, 'name' => $ArtistName);
176
-      }
177
-      G::$Cache->cache_value("request_artists_$RequestID", $Results);
178
+            $ArtistRaw = G::$DB->to_array();
179
+            G::$DB->set_query_id($QueryID);
180
+            foreach ($ArtistRaw as $ArtistRow) {
181
+                list($ArtistID, $ArtistName) = $ArtistRow;
182
+                $Results[] = array('id' => $ArtistID, 'name' => $ArtistName);
183
+            }
184
+            G::$Cache->cache_value("request_artists_$RequestID", $Results);
185
+        }
186
+        return $Results;
178
     }
187
     }
179
-    return $Results;
180
-  }
181
 
188
 
182
-  public static function get_tags($RequestIDs) {
183
-    if (empty($RequestIDs)) {
184
-      return [];
185
-    }
186
-    if (is_array($RequestIDs)) {
187
-      $RequestIDs = implode(',', $RequestIDs);
188
-    }
189
-    $QueryID = G::$DB->get_query_id();
190
-    G::$DB->query("
189
+    public static function get_tags($RequestIDs)
190
+    {
191
+        if (empty($RequestIDs)) {
192
+            return [];
193
+        }
194
+        if (is_array($RequestIDs)) {
195
+            $RequestIDs = implode(',', $RequestIDs);
196
+        }
197
+        $QueryID = G::$DB->get_query_id();
198
+        G::$DB->query("
191
       SELECT
199
       SELECT
192
         rt.RequestID,
200
         rt.RequestID,
193
         rt.TagID,
201
         rt.TagID,
196
         JOIN tags AS t ON rt.TagID = t.ID
204
         JOIN tags AS t ON rt.TagID = t.ID
197
       WHERE rt.RequestID IN ($RequestIDs)
205
       WHERE rt.RequestID IN ($RequestIDs)
198
       ORDER BY rt.TagID ASC");
206
       ORDER BY rt.TagID ASC");
199
-    $Tags = G::$DB->to_array(false, MYSQLI_NUM, false);
200
-    G::$DB->set_query_id($QueryID);
201
-    $Results = [];
202
-    foreach ($Tags as $TagsRow) {
203
-      list($RequestID, $TagID, $TagName) = $TagsRow;
204
-      $Results[$RequestID][$TagID] = $TagName;
207
+        $Tags = G::$DB->to_array(false, MYSQLI_NUM, false);
208
+        G::$DB->set_query_id($QueryID);
209
+        $Results = [];
210
+        foreach ($Tags as $TagsRow) {
211
+            list($RequestID, $TagID, $TagName) = $TagsRow;
212
+            $Results[$RequestID][$TagID] = $TagName;
213
+        }
214
+        return $Results;
205
     }
215
     }
206
-    return $Results;
207
-  }
208
-
209
-  public static function get_votes_array($RequestID) {
210
-    $RequestVotes = G::$Cache->get_value("request_votes_$RequestID");
211
-    if (!is_array($RequestVotes)) {
212
-      $QueryID = G::$DB->get_query_id();
213
-      G::$DB->query("
216
+
217
+    public static function get_votes_array($RequestID)
218
+    {
219
+        $RequestVotes = G::$Cache->get_value("request_votes_$RequestID");
220
+        if (!is_array($RequestVotes)) {
221
+            $QueryID = G::$DB->get_query_id();
222
+            G::$DB->query("
214
         SELECT
223
         SELECT
215
           rv.UserID,
224
           rv.UserID,
216
           rv.Bounty,
225
           rv.Bounty,
219
           LEFT JOIN users_main AS u ON u.ID = rv.UserID
228
           LEFT JOIN users_main AS u ON u.ID = rv.UserID
220
         WHERE rv.RequestID = $RequestID
229
         WHERE rv.RequestID = $RequestID
221
         ORDER BY rv.Bounty DESC");
230
         ORDER BY rv.Bounty DESC");
222
-      if (!G::$DB->has_results()) {
223
-        return array(
224
-          'TotalBounty' => 0,
225
-          'Voters' => []);
226
-      }
227
-      $Votes = G::$DB->to_array();
228
-
229
-      $RequestVotes = [];
230
-      $RequestVotes['TotalBounty'] = array_sum(G::$DB->collect('Bounty'));
231
-
232
-      foreach ($Votes as $Vote) {
233
-        list($UserID, $Bounty, $Username) = $Vote;
234
-        $VoteArray = [];
235
-        $VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
236
-      }
237
-
238
-      $RequestVotes['Voters'] = $VotesArray;
239
-      G::$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
240
-      G::$DB->set_query_id($QueryID);
231
+            if (!G::$DB->has_results()) {
232
+                return array(
233
+                    'TotalBounty' => 0,
234
+                    'Voters' => []);
235
+            }
236
+            $Votes = G::$DB->to_array();
237
+
238
+            $RequestVotes = [];
239
+            $RequestVotes['TotalBounty'] = array_sum(G::$DB->collect('Bounty'));
240
+
241
+            foreach ($Votes as $Vote) {
242
+                list($UserID, $Bounty, $Username) = $Vote;
243
+                $VoteArray = [];
244
+                $VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty);
245
+            }
246
+
247
+            $RequestVotes['Voters'] = $VotesArray;
248
+            G::$Cache->cache_value("request_votes_$RequestID", $RequestVotes);
249
+            G::$DB->set_query_id($QueryID);
250
+        }
251
+        return $RequestVotes;
241
     }
252
     }
242
-    return $RequestVotes;
243
-  }
244
-
245
 }
253
 }

Loading…
Cancel
Save