Jump to content

How to check which folder a user is in?


JustinK101

Recommended Posts

So I have a script I am writing that I wish to distrubte. The problem is that I need to make sure it works in all possible situations. I have the following block of code:

 

<?php
		if(dirname($_SERVER['PHP_SELF']) == "/admin")
		{
			echo '<a href="index.php" target="_self" title="' . $lang_employee_access_title . '">' . $lang_employee_access_title . '</a>';	
		}
		else
		{
			echo '<a href="admin/index.php" target="_self" title="' . $lang_admin_title . '">' . $lang_admin_title . '</a>';		
		}
	?>

 

This checks if the user is in the admin section. If they are in admin, then display go to employee access, if in employee access it displays go to admin. So code works if the script is installed in either one of the following cases:

 

http://www.mydomain.com/index.php

http://subdomain.mydomain.com/index.php

 

It does not work in the case of:

 

http://www.mydomain.com/myfolder/index.php

 

How can I make this check in the if statement work no matter what location that script is install in? Thanks.

Link to comment
https://forums.phpfreaks.com/topic/56977-how-to-check-which-folder-a-user-is-in/
Share on other sites

I don't think a switch will work, there is no way for me to know where a user will install the application. For example, they could install it in: http://www.mydomain.com/myFolder/myFolder/myFolder/myFolder/index.php.

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.