Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=93)
-   -   Guest Online/log Script! (http://www.bvlist.com/showthread.php?t=5141)

Hasan 29th June 2010 10:50

Guest Online/log Script!
 
2 Attachment(s)
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:
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)

Code:

               
        //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 "
Total Guest Online In Last 5 mins: $count[0]
";

Here you go :d

joeroberts 1st July 2010 04:28

There is no need to use data base conection for this mod as pmbt hold data base open for the full duration.

Hasan 1st July 2010 11:30

Quote:

Originally Posted by joeroberts (Post 23860)
There is no need to use data base conection for this mod as pmbt hold data base open for the full duration.

Yea I figured that out but again I'm still new to this. do not wanna edit the code :P

and your welcome for this xD


All times are GMT +2. The time now is 08:28.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.