Download script paging help

Started on the old forum in October 2010 · view the original in the archive · old links redirect here

3 replies · 436 views · started 16 years ago · 1 min read

Guest #1

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

Guest #3
<?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 ?

Guest #4

fixed it 🙂

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close