Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 9th, 2005, 1:24 PM   #1
magic_e
Programmer
 
Join Date: Jan 2005
Posts: 44
Rep Power: 0 magic_e is on a distinguished road
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 &copy; 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
magic_e is offline   Reply With Quote
Old Jan 10th, 2005, 4:07 AM   #2
codetaino
Programmer
 
codetaino's Avatar
 
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4 codetaino is on a distinguished road
Talking

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" :)
codetaino is offline   Reply With Quote
Old Jan 10th, 2005, 10:37 AM   #3
magic_e
Programmer
 
Join Date: Jan 2005
Posts: 44
Rep Power: 0 magic_e is on a distinguished road
thanx alot codetaino it worked a treat

i ow ya one

thanx again

magic_e
magic_e is offline   Reply With Quote
Old Jan 10th, 2005, 5:33 PM   #4
codetaino
Programmer
 
codetaino's Avatar
 
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4 codetaino is on a distinguished road
Quote:
Originally Posted by magic_e
thanx alot codetaino it worked a treat

i ow ya one

thanx again

magic_e
no problem...

glad to help!
__________________
"God bless u all" :)
codetaino is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC