Jaquio Posted April 22, 2007 Share Posted April 22, 2007 Alright, well I have EVERYTHING listed... It is just when you try to click on anything including an '(quotesingle Apostrophe) it cuts it off right there... So something like, "Samantha's Strip Tease.mpg" cuts off into "Samantha" and nothing else.. No it isn't nothing containing nudity just some of us screwing around at school being bored. But yea, anyway to fix this? Here is what I am using. REALLY Sloppy I know, but am just trying new things. <?php $HomeDir = "/Videos/"; echo (" <BODY BGCOLOR=BLACK TEXT=WHITE LINK=GREEN VLINK=ORANGE ALINK=ORANGE> "); if ($TheDir == null or $TheDir == "Home/") { $Files = LoadFiles('./'); SortByType($Files); SortByType($Dirs); echo(" <H1><b><u>Music</u></b></H1> <H2> "); while (list($k, $v) = each($Dirs)) { echo ("<a href='?TheDir=$v[0]'>$v[0]</a><BR>"); } while (list($k, $v) = each($Files)) { echo ("$v[0]<BR>"); } } else { $Files = LoadFiles($TheDir); SortByType($Files); SortByType($Dirs); echo (" <H1><b><u>$TheDir</u></b></H1> <H2> "); $TheCDir = "../Videos/".$TheDir; $CDir = explode("/", $TheCDir); if(count($CDir) == 4){ $HDir = count($CDir) - 2; $DirN = "Home"."/"; } else { $HDir = count($CDir) - 3; $DirN = $CDir[$HDir]."/"; } echo(" <a href='?TheDir=$DirN'>$DirN</a><BR> "); while (list($k, $v) = each($Dirs)) { echo ("<a href='?TheDir=$TheDir$v[0]'>$v[0]</a><BR>"); } while (list($k, $v) = each($Files)) { echo ("<a href='$TheDir/$v[0]'>$v[0]</a><BR>"); } } function LoadFiles($dir) { global $Dirs; $Exts = array("ni", "ll", "pg", "hp", "db"); $Files = array(); $Dirs = array(); $It = opendir($dir); if (!$It) die('Cannot list files for ' . $dir); while ($Filename = readdir($It)) { if ($Filename == '.' || $Filename == '..') continue; $FileType = @filetype($dir . $Filename); if ($FileType == "dir") { $Dirs[] = array($Filename . "/", $FileType); } else { if (!in_array(substr($Filename, strlen($Filename) - 2), $Exts)) { $Files[] = array($Filename, $FileType); } } } return $Files; } function SortByType(&$Files) { sort($Files); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/ Share on other sites More sharing options...
Jaquio Posted April 22, 2007 Author Share Posted April 22, 2007 *Bump* Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235486 Share on other sites More sharing options...
genericnumber1 Posted April 22, 2007 Share Posted April 22, 2007 it's because you're using single quotes in your html and the string contains a single quote. Run urlencode() on a string before putting it into a link to fix the problem. Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235488 Share on other sites More sharing options...
Jaquio Posted April 22, 2007 Author Share Posted April 22, 2007 when I use that, it turns into "Samantha%27s+Strip+Tease.mpg" and when you click to download it, or anything returns HTTP 404 Not Found... Any idea why? Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235493 Share on other sites More sharing options...
genericnumber1 Posted April 22, 2007 Share Posted April 22, 2007 it might be the file extension throwing the browser off... instead of doing your links like "?query=blah" try doing them "thispage.php?query=blah" Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235496 Share on other sites More sharing options...
Jaquio Posted April 22, 2007 Author Share Posted April 22, 2007 I fixed it, might be sloppy as well but it works. But I had to replace the + with %20s so: <a href=".str_replace("%2F", "/", str_replace("+", "%20", urlencode($TheDir.$v["0"]))).">$v[0]</a><BR> worked, thanks for your help with urlencode. Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235498 Share on other sites More sharing options...
genericnumber1 Posted April 22, 2007 Share Posted April 22, 2007 ah.. well http://www.php.net/rawurlencode uses %20 and %2F instead if you wanna be non-messy Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235499 Share on other sites More sharing options...
Jaquio Posted April 22, 2007 Author Share Posted April 22, 2007 Ohh thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235552 Share on other sites More sharing options...
Jaquio Posted April 23, 2007 Author Share Posted April 23, 2007 Ran into another problem... Folders including an ' give me an error... "Warning: opendir(../Friends/Samatha's Stuff/) [function.opendir]: failed to open dir: No error in C:\WS\htdocs\Friends\index.php on line 131 Cannot list files for ../Friends/Samatha's Stuff/" Now I know I could rename the folder and remove ' but I've got a lot of other folders with it and don't feel like renaming them all... Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235628 Share on other sites More sharing options...
AndyB Posted April 23, 2007 Share Posted April 23, 2007 Now I know I could rename the folder and remove ' but I've got a lot of other folders with it and don't feel like renaming them all... Sounds like a Windoze-induced deathwish. The _underscore_ is your friend: sensible file names and sensible folder names will save you headaches Quote Link to comment https://forums.phpfreaks.com/topic/48109-solved-directory-listing/#findComment-235650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.