Error including file $stored_config

"); } } else if (@is_file($config_generator)) { define('CONFIG', true); if (!@include($config_generator)) { die("

Error including file $config_generator

"); } die(); } else { die("

Error: Neither $config_generator nor $stored_config could be found.

"); } $this_file = (($index == '') ? $_SERVER['PHP_SELF'] : $index); $this_file .= ((strpos($this_file, '?') !== false) ? '&' : '?'); $referrer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'N/A'); //make sure all the variables are set correctly from the stored settings $config_vars = array('base_dir', 'icon_path', 'stylesheet', 'use_login_system', 'allow_uploads', 'must_login_to_download', 'user_list', 'allow_file_overwrites', 'log_file', 'dont_log_these_ips', 'download_count', 'links_file', 'lang', 'sub_folder_access', 'index', 'hidden_files', 'show_only_these_files', 'force_download', 'bandwidth_limit', 'anti_leech', 'enable_searching', 'show_dir_size', 'folder_expansion', 'show_folder_count', 'banned_list', 'md5_show', 'header', 'footer', 'header_per_folder', 'footer_per_folder', 'description_file', 'thumbnail_height', 'path_to_language_files', 'days_new', 'select_language', 'show_type_column', 'show_size_column', 'show_date_column'); foreach ($config_vars as $this_var) { if (!isset($$this_var)) { die("

Error: AutoIndex is not configured properly.
The variable $this_var is not set.

Delete $stored_config and then run $config_generator.

"); } } //find the language the script should be displayed in if ($select_language && isset($_GET['lang']) && preg_match('/^[a-z]{2}(_[a-z]{2})?$/i', $_GET['lang']) && @is_file($path_to_language_files.$_GET['lang'].'.php')) { $_SESSION['lang'] = $_GET['lang']; } else if (!isset($_SESSION['lang'])) { $_SESSION['lang'] = $lang; } @include($path_to_language_files.$_SESSION['lang'].'.php'); if (!isset($words)) { die('

Error: You need to include a language.php file that has the variable $words.
Check the $lang and $path_to_language_files variables.

'); } $global_user_list = ($use_login_system ? @file($user_list) : array()); if ($global_user_list === false) { die("

Could not open file $user_list

"); } function translate_uri($uri) //rawurlencodes $uri, but not any slashes { $uri = rawurlencode(str_replace('\\', '/', $uri)); return str_replace(rawurlencode('/'), '/', $uri); } function get_basename($fn) //returns everything after the slash, or the original string if there is no slash { return basename(str_replace('\\', '/', $fn)); } function match_in_array($string, &$array) //returns true if $string matches anything in the array { $string = get_basename($string); static $replace = array( '\*' => '[^\/]*', '\+' => '[^\/]+', '\?' => '[^\/]?'); foreach ($array as $m) { if (preg_match('/^'.strtr(preg_quote(get_basename($m), '/'), $replace).'$/i', $string)) { return true; } } return false; } function check_login($user, $pass) { global $global_user_list; foreach ($global_user_list as $look) { if ((strcasecmp(substr(rtrim($look), 33), $user) === 0) && (strcasecmp(substr(rtrim($look), 0, 32), $pass) === 0)) { return true; } } return false; } function logged_in() { return (isset($_SESSION['user'], $_SESSION['pass']) && check_login($_SESSION['user'], $_SESSION['pass'])); } function is_user_admin($user) { global $global_user_list; foreach ($global_user_list as $look) { if (strcasecmp($user, substr(rtrim($look), 33)) === 0) { return (substr($look, 32, 1) === '1'); } } return false; } function is_admin() { return is_user_admin($_SESSION['user']); } function is_hidden($fn, $is_file = true) //looks at $hidden_files and $show_only_these_files to see if $fn is hidden { if ($fn == '') { return true; } global $use_login_system; if ($use_login_system && logged_in() && is_admin()) //allow admins to view hidden files { return false; } global $hidden_files, $show_only_these_files; if ($is_file && count($show_only_these_files)) { return (!match_in_array($fn, $show_only_these_files)); } if (!count($hidden_files)) { return false; } return match_in_array($fn, $hidden_files); } function eval_dir($d) //check $d for "bad" things, and deal with ".." { $d = str_replace('\\', '/', $d); if ($d == '' || $d == '/') { return ''; } $dirs = explode('/', $d); for ($i=0; $iError: '.htmlentities($base_dir) .' is not a valid directory.
Check the $base_dir variable.

'); } if (!$sub_folder_access || $subdir == '/') { $subdir = ''; } else if (preg_match('#[^/\\\\]$#', $subdir)) { $subdir .= '/'; //add a slash to the end if there isn't one } $dir = $base_dir.$subdir; //this will be displayed before any HTML output $html_heading = ''; if ($index == '') { $html_heading .= ' '; } if ($stylesheet != '') { $html_heading .= "\n\n"; } if ($index == '') { $html_heading .= "\n".$words['index of'].' '.htmlentities($dir) ."\n\n XtGem.com
XtGem Forum catalog
178.33.123.218
\n\n"; } function show_header() { global $header, $header_per_folder, $dir; if ($header != '') { if ($header_per_folder) { $header = $dir.$header; } if (@is_readable($header)) { include($header); } } } function show_footer() { global $footer, $footer_per_folder, $dir; if ($footer != '') { if ($footer_per_folder) { $footer = $dir.$footer; } if (@is_readable($footer)) { include($footer); } } } function show_login_box() { global $this_file, $subdir, $icon_path; $sd = translate_uri($subdir); echo '

Login Login:', "\n
Username:
Password:

"; } function show_search_box() { global $index, $search, $words, $search_mode, $this_file, $subdir, $icon_path; echo '

', $words['search'], ' ', $words['search'], ":

\n"; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo "\n

'; } function is_username($user) { global $html_heading, $global_user_list; foreach ($global_user_list as $look) { if (strcasecmp($user, substr(rtrim($look), 33)) === 0) { return true; } } return false; } function num_admins() //returns the number of accounts with admin rights { global $html_heading, $global_user_list; $num = 0; foreach ($global_user_list as $look) { if (substr($look, 32, 1) === '1') { $num++; } } return $num; } function get_filesize($size) //give a size in bytes, and this will return the appropriate measurement format { $size = max(0, $size); static $u = array(' B', 'KB', 'MB', 'GB'); for ($i=0; $size >= 1024 && $i < 4; $i++) { $size /= 1024; } return number_format($size, 1).' '.$u[$i]; } function ext($fn) //return the lowercase file extension of $fn, not including the leading dot { $fn = get_basename($fn); return (strpos($fn, '.') ? strtolower(substr(strrchr($fn, '.'), 1)) : ''); } function get_all_files($path) //returns an array of every file in $path, including folders (except ./ and ../) { $list = array(); if (($hndl = @opendir($path)) === false) { return $list; } while (($file=readdir($hndl)) !== false) { if ($file != '.' && $file != '..') { $list[] = $file; } } closedir($hndl); return $list; } function get_file_list($path) //returns a sorted array of filenames. Filters out "bad" files { global $sub_folder_access, $links_file; $f = $d = array(); foreach (get_all_files($path) as $name) { if ($sub_folder_access && @is_dir($path.$name) && !is_hidden($name, false)) { $d[] = $name; } else if (@is_file($path.$name) && !is_hidden($name, true)) { $f[] = $name; } } if ($links_file != '' && ($links = @file($path.$links_file))) { foreach ($links as $name) { $p = strpos($name, '|'); $f[] = (($p === false) ? rtrim($name).'|' : substr(rtrim($name), 0, $p).'|'); } } natcasesort($d); natcasesort($f); return array_merge($d, $f); } function dir_size($dir) //returns the total size of a directory (recursive) in bytes { $totalsize = 0; foreach (get_file_list($dir) as $name) { $totalsize += (@is_dir($dir.$name) ? dir_size("$dir$name/") : (int)@filesize($dir.$name)); } return $totalsize; } function match_filename($filename, $string) { if (preg_match_all('/(?<=")[^"]+(?=")|[^ "]+/', $string, $matches)) { foreach ($matches[0] as $w) { if (preg_match('#[^/\.]+#', $w) && stristr($filename, $w)) { return true; } } } return false; } function search_dir($sdir, $string) //returns files/folders (recursive) in $sdir that contain $string { global $search_mode; //search_mode: d=folders, f=files, fd=both $found = array(); $list = get_file_list($sdir); $d = count($list); for ($i=0; $i<$d; $i++) { $full_name = $sdir.$list[$i]; if (stristr($search_mode, 'f') && (@is_file($full_name) || preg_match('/\|$/', $list[$i])) && match_filename($list[$i], $string)) { $found[] = $full_name; } else if (@is_dir($full_name)) { if (stristr($search_mode, 'd') && match_filename($list[$i], $string)) { $found[] = $full_name; } $found = array_merge($found, search_dir($full_name.'/', $string)); } } return $found; } function add_num_to_array($num, &$array) { isset($array[$num]) ? $array[$num]++ : $array[$num] = 1; } function mkdir_recursive($path) { if (@is_dir($path)) { return true; } if (!mkdir_recursive(dirname($path))) { return false; } return @mkdir($path, 0755); } function rmdir_recursive($path) { if (!preg_match('#/$#', $path)) { $path .= '/'; } foreach (get_all_files($path) as $file) { if ($file == '' || $file == '.' || $file == '..') { continue; } if (@is_dir("$path$file/")) { rmdir_recursive("$path$file/"); } else { @unlink($path . $file); } } return @rmdir($path); } function num_files($dir) //returns the number of files in $dir (recursive) { $count = 0; if (!preg_match('#/$#', $dir)) { $dir .= '/'; } $list = get_file_list($dir); $d = count($list); for ($i=0; $i<$d; $i++) { $count += (@is_dir($dir.$list[$i]) ? num_files($dir.$list[$i]) : 1); } return $count; } function redirect($site) { header("Location: $site"); die('

Redirection header could not be sent.
' ."Continue here: $site

"); } function find_mime_type($ext) { static $mime_types = array( 'application/andrew-inset' => array('ez'), 'application/mac-binhex40' => array('hqx'), 'application/mac-compactpro' => array('cpt'), 'application/mathml+xml' => array('mathml'), 'application/msword' => array('doc'), 'application/octet-stream' => array('bin', 'dms', 'lha', 'lzh', 'exe', 'class', 'so', 'dll', 'dmg'), 'application/oda' => array('oda'), 'application/ogg' => array('ogg'), 'application/pdf' => array('pdf'), 'application/postscript' => array('ai', 'eps', 'ps'), 'application/rdf+xml' => array('rdf'), 'application/smil' => array('smi', 'smil'), 'application/srgs' => array('gram'), 'application/srgs+xml' => array('grxml'), 'application/vnd.mif' => array('mif'), 'application/vnd.mozilla.xul+xml' => array('xul'), 'application/vnd.ms-excel' => array('xls'), 'application/vnd.ms-powerpoint' => array('ppt'), 'application/vnd.wap.wbxml' => array('wbxml'), 'application/vnd.wap.wmlc' => array('wmlc'), 'application/vnd.wap.wmlscriptc' => array('wmlsc'), 'application/voicexml+xml' => array('vxml'), 'application/x-bcpio' => array('bcpio'), 'application/x-cdlink' => array('vcd'), 'application/x-chess-pgn' => array('pgn'), 'application/x-cpio' => array('cpio'), 'application/x-csh' => array('csh'), 'application/x-director' => array('dcr', 'dir', 'dxr'), 'application/x-dvi' => array('dvi'), 'application/x-futuresplash' => array('spl'), 'application/x-gtar' => array('gtar'), 'application/x-hdf' => array('hdf'), 'application/x-javascript' => array('js'), 'application/x-koan' => array('skp', 'skd', 'skt', 'skm'), 'application/x-latex' => array('latex'), 'application/x-netcdf' => array('nc', 'cdf'), 'application/x-sh' => array('sh'), 'application/x-shar' => array('shar'), 'application/x-shockwave-flash' => array('swf'), 'application/x-stuffit' => array('sit'), 'application/x-sv4cpio' => array('sv4cpio'), 'application/x-sv4crc' => array('sv4crc'), 'application/x-tar' => array('tar'), 'application/x-tcl' => array('tcl'), 'application/x-tex' => array('tex'), 'application/x-texinfo' => array('texinfo', 'texi'), 'application/x-troff' => array('t', 'tr', 'roff'), 'application/x-troff-man' => array('man'), 'application/x-troff-me' => array('me'), 'application/x-troff-ms' => array('ms'), 'application/x-ustar' => array('ustar'), 'application/x-wais-source' => array('src'), 'application/xhtml+xml' => array('xhtml', 'xht'), 'application/xslt+xml' => array('xslt'), 'application/xml' => array('xml', 'xsl'), 'application/xml-dtd' => array('dtd'), 'application/zip' => array('zip'), 'audio/basic' => array('au', 'snd'), 'audio/midi' => array('mid', 'midi', 'kar'), 'audio/mpeg' => array('mpga', 'mp2', 'mp3'), 'audio/x-aiff' => array('aif', 'aiff', 'aifc'), 'audio/x-mpegurl' => array('m3u'), 'audio/x-pn-realaudio' => array('ram', 'ra'), 'application/vnd.rn-realmedia' => array('rm'), 'audio/x-wav' => array('wav'), 'chemical/x-pdb' => array('pdb'), 'chemical/x-xyz' => array('xyz'), 'image/bmp' => array('bmp'), 'image/cgm' => array('cgm'), 'image/gif' => array('gif'), 'image/ief' => array('ief'), 'image/jpeg' => array('jpeg', 'jpg', 'jpe'), 'image/png' => array('png'), 'image/svg+xml' => array('svg'), 'image/tiff' => array('tiff', 'tif'), 'image/vnd.djvu' => array('djvu', 'djv'), 'image/vnd.wap.wbmp' => array('wbmp'), 'image/x-cmu-raster' => array('ras'), 'image/x-icon' => array('ico'), 'image/x-portable-anymap' => array('pnm'), 'image/x-portable-bitmap' => array('pbm'), 'image/x-portable-graymap' => array('pgm'), 'image/x-portable-pixmap' => array('ppm'), 'image/x-rgb' => array('rgb'), 'image/x-xbitmap' => array('xbm'), 'image/x-xpixmap' => array('xpm'), 'image/x-xwindowdump' => array('xwd'), 'model/iges' => array('igs', 'iges'), 'model/mesh' => array('msh', 'mesh', 'silo'), 'model/vrml' => array('wrl', 'vrml'), 'text/calendar' => array('ics', 'ifb'), 'text/css' => array('css'), 'text/html' => array('html', 'htm'), 'text/plain' => array('asc', 'txt'), 'text/richtext' => array('rtx'), 'text/rtf' => array('rtf'), 'text/sgml' => array('sgml', 'sgm'), 'text/tab-separated-values' => array('tsv'), 'text/vnd.wap.wml' => array('wml'), 'text/vnd.wap.wmlscript' => array('wmls'), 'text/x-setext' => array('etx'), 'video/mpeg' => array('mpeg', 'mpg', 'mpe'), 'video/quicktime' => array('qt', 'mov'), 'video/vnd.mpegurl' => array('mxu', 'm4u'), 'video/x-msvideo' => array('avi'), 'video/x-sgi-movie' => array('movie'), 'x-conference/x-cooltalk' => array('ice') ); foreach ($mime_types as $mime_type => $exts) { if (in_array($ext, $exts)) { return $mime_type; } } return 'text/plain'; } function icon($ext) //find the appropriate icon depending on the extension (returns a link to the image file) { global $icon_path; if ($icon_path == '') { return ''; } if ($ext == '') { $icon = 'generic'; } else { $icon = 'unknown'; static $icon_types = array( 'binary' => array('bat', 'bin', 'com', 'dmg', 'dms', 'exe', 'msi', 'msp', 'pif', 'pyd', 'scr', 'so'), 'binhex' => array('hqx'), 'cd' => array('bwi', 'bws', 'bwt', 'ccd', 'cdi', 'cue', 'img', 'iso', 'mdf', 'mds', 'nrg', 'nri', 'sub', 'vcd'), 'comp' => array('cfg', 'conf', 'inf', 'ini', 'log', 'nfo', 'reg'), 'compressed' => array('7z', 'a', 'ace', 'ain', 'alz', 'amg', 'arc', 'ari', 'arj', 'bh', 'bz', 'bz2', 'cab', 'deb', 'dz', 'gz', 'io', 'ish', 'lha', 'lzh', 'lzs', 'lzw', 'lzx', 'msx', 'pak', 'rar', 'rpm', 'sar', 'sea', 'sit', 'taz', 'tbz', 'tbz2', 'tgz', 'tz', 'tzb', 'uc2', 'xxe', 'yz', 'z', 'zip', 'zoo'), 'dll' => array('386', 'db', 'dll', 'ocx', 'sdb', 'vxd'), 'doc' => array('abw', 'ans', 'chm', 'cwk', 'dif', 'doc', 'dot', 'mcw', 'msw', 'pdb', 'psw', 'rtf', 'rtx', 'sdw', 'stw', 'sxw', 'vor', 'wk4', 'wkb', 'wpd', 'wps', 'wpw', 'wri', 'wsd'), 'image' => array('adc', 'art', 'bmp', 'cgm', 'dib', 'gif', 'ico', 'ief', 'jfif', 'jif', 'jp2', 'jpc', 'jpe', 'jpeg', 'jpg', 'jpx', 'mng', 'pcx', 'png', 'psd', 'psp', 'swc', 'sxd', 'tga', 'tif', 'tiff', 'wmf', 'wpg', 'xcf', 'xif', 'yuv'), 'java' => array('class', 'jar', 'jav', 'java', 'jtk'), 'js' => array('ebs', 'js', 'jse', 'vbe', 'vbs', 'wsc', 'wsf', 'wsh'), 'key' => array('aex', 'asc', 'gpg', 'key', 'pgp', 'ppk'), 'mov' => array('amc', 'dv', 'm4v', 'mac', 'mov', 'mp4v', 'mpg4', 'pct', 'pic', 'pict', 'pnt', 'pntg', 'qpx', 'qt', 'qti', 'qtif', 'qtl', 'qtp', 'qts', 'qtx'), 'movie' => array('asf', 'asx', 'avi', 'div', 'divx', 'dvi', 'm1v', 'm2v', 'mkv', 'movie', 'mp2v', 'mpa', 'mpe', 'mpeg', 'mpg', 'mps', 'mpv', 'mpv2', 'ogm', 'ram', 'rmvb', 'rnx', 'rp', 'rv', 'vivo', 'vob', 'wmv', 'xvid'), 'pdf' => array('edn', 'fdf', 'pdf', 'pdp', 'pdx'), 'php' => array('inc', 'php', 'php3', 'php4', 'php5', 'phps', 'phtml'), 'ppt' => array('emf', 'pot', 'ppa', 'pps', 'ppt', 'sda', 'sdd', 'shw', 'sti', 'sxi'), 'ps' => array('ai', 'eps', 'ps'), 'sound' => array('aac', 'ac3', 'aif', 'aifc', 'aiff', 'ape', 'apl', 'au', 'ay', 'bonk', 'cda', 'cdda', 'cpc', 'fla', 'flac', 'gbs', 'gym', 'hes', 'iff', 'it', 'itz', 'kar', 'kss', 'la', 'lpac', 'lqt', 'm4a', 'm4p', 'mdz', 'mid', 'midi', 'mka', 'mo3', 'mod', 'mp+', 'mp1', 'mp2', 'mp3', 'mp4', 'mpc', 'mpga', 'mpm', 'mpp', 'nsf', 'oda', 'ofr', 'ogg', 'pac', 'pce', 'pcm', 'psf', 'psf2', 'ra', 'rm', 'rmi', 'rmjb', 'rmm', 'sb', 'shn', 'sid', 'snd', 'spc', 'spx', 'svx', 'tfm', 'tfmx', 'voc', 'vox', 'vqf', 'wav', 'wave', 'wma', 'wv', 'wvx', 'xa', 'xm', 'xmz'), 'tar' => array('gtar', 'tar'), 'text' => array('c', 'cc', 'cp', 'cpp', 'cxx', 'diff', 'h', 'hpp', 'hxx', 'm3u', 'md5', 'patch', 'pls', 'py', 'sfv', 'sh', 'txt'), 'uu' => array('uu', 'uud', 'uue'), 'web' => array('asa', 'asp', 'aspx', 'cfm', 'cgi', 'css', 'dhtml', 'dtd', 'grxml', 'htc', 'htm', 'html', 'htt', 'htx', 'jsp', 'lnk', 'mathml', 'mht', 'mhtml', 'perl', 'pl', 'plg', 'rss', 'shtm', 'shtml', 'stm', 'swf', 'tpl', 'wbxml', 'xht', 'xhtml', 'xml', 'xsl', 'xslt', 'xul'), 'xls' => array('csv', 'dbf', 'prn', 'pxl', 'sdc', 'slk', 'stc', 'sxc', 'xla', 'xlb', 'xlc', 'xld', 'xlr', 'xls', 'xlt', 'xlw')); foreach ($icon_types as $png_name => $exts) { if (in_array($ext, $exts)) { $icon = $png_name; break; } } } return "\"[$ext]\" "; } function display_thumbnail($file, $thumbnail_height) { global $html_heading; if (!@is_file($file)) { header('HTTP/1.0 404 Not Found'); die("$html_heading

File not found: ".htmlentities($file).'

'); } switch (ext($file)) { case 'gif': $src = @imagecreatefromgif($file); break; case 'jpeg': case 'jpg': case 'jpe': $src = @imagecreatefromjpeg($file); break; case 'png': $src = @imagecreatefrompng($file); break; default: die("$html_heading

Unsupported file extension.

"); } if ($src === false) { die("$html_heading

Unsupported image type.

"); } header('Content-Type: image/jpeg'); header('Cache-Control: public, max-age=3600, must-revalidate'); header('Expires: '.gmdate('D, d M Y H:i:s', time()+3600).' GMT'); $src_height = imagesy($src); if ($src_height <= $thumbnail_height) { imagejpeg($src, '', 95); } else { $src_width = imagesx($src); $thumb_width = $thumbnail_height * ($src_width / $src_height); $thumb = imagecreatetruecolor($thumb_width, $thumbnail_height); imagecopyresampled($thumb, $src, 0, 0, 0, 0, $thumb_width, $thumbnail_height, $src_width, $src_height); imagejpeg($thumb); imagedestroy($thumb); } imagedestroy($src); die(); } function edit_description($fn, &$desc) //edits a file's description { global $description_file, $html_heading; if ($description_file == '') { return; } $wrote = false; $l = @file($description_file) or $l = array(); $h = @fopen($description_file, 'wb') or die("$html_heading

Cannot open description file for writing.

"); $count_num = count($l); for ($i=0; $i<$count_num; $i++) { $items = explode('|', rtrim($l[$i]), 2); if (count($items) === 2 && $fn == $items[0]) { fwrite($h, "$fn|$desc\n"); $wrote = true; } else { fwrite($h, $l[$i]); } } if (!$wrote && $desc != '') { fwrite($h, "$fn|$desc\n"); } fclose($h); } function add_to_file($item, $outfile) { global $html_heading; $counted = false; if ($l = @file($outfile)) { $count_num = count($l); for ($i=0; $i<$count_num; $i++) { $thisc = rtrim($l[$i]); if ($item == substr($thisc, 0, strpos($thisc, '|'))) { $counted = true; break; } } } if ($counted) { $w = @fopen($outfile, 'wb') or die("$html_heading

Could not open $outfile file for writing.

"); for ($i=0; $i<$count_num; $i++) { $items = explode('|', rtrim($l[$i]), 2); if (count($items) === 2 && $items[0] == $item) { $nc = $items[1] + 1; fwrite($w, "$item|$nc\n"); } else { fwrite($w, $l[$i]); } } } else { $w = @fopen($outfile, 'ab') or die("$html_heading

Could not open $outfile file for writing.

"); fwrite($w, "$item|1\n"); } fclose($w); } function get_stored_info($item, $filename) { if ($contents = @file($filename)) { $count_num = count($contents); for ($i=0; $i<$count_num; $i++) { $items = explode('|', rtrim($contents[$i]), 2); if (count($items) === 2 && $item == $items[0]) { return $items[1]; } } } return ''; } function table_heading($title, $sortMode, $tooltip) { global $this_file, $subdir; echo "\n', $title, ''; } //find and store the user's IP address and hostname: $ip = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'N/A'); if (isset($_SESSION['host'])) { $host = $_SESSION['host']; } else { $_SESSION['host'] = $host = @gethostbyaddr($ip); } if ($banned_list != '' && ($b_list = @file($banned_list))) //make sure the IP or hostname is not banned { for ($i=0; $iSorry, the administrator has blocked your IP address or hostname.

'; show_footer(); die(); } } function ok_to_log() //returns true if the ip or hostname is not in $dont_log_these_ips { global $ip, $host, $dont_log_these_ips; return (!(match_in_array($ip, $dont_log_these_ips) || ($host != 'N/A' && match_in_array($host, $dont_log_these_ips)))); } if ($use_login_system && isset($_POST['user'], $_POST['pass']) && $_POST['user'] != '' && $_POST['pass'] != '') //check login { if (check_login($_POST['user'], md5($_POST['pass']))) { if ($log_file != '' && ok_to_log()) { if ($write = @fopen($log_file, 'ab')) { fwrite($write, date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t$dir\tSuccessful Login (username: " .$_POST['user'].")\n"); fclose($write); } } $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = md5($_POST['pass']); unset($_POST['pass'], $_POST['user']); redirect($this_file.'dir='.translate_uri($subdir)); } else { echo '

Invalid Login.

'; if ($log_file != '' && ok_to_log()) { if ($write = @fopen($log_file, 'ab')) { fwrite($write, date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t$dir\tInvalid Login (username: " .$_POST['user'].")\n"); fclose($write); } } sleep(1); //"freeze" the script for a second to prevent brute force attacks } } if ($use_login_system && $must_login_to_download && !logged_in()) //must login to download { echo $html_heading; show_header(); echo '

You must login to download and view files.

'; show_login_box(); show_footer(); die(); } if ($md5_show && isset($_GET['md5'])) { $file = $dir.eval_dir(rawurldecode($_GET['md5'])); if (!@is_file($file)) { header('HTTP/1.0 404 Not Found'); die($html_heading.'

Error: file does not exist.

'); } $size = (int)@filesize($file); if ($size <= 0 || $size/1048576 > $md5_show) { die($html_heading.'

Error: empty file, or file too big to find the md5sum of (according to the $md5_show variable).

'); } die(md5_file($file)); } if ($thumbnail_height > 0 && isset($_GET['thumbnail']) && $_GET['thumbnail'] != '') { $file = $dir.eval_dir(rawurldecode($_GET['thumbnail'])); display_thumbnail($file, $thumbnail_height); } if (isset($_GET['sort'])) { $_SESSION['sort'] = $_GET['sort']; } else if (!isset($_SESSION['sort'])) { //'a' is ascending, 'd' is descending $_SESSION['sort'] = 'a'; } if (isset($_GET['sortMode'])) { $_SESSION['sortMode'] = $_GET['sortMode']; } else if (!isset($_SESSION['sortMode'])) { /* * 'f' is filename * 't' is filetype * 'h' is downloads (hits) * 's' is size * 'm' is date (modified) * 'd' is description */ $_SESSION['sortMode'] = 'f'; } //size of the "chunks" that are read at a time from the file (when $force_download is on) $speed = ($bandwidth_limit ? $bandwidth_limit : 8); if ($folder_expansion) { if (!isset($_SESSION['expanded'])) { $_SESSION['expanded'] = array(); } if (isset($_GET['expand']) && $_GET['expand'] != '') { $temp = $dir.eval_dir(rawurldecode($_GET['expand'])); if (@is_dir($temp) && !in_array($temp, $_SESSION['expanded'])) { $_SESSION['expanded'][] = $temp; } } if (isset($_GET['collapse']) && $_GET['collapse'] != '') { $temp = $dir.eval_dir(rawurldecode($_GET['collapse'])); if (in_array($temp, $_SESSION['expanded'])) { array_splice($_SESSION['expanded'], array_search($temp, $_SESSION['expanded']), 1); } } } if ($allow_uploads && (!$use_login_system || logged_in())) //upload a file { if ($count_files = count($_FILES)) { echo $html_heading; show_header(); $uploaded_files = $errors = ''; for ($i=0; $i<$count_files; $i++) { $filename = get_basename($_FILES[$i]['name']); if ($filename == '') { continue; } if (is_hidden($filename)) { $errors .= "
  • $filename [filename is listed as a hidden file]
  • "; continue; } $filepath = $base_dir.eval_dir(rawurldecode($_POST['dir'])); $fullpathname = realpath($filepath).'/'.$filename; if (!$allow_file_overwrites && @file_exists($fullpathname)) { $errors .= "
  • $filename [file already exists]
  • "; } else if (@move_uploaded_file($_FILES[$i]['tmp_name'], $fullpathname)) { @chmod($fullpathname, 0644); $uploaded_files .= "
  • $filename
  • "; if ($log_file != '' && ok_to_log() && ($write = @fopen($log_file, 'ab'))) { fwrite($write, date($date_format)."\t".date('H:i:s') . "\t$ip\t$host\t$referrer\t$dir\tFile uploaded: $filepath$filename\n"); fclose($write); } } else { $errors .= "
  • $filename
  • "; } } if ($errors == '') { $errors = '
    [None]'; } if ($uploaded_files == '') { $uploaded_files = '
    [None]'; } echo "

    Uploaded files: $uploaded_files

    Failed files: $errors

    ", '

    Continue.

    '; show_footer(); die(); } else if (isset($_POST['numUpload'])) { echo $html_heading; show_header(); echo "
    \n"; $num = (int)$_POST['numUpload']; for ($i=0; $i<$num; $i++) { $n = $i + 1; echo "\t\t{$words['file']} $n :
    \n"; } echo '

    '; show_footer(); die(); } } if ($use_login_system && logged_in() && is_admin()) { $con = '

    Continue.

    '; if (isset($_GET['getcreate'])) { echo $html_heading; show_header(); echo "
    Enter the name of the folder you would like to create:
    "; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    '; show_footer(); die(); } else if (isset($_GET['create']) && $_GET['create'] != '') { $p = $dir.eval_dir($_GET['create']); $msg = (@file_exists($p) ? 'Folder already exists: ' : (mkdir_recursive($p) ? 'Folder successfully created: ' : 'Could not create folder: ')); echo $html_heading; show_header(); echo $msg, htmlentities($p), $con; show_footer(); die(); } else if ($description_file != '' && isset($_GET['descFile']) && $_GET['descFile'] != '') { if (isset($_GET['desc'])) { $desc = trim(rawurldecode($_GET['desc'])); $descFile = trim(rawurldecode($_GET['descFile'])); edit_description($dir.$descFile, $desc); } else { $filen = rawurldecode($_GET['descFile']); $filen_display = htmlentities($filen); echo $html_heading; show_header(); echo "
    Enter the new description for the file $filen_display:
    '; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    '; show_footer(); die(); } } else if (isset($_GET['edit_links'])) { echo $html_heading; show_header(); echo '
    '; if ($links_file == '') { echo '

    The link system is not in use.
    To turn it on, set the $links_file variable.

    '; } else if (isset($_GET['link'], $_GET['name']) && $_GET['link'] != '') { if ($handle = @fopen($dir.$links_file, 'ab')) { fwrite($handle, $_GET['link'].'|'.$_GET['name']."\n"); fclose($handle); echo '

    Link added.

    '; } else { echo '

    Could not open links_file for writing.

    '; } } else if (isset($_GET['remove'])) { if (($list = @file($dir.$links_file)) && ($handle = @fopen($dir.$links_file, 'wb'))) { for ($i=0; $iLink removed.

    '; } else { echo '

    Could not open links_file.

    '; } } else { echo '

    Add a new link:

    for the directory ', htmlentities($dir), "
    ", '

    URL:
    Name:
    (Leave "name" blank for the URL itself to be shown.)

    '; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    ', '

    ', '

    Remove a link:

    ', "
    "; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '', ''; $list = @file($dir.$links_file) or $list = array(); echo '

    '; } echo '

    ', $con; show_footer(); die(); } else if (isset($_GET['copyFile'], $_GET['protocol'])) { echo $html_heading; show_header(); if ($_GET['copyFile'] == '') { echo '

    Please go back and enter a file to copy.

    ', $con; show_footer(); die(); } $remote = $_GET['protocol'].$_GET['copyFile']; $local = $dir.get_basename($remote); if (!$allow_file_overwrites && @file_exists($local)) { echo "File already exists: $local$con"; show_footer(); die(); } $r = @fopen($remote, 'rb') or die("

    Cannot open remote file for reading: $remote

    $con"); $l = @fopen($local, 'wb') or die("

    Cannot open local file for writing: $local

    $con"); while (true) { $temp = fread($r, 8192); if ($temp === '') { break; } fwrite($l, $temp); } fclose($l); fclose($r); echo "

    Remote file $remote successfully copied to $local

    $con"; show_footer(); die(); } else if (isset($_GET['copyURL'])) { echo $html_heading; show_header(); echo "
    Enter the name of the remote file you would like to copy:
    "; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    http://
    ftp://

    '; show_footer(); die(); } else if (isset($_GET['rename']) && $_GET['rename'] != '') { echo $html_heading; show_header(); echo '
    '; $p = $dir.eval_dir(rawurldecode($_GET['rename'])); if (isset($_GET['newName']) && $_GET['newName'] != '') { $new_name = $dir.eval_dir(rawurldecode($_GET['newName'])); if ($p == $new_name) { $msg = 'The filename is unchanged for '; } else if (@rename($p, $new_name)) { $msg = 'Rename successful for '; if ($download_count != '') { $l = @file($download_count) or $l = array(); if ($h = @fopen($download_count, 'wb')) { for ($i=0; $i
    '; show_footer(); die(); } echo '

    Renaming ', htmlentities($p), "

    New Filename:
    (you can also move the file by specifying a path)

    '; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    '; show_footer(); die(); } else if (isset($_GET['delete']) && $_GET['delete'] != '') { echo $html_heading; show_header(); echo '
    '; $_GET['delete'] = rawurldecode($_GET['delete']); $p = $dir.eval_dir($_GET['delete']); if (isset($_GET['sure'])) //delete the file { if (@is_dir($p)) { $msg = (rmdir_recursive($p) ? 'Folder successfully deleted: ' : 'Could not delete folder: '); } else if (@is_file($p)) { $msg = (@unlink($p) ? 'File successfully deleted: ' : 'Could not delete file: '); } else { $msg = 'File or folder does not exist: '; } } else //ask user for confirmation { $msg = 'Are you sure you want to delete '; $con = '

    Yes, delete it.

    No, go back.

    '; } echo $msg, htmlentities($p), $con, '
    '; show_footer(); die(); } else if (isset($_GET['config'])) { if (@is_file($config_generator)) { define('CONFIG', true); if (!@include($config_generator)) { die("$html_heading

    Error including file $config_generator

    "); } die(); } else { die("$html_heading

    File $config_generator not found.

    "); } } else if (isset($_GET['edit_ban'])) { echo $html_heading; show_header(); echo '
    '; if ($banned_list == '') { echo '

    The banning system is not in use.
    To turn it on, set the $banned_list variable.

    '; } else if (isset($_GET['add_ban'])) { if ($handle = @fopen($banned_list, 'ab')) { fwrite($handle, $_GET['add_ban']."\n"); fclose($handle); echo '

    Ban added.

    '; } else { echo '

    Could not open ban_list file for writing.

    '; } } else if (isset($_GET['del_ban'])) { $del_ban = rtrim($_GET['del_ban']); if (($list = @file($banned_list)) && ($handle = @fopen($banned_list, 'wb'))) { for ($i=0; $iBan removed.

    '; } else { echo '

    Could not open ban_list file.

    '; } } else { echo '

    Add a new ban:

    ', "
    ", 'IP address or hostname:
    You can use wildcards if you want (*, ?, +)

    '; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    ', '
    ', '

    Remove a ban:

    '."
    "; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo ''; $list = @file($banned_list) or $list = array(); echo '

    '; } echo '

    ', $con; show_footer(); die(); } } function get_change_color($num) { if ($num > 0) { return '+'; } if ($num < 0) { return ''; } return ''; } if ($use_login_system && isset($_GET['log'])) //logfile viewer { echo $html_heading; show_header(); if (!logged_in() || !is_admin()) { echo '

    You must be logged in as an admin to access this page.

    '; } else if ($log_file == '') { echo '

    The logging system is not in use.
    To turn it on, set the $log_file variable.

    '; } else if (isset($_GET['view'])) { $log = @file($log_file) or die("Cannot open log file: $log_file"); $count_log = count($log); $max_to_display = (int)$_GET['view']; $num = (($max_to_display == 0) ? $count_log : min($max_to_display, $count_log)); echo "

    Last $num log entries (of $count_log".')

    '; for ($i=0; $i<$num; $i++) { $entries = explode("\t", rtrim($log[$count_log-$i-1])); $num_entries = count($entries); if ($num_entries > 5) { echo "\n' : '"light_row">'), ''; for ($j=0; $j<$num_entries; $j++) { echo ''; } if ($num_entries === 6) { echo ''; } echo ''; } } echo '
     Date TimeIP HostnameReferrer File/Folder ViewedOther
    ', ($i + 1), '', (($j == 4 && $entries[4] != 'N/A') ? ''.htmlentities($entries[$j]).'' : htmlentities($entries[$j])).' 
    '; } else if (isset($_GET['stats'])) { if (!@include($path_to_language_files.'country_codes.php')) { die("

    File not found: {$path_to_language_files}country_codes.php

    "); } $extensions = $dates = $unique_hits = $countries = array(); $total_hits = 0; $h = @fopen($log_file, 'rb') or die("

    Cannot open log file: $log_file

    "); while (!feof($h)) { $entries = explode("\t", rtrim(fgets($h, 1024))); if (count($entries) > 5) { //find the number of unique visits if ($entries[5] == $base_dir) { $total_hits++; if (!in_array($entries[3], $unique_hits)) { $unique_hits[] = htmlentities($entries[3]); } //find country codes by hostnames $cc = ext($entries[3]); if (preg_match('/^[a-z]+$/i', $cc)) { add_num_to_array($cc, $countries); } //find the dates of the visits add_num_to_array($entries[0], $dates); } //find file extensions else if (($ext = ext($entries[5])) && preg_match('/^[\w-]+$/', $ext)) { add_num_to_array($ext, $extensions); } } } fclose($h); $num_days = count($dates); $avg = round($total_hits/$num_days); echo '', "
      TotalDaily
    Hits $total_hits$avg", '
    Unique Hits '.count($unique_hits).'', round(count($unique_hits)/$num_days), '

    Percent Unique: ', number_format(count($unique_hits)/$total_hits*100, 1), '

    '; arsort($extensions); arsort($countries); $date_nums = array_values($dates); echo '

    '; $i = 0; foreach ($dates as $day => $num) { $diff = $num - $avg; $change = (($i > 0) ? ($num - $date_nums[$i-1]) : 0); $change_color = get_change_color($change); $diff_color = get_change_color($diff); $class = (($i++ % 2) ? 'dark_row' : 'light_row'); echo ""; } echo '
    Date Hits That DayChange From Previous Day Difference From Average ('.$avg.')
    $day $num $change_color$change $diff_color$diff

    '; $i = 0; foreach ($extensions as $ext => $num) { $class = (($i++ % 2) ? 'dark_row' : 'light_row'); echo "'; } echo '
    Downloads based on file extensions TotalDaily
    $ext $num", number_format($num/$num_days, 1), '

    '; $i = 0; foreach ($countries as $c => $num) { $c_code = (isset($country_codes[strtolower($c)]) ? ' ('.$country_codes[strtolower($c)].')' : ''); $class = (($i++ % 2) ? 'dark_row' : 'light_row'); echo "\n"; } echo '
    Hostname ISP extension TotalDaily
    $c{$c_code}$num", number_format($num / $num_days, 1), "
    '; } else { echo '
    ' ."
    "; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '

    List the latest enties in the log file (0 to view all).

    or view statistics.

    '; } echo '

    Continue.

    '; show_footer(); die(); } if ($use_login_system && (isset($_POST['admin']) || isset($_GET['admin']))) //user admin section { echo $html_heading; show_header(); if (!logged_in() || !is_admin()) { echo '

    You must be logged in as an admin to access this page.

    '; } else if (isset($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['admin'])) { $pwd_reg_exp = '^[A-Za-z0-9_-]+$'; if (strlen($_POST['password1']) < 6) { echo '

    Password must be at least 6 characters long.

    '; } else if (!ereg($pwd_reg_exp, $_POST['username'])) { echo 'The username must only contain alpha-numeric characters, underscores, or dashes.', '
    It must match the regular expression: ', htmlentities($pwd_reg_exp), ''; } else if ($_POST['password1'] != $_POST['password2']) { echo '

    Passwords do not match.

    '; } else if (is_username($_POST['username'])) { echo '

    That username already exists.

    '; } else { $handle = @fopen($user_list, 'ab') or die("

    Could not open file $user_list for writing.

    "); fwrite($handle, md5($_POST['password1']).$_POST['admin'].$_POST['username']."\n"); fclose($handle); echo '

    User added. Continue.

    '; } } else if (isset($_POST['deluser'], $_POST['doit'])) { if ($_POST['doit']) { if (is_user_admin($_POST['deluser']) && num_admins() < 2) { echo '

    You cannot remove this user because it is the only admin.
    Create another user with admin rights, then delete this user.

    Continue.

    '; } else { $handle = @fopen($user_list, 'wb') or die("

    Could not open file $user_list for writing.

    "); foreach ($global_user_list as $look) { if (strcasecmp($_POST['deluser'], substr(rtrim($look), 33)) !== 0) { fwrite($handle, $look); } } fclose($handle); echo '

    User '.$_POST['deluser'].' has been removed. Continue.

    '; } } else { echo '
    ', 'Are you sure you want to remove ', $_POST['deluser'], "?

    ", '', '
    '; } } else { echo "

    Add a user:

    Username:
    Password:
    Password:
    Is Admin?:

    Delete a user:

    Select user to delete:

    '; } show_footer(); die(); } else if ($use_login_system && isset($_GET['logout'])) //logout { session_unset(); session_destroy(); redirect($this_file); } else if ($use_login_system && (isset($_POST['passwd']) || isset($_GET['passwd']))) //change password { echo $html_heading; show_header(); if (!logged_in()) { echo '

    You must login to access this page.

    '; } else if (isset($_POST['oldpass'], $_POST['newpass1'], $_POST['newpass2'])) { if (strlen($_POST['newpass1']) < 6) { echo '

    New password too short (must be at least 6 characters).

    '; } else if ($_POST['newpass1'] != $_POST['newpass2']) { echo '

    New passwords do not match.

    '; } else if (check_login($_SESSION['user'], md5($_POST['oldpass']))) { $handle = @fopen($user_list, 'wb') or die("

    Could not open file $user_list for writing.

    "); foreach ($global_user_list as $look) { fwrite($handle, ((strcasecmp($_SESSION['user'] , substr(rtrim($look), 33)) === 0) ? md5($_POST['newpass1']).substr($look, 32) : $look)); } fclose($handle); echo '

    Password for '.$_SESSION['user'].' has been changed.

    You must now logout.

    '; } else { echo '

    Incorrect old password.

    '; } } else { echo "
    Old Password:
    New Password:
    New Password:

    "; } show_footer(); die(); } $total_bytes = 0; if ($links_file != '' && isset($_GET['link'])) //redirect to a link { if (ok_to_log()) { if ($log_file != '') { if ($write = @fopen($log_file, 'ab')) { fwrite($write, date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t" .$_GET['link']."\tLink file\n"); fclose($write); } } if ($download_count != '') { add_to_file($_GET['link'], $download_count); } } redirect($_GET['link']); } if ($file_dl != '') //if the user specified a file to download, download it now { if (!@is_file($dir.$file_dl)) { header('HTTP/1.0 404 Not Found'); echo $html_heading; show_header(); echo '

    Error 404: file not found

    ', htmlentities($dir . $file_dl), ' was not found on this server.'; show_footer(); die(); } if ($anti_leech && !isset($_SESSION['ref']) && ($referrer == 'N/A' || !stristr($referrer, $_SERVER['SERVER_NAME']))) { if ($log_file != '' && ok_to_log()) { if ($write = @fopen($log_file, 'ab')) { fwrite($write, date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t$dir$file_dl\tLeech Attempt\n"); fclose($write); } } $ref = (($referrer == 'N/A') ? 'typing it in the address bar...' : $referrer); echo $html_heading; show_header(); echo '

    This PHP Script has an Anti-Leech feature turned on.

    Make sure you are accessing this file directly from ', htmlentities($_SERVER['SERVER_NAME']), '

    ', 'It seems you are trying to get it from ', "$ref

    Your IP address has been logged.
    $ip ($host)"; $index_link = 'http://'.$_SERVER['SERVER_NAME'].$this_file.'dir='.translate_uri($subdir); echo '

    Here is a link to the directory index the file is in:
    ', htmlentities($index_link), '

    '; show_footer(); die(); } if (ok_to_log()) { if ($download_count != '') { add_to_file($dir.$file_dl, $download_count); } if ($log_file != '') { if ($write = @fopen($log_file, 'ab')) { fwrite($write, date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t$dir$file_dl\n"); fclose($write); } } } if ($force_download) //use php to read the file, and tell the browser to download it { if (!($fn = @fopen($dir.$file_dl, 'rb'))) { die($html_heading.'

    Error 401: permission denied

    you cannot access ' .htmlentities($file_dl).' on this server.'); } $outname = get_basename($file_dl); $size = @filesize($dir.$file_dl); if ($size !== false) { header('Content-Length: '.$size); } header('Content-Type: '.find_mime_type(ext($outname)).'; name="'.$outname.'"'); header('Content-Disposition: attachment; filename="'.$outname.'"'); @set_time_limit(0); while (true) { $temp = @fread($fn, (int)($speed * 1024)); if ($temp === '') { break; } echo $temp; flush(); if ($bandwidth_limit) { sleep(1); } } fclose($fn); die(); } redirect(translate_uri($dir.$file_dl)); } if ($log_file != '' && ok_to_log()) //write to the logfile { if ($write = @fopen($log_file, 'ab')) { $log_str = date($date_format)."\t".date('H:i:s') ."\t$ip\t$host\t$referrer\t$dir"; if ($search != '') { $log_str .= "\tSearch: $search"; } fwrite($write, $log_str."\n"); fclose($write); } else { echo '

    Error: Could not write to logfile.

    '; } } if ($anti_leech && !isset($_SESSION['ref'])) { $_SESSION['ref'] = 1; } echo $html_heading; show_header(); if (!@is_dir($dir)) //make sure the subfolder exists { echo '

    Error: The folder '.htmlentities($dir) .' does not exist.

    '; $dir = $base_dir; $subdir = ''; } if ($enable_searching && $search != '') //show the results of a search { echo '

    ', $words['search results'], ' :
    for ', htmlentities($dir), ' and its subdirectories

    '; $results = search_dir($dir, $search); natcasesort($results); if ($_SESSION['sort'] == 'd' && $_SESSION['sortMode'] == 'f') { $results = array_reverse($results); } for ($i=0; $i'; if ($icon_path != '') { echo '[dir] '; } echo htmlentities($file)."/
    \n"; } else if (preg_match('/\|$/', $file)) { $file = substr($file, 0, -1); $display = get_stored_info($file, $dir.$links_file); if ($display == '') { $display = $file; } echo 'dir=', translate_uri($subdir), '&link=', translate_uri($file), '" title="Link to: ', $file, '">', icon(ext($display)), htmlentities($display), '
    '; } else { echo 'dir=', translate_uri(dirname($file)).'/&file=', translate_uri(get_basename($file)), '">', icon(ext($file)), htmlentities($file), "
    \n"; } } if (!count($results)) { echo '

    [ ', $words['no results'], ' ]

    '; } echo '

    ', $words['end of results'], ' (', count($results), ' ', $words['found'], ')

    '; show_search_box(); echo '

    Go back.

    '; show_footer(); die(); } //path navigation at the top echo '
    ', $words['index of'], ' ', htmlentities(substr(str_replace('/', ' / ', $base_dir), 0, -2)), '/ '; $exploded = explode('/', $subdir); $c = count($exploded) - 1; for ($i=0; $i<$c; $i++) { echo '', htmlentities($exploded[$i]), ' / '; } //begin the table echo "
    \n\n", ''; table_heading($words['file'], 'f', 'Sort by Filename'); if ($show_type_column) { table_heading('Type', 't', 'Sort by Type'); } if ($download_count != '') { table_heading('Downloads', 'h', 'Sort by Hits'); } if ($show_size_column) { table_heading($words['size'], 's', 'Sort by Size'); } if ($show_date_column) { table_heading($words['modified'], 'm', 'Sort by Date'); } if ($description_file != '') { table_heading('Description', 'd', 'Sort by Description'); } echo ''; if ($subdir != '') //if they are not in the root folder, have a link to the parent directory { echo ''; $subdir .= '/'; } flush(); $file_array = get_file_list($dir); $size_array = $date_a_array = $date_m_array = $desc_array = $hit_array = $type_array = array(); $c = count($file_array); for ($i=0; $i<$c; $i++) { $thisf = $dir.$file_array[$i]; if (preg_match('/\|$/', $thisf)) //it is a link { $thisf = substr($thisf, 0, -1); $type_array[] = ($show_type_column ? ext(get_stored_info(substr($file_array[$i], 0, -1), $dir.$links_file)) : ''); $hit_array[] = (($download_count != '' && !@is_dir($thisf)) ? (int)(get_stored_info(substr($file_array[$i], 0, -1), $download_count)) : 0); $date_m_array[] = 'N/A'; $date_a_array[] = 'N/A'; $size_array[] = '[Link]'; } else //it is an actual file or folder { $size_array[] = ($show_size_column ? (@is_dir($thisf) ? ($show_dir_size ? dir_size("$thisf/") : 0) : max((int)@filesize($thisf), 0)) : 0); $type_array[] = (($show_type_column && !@is_dir($thisf)) ? ext($thisf) : ''); $hit_array[] = (($download_count != '' && !@is_dir($thisf)) ? (int)(get_stored_info($thisf, $download_count)) : 0); if ($show_date_column) { $date_m_array[] = filemtime($thisf); $date_a_array[] = fileatime($thisf); } else { $date_m_array[] = 0; $date_a_array[] = 0; } } $desc_array[] = (($description_file == '') ? '' : get_stored_info($thisf, $description_file)); } switch (strtolower($_SESSION['sortMode'])) { case 's': array_multisort($size_array, $file_array, $date_m_array, $date_a_array, $hit_array, $desc_array, $type_array); break; case 'm': array_multisort($date_m_array, $file_array, $size_array, $date_a_array, $hit_array, $desc_array, $type_array); break; case 'd': array_multisort($desc_array, $file_array, $date_m_array, $size_array, $date_a_array, $hit_array, $type_array); break; case 'h': array_multisort($hit_array, $file_array, $date_m_array, $size_array, $date_a_array, $desc_array, $type_array); break; case 't': array_multisort($type_array, $file_array, $hit_array, $date_m_array, $size_array, $date_a_array, $desc_array); } if (strtolower($_SESSION['sort']) === 'd') //if the current sort mode is set to descending, reverse all the arrays { $file_array = array_reverse($file_array); $size_array = array_reverse($size_array); $date_m_array = array_reverse($date_m_array); $date_a_array = array_reverse($date_a_array); $desc_array = array_reverse($desc_array); $hit_array = array_reverse($hit_array); $type_array = array_reverse($type_array); } $folder_count = $file_count = $dl_count = 0; for ($i=0; $i<$c; $i++) //display the list of files { $value = $file_array[$i]; echo "\n' : '"light_row">'); //file column echo ''; //end filename column //filetype column if ($show_type_column) { echo ''; } //hits column if ($download_count != '') { $dl_count += $hit_array[$i]; echo ''; } //size column if ($show_size_column) { echo ''; } //date column if ($show_date_column) { echo ''; } //description column if ($description_file != '') { echo ''; } echo "\n"; } //footer of the table echo ''; if ($show_type_column) { echo ""; } if ($download_count != '') { echo ""; } if ($show_size_column) { echo '\n"; } if ($show_date_column) { echo ''; } if ($description_file != '') { echo ''; } echo '
    '; if ($icon_path != '') { echo "\"[dir]\" "; } echo $words['parent directory'], '
    ', icon(ext($display)), htmlentities($display), ''; } else //it is a real file or folder { if (@is_dir($npart)) { $folder_count++; if ($icon_path != '') { if ($folder_expansion) { $listVal = (in_array($npart, $_SESSION['expanded']) ? 'collapse' : 'expand'); echo 'dir=', translate_uri($subdir), "&$listVal=", translate_uri($value), '">[dir] ', ''; } else { echo 'dir=', translate_uri($subdir . $value), '/">', '[dir] '; } } else { echo 'dir=', translate_uri($subdir . $value), '/">'; } echo htmlentities($value).''; if ($show_folder_count) { $n = num_files($npart); $s = (($n == 1) ? $words['file'] : $words['files']); echo " [$n $s]"; } } else //is a file { $file_count++; echo 'dir=', translate_uri($subdir), '&file=', translate_uri($value), "\">", icon(ext($npart)), htmlentities($value), ''; if ($md5_show && $size_array[$i] > 0 && $size_array[$i] / 1048576 <= $md5_show) { echo ' [get md5sum]'; } } if ($use_login_system && logged_in() && is_admin()) { echo ' [delete, ', 'rename/move]'; } $age = (time() - $date_m_array[$i]) / 86400; $age_r = round($age, 1); $s = (($age_r == 1) ? '' : 's'); if ($days_new && $age <= $days_new) { echo (($icon_path == '') ? ' [New]' : ' '.'); } if ($folder_expansion && @is_dir($npart) && in_array($npart, $_SESSION['expanded'])) { $ex_array = get_file_list($npart.'/'); if ($_SESSION['sort'] == 'd' && $_SESSION['sortMode'] == 'f') { $ex_array = array_reverse($ex_array); } echo ''; } } if ($use_login_system && $description_file != '' && logged_in() && is_admin()) //"edit description" link { echo ' [change description]'; } if ($thumbnail_height > 0 && in_array(ext($value), array('png', 'jpg', 'jpeg', 'gif')) && @is_file($npart)) //display the thumbnail image { echo ' Thumbnail of ', $value, ''; } echo '', (($type_array[$i] == '') ? ' ' : htmlentities($type_array[$i])), '', ((!@is_dir($npart)) ? $hit_array[$i] : ' '), ''; $ds = $size_array[$i]; if ($ds === '[Link]') { echo $ds; } else { $total_bytes += $ds; $size_h = get_filesize($ds); echo (@is_dir($npart) ? ($show_dir_size ? "$size_h" : '[dir]') : "$size_h"); } echo ''; if ($date_a_array[$i] == 'N/A') { echo 'N/A'; } else { $a = date($date_format.' h:i:s A', $date_a_array[$i]); $m = date($date_format.' h:i:s A', $date_m_array[$i]); echo "", date($date_format, $date_m_array[$i]), ''; } echo '', (($desc_array[$i] != '') ? $desc_array[$i] : ' '), '
    ', "\n$file_count ", $words[(($file_count == 1) ? 'file' : 'files')], " - $folder_count ", $words['folders'], ' Total: $dl_count', $words['total size'], ': ', get_filesize($total_bytes), "  
    '; /* * We request that you do not remove the link to the AutoIndex website. * This not only gives respect to the large amount of time given freely by the * developer, but also helps build interest, traffic, and use of AutoIndex. */ echo "\n", '
    '; if ($enable_searching) { show_search_box(); } if ($use_login_system) { if (!logged_in()) { echo ''; show_login_box(); } else //show user options { echo '
    '; if (is_admin()) { echo '

    Reconfigure script

    ', '

    User account management', '
    Log file viewer / statistics', '
    Links file editor', '
    Edit ban list

    ', '

    Create a folder (in current directory)', '
    Copy a remote file (to current directory)

    '; } echo '

    Change password
    Log out [ ', $_SESSION['user'], ' ]

    '; } } echo '
    '; if ($allow_uploads && (!$use_login_system || logged_in())) { echo "
    Upload file(s) to this folder
    '; } if ($select_language) { echo '

    Select Language:

    ', "
    '; if ($index != '' && strpos($index, '?') !== false) { $id_temp = explode('=', $index, 2); $id_temp[0] = substr(strstr($id_temp[0], '?'), 1); echo ""; } echo '
    '; } show_footer(); //find time it took for the page to generate, in milliseconds $page_time = round((get_microtime() - $start_time) * 1000, 1); echo ' '; //We request that you retain the above copyright notice. if ($index == '') { echo '
    '; } ?>