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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.