Page 1 of 1
Can you check for a term within a URL?
Posted: Thu Apr 18, 2013 8:32 am
by simonmlewis
We need to prevent part of a page showing if logged in - which will also have a_ within the URL.
ie. /fred/a_add
How do I check if "a_" is in the URL?
Re: Can you check for a term within a URL?
Posted: Thu Apr 18, 2013 8:44 am
by simonmlewis
Haha, just worked it out myself, from using a means of removing something from the URL before:
Code: Select all
function curPageURL()
{
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$url = curPageURL();
if (strpos($url,'a_') === false) {
$disablefooter = "y";
}
Re: Can you check for a term within a URL?
Posted: Thu Apr 18, 2013 12:34 pm
by requinix
By the way,
Code: Select all
if ($_SERVER{"HTTPS"] == "on" && $_SERVER["SERVER_PORT"] != 443 || $_SERVER["HTTPS"] != "on" && $_SERVER["SERVER_PORT"] != 80) {
Otherwise you'll be adding :443 for HTTPS URLs.