I coded wapbuddy to display themes with preview .
I now want to display themes in 3 sort methods a-z// default, z-a, last uoloaded , but as my php is not so strong i cant can someone help me to code this script with sort. Also if one can then please add the jump to page also. i is also truobing when i wanting to do. Please help...
I now want to display themes in 3 sort methods a-z// default, z-a, last uoloaded , but as my php is not so strong i cant can someone help me to code this script with sort. Also if one can then please add the jump to page also. i is also truobing when i wanting to do. Please help...
Code:
<?php /* /////////////////////// WAP Theme Manager Author Ayon Baidya ////////////////////// */ 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\">"; //configuring $setting["max_file_show"] = 10; //max file per page to be shown $setting["site_name"] = "Mobile free themes"; //Define site name $setting["intro"] = "Free mobile themes, nokia, sony erricsson, motorola "; $myfilename="index.php"; //change if you change script filename $thumb="Thumbs.db"; $SCRIPT_NAME=getenv("SCRIPT_NAME"); $path=$_GET["path"]; $page=$_GET["page"]; //get path if (!isset($path)) { $path = "./"; } if (!file_exists($path)) { echo "<wml><card id=\"card1\" title=\"404\"> File not found! <a href=\"".$SCRIPT_NAME."\">Home</a></p></card></wml>"; exit; } if (strstr($path,"..")) { echo "<wml><card id=\"card1\" title=\"404\"> Invalid Path! <a href=\"".$SCRIPT_NAME."\">Home</a></p></card></wml>"; exit; } //get the base directory $base_dir = getcwd(); if ($path=="/") { $path = "./"; } //change dirctory to path now we will read the files of path chdir($path); $current_dir = getcwd(); $directory = dir("./"); $directories_array = array(); $files_array = array(); while ($file = $directory->read()) { if (is_dir($file) AND $file != ".") { $directories_array[] = $file; } if (is_file($file) and $file != "".$myfilename."" and $file != "".$thumb."") { $files_array[] = $file; } } //sorting files and directory sort($directories_array); sort($files_array); //counting files $file_count = count ($files_array); $half_count = count ($files_array) / 2; //end directory reading and closing directory $directory->close(); //Get page number if (!isset($page)) {$page = 0;} $total = 0; ?> <wml> <card id="card1" title="<?php echo $setting["site_name"] ?>"> <p mode="nowrap">[size="1"] <do type="option" label="Home"><go href="<?php echo"http://wap.mobilemobi.net/"; ?>"/></do> <? echo $setting["intro"] ?> [b]Categories[/b] <? foreach($directories_array as $value) { if ($value=="..") { $new_path=strrev(substr(strstr(substr(strstr(strrev($path),"/"),1),"/"),1)); } else{ $new_path=$path.$value; } if (($value != "..") or ($base_dir != $current_dir)) { echo "<a href=\"$SCRIPT_NAME?path=".$new_path."/"."\">[b]".str_replace("..","<==",$value)."[/b]</a> "; } } ?> [b]Themes[/b] <? if ($file_count > 0) { $first_record = $page * $setting["max_file_show"]; $last_record = $first_record + $setting["max_file_show"]; while (list($fileIndexValue, $file_name) = each ($files_array)) { if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) { //sis file show only, and thumb creation if (strpos($file_name, '.sis',1)) { $image_name=str_replace("sis","jpg","$file_name"); echo "<a href=\"$path$file_name\"><img src=\"$path$image_name\" width=\"40\" height=\"50\" alt=\"Themes\" /></a> (". round(filesize($file_name)/1024,1) . "kb) "; $total = $total + filesize($file_name); } } } if (($file_count > 0) AND ($page != 0)) { // previous button $prev_page = $page -1; echo " <a href=\"".$SCRIPT_NAME."?page=$prev_page&path=".$path."\">Prev</a> "; } if (($file_count > 0) AND ($last_record < $file_count)) { // next button $next_page = $page + 1; echo " <a href=\"".$SCRIPT_NAME."?page=$next_page&path=".$path."\">Next</a> "; } echo " Category: $half_count"; if ($file_count == 1) {echo "file";} else {echo "files";} echo " (" . round($total/1024,1) . "kb)"; } echo "-- "; echo "<a href=\"http://wap.mobilemobi.net/themes\">Themes</a> "; echo " <a href=\"http://wap.mobilemobi.net\">Home</a>"; ?> [/size]</p> </card> </wml>