Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other
Author Message
Anders
Worker
Worker



Joined: Jun 16, 2004
Posts: 159
Location: Sweden

PostPosted: Wed Jan 08, 2014 4:52 am Reply with quote

Hi
Can some one help me with some code...that show an image if admin is online/offline


Last edited by Anders on Wed Jan 08, 2014 12:35 pm; edited 1 time in total 
View user's profile Send private message
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1123

PostPosted: Wed Jan 08, 2014 8:56 am Reply with quote

Try this

Code:
<?php if(is_online('admin')) { echo "online"; } else { echo "offline";  };


I think this should work fine but u need to include the image I think.
 
View user's profile Send private message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1775

PostPosted: Wed Jan 08, 2014 9:15 am Reply with quote

hicuxunicorniobestbuildpc, i hope you know that you have posted a function-call and i hope you know that the function must exist before you can call it? Can you tell us where the function is based and what is the code inside the function to get the online status from a admin user?

Anders, what is "admin"?

1. an admin-account with the name "admin" in RN or every admin account or an admin account with specific module rights?
2. an "normal" user-account with the name "admin" in RN ?

Wink

_________________
Only registered users can see links on this board! Get registered or login!  
View user's profile Send private message
Anders







PostPosted: Wed Jan 08, 2014 9:43 am Reply with quote

When i login as admin i want it show in the nav bar iam online or offline with image had been perfect...



fye.png
 Description:
 Filesize:  12.98 KB
 Viewed:  15668 Time(s)

fye.png


 
neralex







PostPosted: Wed Jan 08, 2014 9:48 am Reply with quote

Only if you are logged in as admin, then you have the menue points 'Admin Modules', 'Admin' and 'SEO'. There you can see it directly without code changes.


Last edited by neralex on Wed Jan 08, 2014 9:51 am; edited 1 time in total 
hicuxunicorniobestbuildpc







PostPosted: Wed Jan 08, 2014 9:49 am Reply with quote

I guess I know now what you want. Take a look how I did it in nukeNav.php

This is just one part of my navigation menu on my website.

Code:
if (is_admin($admin))

   $nukeNAV .= '<li><a title=""><img src="images/admin.png" alt="Admin" />&nbsp;Admin</a><ul>' . $hiddenModules . $inactiveModules . '</ul></li>';
if (is_active('Your_Account')) {
   $nukeNAV .= '<li><a href="modules.php?name=Your_Account" title=""><img src="images/account.png" alt="Your Account" />&nbsp;Your Account</a>';
   if (!isset($ya_config)) $ya_config = ya_get_configs();
   if (is_user($user)) {
      $nukeNAV .= '<ul>';
      if (is_active('Private_Messages')) $nukeNAV .= '<li><a href="modules.php?name=Private_Messages" title="">' . _NAV_PM . '</a></li>';
      $nukeNAV .= '<li><a href="modules.php?name=Your_Account&amp;op=edituser" title="">' . _NAV_PREFS . '</a></li>';
      if ($ya_config['allowusertheme']=='1') $nukeNAV .= '<li><a href="modules.php?name=Your_Account&amp;op=chgtheme" title="">' . _NAV_CHGTHEME . '</a></li>';
      $nukeNAV .= '<li><a href="modules.php?name=Your_Account&amp;op=logout" title="">' . _LOGOUT . '</a></li></ul>';
   } elseif (is_active('Your_Account')) {
      $nukeNAV .= '
  <ul>';
      if (is_active('nukeNAV')) $nukeNAV .= '
  <li><a href="modules.php?name=nukeNAV&amp;op=login" class="colorbox" title="">' . _LOGIN . '</a></li>';
      else $nukeNAV .= '
  <li><a href="modules.php?name=Your_Account" title="">' . _LOGIN . '</a></li>';
      if ($ya_config['allowuserreg']=='1')$nukeNAV .= '
  <li><a href="modules.php?name=Your_Account&amp;op=new_user" title="">' . _BREG . '</a></li>';
      $nukeNAV .= '
  </ul>';
   }
   $nukeNAV .= '
</li>';
}
 
neralex







PostPosted: Wed Jan 08, 2014 9:53 am Reply with quote

Please note, this works ONLY for you. No other user can see it - only you!
 
Anders







PostPosted: Wed Jan 08, 2014 9:57 am Reply with quote

Ok i want it to show to my users ...if admin are online or offline
 
neralex







PostPosted: Wed Jan 08, 2014 10:03 am Reply with quote

Now again: what is "admin"?

1. an admin-account with the name "admin" in RN or every admin account or an admin account with specific module rights?
2. an "normal" user-account with the name "admin" in RN ?
 
Anders







PostPosted: Wed Jan 08, 2014 10:05 am Reply with quote

1. an admin-account with the name "admin" in RN
 
hicuxunicorniobestbuildpc







PostPosted: Wed Jan 08, 2014 10:08 am Reply with quote

yes Anders,

Neralex is right. You will be the only person to see that image since you are the ADMINISTRATOR from your site but if you want to show yourself ONLINE or OFFLINE with another ADMIN name or any other name then it is another story.
 
Anders







PostPosted: Wed Jan 08, 2014 10:31 am Reply with quote

Yupp that story had i want if that is possible Smile
 
neralex







PostPosted: Wed Jan 08, 2014 10:59 am Reply with quote

That is not possible, Anders. Because about security reasons should a admin account stay everytime hidden! I would suggest you, to use and normal user-account, maybe your own.


Last edited by neralex on Wed Jan 08, 2014 2:06 pm; edited 1 time in total 
Anders







PostPosted: Wed Jan 08, 2014 11:02 am Reply with quote

ok that will work...had appreciated if you can make some code for a regular user
 
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Wed Jan 08, 2014 11:52 am Reply with quote

Don't moderators online show in the forums? I believe so, and that it uses the bbsessions tables. If so, that could tell you if an admin was online in the forums. You might be able to uses the regular sessions table to identify admins, but not sure I would recommend that approach.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
Anders







PostPosted: Wed Jan 08, 2014 12:04 pm Reply with quote

ok..can you help me with that code kguske ...iam not a coder
 
neralex







PostPosted: Wed Jan 08, 2014 12:18 pm Reply with quote

I have copied a query from the userinfo block-file, was made by spasticdonkey and have builded a little php class with a simple return value.

Create two images in the 'images' folder of your RN:

images/admin_is_online.png
images/admin_is_offline.png

...open includes/jquery/nukeNAV.php and search:

php Code:
if (is_active('nukeNAV') and is_active('Search')) $nukeNAV .= '

<li><a href="modules.php?name=nukeNAV&amp;op=search" class="colorbox" title="">' . _SEARCH . '</a></li>';


Add after:

php Code:
class is_online {

function online($username) {
global $prefix, $db;
$max_session_mins = 60; # how long before inactive user is dropped from online status
$sql = $db->sql_query('SELECT `uname` FROM `' . $prefix . '_session` WHERE `time` > \'' . ( time() - ($max_session_mins * 60) ) . '\' AND `guest` = 0 AND `uname` = \'' . $db->sql_escape_string($username) . '\'');
list($uname) = $db->sql_fetchrow($sql);
if(!isset($uname)) {
return 0;
} else {
return 1;
}
}
}
$check_user = new is_online();
$nukeNAV .= '<li>' . ($check_user->online('Anders') == 1 ? '<img src="images/admin_is_online.png" alt="admin online" />' : '<img src="images/admin_is_offline.png" alt="admin offline" />') . '</li>';


Keep your eyes on: $max_session_mins = 60; # how long before inactive user is dropped from online status

Keep your eyes on: $check_user->online('Anders')

You can type here your wanted username like: $check_user->online('Admin') or $check_user->online('Neralex')
 
Anders







PostPosted: Wed Jan 08, 2014 12:35 pm Reply with quote

Thanks alot neralex works perfect as always...
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©