In some cases, it is desired to obtain the URL of the current page displayed in the browser URL window.
For example, if we allow visitors to make a post to Digg we have to get the exact same URL. There are many other reasons as well.
Example One
<? php function getUrl() { $url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"]; $url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : ""; $url .= $_SERVER["REQUEST_URI"]; return $url; } ?>
Example Two
<?php function cpURL() { $pURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pURL .= "s";} $pURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pURL; } ?>Now you can get the current page URL using the line:
<?php echo cpURL(); ?>Sometimes it just needs to get page name. The following example shows how to do it:
<?php function cpName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } echo "The current page name is ".cpName(); ?>-------------------------------------------------
<?php $file = $_SERVER["SCRIPT_NAME"]; $break = Explode('/', $file); $pfile = $break[count($break) - 1]; echo $pfile; ?>-------------------------------------------------
Friends, if we can get subdomain.yourdomain.com, use this information. can only exploit.
$tmp = explode('.', 'subdomain.domain.com'); print_r($tmp); // $tmp[0] = subdomain // $tmp[1] = domain // $tmp[2] = com
0 Comments
Thank you for your comment.. We will contact you soon..
Emoji