PHP Classes

Protect page

Recommend this page to a friend!

      Access user Class  >  All threads  >  Protect page  >  (Un) Subscribe thread alerts  
Subject:Protect page
Summary:can't login when protect page reside in other directory
Messages:3
Author:António Abrantes
Date:2006-02-04 04:07:35
Update:2006-02-07 12:17:05
 

  1. Protect page   Reply   Report abuse  
Picture of António Abrantes António Abrantes - 2006-02-04 04:07:35
I tested the script on my pc and this work great, but when i upload original files to remote server for testing, example.php(protect page) not run in other directory, and redirect to login.php. On my pc this work great.

When put example.php in directory of login.php the file work.
I modified all initial variables (DOCUMENT_ROOT!!!!! on the files with PATH of remote server.

PHP version of Remote server : 4.4.2
S.O of Remote Server : II5 or IIS6 ?

The other files work fine.

Need help and ideas.

Thanks, and sorry about my English.

  2. Re: Protect page   Reply   Report abuse  
Picture of Olaf Lederer Olaf Lederer - 2006-02-04 08:08:31 - In reply to message 1 from António Abrantes
Hello,

there are often problems with the server var document_root on IIS systems.

do you have an error message?

and what is the code you use in the file you want to enter?

regards Olaf

  3. Re: Protect page   Reply   Report abuse  
Picture of António Abrantes António Abrantes - 2006-02-07 12:17:05 - In reply to message 2 from Olaf Lederer
Hello,

My problem is resolved.

I cannot access protected page because session.save_path on my server have ".\" and with this i cannot have protected pages on other directory.

I resolved this with script:

//////////
<?PHP
//Resolve DOCUMENT_ROOT on IIS
$pathInfo = $_SERVER["PATH_INFO"];
$pathTranslated = $_SERVER["PATH_TRANSLATED"];
$pathInfo = preg_replace("/\//", "\/", $_SERVER["PATH_INFO"]);
$pathTranslated = str_replace("\\\\", "/", $_SERVER["PATH_TRANSLATED"]);
$_SERVER["DOCUMENT_ROOT"] = preg_replace("/$pathInfo/", "", $pathTranslated);
//print $_SERVER["DOCUMENT_ROOT"];
//exit;

//define session.save_path
session_save_path($_SERVER['DOCUMENT_ROOT']."/cgi-bin/tmp");
?>
///////////

Thanks PHP community, this is great.