6 |
kaklik |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/***************************************************************************
|
|
|
4 |
AutoIndex PHP Script, by Justin Hagstrom
|
|
|
5 |
-------------------
|
|
|
6 |
|
|
|
7 |
filename : index.php
|
|
|
8 |
version : 1.5.2
|
|
|
9 |
date : January 04, 2005
|
|
|
10 |
|
|
|
11 |
copyright : Copyright (C) 2002-2005 Justin Hagstrom
|
|
|
12 |
license : GNU General Public License (GPL)
|
|
|
13 |
|
|
|
14 |
website & forum : http://autoindex.sourceforge.net
|
|
|
15 |
e-mail : JustinHagstrom [at] yahoo [dot] com
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
AutoIndex PHP Script is free software; you can redistribute it and/or modify
|
|
|
19 |
it under the terms of the GNU General Public License as published by
|
|
|
20 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
21 |
(at your option) any later version.
|
|
|
22 |
|
|
|
23 |
AutoIndex PHP Script is distributed in the hope that it will be useful,
|
|
|
24 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
25 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
26 |
GNU General Public License for more details.
|
|
|
27 |
|
|
|
28 |
You should have received a copy of the GNU General Public License
|
|
|
29 |
along with this program; if not, write to the Free Software
|
|
|
30 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
31 |
|
|
|
32 |
***************************************************************************/
|
|
|
33 |
|
|
|
34 |
//some basic compatibility for PHP 4.0.x
|
|
|
35 |
if (!isset($_GET)) { $_GET = &$HTTP_GET_VARS; }
|
|
|
36 |
if (!isset($_POST)) { $_POST = &$HTTP_POST_VARS; }
|
|
|
37 |
if (!isset($_SESSION)) { $_SESSION = &$HTTP_SESSION_VARS; }
|
|
|
38 |
if (!isset($_SERVER)) { $_SERVER = &$HTTP_SERVER_VARS; }
|
|
|
39 |
if (!isset($_COOKIE)) { $_COOKIE = &$HTTP_COOKIE_VARS; }
|
|
|
40 |
if (!isset($_FILES)) { $_FILES = &$HTTP_POST_FILES; }
|
|
|
41 |
|
|
|
42 |
/* OPTIONAL SETTINGS */
|
|
|
43 |
|
|
|
44 |
$stored_config = 'AutoIndex.conf.php';
|
|
|
45 |
$config_generator = 'config.php';
|
|
|
46 |
|
|
|
47 |
$date_format = 'Y-M-d'; //see http://php.net/date
|
|
|
48 |
|
|
|
49 |
/* END OPTIONAL SETTINGS */
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
function get_microtime()
|
|
|
53 |
{
|
|
|
54 |
list($usec, $sec) = explode(' ', microtime());
|
|
|
55 |
return ((float)$usec + (float)$sec);
|
|
|
56 |
}
|
|
|
57 |
$start_time = get_microtime();
|
|
|
58 |
|
|
|
59 |
session_name('AutoIndex');
|
|
|
60 |
session_start();
|
|
|
61 |
|
|
|
62 |
if (@get_magic_quotes_gpc())
|
|
|
63 |
//remove any slashes added by the "magic quotes" setting
|
|
|
64 |
{
|
|
|
65 |
$_GET = array_map('stripslashes', $_GET);
|
|
|
66 |
$_POST = array_map('stripslashes', $_POST);
|
|
|
67 |
}
|
|
|
68 |
@set_magic_quotes_runtime(0);
|
|
|
69 |
|
|
|
70 |
if (ini_get('zlib.output_compression') == '1')
|
|
|
71 |
//compensate for compressed output set in php.ini
|
|
|
72 |
{
|
|
|
73 |
header('Content-Encoding: gzip');
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
define('VERSION', '1.5.2');
|
|
|
77 |
|
|
|
78 |
//now we need to include either the stored settings, or the config generator
|
|
|
79 |
if (@is_file($stored_config))
|
|
|
80 |
{
|
|
|
81 |
if (!@include($stored_config))
|
|
|
82 |
{
|
|
|
83 |
die("<p>Error including file <em>$stored_config</em></p>");
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
else if (@is_file($config_generator))
|
|
|
87 |
{
|
|
|
88 |
define('CONFIG', true);
|
|
|
89 |
if (!@include($config_generator))
|
|
|
90 |
{
|
|
|
91 |
die("<p>Error including file <em>$config_generator</em></p>");
|
|
|
92 |
}
|
|
|
93 |
die();
|
|
|
94 |
}
|
|
|
95 |
else
|
|
|
96 |
{
|
|
|
97 |
die("<p>Error: Neither <em>$config_generator</em> nor <em>$stored_config</em> could be found.</p>");
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
$this_file = (($index == '') ? $_SERVER['PHP_SELF'] : $index);
|
|
|
101 |
$this_file .= ((strpos($this_file, '?') !== false) ? '&' : '?');
|
|
|
102 |
$referrer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'N/A');
|
|
|
103 |
|
|
|
104 |
//make sure all the variables are set correctly from the stored settings
|
|
|
105 |
$config_vars = array('base_dir', 'icon_path', 'stylesheet', 'use_login_system',
|
|
|
106 |
'allow_uploads', 'must_login_to_download', 'user_list', 'allow_file_overwrites',
|
|
|
107 |
'log_file', 'dont_log_these_ips', 'download_count', 'links_file', 'lang',
|
|
|
108 |
'sub_folder_access', 'index', 'hidden_files', 'show_only_these_files',
|
|
|
109 |
'force_download', 'bandwidth_limit', 'anti_leech', 'enable_searching',
|
|
|
110 |
'show_dir_size', 'folder_expansion', 'show_folder_count', 'banned_list',
|
|
|
111 |
'md5_show', 'header', 'footer', 'header_per_folder', 'footer_per_folder',
|
|
|
112 |
'description_file', 'thumbnail_height', 'path_to_language_files', 'days_new',
|
|
|
113 |
'select_language', 'show_type_column', 'show_size_column', 'show_date_column');
|
|
|
114 |
foreach ($config_vars as $this_var)
|
|
|
115 |
{
|
|
|
116 |
if (!isset($$this_var))
|
|
|
117 |
{
|
|
|
118 |
die("<p>Error: AutoIndex is not configured properly.
|
|
|
119 |
<br />The variable <strong>$this_var</strong> is not set.</p>
|
|
|
120 |
<p>Delete <em>$stored_config</em> and then run <em>$config_generator</em>.</p>");
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
//find the language the script should be displayed in
|
|
|
125 |
if ($select_language && isset($_GET['lang'])
|
|
|
126 |
&& preg_match('/^[a-z]{2}(_[a-z]{2})?$/i', $_GET['lang'])
|
|
|
127 |
&& @is_file($path_to_language_files.$_GET['lang'].'.php'))
|
|
|
128 |
{
|
|
|
129 |
$_SESSION['lang'] = $_GET['lang'];
|
|
|
130 |
}
|
|
|
131 |
else if (!isset($_SESSION['lang']))
|
|
|
132 |
{
|
|
|
133 |
$_SESSION['lang'] = $lang;
|
|
|
134 |
}
|
|
|
135 |
@include($path_to_language_files.$_SESSION['lang'].'.php');
|
|
|
136 |
|
|
|
137 |
if (!isset($words))
|
|
|
138 |
{
|
|
|
139 |
die('<p>Error: You need to include a language.php file that has the variable $words.
|
|
|
140 |
<br />Check the $lang and $path_to_language_files variables.</p>');
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
$global_user_list = ($use_login_system ? @file($user_list) : array());
|
|
|
144 |
if ($global_user_list === false)
|
|
|
145 |
{
|
|
|
146 |
die("<p>Could not open file <strong>$user_list</strong></p>");
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
function translate_uri($uri)
|
|
|
150 |
//rawurlencodes $uri, but not any slashes
|
|
|
151 |
{
|
|
|
152 |
$uri = rawurlencode(str_replace('\\', '/', $uri));
|
|
|
153 |
return str_replace(rawurlencode('/'), '/', $uri);
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
function get_basename($fn)
|
|
|
157 |
//returns everything after the slash, or the original string if there is no slash
|
|
|
158 |
{
|
|
|
159 |
return basename(str_replace('\\', '/', $fn));
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
function match_in_array($string, &$array)
|
|
|
163 |
//returns true if $string matches anything in the array
|
|
|
164 |
{
|
|
|
165 |
$string = get_basename($string);
|
|
|
166 |
static $replace = array(
|
|
|
167 |
'\*' => '[^\/]*',
|
|
|
168 |
'\+' => '[^\/]+',
|
|
|
169 |
'\?' => '[^\/]?');
|
|
|
170 |
foreach ($array as $m)
|
|
|
171 |
{
|
|
|
172 |
if (preg_match('/^'.strtr(preg_quote(get_basename($m), '/'), $replace).'$/i', $string))
|
|
|
173 |
{
|
|
|
174 |
return true;
|
|
|
175 |
}
|
|
|
176 |
}
|
|
|
177 |
return false;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
function check_login($user, $pass)
|
|
|
181 |
{
|
|
|
182 |
global $global_user_list;
|
|
|
183 |
foreach ($global_user_list as $look)
|
|
|
184 |
{
|
|
|
185 |
if ((strcasecmp(substr(rtrim($look), 33), $user) === 0)
|
|
|
186 |
&& (strcasecmp(substr(rtrim($look), 0, 32), $pass) === 0))
|
|
|
187 |
{
|
|
|
188 |
return true;
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
return false;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
function logged_in()
|
|
|
195 |
{
|
|
|
196 |
return (isset($_SESSION['user'], $_SESSION['pass']) &&
|
|
|
197 |
check_login($_SESSION['user'], $_SESSION['pass']));
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
function is_user_admin($user)
|
|
|
201 |
{
|
|
|
202 |
global $global_user_list;
|
|
|
203 |
foreach ($global_user_list as $look)
|
|
|
204 |
{
|
|
|
205 |
if (strcasecmp($user, substr(rtrim($look), 33)) === 0)
|
|
|
206 |
{
|
|
|
207 |
return (substr($look, 32, 1) === '1');
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
return false;
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
function is_admin()
|
|
|
214 |
{
|
|
|
215 |
return is_user_admin($_SESSION['user']);
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
function is_hidden($fn, $is_file = true)
|
|
|
219 |
//looks at $hidden_files and $show_only_these_files to see if $fn is hidden
|
|
|
220 |
{
|
|
|
221 |
if ($fn == '')
|
|
|
222 |
{
|
|
|
223 |
return true;
|
|
|
224 |
}
|
|
|
225 |
global $use_login_system;
|
|
|
226 |
if ($use_login_system && logged_in() && is_admin())
|
|
|
227 |
//allow admins to view hidden files
|
|
|
228 |
{
|
|
|
229 |
return false;
|
|
|
230 |
}
|
|
|
231 |
global $hidden_files, $show_only_these_files;
|
|
|
232 |
if ($is_file && count($show_only_these_files))
|
|
|
233 |
{
|
|
|
234 |
return (!match_in_array($fn, $show_only_these_files));
|
|
|
235 |
}
|
|
|
236 |
if (!count($hidden_files))
|
|
|
237 |
{
|
|
|
238 |
return false;
|
|
|
239 |
}
|
|
|
240 |
return match_in_array($fn, $hidden_files);
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
function eval_dir($d)
|
|
|
244 |
//check $d for "bad" things, and deal with ".."
|
|
|
245 |
{
|
|
|
246 |
$d = str_replace('\\', '/', $d);
|
|
|
247 |
if ($d == '' || $d == '/')
|
|
|
248 |
{
|
|
|
249 |
return '';
|
|
|
250 |
}
|
|
|
251 |
$dirs = explode('/', $d);
|
|
|
252 |
for ($i=0; $i<count($dirs); $i++)
|
|
|
253 |
{
|
|
|
254 |
if ($dirs[$i] == '.' || is_hidden($dirs[$i], false))
|
|
|
255 |
{
|
|
|
256 |
array_splice($dirs, $i, 1);
|
|
|
257 |
$i--;
|
|
|
258 |
}
|
|
|
259 |
else if (preg_match('/^\.\./', $dirs[$i])) //if it starts with two dots
|
|
|
260 |
{
|
|
|
261 |
array_splice($dirs, $i-1, 2);
|
|
|
262 |
$i = -1;
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
$new_dir = implode('/', $dirs);
|
|
|
266 |
if ($new_dir == '' || $new_dir == '/')
|
|
|
267 |
{
|
|
|
268 |
return '';
|
|
|
269 |
}
|
|
|
270 |
if ($d{0} == '/' && $new_dir{0} != '/')
|
|
|
271 |
{
|
|
|
272 |
$new_dir = '/'.$new_dir;
|
|
|
273 |
}
|
|
|
274 |
if (preg_match('#/$#', $d) && !preg_match('#/$#', $new_dir))
|
|
|
275 |
{
|
|
|
276 |
$new_dir .= '/';
|
|
|
277 |
}
|
|
|
278 |
else if (is_hidden(get_basename($d)))
|
|
|
279 |
{
|
|
|
280 |
return '';
|
|
|
281 |
}
|
|
|
282 |
return $new_dir;
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
//get the user defined variables that are in the URL
|
|
|
286 |
$subdir = (isset($_GET['dir']) ? eval_dir(rawurldecode($_GET['dir'])) : '');
|
|
|
287 |
$file_dl = (isset($_GET['file']) ? rawurldecode($_GET['file']) : '');
|
|
|
288 |
$search = (isset($_GET['search']) ? $_GET['search'] : '');
|
|
|
289 |
$search_mode = (isset($_GET['searchMode']) ? $_GET['searchMode'] : '');
|
|
|
290 |
while (preg_match('#\\\\|/$#', $file_dl))
|
|
|
291 |
{
|
|
|
292 |
$file_dl = substr($file_dl, 0, -1);
|
|
|
293 |
}
|
|
|
294 |
$file_dl = eval_dir($file_dl);
|
|
|
295 |
|
|
|
296 |
if (!@is_dir($base_dir))
|
|
|
297 |
{
|
|
|
298 |
die('<p>Error: <em>'.htmlentities($base_dir)
|
|
|
299 |
.'</em> is not a valid directory.<br />Check the $base_dir variable.</p>');
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
if (!$sub_folder_access || $subdir == '/')
|
|
|
303 |
{
|
|
|
304 |
$subdir = '';
|
|
|
305 |
}
|
|
|
306 |
else if (preg_match('#[^/\\\\]$#', $subdir))
|
|
|
307 |
{
|
|
|
308 |
$subdir .= '/'; //add a slash to the end if there isn't one
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
$dir = $base_dir.$subdir;
|
|
|
312 |
|
|
|
313 |
//this will be displayed before any HTML output
|
|
|
314 |
$html_heading = '';
|
|
|
315 |
|
|
|
316 |
if ($index == '')
|
|
|
317 |
{
|
|
|
318 |
$html_heading .= '<?xml version="1.0" encoding="UTF-8"?>
|
|
|
319 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
|
320 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$_SESSION['lang'].'">
|
|
|
321 |
<head>';
|
|
|
322 |
}
|
|
|
323 |
if ($stylesheet != '')
|
|
|
324 |
{
|
|
|
325 |
$html_heading .= "\n<link rel=\"stylesheet\" href=\"$stylesheet\" type=\"text/css\" title=\"AutoIndex Default\" />\n";
|
|
|
326 |
}
|
|
|
327 |
if ($index == '')
|
|
|
328 |
{
|
|
|
329 |
$html_heading .= "\n<title>".$words['index of'].' '.htmlentities($dir)
|
|
|
330 |
."</title>\n\n</head><body class='autoindex_body'>\n\n";
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
function show_header()
|
|
|
334 |
{
|
|
|
335 |
global $header, $header_per_folder, $dir;
|
|
|
336 |
if ($header != '')
|
|
|
337 |
{
|
|
|
338 |
if ($header_per_folder)
|
|
|
339 |
{
|
|
|
340 |
$header = $dir.$header;
|
|
|
341 |
}
|
|
|
342 |
if (@is_readable($header))
|
|
|
343 |
{
|
|
|
344 |
include($header);
|
|
|
345 |
}
|
|
|
346 |
}
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
function show_footer()
|
|
|
350 |
{
|
|
|
351 |
global $footer, $footer_per_folder, $dir;
|
|
|
352 |
if ($footer != '')
|
|
|
353 |
{
|
|
|
354 |
if ($footer_per_folder)
|
|
|
355 |
{
|
|
|
356 |
$footer = $dir.$footer;
|
|
|
357 |
}
|
|
|
358 |
if (@is_readable($footer))
|
|
|
359 |
{
|
|
|
360 |
include($footer);
|
|
|
361 |
}
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
function show_login_box()
|
|
|
366 |
{
|
|
|
367 |
global $this_file, $subdir, $icon_path;
|
|
|
368 |
$sd = translate_uri($subdir);
|
|
|
369 |
echo '<p /><table border="0" cellpadding="8" cellspacing="0">
|
|
|
370 |
<tr class="paragraph"><td class="default_td"><img src="', $icon_path,
|
|
|
371 |
'/login.png" width="12" height="14" alt="Login" /> Login:',
|
|
|
372 |
"\n<form method='post' action='{$this_file}dir=$sd'>
|
|
|
373 |
<table><tr class=\"paragraph\"><td>Username:</td>
|
|
|
374 |
<td><input type='text' name='user' />
|
|
|
375 |
</td></tr><tr class=\"paragraph\"><td>Password:</td>
|
|
|
376 |
<td><input type='password' name='pass' /></td></tr></table>
|
|
|
377 |
<p><input class='button' type='submit' value='Login' /></p>
|
|
|
378 |
</form></td></tr></table>";
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
function show_search_box()
|
|
|
382 |
{
|
|
|
383 |
global $index, $search, $words, $search_mode, $this_file, $subdir, $icon_path;
|
|
|
384 |
echo '<p /><table border="0" cellpadding="8" cellspacing="0">
|
|
|
385 |
<tr class="paragraph"><td class="default_td"><img src="', $icon_path,
|
|
|
386 |
'/search.png" width="16" height="16" alt="', $words['search'], '" /> ',
|
|
|
387 |
$words['search'], ":<br /><form method='get' action='$this_file'>
|
|
|
388 |
<p><input type='text' name='search' value='$search' />\n";
|
|
|
389 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
390 |
{
|
|
|
391 |
$id_temp = explode('=', $index, 2);
|
|
|
392 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
393 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
394 |
}
|
|
|
395 |
echo "\n<input type='hidden' name='dir' value='", translate_uri($subdir),
|
|
|
396 |
"' /><br /><select name='searchMode'>\n";
|
|
|
397 |
$search_modes = array($words['files'] => 'f', $words['folders'] => 'd', $words['both'] => 'fd');
|
|
|
398 |
foreach ($search_modes as $key => $element)
|
|
|
399 |
{
|
|
|
400 |
$sel = (($search_mode == $element) ? ' selected="selected"' : '');
|
|
|
401 |
echo "\t<option$sel value='$element'>$key</option>\n";
|
|
|
402 |
}
|
|
|
403 |
echo "</select><input type='submit' value='", $words['search'],
|
|
|
404 |
'\' class="button" /></p></form></td></tr></table>';
|
|
|
405 |
}
|
|
|
406 |
|
|
|
407 |
function is_username($user)
|
|
|
408 |
{
|
|
|
409 |
global $html_heading, $global_user_list;
|
|
|
410 |
foreach ($global_user_list as $look)
|
|
|
411 |
{
|
|
|
412 |
if (strcasecmp($user, substr(rtrim($look), 33)) === 0)
|
|
|
413 |
{
|
|
|
414 |
return true;
|
|
|
415 |
}
|
|
|
416 |
}
|
|
|
417 |
return false;
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
function num_admins()
|
|
|
421 |
//returns the number of accounts with admin rights
|
|
|
422 |
{
|
|
|
423 |
global $html_heading, $global_user_list;
|
|
|
424 |
$num = 0;
|
|
|
425 |
foreach ($global_user_list as $look)
|
|
|
426 |
{
|
|
|
427 |
if (substr($look, 32, 1) === '1')
|
|
|
428 |
{
|
|
|
429 |
$num++;
|
|
|
430 |
}
|
|
|
431 |
}
|
|
|
432 |
return $num;
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
function get_filesize($size)
|
|
|
436 |
//give a size in bytes, and this will return the appropriate measurement format
|
|
|
437 |
{
|
|
|
438 |
$size = max(0, $size);
|
|
|
439 |
static $u = array(' B', 'KB', 'MB', 'GB');
|
|
|
440 |
for ($i=0; $size >= 1024 && $i < 4; $i++)
|
|
|
441 |
{
|
|
|
442 |
$size /= 1024;
|
|
|
443 |
}
|
|
|
444 |
return number_format($size, 1).' '.$u[$i];
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
function ext($fn)
|
|
|
448 |
//return the lowercase file extension of $fn, not including the leading dot
|
|
|
449 |
{
|
|
|
450 |
$fn = get_basename($fn);
|
|
|
451 |
return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : '');
|
|
|
452 |
}
|
|
|
453 |
|
|
|
454 |
function get_all_files($path)
|
|
|
455 |
//returns an array of every file in $path, including folders (except ./ and ../)
|
|
|
456 |
{
|
|
|
457 |
$list = array();
|
|
|
458 |
if (($hndl = @opendir($path)) === false)
|
|
|
459 |
{
|
|
|
460 |
return $list;
|
|
|
461 |
}
|
|
|
462 |
while (($file=readdir($hndl)) !== false)
|
|
|
463 |
{
|
|
|
464 |
if ($file != '.' && $file != '..')
|
|
|
465 |
{
|
|
|
466 |
$list[] = $file;
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
closedir($hndl);
|
|
|
470 |
return $list;
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
function get_file_list($path)
|
|
|
474 |
//returns a sorted array of filenames. Filters out "bad" files
|
|
|
475 |
{
|
|
|
476 |
global $sub_folder_access, $links_file;
|
|
|
477 |
$f = $d = array();
|
|
|
478 |
foreach (get_all_files($path) as $name)
|
|
|
479 |
{
|
|
|
480 |
if ($sub_folder_access && @is_dir($path.$name) && !is_hidden($name, false))
|
|
|
481 |
{
|
|
|
482 |
$d[] = $name;
|
|
|
483 |
}
|
|
|
484 |
else if (@is_file($path.$name) && !is_hidden($name, true))
|
|
|
485 |
{
|
|
|
486 |
$f[] = $name;
|
|
|
487 |
}
|
|
|
488 |
}
|
|
|
489 |
if ($links_file != '' && ($links = @file($path.$links_file)))
|
|
|
490 |
{
|
|
|
491 |
foreach ($links as $name)
|
|
|
492 |
{
|
|
|
493 |
$p = strpos($name, '|');
|
|
|
494 |
$f[] = (($p === false) ? rtrim($name).'|' : substr(rtrim($name), 0, $p).'|');
|
|
|
495 |
}
|
|
|
496 |
}
|
|
|
497 |
natcasesort($d);
|
|
|
498 |
natcasesort($f);
|
|
|
499 |
return array_merge($d, $f);
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
function dir_size($dir)
|
|
|
503 |
//returns the total size of a directory (recursive) in bytes
|
|
|
504 |
{
|
|
|
505 |
$totalsize = 0;
|
|
|
506 |
foreach (get_file_list($dir) as $name)
|
|
|
507 |
{
|
|
|
508 |
$totalsize += (@is_dir($dir.$name) ? dir_size("$dir$name/") : (int)@filesize($dir.$name));
|
|
|
509 |
}
|
|
|
510 |
return $totalsize;
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
function match_filename($filename, $string)
|
|
|
514 |
{
|
|
|
515 |
if (preg_match_all('/(?<=")[^"]+(?=")|[^ "]+/', $string, $matches))
|
|
|
516 |
{
|
|
|
517 |
foreach ($matches[0] as $w)
|
|
|
518 |
{
|
|
|
519 |
if (preg_match('#[^/\.]+#', $w) && stristr($filename, $w))
|
|
|
520 |
{
|
|
|
521 |
return true;
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
}
|
|
|
525 |
return false;
|
|
|
526 |
}
|
|
|
527 |
|
|
|
528 |
function search_dir($sdir, $string)
|
|
|
529 |
//returns files/folders (recursive) in $sdir that contain $string
|
|
|
530 |
{
|
|
|
531 |
global $search_mode;
|
|
|
532 |
//search_mode: d=folders, f=files, fd=both
|
|
|
533 |
|
|
|
534 |
$found = array();
|
|
|
535 |
$list = get_file_list($sdir);
|
|
|
536 |
$d = count($list);
|
|
|
537 |
for ($i=0; $i<$d; $i++)
|
|
|
538 |
{
|
|
|
539 |
$full_name = $sdir.$list[$i];
|
|
|
540 |
if (stristr($search_mode, 'f') && (@is_file($full_name) || preg_match('/\|$/', $list[$i])) && match_filename($list[$i], $string))
|
|
|
541 |
{
|
|
|
542 |
$found[] = $full_name;
|
|
|
543 |
}
|
|
|
544 |
else if (@is_dir($full_name))
|
|
|
545 |
{
|
|
|
546 |
if (stristr($search_mode, 'd') && match_filename($list[$i], $string))
|
|
|
547 |
{
|
|
|
548 |
$found[] = $full_name;
|
|
|
549 |
}
|
|
|
550 |
$found = array_merge($found, search_dir($full_name.'/', $string));
|
|
|
551 |
}
|
|
|
552 |
}
|
|
|
553 |
return $found;
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
function add_num_to_array($num, &$array)
|
|
|
557 |
{
|
|
|
558 |
isset($array[$num]) ? $array[$num]++ : $array[$num] = 1;
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
function mkdir_recursive($path)
|
|
|
562 |
{
|
|
|
563 |
if (@is_dir($path))
|
|
|
564 |
{
|
|
|
565 |
return true;
|
|
|
566 |
}
|
|
|
567 |
if (!mkdir_recursive(dirname($path)))
|
|
|
568 |
{
|
|
|
569 |
return false;
|
|
|
570 |
}
|
|
|
571 |
return @mkdir($path, 0755);
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
function rmdir_recursive($path)
|
|
|
575 |
{
|
|
|
576 |
if (!preg_match('#/$#', $path))
|
|
|
577 |
{
|
|
|
578 |
$path .= '/';
|
|
|
579 |
}
|
|
|
580 |
foreach (get_all_files($path) as $file)
|
|
|
581 |
{
|
|
|
582 |
if ($file == '' || $file == '.' || $file == '..')
|
|
|
583 |
{
|
|
|
584 |
continue;
|
|
|
585 |
}
|
|
|
586 |
if (@is_dir("$path$file/"))
|
|
|
587 |
{
|
|
|
588 |
rmdir_recursive("$path$file/");
|
|
|
589 |
}
|
|
|
590 |
else
|
|
|
591 |
{
|
|
|
592 |
@unlink($path . $file);
|
|
|
593 |
}
|
|
|
594 |
}
|
|
|
595 |
return @rmdir($path);
|
|
|
596 |
}
|
|
|
597 |
|
|
|
598 |
function num_files($dir)
|
|
|
599 |
//returns the number of files in $dir (recursive)
|
|
|
600 |
{
|
|
|
601 |
$count = 0;
|
|
|
602 |
if (!preg_match('#/$#', $dir))
|
|
|
603 |
{
|
|
|
604 |
$dir .= '/';
|
|
|
605 |
}
|
|
|
606 |
$list = get_file_list($dir);
|
|
|
607 |
$d = count($list);
|
|
|
608 |
for ($i=0; $i<$d; $i++)
|
|
|
609 |
{
|
|
|
610 |
$count += (@is_dir($dir.$list[$i]) ? num_files($dir.$list[$i]) : 1);
|
|
|
611 |
}
|
|
|
612 |
return $count;
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
function redirect($site)
|
|
|
616 |
{
|
|
|
617 |
header("Location: $site");
|
|
|
618 |
die('<p>Redirection header could not be sent.<br />'
|
|
|
619 |
."Continue here: <a href=\"$site\">$site</a></p>");
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
function find_mime_type($ext)
|
|
|
623 |
{
|
|
|
624 |
static $mime_types = array(
|
|
|
625 |
'application/andrew-inset' => array('ez'),
|
|
|
626 |
'application/mac-binhex40' => array('hqx'),
|
|
|
627 |
'application/mac-compactpro' => array('cpt'),
|
|
|
628 |
'application/mathml+xml' => array('mathml'),
|
|
|
629 |
'application/msword' => array('doc'),
|
|
|
630 |
'application/octet-stream' => array('bin', 'dms', 'lha',
|
|
|
631 |
'lzh', 'exe', 'class', 'so', 'dll', 'dmg'),
|
|
|
632 |
'application/oda' => array('oda'),
|
|
|
633 |
'application/ogg' => array('ogg'),
|
|
|
634 |
'application/pdf' => array('pdf'),
|
|
|
635 |
'application/postscript' => array('ai', 'eps', 'ps'),
|
|
|
636 |
'application/rdf+xml' => array('rdf'),
|
|
|
637 |
'application/smil' => array('smi', 'smil'),
|
|
|
638 |
'application/srgs' => array('gram'),
|
|
|
639 |
'application/srgs+xml' => array('grxml'),
|
|
|
640 |
'application/vnd.mif' => array('mif'),
|
|
|
641 |
'application/vnd.mozilla.xul+xml' => array('xul'),
|
|
|
642 |
'application/vnd.ms-excel' => array('xls'),
|
|
|
643 |
'application/vnd.ms-powerpoint' => array('ppt'),
|
|
|
644 |
'application/vnd.wap.wbxml' => array('wbxml'),
|
|
|
645 |
'application/vnd.wap.wmlc' => array('wmlc'),
|
|
|
646 |
'application/vnd.wap.wmlscriptc' => array('wmlsc'),
|
|
|
647 |
'application/voicexml+xml' => array('vxml'),
|
|
|
648 |
'application/x-bcpio' => array('bcpio'),
|
|
|
649 |
'application/x-cdlink' => array('vcd'),
|
|
|
650 |
'application/x-chess-pgn' => array('pgn'),
|
|
|
651 |
'application/x-cpio' => array('cpio'),
|
|
|
652 |
'application/x-csh' => array('csh'),
|
|
|
653 |
'application/x-director' => array('dcr', 'dir', 'dxr'),
|
|
|
654 |
'application/x-dvi' => array('dvi'),
|
|
|
655 |
'application/x-futuresplash' => array('spl'),
|
|
|
656 |
'application/x-gtar' => array('gtar'),
|
|
|
657 |
'application/x-hdf' => array('hdf'),
|
|
|
658 |
'application/x-javascript' => array('js'),
|
|
|
659 |
'application/x-koan' => array('skp', 'skd', 'skt', 'skm'),
|
|
|
660 |
'application/x-latex' => array('latex'),
|
|
|
661 |
'application/x-netcdf' => array('nc', 'cdf'),
|
|
|
662 |
'application/x-sh' => array('sh'),
|
|
|
663 |
'application/x-shar' => array('shar'),
|
|
|
664 |
'application/x-shockwave-flash' => array('swf'),
|
|
|
665 |
'application/x-stuffit' => array('sit'),
|
|
|
666 |
'application/x-sv4cpio' => array('sv4cpio'),
|
|
|
667 |
'application/x-sv4crc' => array('sv4crc'),
|
|
|
668 |
'application/x-tar' => array('tar'),
|
|
|
669 |
'application/x-tcl' => array('tcl'),
|
|
|
670 |
'application/x-tex' => array('tex'),
|
|
|
671 |
'application/x-texinfo' => array('texinfo', 'texi'),
|
|
|
672 |
'application/x-troff' => array('t', 'tr', 'roff'),
|
|
|
673 |
'application/x-troff-man' => array('man'),
|
|
|
674 |
'application/x-troff-me' => array('me'),
|
|
|
675 |
'application/x-troff-ms' => array('ms'),
|
|
|
676 |
'application/x-ustar' => array('ustar'),
|
|
|
677 |
'application/x-wais-source' => array('src'),
|
|
|
678 |
'application/xhtml+xml' => array('xhtml', 'xht'),
|
|
|
679 |
'application/xslt+xml' => array('xslt'),
|
|
|
680 |
'application/xml' => array('xml', 'xsl'),
|
|
|
681 |
'application/xml-dtd' => array('dtd'),
|
|
|
682 |
'application/zip' => array('zip'),
|
|
|
683 |
'audio/basic' => array('au', 'snd'),
|
|
|
684 |
'audio/midi' => array('mid', 'midi', 'kar'),
|
|
|
685 |
'audio/mpeg' => array('mpga', 'mp2', 'mp3'),
|
|
|
686 |
'audio/x-aiff' => array('aif', 'aiff', 'aifc'),
|
|
|
687 |
'audio/x-mpegurl' => array('m3u'),
|
|
|
688 |
'audio/x-pn-realaudio' => array('ram', 'ra'),
|
|
|
689 |
'application/vnd.rn-realmedia' => array('rm'),
|
|
|
690 |
'audio/x-wav' => array('wav'),
|
|
|
691 |
'chemical/x-pdb' => array('pdb'),
|
|
|
692 |
'chemical/x-xyz' => array('xyz'),
|
|
|
693 |
'image/bmp' => array('bmp'),
|
|
|
694 |
'image/cgm' => array('cgm'),
|
|
|
695 |
'image/gif' => array('gif'),
|
|
|
696 |
'image/ief' => array('ief'),
|
|
|
697 |
'image/jpeg' => array('jpeg', 'jpg', 'jpe'),
|
|
|
698 |
'image/png' => array('png'),
|
|
|
699 |
'image/svg+xml' => array('svg'),
|
|
|
700 |
'image/tiff' => array('tiff', 'tif'),
|
|
|
701 |
'image/vnd.djvu' => array('djvu', 'djv'),
|
|
|
702 |
'image/vnd.wap.wbmp' => array('wbmp'),
|
|
|
703 |
'image/x-cmu-raster' => array('ras'),
|
|
|
704 |
'image/x-icon' => array('ico'),
|
|
|
705 |
'image/x-portable-anymap' => array('pnm'),
|
|
|
706 |
'image/x-portable-bitmap' => array('pbm'),
|
|
|
707 |
'image/x-portable-graymap' => array('pgm'),
|
|
|
708 |
'image/x-portable-pixmap' => array('ppm'),
|
|
|
709 |
'image/x-rgb' => array('rgb'),
|
|
|
710 |
'image/x-xbitmap' => array('xbm'),
|
|
|
711 |
'image/x-xpixmap' => array('xpm'),
|
|
|
712 |
'image/x-xwindowdump' => array('xwd'),
|
|
|
713 |
'model/iges' => array('igs', 'iges'),
|
|
|
714 |
'model/mesh' => array('msh', 'mesh', 'silo'),
|
|
|
715 |
'model/vrml' => array('wrl', 'vrml'),
|
|
|
716 |
'text/calendar' => array('ics', 'ifb'),
|
|
|
717 |
'text/css' => array('css'),
|
|
|
718 |
'text/html' => array('html', 'htm'),
|
|
|
719 |
'text/plain' => array('asc', 'txt'),
|
|
|
720 |
'text/richtext' => array('rtx'),
|
|
|
721 |
'text/rtf' => array('rtf'),
|
|
|
722 |
'text/sgml' => array('sgml', 'sgm'),
|
|
|
723 |
'text/tab-separated-values' => array('tsv'),
|
|
|
724 |
'text/vnd.wap.wml' => array('wml'),
|
|
|
725 |
'text/vnd.wap.wmlscript' => array('wmls'),
|
|
|
726 |
'text/x-setext' => array('etx'),
|
|
|
727 |
'video/mpeg' => array('mpeg', 'mpg', 'mpe'),
|
|
|
728 |
'video/quicktime' => array('qt', 'mov'),
|
|
|
729 |
'video/vnd.mpegurl' => array('mxu', 'm4u'),
|
|
|
730 |
'video/x-msvideo' => array('avi'),
|
|
|
731 |
'video/x-sgi-movie' => array('movie'),
|
|
|
732 |
'x-conference/x-cooltalk' => array('ice')
|
|
|
733 |
);
|
|
|
734 |
foreach ($mime_types as $mime_type => $exts)
|
|
|
735 |
{
|
|
|
736 |
if (in_array($ext, $exts))
|
|
|
737 |
{
|
|
|
738 |
return $mime_type;
|
|
|
739 |
}
|
|
|
740 |
}
|
|
|
741 |
return 'text/plain';
|
|
|
742 |
}
|
|
|
743 |
|
|
|
744 |
function icon($ext)
|
|
|
745 |
//find the appropriate icon depending on the extension (returns a link to the image file)
|
|
|
746 |
{
|
|
|
747 |
global $icon_path;
|
|
|
748 |
if ($icon_path == '')
|
|
|
749 |
{
|
|
|
750 |
return '';
|
|
|
751 |
}
|
|
|
752 |
if ($ext == '')
|
|
|
753 |
{
|
|
|
754 |
$icon = 'generic';
|
|
|
755 |
}
|
|
|
756 |
else
|
|
|
757 |
{
|
|
|
758 |
$icon = 'unknown';
|
|
|
759 |
static $icon_types = array(
|
|
|
760 |
'binary' => array('bat', 'bin', 'com', 'dmg', 'dms', 'exe', 'msi',
|
|
|
761 |
'msp', 'pif', 'pyd', 'scr', 'so'),
|
|
|
762 |
'binhex' => array('hqx'),
|
|
|
763 |
'cd' => array('bwi', 'bws', 'bwt', 'ccd', 'cdi', 'cue', 'img',
|
|
|
764 |
'iso', 'mdf', 'mds', 'nrg', 'nri', 'sub', 'vcd'),
|
|
|
765 |
'comp' => array('cfg', 'conf', 'inf', 'ini', 'log', 'nfo', 'reg'),
|
|
|
766 |
'compressed' => array('7z', 'a', 'ace', 'ain', 'alz', 'amg', 'arc',
|
|
|
767 |
'ari', 'arj', 'bh', 'bz', 'bz2', 'cab', 'deb', 'dz', 'gz',
|
|
|
768 |
'io', 'ish', 'lha', 'lzh', 'lzs', 'lzw', 'lzx', 'msx', 'pak',
|
|
|
769 |
'rar', 'rpm', 'sar', 'sea', 'sit', 'taz', 'tbz', 'tbz2',
|
|
|
770 |
'tgz', 'tz', 'tzb', 'uc2', 'xxe', 'yz', 'z', 'zip', 'zoo'),
|
|
|
771 |
'dll' => array('386', 'db', 'dll', 'ocx', 'sdb', 'vxd'),
|
|
|
772 |
'doc' => array('abw', 'ans', 'chm', 'cwk', 'dif', 'doc', 'dot',
|
|
|
773 |
'mcw', 'msw', 'pdb', 'psw', 'rtf', 'rtx', 'sdw', 'stw', 'sxw',
|
|
|
774 |
'vor', 'wk4', 'wkb', 'wpd', 'wps', 'wpw', 'wri', 'wsd'),
|
|
|
775 |
'image' => array('adc', 'art', 'bmp', 'cgm', 'dib', 'gif', 'ico',
|
|
|
776 |
'ief', 'jfif', 'jif', 'jp2', 'jpc', 'jpe', 'jpeg', 'jpg', 'jpx',
|
|
|
777 |
'mng', 'pcx', 'png', 'psd', 'psp', 'swc', 'sxd', 'tga',
|
|
|
778 |
'tif', 'tiff', 'wmf', 'wpg', 'xcf', 'xif', 'yuv'),
|
|
|
779 |
'java' => array('class', 'jar', 'jav', 'java', 'jtk'),
|
|
|
780 |
'js' => array('ebs', 'js', 'jse', 'vbe', 'vbs', 'wsc', 'wsf',
|
|
|
781 |
'wsh'),
|
|
|
782 |
'key' => array('aex', 'asc', 'gpg', 'key', 'pgp', 'ppk'),
|
|
|
783 |
'mov' => array('amc', 'dv', 'm4v', 'mac', 'mov', 'mp4v', 'mpg4',
|
|
|
784 |
'pct', 'pic', 'pict', 'pnt', 'pntg', 'qpx', 'qt', 'qti',
|
|
|
785 |
'qtif', 'qtl', 'qtp', 'qts', 'qtx'),
|
|
|
786 |
'movie' => array('asf', 'asx', 'avi', 'div', 'divx', 'dvi', 'm1v',
|
|
|
787 |
'm2v', 'mkv', 'movie', 'mp2v', 'mpa', 'mpe', 'mpeg', 'mpg',
|
|
|
788 |
'mps', 'mpv', 'mpv2', 'ogm', 'ram', 'rmvb', 'rnx', 'rp', 'rv',
|
|
|
789 |
'vivo', 'vob', 'wmv', 'xvid'),
|
|
|
790 |
'pdf' => array('edn', 'fdf', 'pdf', 'pdp', 'pdx'),
|
|
|
791 |
'php' => array('inc', 'php', 'php3', 'php4', 'php5', 'phps',
|
|
|
792 |
'phtml'),
|
|
|
793 |
'ppt' => array('emf', 'pot', 'ppa', 'pps', 'ppt', 'sda', 'sdd',
|
|
|
794 |
'shw', 'sti', 'sxi'),
|
|
|
795 |
'ps' => array('ai', 'eps', 'ps'),
|
|
|
796 |
'sound' => array('aac', 'ac3', 'aif', 'aifc', 'aiff', 'ape', 'apl',
|
|
|
797 |
'au', 'ay', 'bonk', 'cda', 'cdda', 'cpc', 'fla', 'flac',
|
|
|
798 |
'gbs', 'gym', 'hes', 'iff', 'it', 'itz', 'kar', 'kss', 'la',
|
|
|
799 |
'lpac', 'lqt', 'm4a', 'm4p', 'mdz', 'mid', 'midi', 'mka',
|
|
|
800 |
'mo3', 'mod', 'mp+', 'mp1', 'mp2', 'mp3', 'mp4', 'mpc',
|
|
|
801 |
'mpga', 'mpm', 'mpp', 'nsf', 'oda', 'ofr', 'ogg', 'pac', 'pce',
|
|
|
802 |
'pcm', 'psf', 'psf2', 'ra', 'rm', 'rmi', 'rmjb', 'rmm', 'sb',
|
|
|
803 |
'shn', 'sid', 'snd', 'spc', 'spx', 'svx', 'tfm', 'tfmx',
|
|
|
804 |
'voc', 'vox', 'vqf', 'wav', 'wave', 'wma', 'wv', 'wvx', 'xa',
|
|
|
805 |
'xm', 'xmz'),
|
|
|
806 |
'tar' => array('gtar', 'tar'),
|
|
|
807 |
'text' => array('c', 'cc', 'cp', 'cpp', 'cxx', 'diff', 'h', 'hpp',
|
|
|
808 |
'hxx', 'm3u', 'md5', 'patch', 'pls', 'py', 'sfv', 'sh',
|
|
|
809 |
'txt'),
|
|
|
810 |
'uu' => array('uu', 'uud', 'uue'),
|
|
|
811 |
'web' => array('asa', 'asp', 'aspx', 'cfm', 'cgi', 'css', 'dhtml',
|
|
|
812 |
'dtd', 'grxml', 'htc', 'htm', 'html', 'htt', 'htx', 'jsp', 'lnk',
|
|
|
813 |
'mathml', 'mht', 'mhtml', 'perl', 'pl', 'plg', 'rss', 'shtm',
|
|
|
814 |
'shtml', 'stm', 'swf', 'tpl', 'wbxml', 'xht', 'xhtml', 'xml',
|
|
|
815 |
'xsl', 'xslt', 'xul'),
|
|
|
816 |
'xls' => array('csv', 'dbf', 'prn', 'pxl', 'sdc', 'slk', 'stc', 'sxc',
|
|
|
817 |
'xla', 'xlb', 'xlc', 'xld', 'xlr', 'xls', 'xlt', 'xlw'));
|
|
|
818 |
foreach ($icon_types as $png_name => $exts)
|
|
|
819 |
{
|
|
|
820 |
if (in_array($ext, $exts))
|
|
|
821 |
{
|
|
|
822 |
$icon = $png_name;
|
|
|
823 |
break;
|
|
|
824 |
}
|
|
|
825 |
}
|
|
|
826 |
}
|
|
|
827 |
return "<img alt=\"[$ext]\" height=\"16\" width=\"16\" src=\"$icon_path/$icon.png\" /> ";
|
|
|
828 |
}
|
|
|
829 |
|
|
|
830 |
function display_thumbnail($file, $thumbnail_height)
|
|
|
831 |
{
|
|
|
832 |
global $html_heading;
|
|
|
833 |
if (!@is_file($file))
|
|
|
834 |
{
|
|
|
835 |
header('HTTP/1.0 404 Not Found');
|
|
|
836 |
die("$html_heading<p>File not found: <em>".htmlentities($file).'</em></p>');
|
|
|
837 |
}
|
|
|
838 |
switch (ext($file))
|
|
|
839 |
{
|
|
|
840 |
case 'gif':
|
|
|
841 |
$src = @imagecreatefromgif($file);
|
|
|
842 |
break;
|
|
|
843 |
case 'jpeg':
|
|
|
844 |
case 'jpg':
|
|
|
845 |
case 'jpe':
|
|
|
846 |
$src = @imagecreatefromjpeg($file);
|
|
|
847 |
break;
|
|
|
848 |
case 'png':
|
|
|
849 |
$src = @imagecreatefrompng($file);
|
|
|
850 |
break;
|
|
|
851 |
default:
|
|
|
852 |
die("$html_heading<p>Unsupported file extension.</p>");
|
|
|
853 |
}
|
|
|
854 |
if ($src === false)
|
|
|
855 |
{
|
|
|
856 |
die("$html_heading<p>Unsupported image type.</p>");
|
|
|
857 |
}
|
|
|
858 |
|
|
|
859 |
header('Content-Type: image/jpeg');
|
|
|
860 |
header('Cache-Control: public, max-age=3600, must-revalidate');
|
|
|
861 |
header('Expires: '.gmdate('D, d M Y H:i:s', time()+3600).' GMT');
|
|
|
862 |
$src_height = imagesy($src);
|
|
|
863 |
if ($src_height <= $thumbnail_height)
|
|
|
864 |
{
|
|
|
865 |
imagejpeg($src, '', 95);
|
|
|
866 |
}
|
|
|
867 |
else
|
|
|
868 |
{
|
|
|
869 |
$src_width = imagesx($src);
|
|
|
870 |
$thumb_width = $thumbnail_height * ($src_width / $src_height);
|
|
|
871 |
$thumb = imagecreatetruecolor($thumb_width, $thumbnail_height);
|
|
|
872 |
imagecopyresampled($thumb, $src, 0, 0, 0, 0, $thumb_width,
|
|
|
873 |
$thumbnail_height, $src_width, $src_height);
|
|
|
874 |
imagejpeg($thumb);
|
|
|
875 |
imagedestroy($thumb);
|
|
|
876 |
}
|
|
|
877 |
imagedestroy($src);
|
|
|
878 |
die();
|
|
|
879 |
}
|
|
|
880 |
|
|
|
881 |
function edit_description($fn, &$desc)
|
|
|
882 |
//edits a file's description
|
|
|
883 |
{
|
|
|
884 |
global $description_file, $html_heading;
|
|
|
885 |
if ($description_file == '')
|
|
|
886 |
{
|
|
|
887 |
return;
|
|
|
888 |
}
|
|
|
889 |
$wrote = false;
|
|
|
890 |
$l = @file($description_file) or $l = array();
|
|
|
891 |
$h = @fopen($description_file, 'wb') or die("$html_heading<p>Cannot open description file for writing.</p>");
|
|
|
892 |
$count_num = count($l);
|
|
|
893 |
for ($i=0; $i<$count_num; $i++)
|
|
|
894 |
{
|
|
|
895 |
$items = explode('|', rtrim($l[$i]), 2);
|
|
|
896 |
if (count($items) === 2 && $fn == $items[0])
|
|
|
897 |
{
|
|
|
898 |
fwrite($h, "$fn|$desc\n");
|
|
|
899 |
$wrote = true;
|
|
|
900 |
}
|
|
|
901 |
else
|
|
|
902 |
{
|
|
|
903 |
fwrite($h, $l[$i]);
|
|
|
904 |
}
|
|
|
905 |
}
|
|
|
906 |
if (!$wrote && $desc != '')
|
|
|
907 |
{
|
|
|
908 |
fwrite($h, "$fn|$desc\n");
|
|
|
909 |
}
|
|
|
910 |
fclose($h);
|
|
|
911 |
}
|
|
|
912 |
|
|
|
913 |
function add_to_file($item, $outfile)
|
|
|
914 |
{
|
|
|
915 |
global $html_heading;
|
|
|
916 |
$counted = false;
|
|
|
917 |
if ($l = @file($outfile))
|
|
|
918 |
{
|
|
|
919 |
$count_num = count($l);
|
|
|
920 |
for ($i=0; $i<$count_num; $i++)
|
|
|
921 |
{
|
|
|
922 |
$thisc = rtrim($l[$i]);
|
|
|
923 |
if ($item == substr($thisc, 0, strpos($thisc, '|')))
|
|
|
924 |
{
|
|
|
925 |
$counted = true;
|
|
|
926 |
break;
|
|
|
927 |
}
|
|
|
928 |
}
|
|
|
929 |
}
|
|
|
930 |
if ($counted)
|
|
|
931 |
{
|
|
|
932 |
$w = @fopen($outfile, 'wb') or die("$html_heading<p>Could not open <em>$outfile</em> file for writing.</p>");
|
|
|
933 |
for ($i=0; $i<$count_num; $i++)
|
|
|
934 |
{
|
|
|
935 |
$items = explode('|', rtrim($l[$i]), 2);
|
|
|
936 |
if (count($items) === 2 && $items[0] == $item)
|
|
|
937 |
{
|
|
|
938 |
$nc = $items[1] + 1;
|
|
|
939 |
fwrite($w, "$item|$nc\n");
|
|
|
940 |
}
|
|
|
941 |
else
|
|
|
942 |
{
|
|
|
943 |
fwrite($w, $l[$i]);
|
|
|
944 |
}
|
|
|
945 |
}
|
|
|
946 |
}
|
|
|
947 |
else
|
|
|
948 |
{
|
|
|
949 |
$w = @fopen($outfile, 'ab') or die("$html_heading<p>Could not open <em>$outfile</em> file for writing.</p>");
|
|
|
950 |
fwrite($w, "$item|1\n");
|
|
|
951 |
}
|
|
|
952 |
fclose($w);
|
|
|
953 |
}
|
|
|
954 |
|
|
|
955 |
function get_stored_info($item, $filename)
|
|
|
956 |
{
|
|
|
957 |
if ($contents = @file($filename))
|
|
|
958 |
{
|
|
|
959 |
$count_num = count($contents);
|
|
|
960 |
for ($i=0; $i<$count_num; $i++)
|
|
|
961 |
{
|
|
|
962 |
$items = explode('|', rtrim($contents[$i]), 2);
|
|
|
963 |
if (count($items) === 2 && $item == $items[0])
|
|
|
964 |
{
|
|
|
965 |
return $items[1];
|
|
|
966 |
}
|
|
|
967 |
}
|
|
|
968 |
}
|
|
|
969 |
return '';
|
|
|
970 |
}
|
|
|
971 |
|
|
|
972 |
function table_heading($title, $sortMode, $tooltip)
|
|
|
973 |
{
|
|
|
974 |
global $this_file, $subdir;
|
|
|
975 |
echo "\n<th class='default_th'><a class='black_link' title=\"$tooltip\" href=\"",
|
|
|
976 |
$this_file, 'dir=', translate_uri($subdir), '&sort=',
|
|
|
977 |
(($_SESSION['sort'] == 'a' && $_SESSION['sortMode'] == $sortMode) ? 'd' : 'a'),
|
|
|
978 |
'&sortMode=', $sortMode, '">', $title, '</a></th>';
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
//find and store the user's IP address and hostname:
|
|
|
982 |
$ip = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'N/A');
|
|
|
983 |
if (isset($_SESSION['host']))
|
|
|
984 |
{
|
|
|
985 |
$host = $_SESSION['host'];
|
|
|
986 |
}
|
|
|
987 |
else
|
|
|
988 |
{
|
|
|
989 |
$_SESSION['host'] = $host = @gethostbyaddr($ip);
|
|
|
990 |
}
|
|
|
991 |
|
|
|
992 |
if ($banned_list != '' && ($b_list = @file($banned_list)))
|
|
|
993 |
//make sure the IP or hostname is not banned
|
|
|
994 |
{
|
|
|
995 |
for ($i=0; $i<count($b_list); $i++)
|
|
|
996 |
{
|
|
|
997 |
$b_list[$i] = rtrim($b_list[$i]);
|
|
|
998 |
}
|
|
|
999 |
if (match_in_array($ip, $b_list) || match_in_array($host, $b_list))
|
|
|
1000 |
{
|
|
|
1001 |
echo $html_heading;
|
|
|
1002 |
show_header();
|
|
|
1003 |
echo '<p>Sorry, the administrator has blocked your IP address or hostname.</p>';
|
|
|
1004 |
show_footer();
|
|
|
1005 |
die();
|
|
|
1006 |
}
|
|
|
1007 |
}
|
|
|
1008 |
|
|
|
1009 |
function ok_to_log()
|
|
|
1010 |
//returns true if the ip or hostname is not in $dont_log_these_ips
|
|
|
1011 |
{
|
|
|
1012 |
global $ip, $host, $dont_log_these_ips;
|
|
|
1013 |
return (!(match_in_array($ip, $dont_log_these_ips) ||
|
|
|
1014 |
($host != 'N/A' && match_in_array($host, $dont_log_these_ips))));
|
|
|
1015 |
}
|
|
|
1016 |
|
|
|
1017 |
if ($use_login_system && isset($_POST['user'], $_POST['pass'])
|
|
|
1018 |
&& $_POST['user'] != '' && $_POST['pass'] != '')
|
|
|
1019 |
//check login
|
|
|
1020 |
{
|
|
|
1021 |
if (check_login($_POST['user'], md5($_POST['pass'])))
|
|
|
1022 |
{
|
|
|
1023 |
if ($log_file != '' && ok_to_log())
|
|
|
1024 |
{
|
|
|
1025 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
1026 |
{
|
|
|
1027 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
1028 |
."\t$ip\t$host\t$referrer\t$dir\tSuccessful Login (username: "
|
|
|
1029 |
.$_POST['user'].")\n");
|
|
|
1030 |
fclose($write);
|
|
|
1031 |
}
|
|
|
1032 |
}
|
|
|
1033 |
$_SESSION['user'] = $_POST['user'];
|
|
|
1034 |
$_SESSION['pass'] = md5($_POST['pass']);
|
|
|
1035 |
unset($_POST['pass'], $_POST['user']);
|
|
|
1036 |
redirect($this_file.'dir='.translate_uri($subdir));
|
|
|
1037 |
}
|
|
|
1038 |
else
|
|
|
1039 |
{
|
|
|
1040 |
echo '<h3>Invalid Login.</h3>';
|
|
|
1041 |
if ($log_file != '' && ok_to_log())
|
|
|
1042 |
{
|
|
|
1043 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
1044 |
{
|
|
|
1045 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
1046 |
."\t$ip\t$host\t$referrer\t$dir\tInvalid Login (username: "
|
|
|
1047 |
.$_POST['user'].")\n");
|
|
|
1048 |
fclose($write);
|
|
|
1049 |
}
|
|
|
1050 |
}
|
|
|
1051 |
sleep(1); //"freeze" the script for a second to prevent brute force attacks
|
|
|
1052 |
}
|
|
|
1053 |
}
|
|
|
1054 |
|
|
|
1055 |
if ($use_login_system && $must_login_to_download && !logged_in())
|
|
|
1056 |
//must login to download
|
|
|
1057 |
{
|
|
|
1058 |
echo $html_heading;
|
|
|
1059 |
show_header();
|
|
|
1060 |
echo '<p>You must login to download and view files.</p>';
|
|
|
1061 |
show_login_box();
|
|
|
1062 |
show_footer();
|
|
|
1063 |
die();
|
|
|
1064 |
}
|
|
|
1065 |
|
|
|
1066 |
if ($md5_show && isset($_GET['md5']))
|
|
|
1067 |
{
|
|
|
1068 |
$file = $dir.eval_dir(rawurldecode($_GET['md5']));
|
|
|
1069 |
if (!@is_file($file))
|
|
|
1070 |
{
|
|
|
1071 |
header('HTTP/1.0 404 Not Found');
|
|
|
1072 |
die($html_heading.'<p>Error: file does not exist.</p>');
|
|
|
1073 |
}
|
|
|
1074 |
$size = (int)@filesize($file);
|
|
|
1075 |
if ($size <= 0 || $size/1048576 > $md5_show)
|
|
|
1076 |
{
|
|
|
1077 |
die($html_heading.'<p><strong>Error</strong>: empty file, or file too big to find the md5sum of (according to the $md5_show variable).</p>');
|
|
|
1078 |
}
|
|
|
1079 |
die(md5_file($file));
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
if ($thumbnail_height > 0 && isset($_GET['thumbnail']) && $_GET['thumbnail'] != '')
|
|
|
1083 |
{
|
|
|
1084 |
$file = $dir.eval_dir(rawurldecode($_GET['thumbnail']));
|
|
|
1085 |
display_thumbnail($file, $thumbnail_height);
|
|
|
1086 |
}
|
|
|
1087 |
|
|
|
1088 |
if (isset($_GET['sort']))
|
|
|
1089 |
{
|
|
|
1090 |
$_SESSION['sort'] = $_GET['sort'];
|
|
|
1091 |
}
|
|
|
1092 |
else if (!isset($_SESSION['sort']))
|
|
|
1093 |
{
|
|
|
1094 |
//'a' is ascending, 'd' is descending
|
|
|
1095 |
$_SESSION['sort'] = 'a';
|
|
|
1096 |
}
|
|
|
1097 |
|
|
|
1098 |
if (isset($_GET['sortMode']))
|
|
|
1099 |
{
|
|
|
1100 |
$_SESSION['sortMode'] = $_GET['sortMode'];
|
|
|
1101 |
}
|
|
|
1102 |
else if (!isset($_SESSION['sortMode']))
|
|
|
1103 |
{
|
|
|
1104 |
/*
|
|
|
1105 |
* 'f' is filename
|
|
|
1106 |
* 't' is filetype
|
|
|
1107 |
* 'h' is downloads (hits)
|
|
|
1108 |
* 's' is size
|
|
|
1109 |
* 'm' is date (modified)
|
|
|
1110 |
* 'd' is description
|
|
|
1111 |
*/
|
|
|
1112 |
$_SESSION['sortMode'] = 'f';
|
|
|
1113 |
}
|
|
|
1114 |
|
|
|
1115 |
//size of the "chunks" that are read at a time from the file (when $force_download is on)
|
|
|
1116 |
$speed = ($bandwidth_limit ? $bandwidth_limit : 8);
|
|
|
1117 |
|
|
|
1118 |
if ($folder_expansion)
|
|
|
1119 |
{
|
|
|
1120 |
if (!isset($_SESSION['expanded']))
|
|
|
1121 |
{
|
|
|
1122 |
$_SESSION['expanded'] = array();
|
|
|
1123 |
}
|
|
|
1124 |
if (isset($_GET['expand']) && $_GET['expand'] != '')
|
|
|
1125 |
{
|
|
|
1126 |
$temp = $dir.eval_dir(rawurldecode($_GET['expand']));
|
|
|
1127 |
if (@is_dir($temp) && !in_array($temp, $_SESSION['expanded']))
|
|
|
1128 |
{
|
|
|
1129 |
$_SESSION['expanded'][] = $temp;
|
|
|
1130 |
}
|
|
|
1131 |
}
|
|
|
1132 |
if (isset($_GET['collapse']) && $_GET['collapse'] != '')
|
|
|
1133 |
{
|
|
|
1134 |
$temp = $dir.eval_dir(rawurldecode($_GET['collapse']));
|
|
|
1135 |
if (in_array($temp, $_SESSION['expanded']))
|
|
|
1136 |
{
|
|
|
1137 |
array_splice($_SESSION['expanded'], array_search($temp, $_SESSION['expanded']), 1);
|
|
|
1138 |
}
|
|
|
1139 |
}
|
|
|
1140 |
}
|
|
|
1141 |
|
|
|
1142 |
if ($allow_uploads && (!$use_login_system || logged_in()))
|
|
|
1143 |
//upload a file
|
|
|
1144 |
{
|
|
|
1145 |
if ($count_files = count($_FILES))
|
|
|
1146 |
{
|
|
|
1147 |
echo $html_heading;
|
|
|
1148 |
show_header();
|
|
|
1149 |
$uploaded_files = $errors = '';
|
|
|
1150 |
for ($i=0; $i<$count_files; $i++)
|
|
|
1151 |
{
|
|
|
1152 |
$filename = get_basename($_FILES[$i]['name']);
|
|
|
1153 |
if ($filename == '')
|
|
|
1154 |
{
|
|
|
1155 |
continue;
|
|
|
1156 |
}
|
|
|
1157 |
if (is_hidden($filename))
|
|
|
1158 |
{
|
|
|
1159 |
$errors .= "<li>$filename [filename is listed as a hidden file]</li>";
|
|
|
1160 |
continue;
|
|
|
1161 |
}
|
|
|
1162 |
$filepath = $base_dir.eval_dir(rawurldecode($_POST['dir']));
|
|
|
1163 |
$fullpathname = realpath($filepath).'/'.$filename;
|
|
|
1164 |
if (!$allow_file_overwrites && @file_exists($fullpathname))
|
|
|
1165 |
{
|
|
|
1166 |
$errors .= "<li>$filename [file already exists]</li>";
|
|
|
1167 |
}
|
|
|
1168 |
else if (@move_uploaded_file($_FILES[$i]['tmp_name'], $fullpathname))
|
|
|
1169 |
{
|
|
|
1170 |
@chmod($fullpathname, 0644);
|
|
|
1171 |
$uploaded_files .= "<li>$filename</li>";
|
|
|
1172 |
if ($log_file != '' && ok_to_log() && ($write = @fopen($log_file, 'ab')))
|
|
|
1173 |
{
|
|
|
1174 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
1175 |
. "\t$ip\t$host\t$referrer\t$dir\tFile uploaded: $filepath$filename\n");
|
|
|
1176 |
fclose($write);
|
|
|
1177 |
}
|
|
|
1178 |
}
|
|
|
1179 |
else
|
|
|
1180 |
{
|
|
|
1181 |
$errors .= "<li>$filename</li>";
|
|
|
1182 |
}
|
|
|
1183 |
}
|
|
|
1184 |
if ($errors == '')
|
|
|
1185 |
{
|
|
|
1186 |
$errors = '<br />[None]';
|
|
|
1187 |
}
|
|
|
1188 |
if ($uploaded_files == '')
|
|
|
1189 |
{
|
|
|
1190 |
$uploaded_files = '<br />[None]';
|
|
|
1191 |
}
|
|
|
1192 |
echo "<p><strong>Uploaded files</strong>: $uploaded_files</p><p><strong>Failed files</strong>: $errors</p>",
|
|
|
1193 |
'<p><a class="default_a" href="', $this_file, 'dir=',
|
|
|
1194 |
$_POST['dir'], '">Continue.</a></p>';
|
|
|
1195 |
show_footer();
|
|
|
1196 |
die();
|
|
|
1197 |
}
|
|
|
1198 |
else if (isset($_POST['numUpload']))
|
|
|
1199 |
{
|
|
|
1200 |
echo $html_heading;
|
|
|
1201 |
show_header();
|
|
|
1202 |
echo "<table border='0' cellpadding='8' cellspacing='0'><tr class='paragraph'><td class='default_td'>
|
|
|
1203 |
<form enctype='multipart/form-data' action='$this_file' method='post'>
|
|
|
1204 |
<input type='hidden' name='dir' value='", $_POST['dir'], "' />\n";
|
|
|
1205 |
$num = (int)$_POST['numUpload'];
|
|
|
1206 |
for ($i=0; $i<$num; $i++)
|
|
|
1207 |
{
|
|
|
1208 |
$n = $i + 1;
|
|
|
1209 |
echo "\t\t{$words['file']} $n : <input name='$i' type='file' /><br />\n";
|
|
|
1210 |
}
|
|
|
1211 |
echo '<p><input class="button" type="submit" value="Upload Files" />
|
|
|
1212 |
</p></form></td></tr></table>';
|
|
|
1213 |
show_footer();
|
|
|
1214 |
die();
|
|
|
1215 |
}
|
|
|
1216 |
}
|
|
|
1217 |
|
|
|
1218 |
if ($use_login_system && logged_in() && is_admin())
|
|
|
1219 |
{
|
|
|
1220 |
$con = '<p><a class="default_a" href="'.$this_file.'dir='
|
|
|
1221 |
.translate_uri($subdir).'">Continue.</a></p>';
|
|
|
1222 |
|
|
|
1223 |
if (isset($_GET['getcreate']))
|
|
|
1224 |
{
|
|
|
1225 |
echo $html_heading;
|
|
|
1226 |
show_header();
|
|
|
1227 |
echo "<table border='0' cellpadding='8' cellspacing='0'><tr class='paragraph'><td class='default_td'>
|
|
|
1228 |
Enter the name of the folder you would like to create:
|
|
|
1229 |
<form method='get' action='$this_file'>
|
|
|
1230 |
<input type='hidden' name='dir' value='", translate_uri($subdir), "' />";
|
|
|
1231 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1232 |
{
|
|
|
1233 |
$id_temp = explode('=', $index, 2);
|
|
|
1234 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1235 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1236 |
}
|
|
|
1237 |
echo '<p><input type="text" name="create" /></p>
|
|
|
1238 |
<p><input class="button" type="submit" value="Create" /></p>
|
|
|
1239 |
</form></td></tr></table>';
|
|
|
1240 |
show_footer();
|
|
|
1241 |
die();
|
|
|
1242 |
}
|
|
|
1243 |
else if (isset($_GET['create']) && $_GET['create'] != '')
|
|
|
1244 |
{
|
|
|
1245 |
$p = $dir.eval_dir($_GET['create']);
|
|
|
1246 |
$msg = (@file_exists($p) ? 'Folder already exists: ' : (mkdir_recursive($p) ? 'Folder successfully created: ' : 'Could not create folder: '));
|
|
|
1247 |
echo $html_heading;
|
|
|
1248 |
show_header();
|
|
|
1249 |
echo $msg, htmlentities($p), $con;
|
|
|
1250 |
show_footer();
|
|
|
1251 |
die();
|
|
|
1252 |
}
|
|
|
1253 |
else if ($description_file != '' && isset($_GET['descFile']) && $_GET['descFile'] != '')
|
|
|
1254 |
{
|
|
|
1255 |
if (isset($_GET['desc']))
|
|
|
1256 |
{
|
|
|
1257 |
$desc = trim(rawurldecode($_GET['desc']));
|
|
|
1258 |
$descFile = trim(rawurldecode($_GET['descFile']));
|
|
|
1259 |
edit_description($dir.$descFile, $desc);
|
|
|
1260 |
}
|
|
|
1261 |
else
|
|
|
1262 |
{
|
|
|
1263 |
$filen = rawurldecode($_GET['descFile']);
|
|
|
1264 |
echo $html_heading;
|
|
|
1265 |
show_header();
|
|
|
1266 |
echo "<table border='0' cellpadding='8' cellspacing='0'>
|
|
|
1267 |
<tr class='paragraph'><td class='default_td'>
|
|
|
1268 |
Enter the new description for the file <em>$filen</em>:
|
|
|
1269 |
<form method='get' action='$this_file'>
|
|
|
1270 |
<input type='hidden' name='dir' value='", translate_uri($subdir), "' />
|
|
|
1271 |
<input type='hidden' name='descFile' value='", translate_uri($filen), '\' />';
|
|
|
1272 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1273 |
{
|
|
|
1274 |
$id_temp = explode('=', $index, 2);
|
|
|
1275 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1276 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1277 |
}
|
|
|
1278 |
echo '<p><input type="text" name="desc" size="50" value="',
|
|
|
1279 |
get_stored_info($dir.$filen, $description_file), '" /></p>
|
|
|
1280 |
<p><input class="button" type="submit" value="Change" /></p>
|
|
|
1281 |
</form></td></tr></table>';
|
|
|
1282 |
show_footer();
|
|
|
1283 |
die();
|
|
|
1284 |
}
|
|
|
1285 |
}
|
|
|
1286 |
else if (isset($_GET['edit_links']))
|
|
|
1287 |
{
|
|
|
1288 |
echo $html_heading;
|
|
|
1289 |
show_header();
|
|
|
1290 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
1291 |
<tr class="paragraph"><td class="default_td">';
|
|
|
1292 |
if ($links_file == '')
|
|
|
1293 |
{
|
|
|
1294 |
echo '<p>The link system is not in use.<br />To turn it on, set the $links_file variable.</p>';
|
|
|
1295 |
}
|
|
|
1296 |
else if (isset($_GET['link'], $_GET['name']) && $_GET['link'] != '')
|
|
|
1297 |
{
|
|
|
1298 |
if ($handle = @fopen($dir.$links_file, 'ab'))
|
|
|
1299 |
{
|
|
|
1300 |
fwrite($handle, $_GET['link'].'|'.$_GET['name']."\n");
|
|
|
1301 |
fclose($handle);
|
|
|
1302 |
echo '<p>Link added.</p>';
|
|
|
1303 |
}
|
|
|
1304 |
else
|
|
|
1305 |
{
|
|
|
1306 |
echo '<p>Could not open links_file for writing.</p>';
|
|
|
1307 |
}
|
|
|
1308 |
}
|
|
|
1309 |
else if (isset($_GET['remove']))
|
|
|
1310 |
{
|
|
|
1311 |
if (($list = @file($dir.$links_file)) && ($handle = @fopen($dir.$links_file, 'wb')))
|
|
|
1312 |
{
|
|
|
1313 |
for ($i=0; $i<count($list); $i++)
|
|
|
1314 |
{
|
|
|
1315 |
if (rtrim($list[$i]) != rtrim($_GET['remove']))
|
|
|
1316 |
{
|
|
|
1317 |
fwrite($handle, $list[$i]);
|
|
|
1318 |
}
|
|
|
1319 |
}
|
|
|
1320 |
fclose($handle);
|
|
|
1321 |
echo '<p>Link removed.</p>';
|
|
|
1322 |
}
|
|
|
1323 |
else
|
|
|
1324 |
{
|
|
|
1325 |
echo '<p>Could not open links_file.</p>';
|
|
|
1326 |
}
|
|
|
1327 |
}
|
|
|
1328 |
else
|
|
|
1329 |
{
|
|
|
1330 |
echo '<h3>Add a new link:</h3><div class"small">for the directory <em>', htmlentities($dir),
|
|
|
1331 |
"</em></div><form method='get' action='$this_file'>",
|
|
|
1332 |
'<input type="hidden" name="dir" value="', translate_uri($subdir),
|
|
|
1333 |
'" /><p>URL: <input type="text" name="link" size="40" value="http://" />
|
|
|
1334 |
<br />Name: <input type="text" name="name" size="35" />
|
|
|
1335 |
<br /><span class="small">(Leave "name" blank for the URL itself to be shown.)</span></p>';
|
|
|
1336 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1337 |
{
|
|
|
1338 |
$id_temp = explode('=', $index, 2);
|
|
|
1339 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1340 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1341 |
}
|
|
|
1342 |
echo '<input type="hidden" name="edit_links" value="true" />
|
|
|
1343 |
<p><input class="button" type="submit" value="Add" /></p></form></td></tr></table></p>',
|
|
|
1344 |
'<p><table border="0" cellpadding="8" cellspacing="0"><tr class="paragraph"><td class="default_td">',
|
|
|
1345 |
'<h3>Remove a link:</h3>', "<form method='get' action='$this_file'>";
|
|
|
1346 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1347 |
{
|
|
|
1348 |
$id_temp = explode('=', $index, 2);
|
|
|
1349 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1350 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1351 |
}
|
|
|
1352 |
echo '<input type="hidden" name="dir" value="', translate_uri($subdir), '" />',
|
|
|
1353 |
'<input type="hidden" name="edit_links" value="true" />';
|
|
|
1354 |
$list = @file($dir.$links_file) or $list = array();
|
|
|
1355 |
echo '<select name="remove">';
|
|
|
1356 |
for ($i=0; $i<count($list); $i++)
|
|
|
1357 |
{
|
|
|
1358 |
echo '<option>'.$list[$i].'</option>';
|
|
|
1359 |
}
|
|
|
1360 |
echo '</select><p><input class="button" type="submit" value="Delete" /></form></p>';
|
|
|
1361 |
}
|
|
|
1362 |
echo '</p></td></tr></table>', $con;
|
|
|
1363 |
show_footer();
|
|
|
1364 |
die();
|
|
|
1365 |
}
|
|
|
1366 |
else if (isset($_GET['copyFile'], $_GET['protocol']))
|
|
|
1367 |
{
|
|
|
1368 |
echo $html_heading;
|
|
|
1369 |
show_header();
|
|
|
1370 |
if ($_GET['copyFile'] == '')
|
|
|
1371 |
{
|
|
|
1372 |
echo '<p>Please go back and enter a file to copy.</p>', $con;
|
|
|
1373 |
show_footer();
|
|
|
1374 |
die();
|
|
|
1375 |
}
|
|
|
1376 |
$remote = $_GET['protocol'].$_GET['copyFile'];
|
|
|
1377 |
$local = $dir.get_basename($remote);
|
|
|
1378 |
if (!$allow_file_overwrites && @file_exists($local))
|
|
|
1379 |
{
|
|
|
1380 |
echo "File already exists: <em>$local</em>$con";
|
|
|
1381 |
show_footer();
|
|
|
1382 |
die();
|
|
|
1383 |
}
|
|
|
1384 |
$r = @fopen($remote, 'rb') or die("<p>Cannot open remote file for reading: <em>$remote</em></p>$con");
|
|
|
1385 |
$l = @fopen($local, 'wb') or die("<p>Cannot open local file for writing: <em>$local</em></p>$con");
|
|
|
1386 |
while (true)
|
|
|
1387 |
{
|
|
|
1388 |
$temp = fread($r, 8192);
|
|
|
1389 |
if ($temp === '')
|
|
|
1390 |
{
|
|
|
1391 |
break;
|
|
|
1392 |
}
|
|
|
1393 |
fwrite($l, $temp);
|
|
|
1394 |
}
|
|
|
1395 |
fclose($l);
|
|
|
1396 |
fclose($r);
|
|
|
1397 |
echo "<p>Remote file <em>$remote</em> successfully copied to <em>$local</em></p>$con";
|
|
|
1398 |
show_footer();
|
|
|
1399 |
die();
|
|
|
1400 |
}
|
|
|
1401 |
else if (isset($_GET['copyURL']))
|
|
|
1402 |
{
|
|
|
1403 |
echo $html_heading;
|
|
|
1404 |
show_header();
|
|
|
1405 |
echo "<table border='0' cellpadding='8' cellspacing='0'>
|
|
|
1406 |
<tr class='paragraph'><td class='default_td'>
|
|
|
1407 |
Enter the name of the remote file you would like to copy:
|
|
|
1408 |
<form method='get' action='$this_file'>
|
|
|
1409 |
<input type='hidden' name='dir' value='", translate_uri($subdir), "' />";
|
|
|
1410 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1411 |
{
|
|
|
1412 |
$id_temp = explode('=', $index, 2);
|
|
|
1413 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1414 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1415 |
}
|
|
|
1416 |
echo '<p><input type="radio" name="protocol" value="http://" checked="checked" />http://
|
|
|
1417 |
<br /><input type="radio" name="protocol" value="ftp://" />ftp://
|
|
|
1418 |
<input type="text" name="copyFile" /></p>
|
|
|
1419 |
<p><input class="button" type="submit" value="Copy" /></p>
|
|
|
1420 |
</form></td></tr></table>';
|
|
|
1421 |
show_footer();
|
|
|
1422 |
die();
|
|
|
1423 |
}
|
|
|
1424 |
else if (isset($_GET['rename']) && $_GET['rename'] != '')
|
|
|
1425 |
{
|
|
|
1426 |
echo $html_heading;
|
|
|
1427 |
show_header();
|
|
|
1428 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
1429 |
<tr class="paragraph"><td class="default_td">';
|
|
|
1430 |
$p = $dir.eval_dir(rawurldecode($_GET['rename']));
|
|
|
1431 |
if (isset($_GET['newName']) && $_GET['newName'] != '')
|
|
|
1432 |
{
|
|
|
1433 |
$new_name = $dir.eval_dir(rawurldecode($_GET['newName']));
|
|
|
1434 |
if ($p == $new_name)
|
|
|
1435 |
{
|
|
|
1436 |
$msg = 'The filename is unchanged for ';
|
|
|
1437 |
}
|
|
|
1438 |
else if (@rename($p, $new_name))
|
|
|
1439 |
{
|
|
|
1440 |
$msg = 'Rename successful for ';
|
|
|
1441 |
if ($download_count != '')
|
|
|
1442 |
{
|
|
|
1443 |
$l = @file($download_count) or $l = array();
|
|
|
1444 |
if ($h = @fopen($download_count, 'wb'))
|
|
|
1445 |
{
|
|
|
1446 |
for ($i=0; $i<count($l); $i++)
|
|
|
1447 |
{
|
|
|
1448 |
$regex = '/^'.preg_quote($p, '/').'/';
|
|
|
1449 |
fwrite($h, preg_replace($regex, $new_name, $l[$i]));
|
|
|
1450 |
}
|
|
|
1451 |
fclose($h);
|
|
|
1452 |
}
|
|
|
1453 |
}
|
|
|
1454 |
if ($description_file != '')
|
|
|
1455 |
{
|
|
|
1456 |
$l = @file($description_file) or $l = array();
|
|
|
1457 |
if ($h = @fopen($description_file, 'wb'))
|
|
|
1458 |
{
|
|
|
1459 |
for ($i=0; $i<count($l); $i++)
|
|
|
1460 |
{
|
|
|
1461 |
$regex = '/^'.preg_quote($p, '/').'/';
|
|
|
1462 |
fwrite($h, preg_replace($regex, $new_name, $l[$i]));
|
|
|
1463 |
}
|
|
|
1464 |
fclose($h);
|
|
|
1465 |
}
|
|
|
1466 |
}
|
|
|
1467 |
}
|
|
|
1468 |
else
|
|
|
1469 |
{
|
|
|
1470 |
$msg = 'Rename failed for ';
|
|
|
1471 |
}
|
|
|
1472 |
echo $msg, htmlentities($p), $con, '</td></tr></table>';
|
|
|
1473 |
show_footer();
|
|
|
1474 |
die();
|
|
|
1475 |
}
|
|
|
1476 |
echo '<p>Renaming <em>', htmlentities($p), "</em></p><p>New Filename:
|
|
|
1477 |
<br /><span class='small'>(you can also move the file by specifying a path)</span>
|
|
|
1478 |
</p><form method='get' action='$this_file'>
|
|
|
1479 |
<input type='hidden' name='dir' value='", translate_uri($subdir), "' />
|
|
|
1480 |
<input type='hidden' name='rename' value='", translate_uri($_GET['rename']), '\' />';
|
|
|
1481 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1482 |
{
|
|
|
1483 |
$id_temp = explode('=', $index, 2);
|
|
|
1484 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1485 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1486 |
}
|
|
|
1487 |
echo '<input type="text" name="newName" size="40" value="', $_GET['rename'], '" />
|
|
|
1488 |
<p><input class="button" type="submit" value="Rename" /></p></form></td></tr></table>';
|
|
|
1489 |
show_footer();
|
|
|
1490 |
die();
|
|
|
1491 |
}
|
|
|
1492 |
else if (isset($_GET['delete']) && $_GET['delete'] != '')
|
|
|
1493 |
{
|
|
|
1494 |
echo $html_heading;
|
|
|
1495 |
show_header();
|
|
|
1496 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
1497 |
<tr class="paragraph"><td class="default_td">';
|
|
|
1498 |
$_GET['delete'] = rawurldecode($_GET['delete']);
|
|
|
1499 |
$p = $dir.eval_dir($_GET['delete']);
|
|
|
1500 |
if (isset($_GET['sure'])) //delete the file
|
|
|
1501 |
{
|
|
|
1502 |
if (@is_dir($p))
|
|
|
1503 |
{
|
|
|
1504 |
$msg = (rmdir_recursive($p) ? 'Folder successfully deleted: '
|
|
|
1505 |
: 'Could not delete folder: ');
|
|
|
1506 |
}
|
|
|
1507 |
else if (@is_file($p))
|
|
|
1508 |
{
|
|
|
1509 |
$msg = (@unlink($p) ? 'File successfully deleted: '
|
|
|
1510 |
: 'Could not delete file: ');
|
|
|
1511 |
}
|
|
|
1512 |
else
|
|
|
1513 |
{
|
|
|
1514 |
$msg = 'File or folder does not exist: ';
|
|
|
1515 |
}
|
|
|
1516 |
}
|
|
|
1517 |
else //ask user for confirmation
|
|
|
1518 |
{
|
|
|
1519 |
$msg = 'Are you sure you want to delete <em>';
|
|
|
1520 |
$con = '</em><p><a class="default_a" href="'.$this_file.'dir='
|
|
|
1521 |
.translate_uri($subdir).'&delete='.translate_uri($_GET['delete'])
|
|
|
1522 |
.'&sure=true">Yes, delete it.</a></p><p><a class="default_a" href="'
|
|
|
1523 |
.$this_file.'dir='.translate_uri($subdir).'">No, go back.</a></p>';
|
|
|
1524 |
}
|
|
|
1525 |
echo $msg, htmlentities($p), $con, '</td></tr></table>';
|
|
|
1526 |
show_footer();
|
|
|
1527 |
die();
|
|
|
1528 |
}
|
|
|
1529 |
else if (isset($_GET['config']))
|
|
|
1530 |
{
|
|
|
1531 |
if (@is_file($config_generator))
|
|
|
1532 |
{
|
|
|
1533 |
define('CONFIG', true);
|
|
|
1534 |
if (!@include($config_generator))
|
|
|
1535 |
{
|
|
|
1536 |
die("$html_heading<p>Error including file <em>$config_generator</em></p>");
|
|
|
1537 |
}
|
|
|
1538 |
die();
|
|
|
1539 |
}
|
|
|
1540 |
else
|
|
|
1541 |
{
|
|
|
1542 |
die("$html_heading<p>File <em>$config_generator</em> not found.</p>");
|
|
|
1543 |
}
|
|
|
1544 |
}
|
|
|
1545 |
else if (isset($_GET['edit_ban']))
|
|
|
1546 |
{
|
|
|
1547 |
echo $html_heading;
|
|
|
1548 |
show_header();
|
|
|
1549 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
1550 |
<tr class="paragraph"><td class="default_td">';
|
|
|
1551 |
if ($banned_list == '')
|
|
|
1552 |
{
|
|
|
1553 |
echo '<p>The banning system is not in use.<br />To turn it on, set the $banned_list variable.</p>';
|
|
|
1554 |
}
|
|
|
1555 |
else if (isset($_GET['add_ban']))
|
|
|
1556 |
{
|
|
|
1557 |
if ($handle = @fopen($banned_list, 'ab'))
|
|
|
1558 |
{
|
|
|
1559 |
fwrite($handle, $_GET['add_ban']."\n");
|
|
|
1560 |
fclose($handle);
|
|
|
1561 |
echo '<p>Ban added.</p>';
|
|
|
1562 |
}
|
|
|
1563 |
else
|
|
|
1564 |
{
|
|
|
1565 |
echo '<p>Could not open ban_list file for writing.</p>';
|
|
|
1566 |
}
|
|
|
1567 |
}
|
|
|
1568 |
else if (isset($_GET['del_ban']))
|
|
|
1569 |
{
|
|
|
1570 |
$del_ban = rtrim($_GET['del_ban']);
|
|
|
1571 |
if (($list = @file($banned_list)) && ($handle = @fopen($banned_list, 'wb')))
|
|
|
1572 |
{
|
|
|
1573 |
for ($i=0; $i<count($list); $i++)
|
|
|
1574 |
{
|
|
|
1575 |
if (rtrim($list[$i]) != $del_ban)
|
|
|
1576 |
{
|
|
|
1577 |
fwrite($handle, $list[$i]);
|
|
|
1578 |
}
|
|
|
1579 |
}
|
|
|
1580 |
fclose($handle);
|
|
|
1581 |
echo '<p>Ban removed.</p>';
|
|
|
1582 |
}
|
|
|
1583 |
else
|
|
|
1584 |
{
|
|
|
1585 |
echo '<p>Could not open ban_list file.</p>';
|
|
|
1586 |
}
|
|
|
1587 |
}
|
|
|
1588 |
else
|
|
|
1589 |
{
|
|
|
1590 |
echo '<h3>Add a new ban:</h3>',
|
|
|
1591 |
"<form method='get' action='$this_file'>",
|
|
|
1592 |
'IP address or hostname: <input type="text" name="add_ban" size="35" />
|
|
|
1593 |
<br /><span class="small">You can use wildcards if you want (*, ?, +)</span></p>';
|
|
|
1594 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1595 |
{
|
|
|
1596 |
$id_temp = explode('=', $index, 2);
|
|
|
1597 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1598 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1599 |
}
|
|
|
1600 |
echo '<input type="hidden" name="edit_ban" value="true" />
|
|
|
1601 |
<p><input class="button" type="submit" value="Add" /></p></form></td></tr></table></p>',
|
|
|
1602 |
'<table border="0" cellpadding="8" cellspacing="0"><tr class="paragraph"><td class="default_td">',
|
|
|
1603 |
'<h3>Remove a ban:</h3>'."<form method='get' action='$this_file'>";
|
|
|
1604 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1605 |
{
|
|
|
1606 |
$id_temp = explode('=', $index, 2);
|
|
|
1607 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1608 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1609 |
}
|
|
|
1610 |
echo '<input type="hidden" name="edit_ban" value="true" />';
|
|
|
1611 |
$list = @file($banned_list) or $list = array();
|
|
|
1612 |
echo '<select name="del_ban">';
|
|
|
1613 |
for ($i=0; $i<count($list); $i++)
|
|
|
1614 |
{
|
|
|
1615 |
echo '<option>'.$list[$i].'</option>';
|
|
|
1616 |
}
|
|
|
1617 |
echo '</select><p><input class="button" type="submit" value="Remove" /></form>';
|
|
|
1618 |
}
|
|
|
1619 |
echo '</p></td></tr></table>', $con;
|
|
|
1620 |
show_footer();
|
|
|
1621 |
die();
|
|
|
1622 |
}
|
|
|
1623 |
}
|
|
|
1624 |
|
|
|
1625 |
function get_change_color($num)
|
|
|
1626 |
{
|
|
|
1627 |
if ($num > 0)
|
|
|
1628 |
{
|
|
|
1629 |
return '<span style="color: #00FF00;">+';
|
|
|
1630 |
}
|
|
|
1631 |
if ($num < 0)
|
|
|
1632 |
{
|
|
|
1633 |
return '<span style="color: #FF0000;">';
|
|
|
1634 |
}
|
|
|
1635 |
return '<span style="color: #000000;">';
|
|
|
1636 |
}
|
|
|
1637 |
|
|
|
1638 |
if ($use_login_system && isset($_GET['log']))
|
|
|
1639 |
//logfile viewer
|
|
|
1640 |
{
|
|
|
1641 |
echo $html_heading;
|
|
|
1642 |
show_header();
|
|
|
1643 |
if (!logged_in() || !is_admin())
|
|
|
1644 |
{
|
|
|
1645 |
echo '<p>You must be logged in as an admin to access this page.</p>';
|
|
|
1646 |
}
|
|
|
1647 |
else if ($log_file == '')
|
|
|
1648 |
{
|
|
|
1649 |
echo '<p>The logging system is not in use.
|
|
|
1650 |
<br />To turn it on, set the $log_file variable.</p>';
|
|
|
1651 |
}
|
|
|
1652 |
else if (isset($_GET['view']))
|
|
|
1653 |
{
|
|
|
1654 |
$log = @file($log_file) or die("Cannot open log file: <em>$log_file</em>");
|
|
|
1655 |
$count_log = count($log);
|
|
|
1656 |
$max_to_display = (int)$_GET['view'];
|
|
|
1657 |
$num = (($max_to_display == 0) ? $count_log : min($max_to_display, $count_log));
|
|
|
1658 |
echo "<p>Last $num log entries (of $count_log".')</p><table width="100%"><tr>
|
|
|
1659 |
<th class="default_th"> </th><th class="default_th">Date</th>
|
|
|
1660 |
<th class="default_th">Time</th><th class="default_th">IP</th>
|
|
|
1661 |
<th class="default_th">Hostname</th><th class="default_th">Referrer</th>
|
|
|
1662 |
<th class="default_th">File/Folder Viewed</th><th class="default_th">Other</th></tr>';
|
|
|
1663 |
for ($i=0; $i<$num; $i++)
|
|
|
1664 |
{
|
|
|
1665 |
$entries = explode("\t", rtrim($log[$count_log-$i-1]));
|
|
|
1666 |
$num_entries = count($entries);
|
|
|
1667 |
if ($num_entries > 5)
|
|
|
1668 |
{
|
|
|
1669 |
echo "\n<tr class=", (($i % 2) ? '"dark_row">' : '"light_row">'),
|
|
|
1670 |
'<td class="default_td"><strong>', ($i + 1), '</strong></td>';
|
|
|
1671 |
for ($j=0; $j<$num_entries; $j++)
|
|
|
1672 |
{
|
|
|
1673 |
echo '<td class="default_td">', (($j == 4 && $entries[4] != 'N/A') ?
|
|
|
1674 |
'<a class="default_a" href="'.$entries[$j].'">'.htmlentities($entries[$j]).'</a>' :
|
|
|
1675 |
htmlentities($entries[$j])).'</td>';
|
|
|
1676 |
}
|
|
|
1677 |
if ($num_entries === 6)
|
|
|
1678 |
{
|
|
|
1679 |
echo '<td class="default_td"> </td>';
|
|
|
1680 |
}
|
|
|
1681 |
echo '</tr>';
|
|
|
1682 |
}
|
|
|
1683 |
}
|
|
|
1684 |
echo '</table>';
|
|
|
1685 |
}
|
|
|
1686 |
else if (isset($_GET['stats']))
|
|
|
1687 |
{
|
|
|
1688 |
if (!@include($path_to_language_files.'country_codes.php'))
|
|
|
1689 |
{
|
|
|
1690 |
die("<p>File not found: <em>{$path_to_language_files}country_codes.php</em></p>");
|
|
|
1691 |
}
|
|
|
1692 |
$extensions = $dates = $unique_hits = $countries = array();
|
|
|
1693 |
$total_hits = 0;
|
|
|
1694 |
$h = @fopen($log_file, 'rb') or die("<p>Cannot open log file: <em>$log_file</em></p>");
|
|
|
1695 |
while (!feof($h))
|
|
|
1696 |
{
|
|
|
1697 |
$entries = explode("\t", rtrim(fgets($h, 1024)));
|
|
|
1698 |
if (count($entries) > 5)
|
|
|
1699 |
{
|
|
|
1700 |
//find the number of unique visits
|
|
|
1701 |
if ($entries[5] == $base_dir)
|
|
|
1702 |
{
|
|
|
1703 |
$total_hits++;
|
|
|
1704 |
if (!in_array($entries[3], $unique_hits))
|
|
|
1705 |
{
|
|
|
1706 |
$unique_hits[] = htmlentities($entries[3]);
|
|
|
1707 |
}
|
|
|
1708 |
|
|
|
1709 |
//find country codes by hostnames
|
|
|
1710 |
$cc = ext($entries[3]);
|
|
|
1711 |
if (preg_match('/^[a-z]+$/i', $cc))
|
|
|
1712 |
{
|
|
|
1713 |
add_num_to_array($cc, $countries);
|
|
|
1714 |
}
|
|
|
1715 |
|
|
|
1716 |
//find the dates of the visits
|
|
|
1717 |
add_num_to_array($entries[0], $dates);
|
|
|
1718 |
}
|
|
|
1719 |
|
|
|
1720 |
//find file extensions
|
|
|
1721 |
else if (($ext = ext($entries[5])) && preg_match('/^[\w-]+$/', $ext))
|
|
|
1722 |
{
|
|
|
1723 |
add_num_to_array($ext, $extensions);
|
|
|
1724 |
}
|
|
|
1725 |
}
|
|
|
1726 |
}
|
|
|
1727 |
fclose($h);
|
|
|
1728 |
$num_days = count($dates);
|
|
|
1729 |
$avg = round($total_hits/$num_days);
|
|
|
1730 |
|
|
|
1731 |
echo '<table width="40%"><tr><th class="default_th"> </th>
|
|
|
1732 |
<th class="default_th">Total</th><th class="default_th">Daily</th></tr>',
|
|
|
1733 |
"<tr class='light_row'><td class='default_td'>Hits</td>
|
|
|
1734 |
<td class='default_td'>$total_hits</td><td class='default_td'>$avg",
|
|
|
1735 |
'</td></tr><tr class="light_row"><td class="default_td">Unique Hits</td>
|
|
|
1736 |
<td class="default_td">'.count($unique_hits).'</td><td class="default_td">',
|
|
|
1737 |
round(count($unique_hits)/$num_days),
|
|
|
1738 |
'</td></tr></table><p>Percent Unique: ',
|
|
|
1739 |
number_format(count($unique_hits)/$total_hits*100, 1), '</p>';
|
|
|
1740 |
|
|
|
1741 |
arsort($extensions);
|
|
|
1742 |
arsort($countries);
|
|
|
1743 |
|
|
|
1744 |
$date_nums = array_values($dates);
|
|
|
1745 |
echo '<p /><table width="75%" border="0"><tr><th class="default_th">Date</th>
|
|
|
1746 |
<th class="default_th">Hits That Day</th><th class="default_th">Change From Previous Day</th>
|
|
|
1747 |
<th class="default_th">Difference From Average ('.$avg.')</th></tr>';
|
|
|
1748 |
$i = 0;
|
|
|
1749 |
foreach ($dates as $day => $num)
|
|
|
1750 |
{
|
|
|
1751 |
$diff = $num - $avg;
|
|
|
1752 |
$change = (($i > 0) ? ($num - $date_nums[$i-1]) : 0);
|
|
|
1753 |
$change_color = get_change_color($change);
|
|
|
1754 |
$diff_color = get_change_color($diff);
|
|
|
1755 |
|
|
|
1756 |
$class = (($i++ % 2) ? 'dark_row' : 'light_row');
|
|
|
1757 |
echo "<tr class='$class'><td class='default_td'>$day</td>
|
|
|
1758 |
<td class='default_td'>$num</td>
|
|
|
1759 |
<td class='default_td'>$change_color$change</span></td>
|
|
|
1760 |
<td class='default_td'>$diff_color$diff</span></td></tr>";
|
|
|
1761 |
}
|
|
|
1762 |
|
|
|
1763 |
echo '</table><p /><table width="75%" border="0">
|
|
|
1764 |
<tr><th class="default_th">Downloads based on file extensions</th>
|
|
|
1765 |
<th class="default_th">Total</th><th class="default_th">Daily</th></tr>';
|
|
|
1766 |
$i = 0;
|
|
|
1767 |
foreach ($extensions as $ext => $num)
|
|
|
1768 |
{
|
|
|
1769 |
$class = (($i++ % 2) ? 'dark_row' : 'light_row');
|
|
|
1770 |
echo "<tr class='$class'><td class='default_td'>$ext</td>
|
|
|
1771 |
<td class='default_td'>$num</td><td class='default_td'>",
|
|
|
1772 |
number_format($num/$num_days, 1), '</td></tr>';
|
|
|
1773 |
}
|
|
|
1774 |
|
|
|
1775 |
echo '</table><p /><table width="75%" border="0"><tr>
|
|
|
1776 |
<th class="default_th">Hostname ISP extension</th>
|
|
|
1777 |
<th class="default_th">Total</th><th class="default_th">Daily</th></tr>';
|
|
|
1778 |
$i = 0;
|
|
|
1779 |
foreach ($countries as $c => $num)
|
|
|
1780 |
{
|
|
|
1781 |
$c_code = (isset($country_codes[strtolower($c)]) ? ' <span class="small">('.$country_codes[strtolower($c)].')</span>' : '');
|
|
|
1782 |
$class = (($i++ % 2) ? 'dark_row' : 'light_row');
|
|
|
1783 |
echo "<tr class='$class'><td class='default_td'>$c{$c_code}</td><td class='default_td'>$num</td><td class='default_td'>",
|
|
|
1784 |
number_format($num / $num_days, 1), "</td></tr>\n";
|
|
|
1785 |
}
|
|
|
1786 |
echo '</table>';
|
|
|
1787 |
}
|
|
|
1788 |
else
|
|
|
1789 |
{
|
|
|
1790 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
1791 |
<tr class="paragraph"><td class="default_td">'
|
|
|
1792 |
."<form method='get' action='$this_file'>
|
|
|
1793 |
<input type='hidden' name='log' value='true' />";
|
|
|
1794 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
1795 |
{
|
|
|
1796 |
$id_temp = explode('=', $index, 2);
|
|
|
1797 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
1798 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
1799 |
}
|
|
|
1800 |
echo '<p>List the latest <input type="text" size="2" name="view" /> enties in the log file (0 to view all).<input class="button" type="submit" value="Go" /></p></form>
|
|
|
1801 |
<p>or <a class="default_a" href="', $this_file, 'log=true&stats=true">view statistics</a>.</p></td></tr></table>';
|
|
|
1802 |
}
|
|
|
1803 |
echo '<p><a class="default_a" href="', $this_file, '">Continue.</a></p>';
|
|
|
1804 |
show_footer();
|
|
|
1805 |
die();
|
|
|
1806 |
}
|
|
|
1807 |
|
|
|
1808 |
if ($use_login_system && (isset($_POST['admin']) || isset($_GET['admin'])))
|
|
|
1809 |
//user admin section
|
|
|
1810 |
{
|
|
|
1811 |
echo $html_heading;
|
|
|
1812 |
show_header();
|
|
|
1813 |
if (!logged_in() || !is_admin())
|
|
|
1814 |
{
|
|
|
1815 |
echo '<p>You must be logged in as an admin to access this page.</p>';
|
|
|
1816 |
}
|
|
|
1817 |
else if (isset($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['admin']))
|
|
|
1818 |
{
|
|
|
1819 |
$pwd_reg_exp = '^[A-Za-z0-9_-]+$';
|
|
|
1820 |
if (strlen($_POST['password1']) < 6)
|
|
|
1821 |
{
|
|
|
1822 |
echo '<p>Password must be at least 6 characters long.</p>';
|
|
|
1823 |
}
|
|
|
1824 |
else if (!ereg($pwd_reg_exp, $_POST['username']))
|
|
|
1825 |
{
|
|
|
1826 |
echo 'The username must only contain alpha-numeric characters, underscores, or dashes.',
|
|
|
1827 |
'<br /><span class="small">It must match the regular expression: <strong>',
|
|
|
1828 |
htmlentities($pwd_reg_exp), '</strong></span>';
|
|
|
1829 |
}
|
|
|
1830 |
else if ($_POST['password1'] != $_POST['password2'])
|
|
|
1831 |
{
|
|
|
1832 |
echo '<p>Passwords do not match.</p>';
|
|
|
1833 |
}
|
|
|
1834 |
else if (is_username($_POST['username']))
|
|
|
1835 |
{
|
|
|
1836 |
echo '<p>That username already exists.</p>';
|
|
|
1837 |
}
|
|
|
1838 |
else
|
|
|
1839 |
{
|
|
|
1840 |
$handle = @fopen($user_list, 'ab') or die("<p>Could not open file <em>$user_list</em> for writing.</p>");
|
|
|
1841 |
fwrite($handle, md5($_POST['password1']).$_POST['admin'].$_POST['username']."\n");
|
|
|
1842 |
fclose($handle);
|
|
|
1843 |
echo '<p>User added. <a class="default_a" href="', $this_file, '">Continue.</a></p>';
|
|
|
1844 |
}
|
|
|
1845 |
}
|
|
|
1846 |
else if (isset($_POST['deluser'], $_POST['doit']))
|
|
|
1847 |
{
|
|
|
1848 |
if ($_POST['doit'])
|
|
|
1849 |
{
|
|
|
1850 |
if (is_user_admin($_POST['deluser']) && num_admins() < 2)
|
|
|
1851 |
{
|
|
|
1852 |
echo '<p>You cannot remove this user because it is the only admin.
|
|
|
1853 |
<br />Create another user with admin rights, then delete this user.</p>
|
|
|
1854 |
<p><a class="default_a" href="', $this_file, '">Continue.</a></p>';
|
|
|
1855 |
}
|
|
|
1856 |
else
|
|
|
1857 |
{
|
|
|
1858 |
$handle = @fopen($user_list, 'wb') or die("<p>Could not open file <strong>$user_list</strong> for writing.</p>");
|
|
|
1859 |
foreach ($global_user_list as $look)
|
|
|
1860 |
{
|
|
|
1861 |
if (strcasecmp($_POST['deluser'], substr(rtrim($look), 33)) !== 0)
|
|
|
1862 |
{
|
|
|
1863 |
fwrite($handle, $look);
|
|
|
1864 |
}
|
|
|
1865 |
}
|
|
|
1866 |
fclose($handle);
|
|
|
1867 |
echo '<p>User <strong>'.$_POST['deluser'].'</strong> has been removed. <a class="default_a" href="'
|
|
|
1868 |
.$this_file.'">Continue.</a></p>';
|
|
|
1869 |
}
|
|
|
1870 |
}
|
|
|
1871 |
else
|
|
|
1872 |
{
|
|
|
1873 |
echo '<table border="0" cellpadding="8" cellspacing="0"><tr class="paragraph"><td class="default_td">',
|
|
|
1874 |
'Are you sure you want to remove <strong>', $_POST['deluser'], "</strong>?<p><form method='post' action='$this_file'>",
|
|
|
1875 |
'<input type="hidden" name="doit" value="1" /><input type="hidden" name="admin" value="true" /><input type="hidden" name="deluser" value="',
|
|
|
1876 |
$_POST['deluser'], '" /><input class="button" type="submit" value="Yes, do it." />',
|
|
|
1877 |
'</form></td></tr></table>';
|
|
|
1878 |
}
|
|
|
1879 |
}
|
|
|
1880 |
else
|
|
|
1881 |
{
|
|
|
1882 |
echo "
|
|
|
1883 |
<table border='0' cellpadding='8' cellspacing='0'>
|
|
|
1884 |
<tr class='paragraph'><td class='default_td'>
|
|
|
1885 |
<h3>Add a user:</h3>
|
|
|
1886 |
<form method='post' action='$this_file'>
|
|
|
1887 |
<p><input type='hidden' name='admin' value='true' />
|
|
|
1888 |
Username: <input type='text' name='username' />
|
|
|
1889 |
<br />Password: <input type='password' name='password1' />
|
|
|
1890 |
<br />Password: <input type='password' name='password2' />
|
|
|
1891 |
<br />Is Admin?: <select name='admin'>
|
|
|
1892 |
<option selected='selected' value='0'>No</option>
|
|
|
1893 |
<option value='1'>Yes</option></select></p>
|
|
|
1894 |
<p><input class='button' type='submit' value='Add User' /></p>
|
|
|
1895 |
</form></td></tr></table>
|
|
|
1896 |
|
|
|
1897 |
<p /><table border='0' cellpadding='8' cellspacing='0'>
|
|
|
1898 |
<tr class='paragraph'><td class='default_td'>
|
|
|
1899 |
<h3>Delete a user:</h3>
|
|
|
1900 |
<form method='post' action='$this_file'>
|
|
|
1901 |
<p><input type='hidden' name='admin' value='true' />
|
|
|
1902 |
Select user to delete: <select name='deluser'>";
|
|
|
1903 |
foreach ($global_user_list as $look)
|
|
|
1904 |
{
|
|
|
1905 |
echo '<option>', substr($look, 33), '</option>';
|
|
|
1906 |
}
|
|
|
1907 |
echo '</select><input type="hidden" name="doit" value="0" /></p>
|
|
|
1908 |
<p><input class="button" type="submit" value="Delete" /></p></form>
|
|
|
1909 |
</td></tr></table>';
|
|
|
1910 |
}
|
|
|
1911 |
show_footer();
|
|
|
1912 |
die();
|
|
|
1913 |
}
|
|
|
1914 |
else if ($use_login_system && isset($_GET['logout']))
|
|
|
1915 |
//logout
|
|
|
1916 |
{
|
|
|
1917 |
session_unset();
|
|
|
1918 |
session_destroy();
|
|
|
1919 |
redirect($this_file);
|
|
|
1920 |
}
|
|
|
1921 |
else if ($use_login_system && (isset($_POST['passwd']) || isset($_GET['passwd'])))
|
|
|
1922 |
//change password
|
|
|
1923 |
{
|
|
|
1924 |
echo $html_heading;
|
|
|
1925 |
show_header();
|
|
|
1926 |
if (!logged_in())
|
|
|
1927 |
{
|
|
|
1928 |
echo '<p>You must login to access this page.</p>';
|
|
|
1929 |
}
|
|
|
1930 |
else if (isset($_POST['oldpass'], $_POST['newpass1'], $_POST['newpass2']))
|
|
|
1931 |
{
|
|
|
1932 |
if (strlen($_POST['newpass1']) < 6)
|
|
|
1933 |
{
|
|
|
1934 |
echo '<p>New password too short (must be at least 6 characters).</p>';
|
|
|
1935 |
}
|
|
|
1936 |
else if ($_POST['newpass1'] != $_POST['newpass2'])
|
|
|
1937 |
{
|
|
|
1938 |
echo '<p>New passwords do not match.</p>';
|
|
|
1939 |
}
|
|
|
1940 |
else if (check_login($_SESSION['user'], md5($_POST['oldpass'])))
|
|
|
1941 |
{
|
|
|
1942 |
$handle = @fopen($user_list, 'wb') or die("<p>Could not open file <strong>$user_list</strong> for writing.</p>");
|
|
|
1943 |
foreach ($global_user_list as $look)
|
|
|
1944 |
{
|
|
|
1945 |
fwrite($handle, ((strcasecmp($_SESSION['user'] , substr(rtrim($look), 33)) === 0) ?
|
|
|
1946 |
md5($_POST['newpass1']).substr($look, 32) : $look));
|
|
|
1947 |
}
|
|
|
1948 |
fclose($handle);
|
|
|
1949 |
echo '<p>Password for <strong>'.$_SESSION['user'].'</strong> has been changed.<p>You must now <a class="default_a" href="'
|
|
|
1950 |
.$this_file.'">logout</a>.</p>';
|
|
|
1951 |
}
|
|
|
1952 |
else
|
|
|
1953 |
{
|
|
|
1954 |
echo '<p>Incorrect old password.</p>';
|
|
|
1955 |
}
|
|
|
1956 |
}
|
|
|
1957 |
else
|
|
|
1958 |
{
|
|
|
1959 |
echo "<table border='0' cellpadding='8' cellspacing='0'>
|
|
|
1960 |
<tr class='paragraph'><td class='default_td'>
|
|
|
1961 |
<form method='post' action='$this_file'>
|
|
|
1962 |
<input type='hidden' name='passwd' value='true' />
|
|
|
1963 |
Old Password: <input type='password' name='oldpass' />
|
|
|
1964 |
<br />New Password: <input type='password' name='newpass1' />
|
|
|
1965 |
<br />New Password: <input type='password' name='newpass2' />
|
|
|
1966 |
<p><input class='button' type='submit' value='Change Password' />
|
|
|
1967 |
</form></td></tr></table>";
|
|
|
1968 |
}
|
|
|
1969 |
show_footer();
|
|
|
1970 |
die();
|
|
|
1971 |
}
|
|
|
1972 |
|
|
|
1973 |
$total_bytes = 0;
|
|
|
1974 |
|
|
|
1975 |
if ($links_file != '' && isset($_GET['link']))
|
|
|
1976 |
//redirect to a link
|
|
|
1977 |
{
|
|
|
1978 |
if (ok_to_log())
|
|
|
1979 |
{
|
|
|
1980 |
if ($log_file != '')
|
|
|
1981 |
{
|
|
|
1982 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
1983 |
{
|
|
|
1984 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
1985 |
."\t$ip\t$host\t$referrer\t"
|
|
|
1986 |
.$_GET['link']."\tLink file\n");
|
|
|
1987 |
fclose($write);
|
|
|
1988 |
}
|
|
|
1989 |
}
|
|
|
1990 |
if ($download_count != '')
|
|
|
1991 |
{
|
|
|
1992 |
add_to_file($_GET['link'], $download_count);
|
|
|
1993 |
}
|
|
|
1994 |
}
|
|
|
1995 |
redirect($_GET['link']);
|
|
|
1996 |
}
|
|
|
1997 |
|
|
|
1998 |
if ($file_dl != '')
|
|
|
1999 |
//if the user specified a file to download, download it now
|
|
|
2000 |
{
|
|
|
2001 |
if (!@is_file($dir.$file_dl))
|
|
|
2002 |
{
|
|
|
2003 |
header('HTTP/1.0 404 Not Found');
|
|
|
2004 |
echo $html_heading;
|
|
|
2005 |
show_header();
|
|
|
2006 |
echo '<h3>Error 404: file not found</h3>',
|
|
|
2007 |
htmlentities($dir . $file_dl), ' was not found on this server.';
|
|
|
2008 |
show_footer();
|
|
|
2009 |
die();
|
|
|
2010 |
}
|
|
|
2011 |
|
|
|
2012 |
if ($anti_leech && !isset($_SESSION['ref']) && ($referrer == 'N/A' || !stristr($referrer, $_SERVER['SERVER_NAME'])))
|
|
|
2013 |
{
|
|
|
2014 |
if ($log_file != '' && ok_to_log())
|
|
|
2015 |
{
|
|
|
2016 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
2017 |
{
|
|
|
2018 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
2019 |
."\t$ip\t$host\t$referrer\t$dir$file_dl\tLeech Attempt\n");
|
|
|
2020 |
fclose($write);
|
|
|
2021 |
}
|
|
|
2022 |
}
|
|
|
2023 |
$ref = (($referrer == 'N/A') ? 'typing it in the address bar...' : $referrer);
|
|
|
2024 |
echo $html_heading;
|
|
|
2025 |
show_header();
|
|
|
2026 |
echo '<h3>This PHP Script has an Anti-Leech feature turned on.<p>Make sure you are accessing this file directly from <a class="default_a" href="http://',
|
|
|
2027 |
$_SERVER['SERVER_NAME'], '">', htmlentities($_SERVER['SERVER_NAME']), '</a></h3>',
|
|
|
2028 |
'It seems you are trying to get it from <strong>', "$ref</strong><p>Your IP address has been logged.<br />$ip ($host)";
|
|
|
2029 |
$index_link = 'http://'.$_SERVER['SERVER_NAME'].$this_file.'dir='.translate_uri($subdir);
|
|
|
2030 |
echo '<p>Here is a link to the directory index the file is in:<br /><a class="default_a" href="',
|
|
|
2031 |
$index_link, '">', htmlentities($index_link), '</a></p>';
|
|
|
2032 |
show_footer();
|
|
|
2033 |
die();
|
|
|
2034 |
}
|
|
|
2035 |
|
|
|
2036 |
if (ok_to_log())
|
|
|
2037 |
{
|
|
|
2038 |
if ($download_count != '')
|
|
|
2039 |
{
|
|
|
2040 |
add_to_file($dir.$file_dl, $download_count);
|
|
|
2041 |
}
|
|
|
2042 |
if ($log_file != '')
|
|
|
2043 |
{
|
|
|
2044 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
2045 |
{
|
|
|
2046 |
fwrite($write, date($date_format)."\t".date('H:i:s')
|
|
|
2047 |
."\t$ip\t$host\t$referrer\t$dir$file_dl\n");
|
|
|
2048 |
fclose($write);
|
|
|
2049 |
}
|
|
|
2050 |
}
|
|
|
2051 |
}
|
|
|
2052 |
|
|
|
2053 |
if ($force_download) //use php to read the file, and tell the browser to download it
|
|
|
2054 |
{
|
|
|
2055 |
if (!($fn = @fopen($dir.$file_dl, 'rb')))
|
|
|
2056 |
{
|
|
|
2057 |
die($html_heading.'<h3>Error 401: permission denied</h3> you cannot access <em>'
|
|
|
2058 |
.htmlentities($file_dl).'</em> on this server.');
|
|
|
2059 |
}
|
|
|
2060 |
$outname = get_basename($file_dl);
|
|
|
2061 |
$size = @filesize($dir.$file_dl);
|
|
|
2062 |
if ($size !== false)
|
|
|
2063 |
{
|
|
|
2064 |
header('Content-Length: '.$size);
|
|
|
2065 |
}
|
|
|
2066 |
header('Content-Type: '.find_mime_type(ext($outname)).'; name="'.$outname.'"');
|
|
|
2067 |
header('Content-Disposition: attachment; filename="'.$outname.'"');
|
|
|
2068 |
@set_time_limit(0);
|
|
|
2069 |
while (true)
|
|
|
2070 |
{
|
|
|
2071 |
$temp = @fread($fn, (int)($speed * 1024));
|
|
|
2072 |
if ($temp === '')
|
|
|
2073 |
{
|
|
|
2074 |
break;
|
|
|
2075 |
}
|
|
|
2076 |
echo $temp;
|
|
|
2077 |
flush();
|
|
|
2078 |
if ($bandwidth_limit)
|
|
|
2079 |
{
|
|
|
2080 |
sleep(1);
|
|
|
2081 |
}
|
|
|
2082 |
}
|
|
|
2083 |
fclose($fn);
|
|
|
2084 |
die();
|
|
|
2085 |
}
|
|
|
2086 |
redirect(translate_uri($dir.$file_dl));
|
|
|
2087 |
}
|
|
|
2088 |
|
|
|
2089 |
if ($log_file != '' && ok_to_log())
|
|
|
2090 |
//write to the logfile
|
|
|
2091 |
{
|
|
|
2092 |
if ($write = @fopen($log_file, 'ab'))
|
|
|
2093 |
{
|
|
|
2094 |
$log_str = date($date_format)."\t".date('H:i:s')
|
|
|
2095 |
."\t$ip\t$host\t$referrer\t$dir";
|
|
|
2096 |
if ($search != '')
|
|
|
2097 |
{
|
|
|
2098 |
$log_str .= "\tSearch: $search";
|
|
|
2099 |
}
|
|
|
2100 |
fwrite($write, $log_str."\n");
|
|
|
2101 |
fclose($write);
|
|
|
2102 |
}
|
|
|
2103 |
else
|
|
|
2104 |
{
|
|
|
2105 |
echo '<p>Error: Could not write to logfile.</p>';
|
|
|
2106 |
}
|
|
|
2107 |
}
|
|
|
2108 |
|
|
|
2109 |
if ($anti_leech && !isset($_SESSION['ref']))
|
|
|
2110 |
{
|
|
|
2111 |
$_SESSION['ref'] = 1;
|
|
|
2112 |
}
|
|
|
2113 |
|
|
|
2114 |
echo $html_heading;
|
|
|
2115 |
show_header();
|
|
|
2116 |
|
|
|
2117 |
if (!@is_dir($dir))
|
|
|
2118 |
//make sure the subfolder exists
|
|
|
2119 |
{
|
|
|
2120 |
echo '<p><strong>Error: The folder <em>'.htmlentities($dir)
|
|
|
2121 |
.'</em> does not exist.</strong></p>';
|
|
|
2122 |
$dir = $base_dir;
|
|
|
2123 |
$subdir = '';
|
|
|
2124 |
}
|
|
|
2125 |
|
|
|
2126 |
if ($enable_searching && $search != '')
|
|
|
2127 |
//show the results of a search
|
|
|
2128 |
{
|
|
|
2129 |
echo '<table border="0" cellpadding="8" cellspacing="0">
|
|
|
2130 |
<tr class="paragraph"><td class="default_td"><p><strong>',
|
|
|
2131 |
$words['search results'], '</strong> :<br /><span class="small">for <em>',
|
|
|
2132 |
htmlentities($dir), '</em> and its subdirectories</span></p><p>';
|
|
|
2133 |
$results = search_dir($dir, $search);
|
|
|
2134 |
natcasesort($results);
|
|
|
2135 |
if ($_SESSION['sort'] == 'd' && $_SESSION['sortMode'] == 'f')
|
|
|
2136 |
{
|
|
|
2137 |
$results = array_reverse($results);
|
|
|
2138 |
}
|
|
|
2139 |
for ($i=0; $i<count($results); $i++)
|
|
|
2140 |
{
|
|
|
2141 |
$file = substr($results[$i], strlen($base_dir));
|
|
|
2142 |
echo '<a class="default_a" href="'.$this_file;
|
|
|
2143 |
if (is_dir($base_dir.$file))
|
|
|
2144 |
{
|
|
|
2145 |
echo 'dir='.translate_uri($file).'/">';
|
|
|
2146 |
if ($icon_path != '')
|
|
|
2147 |
{
|
|
|
2148 |
echo '<img height="16" width="16" alt="[dir]" src="', $icon_path, '/dir.png" /> ';
|
|
|
2149 |
}
|
|
|
2150 |
echo htmlentities($file)."/</a><br />\n";
|
|
|
2151 |
}
|
|
|
2152 |
else if (preg_match('/\|$/', $file))
|
|
|
2153 |
{
|
|
|
2154 |
$file = substr($file, 0, -1);
|
|
|
2155 |
$display = get_stored_info($file, $dir.$links_file);
|
|
|
2156 |
if ($display == '')
|
|
|
2157 |
{
|
|
|
2158 |
$display = $file;
|
|
|
2159 |
}
|
|
|
2160 |
echo 'dir=', translate_uri($subdir), '&link=',
|
|
|
2161 |
translate_uri($file), '" title="Link to: ', $file, '">',
|
|
|
2162 |
icon(ext($display)), htmlentities($display), '</a><br />';
|
|
|
2163 |
}
|
|
|
2164 |
else
|
|
|
2165 |
{
|
|
|
2166 |
echo 'dir=', translate_uri(dirname($file)).'/&file=',
|
|
|
2167 |
translate_uri(get_basename($file)), '">',
|
|
|
2168 |
icon(ext($file)), htmlentities($file), "</a><br />\n";
|
|
|
2169 |
}
|
|
|
2170 |
}
|
|
|
2171 |
if (!count($results))
|
|
|
2172 |
{
|
|
|
2173 |
echo '</p><p><strong>[ ', $words['no results'], ' ]</strong></p>';
|
|
|
2174 |
}
|
|
|
2175 |
echo '</p><p>', $words['end of results'], ' (', count($results), ' ',
|
|
|
2176 |
$words['found'], ')</p></td></tr></table>';
|
|
|
2177 |
show_search_box();
|
|
|
2178 |
echo '<p><a class="default_a" href="', $this_file, 'dir=',
|
|
|
2179 |
translate_uri($subdir), '">Go back.</a></p>';
|
|
|
2180 |
show_footer();
|
|
|
2181 |
die();
|
|
|
2182 |
}
|
|
|
2183 |
|
|
|
2184 |
//path navigation at the top
|
|
|
2185 |
echo '<div>', $words['index of'], ' <a class="default_a" href="', $this_file,
|
|
|
2186 |
'dir=">', htmlentities(substr(str_replace('/', ' / ', $base_dir), 0, -2)),
|
|
|
2187 |
'</a>/ ';
|
|
|
2188 |
$exploded = explode('/', $subdir);
|
|
|
2189 |
$c = count($exploded) - 1;
|
|
|
2190 |
for ($i=0; $i<$c; $i++)
|
|
|
2191 |
{
|
|
|
2192 |
echo '<a class="default_a" href="', $this_file, 'dir=';
|
|
|
2193 |
for ($j=0; $j<=$i; $j++)
|
|
|
2194 |
{
|
|
|
2195 |
echo translate_uri($exploded[$j]), '/';
|
|
|
2196 |
}
|
|
|
2197 |
echo '">', htmlentities($exploded[$i]), '</a> / ';
|
|
|
2198 |
}
|
|
|
2199 |
|
|
|
2200 |
//begin the table
|
|
|
2201 |
echo "</div>\n\n", '<table width="100%" border="0" cellpadding="0" cellspacing="2"><tr>';
|
|
|
2202 |
table_heading($words['file'], 'f', 'Sort by Filename');
|
|
|
2203 |
if ($show_type_column)
|
|
|
2204 |
{
|
|
|
2205 |
table_heading('Type', 't', 'Sort by Type');
|
|
|
2206 |
}
|
|
|
2207 |
if ($download_count != '')
|
|
|
2208 |
{
|
|
|
2209 |
table_heading('Downloads', 'h', 'Sort by Hits');
|
|
|
2210 |
}
|
|
|
2211 |
if ($show_size_column)
|
|
|
2212 |
{
|
|
|
2213 |
table_heading($words['size'], 's', 'Sort by Size');
|
|
|
2214 |
}
|
|
|
2215 |
if ($show_date_column)
|
|
|
2216 |
{
|
|
|
2217 |
table_heading($words['modified'], 'm', 'Sort by Date');
|
|
|
2218 |
}
|
|
|
2219 |
if ($description_file != '')
|
|
|
2220 |
{
|
|
|
2221 |
table_heading('Description', 'd', 'Sort by Description');
|
|
|
2222 |
}
|
|
|
2223 |
echo '</tr>';
|
|
|
2224 |
|
|
|
2225 |
if ($subdir != '')
|
|
|
2226 |
//if they are not in the root folder, have a link to the parent directory
|
|
|
2227 |
{
|
|
|
2228 |
echo '<tr class="light_row"><td class="default_td" colspan="6"><a class="default_a" href="', $this_file, 'dir=';
|
|
|
2229 |
$subdir = substr($subdir, 0, -1);
|
|
|
2230 |
echo translate_uri(substr($subdir, 0, strrpos($subdir,'/'))), '/">';
|
|
|
2231 |
if ($icon_path != '')
|
|
|
2232 |
{
|
|
|
2233 |
echo "<img height=\"16\" width=\"16\" src=\"$icon_path/back.png\" alt=\"[dir]\" /> ";
|
|
|
2234 |
}
|
|
|
2235 |
echo $words['parent directory'], '</a></td></tr>';
|
|
|
2236 |
$subdir .= '/';
|
|
|
2237 |
}
|
|
|
2238 |
|
|
|
2239 |
flush();
|
|
|
2240 |
|
|
|
2241 |
$file_array = get_file_list($dir);
|
|
|
2242 |
$size_array = $date_a_array = $date_m_array = $desc_array = $hit_array = $type_array = array();
|
|
|
2243 |
|
|
|
2244 |
$c = count($file_array);
|
|
|
2245 |
for ($i=0; $i<$c; $i++)
|
|
|
2246 |
{
|
|
|
2247 |
$thisf = $dir.$file_array[$i];
|
|
|
2248 |
if (preg_match('/\|$/', $thisf)) //it is a link
|
|
|
2249 |
{
|
|
|
2250 |
$thisf = substr($thisf, 0, -1);
|
|
|
2251 |
$type_array[] = ($show_type_column ? ext(get_stored_info(substr($file_array[$i], 0, -1), $dir.$links_file)) : '');
|
|
|
2252 |
$hit_array[] = (($download_count != '' && !@is_dir($thisf)) ? (int)(get_stored_info(substr($file_array[$i], 0, -1), $download_count)) : 0);
|
|
|
2253 |
$date_m_array[] = 'N/A';
|
|
|
2254 |
$date_a_array[] = 'N/A';
|
|
|
2255 |
$size_array[] = '[Link]';
|
|
|
2256 |
}
|
|
|
2257 |
else //it is an actual file or folder
|
|
|
2258 |
{
|
|
|
2259 |
$size_array[] = ($show_size_column ? (@is_dir($thisf) ? ($show_dir_size ? dir_size("$thisf/") : 0) : max((int)@filesize($thisf), 0)) : 0);
|
|
|
2260 |
$type_array[] = (($show_type_column && !@is_dir($thisf)) ? ext($thisf) : '');
|
|
|
2261 |
$hit_array[] = (($download_count != '' && !@is_dir($thisf)) ? (int)(get_stored_info($thisf, $download_count)) : 0);
|
|
|
2262 |
if ($show_date_column)
|
|
|
2263 |
{
|
|
|
2264 |
$date_m_array[] = filemtime($thisf);
|
|
|
2265 |
$date_a_array[] = fileatime($thisf);
|
|
|
2266 |
}
|
|
|
2267 |
else
|
|
|
2268 |
{
|
|
|
2269 |
$date_m_array[] = 0;
|
|
|
2270 |
$date_a_array[] = 0;
|
|
|
2271 |
}
|
|
|
2272 |
}
|
|
|
2273 |
$desc_array[] = (($description_file == '') ? '' : get_stored_info($thisf, $description_file));
|
|
|
2274 |
}
|
|
|
2275 |
|
|
|
2276 |
switch (strtolower($_SESSION['sortMode']))
|
|
|
2277 |
{
|
|
|
2278 |
case 's':
|
|
|
2279 |
array_multisort($size_array, $file_array, $date_m_array,
|
|
|
2280 |
$date_a_array, $hit_array, $desc_array, $type_array);
|
|
|
2281 |
break;
|
|
|
2282 |
case 'm':
|
|
|
2283 |
array_multisort($date_m_array, $file_array, $size_array,
|
|
|
2284 |
$date_a_array, $hit_array, $desc_array, $type_array);
|
|
|
2285 |
break;
|
|
|
2286 |
case 'd':
|
|
|
2287 |
array_multisort($desc_array, $file_array, $date_m_array,
|
|
|
2288 |
$size_array, $date_a_array, $hit_array, $type_array);
|
|
|
2289 |
break;
|
|
|
2290 |
case 'h':
|
|
|
2291 |
array_multisort($hit_array, $file_array, $date_m_array,
|
|
|
2292 |
$size_array, $date_a_array, $desc_array, $type_array);
|
|
|
2293 |
break;
|
|
|
2294 |
case 't':
|
|
|
2295 |
array_multisort($type_array, $file_array, $hit_array,
|
|
|
2296 |
$date_m_array, $size_array, $date_a_array, $desc_array);
|
|
|
2297 |
}
|
|
|
2298 |
|
|
|
2299 |
if (strtolower($_SESSION['sort']) === 'd')
|
|
|
2300 |
//if the current sort mode is set to descending, reverse all the arrays
|
|
|
2301 |
{
|
|
|
2302 |
$file_array = array_reverse($file_array);
|
|
|
2303 |
$size_array = array_reverse($size_array);
|
|
|
2304 |
$date_m_array = array_reverse($date_m_array);
|
|
|
2305 |
$date_a_array = array_reverse($date_a_array);
|
|
|
2306 |
$desc_array = array_reverse($desc_array);
|
|
|
2307 |
$hit_array = array_reverse($hit_array);
|
|
|
2308 |
$type_array = array_reverse($type_array);
|
|
|
2309 |
}
|
|
|
2310 |
|
|
|
2311 |
$folder_count = $file_count = $dl_count = 0;
|
|
|
2312 |
|
|
|
2313 |
for ($i=0; $i<$c; $i++)
|
|
|
2314 |
//display the list of files
|
|
|
2315 |
{
|
|
|
2316 |
$value = $file_array[$i];
|
|
|
2317 |
echo "\n<tr class=", (($i % 2 == ($subdir == '')) ? '"dark_row">' : '"light_row">');
|
|
|
2318 |
|
|
|
2319 |
//file column
|
|
|
2320 |
echo '<td class="default_td" align="left" valign="top"><a class="default_a" href="', $this_file;
|
|
|
2321 |
$npart = $dir . $value;
|
|
|
2322 |
if (preg_match('/\|$/', $value)) //it is a link, not an actual file
|
|
|
2323 |
{
|
|
|
2324 |
$value = substr($value, 0, -1);
|
|
|
2325 |
$npart = substr($npart, 0, -1);
|
|
|
2326 |
$display = get_stored_info($value, $dir.$links_file);
|
|
|
2327 |
if ($display == '')
|
|
|
2328 |
{
|
|
|
2329 |
$display = $value;
|
|
|
2330 |
}
|
|
|
2331 |
echo 'dir=', translate_uri($subdir), '&link=',
|
|
|
2332 |
translate_uri($value), '" title="Link to: ', $value, '">',
|
|
|
2333 |
icon(ext($display)), htmlentities($display), '</a>';
|
|
|
2334 |
}
|
|
|
2335 |
else //it is a real file or folder
|
|
|
2336 |
{
|
|
|
2337 |
if (@is_dir($npart))
|
|
|
2338 |
{
|
|
|
2339 |
$folder_count++;
|
|
|
2340 |
if ($icon_path != '')
|
|
|
2341 |
{
|
|
|
2342 |
if ($folder_expansion)
|
|
|
2343 |
{
|
|
|
2344 |
$listVal = (in_array($npart, $_SESSION['expanded']) ? 'collapse' : 'expand');
|
|
|
2345 |
echo 'dir=', translate_uri($subdir), "&$listVal=", translate_uri($value),
|
|
|
2346 |
'"><img height="16" width="16" alt="[dir]" src="',
|
|
|
2347 |
$icon_path.'/dir.png" /></a> ',
|
|
|
2348 |
'<a class="default_a" href="', $this_file, 'dir=',
|
|
|
2349 |
translate_uri($subdir . $value), '/">';
|
|
|
2350 |
}
|
|
|
2351 |
else
|
|
|
2352 |
{
|
|
|
2353 |
echo 'dir=', translate_uri($subdir . $value), '/">',
|
|
|
2354 |
'<img height="16" width="16" alt="[dir]" src="', $icon_path, '/dir.png" /> ';
|
|
|
2355 |
}
|
|
|
2356 |
}
|
|
|
2357 |
else
|
|
|
2358 |
{
|
|
|
2359 |
echo 'dir=', translate_uri($subdir . $value), '/">';
|
|
|
2360 |
}
|
|
|
2361 |
echo htmlentities($value).'</a>';
|
|
|
2362 |
if ($show_folder_count)
|
|
|
2363 |
{
|
|
|
2364 |
$n = num_files($npart);
|
|
|
2365 |
$s = (($n == 1) ? $words['file'] : $words['files']);
|
|
|
2366 |
echo " [$n $s]";
|
|
|
2367 |
}
|
|
|
2368 |
}
|
|
|
2369 |
else //is a file
|
|
|
2370 |
{
|
|
|
2371 |
$file_count++;
|
|
|
2372 |
echo 'dir=', translate_uri($subdir), '&file=',
|
|
|
2373 |
translate_uri($value), "\">",
|
|
|
2374 |
icon(ext($npart)), htmlentities($value), '</a>';
|
|
|
2375 |
if ($md5_show && $size_array[$i] > 0 && $size_array[$i] / 1048576 <= $md5_show)
|
|
|
2376 |
{
|
|
|
2377 |
echo ' [<a class="default_a" href="', $this_file,
|
|
|
2378 |
'dir=', translate_uri($subdir), '&md5=',
|
|
|
2379 |
translate_uri($value), '"><span class="small">get md5sum</span></a>]';
|
|
|
2380 |
}
|
|
|
2381 |
}
|
|
|
2382 |
if ($use_login_system && logged_in() && is_admin())
|
|
|
2383 |
{
|
|
|
2384 |
echo ' [<a class="default_a" href="', $this_file, 'dir='.translate_uri($subdir),
|
|
|
2385 |
'&delete=', translate_uri($value), '"><span class="small">delete</span></a>, ',
|
|
|
2386 |
'<a class="default_a" href="', $this_file, 'dir=', translate_uri($subdir),
|
|
|
2387 |
'&rename=', translate_uri($value), '"><span class="small">rename/move</span></a>]';
|
|
|
2388 |
}
|
|
|
2389 |
$age = (time() - $date_m_array[$i]) / 86400;
|
|
|
2390 |
$age_r = round($age, 1);
|
|
|
2391 |
$s = (($age_r == 1) ? '' : 's');
|
|
|
2392 |
if ($days_new && $age <= $days_new)
|
|
|
2393 |
{
|
|
|
2394 |
echo (($icon_path == '') ? ' <span class="small" style="color: #FF0000;">[New]</span>'
|
|
|
2395 |
: ' <img alt="'."$age_r day$s".' old" height="14" width="28" src="'.$icon_path.'/new.png" />');
|
|
|
2396 |
}
|
|
|
2397 |
if ($folder_expansion && @is_dir($npart) && in_array($npart, $_SESSION['expanded']))
|
|
|
2398 |
{
|
|
|
2399 |
$ex_array = get_file_list($npart.'/');
|
|
|
2400 |
if ($_SESSION['sort'] == 'd' && $_SESSION['sortMode'] == 'f')
|
|
|
2401 |
{
|
|
|
2402 |
$ex_array = array_reverse($ex_array);
|
|
|
2403 |
}
|
|
|
2404 |
echo '<ul>';
|
|
|
2405 |
for ($j=0; $j<count($ex_array); $j++)
|
|
|
2406 |
{
|
|
|
2407 |
$element = $ex_array[$j];
|
|
|
2408 |
echo '<li><a class="default_a" href="'.$this_file
|
|
|
2409 |
.((@is_file("$npart/$element")) ? 'dir='.translate_uri($subdir.$value).'/&file='
|
|
|
2410 |
.translate_uri($element).'">' : 'dir='.translate_uri("$subdir$value/$element/").'">');
|
|
|
2411 |
if (@is_file("$npart/$element"))
|
|
|
2412 |
{
|
|
|
2413 |
echo icon(ext($element));
|
|
|
2414 |
}
|
|
|
2415 |
else if ($icon_path != '')
|
|
|
2416 |
{
|
|
|
2417 |
echo '<img height="16" width="16" alt="[dir]" src="',
|
|
|
2418 |
$icon_path, '/dir.png" /> ';
|
|
|
2419 |
}
|
|
|
2420 |
echo htmlentities($element), "</a></li>\n";
|
|
|
2421 |
}
|
|
|
2422 |
echo '</ul>';
|
|
|
2423 |
}
|
|
|
2424 |
}
|
|
|
2425 |
if ($use_login_system && $description_file != '' && logged_in() && is_admin())
|
|
|
2426 |
//"edit description" link
|
|
|
2427 |
{
|
|
|
2428 |
echo ' [<a class="default_a" href="', $this_file, 'dir=',
|
|
|
2429 |
translate_uri($subdir), '&descFile=', translate_uri($value),
|
|
|
2430 |
'"><span class="small">change description</span></a>]';
|
|
|
2431 |
}
|
|
|
2432 |
|
|
|
2433 |
if ($thumbnail_height > 0 && in_array(ext($value), array('png', 'jpg', 'jpeg', 'gif')) && @is_file($npart))
|
|
|
2434 |
//display the thumbnail image
|
|
|
2435 |
{
|
|
|
2436 |
echo ' <a href="'.$this_file.'dir=', translate_uri($subdir), '&file=',
|
|
|
2437 |
translate_uri($value), '"><img src="', $this_file,
|
|
|
2438 |
'dir=', translate_uri($subdir), '&thumbnail=', translate_uri($value),
|
|
|
2439 |
'" alt="Thumbnail of ', $value, '" /></a>';
|
|
|
2440 |
}
|
|
|
2441 |
|
|
|
2442 |
echo '</td>'; //end filename column
|
|
|
2443 |
|
|
|
2444 |
//filetype column
|
|
|
2445 |
if ($show_type_column)
|
|
|
2446 |
{
|
|
|
2447 |
echo '<td class="default_td" align="left" valign="top">',
|
|
|
2448 |
(($type_array[$i] == '') ? ' ' : htmlentities($type_array[$i])), '</td>';
|
|
|
2449 |
}
|
|
|
2450 |
|
|
|
2451 |
//hits column
|
|
|
2452 |
if ($download_count != '')
|
|
|
2453 |
{
|
|
|
2454 |
$dl_count += $hit_array[$i];
|
|
|
2455 |
echo '<td class="default_td" align="right" valign="top">',
|
|
|
2456 |
((!@is_dir($npart)) ? $hit_array[$i] : ' '), '</td>';
|
|
|
2457 |
}
|
|
|
2458 |
|
|
|
2459 |
//size column
|
|
|
2460 |
if ($show_size_column)
|
|
|
2461 |
{
|
|
|
2462 |
echo '<td class="default_td" align="right" valign="top">';
|
|
|
2463 |
$ds = $size_array[$i];
|
|
|
2464 |
if ($ds === '[Link]')
|
|
|
2465 |
{
|
|
|
2466 |
echo $ds;
|
|
|
2467 |
}
|
|
|
2468 |
else
|
|
|
2469 |
{
|
|
|
2470 |
$total_bytes += $ds;
|
|
|
2471 |
$size_h = get_filesize($ds);
|
|
|
2472 |
echo (@is_dir($npart) ?
|
|
|
2473 |
($show_dir_size ? "<a title=\"$value/\n".number_format($ds, 0, '.', ',')." bytes ($size_h)\">$size_h</a>" : '[dir]')
|
|
|
2474 |
: "<a title=\"$value\n".number_format($ds, 0, '.', ',')." bytes ($size_h)\">$size_h</a>");
|
|
|
2475 |
}
|
|
|
2476 |
echo '</td>';
|
|
|
2477 |
}
|
|
|
2478 |
|
|
|
2479 |
//date column
|
|
|
2480 |
if ($show_date_column)
|
|
|
2481 |
{
|
|
|
2482 |
echo '<td class="default_td" align="right" valign="top">';
|
|
|
2483 |
if ($date_a_array[$i] == 'N/A')
|
|
|
2484 |
{
|
|
|
2485 |
echo 'N/A';
|
|
|
2486 |
}
|
|
|
2487 |
else
|
|
|
2488 |
{
|
|
|
2489 |
$a = date($date_format.' h:i:s A', $date_a_array[$i]);
|
|
|
2490 |
$m = date($date_format.' h:i:s A', $date_m_array[$i]);
|
|
|
2491 |
echo "<a title=\"$value\nLast Modified: $m\nLast Accessed: $a\">",
|
|
|
2492 |
date($date_format, $date_m_array[$i]), '</a>';
|
|
|
2493 |
}
|
|
|
2494 |
echo '</td>';
|
|
|
2495 |
}
|
|
|
2496 |
|
|
|
2497 |
//description column
|
|
|
2498 |
if ($description_file != '')
|
|
|
2499 |
{
|
|
|
2500 |
echo '<td class="default_td" align="left" valign="top">',
|
|
|
2501 |
(($desc_array[$i] != '') ? $desc_array[$i] : ' '), '</td>';
|
|
|
2502 |
}
|
|
|
2503 |
|
|
|
2504 |
echo "</tr>\n";
|
|
|
2505 |
}
|
|
|
2506 |
|
|
|
2507 |
//footer of the table
|
|
|
2508 |
echo '<tr><th class="default_th"><span class="small">', "\n$file_count ",
|
|
|
2509 |
$words[(($file_count == 1) ? 'file' : 'files')],
|
|
|
2510 |
" - $folder_count ", $words['folders'], '</span></th>';
|
|
|
2511 |
if ($show_type_column)
|
|
|
2512 |
{
|
|
|
2513 |
echo "<th class='default_th'> </th>";
|
|
|
2514 |
}
|
|
|
2515 |
if ($download_count != '')
|
|
|
2516 |
{
|
|
|
2517 |
echo "<th class='default_th'><span class='small'>Total: $dl_count</span></th>";
|
|
|
2518 |
}
|
|
|
2519 |
if ($show_size_column)
|
|
|
2520 |
{
|
|
|
2521 |
echo '<th class="default_th"><span class="small">', $words['total size'], ': <a title="' ,$words['total size'], ":\n",
|
|
|
2522 |
number_format($total_bytes, 0, '.', ','), ' bytes (', get_filesize($total_bytes), ')">',
|
|
|
2523 |
get_filesize($total_bytes), "</a></span></th>\n";
|
|
|
2524 |
}
|
|
|
2525 |
if ($show_date_column)
|
|
|
2526 |
{
|
|
|
2527 |
echo '<th class="default_th"> </th>';
|
|
|
2528 |
}
|
|
|
2529 |
if ($description_file != '')
|
|
|
2530 |
{
|
|
|
2531 |
echo '<th class="default_th"> </th>';
|
|
|
2532 |
}
|
|
|
2533 |
echo '</tr></table><div class="small" style="text-align: right;">Powered by <a class="default_a" href="http://autoindex.sourceforge.net/">AutoIndex PHP Script</a></div>';
|
|
|
2534 |
/*
|
|
|
2535 |
* We request that you do not remove the link to the AutoIndex website.
|
|
|
2536 |
* This not only gives respect to the large amount of time given freely by the
|
|
|
2537 |
* developer, but also helps build interest, traffic, and use of AutoIndex.
|
|
|
2538 |
*/
|
|
|
2539 |
|
|
|
2540 |
echo "\n", '<table width="100%" border="0" cellpadding="0" cellspacing="2">
|
|
|
2541 |
<tr valign="top"><td>';
|
|
|
2542 |
if ($enable_searching)
|
|
|
2543 |
{
|
|
|
2544 |
show_search_box();
|
|
|
2545 |
}
|
|
|
2546 |
|
|
|
2547 |
if ($use_login_system)
|
|
|
2548 |
{
|
|
|
2549 |
if (!logged_in())
|
|
|
2550 |
{
|
|
|
2551 |
echo '</td><td>';
|
|
|
2552 |
show_login_box();
|
|
|
2553 |
}
|
|
|
2554 |
else //show user options
|
|
|
2555 |
{
|
|
|
2556 |
echo '<br /><table border="0" cellpadding="8" cellspacing="0"><tr class="paragraph"><td class="default_td">';
|
|
|
2557 |
if (is_admin())
|
|
|
2558 |
{
|
|
|
2559 |
echo '<p><a class="default_a" href="'.$this_file.'config=true">Reconfigure script</a></p>',
|
|
|
2560 |
'<p><a class="default_a" href="'.$this_file.'admin=true">User account management</a>',
|
|
|
2561 |
'<br /><a class="default_a" href="'.$this_file.'log=true">Log file viewer / statistics</a>',
|
|
|
2562 |
'<br /><a class="default_a" href="'.$this_file.'edit_links=true&dir='.translate_uri($subdir).'">Links file editor</a>',
|
|
|
2563 |
'<br /><a class="default_a" href="'.$this_file.'edit_ban=true">Edit ban list</a></p>',
|
|
|
2564 |
'<p><a class="default_a" href="'.$this_file.'getcreate=true&dir='.translate_uri($subdir).'">Create a folder (in current directory)</a>',
|
|
|
2565 |
'<br /><a class="default_a" href="'.$this_file.'copyURL=true&dir='.translate_uri($subdir).'">Copy a remote file (to current directory)</a></p>';
|
|
|
2566 |
}
|
|
|
2567 |
echo '<p><a class="default_a" href="', $this_file,
|
|
|
2568 |
'passwd=true">Change password</a><br /><a class="default_a" href="', $this_file,
|
|
|
2569 |
'logout=true">Log out [ ', $_SESSION['user'], ' ]</a></p></td></tr></table>';
|
|
|
2570 |
}
|
|
|
2571 |
}
|
|
|
2572 |
echo '</td></tr></table>';
|
|
|
2573 |
|
|
|
2574 |
if ($allow_uploads && (!$use_login_system || logged_in()))
|
|
|
2575 |
{
|
|
|
2576 |
echo "<form method='post' action='$this_file'>
|
|
|
2577 |
<input type='hidden' name='dir' value='$subdir' />
|
|
|
2578 |
Upload <select size='1' name='numUpload'>";
|
|
|
2579 |
for ($i=1; $i<=10; $i++)
|
|
|
2580 |
{
|
|
|
2581 |
echo "\t<option>$i</option>\n";
|
|
|
2582 |
}
|
|
|
2583 |
echo '</select> file(s) to this folder <input type="submit" value="Go" /></form>';
|
|
|
2584 |
}
|
|
|
2585 |
|
|
|
2586 |
if ($select_language)
|
|
|
2587 |
{
|
|
|
2588 |
echo '<p style="text-align: left;">Select Language:</p>',
|
|
|
2589 |
"<form method='get' action='$this_file'><div><select name='lang'>";
|
|
|
2590 |
$l = get_all_files($path_to_language_files);
|
|
|
2591 |
sort($l);
|
|
|
2592 |
for ($i=0; $i<count($l); $i++)
|
|
|
2593 |
{
|
|
|
2594 |
if (@is_file($path_to_language_files.$l[$i]) &&
|
|
|
2595 |
preg_match('/^[a-z]{2}(_[a-z]{2})?\.php$/i', $l[$i]))
|
|
|
2596 |
{
|
|
|
2597 |
$f = substr(get_basename($l[$i]), 0, -4);
|
|
|
2598 |
$sel = (($f == $_SESSION['lang']) ? ' selected="selected"' : '');
|
|
|
2599 |
echo "\t<option$sel>$f</option>\n";
|
|
|
2600 |
}
|
|
|
2601 |
}
|
|
|
2602 |
echo '</select><input type="submit" value="Change" />';
|
|
|
2603 |
if ($index != '' && strpos($index, '?') !== false)
|
|
|
2604 |
{
|
|
|
2605 |
$id_temp = explode('=', $index, 2);
|
|
|
2606 |
$id_temp[0] = substr(strstr($id_temp[0], '?'), 1);
|
|
|
2607 |
echo "<input type='hidden' name='$id_temp[0]' value='$id_temp[1]' />";
|
|
|
2608 |
}
|
|
|
2609 |
echo '</div></form>';
|
|
|
2610 |
}
|
|
|
2611 |
|
|
|
2612 |
show_footer();
|
|
|
2613 |
|
|
|
2614 |
//find time it took for the page to generate, in milliseconds
|
|
|
2615 |
$page_time = round((get_microtime() - $start_time) * 1000, 1);
|
|
|
2616 |
|
|
|
2617 |
echo '
|
|
|
2618 |
<!--
|
|
|
2619 |
|
|
|
2620 |
Powered by AutoIndex PHP Script (version '.VERSION.')
|
|
|
2621 |
Copyright (C) 2002-2005 Justin Hagstrom
|
|
|
2622 |
http://autoindex.sourceforge.net
|
|
|
2623 |
|
|
|
2624 |
Page generated in ', $page_time, ' milliseconds.
|
|
|
2625 |
|
|
|
2626 |
-->
|
|
|
2627 |
'; //We request that you retain the above copyright notice.
|
|
|
2628 |
|
|
|
2629 |
if ($index == '')
|
|
|
2630 |
{
|
|
|
2631 |
echo '</body></html>';
|
|
|
2632 |
}
|
|
|
2633 |
|
|
|
2634 |
?>
|