Hello ive made a download script i got it to page through files but something is not 100% right with the paging it displays 6 files then 6 files then 1 file then 3 then 1 but on other pages it displays the right amount could someone please let me send them a private message with the source code i dont want to share it online just yet i want to wait until its finished maybe thanks
Download script paging help
Collapse
X
-
GuestTags: None
-
Guest
PHP Code:<?php
include("config.php");
$folder = @$_GET['folder'];
$page = @$_GET['page'];
$path = getcwd();
$path = "$path/" . "$folder";
$files = scandir($path);
$back = ("$page")-1;
$page = ("$page")+1;
$count = count($files);
$items = (("$page")*("$items_per_page"));
$up = "$folder\\";
$up = strrev($up);
$up = str_replace("\\", "/", $up);
$up = preg_replace("/\/(.*?)\//is", "", $up, 1);
$up = strrev($up);
echo "$head";
echo "$logo";
echo "<a href=$address/" . "folders.php?folder=" . "$up" . ">Up</a>" . "<br />";
for($i = $items; $i < (("$items")+6); $i++){
if($i < $count){
$files = str_replace(" ", "%20", $files);
$filename = str_replace("%20", " ", $files);
$path = str_replace(" ", "%20", $path);
$folder = str_replace(" ", "%20", $folder);
if (preg_match("/.jar/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.sis/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.sisx/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.zip/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.rar/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.jpeg/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.jpg/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.png/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
elseif (preg_match("/.gif/i", "$files[$i]")){
echo "<IMG SRC=\"$address/images/file.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "files.php?file=" . "$folder/" . "$files[$i]" . "&name=" . "$files[$i]" . "&folder=" . "$folder/" .">" . "$files[$i]" ."</a>";
echo "<br />";
}
else {
echo "<IMG SRC=\"$address/images/folder.png\" WIDTH=\"20\" HEIGHT=\"20\" \"><a href=$address/" . "folders.php?page=0" . "&folder=" . "$folder/" . "$files[$i]" . ">" . "$files[$i]" ."</a>";
echo "<br />";
}
}
}
if($back >= 0){
echo "<a href=" . "$address/" . "folders.php?page=$back" . "&folder=$folder" . ">Back</a>" . "<br />";
}
if($i < $count){
echo "<a href=" . "$address/" . "folders.php?page=$page" . "&folder=$folder" . ">Next</a>" . "<br />";
}
echo "<FORM ACTION=\"search.php\" METHOD=\"GET\">";
echo "search:<br />";
echo "<INPUT NAME=\"search\" TYPE=TEXT>";
echo "<br />";
echo "<INPUT TYPE=SUBMIT VALUE=\"Search\">";
echo "</FORM>";
echo "$footer";
?>
decided to post the source im trying to stop it from reading the php files in the array but then it just leaves blank spaces and is still counted in the for function any ideas how to stop this ?Last edited by metulj; 08.10.10, 18:48.
Comment
-
Guest
Comment