Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

User online/offline script by craig help.

So craig has this script that puts users online/offline by their name in the profile.

CodeDownload  
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Name: Forum  Users Activity Status Panel
| Type: Forum Mod
| Filename: users_forums_status_panel.php
| Author: Fangree Productions
| Developers: Fangree_Craig & MvE Designs
| Site: http://www.fangre...
-------------------------------------------------------+
| Output Handler by Hans Kristian Flaatten (Starefossen)
| Copyright (C) 2007 - 2010 Hans Kristian Flaatten
| http://code.stare...
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied!"); }

if (FUSION_SELF == "viewthread.php") {

   global $online_users, $i;
   
   $online_users = array();
   
   function alter_user($matches) {
      global $online_users;
     
      if (!isset($online_users[$matches['3']])) {
         $data = dbarray(dbquery("SELECT user_lastvisit FROM ".DB_USERS." WHERE user_id='".$matches['3']."' LIMIT 1"));
         if ($data['user_lastvisit']<(time()-300)) {
            $user_online = false;
            $online_img = "user-offline.png";
         } else {
            $user_online = true;
            $online_img = "user-online.png";
         }
         $online_users[$matches['3']] = $user_online;
      } else {
         $online_img = ($online_users[$matches['3']] ? "user-online.png" : "user-offline.png");
      }
     
      return $matches['0']."<img src='".BASEDIR."images/".$online_img."' alt='' align='center' />\n";
   }
   
   function alter_forum_output($output) {
       $search = "/(<!--forum_thread_user_name-->)(<a href='[^0-9]+)([0-9]+)('[^0-9]+>)(.*?<\/a>)/";
      return preg_replace_callback($search, "alter_user", $output);
   }
   
   add_handler("alter_forum_output");
}



This puts the online/offline image right next to the user name which I found unsavory. Id rather have it in the bottom of the miniprofile like so.

i.imgur.com/lzMa5YJ.png

I was able to achieve this by adding this code
CodeDownload  
echo "</br ><!--online_status-->\n";

in the location I want. and then changing
CodeDownload  
 $search = "/(<!--forum_thread_user_name-->)(<a href='[^0-9]+)([0-9]+)('[^0-9]+>)(.*?<\/a>)/";
      return preg_replace_callback($search, "alter_user", $output);


with
CodeDownload  
 $search = "/(<!--online_status-->)(<a href='[^0-9]+)([0-9]+)('[^0-9]+>)(.*?<\/a>)/";
      return preg_replace_callback($search, "alter_user", $output);



However this will display the offline image but not the online image. I was able to get this working by adding
CodeDownload  
echo "</br ><!--online_status-->".profile_link($data['user_id'])."\n";



So that there makes the code work and the images display correctly butheres my issue now I get the admin error message at the bottom of my page. What am I doing wrong here after adding .profile_link?
Thread Information
Author
Replies
1 post
Views
3090 times
Last Post
Last updated on 7 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Penguinish