corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Help Please...


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Help Please...
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 19:26   View User's Profile U2U Member Reply With Quote

Can some one please take a look at this code and tell me what I'm doing wrong...

I've written this script which will list files in a folder and create a link for them... the only thing is, it only works if it's pulling files from a different folder... Also if there is another folder in there it won't link it properly...

This is the file in action... http://www.djantd.info/Tunes/Uniting_Nations/index.php


code:
<?php
$path = "../Tunes/Uniting_Nations/";

if (strrpos($moverse,'..')) {
$moverse = str_replace('/..','',$moverse);
$moverse = substr($moverse,0,strrpos($moverse,'/'));
}

if($moverse) $moverse = $moverse."/";

echo $moverse.'<br>';

$handle=opendir($path.$moverse);

while ($file = readdir($handle)) {
if(is_dir($path.$moverse.$file) && $file != ".") {
if ($file == ".." && $moverse == "") {

} else {
echo "<a href='?moverse=".$moverse.$file."'>".$file."</a><br>";
echo('<br>');
}
} else if ($file != ".") {
echo "<a href='".$path.$moverse.$file."'>".$file."</a><br>";
echo('<br>');
}
}
?>


I want it to work like http://www.djantd.info/home.php?nav=mixes.php&t=Mixes

Exept, in that last example the folder called Uniting_Nations doesn't like right eitehr

Cheers people!!
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
4th Apr 05 at 19:31   View Garage View User's Profile U2U Member Reply With Quote

You need mod_rewrite for stuff like that.
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 19:32   View User's Profile U2U Member Reply With Quote

what... just install that on the server and that'll sort it, or do I need to change me code too?
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 19:37   View User's Profile U2U Member Reply With Quote

Is this really gonna be worth it?

Maybe I'll just screw it and do it manually
Dom
Member

Registered: 13th Sep 03
User status: Offline
4th Apr 05 at 19:56   View User's Profile U2U Member Reply With Quote

does the directory exist? if not theres your reason lol

also chmod the directory(s) to 777, that might work, or change the path from "../Tunes/Uniting_Nations/" to "/home/sites/djantd.info/public_html/Tunes/Uniting_Nations/"

Although from what i gather, your code looks alright
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 20:00   View User's Profile U2U Member Reply With Quote

Yeah that directory is good, the file is actually in that directory
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
4th Apr 05 at 20:02   View Garage View User's Profile U2U Member Reply With Quote

Why is the path ../Tunes when the folder is just ./ relative to the php file?
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 20:05   View User's Profile U2U Member Reply With Quote

Cos I use that code for other things, like my gallery and to pull files from folders in other locations.... just couldn't be arsed to modify it, I didn't think it would matter
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
4th Apr 05 at 20:06   View Garage View User's Profile U2U Member Reply With Quote

Well as you're using relative paths, you can't move the php file and the path still work
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 20:11   View User's Profile U2U Member Reply With Quote

no, but isn't it only relative to the path I specify... I changed the folder... it's too confusing... I have a solution....

I just added the Uniting Nations Section to the existing file http://www.djantd.info/home.php?nav=mixes.php&t=Mixes
Antz
Member

Registered: 28th Jul 03
Location: Leeds         Drives: Myself Insane!
User status: Offline
4th Apr 05 at 20:28   View User's Profile U2U Member Reply With Quote

Cheers for your help people... I always take the easy road out

 
New Topic

New Poll

Corsa Sport » Message Board » Off Day » Help Please... 24 database queries in 0.0083001 seconds