Jump to content

Help with Path coding $parent_dir


xacto

Recommended Posts

Ok. I am quite PHP illiterate but learning and trying everyday..  ;)

A basic script kiddy..

But can someone help please..

 

AutoIndex-2.2.4

I am trying to have autoindex use the index.html file if there is one included in a sub directory..

This seems to work but the syntax and path being generated are wrong and I am just learning php..

How can I edit this script so the path works correctly. It seems to miss the parent directory.

 

Autoindex script is installed here:

//localhost/gallery/

and this directory has subfolders some with and without index.html files.

 

example of the generated path.

//localhost/00_Architecture/index.html

 

but needs to be:

//localhost/gallery/00_Architecture/index.html

 

So obviously I need to add another variable or rewrite this.. but not sure how to do it correctly:

".$_SERVER['SERVER_NAME']."/".$parent_dir."index.htm

 

Code:

Add the following to line 68 of the FileItems.php script located in the classes directory of AutoIndex:

 

if ( $filename == "index.html" || $filename == "index.html") {

        $redirect="<script language=javascript>window.location.replace ('http://".$_SERVER['SERVER_NAME']."/".$parent_dir."index.html');</script>";

        echo $redirect;

}

 

how do I extract the directory one level up in the url being generated?

I have tried everything.. I don't want to hard code the directory name, so it can be used in any directory

 

Any Ideas??

Thanks much

 

http://autoindex.sourceforge.net

AutoIndex-2.2.4

Link to comment
https://forums.phpfreaks.com/topic/189388-help-with-path-coding-parent_dir/
Share on other sites

Duh... and Doh...

 

.dirname($_SERVER['PHP_SELF'])

if ( $filename == "index.html" || $filename == "index.html") {

        $redirect="<script language=javascript>window.location.replace ('http://".$_SERVER['SERVER_NAME'].":8888"."/".dirname($_SERVER['PHP_SELF'])."/".$parent_dir."index.html');</script>";

        echo $redirect;

}

 

Hope this helps someone!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.