-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.php
305 lines (270 loc) · 9.93 KB
/
check.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
<?php
//
// TorrentTrader v2.x
// $LastChangedDate: 2011-12-23 18:38:08 +0000 (Fri, 23 Dec 2011) $
// $LastChangedBy: dj-howarth1 $
//
// http://www.torrenttrader.org
//
//
error_reporting(E_ALL ^ E_NOTICE);
if ($_GET["phpinfo"] == 1){
echo "<br /><center><a href='check.php'>Back To Check</a></center><br /><br />";
phpinfo();
die();
}
function get_php_setting($val) {
$r =(ini_get($val) == '1' ? 1 : 0);
return $r ? 'ON' : 'OFF';
}
function writableCell( $folder, $relative=1, $text='' ) {
$writeable = '<b><font color="green">Writeable</font></b>';
$unwriteable = '<b><font color="red">Unwriteable</font></b>';
echo '<tr>';
echo '<td>' . $folder . '</td>';
echo '<td align="right">';
if ( $relative ) {
echo is_writable( "./$folder" ) ? $writeable : $unwriteable;
} else {
echo is_writable( "$folder" ) ? $writeable : $unwriteable;
}
echo '</td>';
echo '</tr>';
}
view();
function view() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TorrentTrader Check</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
td { vertical-align: top; }
</style>
</head>
<body>
<center>
<br /><b>TorrentTrader v2 Config Check<br />v1.7 - TorrentialStorm<br /><br /></b>
<input type="button" class="button" value="Check Again" onclick="window.location=window.location" /><br />
<a href="check.php?phpinfo=1">PHPInfo</a></center><br />
<b>Required Settings Check:</b><br />
<p>If any of these items are highlighted in red then please take actions to correct them. <br />
Failure to do so could lead to your TorrentTrader! installation not functioning correctly.</p>
<br />
This system check is designed for unix based servers, windows based servers may not give desired results<br />
<br />
<br />
<table cellpadding="3" cellspacing="1" style="border-collapse: collapse" border="1">
<tr>
<td>PHP version >= 4.3.0</td>
<td>
<?php
echo phpversion() < '4.3' ? '<b><font color="red">No</font> 4.3 or above required</b>' : '<b><font color="green">Yes</font></b>';
echo " - Your PHP version is ".phpversion();
?>
</td>
</tr>
<tr>
<td> - zlib compression support</td>
<td><?php echo extension_loaded('zlib') ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - XML support</td>
<td><?php echo extension_loaded('xml') ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - MySQL support</td>
<td><?php echo function_exists( 'mysql_connect' ) ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - curl support (Not required but external torrents may scrape faster)</td>
<td><?php echo function_exists( 'curl_init' ) ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - gmp support (Required for IPv6)</td>
<td><?php echo extension_loaded( 'gmp' ) ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - bcmath support (Required for IPv6)</td>
<td><?php echo extension_loaded( 'bcmath' ) ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - hash_hmac support (Recommended - For better password encryption)</td>
<td><?php echo function_exists( 'hash_hmac' ) ? '<b><font color="green">Available</font></b>' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td> - suhosin extension (Optional)</td>
<td><?php echo extension_loaded( 'suhosin' ) ? '<b><font color="green">Available</font></b><br /><br />Add to your php.ini (otherwise you may have issues):<br />suhosin.get.disallow_nul = Off<br />suhosin.request.disallow_nul = Off' : '<b><font color="red">Unavailable</font></b>'; ?></td>
</tr>
<tr>
<td>backend/config.php</td>
<td>
<?php
if (@file_exists('backend/config.php') && @is_writable( 'backend/config.php' )){
echo '<b><font color="red">Writeable</font></b><br />Warning: leaving backend/config.php writeable is a security risk';
} else {
echo '<b><font color="green">Unwriteable</font></b>';
}
?>
</td>
</tr>
<tr>
<td>Document Root<br /><i><font size="1">(Use this for your PATHS in config.php)</font></i></td>
<td><?php echo str_replace('\\', '/', getcwd()) ?></td>
</tr>
</table>
<br />
<p>These settings are recommended for PHP in order to ensure full compatibility with TorrentTrader!.
However, TorrentTrader! will still operate if your settings do not quite match the recommended.</p>
<table cellpadding="3" cellspacing="1" style="border-collapse: collapse" border="1">
<tr><td width="500px">Directive</td><td>Recommended</td><td>Actual</td></tr>
<?php
$php_recommended_settings = array(array ('Safe Mode','safe_mode','OFF'),
array ('Display Errors (Can be off, but does make debugging difficult.)','display_errors','ON'),
array ('File Uploads','file_uploads','ON'),
array ('Magic Quotes Runtime','magic_quotes_runtime','OFF'),
array ('Register Globals','register_globals','OFF'),
array ('Output Buffering','output_buffering','OFF'),
array ('Session auto start','session.auto_start','OFF'),
array ('allow_url_fopen (Required for external torrents)', 'allow_url_fopen', 'ON')
);
foreach ($php_recommended_settings as $phprec) {
?>
<tr>
<td><?php echo $phprec[0]; ?>:</td>
<td><?php echo $phprec[2]; ?>:</td>
<td><b>
<?php
if ( get_php_setting($phprec[1]) == $phprec[2] ) {
?>
<font color="green">
<?php
} else {
?>
<font color="red">
<?php
}
echo get_php_setting($phprec[1]);
?>
</font></b>
</td></tr>
<?php
}
?>
</table>
<br /><b>Directory and File Permissions Check:</b><br />
<p>In order for TorrentTrader! to function correctly it needs to be able to access or write to certain files or directories.<br />
If you see "Unwriteable" you need to change the permissions on the file or directory to 777 (directories) or 666 (files) so that TorrentTrader to write to it.
<br />The censor.txt should be chmodded to <b>600</b>.
</p>
<br />
<table cellpadding="3" cellspacing="1" style='border-collapse: collapse' border="1" >
<?php
writableCell( 'backups' );
writableCell( 'uploads' );
writableCell( 'uploads/images' );
writableCell( 'cache' );
writableCell( 'cache/get_row_count' );
writableCell( 'cache/queries' );
writableCell( 'import' );
writableCell( 'censor.txt', 1 );
?>
</table>
<br />
<?php
require_once("backend/mysql.php");
echo "<b>Table Status Check:</b><br /><br />";
if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass))
printf("<font color='#ff0000'><b>Failed to connect to database:</b></font> (%d) %s<br />", mysql_errno(), mysql_error());
else {
if (!@mysql_select_db($mysql_db))
printf("<font color='#ff0000'><b>Failed to select database:</b></font> (%d) %s<br />", mysql_errno(), mysql_error());
else {
$r = mysql_query("SHOW TABLES");
if (!$r)
printf("<font color='#ff0000'><b>Failed to list tables:</b></font> (%d) %s<br />", mysql_errno(), mysql_error());
else {
$tables = array();
while($rr=mysql_fetch_row($r))
$tables[] = $rr[0];
$arr[] = "announce";
$arr[] = "bans";
$arr[] = "blocks";
$arr[] = "categories";
$arr[] = "censor";
$arr[] = "comments";
$arr[] = "completed";
$arr[] = "countries";
$arr[] = "email_bans";
$arr[] = "faq";
$arr[] = "groups";
$arr[] = "guests";
$arr[] = "languages";
$arr[] = "log";
$arr[] = "messages";
$arr[] = "news";
$arr[] = "peers";
$arr[] = "pollanswers";
$arr[] = "polls";
$arr[] = "ratings";
$arr[] = "reports";
$arr[] = "rules";
$arr[] = "shoutbox";
$arr[] = "stylesheets";
$arr[] = "tasks";
$arr[] = "teams";
$arr[] = "torrentlang";
$arr[] = "torrents";
$arr[] = "users";
$arr[] = "warnings";
$arr[] = "forumcats";
$arr[] = "forum_topics";
$arr[] = "forum_posts";
$arr[] = "forum_forums";
$arr[] = "forum_readposts";
$arr[] = "sqlerr";
echo "<table cellpadding='3' cellspacing='1' style='border-collapse: collapse' border='1'>";
echo "<tr><th>Table</th><th>Status</th></tr>";
foreach ($arr as $t)
if (!in_array($t, $tables))
echo "<tr><td>$t</td><td align='right'><font color='#ff0000'><b>MISSING</b></font></td></tr>";
else
echo "<tr><td>$t</td><td align='right'><font color='green'><b>OK</b></font></td></tr>";
echo "</table>";
require("backend/config.php");
echo "<br /><br /><b>Default Theme:</b> ";
if (!is_numeric($site_config["default_theme"]))
echo "<font color='#ff0000'><b>Invalid.</b></font> (Not a number)";
else {
$res = mysql_query("SELECT uri FROM stylesheets WHERE id=$site_config[default_theme]");
if ($row = mysql_fetch_row($res)) {
if (file_exists("themes/$row[0]/header.php"))
echo "<font color='green'><b>Valid.</b></font> (ID: $site_config[default_theme], Path: themes/$row[0]/)";
else
echo "<font color='#ff0000'><b>Invalid.</b></font> (No header.php found)";
} else
echo "<font color='#ff0000'><b>Invalid.</b></font> (No theme found with ID $site_config[default_theme])";
}
echo "<br /><b>Default Language:</b> ";
if (!is_numeric($site_config["default_language"]))
echo "<font color='#ff0000'><b>Invalid.</b></font> (Not a number)";
else {
$res = mysql_query("SELECT uri FROM languages WHERE id=$site_config[default_language]");
if ($row = mysql_fetch_row($res)) {
if (file_exists("languages/$row[0]"))
echo "<font color='green'><b>Valid.</b></font> (ID: $site_config[default_language], Path: languages/$row[0])";
else
echo "<font color='#ff0000'><b>Invalid.</b></font> (File languages/$row[0] missing)";
} else
echo "<font color='#ff0000'><b>Invalid.</b></font> (No language found with ID $site_config[default_language])";
}
}
}
}
?>
</body>
</html>
<?php
}//end func
?>