Author |
Message |
Anders
Worker


Joined: Jun 16, 2004
Posts: 159
Location: Sweden
|
Posted:
Wed Jan 08, 2014 4:52 am |
|
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 |
|
|
 |
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm

Joined: Aug 13, 2009
Posts: 1123
|
Posted:
Wed Jan 08, 2014 8:56 am |
|
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. |
|
|
|
 |
neralex
Site Admin

Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Wed Jan 08, 2014 9:15 am |
|
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 ?
 |
_________________ Only registered users can see links on this board! Get registered or login!
|
|
|
 |
Anders

|
Posted:
Wed Jan 08, 2014 9:43 am |
|
When i login as admin i want it show in the nav bar iam online or offline with image had been perfect... |
Description: |
|
Filesize: |
12.98 KB |
Viewed: |
15668 Time(s) |

|
|
|
|
 |
neralex

|
Posted:
Wed Jan 08, 2014 9:48 am |
|
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

|
Posted:
Wed Jan 08, 2014 9:49 am |
|
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" /> 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" /> 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&op=edituser" title="">' . _NAV_PREFS . '</a></li>';
if ($ya_config['allowusertheme']=='1') $nukeNAV .= '<li><a href="modules.php?name=Your_Account&op=chgtheme" title="">' . _NAV_CHGTHEME . '</a></li>';
$nukeNAV .= '<li><a href="modules.php?name=Your_Account&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&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&op=new_user" title="">' . _BREG . '</a></li>';
$nukeNAV .= '
</ul>';
}
$nukeNAV .= '
</li>';
}
|
|
|
|
|
 |
neralex

|
Posted:
Wed Jan 08, 2014 9:53 am |
|
Please note, this works ONLY for you. No other user can see it - only you! |
|
|
|
 |
Anders

|
Posted:
Wed Jan 08, 2014 9:57 am |
|
Ok i want it to show to my users ...if admin are online or offline |
|
|
|
 |
neralex

|
Posted:
Wed Jan 08, 2014 10:03 am |
|
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

|
Posted:
Wed Jan 08, 2014 10:05 am |
|
1. an admin-account with the name "admin" in RN |
|
|
|
 |
hicuxunicorniobestbuildpc

|
Posted:
Wed Jan 08, 2014 10:08 am |
|
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

|
Posted:
Wed Jan 08, 2014 10:31 am |
|
Yupp that story had i want if that is possible  |
|
|
|
 |
neralex

|
Posted:
Wed Jan 08, 2014 10:59 am |
|
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

|
Posted:
Wed Jan 08, 2014 11:02 am |
|
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
|
Posted:
Wed Jan 08, 2014 11:52 am |
|
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!
|
|
|
 |
Anders

|
Posted:
Wed Jan 08, 2014 12:04 pm |
|
ok..can you help me with that code kguske ...iam not a coder |
|
|
|
 |
neralex

|
Posted:
Wed Jan 08, 2014 12:18 pm |
|
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&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

|
Posted:
Wed Jan 08, 2014 12:35 pm |
|
Thanks alot neralex works perfect as always... |
|
|
|
 |
|