1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01: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:
e107steved 2009-12-28 17:53:11 +00:00
parent e7ca72a139
commit 61e9b3dcf3
12 changed files with 357 additions and 188 deletions

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.73 $
| $Date: 2009-12-25 23:32:18 $
| $Author: e107coders $
| $Revision: 1.74 $
| $Date: 2009-12-28 17:53:10 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@ -386,6 +386,7 @@ function update_706_to_800($type='')
}
$statusTexts = array(E_MESSAGE_SUCCESS => 'Success', E_MESSAGE_ERROR => 'Fail', E_MESSAGE_INFO => 'Info');
if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
{
@ -411,6 +412,52 @@ function update_706_to_800($type='')
//TODO de-serialize the user_prefs also.
// Move the maximum online counts from menu prefs to a separate pref - 'history'
$menuConfig = e107::getConfig('menu');
if ($menuConfig->get('most_members_online') || $menuConfig->get('most_guests_online') || $menuConfig->get('most_online_datestamp'))
{
$status = E_MESSAGE_SUCCESS;
if ($just_check) return update_needed('Move online counts from menupref');
$newPrefs = e107::getConfig('history');
foreach (array('most_members_online', 'most_guests_online', 'most_online_datestamp') as $v)
{
if (FALSE === $newPrefs->get($v, FALSE))
{
if (FALSE !== $menuConfig->get($v, FALSE))
{
$newPrefs->set($v,$menuConfig->get($v));
}
else
{
$newPrefs->set($v, 0);
}
}
$menuConfig->remove($v);
}
$result = $newPrefs->save(false, true, false);
if ($result === TRUE)
{
$resultMessage = 'Historic member counts updated';
}
elseif ($result === FALSE)
{
$resultMessage = 'moving historic member counts';
$status = E_MESSAGE_ERROR;
}
else
{ // No change
$resultMessage = 'Historic member counts already updated';
$status = E_MESSAGE_INFO;
}
$result = $menuConfig->save(false, true, false); // Save updated menuprefs - without the counts
$updateMessages[] = $statusTexts[$status].': '.$resultMessage; // Admin log message
$mes->add($resultMessage,$status); // User message
}
// ++++++++ Modify Menu Paths +++++++.
if(varset($changeMenuPaths))
{
@ -439,7 +486,7 @@ function update_706_to_800($type='')
//if online_extended is activated, we need to activate the new 'online' menu, and delete this record
if($row['menu_location']!=0)
{
$status = $sql->db_Update("menus", "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$status = $sql->db_Update('menus', "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add(LAN_UPDATE_23."<b>online_menu</b> : online/", $status);
}
else
@ -456,7 +503,7 @@ function update_706_to_800($type='')
{
if ($just_check) return update_needed();
$status = $sql->db_Update("menus", "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$status = $sql->db_Update('menus', "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$mes->add(LAN_UPDATE_23."<b>online_menu</b> : online/", $status);
catch_error($sql);
}
@ -548,7 +595,7 @@ function update_706_to_800($type='')
{
if ($just_check) return update_needed('Update newsfeed field definition');
$status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
$updateMessages[] = LAN_UPDATE_40; //FIXME
$updateMessages[] = LAN_UPDATE_40;
$mes->add(LAN_UPDATE_21."newsfeed",$status);
// catch_error($sql);
}

View File

@ -9,16 +9,16 @@
* e107 Mailout - mail database API and utility routines
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/mail_manager_class.php,v $
* $Revision: 1.10 $
* $Date: 2009-12-13 21:52:32 $
* $Revision: 1.11 $
* $Date: 2009-12-28 17:53:10 $
* $Author: e107steved $
*/
/**
*
* @package e107
* @category e107_handlers
* @version $Revision: 1.10 $
* @subpackage e107_handlers
* @version $Revision: 1.11 $
* @author $Author: e107steved $

View File

@ -9,18 +9,66 @@
* e107 Main
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/online_class.php,v $
* $Revision: 1.8 $
* $Date: 2009-12-24 10:00:30 $
* $Author: e107coders $
* $Revision: 1.9 $
* $Date: 2009-12-28 17:53:10 $
* $Author: e107steved $
*/
/**
*
* @package e107
* @subpackage e107_handlers
* @version $Id: online_class.php,v 1.9 2009-12-28 17:53:10 e107steved Exp $;
*
*/
/*
online_timestamp int(10) unsigned NOT NULL default '0', Start of time period over which accesses counted
online_flag tinyint(3) unsigned NOT NULL default '0', Not used? (displayed in admin log only)
online_user_id varchar(100) NOT NULL default '',
online_ip varchar(45) NOT NULL default '',
online_location text NOT NULL, Current page being accessed
online_pagecount tinyint(3) unsigned NOT NULL default '0', Number of page accesses (within most recent timeout interval?)
online_active int(10) unsigned NOT NULL default '0', Not used? Actually added in the update routines, version 0.7.6. (Also displayed in admin log)
online_agent varchar(255) NOT NULL default '' User agent - use for bot identification
Current count() queries:
a) Total
b) $sql->db_Count('online', '(*)', "WHERE `online_location` = '{$page}' "));
Also forum_viewforum.php:
$member_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id != 0");
$guest_users = $sql->db_Count('online', '(*)', "WHERE online_location REGEXP('viewforum.php.id=$forumId\$') AND online_user_id = 0");
Following single query gives two rows of data - one for members (online_user_id != 0) and one for guests (online_user_id == 0)
SELECT COUNT(`online_user_id`) AS ol_count, `online_user_id` FROM `#online` GROUP BY (`online_user_id` = 0)
*/
/**
* @todo Don't create list of online members by default - $listuserson used in forum, online_menu.php, online.php
* @todo $member_list defined as MEMBER_LIST - used in online_shortcodes.php
* @todo $members_online, defined as MEMBERS_ONLINE - used in online_menu.php, online_shortcodes.php, online_template.php, online.php, forum.php
* @todo $total_online defined (indirectly) as GUESTS_ONLINE + MEMBERS_ONLINE - used in online_menu.php, online_shortcodes.php, online_template.php, online.php
* @todo Possibly online_pagecount should be bigger than tinyint(3)
* @todo Possibly shouldn't log access to index.php - its usually a redirect - but not always!
* @todo Can we distinguish between different users at same IP? Browser sig, maybe?
* @todo Change queries to array access
* @todo Eliminate other globals
* @todo Can we simplify counts into one query?
*/
class e_online
{
function online($online_tracking = false, $flood_control = false)
{
global $sql, $pref, $e107, $e_event, $tp, $online_timeout, $online_warncount, $online_bancount;
global $members_online, $total_online, $member_list, $listuserson;
global $pref, $e_event;
//global $online_timeout, $online_warncount, $online_bancount; // Not needed as globals
//global $members_online, $total_online; // Not needed as globals
global $listuserson;
$e107 = e107::getInstance();
$sql = e107::getDb();
if($online_tracking == true || $flood_control == true)
{
@ -36,12 +84,12 @@ class e_online
}
$online_warncount = $online_bancount * 0.9; // Set warning threshold at 90% of ban threshold
//TODO Add support for all queries.
$page = (strpos(e_SELF, "forum_") !== FALSE) ? e_SELF.".".e_QUERY : e_SELF;
$page = (strpos(e_SELF, "comment") !== FALSE) ? e_SELF.".".e_QUERY : $page;
$page = (strpos(e_SELF, "content") !== FALSE) ? e_SELF.".".e_QUERY : $page;
$page = $tp -> toDB($page, true);
$page = (strpos(e_SELF, 'forum_') !== FALSE) ? e_SELF.'.'.e_QUERY : e_SELF;
$page = (strpos(e_SELF, 'comment') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
$page = (strpos(e_SELF, 'content') !== FALSE) ? e_SELF.'.'.e_QUERY : $page;
$page = $e107->tp->toDB($page, true);
$ip = $e107->getip();
$udata = (USER === true) ? USERID.".".USERNAME : "0";
$udata = (USER === true ? USERID.'.'.USERNAME : '0');
$agent = $_SERVER['HTTP_USER_AGENT'];
$insert_query = array(
@ -58,49 +106,60 @@ class e_online
if (USER)
{
// Find record that matches IP or visitor, or matches user info
if ($sql->db_Select("online", "*", "(`online_ip` = '{$ip}' AND `online_user_id` = '0') OR `online_user_id` = '{$udata}'"))
if ($sql->db_Select('online', '*', "(`online_ip` = '{$ip}' AND `online_user_id` = '0') OR `online_user_id` = '{$udata}'"))
{
$row = $sql->db_Fetch();
if ($row['online_user_id'] == $udata) {
if ($row['online_user_id'] == $udata)
{
//Matching user record
if ($row['online_timestamp'] < (time() - $online_timeout)) {
//It has been at least 'timeout' seconds since this user has connected
if ($row['online_timestamp'] < (time() - $online_timeout))
{
//It has been at least 'online_timeout' seconds since this user's info last logged
//Update user record with timestamp, current IP, current page and set pagecount to 1
$query = "online_timestamp='".time()."', online_ip='{$ip}', online_location='{$page}', online_pagecount=1 WHERE online_user_id='{$row['online_user_id']}' LIMIT 1";
} else {
if (!ADMIN) {
}
else
{
if (!ADMIN)
{
$row['online_pagecount'] ++;
}
// Update user record with current IP, current page and increment pagecount
$query = "online_ip='{$ip}', `online_location` = '{$page}', `online_pagecount` = '".intval($row['online_pagecount'])."' WHERE `online_user_id` = '{$row['online_user_id']}' LIMIT 1";
}
} else {
}
else
{
//Found matching visitor record (ip only) for this user
if ($row['online_timestamp'] < (time() - $online_timeout)) {
if ($row['online_timestamp'] < (time() - $online_timeout))
{
// It has been at least 'timeout' seconds since this user has connected
// Update record with timestamp, current IP, current page and set pagecount to 1
$query = "`online_timestamp` = '".time()."', `online_user_id` = '{$udata}', `online_location` = '{$page}', `online_pagecount` = 1 WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
} else {
if (!ADMIN) {
}
else
{ // Another visit within the timeout period
if (!ADMIN)
{
$row['online_pagecount'] ++;
}
//Update record with current IP, current page and increment pagecount
$query = "`online_user_id` = '{$udata}', `online_location` = '{$page}', `online_pagecount` = ".intval($row['online_pagecount'])." WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
}
}
$sql->db_Update("online", $query);
$sql->db_Update('online', $query);
}
else
{
$sql->db_Insert("online",$insert_query);
$sql->db_Insert('online',$insert_query);
}
}
else
{
//Current page request is from a visitor
if ($sql->db_Select("online", "*", "`online_ip` = '{$ip}' AND `online_user_id` = '0'"))
{
if ($sql->db_Select('online', '*', "`online_ip` = '{$ip}' AND `online_user_id` = '0'"))
{ // Recent visitor
$row = $sql->db_Fetch();
if ($row['online_timestamp'] < (time() - $online_timeout)) //It has been at least 'timeout' seconds since this ip has connected
@ -115,11 +174,11 @@ class e_online
// echo "here {$online_pagecount}";
$query="`online_location` = '{$page}', `online_pagecount` = {$row['online_pagecount']} WHERE `online_ip` = '{$ip}' AND `online_user_id` = '0' LIMIT 1";
}
$sql->db_Update("online", $query);
$sql->db_Update('online', $query);
}
else
{
$sql->db_Insert("online",$insert_query);
{ // New visitor
$sql->db_Insert('online',$insert_query);
}
}
@ -128,47 +187,65 @@ class e_online
$row['online_pagecount'] = 1;
}
if ($row['online_pagecount'] > $online_bancount && ($e107->ipDecode($row['online_ip'],TRUE) != "127.0.0.1"))
// Always allow localhost - any problems are usually semi-intentional!
if (($row['online_ip'] != '127.0.0.1') && ($row['online_ip'] != e107::LOCALHOST_IP))
{
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php');
if ($e107->add_ban(2,str_replace('--HITS--',$row['online_pagecount'],BANLAN_78),$ip,0))
// Check for excessive access
if ($row['online_pagecount'] > $online_bancount)
{
$e_event->trigger("flood", $ip);
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_banlist.php');
if ($e107->add_ban(2,str_replace('--HITS--',$row['online_pagecount'],BANLAN_78),$ip,0))
{
$e_event->trigger('flood', $ip);
exit;
}
}
elseif ($row['online_pagecount'] >= $online_warncount)
{
echo "<div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b>".LAN_WARNING."</b><br /><br />".CORE_LAN6."<br /></div>";
exit;
}
}
if ($row['online_pagecount'] >= $online_warncount && $row['online_ip'] != "127.0.0.1")
// Delete records for users (and guests) not seen for a while
$sql->db_Delete('online', '`online_timestamp` < '.(time() - $online_timeout));
$total_online = $sql->db_Count('online');
if ($members_online = $sql->db_Select('online', 'online_user_id, online_location', 'online_user_id != 0'))
{
echo "<div style='text-align:center; font: 11px verdana, tahoma, arial, helvetica, sans-serif;'><b>".LAN_WARNING."</b><br /><br />".CORE_LAN6."<br /></div>";
exit;
}
$sql->db_Delete("online", "`online_timestamp` < ".(time() - $online_timeout));
$total_online = $sql->db_Count("online");
if ($members_online = $sql->db_Select("online", "*", "online_user_id != '0' ")) {
$member_list = '';
$listuserson = array();
while ($row = $sql->db_Fetch()) {
$vals = explode(".", $row['online_user_id'], 2);
while ($row = $sql->db_Fetch())
{
$vals = explode('.', $row['online_user_id'], 2);
$member_list .= "<a href='".e_BASE."user.php?id.{$vals[0]}'>{$vals[1]}</a> ";
$listuserson[$row['online_user_id']] = $row['online_location'];
}
}
define("TOTAL_ONLINE", $total_online);
define("MEMBERS_ONLINE", $members_online);
define("GUESTS_ONLINE", $total_online - $members_online);
define("ON_PAGE", $sql->db_Count("online", "(*)", "WHERE `online_location` = '{$page}' "));
define("MEMBER_LIST", $member_list);
define('TOTAL_ONLINE', $total_online);
define('MEMBERS_ONLINE', $members_online);
define('GUESTS_ONLINE', $total_online - $members_online);
define('ON_PAGE', $sql->db_Count('online', '(*)', "WHERE `online_location` = '{$page}' "));
define('MEMBER_LIST', $member_list);
//update most ever online
$olCountPrefs = e107::getConfig('history'); // Get historic counts of members on line
if ($total_online > ($olCountPrefs->get('most_members_online') + $olCountPrefs->get('most_guests_online')))
{
$olCountPrefs->set('most_members_online', MEMBERS_ONLINE);
$olCountPrefs->set('most_guests_online', GUESTS_ONLINE);
$olCountPrefs->set('most_online_datestamp', time());
$olCountPrefs->save(false, true, false);
}
}
else
{
define("e_TRACKING_DISABLED", true);
define("TOTAL_ONLINE", "");
define("MEMBERS_ONLINE", "");
define("GUESTS_ONLINE", "");
define("ON_PAGE", "");
define("MEMBER_LIST", ""); //
define('e_TRACKING_DISABLED', true); // Used in forum, online menu
define('TOTAL_ONLINE', '');
define('MEMBERS_ONLINE', '');
define('GUESTS_ONLINE', '');
define('ON_PAGE', '');
define('MEMBER_LIST', '');
}
}
}

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright (c) e107 Inc 2009 - e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: e_shortcode.php,v 1.1 2009-09-18 22:20:39 e107coders Exp $
* $Id: e_shortcode.php,v 1.2 2009-12-28 17:53:10 e107steved Exp $
*
* Banner shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/
@ -10,7 +10,6 @@ class banner_shortcodes // must match the plugin's folder name. ie. [PLUGIN_FOLD
{
function sc_banner($parm)
{
global $menu_pref;
$e107 = e107::getInstance();
$ret = '';

View File

@ -0,0 +1,37 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Event calendar plugin - Front page
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/e_frontpage.php,v $
* $Revision: 1.1 $
* $Date: 2009-12-28 17:53:11 $
* $Author: e107steved $
*
*/
/**
* e107 Event calendar plugin
*
* @package e107_plugins
* @subpackage event_calendar
* @version $Id: e_frontpage.php,v 1.1 2009-12-28 17:53:11 e107steved Exp $;
*/
if (!defined('e107_INIT')) { exit; }
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'_admin_calendar_menu.php');
$front_page['calendar'] = array(
'title' => EC_ADLAN_1,
'page' => array(
array('page' => e_PLUGIN_ABS.'calendar_menu/calendar.php', 'title' => EC_ADLAN_A09 ),
array('page' => e_PLUGIN_ABS.'calendar_menu/event.php', 'title' => EC_LAN_163 ))
);
?>

View File

@ -9,8 +9,8 @@
* Forthcoming events menu handler for event calendar
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/next_event_menu.php,v $
* $Revision: 1.9 $
* $Date: 2009-12-20 22:47:33 $
* $Revision: 1.10 $
* $Date: 2009-12-28 17:53:11 $
* $Author: e107steved $
*/
@ -19,7 +19,7 @@
*
* @package e107_plugins
* @subpackage event_calendar
* @version $Id: next_event_menu.php,v 1.9 2009-12-20 22:47:33 e107steved Exp $;
* @version $Id: next_event_menu.php,v 1.10 2009-12-28 17:53:11 e107steved Exp $;
*/
if (!defined('e107_INIT')) { exit; }
@ -28,6 +28,12 @@ $e107 = e107::getInstance();
if (!$e107->isInstalled('calendar_menu')) return '';
if (!isset($scal_class) || !is_object($ecal_class))
{
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
}
// See if the page is already in the cache
$cache_tag = 'nq_event_cal_next';
if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time))
@ -36,11 +42,6 @@ if($cacheData = $e107->ecache->retrieve($cache_tag, $ecal_class->max_cache_time)
return;
}
if (!is_object($ecal_class))
{
require_once(e_PLUGIN.'calendar_menu/ecal_class.php');
$ecal_class = new ecal_class;
}
include_lan(e_PLUGIN.'calendar_menu/languages/'.e_LANGUAGE.'.php');

View File

@ -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'>

View File

@ -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');

View File

@ -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');
?>

View File

@ -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 /> [ ";

View File

@ -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']);
}
}

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/userposts.php,v $
| $Revision: 1.13 $
| $Date: 2009-11-18 01:04:24 $
| $Author: e107coders $
| $Revision: 1.14 $
| $Date: 2009-12-28 17:53:11 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
require_once('class2.php');
@ -101,7 +101,7 @@ if ($action == "comments")
global $row;
foreach($data as $row){
$userposts_comments_table_string .= parse_userposts_comments_table($row);
$userposts_comments_table_string .= parse_userposts_comments_table($row, $USERPOSTS_COMMENTS_TABLE);
}
$userposts_comments_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE_START);
@ -212,9 +212,9 @@ if ($action == 'forums' || isset($_POST['fsearch']))
require_once(FOOTERF);
function parse_userposts_comments_table($row)
function parse_userposts_comments_table($row, $USERPOSTS_COMMENTS_TABLE)
{
global $USERPOSTS_COMMENTS_TABLE, $pref, $gen, $tp, $menu_pref, $id, $sql2, $comment_files;
// global $USERPOSTS_COMMENTS_TABLE, $pref, $gen, $tp, $id, $sql2, $comment_files;
$gen = new convert;
$datestamp = $gen->convert_date($row['comment_datestamp'], "short");