Joined: Jan 02, 2003 Posts: 666 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.
Joined: Jan 02, 2003 Posts: 666 Location: Vancouver Island
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=\"userinfo-.html$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";
Joined: Dec 02, 2006 Posts: 1359 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 to the forums!
Joined: Nov 06, 2005 Posts: 318 Location: Los Angeles, USA
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
Only registered users can see links on this board! Get registered or login to the forums!
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.
Joined: Nov 06, 2005 Posts: 318 Location: Los Angeles, USA
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:
Only registered users can see links on this board! Get registered or login to the forums!
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.
View next topic View previous 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