*

Recent

Author Topic: MOD - Add Guests On Line  (Read 12302 times)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
MOD - Add Guests On Line
« on: October 11, 2011, 07:00:05 AM »
This MOD will allow you to not only see how many members there are on-line, it also shows how many guests there are on line.

See it in action here -> http://ozigames.net/arcade/

PS: The Stats are at the bottom of the pages.

Code: [Select]
DO THIS FIRST - - - - - Your Database SQL:

CREATE TABLE `onlineuser` (
  `timestamp` int(15) NOT NULL DEFAULT '0',
  `ip` varchar(40) NOT NULL,
  PRIMARY KEY (`timestamp`),
  KEY `ip` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


_______________________________________________________

Edit:

template.php

Find:
Users Online: <? echo $onlineusers; ?><p>

Replace with:

Users Online: <? echo $onlineusers; ?><br />
<?php
$timeoutseconds  600; // Timeout Value in Seconds - 300 equals 5 minutes.
$timestamp=time();                       
$timeout=$timestamp-$timeoutseconds
$ip $_SERVER['REMOTE_ADDR'];
//Insert all users online
$query_add "INSERT INTO onlineuser VALUES ('$timestamp','$ip')";
$resultt mysql_query($query_add);
if (!$resultt) { echo 'Cannot connect to the database'; }

//Delete guest users after timeout - Does not affect members count
$query_time "DELETE FROM onlineuser WHERE timestamp < $timeout";
$resultt mysql_query($query_time);
if (!$resultt) { echo 'Cannot connect to the database'; }

//Count all members and guests IP's to make a grand total.
//Then subtract the number of members online from the grand total - leaving the Guests.
$query_resultt "SELECT DISTINCT ip FROM onlineuser";
$resultt mysql_query($query_resultt);
if (!$resultt) { echo 'Cannot connect to the database'; }

$totalusers = (mysql_num_rows($resultt)); 

$a="$totalusers";
$b="$onlineusers";
?>


Guests Online: <?php echo $a $b?><br />



« Last Edit: November 02, 2011, 05:41:01 PM by mort »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: MOD - Add Guests On Line
« Reply #1 on: October 11, 2011, 07:10:45 AM »
sweeeeeeet i was lookin for this... Maybe then my site wont seem so inactive..... and worth the money :/

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #2 on: October 11, 2011, 07:15:33 AM »
I used to think the same - No Members - No Guests - What the hell?

If you want to test it - Just tweet at twitter etc with a link to your site - Should get some visitors fairly quickly - - - BOOM!

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: MOD - Add Guests On Line
« Reply #3 on: October 11, 2011, 07:18:17 AM »
yea this guy told me to get visitors just follow a crap ton of people on twitter then post your link. Iv thought about doing this... Also i say all of morts mods should be in offcial releases just sayin :)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #4 on: October 11, 2011, 07:46:39 AM »
Also i say all of morts mods should be in official releases just saying :)

Then how am I going to be able to charge for them?

j/k

Because IMHO FAS script would be better off released as GPL in much the same way as MyBB is.

Time for B E D! ;)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: MOD - Add Guests On Line
« Reply #5 on: October 11, 2011, 01:58:54 PM »
Works like a charm!

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: MOD - Add Guests On Line
« Reply #6 on: October 11, 2011, 10:37:21 PM »
I think, not certain though, Adam has put something like this into the next release. Nothing for 2.0 though, thanks mort!

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #7 on: October 11, 2011, 11:11:51 PM »
If he hasn't and he wants it - He's welcome to use it. ;)

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: MOD - Add Guests On Line
« Reply #8 on: October 11, 2011, 11:17:25 PM »
Thanks! When he makes it back online, I'm pretty sure he will read this.

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: MOD - Add Guests On Line
« Reply #9 on: October 11, 2011, 11:37:27 PM »
Hmm ya know.. I don't remember if I added a guest online counter lol if not I will add one. I can use this as a base, but it looks like there is a few mistakes.
$file isn't defined (maybe its defined above the code you provided? Too lazy to open FAS up lol). It is pretty late so my mind is fried but what is the point of the $file_name?

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #10 on: October 12, 2011, 12:50:17 AM »
But what is the point of the $file_name?

Leftovers from something else the script was used for - Damn! :(

The first post has been updated. :)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: MOD - Add Guests On Line
« Reply #11 on: October 22, 2011, 12:59:12 AM »
Users Online: 2
 Guests Online: -1

hmmmmmmm

I dont think thats possible......

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #12 on: October 22, 2011, 01:39:35 AM »
It shouldn't be, as it counts everyone who is online and subtracts the guests, so the actual online count should always be more than guests.

In other words 1 member and 1 guest always = 2 - 1 member, and so on.

That script was updated in the first post - - ;)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: MOD - Add Guests On Line
« Reply #13 on: October 22, 2011, 01:43:59 AM »
It shouldn't be, as it counts everyone who is online and subtracts the guests, so the actual online count should always be more than guests.

In other words 1 member and 1 guest always = 2 - 1 member, and so on.

That script was updated in the first post - - ;)

I tried using the new code and i said cant connect to database...

Users Online: 1
Cannot connect to the database Guests
Online: 0

Also does this mean i can delete the file row from the database?
« Last Edit: October 22, 2011, 01:49:26 AM by spagetiokillers »

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: MOD - Add Guests On Line
« Reply #14 on: October 22, 2011, 02:44:50 AM »
Yes, or drop the table and SQL the new one. ;)