|
From: OryNider <ory...@us...> - 2007-06-07 00:08:55
|
Update of /cvsroot/mxbb/mx_pjirc/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11032/includes Added Files: common.php Log Message: --- NEW FILE: common.php --- <?php /** * * @package mxBB Portal Module - mx_pjirc * @version $Id: common.php,v 1.1 2007/06/07 00:08:50 orynider Exp $ * @copyright (c) 2004-2006 Marc Ferran; Eric; Amo * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*************************************************************************** * History: * * * 2003/12/21 * - Modified from admin_chatbox.php by AMO for mx_pjirc module * ***************************************************************************/ // // Security check // if( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // mx_pjirc version... // define('_PJIRC_VERSION', "mx_PJIRC v.1.0"); // // Define table names. // define('PJIRC_CONFIG_TABLE', $mx_table_prefix.'pjirc_config'); define('PJIRC_SESSION_TABLE', $mx_table_prefix.'pjirc_session'); // // Load language files. // if( file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx) ) { include($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx); } else { include($module_root_path . 'language/lang_english/lang_admin.' . $phpEx); } if( file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx) ) { include($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); } else { include($module_root_path . 'language/lang_english/lang_main.' . $phpEx); } // // Common definitions... // $cfg_chatname = $board_config['sitename'] . ' -> ' . 'Pjirc'; // ================================================================================ // [ PJIRC CONFIG ] // ================================================================================ // // Get Pjirc Settings from config table // if( defined('_PJIRC_CONFIG') ) { $pjirc_config = array(); $sql = "SELECT * FROM ".PJIRC_CONFIG_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't query pjirc config table", "", __LINE__, __FILE__, $sql); } else { while( $row = $db->sql_fetchrow($result) ) { $pjirc_config[$row['config_name']] = $row['config_value']; } } } // ================================================================================ // [ COMMON FUNCTIONS ] // ================================================================================ function user_join($nick) { global $pjirc_config, $db; $current_time=date("U"); $sql = "DELETE FROM ".PJIRC_SESSION_TABLE." WHERE username = '".addslashes($nick)."'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_join(): DELETE<br />" . $sql); } $sql = "INSERT INTO ".PJIRC_SESSION_TABLE." (username, time)" . " VALUES ('" .addslashes($nick). "', ".$current_time.")"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_join(): INSERT<br />" . $sql); } } //Update user statue "chatting/not chatting" function update_user($nick,$time) { global $pjirc_config, $board_config, $db, $lang; $sql="update ".PJIRC_SESSION_TABLE." set time='$time' where username='$nick'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function update_users(): UPDATE<br />" . $sql); } } function drop_users($period) { global $pjirc_config, $board_config, $db, $lang; $current_time=date("U"); //prevent delay $period=$period+2; // Calcul max_time $max_time=$current_time-$period; $sql="delete from ".PJIRC_SESSION_TABLE." where time<'$max_time'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function drop_users()"); } } ?> |