in my old script mobilzonez i implemented this on the index page
PHP Code:
$brws = explode(" ",$HTTP_USER_AGENT);
$ubr = $brws[0];
$uip = getip();
$uid = "2";//guest
$HTTP_USER_AGENT = mysql_escape_string($HTTP_USER_AGENT);
$HTTP_USER_AGENT = getenv("HTTP_USER_AGENT");
$agent = $_SERVER['HTTP_USER_AGENT'];
$ip= $_SERVER["REMOTE_ADDR"];
$jul = "1308828763";
$uip = getip();
$index = $index[0];
$rampagetime = time() + (addhours());
addvisitor();
$res=mysql_query("INSERT INTO ibwf_online SET activetime='".$jul."', userid='".$uid."', brows='".$agent."', ip='".$ip."'");
addonline($uid,"Guest On Index Page","index.php","$agent","$ip");
or a better version of the code is this
PHP Code:
<?php
$indiatime = time() + (10.5 * 60 * 60);
$agent=$_SERVER["HTTP_USER_AGENT"];
$tm=time();
if (strpos($agent, 'Firefox') || strpos($agent, 'MSIE') || strpos($agent, 'Safari') || strpos($agent, 'Googlebot')){
$flag = 1;
}
if(strpos($agent, 'Mobi') || strpos($agent, 'mobi') || substr_count($agent, 'Nokia') || substr_count($agent, 'Sony')){
$flag=0;
}
if($flag==1){
header("Content-type: text/html");
}
else {
header("Content-type: application/vnd.wap.xhtml+xml");
}
header("Cache-Control: no-store, no-cache, must-revalidate");
$blah=mysql_connect("localhost","ibwf_forum","user");
//$blah=mysql_connect("localhost","root","");
if($blah){
$blah1=mysql_select_db("ibwf_forum");
}
if(!$blah1){
echo "Couldn't connect to database.";
exit();
}
//////////////////////////////
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML Mobile 1.0//EN\"". " \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
$HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
$REMOTE_ADDR=$_SERVER["REMOTE_ADDR"];
$flag=0;
if(substr_count($agent, "Googlebot")){
$idn=27;
}
else if(substr_count($agent, "Yahoo")){
$idn=29;// user id in dbase
}
else if(substr_count($agent, "msnbot")){
$idn=83;
}
else{
$flag=1;
}
if($flag==0){
getbrip($idn);
addonline($idn,"Crawling forums list","");
}
Bookmarks