Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Who is online - possibility of displaying only active users  (Read 7434 times)

0 Members and 1 Guest are viewing this topic.

Arminius

  • Coppermine novice
  • *
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 28
    • www.arminius-numismatics.com
Who is online - possibility of displaying only active users
« on: November 08, 2019, 06:02:54 pm »

Hello,

too often spammers and crazy people are trying to register on my gallery. Sometimes i see up to 8 of these per day.
Their profile, links and silly comments are visible for all visitors under

"Who is online? ... The newest registered user is (profile name)"

if you click on their profile name.

These will never be activated of course and usually i delete these fake users within 1-2 days.

Is there a way only active users are visible in "Who is online" ?
Maybe this can reduce the fake registrations.

Regards

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Who is online - possibility of displaying only active users
« Reply #1 on: November 08, 2019, 07:52:51 pm »

Edit your_gallery_folder/plugins/onlinestats/codebase.php

function online_mainpage() has the items to display.

REPLACE

Code: [Select]
    starttable("100%", cpg_fetch_icon('online', 2) . $lang_plugin_onlinestats['name']);
    print '<tr><td class="tableb">';
    if ($num_users == 1) {
        printf($lang_plugin_onlinestats['we_have_reg_member'], '<strong>'.$num_users.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['we_have_reg_members'], '<strong>'.$num_users.'</strong>');
    }
    echo '.&nbsp;' . $LINEBREAK;
    printf($lang_plugin_onlinestats['most_recent'], '<a href="profile.php?uid='.$newest['user_id'].'">'.$newest['user_name'].'</a>');
    echo '.&nbsp;' . $LINEBREAK;
    if ($num_online == 1) {
        printf($lang_plugin_onlinestats['is'], '<strong>'.$num_online.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['are'], '<strong>'.$num_online.'</strong>');
    }
    print ': ';
    if ($num_reg_online == 1) {
        printf($lang_plugin_onlinestats['reg_member'], '<strong>'.$num_reg_online.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['reg_members'], '<strong>'.$num_reg_online.'</strong>');
    }
    print ' '.$lang_plugin_onlinestats['and'].' ';
    if ($num_guests == 1) {
        printf($lang_plugin_onlinestats['guest'], '<strong>'.$num_guests.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['guests'], '<strong>'.$num_guests.'</strong>');
    }
    echo '.&nbsp;' . $LINEBREAK;
    printf($lang_plugin_onlinestats['record'], '<strong>'.$CONFIG['record_online_users'].'</strong>', localised_date($CONFIG['record_online_date'], $lang_date['lastcom']));
    echo '.&nbsp;' . $LINEBREAK;
    printf($lang_plugin_onlinestats['since'], $CONFIG['mod_updates_duration'], $logged_in_names);
    print '.</td></tr>';
    endtable();
    print '<br />';

WITH

Code: [Select]
function online_mainpage() {
    global $CONFIG, $cpg_udb, $matches, $lang_plugin_onlinestats, $lang_date, $LINEBREAK;

    if($matches[1] != 'onlinestats') {
      return $matches;
    }

    $num_users = $cpg_udb->get_user_count();

    $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ONLINE']}");
    list($num_online) = cpg_db_fetch_row($result);

    $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id <> 0");
    list($num_reg_online) = cpg_db_fetch_row($result);

    $result = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name FROM {$cpg_udb->usertable} ORDER BY user_id DESC LIMIT 1");
    $newest = cpg_db_fetch_assoc($result);

    $result = cpg_db_query("SELECT user_id, user_name FROM {$CONFIG['TABLE_ONLINE']} WHERE user_id <> 0");

    $logged_in_array = array();

    while ($row = cpg_db_fetch_row($result)) {
        $logged_in_array[] = vsprintf('<a href="profile.php?uid=%d">%s</a>', $row);
    }

    $logged_in_names = implode(', ', array_unique($logged_in_array));

    $num_guests = $num_online - $num_reg_online;

    // most users online - TND
    if ($num_online > $CONFIG['record_online_users'])
    {
        $CONFIG['record_online_date'] = localised_date(-1, $lang_plugin_onlinestats_date_fmt);
        $CONFIG['record_online_users'] = $num_online;

        cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '$num_online' WHERE name = 'record_online_users'");
        cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = ".time()." WHERE name = 'record_online_date'");
    }

    starttable("100%", cpg_fetch_icon('online', 2) . $lang_plugin_onlinestats['name']);
    print '<tr><td class="tableb">';
/* IS SHOWING There is X NR registered user
    if ($num_users == 1) {
        printf($lang_plugin_onlinestats['we_have_reg_member'], '<strong>'.$num_users.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['we_have_reg_members'], '<strong>'.$num_users.'</strong>');
    } */
/* Showing just space
    echo '.&nbsp;' . $LINEBREAK;
*/
/*IS SHOWING The newest registered user is admin.
    printf($lang_plugin_onlinestats['most_recent'], '<a href="profile.php?uid='.$newest['user_id'].'">'.$newest['user_name'].'</a>');
*/
/* Showing just space
    echo '.&nbsp;' . $LINEBREAK;
*/
    if ($num_online == 1) {
        printf($lang_plugin_onlinestats['is'], '<strong>'.$num_online.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['are'], '<strong>'.$num_online.'</strong>');
    }
    print ': ';
    if ($num_reg_online == 1) {
        printf($lang_plugin_onlinestats['reg_member'], '<strong>'.$num_reg_online.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['reg_members'], '<strong>'.$num_reg_online.'</strong>');
    }
    print ' '.$lang_plugin_onlinestats['and'].' ';
    if ($num_guests == 1) {
        printf($lang_plugin_onlinestats['guest'], '<strong>'.$num_guests.'</strong>');
    } else {
        printf($lang_plugin_onlinestats['guests'], '<strong>'.$num_guests.'</strong>');
    }
/* IS SHOWING Most users ever online: 2 on 10/30/19 at 05:48.  Registered users who have been online in the past 10 minutes: .
    echo '.&nbsp;' . $LINEBREAK;
    printf($lang_plugin_onlinestats['record'], '<strong>'.$CONFIG['record_online_users'].'</strong>', localised_date($CONFIG['record_online_date'], $lang_date['lastcom']));
echo '.&nbsp;' . $LINEBREAK;
    */
/* IS SHOWING  Registered users who have been online in the past 10 minutes: .
    printf($lang_plugin_onlinestats['since'], $CONFIG['mod_updates_duration'], $logged_in_names);
*/
    print '.</td></tr>';
    endtable();
    print '<br />';
}
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Who is online - possibility of displaying only active users
« Reply #2 on: November 08, 2019, 07:57:01 pm »

I did not deleted the text that you did not want.
I just commented that php will consider them plain text like in a text file.
If you ever chage your mind uncomment the one you want,
I wrote above what each on is for.

I did not hide it but is still there.
Is gone because php will consider the comments plain text mot html or php.

NOW is shows only In total there is 1 visitor online: X registered users and X guest.
Logged

tonyyears

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Re: Who is online - possibility of displaying only active users
« Reply #3 on: May 24, 2020, 06:48:07 am »

Is it a way it can only show: "In total there are XX visitors online: X registered user and X guests.  Most users ever online: XXX on 12/12/12 at 00:00."

Thanks in advance.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 19 queries.