|
From: OryNider <ory...@us...> - 2007-06-26 16:02:01
|
Update of /cvsroot/mxbb/mx_online_adv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25899 Added Files: db_install.php db_uninstall.php mx_online_adv.pak mx_online_adv.php readme.txt Log Message: --- NEW FILE: db_install.php --- <?php /** * * @package mxBB Portal Module - mx_online_adv * @version $Id: db_install.php,v 1.1 2007/06/26 16:01:49 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ //ini_set( 'display_errors', '1' ); define( 'IN_PORTAL', true ); if ( !defined( 'IN_ADMIN' ) ) { $mx_root_path = './../../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include( $mx_root_path . 'common.' . $phpEx ); // Start session management $mx_user->init($user_ip, PAGE_INDEX); // End session management if ( !$userdata['session_logged_in'] ) { die( "Hacking attempt(1)" ); } if ( $userdata['user_level'] != ADMIN ) { die( "Hacking attempt(2)" ); } } $mx_module_version = '1.0.0'; $mx_module_copy = 'mxBB <i> - mx_online_adv</i> module by Horace & <a href="http://www.mxbb.net" target="_blank">OryNider</a>'; // If fresh install if ( !$result = $db->sql_query( "SELECT username from " . $mx_table_prefix . "online_adv_session" ) ) { $message = "<b>This is a fresh install!</b><br/><br/>"; $sql = array(); $sql[] = "DROP TABLE IF EXISTS " . $mx_table_prefix . "online_adv_session"; $sql[] = "CREATE TABLE ".$mx_table_prefix."online_adv_session ( username varchar(99) NOT NULL, time bigint(20) NOT NULL, bot_id INTEGER NOT NULL DEFAULT '0', UNIQUE username (username) ) TYPE=MyISAM"; $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', module_copy = '" . $mx_module_copy . "' WHERE module_id = '" . $mx_module_id . "'"; $message .= mx_do_install_upgrade( $sql ); } else { // If already installed $message = "<b>Module is already installed... consider upgrading ;)</b><br/><br/>"; } echo "<br /><br />"; echo "<table width=\"90%\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"forumline\">"; echo "<tr><th class=\"thHead\" align=\"center\">Module Installation/Upgrading/Uninstallation Information - Module specific DB tables</th></tr>"; echo "<tr><td class=\"row1\" align=\"left\"><span class=\"gen\">" . $message . "</span></td></tr>"; echo "</table><br />"; ?> --- NEW FILE: mx_online_adv.php --- <?php /** * * @package mxBB Portal Module - mx_coreblocks * @version $Id: mx_online_adv.php,v 1.1 2007/06/26 16:01:51 orynider Exp $ * @copyright (c) 2002-2006 mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if( !defined('IN_PORTAL') || !is_object($mx_block)) { die("Hacking attempt"); } // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); // // End session management // include_once($module_root_path . 'includes/online_common.'.$phpEx); // Get all remain sessions $sql = "SELECT * FROM ".ONLINE_ADV_SESSION_TABLE; if (!$sol = $db->sql_query($sql)) { mx_message_die(GENERAL_ERROR, "Could not query Online Advance Session information", "", __LINE__, __FILE__, $sql); } $howmanyspiders = $db->sql_numrows($sol); // Return this $isimler[0] = $db->sql_numrows($sol); $i = 1; while ($record = $db->sql_fetchrow($sol)) { $isimler[$i++] = $record['username']; } if ( !empty($howmanyspiders) ) { $bot_count = $howmanyspiders; } else { $bot_count = 0; } $spiders = ( empty($isimler[1]) ? '' : $isimler[1] ); for($s = 2; $s <= $isimler[0]; $s++) { $spiders .= ', ' . $isimler[$s]; } // // Get basic (usernames + totals) online // situation // $logged_visible_online = 0; $logged_hidden_online = 0; $guests_online = ''; $online_userlist = ''; $l_online_users = ''; $uot_this_timestamp_array = getdate(); $uot_when_from = mktime(0, 0, 0, $uot_this_timestamp_array[mon], $uot_this_timestamp_array[mday], $uot_this_timestamp_array[year]); $uot_hidden_count = 0; // ================================================================================ // The following code is backported from includes/page_header.php (phpBB 2.0.13) // ================================================================================ /* $block_config = read_block_config($block_id); $parm1_display_today = $block_config[$block_id]['Display Todays Users']['parameter_value']; $parm2_put_today_bottom = $block_config[$block_id]['Todays Users On Bottom']['parameter_value']; $parm3_show_icon = $block_config[$block_id]['Show Left Icon']['parameter_value']; */ $parm1_display_today = $mx_block->get_parameters( 'Display Todays Users' ); $parm2_put_today_bottom = $mx_block->get_parameters( 'Todays Users On Bottom' ); $parm3_show_icon = $mx_block->get_parameters( 'Show Left Icon' ); // Start of Advanced mx_online block if ($parm1_display_today == 'TRUE') { $sql = "SELECT count(*) cnt FROM " . USERS_TABLE . " u WHERE u.user_session_time >= " . $uot_when_from . " ORDER BY u.username ASC"; if (!($uot_result = $db->sql_query($sql))) { mx_message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($uot_result); $uot_count = $row['cnt']; $sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, user_session_time FROM " . USERS_TABLE . " u WHERE u.user_session_time >= " . $uot_when_from . " ORDER BY u.username ASC"; if (!($uot_result = $db->sql_query($sql))) { mx_message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql); } $users_online_today = array(); while ($row = $db->sql_fetchrow($uot_result)) { $$which_counter++; $row_color = ($$which_counter % 2) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ($$which_counter % 2) ? $theme['td_class1'] : $theme['td_class2']; //generate the user name (robbed from the code above) $uot_user_id = $row['user_id']; //reset the style... $uot_style = ''; if ($uot_user_id != $prev_user) { $uot_username_plain = $uot_username = $row['username']; if ($row['user_level'] == ADMIN) { $uot_style = 'style="color:#' . $theme['fontcolor3'] . ';"'; $uot_username = '<b>' . $uot_username . '</b>'; } else if ($row['user_level'] == MOD) { $uot_style = 'style="color:#' . $theme['fontcolor2'] . ';"'; $uot_username = '<b>' . $uot_username . '</b>'; } if (!$row['user_allow_viewonline']) { $uot_hidden_count++; $view_online = ( $userdata['user_level'] == ADMIN ) ? true : false; $uot_username = $lang['UOT_hidden_start'] . $uot_username . $lang['UOT_hidden_end']; } else { $view_online = true; } } //annon does not have a profile... if($row['user_id'] > 0) { $uot_username = sprintf('<a href="' . PHPBB_URL . 'profile.php?mode=viewprofile&u=%d" title="%s was last here at: %s" %s>%s</a>',$uot_user_id,$uot_username_plain,create_date('g:ia', $row['user_session_time'], $board_config['board_timezone']),$uot_style,$uot_username); } //this will show just the user's name, with the time in the tool tip. if($view_online) { array_push($users_online_today, $uot_username); } } if(count($users_online_today)==0) { array_push($users_online_today,$lang['UOT_none']); } if( $userdata['user_level'] == ADMIN && $uot_hidden_count>0) { array_push($users_online_today,sprintf($lang['UOT_hidden'], $uot_hidden_count)); } if ($parm2_put_today_bottom == 'TRUE') { $template->assign_block_vars('show_today_mode_bottom', array( 'UOT_TITLE' => sprintf($lang['UOT_title'], $uot_count), 'UOT_COUNT' => $uot_count, 'UOT_LIST' => implode(", ",$users_online_today) ) ); } else { $template->assign_block_vars('show_today_mode_top', array( 'UOT_TITLE' => sprintf($lang['UOT_title'], $uot_count), 'UOT_COUNT' => $uot_count, 'UOT_LIST' => implode(", ",$users_online_today) ) ); } } if ($parm3_show_icon == 'TRUE') { $template->assign_block_vars('hide_left_icon', array( ) ); } // End of Advanced mx_online block $sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s WHERE u.user_id = s.session_user_id AND s.session_time >= ".( time() - 300 ) . " ORDER BY u.username ASC, s.session_ip ASC"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql); } $userlist_ary = array(); $userlist_visible = array(); $prev_user_id = 0; $prev_user_ip = $prev_session_ip = ''; while( $row = $db->sql_fetchrow($result) ) { // User is logged in and therefor not a guest if ( $row['session_logged_in'] ) { // Skip multiple sessions for one user if ( $row['user_id'] != $prev_user_id ) { $style_color = ''; if ( $row['user_level'] == ADMIN ) { $row['username'] = '<b>' . $row['username'] . '</b>'; $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; } else if ( $row['user_level'] == MOD ) { $row['username'] = '<b>' . $row['username'] . '</b>'; $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; } if ( $row['user_allow_viewonline'] ) { $user_online_link = '<a href="' . append_sid(PHPBB_URL."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>'; $logged_visible_online++; } else { $user_online_link = '<a href="' . append_sid(PHPBB_URL."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>'; $logged_hidden_online++; } if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) { $online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link; } } $prev_user_id = $row['user_id']; } else { // Skip multiple sessions for one user if ( $row['session_ip'] != $prev_session_ip ) { $guests_online++; } } $prev_session_ip = $row['session_ip']; } $db->sql_freeresult($result); if ( empty($online_userlist) ) { $online_userlist = $lang['None']; } if ( empty($spiders) ) { $spiders = $lang['None']; } $msn_color = 'style="font-weight: bold; color:#' . $theme['fontcolor1'] . '"'; $yahoo_color = 'style="font-weight: bold; color: #DD2222;"'; $lycos_color = 'style="font-weight: bold;"'; $spiders = str_replace('google','<span style="font-weight: bold; color: #2244BB;">G</span><span style="font-weight: bold; color: #DD2222;">o</span><span style="font-weight: bold; color: #EEBB00;">o</span><span style="font-weight: bold; color: #2244BB;">g</span><span style="font-weight: bold; color: #339933;">l</span><span style="font-weight: bold; color: #DD2222;">e</span>',$spiders); $spiders = str_replace('msn','<span ' . $msn_color . '>msn</span>',$spiders); $spiders = str_replace('lycos','<span ' . $lycos_color . '>lycos</span>',$spiders); $spiders = str_replace('yahoo','<span ' . $yahoo_color . '>Yahoo!</span>',$spiders); $online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist; $online_spiderlist = $lang['Seach_Engines'] . ': ' . $spiders; if ( !empty($howmanyspiders) ) { if ( $guests_online < $howmanyspiders ) { $guests_online = $howmanyspiders; $period=$period+2; drop_spiders_surfing($period); } } if ( $guests_online == 0 ) { if ( !empty($howmanyspiders) ) { $guests_online = $howmanyspiders; } $nullperiod = '2'; drop_spiders_surfing($nullperiod); } $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; if ( $total_online_users > $board_config['record_online_users']) { $board_config['record_online_users'] = $total_online_users; $board_config['record_online_date'] = time(); $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$total_online_users' WHERE config_name = 'record_online_users'"; if ( !$db->sql_query($sql,300) ) { mx_message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql); } $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . $board_config['record_online_date'] . "' WHERE config_name = 'record_online_date'"; if ( !$db->sql_query($sql,300) ) { mx_message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql); } } if ( $total_online_users == 0 ) { $l_t_user_s = $lang['Online_users_zero_total']; } else if ( $total_online_users == 1 ) { $l_t_user_s = $lang['Online_user_total']; } else { $l_t_user_s = $lang['Online_users_total']; } if ( $logged_visible_online == 0 ) { $l_r_user_s = $lang['Reg_users_zero_total']; } else if ( $logged_visible_online == 1 ) { $l_r_user_s = $lang['Reg_user_total']; } else { $l_r_user_s = $lang['Reg_users_total']; } if ( $logged_hidden_online == 0 ) { $l_h_user_s = $lang['Hidden_users_zero_total']; } else if ( $logged_hidden_online == 1 ) { $l_h_user_s = $lang['Hidden_user_total']; } else { $l_h_user_s = $lang['Hidden_users_total']; } if ( $guests_online == 0 ) { if ( !empty($howmanyspiders) ) { $guests_online = $howmanyspiders; if ( $guests_online == 1 ) { $l_g_user_s = $lang['Guest_user_total']; } else { $l_g_user_s = $lang['Guest_users_total']; } } else { $l_g_user_s = $lang['Guest_users_zero_total']; } $nullperiod = '2'; drop_spiders_surfing($nullperiod); } else if ( $guests_online == 1 ) { $l_g_user_s = $lang['Guest_user_total']; } else { $l_g_user_s = $lang['Guest_users_total']; } $l_online_users = sprintf($l_t_user_s, $total_online_users); $l_online_users .= sprintf($l_r_user_s, $logged_visible_online); $l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); $l_online_users .= sprintf($l_g_user_s, $guests_online); // ================================================================================ // The following code is backported from index.php (phpBB 2.0.13) // ================================================================================ // // If you don't use these stats on your index you may want to consider // removing them // $total_posts = mx_get_db_stat('postcount'); $total_users = mx_get_db_stat('usercount'); $newest_userdata = mx_get_db_stat('newestuser'); $newest_user = $newest_userdata['username']; $newest_uid = $newest_userdata['user_id']; if( $total_posts == 0 ) { $l_total_post_s = $lang['Posted_articles_zero_total']; } else if( $total_posts == 1 ) { $l_total_post_s = $lang['Posted_article_total']; } else { $l_total_post_s = $lang['Posted_articles_total']; } if( $total_users == 0 ) { $l_total_user_s = $lang['Registered_users_zero_total']; } else if( $total_users == 1 ) { $l_total_user_s = $lang['Registered_user_total']; } else { $l_total_user_s = $lang['Registered_users_total']; } // ================================================================================ // Send our Who's Online block to the browser // ================================================================================ $template->set_filenames(array( 'body_online' => 'mx_online_adv.tpl') ); $template->assign_vars(array( 'BLOCK_SIZE' => $block_size, 'TOTAL_USERS_ONLINE' => $l_online_users, 'SEARCH_ENGINES_LIST' => $online_spiderlist, 'LOGGED_IN_USER_LIST' => $online_userlist, 'RECORD_USERS' => sprintf($lang['Record_online_users'], $board_config['record_online_users'], create_date($board_config['default_dateformat'], $board_config['record_online_date'], $board_config['board_timezone'])), 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], 'L_WHOSONLINE_ADMIN' => sprintf($lang['Admin_online_color'], '<span style="color:#' . $theme['fontcolor3'] . '">', '</span>'), 'L_WHOSONLINE_MOD' => sprintf($lang['Mod_online_color'], '<span style="color:#' . $theme['fontcolor2'] . '">', '</span>'), 'ONLINE_IMG' => $images['mx_who_is_online'], 'U_VIEWONLINE' => append_sid(PHPBB_URL.'viewonline.'.$phpEx), 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts), 'TOTAL_USERS' => sprintf($l_total_user_s, $total_users), 'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid(PHPBB_URL."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'), )); $template->pparse('body_online'); ?> --- NEW FILE: mx_online_adv.pak --- module=+:10=+:Online Advance=+:modules/mx_online_adv/=+:mxBB Online (Advance) Module=+:0 New_function=+:---------------------------=+:0=+:0=+:0=+:0=+:0 function=+:10=+:83=+:Who is Online (Advanced)=+:Who is Online Block Advanced Block=+:mx_online_adv.php=+: parameter=+:83=+:164=+:Display Todays Users=+:Boolean=+:FALSE=+:=+:1=+:0 parameter=+:83=+:165=+:Todays Users On Bottom=+:Boolean=+:FALSE=+:=+:1=+:0 parameter=+:83=+:166=+:Show Left Icon=+:Boolean=+:TRUE=+:=+:1=+:0 parameter=+:0=+:0=+:0=+:endoflist=+:0=+:0 block=+:=+:Demo - Who is Online (Advanced)=+:Demo block=+:83=+:0=+:5=+:0=+:0=+:0=+:0=+:1=+:1 function=+:0=+:0=+:0=+:endoflist=+:0=+:0 --- NEW FILE: readme.txt --- /********************************************************************************\ | | subject : mx-portal, CMS & portal, module | name : mx_online | copyright : (C) 2002-2005 MX-System | mxBB project site : www.mx-system.com | | | description : The "mx_online_adv" block is a block with | Who is Online Advance statistics. | | | | \********************************************************************************/ /********************************************************************************\ | Installation Instructions \********************************************************************************/ Note: In order for this module to install you must have a working phpBB and mxBB installation. phpbbroot refers to where your phpBB2 install is located, e.g in phpBB2/ or forum/ 1) Copy the folder: mx_online_adv into your: {mxBB install}\modules\ folder on your web server. 2) From your website enter mxBB Admin Control Panel. 3) Under mxBB-Portal click on Management. 4) Now click on Modules Setup. 5) Under Module Administration use the pull down menu and choose: mx_online_adv 6) Press the Install Module button 7) Now, add the newly created mx_online_adv Block to a relevant portal page and replace, the now redundant mx_onlie block (Who is Online) for e.g. from portal home page. Using mxBB-Portal -> Management -> Page Control Pannel. 8) Modify your mxBB common.php # #-----[ OPEN ]------------------------------------------ # mxbb_root/common.php # #-----[ FIND ]------------------------------------------ # ?> # #-----[ REPLACE WITH ]------------------------------------------ # // Code to be inluded at the end of common.php for mx_online_adv BEGIN if (file_exists($mx_root_path . 'modules/mx_online_adv/includes/online_adv_hack.'.$phpEx)) { include_once($mx_root_path . 'modules/mx_online_adv/includes/online_adv_hack.'.$phpEx); } // Code to be inluded at the end of common.php for mx_online_adv END ?> # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM /********************************************************************************\ | End Of Document \********************************************************************************/ --- NEW FILE: db_uninstall.php --- <?php /** * * @package mxBB Portal Module - mx_online_adv * @version $Id: db_uninstall.php,v 1.1 2007/06/26 16:01:50 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ define('IN_PORTAL', true); if ( !defined('IN_ADMIN') ) { $mx_root_path = '../../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'common.'.$phpEx); // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); if( !$userdata['session_logged_in'] ) { die("Hacking attempt(3)"); } if( $userdata['user_level'] != ADMIN ) { die("Hacking attempt(4)"); } // // End session management // } $sql = array( "DROP TABLE IF EXISTS ".$mx_table_prefix."online_adv_session" ); $n = 0; $message = "<b>This list is a result of the SQL queries needed to uninstall radio Module Addon</b><br/><br/>"; while($sql[$n]) { $message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br/>' : ''; if( !$result = $db->sql_query($sql[$n]) ) { $message .= '<b><font color=#FF0000>[Error or Already removed]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } else { $message .='<b><font color=#0000fF>[Removed]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />'; } $n++; } $message .= ' <br />If you get some Error, relax, this is normal when updating modules'; echo '<br /> <br />'; echo '<table cellpadding="4" cellspacing="1" border="0" class="forumline">'; echo '<tr><th class="thHead" align="center">Module Installation Information</th></tr>'; echo '<tr><td class="row1" align="center"><span class="gen">' . $message . '</span></td></tr>'; echo '</table> <br />'; ?> |