-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.php
570 lines (529 loc) · 33.3 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
<?php
require_once ("funcsv2.php");
//check if config.php file already exists, if so, this could be an already existing installation
if (file_exists("config.php"))
{
echo "<font color=red><strong>The config.php file already exists. This is an indication of an already existing installation" .
" of RivetTracker. If you are sure you are installing for the first time, please try recopying the files/folders." .
" This is also a security feature to prevent malicious attempts to run the installer if you forgot to delete it." .
" This installer will now abort.</strong></font>";
exit();
}
if (isset($_POST["download"]))
{
//download config.php using header()
header('content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"config.php\"");
print "<?php //Please do NOT edit this file, use the admin page for changes.\n";
print "\$GLOBALS['hiddentracker'] = " . htmlspecialchars($_POST["hiddentracker"]) . ";\n";
print "\$GLOBALS['scrape'] = " . htmlspecialchars($_POST["scrape"]) . ";\n";
print "\$GLOBALS['report_interval'] = " . htmlspecialchars($_POST["report_interval"]) . ";\n";
print "\$GLOBALS['min_interval'] = " . htmlspecialchars($_POST["min_interval"]) . ";\n";
print "\$GLOBALS['maxpeers'] = " . htmlspecialchars($_POST["maxpeers"]) . ";\n";
print "\$GLOBALS['NAT'] = " . htmlspecialchars($_POST["NAT"]) . ";\n";
print "\$GLOBALS['persist'] = " . htmlspecialchars($_POST["persist"]) . ";\n";
print "\$GLOBALS['ip_override'] = " . htmlspecialchars($_POST["ip_override"]) . ";\n";
print "\$GLOBALS['countbytes'] = " . htmlspecialchars($_POST["countbytes"]) . ";\n";
print "\$upload_username = '" . htmlspecialchars($_POST["upload_username"]) . "';\n";
print "\$upload_password = '" . htmlspecialchars($_POST["upload_password"]) . "';\n";
print "\$admin_username = '" . htmlspecialchars($_POST["admin_username"]) . "';\n";
print "\$admin_password = '" . htmlspecialchars($_POST["admin_password"]) . "';\n";
print "\$GLOBALS['title'] = '" . htmlspecialchars(addquotes($_POST["title"])) . "';\n";
print "\$dbhost = '" . htmlspecialchars($_POST["dbhost"]) . "';\n";
print "\$dbuser = '" . htmlspecialchars($_POST["dbuser"]) . "';\n";
print "\$dbpass = '" . htmlspecialchars($_POST["dbpass"]) . "';\n";
print "\$database = '" . htmlspecialchars($_POST["database"]) . "';\n";
print "\$enablerss = " . htmlspecialchars($_POST['enablerss']) . ";\n";
print "\$rss_title = '" . htmlspecialchars(addquotes($_POST["rss_title"])) . "';\n";
print "\$rss_link = '" . htmlspecialchars($_POST["rss_link"]) . "';\n";
print "\$rss_description = '" . htmlspecialchars($_POST["rss_description"]) . "';\n";
print "\$website_url = '" . htmlspecialchars($_POST['website_url']) . "';\n";
print "\$GLOBALS['max_upload_rate'] = " . htmlspecialchars($_POST['max_upload_rate']) . ";\n";
print "\$GLOBALS['max_uploads'] = " . htmlspecialchars($_POST['max_uploads']) . ";\n";
print "\$timezone = '" . htmlspecialchars($_POST['timezone']) . "';\n";
print "\$prefix = '" . htmlspecialchars($_POST['prefix']) . "';\n";
print "?>";
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>RivetTracker Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="./css/style.css" type="text/css" />
</head>
<body>
<p align="right"><a href="./docs/help.html"><img src="images/help.png" border="0" class="icon" alt="Help" title="Help" /></a><a href="./docs/help.html">Help</a></p>
<?php
if (!isset($_POST["started"]))
{
?>
<center>
<h1>RivetTracker Installer</h1>
<img src="images/install.png" border="0" class="icon" alt="RivetTracker Installation" title="RivetTracker Installation" />
</center>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="started" value="1">
<h2>The MySQL database needs to be prepared for the tracker. This script will help
you do that.</h2>
<h2>You have two choices:</h2>
<ul>
<li><h2>If you have a username, password, and database for the tracker already
created:</h2></li>
</ul>
<input type="submit" name="preexisting" value="Click Here">
<br>
<ul>
<li><h2>If you need to create the account and database, and you have the username and password
of a user who can create user accounts and databases:</h2></li>
</ul>
<input type="submit" name="makeaccount" value="Click Here">
</form>
<br>
</body></html><?php exit;
}
if (isset($_POST["preexisting"]))
{
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="maketables" value="1">
<input type="hidden" name="started" value="1">
<h1>RivetTracker Installation</h1>
<center>
<img src="images/install.png" border="0" class="icon" alt="RivetTracker Installation" title="RivetTracker Installation" />
</center>
<br><br>
<table border=0 cellpadding=5>
<tr><td align="right"><b>Database hostname:<br>(in MySQL format, example: localhost)</b></td><td align="left"><input type="text" name="host" value="localhost" size="40"></td></tr>
<tr><td align="right"><b>Tracker's database username:</b></td><td align="left"><input type="text" name="username" size="40"></td></tr>
<tr><td align="right"><b>Tracker's database password:</b></td><td align="left"><input type="password" name="password" size="40"></td></tr>
<tr><td align="right"><b>Database name:</b></td><td align="left"><input type="text" name="database" size="40"></td></tr>
<tr><td align="right"><b>Table Prefix:<br> (If you want to use an existing<br> database this will add the tables
in<br> with the specified prefix. If you<br> are unsure, leave this blank.)<br>e.g.: rt_</b></td><td align="left"><input type="text" name="prefix" size="40"></td></tr>
</table>
<br><br>
<center>
<input type="submit" value="Install">
</center>
<br>
</form></body></html><?php exit;
}
if (isset($_POST["makeaccount"]))
{
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="domakeaccount" value="1">
<input type="hidden" name="started" value="1">
<h1>Tracker Installation</h1>
<center>
<img src="images/install.png" border="0" class="icon" alt="RivetTracker Installation" title="RivetTracker Installation" />
</center>
<br><br>
<table border=0 cellpadding=5>
<tr><td align="right"><b>Username of database admin:</b></td><td align="left"><input type="text" name="adminname" size="40"></td></tr>
<tr><td align="right"><b>Password of database admin:</b></td><td align="left"><input type="password" name="adminpass" size="40"></td></tr>
<tr><td align="right"><b>Database hostname:<br>(in MySQL format, example: localhost)</b></td><td align="left"><input type="text" name="host" size="40" value="localhost"></td></tr>
<tr><td align="right"><b>Create user for MySQL:<br>(make sure this user does not already exist)</b></td><td align="left"><input type="text" name="username" size="40"></td></tr>
<tr><td align="right"><b>Password:</b></td><td align="left"><input type="password" name="password" size="40"></td></tr>
<tr><td align="right"><b>Create database (name):</b></td><td align="left"><input type="text" name="database" size="40"></td></tr>
</table>
<br><br>
<center>
<input type="submit" value="Install">
</center>
</form></body></html>
<?php exit;
}
$prefix = $_POST["prefix"];
$makenamemap= 'CREATE TABLE ' . $prefix . 'namemap (info_hash char(40) NOT NULL default "", filename varchar(250) NOT NULL default "", url varchar(250) NOT NULL default "", size bigint(20) unsigned NOT NULL, pubDate varchar(25) NOT NULL default "", PRIMARY KEY(info_hash)) ENGINE = innodb';
$makesummary = 'CREATE TABLE ' . $prefix . 'summary (info_hash char(40) NOT NULL default "", dlbytes bigint unsigned NOT NULL default 0, seeds int unsigned NOT NULL default 0, leechers int unsigned NOT NULL default 0, finished int unsigned NOT NULL default 0, lastcycle int unsigned NOT NULL default "0", lastSpeedCycle int unsigned NOT NULL DEFAULT "0", speed bigint unsigned NOT NULL default 0, piecelength int(11) NOT NULL default -1, numpieces int(11) NOT NULL default 0, PRIMARY KEY (info_hash)) ENGINE = innodb';
$maketimestamps = 'CREATE TABLE ' . $prefix . 'timestamps (info_hash char(40) not null, sequence int unsigned not null auto_increment, bytes bigint unsigned not null, delta smallint unsigned not null, primary key(sequence), key sorting (info_hash)) ENGINE = innodb';
$makespeedlimit = 'CREATE TABLE ' . $prefix . 'speedlimit (uploaded bigint(25) NOT NULL default 0, total_uploaded bigint(30) NOT NULL default 0, started bigint(25) NOT NULL default 0) ENGINE = innodb';
$makewebseedfiles = 'CREATE TABLE ' . $prefix . 'webseedfiles (info_hash char(40) default NULL, filename char(250) NOT NULL default "", startpiece int(11) NOT NULL default 0, endpiece int(11) NOT NULL default 0, startpieceoffset int(11) NOT NULL default 0, fileorder int(11) NOT NULL default 0, UNIQUE KEY fileseq (info_hash,fileorder)) ENGINE = innodb';
if (isset($_POST["maketables"]))
{
$username = $_POST["username"] or die(errorMessage() . "No username was given, please try again.</p>");
$password = $_POST["password"] or die(errorMessage() . "No username password was given, this is a huge security risk, please try again.</p>");
$database = $_POST["database"] or die(errorMessage() . "No database specified, please try again.</p>");
$hostname = $_POST["host"] or die(errorMessage() . "No database hostname specified, please try again.</p>");
$sql = new mysqli($hostname, $username, $password, $database);
$sql->query($makesummary);
$sql->query($makenamemap);
$sql->query($maketimestamps);
$sql->query($makespeedlimit);
$sql->query($makewebseedfiles);
$sql->query("INSERT INTO ".$prefix."speedlimit values (0,0,0)");
echo "<p class=\"success\">Database was created successfully!</p><br><br>";
}
if (isset($_POST["domakeaccount"]))
{
$username = $_POST["username"] or die(errorMessage() . "No username was given, please try again.</p>");
$password = $_POST["password"] or die(errorMessage() . "No username password was given, this is a huge security risk, please try again.</p>");
$database = $_POST["database"] or die(errorMessage() . "No database specified, please try again.</p>");
$hostname = $_POST["host"] or die(errorMessage() . "No database hostname specified, please try again.</p>");
$dbadmin = $_POST["adminname"] or die(errorMessage() . "No admin username was given, please try again.</p>");
$dbpass = $_POST["adminpass"]; // No admin password, OK but huge security risk...
// Escaping strings will be ignored for now.
$sql = new mysqli($hostname, $username, $password, $database);
$sql->query("INSERT INTO user SET user=\"$username\", password=PASSWORD(\"$password\"), host=\"\"") or die(errorMessage() . "Can't make user: " . mysql_error() . "</p>");
$sql->query("INSERT INTO db SET Host=\"%\", db=\"$database\", user=\"$username\", select_priv='Y', Insert_priv='Y', Update_priv='Y', Delete_priv='Y', Create_priv='Y', Drop_priv='Y', Alter_priv='Y', index_priv='Y'") or die(errorMessage() . "Cannot insert into \"Db\": " . mysql_error() . "</p>");
$sql->query("CREATE DATABASE $database") or die(errorMessage() . "Can't make database: " . mysql_error() . "</p>");
$sql->query("FLUSH PRIVILEGES") or die(errorMessage() . "Can't flush privileges: " . mysql_error() . "</p>");
$sql->query($makesummary) or die(errorMessage() . "Can't make the summary table: " . mysql_error() . "</p>");
$sql->query($makenamemap) or die(errorMessage() . "Can't make the namemap table: " . mysql_error() . "</p>");
$sql->query($maketimestamps) or die(errorMessage() . "Can't make the timestamps table: " . mysql_error() . "</p>");
$sql->query($makespeedlimit) or die(errorMessage() . "Can't make the speedlimit table: " . mysql_error() . "</p>");
$sql->query($makewebseedfiles) or die(errorMessage() . "Can't make the webseedfiles table: " . mysql_error() . "</p>");
$sql->query("INSERT INTO ".$prefix."speedlimit values (0,0,0)") or die(errorMessage() . "Can't insert zeros into speedlimit table: " . mysql_error() . "</p>");
echo "<p class=\"success\">Database was created successfully!</p><br><br>";
}
if (isset($_POST["domakeaccount"]) || isset($_POST["maketables"]))
{
//have user set values for config.php
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="config" value="1">
<input type="hidden" name="started" value="1">
<?php
echo "<input type=\"hidden\" name=\"dbhost\" value=\"" . $hostname . "\">\n";
echo "<input type=\"hidden\" name=\"dbuser\" value=\"" . $username . "\">\n";
echo "<input type=\"hidden\" name=\"dbpass\" value=\"" . $password . "\">\n";
echo "<input type=\"hidden\" name=\"database\" value=\"" . $database . "\">\n";
echo "<input type=\"hidden\" name=\"prefix\" value=\"" . $prefix . "\">\n";
?>
<h1>Create Configuration File</h1>
<br><br>
<h2>This last step allows you to configure the "config.php" file. This file stores all the necessary
settings for your tracker. You can edit these settings at a later time in the admin page if you need
to change them. Please do NOT edit the "config.php" file directly, use the admin page for any changes.
It's usually pretty safe to leave most of the settings to the default unless you know what you're doing.</h2>
<h2><span class="notice">*</span> - required value</h2>
<table border=1 cellpadding=3>
<tr><td><b>Make tracker hidden: This will require a login by either the admin or upload user in order to
see the torrents available on the main statistics page. This does not mean it's a private tracker. If you
need a private tracker, there are many other trackers out there. Also, you will need to secure the "torrents"
folder with an .htaccess file for Apache or some other method. The tracker will still accept all valid
connections by clients. There is no user checking in that regard.</b></td>
<td><input type="checkbox" name="hiddentracker"></td></tr>
<tr><td><b>Enable or disable scraping by clients. Generally it is safe to leave this on unless
you have a large number of torrents or users which can lead to increased bandwidth usage. Also, scraping
can possibily be used maliciously by abusive clients.</b></td>
<td><input type="checkbox" name="scrape" checked></td></tr>
<tr><td><b><span class="notice">* </span>Maximum reannounce interval (in seconds) 1800 == 30 minutes</b></td>
<td><input type="text" name="report_interval" size="40" value="1800"></td></tr>
<tr><td><b><span class="notice">* </span>Minimum reannounce interval (also in seconds) 300 == 5 minutes</b></td>
<td><input type="text" name="min_interval" size="40" value="300"></td></tr>
<tr><td><b><span class="notice">* </span>Number of peers to send in one request. Some logic will break if you set this to more than 300,
so please don't do that. 100 is the most you should set anyway.</b></td>
<td><input type="text" name="maxpeers" size="40" value="50"></td></tr>
<tr><td><b>If set, NAT checking will be performed.
This may cause trouble with some providers, so it's
off by default.</b></td>
<td><input type="checkbox" name="NAT"></td></tr>
<tr><td><b>Persistent MySQL connections:
Check with your webmaster to see if you're allowed to use these.
Highly recommended, especially for higher loads, but generally
not allowed unless it's a dedicated machine.</b></td>
<td><input type="checkbox" name="persist"></td></tr>
<tr><td><b>Allow users to override ip address.
Enable this if you know people have a legit reason to use
this function. Leave disabled otherwise.</b></td>
<td><input type="checkbox" name="ip_override"></td></tr>
<tr><td><b>For heavily loaded trackers, uncheck this. It will stop count the number
of downloaded bytes and the speed of the torrent, but will significantly reduce
the load.</b></td>
<td><input type="checkbox" name="countbytes" checked></td></tr>
<tr><td><b><span class="notice">* </span>Username for individual who can add torrents to tracker database.
This user is only able to create, and not delete torrents to the tracker.
For full privileges, see the admin user.</b></td>
<td><input type="text" name="upload_username" size="40"></td></tr>
<tr><td><b><span class="notice">* </span>Password for individual who can add torrents to tracker database.
Again, this user is only able to create, and not delete torrents to the tracker.
For full privileges, see the admin user.</b></td>
<td><input type="password" name="upload_password" size="40"></td></tr>
<tr><td><b><span class="notice">* </span>Admin username. The admin is able to go to the admin page and show detailed
information about the tracker as well as access a few other important tools.
The admin is also able to upload torrents to the database
just like the previous account.</b></td>
<td><input type="text" name="admin_username" size="40"></td></tr>
<tr><td><b><span class="notice">* </span>Password for admin. Again, The admin is able to go to the admin page and show detailed
information about the tracker as well as access a few other important tools.
The admin is also able to upload torrents to the database.</b></td>
<td><input type="password" name="admin_password" size="40"></td></tr>
<tr><td><b>Title on index.php statistics page, if not set, defaults to "Tracker Statistics"</b></td>
<td><input type="text" name="title" size="40"></td></tr>
<tr><td><b>Enable RSS feed: If you do not want the RSS feed to be created for
privacy reasons or do not need it disable this checkbox.</b></td>
<td><input type="checkbox" name="enablerss" checked></td></tr>
<tr><td><b>RSS Title: In the rss.xml file, this is the main <pre><title></pre> tag.</b></td>
<td><input type="text" name="rss_title" size="40"></td></tr>
<tr><td><b>RSS link to main website: In the rss.xml file, this is the main <pre><link></pre> tag.</b></td>
<td><input type="text" name="rss_link" size="40"></td></tr>
<tr><td><b>RSS description: In the rss.xml file, this is the main <pre><description></pre> tag.</b></td>
<td><input type="text" name="rss_description" size="60"></td></tr>
<tr><td><b><span class="notice">* </span>Main website url that the tracker runs on, example: http://www.mywebsite.com</b></td>
<td><input type="text" name="website_url" size="40"></td></tr>
<tr><td><b><span class="notice">* </span>For HTTP seeding, this is the maximum total upload rate per second in kilobytes, for example 100 would be 100 KB/s</b></td>
<td><input type="text" name="max_upload_rate" size="40" value="100"></td></tr>
<tr><td><b><span class="notice">* </span>For HTTP seeding, this is the maximum number of uploads to run at a time</b></td>
<td><input type="text" name="max_uploads" size="40" value="5"></td></tr>
<tr><td><b><span class="notice">* </span>Timezone that the server runs on</b></td>
<td>
<select name="timezone" id="timezone">
<option title="[UTC - 12] Baker Island Time" value="-1200">[UTC - 12] Baker Island Time</option>
<option title="[UTC - 11] Niue Time, Samoa Standard Time" value="-1100">[UTC - 11] Niue Time, Samoa Standard Time</option>
<option title="[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time" value="-1000">[UTC - 10] Hawaii-Aleutian Standard Time, Cook Isl...</option>
<option title="[UTC - 9:30] Marquesas Islands Time" value="-0930">[UTC - 9:30] Marquesas Islands Time</option>
<option title="[UTC - 9] Alaska Standard Time, Gambier Island Time" value="-0900">[UTC - 9] Alaska Standard Time, Gambier Island Tim...</option>
<option title="[UTC - 8] Pacific Standard Time" value="-0800">[UTC - 8] Pacific Standard Time</option>
<option title="[UTC - 7] Mountain Standard Time" value="-0700">[UTC - 7] Mountain Standard Time</option>
<option title="[UTC - 6] Central Standard Time" value="-0600">[UTC - 6] Central Standard Time</option>
<option title="[UTC - 5] Eastern Standard Time" value="-0500">[UTC - 5] Eastern Standard Time</option>
<option title="[UTC - 4] Atlantic Standard Time" value="-0400">[UTC - 4] Atlantic Standard Time</option>
<option title="[UTC - 3:30] Newfoundland Standard Time" value="-0330">[UTC - 3:30] Newfoundland Standard Time</option>
<option title="[UTC - 3] Amazon Standard Time, Central Greenland Time" value="-0300">[UTC - 3] Amazon Standard Time, Central Greenland ...</option>
<option title="[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time" value="-0200">[UTC - 2] Fernando de Noronha Time, South Georgia ...</option>
<option title="[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time" value="-0100">[UTC - 1] Azores Standard Time, Cape Verde Time, E...</option>
<option title="[UTC] Western European Time, Greenwich Mean Time" value="+0000" selected="selected">[UTC] Western European Time, Greenwich Mean Time</option>
<option title="[UTC + 1] Central European Time, West African Time" value="+0100">[UTC + 1] Central European Time, West African Time</option>
<option title="[UTC + 2] Eastern European Time, Central African Time" value="+0200">[UTC + 2] Eastern European Time, Central African T...</option>
<option title="[UTC + 3] Moscow Standard Time, Eastern African Time" value="+0300">[UTC + 3] Moscow Standard Time, Eastern African Ti...</option>
<option title="[UTC + 3:30] Iran Standard Time" value="+0330">[UTC + 3:30] Iran Standard Time</option>
<option title="[UTC + 4] Gulf Standard Time, Samara Standard Time" value="+0400">[UTC + 4] Gulf Standard Time, Samara Standard Time</option>
<option title="[UTC + 4:30] Afghanistan Time" value="+0430">[UTC + 4:30] Afghanistan Time</option>
<option title="[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time" value="+0500">[UTC + 5] Pakistan Standard Time, Yekaterinburg St...</option>
<option title="[UTC + 5:30] Indian Standard Time, Sri Lanka Time" value="+0530">[UTC + 5:30] Indian Standard Time, Sri Lanka Time</option>
<option title="[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time" value="+0600">[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirs...</option>
<option title="[UTC + 6:30] Cocos Islands Time, Myanmar Time" value="+0630">[UTC + 6:30] Cocos Islands Time, Myanmar Time</option>
<option title="[UTC + 7] Indochina Time, Krasnoyarsk Standard Time" value="+0700">[UTC + 7] Indochina Time, Krasnoyarsk Standard Tim...</option>
<option title="[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time" value="+0800">[UTC + 8] Chinese Standard Time, Australian Wester...</option>
<option title="[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time" value="+0900">[UTC + 9] Japan Standard Time, Korea Standard Time...</option>
<option title="[UTC + 9:30] Australian Central Standard Time" value="+0930">[UTC + 9:30] Australian Central Standard Time</option>
<option title="[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time" value="+1000">[UTC + 10] Australian Eastern Standard Time, Vladi...</option>
<option title="[UTC + 10:30] Lord Howe Standard Time" value="+1030">[UTC + 10:30] Lord Howe Standard Time</option>
<option title="[UTC + 11] Solomon Island Time, Magadan Standard Time" value="+1100">[UTC + 11] Solomon Island Time, Magadan Standard T...</option>
<option title="[UTC + 11:30] Norfolk Island Time" value="+1130">[UTC + 11:30] Norfolk Island Time</option>
<option title="[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time" value="+1200">[UTC + 12] New Zealand Time, Fiji Time, Kamchatka ...</option>
<option title="[UTC + 13] Tonga Time, Phoenix Islands Time" value="+1300">[UTC + 13] Tonga Time, Phoenix Islands Time</option>
<option title="[UTC + 14] Line Island Time" value="+1400">[UTC + 14] Line Island Time</option>
</select>
</td>
</tr>
</table>
<br>
<center>
<input type="submit" value="Create Config File">
</center>
<br><br><br>
</form>
</body>
</html>
<?php
}
if (isset($_POST["config"]))
{
//check required entries for values, if blank: error out
if (!is_numeric($_POST["report_interval"]) || $_POST["report_interval"] == "" || $_POST["report_interval"] <= 0)
{
echo errorMessage() . "Error: The maximum reannounce interval is not an integer, a negative number, or is blank.</p>";
exit();
}
if (!is_numeric($_POST["min_interval"]) || $_POST["min_interval"] == "" || $_POST["min_interval"] <= 0)
{
echo errorMessage() . "Error: The minimum reannounce interval is not an integer, a negative number, or is blank.</p>";
exit();
}
if (!is_numeric($_POST["maxpeers"]) || $_POST["maxpeers"] == "" || $_POST["maxpeers"] > 300 || $_POST["maxpeers"] <= 0)
{
echo errorMessage() . "Error: The number of peers to send in one request is not an integer, over 300, a negative number, zero, or blank.</p>";
exit();
}
if ($_POST["upload_username"] == "")
{
echo errorMessage() . "Error: The upload username is blank.</p>";
exit();
}
if ($_POST["upload_password"] == "")
{
echo errorMessage() . "Error: The upload user password is blank. This is considered a security risk.</p>";
exit();
}
if ($_POST["admin_username"] == "")
{
echo errorMessage() . "Error: The admin username is blank.</p>";
exit();
}
if ($_POST["admin_password"] == "")
{
echo errorMessage() . "Error: The admin user password is blank. This is considered a LARGE security risk.</p>";
exit();
}
if ($_POST["dbhost"] == "")
{
echo errorMessage() . "Error: The database hostname is blank.</p>";
exit();
}
if ($_POST["dbuser"] == "")
{
echo errorMessage() . "Error: The database username is blank.</p>";
exit();
}
if ($_POST["dbpass"] == "")
{
echo errorMessage() . "Error: The database password is blank.</p>";
exit();
}
if ($_POST["database"] == "")
{
echo errorMessage() . "Error: The database name is blank.</p>";
exit();
}
if ($_POST["rss_link"] != "" && Substr($_POST["rss_link"], 0, 7) != "http://")
{
echo errorMessage() . "Error: The RSS website URL does not start with http://</p>";
exit();
}
if ($_POST["website_url"] == "" || Substr($_POST["website_url"], 0, 7) != "http://")
{
echo errorMessage() . "Error: The website URL does not start with http:// or is blank.</p>";
exit();
}
if (!is_numeric($_POST["max_upload_rate"]) || $_POST["max_upload_rate"] == "" || $_POST["max_upload_rate"] <= 0)
{
echo errorMessage() . "Error: The maximum upload rate is not an integer, a negative number, or is blank.</p>";
exit();
}
if (!is_numeric($_POST["max_uploads"]) || $_POST["max_uploads"] == "" || $_POST["max_uploads"] <= 0)
{
echo errorMessage() . "Error: The maximum uploads is not an integer, a negative number, or is blank.</p>";
exit();
}
if ($_POST["timezone"] == "")
{
echo errorMessage() . "Error: The timezone is blank.</p>";
exit();
}
if ($_POST["upload_username"] == $_POST["admin_username"])
{
echo errorMessage() . "Error: The admin username cannot be the same as the upload username.</p>";
exit();
}
//create config.php based on user input
//first try creating it on the server
if (is_writable("./"))
{
//go through checkboxes and change "on" to "true"
if ($_POST["hiddentracker"] == "on")
$hiddentracker = "true";
else
$hiddentracker = "false";
if ($_POST["enablerss"] == "on")
$enablerss = "true";
else
$enablerss = "false";
if ($_POST["scrape"] == "on")
$scrape = "true";
else
$scrape = "false";
if ($_POST["NAT"] == "on")
$NAT = "true";
else
$NAT = "false";
if ($_POST["persist"] == "on")
$persist = "true";
else
$persist = "false";
if ($_POST["ip_override"] == "on")
$ip_override = "true";
else
$ip_override = "false";
if ($_POST["countbytes"] == "on")
$countbytes = "true";
else
$countbytes = "false";
//write config.php file
$fd = fopen("config.php", "w") or die(errorMessage() . "Error: couldn't make config.php!</p>");
fwrite($fd,
"<?php //Please do NOT edit this file, use the admin page for changes.\n" .
"\$GLOBALS['hiddentracker'] = " . $hiddentracker . ";\n" .
"\$GLOBALS['scrape'] = " . $scrape . ";\n" .
"\$GLOBALS['report_interval'] = " . htmlspecialchars($_POST["report_interval"]) . ";\n" .
"\$GLOBALS['min_interval'] = " . htmlspecialchars($_POST["min_interval"]) . ";\n" .
"\$GLOBALS['maxpeers'] = " . htmlspecialchars($_POST["maxpeers"]) . ";\n" .
"\$GLOBALS['NAT'] = " . $NAT . ";\n" .
"\$GLOBALS['persist'] = " . $persist . ";\n" .
"\$GLOBALS['ip_override'] = " . $ip_override . ";\n" .
"\$GLOBALS['countbytes'] = " . $countbytes . ";\n" .
"\$upload_username = '" . htmlspecialchars($_POST["upload_username"]) . "';\n" .
"\$upload_password = '" . md5($_POST["upload_username"].$_POST["upload_password"]) . "';\n" .
"\$admin_username = '" . htmlspecialchars($_POST["admin_username"]) . "';\n" .
"\$admin_password = '" . md5($_POST["admin_username"].$_POST["admin_password"]) . "';\n" .
"\$GLOBALS['title'] = '" . htmlspecialchars(addquotes($_POST["title"])) . "';\n" .
"\$dbhost = '" . htmlspecialchars($_POST["dbhost"]) . "';\n" .
"\$dbuser = '" . htmlspecialchars($_POST["dbuser"]) . "';\n" .
"\$dbpass = '" . htmlspecialchars($_POST["dbpass"]) . "';\n" .
"\$database = '" . htmlspecialchars($_POST["database"]) . "';\n" .
"\$enablerss = " . $enablerss . ";\n" .
"\$rss_title = '" . htmlspecialchars(addquotes($_POST["rss_title"])) . "';\n" .
"\$rss_link = '" . htmlspecialchars($_POST["rss_link"]) . "';\n" .
"\$rss_description = '" . htmlspecialchars(addquotes($_POST["rss_description"])) . "';\n" .
"\$website_url = '" . htmlspecialchars($_POST["website_url"]) . "';\n" .
"\$GLOBALS['max_upload_rate'] = " . htmlspecialchars($_POST['max_upload_rate']) . ";\n" .
"\$GLOBALS['max_uploads'] = " . htmlspecialchars($_POST['max_uploads']) . ";\n" .
"\$timezone = '" . htmlspecialchars($_POST["timezone"]) . "';\n" .
"\$prefix = '" . htmlspecialchars($_POST["prefix"]) . "';\n" .
"\$sql = new mysqli(\$dbhost, \$dbuser, \$dbpass, \$database);" . "';\n" .
"?>"
);
fclose($fd);
echo "<br><p class=\"success\">config.php file was created successfully!</p>";
}
//if unable to create on server, user downloads config.php file for future upload
if (!is_writable("./"))
{
?>
<h2>"config.php" was unable to be created on the server,
you will have to download the file and upload it manually.</h2>
<br>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="download" value="1">
<input type="hidden" name="hiddentracker" value="<?php if ($_POST['hiddentracker'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="scrape" value="<?php if ($_POST['scrape'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="report_interval" value="<?php echo $_POST['report_interval'];?>">
<input type="hidden" name="min_interval" value="<?php echo $_POST['min_interval'];?>">
<input type="hidden" name="maxpeers" value="<?php echo $_POST['maxpeers'];?>">
<input type="hidden" name="NAT" value="<?php if ($_POST['NAT'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="persist" value="<?php if ($_POST['persist'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="ip_override" value="<?php if ($_POST['ip_override'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="countbytes" value="<?php if ($_POST['countbytes'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="upload_username" value="<?php echo $_POST['upload_username'];?>">
<input type="hidden" name="upload_password" value="<?php echo md5($_POST["upload_username"].$_POST["upload_password"]);?>">
<input type="hidden" name="admin_username" value="<?php echo $_POST['admin_username'];?>">
<input type="hidden" name="admin_password" value="<?php echo md5($_POST["admin_username"].$_POST["admin_password"]);?>">
<input type="hidden" name="title" value="<?php echo $_POST['title'];?>">
<input type="hidden" name="dbhost" value="<?php echo $_POST['dbhost'];?>">
<input type="hidden" name="dbuser" value="<?php echo $_POST['dbuser'];?>">
<input type="hidden" name="dbpass" value="<?php echo $_POST['dbpass'];?>">
<input type="hidden" name="database" value="<?php echo $_POST['database'];?>">
<input type="hidden" name="enablerss" value="<?php if ($_POST['enablerss'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="rss_title" value="<?php echo $_POST['rss_title'];?>">
<input type="hidden" name="rss_link" value="<?php echo $_POST['rss_link'];?>">
<input type="hidden" name="rss_description" value="<?php echo $_POST['rss_description'];?>">
<input type="hidden" name="website_url" value="<?php echo $_POST['website_url'];?>">
<input type="hidden" name="max_upload_rate" value="<?php echo $_POST['max_upload_rate'];?>">
<input type="hidden" name="max_uploads" value="<?php echo $_POST['max_uploads'];?>">
<input type="hidden" name="timezone" value="<?php echo $_POST['timezone'];?>">
<input type="hidden" name="prefix" value="<?php echo $_POST['prefix'];?>">
<input type="submit" value="Download config.php File">
</form>
<br>
<?php
}
//display message to delete install.php file
echo "<p class=\"error\">Make sure you go and delete this installer script when you are done! (install.php)</p><br><br>\n";
echo "<p class=\"error\">Also, check the permissions and make sure the 'torrents' and 'rss' folders are able to be written to by the server.</p><br><br>\n";
echo "<br><center><a href=\"index.php\">Main Statistics Page</a></center>\n";
echo "</body></html>\n";
}
?>