|
From: OryNider <ory...@us...> - 2007-06-06 20:33:16
|
Update of /cvsroot/mxbb/mx_music/music_box In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6104/music_box Added Files: index.html music_common.php music_constants.php music_functions.php music_integration.php Log Message: --- NEW FILE: music_common.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_common.php,v 1.1 2007/06/06 20:33:01 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } define('IN_MO', true); if ( !defined('MUSIC_BOX_PATH') ) { define('MUSIC_BOX_PATH', 'music_box/'); } if (!isset($music_root_path) || empty($music_root_path)) { $music_root_path = $module_root_path . MUSIC_BOX_PATH . ''; } include_once($music_root_path . 'music_constants.'.$phpEx); // ********************************************************************** // Read language definition // ********************************************************************** if ( !file_exists( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main_music.' . $phpEx ) ) { include( $module_root_path . 'language/lang_english/lang_main_music.' . $phpEx ); $link_language='lang_english'; } else { include( $module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main_music.' . $phpEx ); $link_language='lang_' . $board_config['default_lang']; } // ********************************************************************** // Read theme definition and language in theme definition // ********************************************************************** if ( file_exists( $module_root_path . "templates/" . $theme['template_name'] . $theme['template_name'] . ".cfg" ) ) { // ---------- include($module_root_path . "templates/" . $theme['template_name'] . $theme['template_name'] . ".cfg"); // ---------- } else { // ---------- include($module_root_path . "templates/" . "subSilver/" . "subSilver.cfg"); // ---------- } // // Get music Config // $sql = "SELECT * FROM ". MUSIC_CONFIG_TABLE; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Could not query music config information", "", __LINE__, __FILE__, $sql); } while( $row = $db->sql_fetchrow($result) ) { $music_config_name = $row['config_name']; $music_config_value = $row['config_value']; $music_config[$music_config_name] = $music_config_value; } include($music_root_path . 'music_functions.' . $phpEx); include($music_root_path . 'music_integration.' . $phpEx); // // Set Music Version // $module_name = 'Music Center'; $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) ) { $music_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; $music_module_copyright .= 'Media Center Powered by: <a href="http://pubory.uv.ro/" target="_blank">OryNider</a>, mxBB <i> - ' . $music_module_name . '</i> ' . $music_module_version . ' © 2007 is modified by <a href="http://www.mx-system.com/">MX-Team</a><br />'; $music_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> - <i>Music Online</i> v2' . $music_config['music_version'] . ']'; $music_module_copyright .= '</div>'; } else { $music_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; $music_module_copyright .= 'Media Center Powered by: <a href="http://pubory.uv.ro/" target="_blank">OryNider</a>, mxBB <i> - Music Center</i> v2.0.x © 2007 is modified by <a href="http://www.mx-system.com/">MX-Team</a><br />'; $music_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> - <i>Music Online</i> v2' . $music_config['music_version'] . ']'; $music_module_copyright .= '</div>'; } $template->assign_vars(array( 'NAV_SEP' => $lang['Nav_Separator'], 'NAV_DOT' => '•', 'MUSIC_VERSION' => '2' . $music_config['music_version'], 'MUSIC_COPYRIGHT' => $music_module_copyright, 'L_INDEX' => '<<', 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'L_MUSIC_INDEX' => $lang['Music'], 'L_MUSIC' => $lang['Music'], 'U_MUSIC' => append_sid(this_mo_mxurl()), 'L_SEARCH' => $lang['Search'], 'U_MX_MUSIC' => append_sid(this_mo_portalurl()) ) ); ?> --- NEW FILE: music_functions.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_functions.php,v 1.1 2007/06/06 20:33:05 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // ------------------------------------ // All common functions are here! // ------------------------------------ // You cannot call this file directly from your browser // if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } // ---------------------------------------------------------------------------- // This function will return the access data of the current user for a category // Default returning value is "0" (means NOT AUTHORISED) // // All $*_check must be "1" or "0" // // $passed_auth must be a full row from MUSIC_CAT_TABLE. This function still works without // ... but $passed_auth will make it worked very much faster (because this function is often // called in a loop) // function music_user_access($cat_id, $passed_auth = 0, $view_check, $upload_check, $rate_check, $comment_check, $edit_check, $delete_check) { global $db, $music_config, $userdata; // -------------------------------- // Force to check moderator status // -------------------------------- $moderator_check = 1; // -------------------------------- // Here the array which this function would return. Now we initiate it! // -------------------------------- $music_user_access = array( 'view' => 0, 'upload' => 0, 'rate' => 0, 'comment' => 0, 'edit' => 0, 'delete' => 0, 'moderator' => 0 ); $music_user_access_keys = array_keys($music_user_access); // // END initiation $music_user_access // // -------------------------------- // Check $cat_id // -------------------------------- if ($cat_id < 0) { message_die(GENERAL_ERROR, 'Bad cat_id arguments for function music_user_access()'); } // // END check $cat_id // // -------------------------------- // If the current user is an ADMIN (MUSIC_ADMIN == ADMIN) // -------------------------------- if ($userdata['user_level'] == ADMIN) { for ($i = 0; $i < count($music_user_access); $i++) { $music_user_access[$music_user_access_keys[$i]] = 1; // Authorised All } // // Function EXIT here // return $music_user_access; } // // END check ADMIN // // -------------------------------- // if this is a GUEST, we will ignore some checking // -------------------------------- if (!$userdata['session_logged_in']) { $edit_check = 0; $delete_check = 0; $moderator_check = 0; } // // END check GUEST // // -------------------------------- // check if RATE or COMMENT are turned off by music Config, so we can ignore them // -------------------------------- if ($music_config['rate'] == 0) { $rate_check = 0; } if ($music_config['comment'] == 0) { $comment_check = 0; } // // END Check RATE & COMMENT // // -------------------------------- // The array that list all access type this function will look for (except MODERATOR) // -------------------------------- $access_type = array(); if ($view_check != 0) { $access_type[] = 'view'; } if ($upload_check != 0) { $access_type[] = 'upload'; } if ($rate_check != 0) { $access_type[] = 'rate'; } if ($comment_check != 0) { $access_type[] = 'comment'; } if ($edit_check != 0) { $access_type[] = 'edit'; } if ($delete_check != 0) { $access_type[] = 'delete'; } // // END generating array $access_type // // -------------------------------- // If everything is empty // -------------------------------- if( empty($access_type) and (!$moderator_check) ) { // // Function EXIT here // return $music_user_access; } // // END check empty // // -------------------------------- // Generate the SQL query based on $access_type and $moderator_check // -------------------------------- $sql = 'SELECT cat_id'; for ($i = 0; $i < count($access_type); $i++) { $sql .= ', cat_'. $access_type[$i] .'_level, cat_'. $access_type[$i] .'_groups'; } if ($moderator_check) { $sql .= ', cat_moderator_groups'; } $sql .= " FROM ". MUSIC_CAT_TABLE ." WHERE cat_id = '$cat_id'"; // // END SQL query generating // // -------------------------------- // Query the $sql then Fetchrow if $passed_auth == 0 // -------------------------------- if( !is_array($passed_auth) ) { if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not query music Category information' ,'' , __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); } else { $thiscat = $passed_auth; } // // END Query and Fetchrow // // -------------------------------- // Maybe the access level is not PRIVATE or the groups list is empty // ... so we can skip some queries ;) // -------------------------------- $groups_access = array(); for ($i = 0; $i < count($access_type); $i++) { switch ($thiscat['cat_'. $access_type[$i] .'_level']) { case MUSIC_GUEST: $music_user_access[$access_type[$i]] = 1; break; case MUSIC_USER: if ($userdata['session_logged_in']) { $music_user_access[$access_type[$i]] = 1; } break; case MUSIC_PRIVATE: if( ($thiscat['cat_'. $access_type[$i] .'_groups'] != '') and ($userdata['session_logged_in']) ) { $groups_access[] = $access_type[$i]; } break; case MUSIC_MOD: // this will be checked later break; case MUSIC_ADMIN: // ADMIN already returned before at the checking code // at the top of this function. So this user cannot be authorised $music_user_access[$access_type[$i]] = 0; break; default: $music_user_access[$access_type[$i]] = 0; } } // // END Check Access Level // // -------------------------------- // We can return now if $groups_access is empty AND $moderator_check == 0 // -------------------------------- if( ($moderator_check == 1) and ($thiscat['cat_moderator_groups'] != '') ) { // We can merge them now $groups_access[] = 'moderator'; } if (empty($groups_access)) { // // Function EXIT here // return $music_user_access; } // -------------------------------- // Now we have the list of usergroups have PRIVATE/MODERATOR access // So we will check if this user is in these usergroups or not... // -------------------------------- // upto (6 + 1) loops maximum when this user logged in and All Levels // are set to PRIVATE and this function was called to check all. // So avoiding PRIVATE will speed up your music. However, these queries are very fast for ($i = 0; $i < count($groups_access); $i++) { $sql = "SELECT group_id, user_id FROM ". USER_GROUP_TABLE ." WHERE user_id = '". $userdata['user_id'] ."' AND user_pending = 0 AND group_id IN (". $thiscat['cat_'. $groups_access[$i] .'_groups'] .")"; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not query User-Group information' ,'' , __LINE__, __FILE__, $sql); } if( $db->sql_numrows($result) > 0 ) { $music_user_access[$groups_access[$i]] = 1; } } // // END check PRIVATE/MODERATOR groups // // -------------------------------- // If $moderator_check was called and this user is a MODERATOR he // will be authorised for all accesses which were not set to ADMIN // -------------------------------- if( ($music_user_access['moderator'] == 1) and ($moderator_check == 1) ) { for ($i = 0; $i < count($music_user_access); $i++) { if( $thiscat['cat_'. $music_user_access_keys[$i] .'_level'] != MUSIC_ADMIN ) { $music_user_access[$music_user_access_keys[$i]] = 1; } } } // // END Moderator // // -------------------------------- // Return result... // -------------------------------- return $music_user_access; } // // END function music_user_access() // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // You must retain the full copyright notice below including the link to my site. // This not only gives respect to the large amount of time given freely // but also helps promoting my scripts. If you refuse to include this then // support by me may be affected. And Do NOT modify anything!!! function music_end() { global $music_config; echo '<div align="center" style="font-family: Verdana; font-size: 10px; letter-spacing: -1px">Powered by Music Online 2' . $music_config['music_version'] . ' © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a></div>'; } // // OR you can pay me for the copyright notice removal. Contact me! // ---------------------------------------------------------------------------- // +------------------------------------------------------+ // | Powered by Music Online 2.0 (c) 2003 Cf Manager | // +------------------------------------------------------+ ?> --- NEW FILE: index.html --- <html> <head> <title>Redirecting...</title> <script language="JavaScript"> self.location.href='http://cfmanager.net.tf'; </script> </head> <body> </body> </html> --- NEW FILE: music_integration.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_integration.php,v 1.1 2007/06/06 20:33:08 orynider Exp $ * @copyright (c) 2002-2006 [OryNider, ory...@rd...] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) ) { die( "Hacking attempt" ); } /* if( defined('music_CONFIG_TABLE') ) { $music_config = array(); $sql = "SELECT * FROM " . MUSIC_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) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $music_config[$row['config_name']] = $row['config_value']; } } } */ $music_index = $music_config['index']; $override_default_pages = $music_config['override_default_pages']; $integration_enabled = $music_config['enable_integration']; // MX add-on // Generate paths for page and standalone mode // ...function based on original function written by Markus :-) function this_mo_mxurl($args = '', $force_standalone_mode = false) { global $mx_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; if( $force_standalone_mode || !$is_block ) { $mxurl = $mx_root_path . 'modules/mx_music/' . 'music.' . $phpEx . ($args == '' ? '' : '?' . $args); } else { $mxurl = $mx_root_path . 'index.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= '?page=' . $page_id . ($args == '' ? '' : '&' . $args); } else { $mxurl .= '?page=' . $music_index . ($args == '' ? '' : '&' . $args); } } return $mxurl; } function this_mo_portalurl($args = '') { global $mx_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; if( $integration_enabled != "1" ) { $mxurl = $mx_root_path . 'modules/mx_music/' . 'music.' . $phpEx . ($args == '' ? '' : '?' . $args); } else { $mxurl = $mx_root_path . 'index.' . $phpEx . '?page=' . $music_index . ($args == '' ? '' : '&' . $args); } return $mxurl; } function this_mo_loginurl($args = '', $force_standalone_mode = false) { global $mx_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; $mxurl = $mx_root_path . 'index.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $page_id; } else { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $music_index; } return $mxurl; } // -------------------------------------------------------------------------------- // That's all Folks! // -------------------------------------------------------------------------------- ?> --- NEW FILE: music_constants.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_constants.php,v 1.1 2007/06/06 20:33:04 orynider Exp $ * @copyright (c) 2003 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined('IN_PORTAL') ) { die('Hacking attempt'); } define('PAGE_MUSIC', -19); // for Session Handling // User Levels for Music system <- do NOT change these values define('MUSIC_ANONYMOUS', -1); define('MUSIC_GUEST', -1); define('MUSIC_USER', 0); define('MUSIC_ADMIN', 1); define('MUSIC_MOD', 2); define('MUSIC_PRIVATE', 3); // Path (trailing slash required) define('MUSIC_UPLOAD_PATH', $module_root_path . 'upload/'); // Table names !defined('MUSIC_TABLE') ? define('MUSIC_TABLE', $mx_table_prefix.'music') : false; !defined('MUSIC_CAT_TABLE') ? define('MUSIC_CAT_TABLE', $mx_table_prefix.'music_cat') : false; !defined('MUSIC_CONFIG_TABLE') ? define('MUSIC_CONFIG_TABLE', $mx_table_prefix.'music_config') : false; !defined('MUSIC_COMMENT_TABLE') ? define('MUSIC_COMMENT_TABLE', $mx_table_prefix.'music_comment') : false; !defined('MUSIC_RATE_TABLE') ? define('MUSIC_RATE_TABLE', $mx_table_prefix.'music_rate') : false; ?> |