mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Save 'most online' counts in separate pref, use array-based $menu_pref and new prefs handler, global elimination, odd fixes
This commit is contained in:
@@ -9,21 +9,32 @@
|
||||
* Plugin Administration - Online menu
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/online/config.php,v $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2009-12-28 17:53:11 $
|
||||
* $Author: e107steved $
|
||||
*
|
||||
*/
|
||||
$eplug_admin = TRUE;
|
||||
require_once("../../class2.php");
|
||||
include_lan(e_PLUGIN."online/languages/".e_LANGUAGE.".php");
|
||||
require_once('../../class2.php');
|
||||
include_lan(e_PLUGIN.'online/languages/'.e_LANGUAGE.'.php');
|
||||
|
||||
if (!getperms("1"))
|
||||
if (!getperms('1'))
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
header('location:'.e_BASE.'index.php');
|
||||
exit ;
|
||||
}
|
||||
require_once(e_ADMIN."auth.php");
|
||||
require_once(e_ADMIN.'auth.php');
|
||||
|
||||
$menu_pref = e107::getConfig('menu')->getPref('');
|
||||
if (!isset($menu_pref['online_ls_caption']))
|
||||
{ // Assume that if one isn't set, none are set
|
||||
$menu_pref['online_ls_caption'] = 'LAN_LASTSEEN_1'; //caption for the lastseen_menu
|
||||
$menu_pref['online_ls_amount'] = 10; //amount of records to show in the lastseen_menu
|
||||
$menu_pref['online_caption'] = 'LAN_ONLINE_10'; //caption for the online_menu
|
||||
$menu_pref['online_show_memberlist'] = true; //toggle whether to show a simple member list of online members (shwoing user1, user2, user3)
|
||||
$menu_pref['online_show_memberlist_extended'] = false; //toggle whether to show the extended member list of online members (showing 'user viewing page')
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['update_menu']))
|
||||
{
|
||||
@@ -37,20 +48,19 @@ if (isset($_POST['update_menu']))
|
||||
}
|
||||
if ($admin_log->logArrayDiffs($temp,$menu_pref,'MISC_02'))
|
||||
{
|
||||
$tmp = addslashes(serialize($menu_pref));
|
||||
$sql->db_Update("core", "e107_value='{$tmp}' WHERE e107_name='menu_pref' ");
|
||||
$menuPref = e107::getConfig('menu');
|
||||
//e107::getConfig('menu')->setPref('', $menu_pref);
|
||||
//e107::getConfig('menu')->save(false, true, false);
|
||||
foreach ($temp as $k => $v)
|
||||
{
|
||||
$menuPref->setPref($k, $v);
|
||||
}
|
||||
$menuPref->save(false, true, false);
|
||||
}
|
||||
$ns->tablerender("", "<div style='text-align:center'><b>".LAN_UPDATED."</b></div>");
|
||||
$ns->tablerender('', "<div style='text-align:center'><b>".LAN_UPDATED.'</b></div>');
|
||||
}
|
||||
|
||||
|
||||
function defaultpref(){
|
||||
$menu_pref['online_ls_caption'] = 'LAN_LASTSEEN_1'; //caption for the lastseen_menu
|
||||
$menu_pref['online_ls_amount'] = 10; //amount of records to show in the lastseen_menu
|
||||
$menu_pref['online_caption'] = 'LAN_ONLINE_10'; //caption for the online_menu
|
||||
$menu_pref['online_show_memberlist'] = true; //toggle whether to show a simple member list of online members (shwoing user1, user2, user3)
|
||||
$menu_pref['online_show_memberlist_extended'] = false; //toggle whether to show the extended member list of online members (showing 'user viewing page')
|
||||
}
|
||||
|
||||
$text = "<div style='text-align:center'>
|
||||
<form method='post' action='".e_SELF."' id='menu_form'>
|
||||
|
@@ -9,35 +9,39 @@
|
||||
*
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/online/lastseen_menu.php,v $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-12-28 17:53:11 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
include_lan(e_PLUGIN."online/languages/".e_LANGUAGE.".php");
|
||||
include_lan(e_PLUGIN.'online/languages/'.e_LANGUAGE.'.php');
|
||||
require_once(e_PLUGIN.'online/online_shortcodes.php');
|
||||
if (is_readable(THEME.'online_menu_template.php')) {
|
||||
require_once(THEME.'online_menu_template.php');
|
||||
} else {
|
||||
require_once(e_PLUGIN.'online/online_menu_template.php');
|
||||
if (is_readable(THEME.'online_menu_template.php'))
|
||||
{
|
||||
require(THEME.'online_menu_template.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
require(e_PLUGIN.'online/online_menu_template.php');
|
||||
}
|
||||
|
||||
global $tp, $row, $gen;
|
||||
if (!is_object($gen)) { $gen = new convert; }
|
||||
$menu_pref = e107::getConfig('menu')->getPref('');
|
||||
$tp = e107::getParser();
|
||||
|
||||
$num = varsettrue($menu_pref['online_ls_amount'],10);
|
||||
$num = intval(varsettrue($menu_pref['online_ls_amount'],10));
|
||||
|
||||
$sql -> db_Select("user", "user_id, user_name, user_currentvisit", "ORDER BY user_currentvisit DESC LIMIT 0,".intval($num), "nowhere");
|
||||
$sql -> db_Select('user', 'user_id, user_name, user_currentvisit', 'ORDER BY user_currentvisit DESC LIMIT 0,'.$num, 'nowhere');
|
||||
$lslist = $sql -> db_getList();
|
||||
|
||||
$text = $tp -> parseTemplate($TEMPLATE_LASTSEEN['START'], FALSE, $online_shortcodes);
|
||||
$text = $tp -> parseTemplate($TEMPLATE_LASTSEEN['START'], TRUE);
|
||||
foreach($lslist as $row)
|
||||
{
|
||||
$text .= $tp -> parseTemplate($TEMPLATE_LASTSEEN['ITEM'], FALSE, $online_shortcodes);
|
||||
setScVar('online_shortcodes', 'currentUser', $row);
|
||||
$text .= $tp -> parseTemplate($TEMPLATE_LASTSEEN['ITEM'],TRUE);
|
||||
}
|
||||
$text .= $tp -> parseTemplate($TEMPLATE_LASTSEEN['END'], FALSE, $online_shortcodes);
|
||||
$text .= $tp -> parseTemplate($TEMPLATE_LASTSEEN['END'], TRUE);
|
||||
|
||||
$caption = varsettrue($menu_pref['online_ls_caption'],LAN_LASTSEEN_1);
|
||||
$ns->tablerender($caption, $text, 'lastseen');
|
||||
|
@@ -9,14 +9,17 @@
|
||||
* e107 Main
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/online/online_menu.php,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2009-12-28 17:53:11 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
global $tp, $sc_style, $gen, $menu_pref, $pref;
|
||||
//global $pref;
|
||||
global $menu_pref;
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
include_lan(e_PLUGIN.'online/languages/'.e_LANGUAGE.'.php');
|
||||
|
||||
@@ -24,75 +27,66 @@ require_once(e_PLUGIN.'online/online_shortcodes.php');
|
||||
|
||||
if (is_readable(THEME.'online_menu_template.php'))
|
||||
{
|
||||
require_once(THEME.'online_menu_template.php');
|
||||
require(THEME.'online_menu_template.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once(e_PLUGIN.'online/online_menu_template.php');
|
||||
require(e_PLUGIN.'online/online_menu_template.php');
|
||||
}
|
||||
|
||||
if(!defined("e_TRACKING_DISABLED") && varsettrue($pref['track_online']))
|
||||
//if(!defined('e_TRACKING_DISABLED') && varsettrue($pref['track_online']))
|
||||
if(!defined('e_TRACKING_DISABLED'))
|
||||
{
|
||||
if (!is_object($gen)) { $gen = new convert; }
|
||||
|
||||
//update most ever online
|
||||
if ((MEMBERS_ONLINE + GUESTS_ONLINE) > ($menu_pref['most_members_online'] + $menu_pref['most_guests_online']))
|
||||
{
|
||||
$menu_pref['most_members_online'] = MEMBERS_ONLINE;
|
||||
$menu_pref['most_guests_online'] = GUESTS_ONLINE;
|
||||
$menu_pref['most_online_datestamp'] = time();
|
||||
$tmp = addslashes(serialize($menu_pref));
|
||||
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='menu_pref' ");
|
||||
}
|
||||
|
||||
//display list of 'member viewing page'
|
||||
if($menu_pref['online_show_memberlist_extended'])
|
||||
if (e107::getConfig('menu')->get('online_show_memberlist_extended'))
|
||||
{
|
||||
if (MEMBERS_ONLINE)
|
||||
{
|
||||
global $listuserson, $pinfo, $ADMIN_DIRECTORY, $online_location_page, $oid, $oname, $online_location_page;
|
||||
global $listuserson;
|
||||
$ret='';
|
||||
foreach($listuserson as $uinfo => $pinfo)
|
||||
{
|
||||
list($oid, $oname) = explode(".", $uinfo, 2);
|
||||
$online_location_page = substr(strrchr($pinfo, "/"), 1);
|
||||
if ($pinfo == "log.php" || $pinfo == "error.php") {
|
||||
$pinfo = "news.php";
|
||||
$online_location_page = "news.php";
|
||||
}
|
||||
if ($online_location_page == "request.php")
|
||||
$online_location_page = str_replace('.php', '', substr(strrchr($pinfo, '/'), 1));
|
||||
if ($pinfo == 'log.php' || $pinfo == 'error.php')
|
||||
{
|
||||
$pinfo = "download.php";
|
||||
$pinfo = 'news.php';
|
||||
$online_location_page = 'news';
|
||||
}
|
||||
if (strstr($online_location_page, "forum"))
|
||||
elseif ($online_location_page == 'request.php')
|
||||
{
|
||||
$pinfo = e_PLUGIN."forum/forum.php";
|
||||
$online_location_page = "forum.php";
|
||||
$pinfo = 'download.php';
|
||||
$online_location_page = 'news';
|
||||
}
|
||||
if (strstr($online_location_page, "content"))
|
||||
elseif (strstr($online_location_page, 'forum'))
|
||||
{
|
||||
$pinfo = "content.php";
|
||||
$online_location_page = "content.php";
|
||||
$pinfo = e_PLUGIN.'forum/forum.php';
|
||||
$online_location_page = 'forum';
|
||||
}
|
||||
if (strstr($online_location_page, "comment"))
|
||||
elseif (strstr($online_location_page, 'content'))
|
||||
{
|
||||
$pinfo = "comment.php";
|
||||
$online_location_page = "comment.php";
|
||||
$pinfo = 'content.php';
|
||||
$online_location_page = 'content';
|
||||
}
|
||||
$ret .= $tp -> parseTemplate($TEMPLATE_ONLINE['ONLINE_MEMBERS_LIST_EXTENDED'], FALSE, $online_shortcodes);
|
||||
elseif (strstr($online_location_page, 'comment'))
|
||||
{
|
||||
$pinfo = 'comment.php';
|
||||
$online_location_page = 'comment';
|
||||
}
|
||||
list($oid, $oname) = explode('.', $uinfo, 2);
|
||||
setScVar('online_shortcodes', 'currentMember', array('oid' => $oid, 'oname' => $oname, 'page' => $online_location_page, 'pinfo' => $pinfo));
|
||||
$ret .= $tp->parseTemplate($TEMPLATE_ONLINE['ONLINE_MEMBERS_LIST_EXTENDED'], TRUE);
|
||||
}
|
||||
global $ONLINE_MEMBERS_LIST_EXTENDED;
|
||||
$ONLINE_MEMBERS_LIST_EXTENDED = $ret;
|
||||
setScVar('online_shortcodes', 'onlineMembersList', $ret);
|
||||
}
|
||||
}
|
||||
|
||||
$text = $e107->tp->parseTemplate($TEMPLATE_ONLINE['ENABLED'], TRUE);
|
||||
$text = $tp->parseTemplate($TEMPLATE_ONLINE['ENABLED'], TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ADMIN)
|
||||
{
|
||||
$text = $e107->tp -> parseTemplate($TEMPLATE_ONLINE['DISABLED'], TRUE);
|
||||
$text = $tp->parseTemplate($TEMPLATE_ONLINE['DISABLED'], TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -100,8 +94,8 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$img = (is_readable(THEME."images/online_menu.png") ? "<img src='".THEME_ABS."images/online_menu.png' alt='' />" : "");
|
||||
$caption = $img." ".varsettrue($menu_pref['online_caption'],LAN_ONLINE_10);
|
||||
$img = (is_readable(THEME.'images/online_menu.png') ? "<img src='".THEME_ABS."images/online_menu.png' alt='' />" : '');
|
||||
$caption = $img.' '.varsettrue($menu_pref['online_caption'],LAN_ONLINE_10);
|
||||
$ns->tablerender($caption, $text, 'online');
|
||||
|
||||
?>
|
@@ -9,11 +9,12 @@
|
||||
* e107 Main
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/online/online_menu_template.php,v $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-12-28 17:53:11 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
|
||||
global $sc_style;
|
||||
//##### LASTSEEN MENU ---------------------------------------------------------
|
||||
|
||||
$sc_style['LASTSEEN_DATE']['pre'] = "<br /> [ ";
|
||||
|
@@ -9,9 +9,9 @@
|
||||
* e107 Main
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/online/online_shortcodes.php,v $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2009-11-18 01:05:53 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2009-12-28 17:53:11 $
|
||||
* $Author: e107steved $
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
@@ -22,24 +22,30 @@ initShortcodeClass('online_shortcodes');
|
||||
class online_shortcodes
|
||||
{
|
||||
var $e107;
|
||||
var $memberInfo = array(); // Site stats
|
||||
var $currentMember = array('oid' => '0', 'oname' => '??', 'page' => 'lost');
|
||||
var $currentUser = array(); // Information about current user (for last seen)
|
||||
var $onlineMembersList = '';
|
||||
var $gen;
|
||||
|
||||
function online_shortcodes()
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->memberInfo = e107::getConfig('history');
|
||||
$this->gen = e107::getDateConvert();
|
||||
}
|
||||
|
||||
// Last Seen Menu
|
||||
function sc_lastseen_userlink()
|
||||
{
|
||||
global $row;
|
||||
return "<a href='".e_BASE."user.php?id.".$row['user_id']."'>".$row['user_name']."</a>";
|
||||
return "<a href='".e_BASE."user.php?id.".$this->currentUser['user_id']."'>".$this->currentUser['user_name']."</a>";
|
||||
}
|
||||
|
||||
function sc_lastseen_date()
|
||||
{
|
||||
global $gen, $row;
|
||||
$seen_ago = $gen->computeLapse($row['user_currentvisit'], false, false, true, 'short');
|
||||
return ($seen_ago ? $seen_ago : "1 ".LANDT_09)." ".LANDT_AGO;
|
||||
$seen_ago = $this->gen->computeLapse($this->currentUser['user_currentvisit'], false, false, true, 'short');
|
||||
return ($seen_ago ? $seen_ago : '1 '.LANDT_09).' '.LANDT_AGO;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +68,7 @@ class online_shortcodes
|
||||
|
||||
function sc_online_members_list()
|
||||
{
|
||||
global $menu_pref;
|
||||
if($menu_pref['online_show_memberlist'])
|
||||
if(e107::getConfig('menu')->get('online_show_memberlist', FALSE))
|
||||
{
|
||||
return (MEMBERS_ONLINE ? MEMBER_LIST : '');
|
||||
}
|
||||
@@ -96,7 +101,7 @@ class online_shortcodes
|
||||
$newest_member_sql = $this->e107->sql->db_Select('user', 'user_id, user_name', "user_ban='0' ORDER BY user_join DESC LIMIT 1");
|
||||
$row = $this->e107->sql->db_Fetch();
|
||||
$ret = "<a href='".e_HTTP."user.php?id.".$row['user_id']."'>".$row['user_name']."</a>";
|
||||
$this->e107->ecache->set("online_menu_member_newest", $ret);
|
||||
$this->e107->ecache->set('online_menu_member_newest', $ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -104,58 +109,52 @@ class online_shortcodes
|
||||
|
||||
function sc_online_most()
|
||||
{
|
||||
global $menu_pref;
|
||||
return intval($menu_pref['most_members_online'] + $menu_pref['most_guests_online']);
|
||||
return intval($this->memberInfo->get('most_members_online') + $this->memberInfo->get('most_guests_online'));
|
||||
}
|
||||
|
||||
|
||||
function sc_online_most_members()
|
||||
{
|
||||
global $menu_pref;
|
||||
return $menu_pref['most_members_online'];
|
||||
return $this->memberInfo->get('most_members_online');
|
||||
}
|
||||
|
||||
|
||||
function sc_online_most_guests()
|
||||
{
|
||||
global $menu_pref;
|
||||
return $menu_pref['most_guests_online'];
|
||||
return $this->memberInfo->get('most_guests_online');
|
||||
}
|
||||
|
||||
|
||||
function sc_online_most_datestamp()
|
||||
{
|
||||
global $menu_pref, $gen;
|
||||
return $gen->convert_date($menu_pref['most_online_datestamp'], "short");
|
||||
return $this->gen->convert_date($this->memberInfo->get('most_online_datestamp'), 'short');
|
||||
}
|
||||
|
||||
|
||||
|
||||
//##### ONLINE MEMBER LIST EXTENDED
|
||||
function sc_online_member_list_extended()
|
||||
function sc_online_members_list_extended()
|
||||
{
|
||||
global $ONLINE_MEMBERS_LIST_EXTENDED;
|
||||
return $ONLINE_MEMBERS_LIST_EXTENDED;
|
||||
return $this->onlineMembersList;
|
||||
}
|
||||
|
||||
|
||||
function sc_online_member_image()
|
||||
{
|
||||
return "<img src='".e_IMAGE."admin_images/users_16.png' alt='' style='vertical-align:middle' />";
|
||||
return "<img src='".e_IMAGE_ABS."admin_images/users_16.png' alt='' style='vertical-align:middle' />";
|
||||
}
|
||||
|
||||
|
||||
function sc_online_member_user()
|
||||
{
|
||||
global $oid, $oname;
|
||||
return "<a href='".e_BASE."user.php?id.$oid'>$oname</a>";
|
||||
return "<a href='".e_HTTP."user.php?id.{$this->currentMember['oid']}'>{$this->currentMember['oname']}</a>";
|
||||
}
|
||||
|
||||
|
||||
function sc_online_member_page()
|
||||
{
|
||||
global $pinfo, $ADMIN_DIRECTORY, $online_location_page;
|
||||
return (!strstr($pinfo, $ADMIN_DIRECTORY) ? "<a href='".$pinfo."'>".$online_location_page."</a>" : $online_location_page);
|
||||
global $ADMIN_DIRECTORY;
|
||||
return (!strstr($this->currentMember['pinfo'], $ADMIN_DIRECTORY) ? "<a href='".$this->currentMember['pinfo']."'>".$this->currentMember['page']."</a>" : $this->currentMember['page']);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user