Redirect by PC or mobile access
July 25th, 2008 — adminphp code as follows:
$iswap = isset($_SERVER['HTTP_ACCEPT'])? $_SERVER['HTTP_ACCEPT']:”;
if(strpos($iswap,”wap”)>0)
{
@header(“Location: /wap/”);
}
php code as follows:
$iswap = isset($_SERVER['HTTP_ACCEPT'])? $_SERVER['HTTP_ACCEPT']:”;
if(strpos($iswap,”wap”)>0)
{
@header(“Location: /wap/”);
}
Add php code into html for lunarpage.com linux host.
try this line in a blank .htaccess
AddType application/x-httpd-php php html
AddType application/x-httpd-php5 .html .htm .php
AddHandler application/x-httpd-php5 .html .htm .php
Just add the following codes within the body:
<script language=”JavaScript”>
var how_many_ads = 5
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1){
url=”http://kingphp.com“;
alt=”ad1″;
banner=”img/ad1.jpg”;
width=”240″;
height=”320″;
}
if (ad==2) {
url=”http://kingphp.com“;
alt=”ad2″;
banner=”img/ad2.jpg”;
width=”240″;
height=”320″;
}
if (ad==3) {
url=”http://kingphp.com“;
alt=”ad3″;
banner=”img/ad3.jpg”;
width=”240″;
height=”320″;
}
if (ad==4) {
url=”http://kingphp.com“;
alt=”ad4″;
banner=”img/ad4.jpg”;
width=”240″;
height=”320″;
}
if (ad==5) {
url=”http://kingphp.com“;
alt=”ad5″;
banner=”img/ad5.jpg”;
width=”240″;
height=”320″;
}
document.write(‘<center>’);
document.write(‘<a href=\”‘ + url + ‘\” target=\”_blank\”>’);
document.write(‘<img src=\”‘ + banner + ‘\” width=’)
That’s all.
</script>
Ad the following code between head:
--more-->
add the following code in the body:

That’s all.
The most efficient way to detect mobile phones with PHP, this simply queries the accept headers, the user agent and checks for any tell tale signs that the browser we’re sniffing is a mobile device. Continue reading “PHP to detect mobile phones”
< ?php
$hotel=" How to study; PHP? ";
$foldername = stripslashes ($hotel);
//This erase white-spaces on the beginning and the end in each line of a string:
$foldername = preg_replace('~^(\s*)(.*?)(\s*)$~m', "\\2", $foldername);
//erases all NON-alfanumerics
$foldername = ereg_replace("[^[:alnum:] ]","",$foldername); Continue reading “How to remove the special characters in title?”
<?php
$hotel=” How to study PHP “;
$hotel= trim($hotel);
$array=explode(” “, $hotel);
$hotel=implode(“-”, $array);
echo ($hotel);
?>
Want to change the seperator between categories in the title tag?
At the moment the phpld generate the title as:
home – category – category – category
Continue reading “How to change phpld title seperator”
<?php
//get the current page URL that is shown in the browser URL window
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"]; Continue reading “Get current url”