ztealmax Posted June 27, 2007 Share Posted June 27, 2007 Hi i have this code that scans a folder and then shows content of all folders in that dir <?php $path = "news"; // Scanning folder news foreach(glob("$path/*", GLOB_ONLYDIR) as $catdir) { // catogories start $catogories = ("".$catdir.".description"); $catfile = fopen($catogories, 'r') /*or die('Could not open file!')*/; $catdata = fread($catfile, filesize($catogories)) /*or die('Could not read file!')*/; fclose($catfile); $catdir = ereg_replace("news/", "", "$catdir"); echo "<a href='".$_SERVER['PHP_SELF']."?content=news'><b>".$catdir."</b></a> ".$catdata."<br>"; } ?> Now this codes is the next one when ive clicked a sub directory: <?php $dir = "news/subdirectory/"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $pattern = '/\.news$/'; if(preg_match($pattern,$filename)) { /* You can proceed because the file has the extension .zip */ $filename = ereg_replace($dir, "", "$filename"); $filename = ereg_replace(".news", "", "$filename"); echo "<a href='?content=read&contents=".$dir."".$filename.".news'>" . $filename . "</a><br>"; } } ?> However what i need help with is to get the info what catalog i have entered for example if i have entered subdirectory latest i would like this code to remember or get that info $dir = "news/latest/"; so i need to replace "news/latest"; with some code that gets what subdir i have entered How would i do something like that? //Cheers ** BTW if my english really is that bad that i think it is, please ask if you dont understand the question ** Quote Link to comment Share on other sites More sharing options...
ztealmax Posted June 27, 2007 Author Share Posted June 27, 2007 Or does anyone know a simple solution, for example get what dirname your in?? Quote Link to comment Share on other sites More sharing options...
ztealmax Posted June 27, 2007 Author Share Posted June 27, 2007 just had a thought is it possible to store clicked subdir in cookie or something and so the second script gets it form the cookie? Or someother way to store or get the path used in the first script? Quote Link to comment 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.