Jump to content

Truncating currentPage


Brenty

Recommended Posts

[b]Intro:[/b]

I have a server configuration that assigns folders as subdomains through DNS. When you FTP the files, you use the folder, but when you view them, you use that folder name as a subdomain - Like this:

[code]http://www.website.com/subdomain[/code]

translates to:

[code]http://subdomain.website.com/[/code]

You can also access the subdomain folder through the browser like you do with the FTP.

Because of this subdomain configuration, a package I'm using is getting a bit confused when reading out php server variables. I've changed the configuration in the software so that it mostly works, however, still have 1 problem, which I've identified to this:

[code]if(!isset($_SESSION['ccAdmin'])){
    
    header("Location: ".$GLOBALS['rootRel']."admin/login.php?goto=".currentPage());
    exit;

// check session path is correct
} elseif(strpos(dirname($_SERVER['PHP_SELF']), $_SESSION['AdminPath']) !== 0){
    
    header("Location: ".$GLOBALS['rootRel']."admin/login.php?goto=".currentPage());
    exit;[/code]

What I believe this code does is create a record of where the user was so that when re-authenticating themself, the software returns to that page. I could be wrong about this (Limited php knowledge), but that isn't the problem anyway.

[b]Problem:[/b]

From currentPage, I'm getting this result:

[code]subdomain/admin/index.php[/code]

when I should be getting just...

[code]admin/index.php[/code]

How can I strip out the subdomain folder from that currentPage result?
Link to comment
Share on other sites

[code]$result = "subdomain/admin/page.php";

$result = substr($result, strpos($result, '/', 1)+1);

echo $result;
[/code]

You should be able to adjust this to fit your specific needs. I honestly didn't look to see what your variable names are or anything just at your question and wrote this basic solution.
Link to comment
Share on other sites

[!--quoteo(post=354439:date=Mar 13 2006, 04:33 AM:name=txmedic03)--][div class=\'quotetop\']QUOTE(txmedic03 @ Mar 13 2006, 04:33 AM) [snapback]354439[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]$result = "subdomain/admin/page.php";

$result = substr($result, strpos($result, '/', 1)+1);

echo $result;
[/code]

You should be able to adjust this to fit your specific needs. I honestly didn't look to see what your variable names are or anything just at your question and wrote this basic solution.
[/quote]

Many many thanks for replying. I was starting to get worried about this.

What you've given me has helped send me in the right direction. Although the URL changes (Due to currentPage), it's the folder at the beginning that I need to strip out, and I think your code may just manage it - With adaptions as you said of course.

Greatly appreciated, and I'm just off to try it out. I'll post the results later.
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.