How to print/retrieve current page link location
Several time we need to print or retrieve current page link location. Or Several time we need to pass the instant page link location. But how to do it? Ok, just I try to give you some hints about this. Just you can add this code on your page head or you can add the following function on your site configuration page.
<?php
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;
}
?>
Now, you need to call this function on your desired place where you want to print this link location. Call system are as follows:
<?php
echo curPageURL();
?>
I hope it will be helpful.
How to create a custom search engine
<!– Google Custom Search Element –>
<div id=”cse” style=”width:100%;”>Loading</div>
<script src=”http://www.google.com/jsapi” type=”text/javascript”></script>
<script type=”text/javascript”>
google.load(‘search’, ’1′, {style: google.loader.themes.GREENSKY});
google.setOnLoadCallback(function(){
new google.search.CustomSearchControl().draw(‘cse’);
}, true);
</script>
Want to do more with your Custom Search element? Go this page for details information.
How to Avoid the PHP_SELF exploits
PHP_SELF exploits can be avoided by using the htmlentities() function. For example, the form code should be like this to avoid the PHP_SELF exploits:
<form name="test" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
The htmlentities() function encodes the HTML entities. Now if the user tries to exploit the PHP_SELF variable, the attempt will fail and the result of entering malicious code in URL will result in the following output: Continue Reading »
