JustinK101 Posted June 24, 2007 Share Posted June 24, 2007 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. Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 24, 2007 Share Posted June 24, 2007 Using a switch...or maybe using regex. Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted June 25, 2007 Author Share Posted June 25, 2007 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. 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.