yaakhi Posted February 13, 2011 Share Posted February 13, 2011 Hi there, i am working on a mobile site can u pls help me with a script which shows guests online on my site with their country flag next to its phone model Link to comment https://forums.phpfreaks.com/topic/227507-guests-online/ Share on other sites More sharing options...
trq Posted February 13, 2011 Share Posted February 13, 2011 Sure, where are you stuck? Link to comment https://forums.phpfreaks.com/topic/227507-guests-online/#findComment-1173513 Share on other sites More sharing options...
yaakhi Posted February 13, 2011 Author Share Posted February 13, 2011 Thanks for the reply. I use a script which can show me guests ip and phone model but not their country name or flag it user three files online.php, online.dat, who.php i cannot upload files here so here are the files online.php <?php $data="online.dat"; //print date('his A',time()-((10*60*60)+(30*60))); $time=time()-((10*60*60)+(30*60)); $past_time=$time-600; $readdata=@fopen($data,"r") or die("? ? ? ? $data"); $data_array=file($data); @fclose($readdata); if (getenv('HTTP_X_FORWARDED_FOR')) $user = getenv('HTTP_X_FORWARDED_FOR'); else $user = getenv('REMOTE_ADDR'); $page = getenv('REQUEST_URI'); $agent = getenv('HTTP_USER_AGENT'); $d=count($data_array); for($i=0;$i<$d;$i++) { list($live_agent,$live_user,$live_page,$last_time)=explode("::","$data_array[$i]"); if($live_user!=""&&$last_time!=""&&$live_agent!=""&&$live_page!=""): if($last_time<$past_time): $live_user=""; $last_time=""; $live_agent=""; endif; if($live_user!=""&&$last_time!=""&&$live_agent!="") { if($user==$live_user&&$agent==$live_agent) { $online_array[]="$agent::$user::$page::$time\r\n"; } else $online_array[]="$live_agent::$live_user::$live_page::$last_time"; } endif; } if(isset($online_array)): foreach($online_array as $i=>$str) { if($str=="$agent::$user::$page::$time\r\n") { $ok=$i; break; } } foreach($online_array as $j=>$str) { if($ok==$j) { $online_array[$ok]="$agent::$user::$page::$time\r\n"; break;} } endif; $writedata=@fopen($data,"w") or die("? ? ? ? $data"); @flock($writedata,2); if($online_array=="") $online_array[]="$agent::$user::$page::$time\r\n"; foreach($online_array as $str) fputs($writedata,"$str"); @flock($writedata,3); @fclose($writedata); $readdata=@fopen($data,"r") or die("? ? ? ? $data"); $data_array=@file($data); @fclose($readdata); $online=count($data_array); print ''.$online.''; ?> who.php <? echo "<div class='my3'>Online Users Status</div><br />";$des = array('P','o','w','e','r','e','d',' ','b','y',', ','P','A','K','w','a','p','.','N','e','t');echo '<script type="text/javascript">document.title=document.title+" :: '.implode('',$des).'"; </script>'; $data = file('online.dat'); echo ''; echo ''; foreach($data as $val) { $ex = explode('::', $val); $ex2 = explode(' ', $ex[0]); $i++; echo "<div class='usersdetail'><b>$i. </b>$ex2[0]<br/><b>IP:</b> $ex[1]<br/><b>Corrent Page:</b> <a href=\"$ex[2]\">http://PAKwap.mobi$ex[2]</a><br/><b>Time:</b> ".date('h:i A', (int)(trim($ex[3])))."</div>"; } echo '<div class="my3"><a href="index.php">» Home</a></div>'; include("footer.php"); ?> and online.dat is used for storage Link to comment https://forums.phpfreaks.com/topic/227507-guests-online/#findComment-1173519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.