![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jan 2005
Posts: 44
Rep Power: 0
![]() |
hi, i have written my own directory lister that automatically generates a link for the file
but there seems to be a problem with files or folders that contain spaces in there name the script will only get the text before the first space and nothing after can any1 see anything wrong with my script or is there a better way to list the files?
//Header Stuff!!!
$me = $_SERVER['PHP_SELF'];
$Apathweb = explode("/", $me);
$FileNm = array_pop($Apathweb);
$webpt = implode("/", $Apathweb);
$actuURL = "http://".$_SERVER['HTTP_HOST'].$webpt;
include("http://".$_SERVER['HTTP_HOST']."/manik/header.php");
// END OF HEADER STUFF!!!
$bleb = "http://".$_SERVER['HTTP_HOST']."/manik/images";
$fred = getcwd()."/";
$fredon = dirname($fred);
$dir4me = @opendir($fred) or header("Status: 404 Not Found");
while (false !== ($file = readdir($dir4me))) {
if ($file != "." && $file != ".." && $file !=".htaccess" && $file != ".htpasswrd" && $file != "index.php"&& $file != "index.html"&& $file != "manik.php" && $file != "~.htaccess" && $file != "~.passwrd" && $file != ".passwd"&& $file != "~passwd"&& $file != "~.passwd"&& $file != ".log") { /* Remeber To provent a certain file or filetype add it to this line*/
$len = filesize("$file");
echo "<p align=center>Title: $file";
echo "<p align=center>Size: $len (bytes) <br>";
echo "<p align=center><a href=$actuURL/$file><img border=0 onmouseover=roll_over('but1', '$bleb/dl_up.jpg') onmouseout=roll_over('but1', '$bleb/dl_dwn.jpg') src=$bleb/dl_dwn.jpg width=117 height=48 name=but1></a></p>";
echo "<hr>";
}
}
closedir($dir4me);
?>
</p><style type="text/css">
<!--
body {
background-color: #E0E0E0;
}
-->
</style>
<p align="center"></p>
<p align="center">Copyright © 2005 <a href="http://www.underground-vinyls.co.uk/manik/">Manik Script</a> v0.5 written by Stuart Bell<br>
<p></p>
<script language = "Javascript">
function roll_over(img_name, img_src)
{
document[img_name].src = img_src;
}
</script>
<script language=JavaScript>
<!--
var message="Sorry but Right Click has been disabled!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script>
<?php
//Footer stuff
$me = $_SERVER['PHP_SELF'];
$Apathweb = explode("/", $me);
$FileNm = array_pop($Apathweb);
$webpat = implode("/", $Apathweb);
$actuURL = "http://".$_SERVER['HTTP_HOST'].$webpt."/".$FileNm;
include("http://".$_SERVER['HTTP_HOST']."/manik/footer.php");
// END of FOOTER STUFF!!!
?>thanx in advanced 4 your replays |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
Hi,
The problem in your code resides in the line 21 when you calls the echo function to create the image with the link to the file: echo "<p align=center><a href=$actuURL/$file><img border=0 onmouseover=roll_over('but1', '$bleb/dl_up.jpg') onmouseout=roll_over('but1', '$bleb/dl_dwn.jpg') src=$bleb/dl_dwn.jpg width=117 height=48 name=but1></a></p>";When dealing with urls we have to take an extra step to convert the string of the location to fit the standard needs. Just calling the rawurlencode() function should solve your problem. echo "<p align=center><a href=$actuURL/".rawurlencode($file)."><img border=0 onmouseover=roll_over('but1', '$bleb/dl_up.jpg') onmouseout=roll_over('but1', '$bleb/dl_dwn.jpg') src=$bleb/dl_dwn.jpg width=117 height=48 name=but1></a></p>";I hope this information helps you, codetaino PD: sorry for my english... spanish is my primary language.
__________________
"God bless u all" :) |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jan 2005
Posts: 44
Rep Power: 0
![]() |
thanx alot codetaino it worked a treat
i ow ya one thanx again magic_e |
|
|
|
|
|
#4 | |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
Quote:
![]() glad to help!
__________________
"God bless u all" :) |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|