|
From: OryNider <ory...@us...> - 2007-06-06 23:31:29
|
Update of /cvsroot/mxbb/mx_radio/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19138/includes Added Files: common.php Log Message: --- NEW FILE: common.php --- <?php /** * * @package mxBB Portal Module - mx_radio * @version $Id: common.php,v 1.1 2007/06/06 23:31:25 orynider Exp $ * @copyright (c) 2002-2006 [OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*************************************************************************** * History: * * * 2003/12/21 * - Modified from admin_chatbox.php by OryNider for mx_radio module * ***************************************************************************/ // // Security check // if( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // mx_radio version... // define('_radio_VERSION', "mx_radio v 1.0 RC 2"); // // Define table names. // define('RADIO_CONFIG_TABLE', $mx_table_prefix.'radio_config'); define('RADIO_SESSION_TABLE', $mx_table_prefix.'radio_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_radioname = $board_config['sitename'] . ' -> ' . 'radio'; // ================================================================================ // [ RADIO CONFIG ] // ================================================================================ // // Get radio Settings from config table // if( defined('_RADIO_CONFIG') ) { $radio_config = array(); $sql = "SELECT * FROM ".RADIO_CONFIG_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't query radio config table", "", __LINE__, __FILE__, $sql); } else { while( $row = $db->sql_fetchrow($result) ) { $radio_config[$row['config_name']] = $row['config_value']; } } } // ================================================================================ // [ COMMON FUNCTIONS ] // ================================================================================ $nick = str_replace(" ", "_", $userdata['username']); function user_listen($nick) { global $radio_config, $db; $current_time=date("U"); $sql = "DELETE FROM ".RADIO_SESSION_TABLE." WHERE username = '".addslashes($nick)."'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_listen(): DELETE<br />" . $sql); } $sql = "INSERT INTO ".RADIO_SESSION_TABLE." (username, time)" . " VALUES ('" .addslashes($nick). "', ".$current_time.")"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function user_listen(): INSERT<br />" . $sql); } } //Update user statue "listening/not listening" function update_radio_users($nick,$time) { global $radio_config, $board_config, $db, $lang; $sql="update ".RADIO_SESSION_TABLE." set time='$time' where username='$nick'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function update_radio_users(): UPDATE<br />" . $sql); } } function drop_radio_users($period) { global $radio_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 ".RADIO_SESSION_TABLE." where time<'$max_time'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function drop_radio_users()"); } } ?> |