Support Forum Project Downloads FAQ Documentation About Demo Tutorials Blog Plugins
November 20, 2009, 11:45:46 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: cpg1.5.2 beta released
The brand new cpg1.5.x series that comes with a lot of new features finally has reached the release stage: a first public beta release cpg1.5.2 has been released that is mainly aimed at translators, testers and community members that have contributed in the past. The beta release is not meant to be used in a production environment, but only on testbeds and for evaluation purposes. There is currently no support for cpg1.5.x yet!
[more]
   Home   Help Search Board rules Login Register  
Pages: [1] 2 3 4 5 ... 19   Go Down
  Print  
Author Topic: A phpbb style 'who is online' block  (Read 133033 times)
0 Members and 1 Guest are viewing this topic.
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« on: April 13, 2004, 07:40:16 pm »

This will add a phpbb style block to your index page, showing the names and the number of users currently browsing the gallery. It is suitable for versions 1.2 and 1.3 standalone. It will function with bb integration if you change the references to the users table in onlinestats.php accordingly.

Quote from: Sample
We have 437 registered users
The newest registered user is Edom001
In total there is 1 user online :: 1 Registered, and 0 Guests
Registered Users: Nibbler

*updated 28/6/04*

Steps for installation:

1) Make changes to your include/init.inc.php file.

add:

Code:
// stats block additions begin
$del = db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE last_action < NOW() - INTERVAL 60 MINUTE");
$testarray = explode('.',$raw_ip);
$teststr = $testarray[0] . '.' . $testarray[1];
if ($user_id) {
$sel = db_query("SELECT * FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id='$user_id'");
if (mysql_num_rows($sel)) {
    $upd = db_query("UPDATE {$CONFIG['TABLE_ONLINE']} SET last_action = NOW() WHERE user_id = '$user_id' LIMIT 1");
    } else {
    $ins = db_query("INSERT INTO {$CONFIG['TABLE_ONLINE']} (user_id,user_ip,last_action) VALUES ('$user_id', '$raw_ip', NOW())");
    }
       
} else{
$sel = db_query("SELECT user_ip FROM {$CONFIG['TABLE_ONLINE']} WHERE user_ip LIKE '$teststr%'");
$res = mysql_fetch_assoc($sel);
$result = $res['user_ip'];
if (mysql_num_rows($sel)){
$upd = db_query("UPDATE {$CONFIG['TABLE_ONLINE']} SET last_action = NOW() WHERE user_ip = '$result' LIMIT 1");
} else $ins = db_query("INSERT INTO {$CONFIG['TABLE_ONLINE']} (user_id,user_ip,last_action) VALUES ('$user_id', '$raw_ip', NOW())");
}
// stats block additions end

just before the ?> at the end of the file.

You can change 'INTERVAL 5 MINUTE' to the length of time before a user is removed from the online list, and presumed to not be actively browsing.

and...

Code:
$CONFIG['TABLE_ONLINE'] = $CONFIG['TABLE_PREFIX']."online";

goes under the similar lines around line 150 (exact line depends on your version) (now ~230 ??)

2) Get a copy of this file, and upload it to your coppermine directory as onlinestats.php (smf version available here).

3) Edit index.php

find:

Code:
            case 'anycontent':
                if ($cat == 0) {
                    include('anycontent.php');
                }
                flush();
                break;

and underneath add:

Code:
            case 'onlinestats':
                if ($cat == 0) {
                    include('onlinestats.php');
                }
                flush();
                break;

4) Create the table

Code:
CREATE TABLE cpg_online (
  user_id int(11) NOT NULL default '0',
  user_ip tinytext NOT NULL,
  last_action datetime default NULL,
  PRIMARY KEY  (user_id,user_ip(15))
) TYPE=MyISAM;

in phpmyadmin or equivalent, using your normal coppermine tablename prefix instead of cpg_ if applicable.

5) edit login.php

find
Code:
if (defined('UDB_INTEGRATION')) udb_login_page();

add before it:

Code:
$result = db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id = 0 AND user_ip = '$raw_ip'");

6) edit logout.php

find
Code:
if (defined('UDB_INTEGRATION')) udb_logout_page();

add before it

Code:
$result = db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id = $user_id");

7) finally add 'onlinestats' into your 'The content of the main page' section in config, wherever you want it to appear.






[edit GauGau 2006-01-16]
I started a separate thread for the online plugin version for cpg1.4.x (which is still experimental, your feedback would be appreciated).
Please post stuff related to the plugin version there, but make sure to read the existing replies to this thread as well.
[/edit]


« Last Edit: January 16, 2006, 01:38:40 pm by GauGau » Logged

I don't care about what they say, I won't live or die that way.
DefenceTalk.com
Coppermine frequent poster
***
Posts: 230



WWW
« Reply #1 on: April 16, 2004, 05:12:17 am »

www.defencetalk.com/pictures

I already did it... without editing any files. Just use anycontent file to include online.php from ur forums.

Code:
starttable("100%", "Who is Online");
?>
<tr><td class="tableb" >
<?php 
include("online.php"); 
?>

</td></tr>
<?php
endtable
();
?>

« Last Edit: October 06, 2004, 04:11:28 pm by Casper » Logged

(http://www.defencetalk.com/pictures/signature_cpg.php)
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #2 on: April 16, 2004, 05:34:56 am »

The idea of this is that it will work for sites without any integration. :wink:

I notice you also have the ï"¿ problem on the top left of your pages.
Logged

I don't care about what they say, I won't live or die that way.
DefenceTalk.com
Coppermine frequent poster
***
Posts: 230



WWW
« Reply #3 on: April 16, 2004, 05:46:16 pm »

Quote from: "Nibbler"
The idea of this is that it will work for sites without any integration. :wink:

I notice you also have the ï"¿ problem on the top left of your pages.


Oh without integration... nice.

 ï"¿ problem? i dont see it. :O
Logged

(http://www.defencetalk.com/pictures/signature_cpg.php)
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #4 on: April 16, 2004, 05:56:19 pm »

Very top left of www.defencetalk.com/pictures i can see:

(http://www.ic-gallery.com/stuff/ss4.jpg)

but i think we are getting a little off topic here...
Logged

I don't care about what they say, I won't live or die that way.
glacious
Coppermine newbie

Posts: 19


« Reply #5 on: April 16, 2004, 06:04:54 pm »

I've done all the steps in the first part, and i've even tried it just as a single file include like in the last post in this thread.  Any ideas what could be causing this problem?  Debug mode on:


Critical error

There was an error while processing a database query.


While executing query "SELECT * FROM  WHERE user_ip = '123.123.123.123' AND user_id = 1" on 0

mySQL error: You have an error in your SQL syntax near 'WHERE user_ip = '123.123.123.123' AND user_id = 1' at line 1




File: /usr/local/www/gallery/include/functions.inc.php - Line: 105


Notice: Undefined index: TABLE_ONLINE in /usr/local/www/gallery/include/init.inc.php on line 274



thanks! Smiley

-Bill
Logged
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #6 on: April 16, 2004, 06:33:44 pm »

Looks like you haven't done the second part of 1) properly.
Logged

I don't care about what they say, I won't live or die that way.
glacious
Coppermine newbie

Posts: 19


« Reply #7 on: April 16, 2004, 07:32:05 pm »

thank you, it works fine now Smiley

-Bill
Logged
nanothree
Coppermine regular visitor
**
Gender: Male
Posts: 70


WWW
« Reply #8 on: May 12, 2004, 11:19:44 am »

ahhhh look at this>

Who is Online
We have 103 registered users
The newest registered user is autumntoashes
In total there are 10 users online :: 8 Registered, and 2 Guests
Registered Users: autumntoashes, autumntoashes, nanothree, autumntoashes, autumntoashes, autumntoashes, autumntoashes, autumntoashes

why did it doi that?
Logged
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #9 on: May 12, 2004, 07:11:23 pm »

Check you have done part one properly, there is code there to stop that happening. Make sure you copy/pasted it right, and that it is at the end of the file.
« Last Edit: May 12, 2004, 07:26:30 pm by Nibbler » Logged

I don't care about what they say, I won't live or die that way.
IHofN_the_Corrupt
Coppermine newbie

Posts: 6


« Reply #10 on: May 21, 2004, 01:25:46 pm »

Nibbler,

Quote
2) Get a copy of this file, and upload it to your coppermine directory as onlinestats.php

I can't seem to access "this file"
I keep getting a Page Not Found error. I can't even seem to access your site at all.

Can you post onlinestats.php here?
Logged
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #11 on: May 21, 2004, 04:06:31 pm »

Site is back up now.
Logged

I don't care about what they say, I won't live or die that way.
IHofN_the_Corrupt
Coppermine newbie

Posts: 6


« Reply #12 on: May 21, 2004, 09:52:04 pm »

OK great, Thanks, Got it.

But moving on to the next bit:
Quote
3) Edit index.php

find:

Code:
           case 'anycontent':
               if ($cat == 0) {
                   include('anycontent.php');
               }
               flush();
               break;

I am unable to find this in index.php
I am using the 1.3 beta version, and comparing it with cpg 1.2., I see that index.php is radically different to 1.3
Therefore I have to assume that this mod only works (so far) with cpg 1.2.x.
Is there any way I can ask (as 1.3 currently has no official support) if someone can tell me the cahnges to make to get this to work with the 1.3 beta?

P.S. Do we have any update on an expected release date for the 1.3 stable?
Logged
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #13 on: May 22, 2004, 02:57:12 pm »

It should be at around line 660.
Logged

I don't care about what they say, I won't live or die that way.
IHofN_the_Corrupt
Coppermine newbie

Posts: 6


« Reply #14 on: May 23, 2004, 05:00:13 am »

Had a glitch with copy/paste of the onlinestats.php file....but sorted it out. Works a treat.
Thank you.
Logged
johnwr
Translator
**
Gender: Male
Posts: 46


« Reply #15 on: May 26, 2004, 04:12:12 pm »

Nice mod adding a nice feature. Hopefully incorporated into main branch next time the translationfiles needs updating.
Logged
johnwr
Translator
**
Gender: Male
Posts: 46


« Reply #16 on: May 26, 2004, 04:29:18 pm »

I made a modification to the onlinestats.php file, might be useful for others:

Edited this line:
echo "Registered Users: {$logged_in_names}</td></tr>";

To:
echo ($num_guests == $num_online) ? "</td></tr>" : "Registered Users: {$logged_in_names}</td></tr>";

In case there are only guests browsing, and you don't want the last line to be:
Registered Users:

p.s. this marks my first line of PHP, I'm originally a Java guy. At this rate I'll be part of the dev team soon... :-)
Logged
jmc
Contributor
***
Posts: 92


WWW
« Reply #17 on: May 30, 2004, 02:06:32 am »

Hi, Nibbler!
I'm having a problem with your mod, getting "critical error" mysql messages because of the phpbb table references in the onlinestats.php file. My cpg is NOT integrated with phpbb at the minute, and I get the impression your mod is aimed at exactly that sort of gallery? If so... why the references to phpbb in onlinestats.php? Huh
Sorry, but I'm far too much of a php noob to be able to figure this out myself! Any idea where I may be going wrong?
BTW - I've followed the install routine to the letter (twice!), but still no luck!
Hope you can help,
John Mc
Logged

I'm trying hard... at least!
Nibbler Topic starter
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19445



WWW
« Reply #18 on: May 30, 2004, 12:02:58 pm »

Looks like I linked the wrong file, the phpbb references shouldn't have been there please try it again.
Logged

I don't care about what they say, I won't live or die that way.
jmc
Contributor
***
Posts: 92


WWW
« Reply #19 on: May 30, 2004, 12:17:18 pm »

Cheers, Nibbler!
That works fine. Thanks.
Keep up the good work.
John Mc
Logged

I'm trying hard... at least!
Pages: [1] 2 3 4 5 ... 19   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
Page created in 0.048 seconds with 15 queries.