Jump to content


Photo

Truncating currentPage


  • Please log in to reply
3 replies to this topic

#1 Brenty

Brenty
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 10 March 2006 - 06:58 PM

Intro:

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:

http://www.website.com/subdomain

translates to:

http://subdomain.website.com/

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:

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;

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.

Problem:

From currentPage, I'm getting this result:

subdomain/admin/index.php

when I should be getting just...

admin/index.php

How can I strip out the subdomain folder from that currentPage result?

#2 Brenty

Brenty
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 11 March 2006 - 02:01 PM

Anyone?

I'm sure this is easy for someone who knows. I'd consider using preg_replace, but don't know enough about php code yet.


#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 13 March 2006 - 09:33 AM

$result = "subdomain/admin/page.php";

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

echo $result;

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.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#4 Brenty

Brenty
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 13 March 2006 - 10:07 AM

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

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

echo $result;

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users