Author |
Message |
CodyG
Life Cycles Becoming CPU Cycles

Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island
|
Posted:
Wed Dec 31, 2008 2:43 pm |
|
The block, despite the above edits, the block continued to display what looked like location fields instead of username. ie: blank, Victoria, Fernwood ... Also, I discovered these invalid usernames in the sessions table!
So, I managed to find another last seen block. And it works much better.
I'm right in the middle of bathing our dog (time-out before blow drying) and I'll post what I found in an hour or so. |
_________________ "We want to see if life is ubiquitous." D.Goldin |
|
|
 |
CodyG

|
Posted:
Wed Dec 31, 2008 9:08 pm |
|
Code:
<?php
/************************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* 2001 by Francisco Burzi (fburzi@ncc.org.ve) */
/* http://phpnuke.org */
/* */
/* Copyright (c)Michael Yarbrough opedog@comediccadavers.com */
/* http://www.comediccadavers.com/ */
/* */
/* Copyright (c) 2003 by Jack Kozbial http://www.ewebsite.biz */
/* PHP-NUKE block : Last Seen for phpNuke 6.5+ */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************************/
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $admin, $user, $cookie, $dbi, $prefix;
sql_query("CREATE TABLE IF NOT EXISTS $prefix"._lastseen."
(id INT (15) not null AUTO_INCREMENT,
username TEXT not null,
date INT(15) not null,
ip CHAR(50),
PRIMARY KEY (id),
UNIQUE (id))", $dbi);
function Lastseen_cookiedecode($user) {
global $cookie, $prefix, $db, $user_prefix;
$user = base64_decode($user);
$cookie = explode(":", $user);
$sql = "SELECT user_password FROM ".$user_prefix."_users WHERE username='$cookie[1]'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$pass = $row[user_password];
if ($cookie[2] == $pass && $pass != "") {
return $cookie;
} else {
unset($user);
unset($cookie);
}
}
lastseen_cookiedecode($user);
$numuser = 10; // limit number of users displayed in the list
$lastseen = $cookie[1];
$content = "";
if (isset($lastseen)) {
$ip = $_SERVER["REMOTE_HOST"];
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
}
$result = mysql_query("SELECT * FROM $prefix"._lastseen." WHERE username = \"$lastseen\"");
if (mysql_num_rows($result) > 0) {
mysql_query("UPDATE $prefix"._lastseen." SET date = " . time() . " WHERE username = \"$lastseen\"");
} else {
mysql_query("INSERT INTO $prefix"._lastseen." VALUES (\"\", \"$lastseen\", ".time().", \"".$ip."\")");
}
}
$numuser++;
// limit number of users displayed in the list for Administrator
$numadmin = 20;
if(is_admin($admin)) {
$result = mysql_query("SELECT username, date FROM $prefix"._lastseen." ORDER BY date DESC limit 0,$numadmin");
} else {
$result = mysql_query("SELECT username, date FROM $prefix"._lastseen." ORDER BY date DESC limit 0,$numuser");
}
while (list($lastseen, $date) = mysql_fetch_row($result)) {
if ($lastseen != $username && $lastseen != "Array") {
$realtime = time() - $date;
$dont = false;
// Content for your Last Seen block
$content .= "<font class=\"content\"><img src=\"images/blocks/ur-member.gif\" height=\"10\" width=\"14\"> <a href=\"modules.php?name=Your_Account&op=userinfo&username=$lastseen\">$lastseen</a>: ";
// how many days ago?
if ($realtime >= (60*60*24*2)) { // if it's been more than 2 days
$days = floor($realtime / (60*60*24));
$dont = true;
} else if ($realtime >= (60*60*24)) { // if it's been less than 2 days
$days = 1;
$realtime -= (60*60*24);
}
if (!$dont) {
// how many hours ago?
if ($realtime >= (60*60)) {
//$body .= " ($realtime) ";
$hours = floor($realtime / (60*60));
$realtime -= (60*60*$hours);
}
// how many minutes ago?
if ($realtime >= 60) {
$mins = floor($realtime / 60);
$realtime -= (60*$mins);
}
// just a little precation, although I don't *think* mins will ever be 60...
if ($mins == 60) {
$mins = 0;
$hours += 1;
}
}
if ($dont) {
$content .= " ".$days." days";
} else {
if ($days > 0) {
$content .= " ".$days." day".(($hours == 0 && $mins == 0)?(""):(","));
}
if ($hours > 0) {
$content .= " ".$hours." ".(($hours > 1)?("hrs"):("hr")).(($mins == 0)?(""):(","));
}
if ($mins > 0) {
$content .= " ".$mins." ".(($mins > 1)?("min"):("min"))."";
} else { // less than a minute :)
$content .= " ".$realtime." sec.";
}
}
$content .= " ago</font><br>\n";
$days = 0;
$hours = 0;
$mins = 0;
$dont = false;
}
}
$content .= "<div align=\"right\"><a href=\"http://www.eWebsite.biz\" title=\"web design\">©</a> </div>";
?>
|
Happy New Year! |
|
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Thu Jan 01, 2009 4:20 pm |
|
Thanks for posting
Although I had modded the original version you gave me months back, so I took a stab at it last night and I think it's working just fine. Simply followed the $dbi conversion instructions and left the core coding alone.
This is modified, but uses the same database tables as the original.. Borrowed boxover from nukePIE so that will need to be set to true to work correctly. Included images used and Shortlinks tap if anyone interested (the sql to install the tables is commented out in the block file):
Only registered users can see links on this board! Get registered or login!
 |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Thu Jan 01, 2009 5:26 pm |
|
Nice!  |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
 |
NeapolitanWorld
Involved


Joined: Nov 06, 2005
Posts: 339
Location: Los Angeles, USA
|
Posted:
Fri Aug 21, 2009 10:37 am |
|
spasticdonkey, This looks really nice! but is not working in my install. I think because I do not have RN installed in root, instead www.mysite.com/rnnuke/
Also my images are broken I think because of this. Any quick fix with a / somewhere instead of changing all?
jc |
_________________ My Raven Site Only registered users can see links on this board! Get registered or login! |
|
|
 |
NeapolitanWorld

|
Posted:
Fri Aug 21, 2009 10:54 am |
|
NeapolitanWorld wrote: | spasticdonkey, This looks really nice! but is not working in my install. I think because I do not have RN installed in root, instead www.mysite.com/rnnuke/
Also my images are broken I think because of this. Any quick fix with a / somewhere instead of changing all?
jc |
Sorry to the community. The block is working nice I just needed to comment out the \\ to install the DB table
The images are broken due to the above but it's an easy fix. |
|
|
|
 |
NeapolitanWorld

|
Posted:
Thu Aug 27, 2009 5:53 pm |
|
spasticdonkey, or montego can maybe help....I have been using this block for a week and really enjoy it! just one thing or error due to a modification I made to the block on a a herf link going from Your Account to Forum Profile instead, so now when @ home page you click on a name to go to their profile page it works perfect, but when for example I'm in Private Message section of the site and I click on a name of the block I get the following:
"Sorry, but that user does not exist."
With a link of:
http://www.mysite.com/rnnuke/forum-userprofile-.htmladmin
the admin is the user or any user selected so its the variable on the link.
I figure it has to do with the tego-shortlinks file? which I do not know how to edit for the modification.
Code:$urlin = array(
'"(?<!/)modules.php\?name=Your_Account&op=userinfo&username=([a-zA-Z0-9_-]*)"'
);
$urlout = array(
'userinfo-\\1.html'
);
?>
|
Instead of going to your account page of a member I changed the a herf link to go to profile page:
Code:a href=\" modules.php? name=Forums &file = profile &mode =viewprofile&u=".$uname."\"
|
this is the original:
Code:a href=\" modules.php? name = Your_Account &op= userinfo& username=".$uname."\"
|
Help with the shortlinks file would be appreciated =)
jc |
|
|
|
 |
spasticdonkey

|
Posted:
Fri Aug 28, 2009 4:50 am |
|
try adding to the GTB file
Code:$urlin = array(
'"(?<!/)modules.php\?name=Forums&file=profile&mode=viewprofile&u=([0-9]*)"',
etc............
);
$urlout = array(
'forum-userprofile-\\1.html',
etc............
);
|
|
|
|
|
 |
NeapolitanWorld

|
Posted:
Fri Aug 28, 2009 8:13 am |
|
Hmmmm no, did not work it gives me
"Sorry, but that user does not exist."
Thanks for the help,
jc |
|
|
|
 |
spasticdonkey

|
Posted:
Fri Aug 28, 2009 11:27 am |
|
this will need to be changed since you looking for the user id not the username
Code:a href=\" modules.php? name=Forums &file = profile &mode =viewprofile&u=".$uname."\"
|
try this
Code:a href=\" modules.php? name=Forums &file = profile &mode =viewprofile&u=".$uid."\"
|
|
|
|
|
 |
NeapolitanWorld

|
Posted:
Fri Aug 28, 2009 11:44 am |
|
The change of the uid was the problem
Thank you for pointing that out to me!
jc |
|
|
|
 |
|