This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.php
918 lines (847 loc) · 55.6 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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
<?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['customtitle'] = " . htmlspecialchars($_POST["customtitle"]) . ";\n";
print "\$GLOBALS['indexpagelimitspecify'] = " . htmlspecialchars($_POST["indexpagelimitspecify"]) . ";\n";
print "\$GLOBALS['statspagelimitspecify'] = " . htmlspecialchars($_POST["statspagelimitspecify"]) . ";\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 "\$announce_url0 = '" . htmlspecialchars($_POST['announce_url0']) . "';\n";
print "\$announce_url1 = '" . htmlspecialchars($_POST['announce_url1']) . "';\n";
print "\$announce_url2 = '" . htmlspecialchars($_POST['announce_url2']) . "';\n";
print "\$announce_url3 = '" . htmlspecialchars($_POST['announce_url3']) . "';\n";
print "\$announce_url4 = '" . htmlspecialchars($_POST['announce_url4']) . "';\n";
print "\$GLOBALS['max_upload_rate'] = " . htmlspecialchars($_POST['max_upload_rate']) . ";\n";
print "\$GLOBALS['max_uploads'] = " . htmlspecialchars($_POST['max_uploads']) . ";\n";
print "\$dateformat = '" . htmlspecialchars($_POST['dateformat']) . "';\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" />
<br>
<br>
<br>
<h2>Check for PHP and MySQL</h2>
</center>
<form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>">
<input type="hidden" name="started" value="1">
<?php
echo <<<HTML
<style>table {width: 650px; margin: auto;} th {background: transparent; border: none; align: center;} td.a {width: 225px; text-align: center;} td.c {width: 50px; height: 42px; margin: auto;}</style>
HTML;
// PHP Version
$_GET['php_version'] = PHP_VERSION;
// Check 5.6
if (version_compare(PHP_VERSION, '5.6.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.6+.</td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></table></font>
HTML;
}
// Check 5.5
else if (version_compare(PHP_VERSION, '5.5.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.5+.</td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Check 5.4
else if (version_compare(PHP_VERSION, '5.4.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.4+.</td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Check 5.3
else if (version_compare(PHP_VERSION, '5.3.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.3+.</td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Check 5.2
else if (version_compare(PHP_VERSION, '5.2.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.2+. Update to PHP 5.3 or higher when possible. </td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Check 5.1
else if (version_compare(PHP_VERSION, '5.1.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.1+. Update to PHP 5.3 or higher when possible. </td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Check 5.0
else if (version_compare(PHP_VERSION, '5.0.0*', '>='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server supports PHP 5.0+. Update to PHP 5.3 or higher when possible. </td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></font>
HTML;
}
// Does not support PHP 5
else if (version_compare(PHP_VERSION, '4.4.9*', '<='))
{
echo <<<HTML
<font face="Verdana" size="3"><br><table><tr><th>PHP Version:</th></tr><tr><td class="a">{$_GET['php_version']}</td><td class="b">Your server does not support PHP 5. You may have issues running this tracker.</td><td class="c"> <img src="./images/no.png" alt="Not Supported" </tr></table></font>
HTML;
}
echo <<<HTML
<br>
HTML;
//MySQL check
if (class_exists('mysqli') OR function_exists('mysql_connect'))
{
echo <<<HTML
<font face="Verdana" size="3"><table><tr><th>MySQL Support:</th></tr><tr><td class="a">Yes</td><td class="b">Your server supports MySQL.</td><td class="c"><img src="./images/yes.png" class="icon" alt="Supported" /></td></tr></table></font>
HTML;
}
// No MySQL
else
{
echo <<<HTML
<font face="Verdana" size="3"><table><tr><th>MySQL Support:</tr></th><tr><td class="a">No</td><td class="b">Your server does not support MySQL.</td><td class="c"> <img src="./images/no.png" alt="Not Supported" /></td></tr></table></font>
HTML;
}
echo ("<br><br>");
if (version_compare(PHP_VERSION, '5.3.0*', '>=') && class_exists('mysqli') || version_compare(PHP_VERSION, '5.3.0*', '>=') && function_exists('mysql_connect')) echo "<center><font face=\"Verdana\">Fully supported. You may continue.</font></center>";
else if (version_compare(PHP_VERSION, '5.3.0*', '>=') && !class_exists('mysqli') || version_compare(PHP_VERSION, '5.3.0*', '>=') && !function_exists('mysql_connect')) die ("<center><font face=\"Verdana\">Fully supported, but cannot connect to database. You may not continue.</font></center>");
if (version_compare(PHP_VERSION, '5.2.0*', '<=') && class_exists('mysqli') || version_compare(PHP_VERSION, '5.2.0*', '<=') && function_exists('mysql_connect')) echo "<center><font face=\"Verdana\">Supported. You may continue.</font></center>";
else if (version_compare(PHP_VERSION, '5.2.0*', '<=') && !class_exists('mysqli') || version_compare(PHP_VERSION, '5.2.0*', '<=') && !function_exists('mysql_connect')) die ("<center><font face=\"Verdana\">Supported, but cannot connect to database. You may not continue.</font></center>");
if (version_compare(PHP_VERSION, '4.4.9*', '<=') && class_exists('mysqli') || version_compare(PHP_VERSION, '4.4.9*', '<=') && function_exists('mysql_connect')) echo "<center><font face=\"Verdana\">Not fully supported, but you may try.</font></center>";
else if (version_compare(PHP_VERSION, '4.4.9*', '<=') && !class_exists('mysqli') || version_compare(PHP_VERSION, '4.4.9*', '<=') && !function_exists('mysql_connect')) die("<center><font face=\"Verdana\">Not fully supported, also cannot connect to database. You may not continue.</font></center>");
?>
<br>
<br>
<center>
<input type="submit" name="checkpassed" value="Continue">
</form>
</center>
<br>
</body></html><?php exit;
}
if (isset($_POST["checkpassed"]))
{
?>
<center>
<h1>RivetTracker Installer</h1>
<img src="images/install.png" border="0" class="icon" alt="RivetTracker Installation" title="RivetTracker Installation" />
</center>
<br>
<br>
<form method="post" action="<?php echo htmlentities($_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>
<br>
<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>
<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 htmlentities($_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">Database hostname:<br>(in MySQL format, example: localhost)</td><td align="left"><input type="text" name="host" value="localhost" size="40"></td></tr>
<tr><td align="right">Tracker's database username:</td><td align="left"><input type="text" name="username" size="40"></td></tr>
<tr><td align="right">Tracker's database password:</td><td align="left"><input type="password" name="password" size="40"></td></tr>
<tr><td align="right">Database name:</td><td align="left"><input type="text" name="database" size="40"></td></tr>
<tr><td align="right">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_</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 htmlentities($_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">Username of database admin:</td><td align="left"><input type="text" name="adminname" size="40"></td></tr>
<tr><td align="right">Password of database admin:</td><td align="left"><input type="password" name="adminpass" size="40"></td></tr>
<tr><td align="right">Database hostname:<br>(in MySQL format, example: localhost)</td><td align="left"><input type="text" name="host" size="40" value="localhost"></td></tr>
<tr><td align="right">Create user for MySQL:<br>(make sure this user does not already exist)</td><td align="left"><input type="text" name="username" size="40"></td></tr>
<tr><td align="right">Password:</td><td align="left"><input type="password" name="password" size="40"></td></tr>
<tr><td align="right">Create database (name):</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;
}
if (isset($_POST["prefix"])) {
$prefix = $_POST["prefix"];
} else {
$prefix = "";
}
$makenamemap= 'CREATE TABLE ' . $prefix . 'namemap (info_hash char(40) NOT NULL default "", title varchar(250) NOT NULL default "", filename varchar(250) NOT NULL default "", url varchar(250) NOT NULL default "", size bigint(20) unsigned NOT NULL, pubDate varchar(50) NOT NULL default "", PRIMARY KEY(info_hash)) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci 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)) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci 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)) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci 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) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci 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)) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci 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>");
$db = mysql_connect($hostname, $username, $password) or die(errorMessage() . "Can't connect to database: " . mysql_error() . "</p>");
mysql_select_db($database) or die(errorMessage() . "Can't select database: " . mysql_error() . "</p>");
mysql_query($makesummary) or die(errorMessage() . "Can't make the summary table: " . mysql_error() . "</p>");
mysql_query($makenamemap) or die(errorMessage() . "Can't make the namemap table: " . mysql_error() . "</p>");
mysql_query($maketimestamps) or die(errorMessage() . "Can't make the timestamps table: " . mysql_error() . "</p>");
mysql_query($makespeedlimit) or die(errorMessage() . "Can't make the speedlimit table: " . mysql_error() . "</p>");
mysql_query($makewebseedfiles) or die(errorMessage() . "Can't make the webseedfiles table: " . mysql_error() . "</p>");
mysql_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"]))
{
$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.
$db = mysql_connect($hostname, $dbadmin, $dbpass) or die(errorMessage() . "Error connecting: " . mysql_error() . "</p>");
mysql_select_db("mysql") or die(errorMessage() . "Can't select db \"mysql\":" . mysql_error() . "</p>");
mysql_query("INSERT INTO user SET user=\"$username\", password=PASSWORD(\"$password\"), host=\"\"") or die(errorMessage() . "Can't make user: " . mysql_error() . "</p>");
mysql_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>");
mysql_query("CREATE DATABASE `$database`") or die(errorMessage() . "Can't make database: " . mysql_error() . "</p>");
mysql_query("FLUSH PRIVILEGES") or die(errorMessage() . "Can't flush privileges: " . mysql_error() . "</p>");
mysql_select_db($database) or die(errorMessage() . "Can't select database \"$database\":" . mysql_error() . "</p>");
mysql_query($makesummary) or die(errorMessage() . "Can't make the summary table: " . mysql_error() . "</p>");
mysql_query($makenamemap) or die(errorMessage() . "Can't make the namemap table: " . mysql_error() . "</p>");
mysql_query($maketimestamps) or die(errorMessage() . "Can't make the timestamps table: " . mysql_error() . "</p>");
mysql_query($makespeedlimit) or die(errorMessage() . "Can't make the speedlimit table: " . mysql_error() . "</p>");
mysql_query($makewebseedfiles) or die(errorMessage() . "Can't make the webseedfiles table: " . mysql_error() . "</p>");
mysql_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 htmlentities($_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>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.</td>
<td><input type="checkbox" name="hiddentracker"></td></tr>
<tr><td>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.</td>
<td><input type="checkbox" name="scrape" checked></td></tr>
<tr><td>Displays custom titles on the main torrent statistics page instead of the filename. This is
because the uploader script will auto-rename your uploaded filename to exactly what you specified initally
or by automatically using the data from the uploaded torrent. Check this if you want the titles to be
different from the filename.</td>
<td><input type="checkbox" name="customtitle"></td></tr>
<tr><td><span class="notice">* </span>Lists the number of torrents on each page on your torrent tracker list. Default is 10.</td>
<td><input type="text" name="indexpagelimitspecify" size="40" value="10"></td></tr>
<tr><td><span class="notice">* </span>Lists the number of torrents on each page on the detailed statistics page. Default is 5.</td>
<td><input type="text" name="statspagelimitspecify" size="40" value="5"></td></tr>
<tr><td><span class="notice">* </span>Maximum reannounce interval (in seconds) 1800 == 30 minutes</td>
<td><input type="text" name="report_interval" size="40" value="1800"></td></tr>
<tr><td><span class="notice">* </span>Minimum reannounce interval (also in seconds) 300 == 5 minutes</td>
<td><input type="text" name="min_interval" size="40" value="300"></td></tr>
<tr><td><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.</td>
<td><input type="text" name="maxpeers" size="40" value="50"></td></tr>
<tr><td>If set, NAT checking will be performed.
This may cause trouble with some providers, so it's
off by default.</td>
<td><input type="checkbox" name="NAT"></td></tr>
<tr><td>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.</td>
<td><input type="checkbox" name="persist"></td></tr>
<tr><td>Allow users to override ip address.
Enable this if you know people have a legit reason to use
this function. Leave disabled otherwise.</td>
<td><input type="checkbox" name="ip_override"></td></tr>
<tr><td>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.</td>
<td><input type="checkbox" name="countbytes" checked></td></tr>
<tr><td><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.</td>
<td><input type="text" name="upload_username" size="40"></td></tr>
<tr><td><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.</td>
<td><input type="password" name="upload_password" size="40"></td></tr>
<tr><td><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.</td>
<td><input type="text" name="admin_username" size="40"></td></tr>
<tr><td><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.</td>
<td><input type="password" name="admin_password" size="40"></td></tr>
<tr><td>Title on index.php statistics page, if not set, defaults to "Tracker Statistics"</td>
<td><input type="text" name="title" size="40"></td></tr>
<tr><td>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.</td>
<td><input type="checkbox" name="enablerss" checked></td></tr>
<tr><td>RSS Title: In the rss.xml file, this is the main <pre><title></pre> tag.</td>
<td><input type="text" name="rss_title" size="40"></td></tr>
<tr><td>RSS link to main website: In the rss.xml file, this is the main <pre><link></pre> tag.</td>
<td><input type="text" name="rss_link" size="40"></td></tr>
<tr><td>RSS description: In the rss.xml file, this is the main <pre><description></pre> tag.</td>
<td><input type="text" name="rss_description" size="60"></td></tr>
<tr><td><span class="notice">* </span>Main website url that the tracker runs on, example: http://www.mywebsite.com</td>
<td><input type="text" name="website_url" size="40"></td></tr>
<tr><td><span class="notice">* </span>Primary announce url that the tracker runs on, example: http://www.mywebsite.com/tracker/announce</td>
<td><input type="text" name="announce_url0" size="40"></td></tr>
<tr><td>Secondary website url that the tracker runs on, example: http://www.mywebsite.com/tracker/announce</td>
<td><input type="text" name="announce_url1" size="40"></td></tr>
<tr><td>Tertiary website url that the tracker runs on, example: http://www.mywebsite.com/tracker/announce</td>
<td><input type="text" name="announce_url2" size="40"></td></tr>
<tr><td>Quaternary website url that the tracker runs on, example: http://www.mywebsite.com/tracker/announce</td>
<td><input type="text" name="announce_url3" size="40"></td></tr>
<tr><td>Quinary website url that the tracker runs on, example: http://www.mywebsite.com/tracker/announce</td>
<td><input type="text" name="announce_url4" size="40"></td></tr>
<tr><td><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</td>
<td><input type="text" name="max_upload_rate" size="40" value="100"></td></tr>
<tr><td><span class="notice">* </span>For HTTP seeding, this is the maximum number of uploads to run at a time</td>
<td><input type="text" name="max_uploads" size="40" value="5"></td></tr>
<tr><td><span class="notice">* </span>Date format of the torrent publication date. It shows on statistics.php. If you change this setting, you will have to change it for every other existing torrent!</td>
<td>
<select name="dateformat" id="dateformat">
<option title="Mon, 4 Jan, 1999 01:15:40 PM" value="D, j M, Y h:i:s A" selected="selected">Mon, 4 Jan, 1999 01:15:40 PM</option>
<option title="Monday, 4 Jan, 1999 01:15:40 PM" value="l, j M, Y h:i:s A">Monday, 4 Jan, 1999 01:15:40 PM</option>
<option title="Mon, 4 January, 1999 01:15:40 PM" value="D, j F, Y h:i:s A">Mon, 4 January, 1999 01:15:40 PM</option>
<option title="Monday, 4 January, 1999 01:15:40 PM" value="l, j F, Y h:i:s A">Monday, 4 January, 1999 01:15:40 PM</option>
<option title="Mon, 4 Jan, 1999 13:15:40" value="D, j M, Y H:i:s">Mon, 4 Jan, 1999 13:15:40</option>
<option title="Monday, 4 Jan, 1999 13:15:40" value="l, j M, Y H:i:s">Monday, 4 Jan, 1999 13:15:40</option>
<option title="Mon, 4 January, 1999 13:15:40" value="D, j F, Y H:i:s">Mon, 4 January, 1999 13:15:40</option>
<option title="Monday, 4 January, 1999 13:15:40" value="l, j F, Y H:i:s">Monday, 4 January, 1999 13:15:40</option>
<option title="Mon, Jan 4, 1999 01:15:40 PM" value="D, M j, Y h:i:s A">Mon, Jan 4, 1999 01:15:40 PM</option>
<option title="Monday, Jan 4, 1999 01:15:40 PM" value="l, M j, Y h:i:s A">Monday, Jan 4, 1999 01:15:40 PM</option>
<option title="Mon, January 4, 1999 01:15:40 PM" value="D, F j, Y h:i:s A">Mon, January 4, 1999 01:15:40 PM</option>
<option title="Monday, January 4, 1999 01:15:40 PM" value="l, F j, Y h:i:s A">Monday, January 4, 1999 01:15:40 PM</option>
<option title="Mon, Jan 4, 1999 13:15:40" value="D, M j, Y H:i:s">Mon, Jan 4, 1999 13:15:40</option>
<option title="Monday, Jan 4, 1999 13:15:40" value="l, M j, Y H:i:s">Monday, Jan 4, 1999 13:15:40</option>
<option title="Mon, January 4, 1999 13:15:40" value="D, F j, Y H:i:s">Mon, January 4, 1999 13:15:40</option>
<option title="Monday, January 4, 1999 13:15:40" value="l, F j, Y H:i:s">Monday, January 4, 1999 13:15:40</option>
</select>
</td>
</tr>
<tr><td><span class="notice">* </span>Timezone that the server runs on</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 ($_POST["announce_url0"] == "")
{
echo errorMessage() . "Error: The announce URL is blank.</p>";
exit();
}
if (!is_numeric($_POST["indexpagelimitspecify"]) || $_POST["indexpagelimitspecify"] == "" || $_POST["indexpagelimitspecify"] <= 0)
{
echo errorMessage() . "Error: The index page limit is not an integer, a negative number, or is blank.</p>";
exit();
}
if (!is_numeric($_POST["statspagelimitspecify"]) || $_POST["statspagelimitspecify"] == "" || $_POST["statspagelimitspecify"] <= 0)
{
echo errorMessage() . "Error: The statistics page limit is not an integer, a negative number, or is blank.</p>";
exit();
}
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 ($_POST["announce_url0"] == "" || Substr($_POST["announce_url0"], 0, 7) != "http://")
{
echo errorMessage() . "Error: The announce 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["dateformat"] == "")
{
echo errorMessage() . "Error: The date format 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["customtitle"] == "on")
$customtitle = "true";
else
$customtitle = "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";
$_GET['php_version'] = PHP_VERSION;
//write config.php file
if (version_compare(PHP_VERSION, '5.5.0*', '>=')) {
$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['customtitle'] = " . $customtitle . ";\n" .
"\$GLOBALS['indexpagelimitspecify'] = " . htmlspecialchars($_POST["indexpagelimitspecify"]) . ";\n" .
"\$GLOBALS['statspagelimitspecify'] = " . htmlspecialchars($_POST["statspagelimitspecify"]) . ";\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 = '" . password_hash($_POST["upload_username"].$_POST["upload_password"], PASSWORD_BCRYPT) . "';\n" .
"\$admin_username = '" . htmlspecialchars($_POST["admin_username"]) . "';\n" .
"\$admin_password = '" . password_hash($_POST["admin_username"].$_POST["admin_password"], PASSWORD_BCRYPT) . "';\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" .
"\$announce_url0 = '" . htmlspecialchars($_POST["announce_url0"]) . "';\n" .
"\$announce_url1 = '" . htmlspecialchars($_POST["announce_url1"]) . "';\n" .
"\$announce_url2 = '" . htmlspecialchars($_POST["announce_url2"]) . "';\n" .
"\$announce_url3 = '" . htmlspecialchars($_POST["announce_url3"]) . "';\n" .
"\$announce_url4 = '" . htmlspecialchars($_POST["announce_url4"]) . "';\n" .
"\$GLOBALS['max_upload_rate'] = " . htmlspecialchars($_POST['max_upload_rate']) . ";\n" .
"\$GLOBALS['max_uploads'] = " . htmlspecialchars($_POST['max_uploads']) . ";\n" .
"\$dateformat = '" . htmlspecialchars($_POST["dateformat"]) . "';\n" .
"\$timezone = '" . htmlspecialchars($_POST["timezone"]) . "';\n" .
"\$prefix = '" . htmlspecialchars($_POST["prefix"]) . "';\n" .
"?>"
);
fclose($fd);
}
else if (version_compare(PHP_VERSION, '5.4.0*', '<=')) {
$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['customtitle'] = " . $customtitle . ";\n" .
"\$GLOBALS['indexpagelimitspecify'] = " . htmlspecialchars($_POST["indexpagelimitspecify"]) . ";\n" .
"\$GLOBALS['statspagelimitspecify'] = " . htmlspecialchars($_POST["statspagelimitspecify"]) . ";\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 = '" . crypt($_POST["upload_username"].$_POST["upload_password"]) . "';\n" .
"\$admin_username = '" . htmlspecialchars($_POST["admin_username"]) . "';\n" .
"\$admin_password = '" . crypt($_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" .
"\$announce_url0 = '" . htmlspecialchars($_POST["announce_url0"]) . "';\n" .
"\$announce_url1 = '" . htmlspecialchars($_POST["announce_url1"]) . "';\n" .
"\$announce_url2 = '" . htmlspecialchars($_POST["announce_url2"]) . "';\n" .
"\$announce_url3 = '" . htmlspecialchars($_POST["announce_url3"]) . "';\n" .
"\$announce_url4 = '" . htmlspecialchars($_POST["announce_url4"]) . "';\n" .
"\$GLOBALS['max_upload_rate'] = " . htmlspecialchars($_POST['max_upload_rate']) . ";\n" .
"\$GLOBALS['max_uploads'] = " . htmlspecialchars($_POST['max_uploads']) . ";\n" .
"\$dateformat = '" . htmlspecialchars($_POST["dateformat"]) . "';\n" .
"\$timezone = '" . htmlspecialchars($_POST["timezone"]) . "';\n" .
"\$prefix = '" . htmlspecialchars($_POST["prefix"]) . "';\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 (version_compare(PHP_VERSION, '5.5.0*', '>='))
{
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 htmlentities($_SERVER['PHP_SELF']);?>">
<input type="hidden" name="download" value="1">
<input type="hidden" name="hiddentracker" value="<?php if (isset($_POST['hiddentracker']) AND $_POST['hiddentracker'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="scrape" value="<?php if (isset($_POST['scrape']) AND $_POST['scrape'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="customtitle" value="<?php if (isset($_POST['customtitle']) AND $_POST['customtitle'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="indexpagelimitspecify" value="<?php echo $_POST['indexpagelimitspecify'];?>">
<input type="hidden" name="statspagelimitspecify" value="<?php echo $_POST['statspagelimitspecify'];?>">
<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 (isset($_POST['NAT']) AND $_POST['NAT'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="persist" value="<?php if (isset($_POST['persist']) AND $_POST['persist'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="ip_override" value="<?php if (isset($_POST['ip_override']) AND $_POST['ip_override'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="countbytes" value="<?php if (isset($_POST['countbytes']) AND $_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 password_hash($_POST["upload_username"].$_POST["upload_password"], PASSWORD_BCRYPT);?>">
<input type="hidden" name="admin_username" value="<?php echo $_POST['admin_username'];?>">
<input type="hidden" name="admin_password" value="<?php echo password_hash($_POST["admin_username"].$_POST["admin_password"], PASSWORD_BCRYPT);?>">
<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 (isset($_POST['enablerss']) AND $_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="announce_url0" value="<?php echo $_POST['announce_url0'];?>">
<input type="hidden" name="announce_url1" value="<?php echo $_POST['announce_url1'];?>">
<input type="hidden" name="announce_url2" value="<?php echo $_POST['announce_url2'];?>">
<input type="hidden" name="announce_url3" value="<?php echo $_POST['announce_url3'];?>">
<input type="hidden" name="announce_url4" value="<?php echo $_POST['announce_url4'];?>">
<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="dateformat" value="<?php echo $_POST['dateformat'];?>">
<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
}
}
if (version_compare(PHP_VERSION, '5.4.0*', '<='))
{
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 htmlentities($_SERVER['PHP_SELF']);?>">
<input type="hidden" name="download" value="1">
<input type="hidden" name="hiddentracker" value="<?php if (isset($_POST['hiddentracker']) AND $_POST['hiddentracker'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="scrape" value="<?php if (isset($_POST['scrape']) AND $_POST['scrape'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="customtitle" value="<?php if (isset($_POST['customtitle']) AND $_POST['customtitle'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="indexpagelimitspecify" value="<?php echo $_POST['indexpagelimitspecify'];?>">
<input type="hidden" name="statspagelimitspecify" value="<?php echo $_POST['statspagelimitspecify'];?>">
<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 (isset($_POST['NAT']) AND $_POST['NAT'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="persist" value="<?php if (isset($_POST['persist']) AND $_POST['persist'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="ip_override" value="<?php if (isset($_POST['ip_override']) AND $_POST['ip_override'] == 'on') echo 'true'; else echo 'false';?>">
<input type="hidden" name="countbytes" value="<?php if (isset($_POST['countbytes']) AND $_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 crypt($_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 crypt($_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 (isset($_POST['enablerss']) AND $_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="announce_url0" value="<?php echo $_POST['announce_url0'];?>">
<input type="hidden" name="announce_url1" value="<?php echo $_POST['announce_url1'];?>">
<input type="hidden" name="announce_url2" value="<?php echo $_POST['announce_url2'];?>">
<input type="hidden" name="announce_url3" value="<?php echo $_POST['announce_url3'];?>">
<input type="hidden" name="announce_url4" value="<?php echo $_POST['announce_url4'];?>">
<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="dateformat" value="<?php echo $_POST['dateformat'];?>">
<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\"><img src=\"images/stats.png\" border=\"0\" class=\"icon\" alt=\"Tracker Statistics\" title=\"Tracker Statistics\" />Main Statistics Page</a></center>\n";
echo "</body></html>\n";
}
?>