
January 5th, 2005, 10:13 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Location: Bangalorre
Posts: 107
Time spent in forums: 17 h 25 m 43 sec
Reputation Power: 0
|
|
|
Explain Directory Listor Script which is INSIDE!!!!
How does this script work's ??? it a script which points out to the link of the files in a particular directory ( automatically lists all the files the the directory ) How it works please explain ?????
Can some one tell me how to add a subdirectory listor to this script ???
here is the index.php file script
Quote: <?
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""." \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
include("../wapbuddy_settings.php");
if (!isset($page)) {$page = 0;}
$total = 0;
if(!($dp = opendir("./"))) die ("Cannot open ./");
$file_array = array();
while ($file = readdir ($dp))
{
if(substr($file,0,1) != '.' and $file != "index.php")
{
$file_array[] = $file;
}
}
$file_count = count ($file_array);
sort ($file_array);
?>
<wml>
<card id="card1" title="<? echo $conf["site_name"] ?>">
<p mode="nowrap">
<do type="option" label="Home"><go href="../index.php"/></do>
<? echo "<a href=\"../index.php\">Home</a><br/><br/>"; ?>
<?
if ($file_count > 0)
{
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];
while (list($fileIndexValue, $file_name) = each ($file_array))
{
if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{
echo "<a href=\"$file_name\">$file_name</a> (". round(filesize($file_name)/1024,1) . "kb)<br/>";
$total = $total + filesize($file_name);
}
}
if (($file_count > 0) AND ($page != 0))
{
// previous button
$prev_page = $page -1;
echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page\">Prev</a><br/>";
}
if (($file_count > 0) AND ($last_record < $file_count))
{
// next button
$next_page = $page + 1;
echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page\">Next</a><br/>";
}
echo "<br/>Directory:<br/>$file_count ";
if ($file_count == 1)
{echo "file";}
else
{echo "files";}
echo " (" . round($total/1024,1) . "kb)";
echo "<br/><a href=\"../index.php\">Home</a>";
}
closedir($dp);
?>
</p>
</card>
</wml> |
here's the wapbuddy_settings.php script
Quote: <?
// SETTTINGS
$conf["site_name"] = "WapBuddy"; // the name of your site
$conf["welcome_message"] = "Powered by WapBuddy"; // default greeting
$conf["items_per_page"] = 10;
$conf["dirs"] = array ( // folders which store downloads
"Application"
,"Games"
,"Ringtones"
,"Wallpaper"
//,your new folder (don't forget the comma)
);
?> |
__________________

Last edited by hmvrulz : January 5th, 2005 at 10:16 PM.
Reason: add some things
|