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.
Not a member yet? Click here to register.
Forgot Password?

User online/offline script by craig help.

Asked Modified Viewed 3,477 times
P
Penguinish
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

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

/*-------------------------------------------------------+
| PHPFusion 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
echo "</br ><!--online_status-->\n";
in the location I want. and then changing
 $search = "/(<!--forum_thread_user_name-->)(<a href='[^0-9]+)([0-9]+)('[^0-9]+>)(.*?<\/a>)/";
      return preg_replace_callback($search, "alter_user", $output);

with
 $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
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?
0 replies
There are no post found.

Labels

None yet

Statistics

  • Views 0 views
  • Posts 0 posts
  • Votes 0 votes
  • Topic users 1 member

1 participant

P
P
  • Junior Member, joined since
  • Contributed 24 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet