|
From: OryNider <ory...@us...> - 2007-06-06 23:18:30
|
Update of /cvsroot/mxbb/mx_shotcast/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9956/includes Added Files: common.php Log Message: --- NEW FILE: common.php --- <?php /** * * @package mxBB Portal Module - mx_shotcast * @version $Id: common.php,v 1.1 2007/06/06 23:18:27 orynider Exp $ * @copyright (c) 2002-2006 [OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // // Security check // if( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // Define table names. // define('SHOTCAST_CONFIG_TABLE', $mx_table_prefix.'shotcast_config'); define('SHOTCAST_SESSION_TABLE', $mx_table_prefix.'shotcast_session'); // // mx_shotcast version... // $module_name = 'shotcast'; $sql = "SELECT * FROM " . MODULE_TABLE . " WHERE module_name = '$module_name'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't obtain the module informations from database", '', __LINE__, __FILE__, $sql); } while( $module = $db->sql_fetchrow($result) ) { $music_module_copy = $module['module_copy']; $music_module_name = $module['module_name']; $music_module_version = $module['module_version']; } if( !empty($music_module_copy) ) { define('_SHOTCAST_VERSION', 'mxBB <i> - ' . $music_module_name . '</i> ' . $music_module_version . ' © 2007 by OryNider'); } else { define('_SHOTCAST_VERSION', 'mxBB <i> - ShotCast Module ver. 1.x</i> © 2007 by OryNider'); } // // 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_shotcastname = $board_config['sitename'] . ' -> ' . 'shotcast'; // ================================================================================ // [ SHOTCAST CONFIG ] // ================================================================================ // // Get shotcast Settings from config table // if( defined('_SHOTCAST_CONFIG') ) { $shotcast_config = array(); $sql = "SELECT * FROM ".SHOTCAST_CONFIG_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't query shotcast config table", "", __LINE__, __FILE__, $sql); } else { while( $row = $db->sql_fetchrow($result) ) { $shotcast_config[$row['config_name']] = $row['config_value']; } } } // ================================================================================ // [ COMMON FUNCTIONS ] // ================================================================================ // $mx_user->init($user_ip, PAGE_INDEX); // $nick = str_replace(" ", "_", $userdata['username']); function user_listensc($nick) { global $shotcast_config, $db; $current_time=date("U"); $sql = "DELETE FROM ".SHOTCAST_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 ".SHOTCAST_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_shotcast_users($nick,$time) { global $shotcast_config, $board_config, $db, $lang; $sql="update ".SHOTCAST_SESSION_TABLE." set time='$time' where username='$nick'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function update_shotcast_users(): UPDATE<br />" . $sql); } } function drop_shotcast_users($period) { global $shotcast_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 ".SHOTCAST_SESSION_TABLE." where time<'$max_time'"; if( !$result = $db->sql_query($sql) ) { die("SQL Error in function drop_shotcast_users()"); } } ?> |