You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 59 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Hack for all User Info type blocks [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Wizarium
Nuke Soldier
Nuke Soldier


Joined: Jan 15, 2003
Posts: 26

Location: USA

PostPosted: Sun Jan 19, 2003 2:05 pm Reply with quoteBack to top

Hi all.. great site, and although there are tons of Nuke and Port support sites, you guys by far are the fastest at responding to people and getting solutions figured out. So congratulations up front...

Ok, on to the hack... Smile

Anyone who uses User-Info type blocks that gains information from the {prefix}_session table knows that once a registered User logs in, a 'ghost' of that User is kept as a Guest until they are dropped (usually about 5 mins). At any rate, this does create a situation where the Guests Online is not very accurate, especially on a busy site. This one-line hack to the mainfile.php will automatically delete any 'ghosts' in the Guests section. There are also some User Info blocks that use their own new table to track surfers, one in particular is Whoiswhere. It'll become plain how to incorporate this hack to any modified table such as that...

Ok, locate the function online section like this:
Code:

function online() {
    global $user, $cookie, $prefix, $dbi;
    cookiedecode($user);
    $ip = getenv("REMOTE_ADDR");
    $username = $cookie[1];
    if (!isset($username)) {
        $username = "$ip";
        $guest = 1;
    }
    $past = time()-1800;
    sql_query("DELETE FROM ".$prefix."_session WHERE time < $past", $dbi);
    $result = sql_query("SELECT time FROM ".$prefix."_session WHERE uname='$username'", $dbi);
    $ctime = time();
    if ($row = sql_fetch_array($result, $dbi)) {
   sql_query("UPDATE ".$prefix."_session SET uname='$username', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$username'", $dbi);
    } else {
   sql_query("INSERT INTO ".$prefix."_session (username, time, host_addr, guest) VALUES ('$username', '$ctime', '$ip', '$guest')", $dbi);
    }
}


Now add the following DELETE query right above $past = time()-1800;
Code:

function online() {
    global $user, $cookie, $prefix, $dbi;
    cookiedecode($user);
    $ip = getenv("REMOTE_ADDR");
    $username = $cookie[1];

    if (!isset($username)) {
        $username = "$ip";
        $guest = 1;
    }
    sql_query("DELETE FROM ".$prefix."_session where uname='$ip'", $dbi);
    $past = time()-1800;
    sql_query("DELETE FROM ".$prefix."_session WHERE time < $past", $dbi);
    $result = sql_query("SELECT time FROM ".$prefix."_session WHERE uname='$username'", $dbi);
    $ctime = time();
    if ($row = sql_fetch_array($result, $dbi)) {
   sql_query("UPDATE ".$prefix."_session SET uname='$username', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$username'", $dbi);
    } else {
   sql_query("INSERT INTO ".$prefix."_session (username, time, host_addr, guest) VALUES ('$username', '$ctime', '$ip', '$guest')", $dbi);
    }
}


If you have a block that uses an added table, such as Whoiswhere, just open up the files that come with the block, and find out what the table name is. For Whoiswhere, the table is {prefix}_whoiswhere, so add the following below the {prefix}_session delete query:
Code:

function online() {
    global $user, $cookie, $prefix, $dbi;
    cookiedecode($user);
    $ip = getenv("REMOTE_ADDR");
    $username = $cookie[1];

    if (!isset($username)) {
        $username = "$ip";
        $guest = 1;
    }
    sql_query("DELETE FROM ".$prefix."_whoiswhere where uname='$ip'", $dbi);
    sql_query("DELETE FROM ".$prefix."_session where uname='$ip'", $dbi);
    $past = time()-1800;
    sql_query("DELETE FROM ".$prefix."_session WHERE time < $past", $dbi);
    $result = sql_query("SELECT time FROM ".$prefix."_session WHERE uname='$username'", $dbi);
    $ctime = time();
    if ($row = sql_fetch_array($result, $dbi)) {
   sql_query("UPDATE ".$prefix."_session SET uname='$username', time='$ctime', host_addr='$ip', guest='$guest' WHERE uname='$username'", $dbi);
    } else {
   sql_query("INSERT INTO ".$prefix."_session (username, time, host_addr, guest) VALUES ('$username', '$ctime', '$ip', '$guest')", $dbi);
    }
}


This all keeps things neat and tidy. Guests stay in the tables, but as soon as a Guest logs on, they are immediately removed from the table and kept as a User. Enjoy!

- Keith
Find all posts by WizariumView user's profileSend private messageVisit poster's website
Zhen-Xjell
Nuke Cops Founder
Nuke Cops Founder


Joined: Nov 14, 2002
Posts: 5939


PostPosted: Sun Jan 19, 2003 2:08 pm Reply with quoteBack to top

Hey that's a great hack Keith, and thanks for sharing. I for one appreciate your kind remarks for the site and must re-inforce that it wouldn't be possible without teamwork. The more folks we have helping out, the better not only for the site, the users seeking help, but also for Nuke as a whole. Spread the word... We want Nuke to succeed for anyone 100% of the time.

_________________
Paul Laudanski, Microsoft MVP Windows-Security
CastleCops: [de] [en] [wiki]
Find all posts by Zhen-XjellView user's profileSend private messageSend e-mailVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.196 Seconds - 277 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::