Hi all,
I'm trying to configure this script entitled Czar New File... essentially it lists the 5 newest files added to a directory. Anyways, I have it configured nearly to the point of completion, but when you click the link of the file, it errors because it's trying to call the web address and the root directory on top of it.
But enough of my poor explanation.... here's the problem:
http://www.foothillsbaptist.org/new08/resources.htm
(Just try clicking either of the two listed files)
and here's the code:
PHP Code:
<body link="#133980">
<? ########################################## ### ### CzarNewfile v1.01 ### Made by: Czaries [czaries@pacbell.net] ### http://www.czaries.net/scripts/ ### for more scripts and updates. ### ##########################################
### How many files to show? ### // i.e. "Newest 5 Files", "Newest 10 Files", etc... $filelim = "5";
### Directory to look in for files ### /* Directory, from the base http URL your files are in. Include BOTH starting and trailing slashes ( / ). i.e. If your files are at http://yoursite.com/downloads, put "/downloads/" - WITH BOTH SLASHES! */ # $checkdir = "/"; // base directory (http://yoursite.com/) $checkdir = "/home/**USER**/public_html/new08/downloads/2008/ministries/adult discipleship/";
### File extensions to include ### // Turns feature "on" or "off" $extlim = "off"; /* Allows you to limit which types of files will be included Separate each by quotes/comma, you may use as many as you like INCLUDE the beginning period ( . )! Note: Only includes text from the LAST period on (i.e. If you want to include ".tar.gz" files, put ".gz" only. This is a bug that not even the PHP file extension function can read, and it something that cannot be fixed without extensive coding) */ # $extarr = array(".exe", ".zip", ".rar"); // Only accepts EXE, ZIP, and RAR files $extarr = array(".exe", ".zip", ".rar", ".gz", ".sit", ".hqx");
### Table Properties ### // Width of output table $tblwidth = "150"; // can be a number, or a percent // Background color of output table $tblbg = ""; // hexidecimal format (i.e. "#FFFFFF")
### No need to edit below this line ###
### Put starting & trailing slash on incase user forgot if(strrpos($checkdir, "/") != (strlen($checkdir)-1)) { $checkdir .= "/"; } if(strpos($checkdir, "/") != "0") { $checkdir = "/$checkdir"; } ### Get full root path of the file directory $filedir = "$DOCUMENT_ROOT$checkdir"; ### Get the name of this file, without the beginning slash $thisfile = basename($PHP_SELF); ### Make sure directory exists if(!file_exists($filedir)) { print "No such directory!<br>Check to make sure the \$checkdir variable is correct.<br><br>Current: \$checkdir = \"$checkdir\";"; exit; } ### Open folder, get file names and load them into an array if ($handle = opendir($filedir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != $thisfile && !is_dir("$filedir$file")) { if($extlim == "on") { if(in_array(strrchr($file, "."), $extarr)) { $farr[$file] = date ("U", filemtime("$filedir$file")); } } else { $farr[$file] = date ("U", filemtime("$filedir$file")); } } } closedir($handle); }
### Check to make sure there are actually items in the folder $farrc = count($farr); if ($farrc != "0") { if($farrc < $filelim) { $filelim = $farrc; } ?> <!-- CzarNewfile v1.01 --> <font face="arial" size=10 color="#133980"> <table width="<? print $tblwidth; ?>" border="0" cellspacing="0" cellpadding="0"<? if($bgcolor != "") { print " bgcolor=\"$tblbg\""; } ?>> <tr><td colspan="3"><? echo "<b>Newest $filelim Files</b><br>\n"; ?></td></tr> <? ### Sort by date, descending arsort($farr); $limset = "1"; ### Print each result foreach($farr as $filename => $date) { if($limset <= $filelim) { print "<tr><td nowrap>$limset) </td><td><a href=\"$checkdir$filename\">$filename</a> </td><td nowrap>[" . date ("n/j", $date) . "]</td></tr>\n"; $limset++; } } print "</table>\n"; } else { print " <!-- CzarNewfile v1.01 --> There are currently no files to display! "; } ?> <!-- CzarNewfile made by Czaries - www.czaries.net -->
</body>
Thanks in advance!
|