Members   Search      Help    Register    Login    Home
Home » Discussion Forums » M0dZ & HaCkZ » Guest Online/log Script!
Guest Online/log Script! [message #4351] Mon, 28 June 2010 21:32
Hasan is currently offline Hasan  Denmark
Messages: 89
Registered: April 2010
Seeder
A little script I made..( Used codes from other script and made this)
I'm still new too php so please be gentle o.o


In this script you can see guest/user online last 5 mins(you can chose how long time as well)and there will be added a log too..

You can see how it looks in my side wwww.u-torrentz.org, Just scroll down.

1) Install the Sql ( remember to change CHARSET to "latin1" when you import the sql file)

Code:
CREATE TABLE `guest` (
  `time` int(15) NOT NULL default '0',
  `ip` varchar(50) NOT NULL default '',
  `browser` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`time`)
)ENGINE=MyISAM DEFAULT CHARSET=latin1;


2) Upload the online.php file in you root ( You can mod it and add so you can see ip by adding "ip" or do other mods o.o)

3)

Add this code where ever you want it to... (easily too mod)

                
        //Guest Online
        $db_host = "localhost";
        $db_user = "User-name"; 
        $db_pass = "Password";
        $db_name = "DATABASE";
        $dbc = mysql_connect($db_host, $db_user, $db_pass);
        $dbs = mysql_select_db($db_name);
        $tm = time();
        $timeout = $tm - (300);  //300 is 5 mins
        if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR"
                                             ];}
            else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}
        $brws = explode("(",$_SERVER["HTTP_USER_AGENT"]);
        $browser = $brws[0];
        mysql_query("INSERT INTO guest SET  time='".$tm."', ip='".$ip."', browser='".$browser."'");
        $delete = mysql_db_query($db_name, "DELETE FROM guest WHERE time<$timeout"); 

if(!($delete)) { 

    print ""; 

} 

        $count = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM guest"));
        mysql_close();
        echo "<br/><a href=\"online.php\"><b>Total Guest Online In Last 5 mins:</b> $count[0]</a><br/>";


Here you go Very Happy
  • Attachment: online.php
    (Size: 0.82KB, Downloaded 86 times)


My site www.u-torrentz.org
Previous Topic:world cup map
Next Topic:Modifying the Search function
Goto Forum:
  


Current Time: Wed Feb 08 11:05:18 GMT 2012

Total time taken to generate the page: 0.00716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software