PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
CodyG
Life Cycles Becoming CPU Cycles


Joined: Jan 02, 2003
Posts: 666
Location: Vancouver Island

PostPosted: Wed Dec 31, 2008 2:43 pm Reply with quote Back to top

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.
View user's profile Send private message
CodyG
Life Cycles Becoming CPU Cycles


Joined: Jan 02, 2003
Posts: 666
Location: Vancouver Island

PostPosted: Wed Dec 31, 2008 9:08 pm Reply with quote Back to top

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\">&nbsp;<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";
 
                        $days = 0;
                        $hours = 0;
                        $mins = 0;
                        $dont = false;
      }
   }
$content .= "<div align=\"right\"><a href=\"http://www.eWebsite.biz\" title=\"web design\">&copy;</a>&nbsp;</div>";

?>


Happy New Year!
View user's profile Send private message
spasticdonkey
RavenNuke(tm) Development Team


Joined: Dec 02, 2006
Posts: 1359
Location: Texas, USA

PostPosted: Thu Jan 01, 2009 4:20 pm Reply with quote Back to top

Thanks for posting Smile
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):
Arrow
Only registered users can see links on this board!
Get registered or login to the forums!

Image
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2455
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Jan 01, 2009 5:26 pm Reply with quote Back to top

Nice! :clap:
View user's profile Send private message
NeapolitanWorld
Involved
Involved


Joined: Nov 06, 2005
Posts: 318
Location: Los Angeles, USA

PostPosted: Fri Aug 21, 2009 10:37 am Reply with quote Back to top

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
View user's profile Send private message Visit poster's website
NeapolitanWorld
Involved
Involved


Joined: Nov 06, 2005
Posts: 318
Location: Los Angeles, USA

PostPosted: Fri Aug 21, 2009 10:54 am Reply with quote Back to top

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 Embarassed
The images are broken due to the above but it's an easy fix.
View user's profile Send private message Visit poster's website
NeapolitanWorld
Involved
Involved


Joined: Nov 06, 2005
Posts: 318
Location: Los Angeles, USA

PostPosted: Thu Aug 27, 2009 5:53 pm Reply with quote Back to top

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.
Code:
$urlin = array(
'"(?<!/)modules.php\?name=Your_Account&amp;op=userinfo&amp;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
View user's profile Send private message Visit poster's website
spasticdonkey
RavenNuke(tm) Development Team


Joined: Dec 02, 2006
Posts: 1359
Location: Texas, USA

PostPosted: Fri Aug 28, 2009 4:50 am Reply with quote Back to top

try adding to the GTB file
Code:
$urlin = array(
'"(?<!/)modules.php\?name=Forums&amp;file=profile&amp;mode=viewprofile&amp;u=([0-9]*)"',
etc............
);

$urlout = array(
'forum-userprofile-\\1.html',
etc............
);
View user's profile Send private message
NeapolitanWorld
Involved
Involved


Joined: Nov 06, 2005
Posts: 318
Location: Los Angeles, USA

PostPosted: Fri Aug 28, 2009 8:13 am Reply with quote Back to top

Hmmmm no, did not work it gives me
"Sorry, but that user does not exist."

Thanks for the help,
jc
View user's profile Send private message Visit poster's website
spasticdonkey
RavenNuke(tm) Development Team


Joined: Dec 02, 2006
Posts: 1359
Location: Texas, USA

PostPosted: Fri Aug 28, 2009 11:27 am Reply with quote Back to top

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."\"
View user's profile Send private message
NeapolitanWorld
Involved
Involved


Joined: Nov 06, 2005
Posts: 318
Location: Los Angeles, USA

PostPosted: Fri Aug 28, 2009 11:44 am Reply with quote Back to top

The change of the uid was the problem Embarassed
Thank you for pointing that out to me!

jc
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum