|
From: OryNider <ory...@us...> - 2008-01-16 19:53:17
|
Update of /cvsroot/mxbb/mx_music/music_box/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18200/includes Added Files: Tag: core28x index.htm music_constants.php music_functions.php music_integration.php Log Message: --- NEW FILE: music_functions.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_functions.php,v 1.1.2.1 2008/01/16 19:53:10 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.htm --- <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> --- NEW FILE: music_integration.php --- <?php /** * * @package mxBB Portal Module - mx_music * @version $Id: music_integration.php,v 1.1.2.1 2008/01/16 19:53:11 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, $phpbb_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; if( $force_standalone_mode || !$is_block ) { $mxurl = ( !MXBB_MODULE ) ? $phpbb_root_path . 'music.' . $phpEx . ($args == '' ? '' : '?' . $args) : $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 = '', $force_standalone_mode = false) { global $mx_root_path, $phpbb_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; if( $force_standalone_mode || !$integration_enabled ) { $mxurl = ( !MXBB_MODULE ) ? $phpbb_root_path . 'music.' . $phpEx . ($args == '' ? '' : '?' . $args) : $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 = '') { global $mx_root_path, $module_root_path, $page_id, $music_index, $phpEx, $integration_enabled, $is_block; $mxurl = ( !MXBB_MODULE ) ? $phpbb_root_path . 'music.' . $phpEx : $mx_root_path . 'modules/mx_music/' . 'music.' . $phpEx; if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $page_id; } else { $mxurl .= ($args == '' ? '' : '&' . $args) . '&page=' . $music_index; } return $mxurl; } function this_mo_rssurl($args = '', $force_standalone_mode = false) { global $music_index, $phpEx; if( $force_standalone_mode ) { $mxurl = ( !MXBB_MODULE ) ? 'music.' . $phpEx . ($args == '' ? '' : '?' . $args) : 'modules/mx_music/' . 'music.' . $phpEx . ($args == '' ? '' : '?' . $args); } else { $mxurl = ( !MXBB_MODULE ) ? 'music.' . $phpEx . ($args == '' ? '' : '?' . $args) : 'music.' . $phpEx . ($args == '' ? '' : '?' . $args); } 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.2.1 2008/01/16 19:53:10 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'); } if ( !MXBB_MODULE ) { $server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://'; $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name'])); $server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : ''; $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path'])); $script_name = ($script_name == '') ? $script_name : '/' . $script_name; define( 'PORTAL_URL', $server_protocol . $server_name . $server_port . $script_name . '/' ); define( 'PHPBB_URL', PORTAL_URL ); $mx_table_prefix = $table_prefix; $is_block = false; // This also makes the script work for phpBB ;) } 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); if ( !MXBB_MODULE ) { // Path (trailing slash required) define('MUSIC_UPLOAD_PATH', $module_root_path . 'music_box/upload/'); define('MUSIC_IMAGE_PATH', $module_root_path . 'muisc_box/upload/song_image/'); } else { // Path (trailing slash required) define('MUSIC_UPLOAD_PATH', $module_root_path . 'upload/'); define('MUSIC_IMAGE_PATH', $module_root_path . 'upload/song_image/'); } // 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; ?> |