Browse Source

code cleanup

spaghetti 9 years ago
parent
commit
e30e450151

+ 2
- 6
README.md View File

1
 This is Oppaitime's version of Gazelle
1
 This is Oppaitime's version of Gazelle
2
 
2
 
3
-Below is a list of differences between this version of Gazelle and What.cd's. Please note that these lists are far from complete.
3
+Below are some lists of differences between this version of Gazelle and What.cd's. Please note that these lists are far from complete.
4
 
4
 
5
 ## Major Changes
5
 ## Major Changes
6
 
6
 
36
 * When a torrent is trumped, the new torrent is made freeleech to users who snatched the old torrent for a few days.
36
 * When a torrent is trumped, the new torrent is made freeleech to users who snatched the old torrent for a few days.
37
 * Sends headers to tell cloudflare to use HTTP/2 Server Push for most resources.
37
 * Sends headers to tell cloudflare to use HTTP/2 Server Push for most resources.
38
 * An attempt has been made to support magnet links. This has shown partial success.
38
 * An attempt has been made to support magnet links. This has shown partial success.
39
-* This codebase is expected to run over https only.
40
-
41
-## Bug Fixes
42
-
43
-* Count of torrent results is accurate from first page for much larger databases, but could still be improved to scale automatically.
39
+* This codebase expects to run over https only.

+ 0
- 1
captcha.php View File

1
-<? require("classes/script_start.php");

+ 115
- 184
classes/config.template View File

1
 <?php
1
 <?php
2
-if (PHP_VERSION_ID < 70000) {
3
-	die("Gazelle requires PHP 7.0 or later to function properly");
2
+if (version_compare(PHP_VERSION, '7.0.0', '<')) {
3
+  die("Gazelle requires PHP 7.0 or later to function properly");
4
 }
4
 }
5
 //date_default_timezone_set('EST');
5
 //date_default_timezone_set('EST');
6
 
6
 
7
 // Main settings
7
 // Main settings
8
-define('SITE_NAME', 'Oppaitime'); //The name of your site
8
+define('SITE_NAME',   'Oppaitime'); //The name of your site
9
 define('SITE_DOMAIN', 'oppaiti.me'); //The FQDN of your site
9
 define('SITE_DOMAIN', 'oppaiti.me'); //The FQDN of your site
10
-define('SITE_IP', '8.8.8.8'); //The IP address by which your site can be publicly accessed
11
 define('SERVER_ROOT', '/var/www'); //The root of the server, used for includes, purpose is to shorten the path string
10
 define('SERVER_ROOT', '/var/www'); //The root of the server, used for includes, purpose is to shorten the path string
12
 
11
 
13
 // Tracker urls to be added to torrent files ala bittorrent.org/beps/bep_0012.html
12
 // Tracker urls to be added to torrent files ala bittorrent.org/beps/bep_0012.html
14
-define('ANNOUNCE_URLS', [['https://tracker.'.SSL_SITE_URL.':34001',
15
-                   'https://tracker2.'.SSL_SITE_URL.':34001',
16
-                   'https://tracker3.'.SSL_SITE_URL.':34001',
17
-                   'https://tracker4.'.SSL_SITE_URL.':34001']] );
13
+define('ANNOUNCE_URLS', [[
14
+  'https://tracker.'.SITE_DOMAIN.':34001',
15
+  'https://tracker2.'.SITE_DOMAIN.':34001',
16
+  'https://tracker3.'.SITE_DOMAIN.':34001',
17
+  'https://tracker4.'.SITE_DOMAIN.':34001'
18
+]]);
18
 
19
 
19
 // Don't hard code API keys for services
20
 // Don't hard code API keys for services
20
 define('API_KEYS', ['ANIDB' => 'AAAAAAAAAAAAAAAA']);
21
 define('API_KEYS', ['ANIDB' => 'AAAAAAAAAAAAAAAA']);
23
 define('STATIC_SERVER', 'static/');
24
 define('STATIC_SERVER', 'static/');
24
 
25
 
25
 // Keys
26
 // Keys
26
-define('ENCKEY', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); //Random key. The key for encryption
27
+define('ENCKEY',       'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); //Random key. The key for encryption
27
 define('SCHEDULE_KEY', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Random key. This key must be the argument to schedule.php for the schedule to work.
28
 define('SCHEDULE_KEY', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Random key. This key must be the argument to schedule.php for the schedule to work.
28
-define('RSS_HASH', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); //Random key. Used for generating unique RSS auth key.
29
+define('RSS_HASH',     'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); //Random key. Used for generating unique RSS auth key.
29
 
30
 
30
 // MySQL details
31
 // MySQL details
31
-define('SQLHOST', 'localhost'); //The MySQL host ip/fqdn
32
+define('SQLHOST',  'localhost'); //The MySQL host ip/fqdn
32
 define('SQLLOGIN', 'root');//The MySQL login
33
 define('SQLLOGIN', 'root');//The MySQL login
33
-define('SQLPASS', 'toor'); //The MySQL password
34
-define('SQLDB', 'gazelle'); //The MySQL database to use
35
-define('SQLPORT', 3306); //The MySQL port to connect on
36
-define('SQLSOCK', '/var/run/mysqld/mysqld.sock');
34
+define('SQLPASS',  'toor'); //The MySQL password
35
+define('SQLDB',    'gazelle'); //The MySQL database to use
36
+define('SQLPORT',  3306); //The MySQL port to connect on
37
+define('SQLSOCK',  '/var/run/mysqld/mysqld.sock');
37
 
38
 
38
 // Memcached details
39
 // Memcached details
39
 define('MEMCACHED_SERVERS',
40
 define('MEMCACHED_SERVERS',
40
-	[['host' => 'unix:///var/run/memcached.sock', 'port' => 0, 'buckets' => 1]]
41
+  [['host' => 'unix:///var/run/memcached.sock', 'port' => 0, 'buckets' => 1]]
41
 );
42
 );
42
 
43
 
43
 // Sphinx details
44
 // Sphinx details
44
-define('SPHINX_HOST', 'localhost');
45
-define('SPHINX_PORT', 9312);
46
-define('SPHINXQL_HOST', '127.0.0.1');
47
-define('SPHINXQL_PORT', 9306);
48
-define('SPHINXQL_SOCK', false);
45
+define('SPHINX_HOST',        'localhost');
46
+define('SPHINX_PORT',        9312);
47
+define('SPHINXQL_HOST',      '127.0.0.1');
48
+define('SPHINXQL_PORT',      9306);
49
+define('SPHINXQL_SOCK',      false);
49
 define('SPHINX_MAX_MATCHES', 1000); // Must be <= the server's max_matches variable (default 1000)
50
 define('SPHINX_MAX_MATCHES', 1000); // Must be <= the server's max_matches variable (default 1000)
50
-define('SPHINX_INDEX', 'torrents');
51
+define('SPHINX_INDEX',       'torrents');
51
 
52
 
52
 // Ocelot details
53
 // Ocelot details
53
-define('TRACKER_HOST', '8.8.8.8');
54
-define('TRACKER_PORT', 34000);
55
-define('TRACKER_SECRET', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Must be 32 characters and match site_password in Ocelot's config.cpp
54
+define('TRACKER_HOST',      '8.8.8.8');
55
+define('TRACKER_PORT',      34000);
56
+define('TRACKER_SECRET',    'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Must be 32 characters and match site_password in Ocelot's config.cpp
56
 define('TRACKER_REPORTKEY', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Must be 32 characters and match report_password in Ocelot's config.cpp
57
 define('TRACKER_REPORTKEY', 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); // Must be 32 characters and match report_password in Ocelot's config.cpp
57
 
58
 
58
 // Site settings
59
 // Site settings
59
-define('DEBUG_MODE', false); //Set to false if you dont want everyone to see debug information, can be overriden with 'site_debug'
60
-define('DEBUG_WARNINGS', true); //Set to true if you want to see PHP warnings in the footer
60
+define('DEBUG_MODE',        false); //Set to false if you dont want everyone to see debug information, can be overriden with 'site_debug'
61
+define('DEBUG_WARNINGS',    true); //Set to true if you want to see PHP warnings in the footer
61
 define('OPEN_REGISTRATION', false); //Set to false to disable open regirstration, true to allow anyone to register
62
 define('OPEN_REGISTRATION', false); //Set to false to disable open regirstration, true to allow anyone to register
62
-define('USER_LIMIT', 0); //The maximum number of users the site can have, 0 for no limit
63
-define('STARTING_INVITES', 0); //# of invites to give to newly registered users
64
-define('BLOCK_TOR', false); //Set to true to block Tor users
65
-define('BLOCK_OPERA_MINI', false); //Set to true to block Opera Mini proxy
66
-define('DONOR_INVITES', 2);
67
-if (!defined('FEATURE_EMAIL_REENABLE')) {
68
-  define('FEATURE_EMAIL_REENABLE', true);
69
-}
63
+define('USER_LIMIT',        0); //The maximum number of users the site can have, 0 for no limit
64
+define('STARTING_INVITES',  0); //# of invites to give to newly registered users
65
+define('BLOCK_TOR',         false); //Set to true to block Tor users
66
+define('BLOCK_OPERA_MINI',  false); //Set to true to block Opera Mini proxy
67
+define('DONOR_INVITES',     2);
68
+
69
+// Features
70
+define('FEATURE_EMAIL_REENABLE', true);
70
 
71
 
71
 // User class IDs needed for automatic promotions. Found in the 'permissions' table
72
 // User class IDs needed for automatic promotions. Found in the 'permissions' table
72
-// Name of class	Class ID (NOT level)
73
-define('ADMIN',		'1');
74
-define('USER',		'2');
75
-define('MEMBER',	'3');
76
-define('POWER',		'4');
77
-define('ELITE',		'5');
78
-define('VIP',		'21');
79
-define('TORRENT_MASTER','23');
80
-define('LEGEND',	'8');
81
-define('MOD',		'11');
82
-define('SYSOP',		'15');
83
-define('ARTIST',	'19');
84
-define('DONOR',		'20');
85
-define('POWER_TM',	'24');
86
-define('FLS_TEAM', '9000');
87
-define('FORUM_MOD', '9001');
73
+// Name of class  Class ID (NOT level)
74
+define('ADMIN',          '1');
75
+define('USER',           '2');
76
+define('MEMBER',         '3');
77
+define('POWER',          '4');
78
+define('ELITE',          '5');
79
+define('LEGEND',         '8');
80
+define('MOD',            '11');
81
+define('SYSOP',          '15');
82
+define('ARTIST',         '19');
83
+define('DONOR',          '20');
84
+define('VIP',            '21');
85
+define('TORRENT_MASTER', '23');
86
+define('POWER_TM',       '24');
87
+define('FLS_TEAM',       '9000');
88
+define('FORUM_MOD',      '9001');
88
 
89
 
89
 // Forums
90
 // Forums
90
-define('STAFF_FORUM', 7);
91
-define('DONOR_FORUM', 9);
92
-define('TRASH_FORUM_ID', 4);
91
+define('STAFF_FORUM',           7);
92
+define('DONOR_FORUM',           9);
93
+define('TRASH_FORUM_ID',        4);
93
 define('ANNOUNCEMENT_FORUM_ID', 10);
94
 define('ANNOUNCEMENT_FORUM_ID', 10);
94
 
95
 
95
 // Pagination
96
 // Pagination
96
 define('TORRENT_COMMENTS_PER_PAGE', 10);
97
 define('TORRENT_COMMENTS_PER_PAGE', 10);
97
-define('POSTS_PER_PAGE', 25);
98
-define('TOPICS_PER_PAGE', 50);
99
-define('TORRENTS_PER_PAGE', 50);
100
-define('REQUESTS_PER_PAGE', 25);
101
-define('MESSAGES_PER_PAGE', 25);
102
-define('LOG_ENTRIES_PER_PAGE', 50);
98
+define('POSTS_PER_PAGE',            25);
99
+define('TOPICS_PER_PAGE',           50);
100
+define('TORRENTS_PER_PAGE',         50);
101
+define('REQUESTS_PER_PAGE',         25);
102
+define('MESSAGES_PER_PAGE',         25);
103
+define('LOG_ENTRIES_PER_PAGE',      50);
103
 
104
 
104
 // Cache catalogues
105
 // Cache catalogues
105
 define('THREAD_CATALOGUE', 500); // Limit to THREAD_CATALOGUE posts per cache key.
106
 define('THREAD_CATALOGUE', 500); // Limit to THREAD_CATALOGUE posts per cache key.
106
 
107
 
107
 // IRC settings
108
 // IRC settings
108
-define('BOT_NICK', 'bot');
109
-define('BOT_SERVER', 'irc.'.SSL_SITE_URL); // IRC server address. Used for onsite chat tool.
110
-define('BOT_PORT', 6667);
111
-define('BOT_CHAN', '#bot');
112
-define('BOT_ANNOUNCE_CHAN', '#announce');
113
-define('BOT_REQUEST_CHAN', '#requests');
114
-define('BOT_STAFF_CHAN', '#staff');
115
-define('BOT_DISABLED_CHAN', '#disabled'); // Channel to refer disabled users to.
116
-define('BOT_HELP_CHAN', '#help');
117
-define('BOT_DEBUG_CHAN', '#debup');
118
-define('BOT_REPORT_CHAN', '#report');
119
-define('BOT_NICKSERV_PASS', '');
120
-define('BOT_INVITE_CHAN', '#invites'); // Channel for non-members seeking an interview
121
-define('BOT_INTERVIEW_CHAN', '#interview'); // Channel for the interviews
122
-define('BOT_INTERVIEW_NUM', 5);
123
-define('BOT_INTERVIEW_STAFF', '#interview-staff'); // Channel for the interviewers
124
-define('SOCKET_LISTEN_PORT', 51010);
109
+define('BOT_NICK',              'bot');
110
+define('BOT_SERVER',            'irc.'.SITE_DOMAIN); // IRC server address. Used for onsite chat tool.
111
+define('BOT_PORT',              6667);
112
+define('BOT_CHAN',              '#bot');
113
+define('BOT_ANNOUNCE_CHAN',     '#announce');
114
+define('BOT_REQUEST_CHAN',      '#requests');
115
+define('BOT_STAFF_CHAN',        '#staff');
116
+define('BOT_DISABLED_CHAN',     '#disabled'); // Channel to refer disabled users to.
117
+define('BOT_HELP_CHAN',         '#help');
118
+define('BOT_DEBUG_CHAN',        '#debug');
119
+define('BOT_REPORT_CHAN',       '#report');
120
+define('BOT_NICKSERV_PASS',     '');
121
+define('BOT_INVITE_CHAN',       '#invites'); // Channel for non-members seeking an interview
122
+define('BOT_INTERVIEW_CHAN',    '#interview'); // Channel for the interviews
123
+define('BOT_INTERVIEW_NUM',     5);
124
+define('BOT_INTERVIEW_STAFF',   '#interview-staff'); // Channel for the interviewers
125
+define('SOCKET_LISTEN_PORT',    51010);
125
 define('SOCKET_LISTEN_ADDRESS', '8.8.8.8');
126
 define('SOCKET_LISTEN_ADDRESS', '8.8.8.8');
126
-define('ADMIN_CHAN', '#admin');
127
-define('LAB_CHAN', '#lab');
128
-define('STATUS_CHAN', '#status');
127
+define('ADMIN_CHAN',            '#admin');
128
+define('LAB_CHAN',              '#lab');
129
+define('STATUS_CHAN',           '#status');
129
 
130
 
130
 // Miscellaneous values
131
 // Miscellaneous values
131
-define('RANK_ONE_COST', 5);
132
-define('RANK_TWO_COST', 10);
133
-define('RANK_THREE_COST', 15);
134
-define('RANK_FOUR_COST', 20);
135
-define('RANK_FIVE_COST', 30);
136
-define('MAX_RANK', 6);
137
-define('MAX_EXTRA_RANK', 8);
132
+define('RANK_ONE_COST',    5);
133
+define('RANK_TWO_COST',    10);
134
+define('RANK_THREE_COST',  15);
135
+define('RANK_FOUR_COST',   20);
136
+define('RANK_FIVE_COST',   30);
137
+define('MAX_RANK',         6);
138
+define('MAX_EXTRA_RANK',   8);
138
 define('DONOR_FORUM_RANK', 6);
139
 define('DONOR_FORUM_RANK', 6);
139
 define('MAX_SPECIAL_RANK', 3);
140
 define('MAX_SPECIAL_RANK', 3);
140
 
141
 
141
-$ForumsRevealVoters = array();
142
-$ForumsDoublePost = array();
142
+define('FORUMS_TO_REVEAL_VOTERS,      []);
143
+define('FORUMS_TO_ALLOW_DOUBLE_POST', []);
143
 
144
 
144
 $Categories = array('Movies', 'Anime', 'Manga', 'Games', 'Other');
145
 $Categories = array('Movies', 'Anime', 'Manga', 'Games', 'Other');
145
 $GroupedCategories = $Categories;
146
 $GroupedCategories = $Categories;
164
 $CollageCats = array(0=>'Personal', 1=>'Theme', 2=>'Staff picks', 3=>'Artists');
165
 $CollageCats = array(0=>'Personal', 1=>'Theme', 2=>'Staff picks', 3=>'Artists');
165
 
166
 
166
 $ReleaseTypes = array(1=>'Album', 3=>'Soundtrack', 5=>'EP', 6=>'Anthology', 7=>'Compilation', 9=>'Single', 11=>'Live album', 13=>'Remix', 14=>'Bootleg', 15=>'Interview', 16=>'Mixtape', 21=>'Unknown');
167
 $ReleaseTypes = array(1=>'Album', 3=>'Soundtrack', 5=>'EP', 6=>'Anthology', 7=>'Compilation', 9=>'Single', 11=>'Live album', 13=>'Remix', 14=>'Bootleg', 15=>'Interview', 16=>'Mixtape', 21=>'Unknown');
167
-//$ForumCats = array(1=>'Site', 5=>'Community', 10=>'Help', 8=>'Music', 20=>'Trash'); //No longer needed
168
-
169
-$ZIPGroups = array(
170
-	0 => 'MP3 (VBR) - High Quality',
171
-	1 => 'MP3 (VBR) - Low Quality',
172
-	2 => 'MP3 (CBR)',
173
-	3 => 'FLAC - Lossless',
174
-	4 => 'Others'
175
-);
176
-
177
-//3D array of attributes, OptionGroup, OptionNumber, Name
178
-$ZIPOptions = array(
179
-	'00' => array(0, 0, 'V0'),
180
-	'01' => array(0, 1, 'APX'),
181
-	'02' => array(0, 2, '256'),
182
-	'03' => array(0, 3, 'V1'),
183
-	'10' => array(1, 0, '224'),
184
-	'11' => array(1, 1, 'V2'),
185
-	'12' => array(1, 2, 'APS'),
186
-	'13' => array(1, 3, '192'),
187
-	'20' => array(2, 0, '320'),
188
-	'21' => array(2, 1, '256'),
189
-	'22' => array(2, 2, '224'),
190
-	'23' => array(2, 3, '192'),
191
-	'30' => array(3, 0, 'FLAC / 24bit / Vinyl'),
192
-	'31' => array(3, 1, 'FLAC / 24bit / DVD'),
193
-	'32' => array(3, 2, 'FLAC / 24bit / SACD'),
194
-	'33' => array(3, 3, 'FLAC / Log (100) / Cue'),
195
-	'34' => array(3, 4, 'FLAC / Log (100)'),
196
-	'35' => array(3, 5, 'FLAC / Log'),
197
-	'36' => array(3, 6, 'FLAC'),
198
-	'40' => array(4, 0, 'DTS'),
199
-	'41' => array(4, 1, 'Ogg Vorbis'),
200
-	'42' => array(4, 2, 'AAC - 320'),
201
-	'43' => array(4, 3, 'AAC - 256'),
202
-	'44' => array(4, 4, 'AAC - q5.5'),
203
-	'45' => array(4, 5, 'AAC - q5'),
204
-	'46' => array(4, 6, 'AAC - 192')
205
-);
206
 
168
 
207
 // Ratio requirements, in descending order
169
 // Ratio requirements, in descending order
208
-// Columns: Download amount, required ratio, grace period
209
-$RatioRequirements = array(
210
-	//array(0, 0, date('Y-m-d H:i:s'))
211
-	array(200 * 1024 * 1024 * 1024, 0.60, date('Y-m-d H:i:s')),
212
-	array(160 * 1024 * 1024 * 1024, 0.60, date('Y-m-d H:i:s')),
213
-	array(120 * 1024 * 1024 * 1024, 0.50, date('Y-m-d H:i:s')),
214
-	array(100 * 1024 * 1024 * 1024, 0.40, date('Y-m-d H:i:s')),
215
-	array(80  * 1024 * 1024 * 1024, 0.30, date('Y-m-d H:i:s')),
216
-	array(60  * 1024 * 1024 * 1024, 0.20, date('Y-m-d H:i:s')),
217
-	array(40  * 1024 * 1024 * 1024, 0.15, date('Y-m-d H:i:s')),
218
-	array(20  * 1024 * 1024 * 1024, 0.10, date('Y-m-d H:i:s')),
219
-	array(10  * 1024 * 1024 * 1024, 0.05, date('Y-m-d H:i:s', time() - (60 * 60 * 24 * 14)))
220
-);
221
-
222
-//Captcha fonts should be located in /classes/fonts
223
-$CaptchaFonts = array(
224
-		'ARIBLK.TTF',
225
-		'IMPACT.TTF',
226
-		'TREBUC.TTF',
227
-		'TREBUCBD.TTF',
228
-		'TREBUCBI.TTF',
229
-		'TREBUCIT.TTF',
230
-		'VERDANA.TTF',
231
-		'VERDANAB.TTF',
232
-		'VERDANAI.TTF',
233
-		'VERDANAZ.TTF');
234
-//Captcha images should be located in /captcha
235
-$CaptchaBGs = array(
236
-		'captcha1.png',
237
-		'captcha2.png',
238
-		'captcha3.png',
239
-		'captcha4.png',
240
-		'captcha5.png',
241
-		'captcha6.png',
242
-		'captcha7.png',
243
-		'captcha8.png',
244
-		'captcha9.png');
245
-
246
-// Special characters, and what they should be converted to
247
-// Used for torrent searching
248
-$SpecialChars = array(
249
-		'&' => 'and'
250
-);
170
+// Columns: Download amount, Req Ratio (0% seeded), Req Ratio (100% seeded)
171
+define('RATIO_REQUIREMENTS', [
172
+  [200 * 1024**3, 0.60, 0.60],
173
+  [160 * 1024**3, 0.60, 0.50],
174
+  [120 * 1024**3, 0.50, 0.40],
175
+  [100 * 1024**3, 0.40, 0.30],
176
+  [80  * 1024**3, 0.30, 0.20],
177
+  [60  * 1024**3, 0.20, 0.10],
178
+  [40  * 1024**3, 0.15, 0.00],
179
+  [20  * 1024**3, 0.10, 0.00],
180
+  [10  * 1024**3, 0.05, 0.00],
181
+]);
251
 
182
 
252
 // God I wish I didn't have to do this but I just don't care anymore.
183
 // God I wish I didn't have to do this but I just don't care anymore.
253
-$AutomatedBadgeIDs = array(
254
-	'DL' => array(
255
-		'8' => 10,
256
-		'16' => 11,
257
-		'32' => 12,
258
-		'64' => 13,
259
-		'128' => 14,
260
-		'256' => 15,
261
-		'512' => 16,
262
-		'1024' => 17,
263
-		'2048' => 18
264
-	)
265
-);
184
+define('AUTOMATED_BADGE_IDS', [
185
+  'DL' => [
186
+    '8' => 10,
187
+    '16' => 11,
188
+    '32' => 12,
189
+    '64' => 13,
190
+    '128' => 14,
191
+    '256' => 15,
192
+    '512' => 16,
193
+    '1024' => 17,
194
+    '2048' => 18
195
+  ]
196
+]);
266
 ?>
197
 ?>

BIN
classes/fonts/ARIBLK.TTF View File


BIN
classes/fonts/COMIC.TTF View File


BIN
classes/fonts/COMICBD.TTF View File


BIN
classes/fonts/GEORGIA.TTF View File


BIN
classes/fonts/GEORGIAB.TTF View File


BIN
classes/fonts/GEORGIAI.TTF View File


BIN
classes/fonts/GEORGIAZ.TTF View File


BIN
classes/fonts/IMPACT.TTF View File


BIN
classes/fonts/MISTRAL.TTF View File


+ 0
- 107
classes/fonts/README.TXT View File

1
-This document contains the End User Licensing Agreement, and instructions concerning font installation on the various Windows platforms.
2
-
3
-
4
-Microsoft TrueType Fonts
5
-END-USER LICENSE AGREEMENT FOR MICROSOFT SOFTWARE
6
----------------------------------------------------
7
-
8
-IMPORTANT - READ CAREFULLY: This Microsoft End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and Microsoft Corporation for the Microsoft software accompanying this EULA, which includes computer software and may include associated media, printed materials, and "on-line" or electronic documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). By exercising your rights to make and use copies of the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, you may not use the SOFTWARE PRODUCT.
9
-SOFTWARE PRODUCT LICENSE
10
-The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold.
11
-1. GRANT OF LICENSE. This EULA grants you the following rights:
12
-·	Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
13
-·	Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT;  provided that each copy shall be a true and complete copy, including all copyright and trademark notices, and shall be accompanied by a copy of this EULA.  Copies of the SOFTWARE PRODUCT may not be distributed for profit either on a standalone basis or included as part of your own product.
14
-2.	DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS.
15
-·	Limitations on Reverse Engineering, Decompilation, and Disassembly. You may not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation.
16
-· Restrictions on Alteration.  You may not rename, edit or create any derivative works from the SOFTWARE PRODUCT, other than subsetting when embedding them in documents.
17
-·	Software Transfer. You may permanently transfer all of your rights under this EULA, provided the recipient agrees to the terms of this EULA.
18
-·	Termination. Without prejudice to any other rights, Microsoft may terminate this EULA if you fail to comply with the terms and conditions of this EULA. In such event, you must destroy all copies of the SOFTWARE PRODUCT and all of its component parts.
19
-3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by Microsoft or its suppliers. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material.
20
-4.	U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and documentation are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer Software-Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer is Microsoft Corporation/One Microsoft Way/Redmond, WA 98052-6399.
21
-LIMITED WARRANTY
22
-NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or noninfringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you.
23
-NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its suppliers be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this Microsoft product, even if Microsoft has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.
24
-MISCELLANEOUS
25
-If you acquired this product in the United States, this EULA is governed by the laws of the State of Washington.
26
-If this product was acquired outside the United States, then local laws may apply.
27
-Should you have any questions concerning this EULA, or if you desire to contact Microsoft for any reason, please contact the Microsoft subsidiary serving your country, or write: Microsoft Sales Information Center/One Microsoft Way/Redmond, WA  98052-6399.
28
-
29
-
30
-
31
-
32
-
33
-
34
-INSTALLING FONTS
35
-________________
36
-----------------
37
-
38
-
39
-Windows95
40
----------
41
-
42
-To add a new font to your computer:
43
-
44
-1) Open the font folder from the Control Panel.
45
-
46
-2) On the File menu, click Install New Font.
47
-
48
-3) Click the drive and folder that contain the fonts you want to add.
49
-
50
-4) Double-click the icon for the font you want to add.
51
-
52
-
53
-Tips
54
-
55
-To select more than one font to add, press and hold down the CTRL key, and then click the fonts you want.
56
-
57
-To select a range of fonts in the list, press and hold down the SHIFT key while dragging the cursor over the fonts.
58
-
59
-To add fonts from a network drive without using disk space on your computer, make sure Copy Fonts To Windows Folder is not checked.
60
-
61
-
62
-
63
-
64
-
65
-Windows 3.1x
66
-------------
67
-
68
-To add fonts to your computer:
69
-
70
-1) In the Control Panel window, choose the Fonts icon. The fonts already installed are listed in the Installed Fonts box.
71
-
72
-2) Choose the Add button.
73
-
74
-3) In the Add Fonts dialog box, select the font you want to add. You can add more than one font at a time. You can also select all the fonts listed by choosing the Select All button. If the font is not located in the current drive or directory, select the drive and directory where it is located. If the font you want to add is on someone else's computer, you can use the Network button to browse through and connect to shared directories on other computers.
75
-
76
-4) If you are low on disk space and want to use the fonts directly from the directory (network or local) where they are located, without copying the font files to the Windows directory, clear the Copy Fonts To Windows Directory check box.
77
-
78
-5) Choose the OK button.
79
-
80
-6) In the Fonts dialog box, choose the Close button.
81
-
82
-For help with the Fonts and Add Fonts dialog boxes, choose the Help button or press F1 while using the dialog boxes.
83
-
84
-
85
-
86
-
87
-Windows NT
88
-----------
89
-
90
-To add fonts to your computer:
91
-
92
-1) In the Control Panel window, choose the Fonts icon. The fonts already installed are listed in the Installed Fonts box.
93
-
94
-2) Choose the Add button.
95
-
96
-3)In the Add Fonts dialog box, select the font you want to add. If the font is not located in the current drive or directory, select the drive and directory where it is located. You can add more than one font at a time. You can also select all the fonts listed by choosing the Select All button.
97
-
98
-4) If you are low on disk space and want to use the fonts directly from the directory (network or local) where they are located, without copying the font files to the \systemroot\SYSTEM directory, clear the Copy Fonts To Windows Directory check box.
99
-
100
-5) Choose the OK button.
101
-
102
-6) Choose the Close button.
103
-
104
-For help with the Fonts and Add Fonts dialog boxes, choose the Help button or press F1 while using the dialog boxes.
105
-
106
-
107
-

BIN
classes/fonts/TREBUC.TTF View File


BIN
classes/fonts/TREBUCBD.TTF View File


BIN
classes/fonts/TREBUCBI.TTF View File


BIN
classes/fonts/TREBUCIT.TTF View File


BIN
classes/fonts/VERDANA.TTF View File


BIN
classes/fonts/VERDANAB.TTF View File


BIN
classes/fonts/VERDANAI.TTF View File


BIN
classes/fonts/VERDANAZ.TTF View File


+ 1
- 1
classes/regex.php View File

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*)?');
13
-define('SITELINK_REGEX', RESOURCE_REGEX.'(www)?'.preg_quote(SITE_DOMAIN, '/'));
13
+define('SITELINK_REGEX', RESOURCE_REGEX.'(www.)?'.preg_quote(SITE_DOMAIN, '/'));
14
 define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
14
 define('TORRENT_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?torrentid=(\d+)'); // torrentid = group 4
15
 define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
15
 define('TORRENT_GROUP_REGEX', SITELINK_REGEX.'\/torrents\.php\?(.*&)?id=(\d+)'); // id = group 4
16
 define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4
16
 define('ARTIST_REGEX', SITELINK_REGEX.'\/artist\.php\?(.*&)?id=(\d+)'); // id = group 4

+ 1
- 1
classes/users.class.php View File

728
     $TPL->set('ResetKey', $ResetKey);
728
     $TPL->set('ResetKey', $ResetKey);
729
     $TPL->set('IP', $_SERVER['REMOTE_ADDR']);
729
     $TPL->set('IP', $_SERVER['REMOTE_ADDR']);
730
     $TPL->set('SITE_NAME', SITE_NAME);
730
     $TPL->set('SITE_NAME', SITE_NAME);
731
-    $TPL->set('SITE_DOMAIN', SITE_DOMAIN); // TODO: Remove
731
+    $TPL->set('SITE_DOMAIN', SITE_DOMAIN);
732
 
732
 
733
     Misc::send_email($Email, 'Password reset information for ' . SITE_NAME, $TPL->get(), 'noreply');
733
     Misc::send_email($Email, 'Password reset information for ' . SITE_NAME, $TPL->get(), 'noreply');
734
   }
734
   }

+ 459
- 461
design/privateheader.php
File diff suppressed because it is too large
View File


+ 2
- 2
design/views/generic/reply/quickreply.php View File

35
 			'SubscribeBox' => true
35
 			'SubscribeBox' => true
36
 		));
36
 		));
37
  */
37
  */
38
-	global $HeavyInfo, $UserSubscriptions, $ThreadInfo, $ForumsDoublePost, $Document;
38
+	global $HeavyInfo, $UserSubscriptions, $ThreadInfo, $Document;
39
 
39
 
40
 	if (G::$LoggedUser['DisablePosting']) {
40
 	if (G::$LoggedUser['DisablePosting']) {
41
 		return;
41
 		return;
135
 		}
135
 		}
136
 		if ($ThreadInfo['LastPostAuthorID'] == G::$LoggedUser['ID']
136
 		if ($ThreadInfo['LastPostAuthorID'] == G::$LoggedUser['ID']
137
 			&& (check_perms('site_forums_double_post')
137
 			&& (check_perms('site_forums_double_post')
138
-				|| in_array($ForumID, $ForumsDoublePost))
138
+				|| in_array($ForumID, FORUMS_TO_ALLOW_DOUBLE_POST))
139
 		) {
139
 		) {
140
 ?>
140
 ?>
141
 							<input id="mergebox" type="checkbox" name="merge" tabindex="2" />
141
 							<input id="mergebox" type="checkbox" name="merge" tabindex="2" />

BIN
favicon.ico View File


BIN
favicon.png View File


+ 1
- 1
sections/ajax/forum/thread.php View File

182
 		$MaxVotes = 0;
182
 		$MaxVotes = 0;
183
 	}
183
 	}
184
 
184
 
185
-	$RevealVoters = in_array($ForumID, $ForumsRevealVoters);
185
+	$RevealVoters = in_array($ForumID, FORUMS_TO_REVEAL_VOTERS);
186
 	//Polls lose the you voted arrow thingy
186
 	//Polls lose the you voted arrow thingy
187
 	$DB->query("
187
 	$DB->query("
188
 		SELECT Vote
188
 		SELECT Vote

+ 0
- 54
sections/captcha/index.php View File

1
-<?
2
-if (!function_exists('imagettftext')) {
3
-	die('Captcha requires both the GD library and the FreeType library.');
4
-}
5
-
6
-function get_font() {
7
-	global $CaptchaFonts;
8
-	return SERVER_ROOT.'/classes/fonts/'.$CaptchaFonts[mt_rand(0, count($CaptchaFonts) - 1)];
9
-}
10
-
11
-function make_captcha_img() {
12
-	global $CaptchaBGs;
13
-
14
-	$Length = 6;
15
-	$ImageHeight = 75;
16
-	$ImageWidth = 300;
17
-
18
-	$Chars = 'abcdefghjkmprstuvwxyzABCDEFGHJKLMPQRSTUVWXY23456789';
19
-	$CaptchaString = '';
20
-
21
-	for ($i = 0; $i < $Length; $i++) {
22
-		$CaptchaString .= $Chars[mt_rand(0,strlen($Chars) - 1)];
23
-	}
24
-
25
-	for ($x = 0; $x < $Length; $x++) {
26
-		$FontDisplay[$x]['size'] = mt_rand(24, 32);
27
-		$FontDisplay[$x]['top'] = mt_rand($FontDisplay[$x]['size'] + 5, $ImageHeight - ($FontDisplay[$x]['size'] / 2));
28
-		$FontDisplay[$x]['angle'] = mt_rand(-30, 30);
29
-		$FontDisplay[$x]['font'] = get_font();
30
-	}
31
-
32
-	$Img = imagecreatetruecolor($ImageWidth, $ImageHeight);
33
-	$BGImg = imagecreatefrompng(SERVER_ROOT.'/captcha/'.$CaptchaBGs[mt_rand(0, count($CaptchaBGs) - 1)]);
34
-	imagecopymerge($Img, $BGImg, 0, 0, 0, 0, 300, 75, 50);
35
-
36
-	$ForeColor = imagecolorallocatealpha($Img, 255, 255, 255, 65);
37
-
38
-	for ($i = 0; $i < strlen($CaptchaString); $i++) {
39
-		$CharX = (($ImageWidth / $Length) * ($i + 1)) - (($ImageWidth / $Length) * 0.75);
40
-		imagettftext($Img,$FontDisplay[$i]['size'], $FontDisplay[$i]['angle'], $CharX,
41
-						$FontDisplay[$i]['top'], $ForeColor,
42
-						$FontDisplay[$i]['font'], $CaptchaString[$i]
43
-					);
44
-	}
45
-
46
-	header('Content-type: image/png');
47
-	imagepng($Img);
48
-	imagedestroy($Img);
49
-
50
-	return $CaptchaString;
51
-}
52
-
53
-$_SESSION['captcha'] = make_captcha_img();
54
-?>

+ 5
- 3
sections/collages/torrent_collage.php View File

334
 			<div class="pad"><?=Text::full_format($Description)?></div>
334
 			<div class="pad"><?=Text::full_format($Description)?></div>
335
 		</div>
335
 		</div>
336
 <?
336
 <?
337
-if (false) { // I'm effectively commenting this out until we maybe fix the collector at some point in the future - Azathoth
337
+// I'm actually commenting this out
338
+/*
338
 if (check_perms('zip_downloader')) {
339
 if (check_perms('zip_downloader')) {
339
 	if (isset($LoggedUser['Collector'])) {
340
 	if (isset($LoggedUser['Collector'])) {
340
 		list($ZIPList, $ZIPPrefs) = $LoggedUser['Collector'];
341
 		list($ZIPList, $ZIPPrefs) = $LoggedUser['Collector'];
396
 				</form>
397
 				</form>
397
 			</div>
398
 			</div>
398
 		</div>
399
 		</div>
399
-<? } 
400
-	}?>
400
+<? }
401
+*/
402
+?>
401
 		<div class="box box_info box_statistics_collage_torrents">
403
 		<div class="box box_info box_statistics_collage_torrents">
402
 			<div class="head"><strong>Statistics</strong></div>
404
 			<div class="head"><strong>Statistics</strong></div>
403
 			<ul class="stats nobullet">
405
 			<ul class="stats nobullet">

+ 1
- 1
sections/forums/add_poll_option.php View File

13
 		FROM forums_topics
13
 		FROM forums_topics
14
 		WHERE ID = $ThreadID");
14
 		WHERE ID = $ThreadID");
15
 	list($ForumID) = $DB->next_record();
15
 	list($ForumID) = $DB->next_record();
16
-	if (!in_array($ForumID, $ForumsRevealVoters)) {
16
+	if (!in_array($ForumID, FORUMS_TO_REVEAL_VOTERS)) {
17
 		error(403);
17
 		error(403);
18
 	}
18
 	}
19
 }
19
 }

+ 1
- 1
sections/forums/change_vote.php View File

10
 			FROM forums_topics
10
 			FROM forums_topics
11
 			WHERE ID = $ThreadID");
11
 			WHERE ID = $ThreadID");
12
 		list($ForumID) = $DB->next_record();
12
 		list($ForumID) = $DB->next_record();
13
-		if (!in_array($ForumID, $ForumsRevealVoters)) {
13
+		if (!in_array($ForumID, FORUMS_TO_REVEAL_VOTERS)) {
14
 			error(403);
14
 			error(403);
15
 		}
15
 		}
16
 	}
16
 	}

+ 1
- 1
sections/forums/delete_poll_option.php View File

13
 		FROM forums_topics
13
 		FROM forums_topics
14
 		WHERE ID = $ThreadID");
14
 		WHERE ID = $ThreadID");
15
 	list($ForumID) = $DB->next_record();
15
 	list($ForumID) = $DB->next_record();
16
-	if (!in_array($ForumID, $ForumsRevealVoters)) {
16
+	if (!in_array($ForumID, FORUMS_TO_REVEAL_VOTERS)) {
17
 		error(403);
17
 		error(403);
18
 	}
18
 	}
19
 
19
 

+ 1
- 1
sections/forums/take_reply.php View File

66
 }
66
 }
67
 
67
 
68
 //Now lets handle the special case of merging posts, we can skip bumping the thread and all that fun
68
 //Now lets handle the special case of merging posts, we can skip bumping the thread and all that fun
69
-if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site_forums_double_post') && !in_array($ForumID, $ForumsDoublePost)) || isset($_POST['merge']))) {
69
+if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site_forums_double_post') && !in_array($ForumID, FORUMS_TO_ALLOW_DOUBLE_POST)) || isset($_POST['merge']))) {
70
 	//Get the id for this post in the database to append
70
 	//Get the id for this post in the database to append
71
 	$DB->query("
71
 	$DB->query("
72
 		SELECT ID, Body
72
 		SELECT ID, Body

+ 1
- 1
sections/forums/thread.php View File

249
 		$MaxVotes = 0;
249
 		$MaxVotes = 0;
250
 	}
250
 	}
251
 
251
 
252
-	$RevealVoters = in_array($ForumID, $ForumsRevealVoters);
252
+	$RevealVoters = in_array($ForumID, FORUMS_TO_REVEAL_VOTERS);
253
 	//Polls lose the you voted arrow thingy
253
 	//Polls lose the you voted arrow thingy
254
 	$DB->query("
254
 	$DB->query("
255
 		SELECT Vote
255
 		SELECT Vote

+ 186
- 189
sections/log/index.php View File

1
 <?
1
 <?
2
 enforce_login();
2
 enforce_login();
3
 if (!defined('LOG_ENTRIES_PER_PAGE')) {
3
 if (!defined('LOG_ENTRIES_PER_PAGE')) {
4
-	define('LOG_ENTRIES_PER_PAGE', 100);
4
+  define('LOG_ENTRIES_PER_PAGE', 100);
5
 }
5
 }
6
 View::show_header("Site log");
6
 View::show_header("Site log");
7
 
7
 
8
 include(SERVER_ROOT.'/sections/log/sphinx.php');
8
 include(SERVER_ROOT.'/sections/log/sphinx.php');
9
 ?>
9
 ?>
10
 <div class="thin">
10
 <div class="thin">
11
-	<div class="header">
12
-		<h2>Site log</h2>
13
-	</div>
14
-	<div class="box pad">
15
-		<form class="search_form" name="log" action="" method="get">
16
-			<table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
17
-				<tr>
18
-					<td class="label"><strong>Search for:</strong></td>
19
-					<td>
20
-						<input type="search" name="search" size="60"<?=(!empty($_GET['search']) ? ' value="'.display_str($_GET['search']).'"' : '')?> />
21
-						&nbsp;
22
-						<input type="submit" value="Search log" />
23
-					</td>
24
-				</tr>
25
-			</table>
26
-		</form>
27
-	</div>
11
+  <div class="header">
12
+    <h2>Site log</h2>
13
+  </div>
14
+  <div class="box pad">
15
+    <form class="search_form" name="log" action="" method="get">
16
+      <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
17
+        <tr>
18
+          <td class="label"><strong>Search for:</strong></td>
19
+          <td>
20
+            <input type="search" name="search" size="60"<?=(!empty($_GET['search']) ? ' value="'.display_str($_GET['search']).'"' : '')?> />
21
+            &nbsp;
22
+            <input type="submit" value="Search log" />
23
+          </td>
24
+        </tr>
25
+      </table>
26
+    </form>
27
+  </div>
28
 
28
 
29
-<?	if ($TotalMatches > LOG_ENTRIES_PER_PAGE) { ?>
30
-	<div class="linkbox">
29
+<?  if ($TotalMatches > LOG_ENTRIES_PER_PAGE) { ?>
30
+  <div class="linkbox">
31
 <?
31
 <?
32
-	$Pages = Format::get_pages($Page, $TotalMatches, LOG_ENTRIES_PER_PAGE, 9);
33
-	echo $Pages;?>
34
-	</div>
35
-<?	} ?>
36
-	<div class="box">
37
-	<table cellpadding="6" cellspacing="1" border="0" class="log_table" id="log_table" width="100%">
38
-		<tr class="colhead">
39
-			<td style="width: 180px;"><strong>Time</strong></td>
40
-			<td><strong>Message</strong></td>
41
-		</tr>
42
-<?	if ($QueryStatus) { ?>
43
-	<tr class="nobr"><td colspan="2">Search request failed (<?=$QueryError?>).</td></tr>
44
-<?	} elseif (!$DB->has_results()) { ?>
45
-	<tr class="nobr"><td colspan="2">Nothing found!</td></tr>
32
+  $Pages = Format::get_pages($Page, $TotalMatches, LOG_ENTRIES_PER_PAGE, 9);
33
+  echo $Pages;?>
34
+  </div>
35
+<?  } ?>
36
+  <div class="box">
37
+  <table cellpadding="6" cellspacing="1" border="0" class="log_table" id="log_table" width="100%">
38
+    <tr class="colhead">
39
+      <td style="width: 180px;"><strong>Time</strong></td>
40
+      <td><strong>Message</strong></td>
41
+    </tr>
42
+<?  if ($QueryStatus) { ?>
43
+  <tr class="nobr"><td colspan="2">Search request failed (<?=$QueryError?>).</td></tr>
44
+<?  } elseif (!$DB->has_results()) { ?>
45
+  <tr class="nobr"><td colspan="2">Nothing found!</td></tr>
46
 <?
46
 <?
47
-	}
47
+  }
48
 $Usernames = array();
48
 $Usernames = array();
49
 while (list($ID, $Message, $LogTime) = $DB->next_record()) {
49
 while (list($ID, $Message, $LogTime) = $DB->next_record()) {
50
-	$MessageParts = explode(' ', $Message);
51
-	$Message = '';
52
-	$Color = $Colon = false;
53
-	for ($i = 0, $PartCount = sizeof($MessageParts); $i < $PartCount; $i++) {
54
-		if ((strpos($MessageParts[$i], 'https://'.SITE_DOMAIN) === 0
55
-				&& $Offset = strlen('https://'.SITE_DOMAIN.'/'))
56
-			|| (strpos($MessageParts[$i], 'http://'.SITE_DOMAIN) === 0
57
-				&& $Offset = strlen('http://'.SITE_DOMAIN.'/'))
58
-			) {
59
-				$MessageParts[$i] = '<a href="'.substr($MessageParts[$i], $Offset).'">'.substr($MessageParts[$i], $Offset).'</a>';
60
-		}
61
-		switch ($MessageParts[$i]) {
62
-			case 'Torrent':
63
-			case 'torrent':
64
-				$TorrentID = $MessageParts[$i + 1];
65
-				if (is_numeric($TorrentID)) {
66
-					$Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?torrentid=$TorrentID\">$TorrentID</a>";
67
-					$i++;
68
-				} else {
69
-					$Message = $Message.' '.$MessageParts[$i];
70
-				}
71
-				break;
72
-			case 'Request':
73
-				$RequestID = $MessageParts[$i + 1];
74
-				if (is_numeric($RequestID)) {
75
-					$Message = $Message.' '.$MessageParts[$i]." <a href=\"requests.php?action=view&amp;id=$RequestID\">$RequestID</a>";
76
-					$i++;
77
-				} else {
78
-					$Message = $Message.' '.$MessageParts[$i];
79
-				}
80
-				break;
81
-			case 'Artist':
82
-			case 'artist':
83
-				$ArtistID = $MessageParts[$i + 1];
84
-				if (is_numeric($ArtistID)) {
85
-					$Message = $Message.' '.$MessageParts[$i]." <a href=\"artist.php?id=$ArtistID\">$ArtistID</a>";
86
-					$i++;
87
-				} else {
88
-					$Message = $Message.' '.$MessageParts[$i];
89
-				}
90
-				break;
91
-			case 'group':
92
-			case 'Group':
93
-				$GroupID = $MessageParts[$i + 1];
94
-				if (is_numeric($GroupID)) {
95
-					$Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?id=$GroupID\">$GroupID</a>";
96
-				} else {
97
-					$Message = $Message.' '.$MessageParts[$i];
98
-				}
99
-				$i++;
100
-				break;
101
-			case 'by':
102
-				$UserID = 0;
103
-				$User = '';
104
-				$URL = '';
105
-				if ($MessageParts[$i + 1] == 'user') {
106
-					$i++;
107
-					if (is_numeric($MessageParts[$i + 1])) {
108
-						$UserID = $MessageParts[++$i];
109
-					}
110
-					$URL = "user $UserID (<a href=\"user.php?id=$UserID\">".substr($MessageParts[++$i], 1, -1).'</a>)';
111
-				} elseif (in_array($MessageParts[$i - 1], array('deleted', 'uploaded', 'edited', 'created', 'recovered'))) {
112
-					$User = $MessageParts[++$i];
113
-					if (substr($User, -1) == ':') {
114
-						$User = substr($User, 0, -1);
115
-						$Colon = true;
116
-					}
117
-					if (!isset($Usernames[$User])) {
118
-						$DB->query("
119
-							SELECT ID
120
-							FROM users_main
121
-							WHERE Username = _utf8 '" . db_string($User) . "'
122
-							COLLATE utf8_bin");
123
-						list($UserID) = $DB->next_record();
124
-						$Usernames[$User] = $UserID ? $UserID : '';
125
-					} else {
126
-						$UserID = $Usernames[$User];
127
-					}
128
-					$DB->set_query_id($Log);
129
-					$URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>".($Colon ? ':' : '') : $User;
130
-				}
131
-				$Message = "$Message by $URL";
132
-				break;
133
-			case 'uploaded':
134
-				if ($Color === false) {
135
-					$Color = 'green';
136
-				}
137
-				$Message = $Message.' '.$MessageParts[$i];
138
-				break;
139
-			case 'deleted':
140
-				if ($Color === false || $Color === 'green') {
141
-					$Color = 'red';
142
-				}
143
-				$Message = $Message.' '.$MessageParts[$i];
144
-				break;
145
-			case 'edited':
146
-				if ($Color === false) {
147
-					$Color = 'blue';
148
-				}
149
-				$Message = $Message.' '.$MessageParts[$i];
150
-				break;
151
-			case 'un-filled':
152
-				if ($Color === false) {
153
-					$Color = '';
154
-				}
155
-				$Message = $Message.' '.$MessageParts[$i];
156
-				break;
157
-			case 'marked':
158
-				if ($i == 1) {
159
-					$User = $MessageParts[$i - 1];
160
-					if (!isset($Usernames[$User])) {
161
-						$DB->query("
162
-							SELECT ID
163
-							FROM users_main
164
-							WHERE Username = _utf8 '" . db_string($User) . "'
165
-							COLLATE utf8_bin");
166
-						list($UserID) = $DB->next_record();
167
-						$Usernames[$User] = $UserID ? $UserID : '';
168
-						$DB->set_query_id($Log);
169
-					} else {
170
-						$UserID = $Usernames[$User];
171
-					}
172
-					$URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>" : $User;
173
-					$Message = $URL." ".$MessageParts[$i];
174
-				} else {
175
-					$Message = $Message.' '.$MessageParts[$i];
176
-				}
177
-				break;
178
-			case 'Collage':
179
-				$CollageID = $MessageParts[$i + 1];
180
-				if (is_numeric($CollageID)) {
181
-					$Message = $Message.' '.$MessageParts[$i]." <a href=\"collages.php?id=$CollageID\">$CollageID</a>";
182
-					$i++;
183
-				} else {
184
-					$Message = $Message.' '.$MessageParts[$i];
185
-				}
186
-				break;
187
-			default:
188
-				$Message = $Message.' '.$MessageParts[$i];
189
-		}
190
-	}
50
+  $MessageParts = explode(' ', $Message);
51
+  $Message = '';
52
+  $Color = $Colon = false;
53
+  for ($i = 0, $PartCount = sizeof($MessageParts); $i < $PartCount; $i++) {
54
+    if (strpos($MessageParts[$i], 'https://'.SITE_DOMAIN) === 0) {
55
+      $Offset = strlen('https://'.SITE_DOMAIN.'/');
56
+      $MessageParts[$i] = '<a href="'.substr($MessageParts[$i], $Offset).'">'.substr($MessageParts[$i], $Offset).'</a>';
57
+    }
58
+    switch ($MessageParts[$i]) {
59
+      case 'Torrent':
60
+      case 'torrent':
61
+        $TorrentID = $MessageParts[$i + 1];
62
+        if (is_numeric($TorrentID)) {
63
+          $Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?torrentid=$TorrentID\">$TorrentID</a>";
64
+          $i++;
65
+        } else {
66
+          $Message = $Message.' '.$MessageParts[$i];
67
+        }
68
+        break;
69
+      case 'Request':
70
+        $RequestID = $MessageParts[$i + 1];
71
+        if (is_numeric($RequestID)) {
72
+          $Message = $Message.' '.$MessageParts[$i]." <a href=\"requests.php?action=view&amp;id=$RequestID\">$RequestID</a>";
73
+          $i++;
74
+        } else {
75
+          $Message = $Message.' '.$MessageParts[$i];
76
+        }
77
+        break;
78
+      case 'Artist':
79
+      case 'artist':
80
+        $ArtistID = $MessageParts[$i + 1];
81
+        if (is_numeric($ArtistID)) {
82
+          $Message = $Message.' '.$MessageParts[$i]." <a href=\"artist.php?id=$ArtistID\">$ArtistID</a>";
83
+          $i++;
84
+        } else {
85
+          $Message = $Message.' '.$MessageParts[$i];
86
+        }
87
+        break;
88
+      case 'group':
89
+      case 'Group':
90
+        $GroupID = $MessageParts[$i + 1];
91
+        if (is_numeric($GroupID)) {
92
+          $Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?id=$GroupID\">$GroupID</a>";
93
+        } else {
94
+          $Message = $Message.' '.$MessageParts[$i];
95
+        }
96
+        $i++;
97
+        break;
98
+      case 'by':
99
+        $UserID = 0;
100
+        $User = '';
101
+        $URL = '';
102
+        if ($MessageParts[$i + 1] == 'user') {
103
+          $i++;
104
+          if (is_numeric($MessageParts[$i + 1])) {
105
+            $UserID = $MessageParts[++$i];
106
+          }
107
+          $URL = "user $UserID (<a href=\"user.php?id=$UserID\">".substr($MessageParts[++$i], 1, -1).'</a>)';
108
+        } elseif (in_array($MessageParts[$i - 1], array('deleted', 'uploaded', 'edited', 'created', 'recovered'))) {
109
+          $User = $MessageParts[++$i];
110
+          if (substr($User, -1) == ':') {
111
+            $User = substr($User, 0, -1);
112
+            $Colon = true;
113
+          }
114
+          if (!isset($Usernames[$User])) {
115
+            $DB->query("
116
+              SELECT ID
117
+              FROM users_main
118
+              WHERE Username = _utf8 '" . db_string($User) . "'
119
+              COLLATE utf8_bin");
120
+            list($UserID) = $DB->next_record();
121
+            $Usernames[$User] = $UserID ? $UserID : '';
122
+          } else {
123
+            $UserID = $Usernames[$User];
124
+          }
125
+          $DB->set_query_id($Log);
126
+          $URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>".($Colon ? ':' : '') : $User;
127
+        }
128
+        $Message = "$Message by $URL";
129
+        break;
130
+      case 'uploaded':
131
+        if ($Color === false) {
132
+          $Color = 'green';
133
+        }
134
+        $Message = $Message.' '.$MessageParts[$i];
135
+        break;
136
+      case 'deleted':
137
+        if ($Color === false || $Color === 'green') {
138
+          $Color = 'red';
139
+        }
140
+        $Message = $Message.' '.$MessageParts[$i];
141
+        break;
142
+      case 'edited':
143
+        if ($Color === false) {
144
+          $Color = 'blue';
145
+        }
146
+        $Message = $Message.' '.$MessageParts[$i];
147
+        break;
148
+      case 'un-filled':
149
+        if ($Color === false) {
150
+          $Color = '';
151
+        }
152
+        $Message = $Message.' '.$MessageParts[$i];
153
+        break;
154
+      case 'marked':
155
+        if ($i == 1) {
156
+          $User = $MessageParts[$i - 1];
157
+          if (!isset($Usernames[$User])) {
158
+            $DB->query("
159
+              SELECT ID
160
+              FROM users_main
161
+              WHERE Username = _utf8 '" . db_string($User) . "'
162
+              COLLATE utf8_bin");
163
+            list($UserID) = $DB->next_record();
164
+            $Usernames[$User] = $UserID ? $UserID : '';
165
+            $DB->set_query_id($Log);
166
+          } else {
167
+            $UserID = $Usernames[$User];
168
+          }
169
+          $URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>" : $User;
170
+          $Message = $URL." ".$MessageParts[$i];
171
+        } else {
172
+          $Message = $Message.' '.$MessageParts[$i];
173
+        }
174
+        break;
175
+      case 'Collage':
176
+        $CollageID = $MessageParts[$i + 1];
177
+        if (is_numeric($CollageID)) {
178
+          $Message = $Message.' '.$MessageParts[$i]." <a href=\"collages.php?id=$CollageID\">$CollageID</a>";
179
+          $i++;
180
+        } else {
181
+          $Message = $Message.' '.$MessageParts[$i];
182
+        }
183
+        break;
184
+      default:
185
+        $Message = $Message.' '.$MessageParts[$i];
186
+    }
187
+  }
191
 ?>
188
 ?>
192
-		<tr class="row" id="log_<?=$ID?>">
193
-			<td class="nobr">
194
-				<?=time_diff($LogTime)?>
195
-			</td>
196
-			<td>
197
-				<span<? if ($Color) { ?> style="color: <?=$Color?>;"<? } ?>><?=$Message?></span>
198
-			</td>
199
-		</tr>
189
+    <tr class="row" id="log_<?=$ID?>">
190
+      <td class="nobr">
191
+        <?=time_diff($LogTime)?>
192
+      </td>
193
+      <td>
194
+        <span<? if ($Color) { ?> style="color: <?=$Color?>;"<? } ?>><?=$Message?></span>
195
+      </td>
196
+    </tr>
200
 <?
197
 <?
201
 }
198
 }
202
 ?>
199
 ?>
203
-	</table>
204
-	</div>
200
+  </table>
201
+  </div>
205
 <? if (isset($Pages)) { ?>
202
 <? if (isset($Pages)) { ?>
206
-	<div class="linkbox">
207
-		<?=$Pages?>
208
-	</div>
203
+  <div class="linkbox">
204
+    <?=$Pages?>
205
+  </div>
209
 <? } ?>
206
 <? } ?>
210
 </div>
207
 </div>
211
 <?
208
 <?

+ 7
- 34
sections/schedule/daily/ratio_reqs.php View File

62
   SET um.RequiredRatioWork = (1 - (t.SeedingAvg / s.NumSnatches))
62
   SET um.RequiredRatioWork = (1 - (t.SeedingAvg / s.NumSnatches))
63
   WHERE s.NumSnatches > 0");
63
   WHERE s.NumSnatches > 0");
64
 
64
 
65
-// Lower Limit, Req Ratio (0% seeded), Req Ratio (100% seeded)
66
-$RatioRequirements = array(
67
-  array(160 * 1024 * 1024 * 1024, 0.60, 0.50),
68
-  array(120 * 1024 * 1024 * 1024, 0.60, 0.40),
69
-  array(100 * 1024 * 1024 * 1024, 0.60, 0.30),
70
-  array(80  * 1024 * 1024 * 1024, 0.50, 0.20),
71
-  array(60  * 1024 * 1024 * 1024, 0.40, 0.10),
72
-  array(40  * 1024 * 1024 * 1024, 0.30, 0.00),
73
-  array(20  * 1024 * 1024 * 1024, 0.20, 0.00),
74
-  array(10  * 1024 * 1024 * 1024, 0.15, 0.00)
75
-);
76
-
77
-$DownloadBarrier = 200 * 1024 * 1024 * 1024;
78
-$DB->query("
79
-  UPDATE users_main
80
-  SET RequiredRatio = 0.60
81
-  WHERE Downloaded > $DownloadBarrier");
82
 
65
 
66
+// TODO: change from PHP_INT_MAX to INF when we get prepared statements working (because apparently that works)
67
+$DownloadBarrier = PHP_INT_MAX;
83
 
68
 
84
-foreach ($RatioRequirements as $Requirement) {
69
+foreach (RATIO_REQUIREMENTS as $Requirement) {
85
   list($Download, $Ratio, $MinRatio) = $Requirement;
70
   list($Download, $Ratio, $MinRatio) = $Requirement;
86
 
71
 
87
   $DB->query("
72
   $DB->query("
88
     UPDATE users_main
73
     UPDATE users_main
89
     SET RequiredRatio = RequiredRatioWork * $Ratio
74
     SET RequiredRatio = RequiredRatioWork * $Ratio
90
-    WHERE Downloaded >= '$Download'
91
-      AND Downloaded < '$DownloadBarrier'");
75
+    WHERE Downloaded >= $Download
76
+      AND Downloaded < $DownloadBarrier");
92
 
77
 
93
   $DB->query("
78
   $DB->query("
94
     UPDATE users_main
79
     UPDATE users_main
95
     SET RequiredRatio = $MinRatio
80
     SET RequiredRatio = $MinRatio
96
-    WHERE Downloaded >= '$Download'
97
-      AND Downloaded < '$DownloadBarrier'
81
+    WHERE Downloaded >= $Download
82
+      AND Downloaded < $DownloadBarrier
98
       AND RequiredRatio < $MinRatio");
83
       AND RequiredRatio < $MinRatio");
99
 
84
 
100
-  /*$DB->query("
101
-    UPDATE users_main
102
-    SET RequiredRatio = $Ratio
103
-    WHERE Downloaded >= '$Download'
104
-      AND Downloaded < '$DownloadBarrier'
105
-      AND can_leech = '0'
106
-      AND Enabled = '1'");
107
-  */
108
   $DownloadBarrier = $Download;
85
   $DownloadBarrier = $Download;
109
 }
86
 }
110
 
87
 
111
-$DB->query("
112
-  UPDATE users_main
113
-  SET RequiredRatio = 0.00
114
-  WHERE Downloaded < 5 * 1024 * 1024 * 1024");
115
 ?>
88
 ?>

+ 18
- 19
sections/schedule/hourly/badges.php View File

1
 <?
1
 <?
2
 //----------- Award Automated Badges -----------------------//
2
 //----------- Award Automated Badges -----------------------//
3
 
3
 
4
-global $AutomatedBadgeIDs;
5
 $GiB = 1024*1024*1024;
4
 $GiB = 1024*1024*1024;
6
 $ModifiedIDs = array();
5
 $ModifiedIDs = array();
7
 // Download Badges
6
 // Download Badges
10
   SELECT ID
9
   SELECT ID
11
   FROM users_main
10
   FROM users_main
12
   WHERE Downloaded >= ".(8*$GiB)."
11
   WHERE Downloaded >= ".(8*$GiB)."
13
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['8'].")");
12
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['8'].")");
14
 
13
 
15
 if ($DB->has_results()) {
14
 if ($DB->has_results()) {
16
   $IDs = $DB->collect('ID');
15
   $IDs = $DB->collect('ID');
17
   foreach ($IDs as $ID) {
16
   foreach ($IDs as $ID) {
18
     $DB->query("
17
     $DB->query("
19
       INSERT INTO users_badges
18
       INSERT INTO users_badges
20
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['8'].", 0)");
19
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['8'].", 0)");
21
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 8GiB of data.\n\nIt can be enabled from your user settings.");
20
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 8GiB of data.\n\nIt can be enabled from your user settings.");
22
   }
21
   }
23
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
22
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
28
   SELECT ID
27
   SELECT ID
29
   FROM users_main
28
   FROM users_main
30
   WHERE Downloaded >= ".(16*$GiB)."
29
   WHERE Downloaded >= ".(16*$GiB)."
31
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['16'].")");
30
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['16'].")");
32
 
31
 
33
 if ($DB->has_results()) {
32
 if ($DB->has_results()) {
34
   $IDs = $DB->collect('ID');
33
   $IDs = $DB->collect('ID');
35
   foreach ($IDs as $ID) {
34
   foreach ($IDs as $ID) {
36
     $DB->query("
35
     $DB->query("
37
       INSERT INTO users_badges
36
       INSERT INTO users_badges
38
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['16'].", 0)");
37
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['16'].", 0)");
39
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 16GiB of data.\n\nIt can be enabled from your user settings.");
38
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 16GiB of data.\n\nIt can be enabled from your user settings.");
40
   }
39
   }
41
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
40
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
46
   SELECT ID
45
   SELECT ID
47
   FROM users_main
46
   FROM users_main
48
   WHERE Downloaded >= ".(32*$GiB)."
47
   WHERE Downloaded >= ".(32*$GiB)."
49
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['32'].")");
48
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['32'].")");
50
 
49
 
51
 if ($DB->has_results()) {
50
 if ($DB->has_results()) {
52
   $IDs = $DB->collect('ID');
51
   $IDs = $DB->collect('ID');
53
   foreach ($IDs as $ID) {
52
   foreach ($IDs as $ID) {
54
     $DB->query("
53
     $DB->query("
55
       INSERT INTO users_badges
54
       INSERT INTO users_badges
56
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['32'].", 0)");
55
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['32'].", 0)");
57
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 32GiB of data.\n\nIt can be enabled from your user settings.");
56
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 32GiB of data.\n\nIt can be enabled from your user settings.");
58
   }
57
   }
59
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
58
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
64
   SELECT ID
63
   SELECT ID
65
   FROM users_main
64
   FROM users_main
66
   WHERE Downloaded >= ".(64*$GiB)."
65
   WHERE Downloaded >= ".(64*$GiB)."
67
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['64'].")");
66
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['64'].")");
68
 
67
 
69
 if ($DB->has_results()) {
68
 if ($DB->has_results()) {
70
   $IDs = $DB->collect('ID');
69
   $IDs = $DB->collect('ID');
71
   foreach ($IDs as $ID) {
70
   foreach ($IDs as $ID) {
72
     $DB->query("
71
     $DB->query("
73
       INSERT INTO users_badges
72
       INSERT INTO users_badges
74
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['64'].", 0)");
73
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['64'].", 0)");
75
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 64GiB of data.\n\nIt can be enabled from your user settings.");
74
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 64GiB of data.\n\nIt can be enabled from your user settings.");
76
   }
75
   }
77
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
76
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
82
   SELECT ID
81
   SELECT ID
83
   FROM users_main
82
   FROM users_main
84
   WHERE Downloaded >= ".(128*$GiB)."
83
   WHERE Downloaded >= ".(128*$GiB)."
85
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['128'].")");
84
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['128'].")");
86
 
85
 
87
 if ($DB->has_results()) {
86
 if ($DB->has_results()) {
88
   $IDs = $DB->collect('ID');
87
   $IDs = $DB->collect('ID');
89
   foreach ($IDs as $ID) {
88
   foreach ($IDs as $ID) {
90
     $DB->query("
89
     $DB->query("
91
       INSERT INTO users_badges
90
       INSERT INTO users_badges
92
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['128'].", 0)");
91
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['128'].", 0)");
93
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 128GiB of data.\n\nIt can be enabled from your user settings.");
92
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 128GiB of data.\n\nIt can be enabled from your user settings.");
94
   }
93
   }
95
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
94
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
100
   SELECT ID
99
   SELECT ID
101
   FROM users_main
100
   FROM users_main
102
   WHERE Downloaded >= ".(256*$GiB)."
101
   WHERE Downloaded >= ".(256*$GiB)."
103
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['256'].")");
102
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['256'].")");
104
 
103
 
105
 if ($DB->has_results()) {
104
 if ($DB->has_results()) {
106
   $IDs = $DB->collect('ID');
105
   $IDs = $DB->collect('ID');
107
   foreach ($IDs as $ID) {
106
   foreach ($IDs as $ID) {
108
     $DB->query("
107
     $DB->query("
109
       INSERT INTO users_badges
108
       INSERT INTO users_badges
110
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['256'].", 0)");
109
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['256'].", 0)");
111
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 256GiB of data.\n\nIt can be enabled from your user settings.");
110
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 256GiB of data.\n\nIt can be enabled from your user settings.");
112
   }
111
   }
113
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
112
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
118
   SELECT ID
117
   SELECT ID
119
   FROM users_main
118
   FROM users_main
120
   WHERE Downloaded >= ".(512*$GiB)."
119
   WHERE Downloaded >= ".(512*$GiB)."
121
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['512'].")");
120
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['512'].")");
122
 
121
 
123
 if ($DB->has_results()) {
122
 if ($DB->has_results()) {
124
   $IDs = $DB->collect('ID');
123
   $IDs = $DB->collect('ID');
125
   foreach ($IDs as $ID) {
124
   foreach ($IDs as $ID) {
126
     $DB->query("
125
     $DB->query("
127
       INSERT INTO users_badges
126
       INSERT INTO users_badges
128
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['512'].", 0)");
127
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['512'].", 0)");
129
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 512GiB of data.\n\nIt can be enabled from your user settings.");
128
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 512GiB of data.\n\nIt can be enabled from your user settings.");
130
   }
129
   }
131
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
130
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
136
   SELECT ID
135
   SELECT ID
137
   FROM users_main
136
   FROM users_main
138
   WHERE Downloaded >= ".(1024*$GiB)."
137
   WHERE Downloaded >= ".(1024*$GiB)."
139
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['1024'].")");
138
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['1024'].")");
140
 
139
 
141
 if ($DB->has_results()) {
140
 if ($DB->has_results()) {
142
   $IDs = $DB->collect('ID');
141
   $IDs = $DB->collect('ID');
143
   foreach ($IDs as $ID) {
142
   foreach ($IDs as $ID) {
144
     $DB->query("
143
     $DB->query("
145
       INSERT INTO users_badges
144
       INSERT INTO users_badges
146
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['1024'].", 0)");
145
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['1024'].", 0)");
147
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 1024GiB of data.\n\nIt can be enabled from your user settings.");
146
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 1024GiB of data.\n\nIt can be enabled from your user settings.");
148
   }
147
   }
149
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
148
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
154
   SELECT ID
153
   SELECT ID
155
   FROM users_main
154
   FROM users_main
156
   WHERE Downloaded >= ".(2048*$GiB)."
155
   WHERE Downloaded >= ".(2048*$GiB)."
157
-    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".$AutomatedBadgeIDs['DL']['2048'].")");
156
+    AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = ".AUTOMATED_BADGE_IDS['DL']['2048'].")");
158
 
157
 
159
 if ($DB->has_results()) {
158
 if ($DB->has_results()) {
160
   $IDs = $DB->collect('ID');
159
   $IDs = $DB->collect('ID');
161
   foreach ($IDs as $ID) {
160
   foreach ($IDs as $ID) {
162
     $DB->query("
161
     $DB->query("
163
       INSERT INTO users_badges
162
       INSERT INTO users_badges
164
-      VALUES (".$ID.", ".$AutomatedBadgeIDs['DL']['2048'].", 0)");
163
+      VALUES (".$ID.", ".AUTOMATED_BADGE_IDS['DL']['2048'].", 0)");
165
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 2048GiB of data.\n\nIt can be enabled from your user settings.");
164
     Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading 2048GiB of data.\n\nIt can be enabled from your user settings.");
166
   }
165
   }
167
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
166
   $ModifiedIDs = array_merge($ModifiedIDs, $IDs);

+ 0
- 59
sections/tools/development/update_geoip.php View File

50
 }
50
 }
51
 
51
 
52
 View::show_footer();
52
 View::show_footer();
53
-
54
-/*
55
-	The following way works perfectly fine, we just foung the APNIC data to be to outdated for us.
56
-*/
57
-
58
-/*
59
-if (!check_perms('admin_update_geoip')) {
60
-	die();
61
-}
62
-enforce_login();
63
-
64
-ini_set('memory_limit', 1024 * 1024 * 1024);
65
-ini_set('max_execution_time', 3600);
66
-
67
-header('Content-type: text/plain');
68
-ob_end_clean();
69
-restore_error_handler();
70
-
71
-$Registries[] = 'http://ftp.apnic.net/stats/afrinic/delegated-afrinic-latest'; //Africa
72
-$Registries[] = 'http://ftp.apnic.net/stats/apnic/delegated-apnic-latest'; //Asia & Pacific
73
-$Registries[] = 'http://ftp.apnic.net/stats/arin/delegated-arin-latest'; //North America
74
-$Registries[] = 'http://ftp.apnic.net/stats/lacnic/delegated-lacnic-latest'; //South America
75
-$Registries[] = 'http://ftp.apnic.net/stats/ripe-ncc/delegated-ripencc-latest'; //Europe
76
-
77
-$Registries[] = 'ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest'; //Africa
78
-$Registries[] = 'ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest'; //Asia & Pacific
79
-$Registries[] = 'ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest'; //North America
80
-$Registries[] = 'ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest'; //South America
81
-$Registries[] = 'ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest'; //Europe
82
-
83
-
84
-
85
-$Query = array();
86
-
87
-foreach ($Registries as $Registry) {
88
-	$CountryData = explode("\n",file_get_contents($Registry));
89
-	foreach ($CountryData as $Country) {
90
-		if (preg_match('/\|([A-Z]{2})\|ipv4\|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\|(\d+)\|/', $Country, $Matches)) {
91
-
92
-			$Start = Tools::ip_to_unsigned($Matches[2]);
93
-			if ($Start == 2147483647) { continue; }
94
-
95
-			if (!isset($Current)) {
96
-				$Current = array('StartIP' => $Start, 'EndIP' => $Start + $Matches[3],'Code' => $Matches[1]);
97
-			} elseif ($Current['Code'] == $Matches[1] && $Current['EndIP'] == $Start) {
98
-				$Current['EndIP'] = $Current['EndIP'] + $Matches[3];
99
-			} else {
100
-				$Query[] = "('".$Current['StartIP']."','".$Current['EndIP']."','".$Current['Code']."')";
101
-				$Current = array('StartIP' => $Start, 'EndIP' => $Start + $Matches[3],'Code' => $Matches[1]);
102
-			}
103
-		}
104
-	}
105
-}
106
-$Query[] = "('".$Current['StartIP']."','".$Current['EndIP']."','".$Current['Code']."')";
107
-
108
-$DB->query("TRUNCATE TABLE geoip_country");
109
-$DB->query("INSERT INTO geoip_country (StartIP, EndIP, Code) VALUES ".implode(',', $Query));
110
-echo $DB->affected_rows();
111
-*/

Loading…
Cancel
Save