Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Ip log script to mysql

Parašė WebDraw· 2010 Rugs. 2 15:09:50
#2


 
<?php
 
$ip = $_SERVER['REMOTE_ADDR'];
 
mysql_query("INSERT INTO online (`ip`) VALUES( INET_ATON('$ip')) ON DUPLICATE KEY UPDATE `date`= CURRENT_TIMESTAMP()");
 
function show_online(){
return mysql_num_rows(mysql_query("SELECT ip FROM online WHERE date > '".today(mktime(date("H"),(date("i")-5),date("s"),date("n"),date("j"),date("Y")))."'"));
}
function show_online_list(){
$q = mysql_query("SELECT INET_NTOA(ip) as ipa FROM online WHERE date > '".today(mktime(date("H"),(date("i")-5),date("s"),date("n"),date("j"),date("Y")))."'");
$a = array();
while($r = mysql_fetch_array($q))
$a[] = $r['ipa'];
return $a;
}
?>
 

skriptas kuris issaugo visu prisijungusiu ip ir prisijungimo laika
dar pridedu pora funkciju atvaizduoti online zmoniu skaiciu (show_online()) ir ju ip

taip pat kad veiktu per phpmyadmin susikurk lentele `online`

joje dvi eilutes:
ip int(11) UNSIGNED Null:Ne 0
date timestamp on update CURRENT_TIMESTAMP Null:Taip CURRENT_TIMESTAMP

PRIMARY ip


<? echo show_online() ?>
parodo online zmoniu skaiciu