|
From: FlorinCB <ory...@us...> - 2009-01-22 08:30:27
|
Update of /cvsroot/mxbb/mx_radiocast/radiocast_mod In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv7371/radiocast_mod Modified Files: radiocast_common.php radiocast_constants.php radiocast_functions.php Log Message: fixes for 3.0.x Index: radiocast_functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_radiocast/radiocast_mod/radiocast_functions.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** radiocast_functions.php 6 Jun 2007 23:03:59 -0000 1.1 --- radiocast_functions.php 22 Jan 2009 08:29:51 -0000 1.2 *************** *** 20,26 **** } - - - // ---------------------------------------------------------------------------- // This function will return the access data of the current user for a category --- 20,23 ---- *************** *** 60,64 **** // - // -------------------------------- // Check $cat_id --- 57,60 ---- *************** *** 66,70 **** if ($cat_id < 0) { ! mx_message_die(GENERAL_ERROR, 'Bad cat_id arguments for function radiocast_user_access()'); } // --- 62,66 ---- if ($cat_id < 0) { ! mx_message_die(GENERAL_ERROR, "Bad cat_id arguments for function radiocast_user_access()", "", __LINE__, __FILE__, $sql); } // *************** *** 108,112 **** // -------------------------------- ! // check if RATE or COMMENT are turned off by music Config, so we can ignore them // -------------------------------- if ($radiocast_config['rate'] == 0) --- 104,108 ---- // -------------------------------- ! // check if RATE or COMMENT are turned off by radio Config, so we can ignore them // -------------------------------- if ($radiocast_config['rate'] == 0) *************** *** 207,211 **** if( !$result = $db->sql_query($sql) ) { ! message_die(GENERAL_ERROR, 'Could not query music Category information' ,'' , __LINE__, __FILE__, $sql); } --- 203,207 ---- if( !$result = $db->sql_query($sql) ) { ! mx_message_die(GENERAL_ERROR, 'Could not query radio Category information' ,'' , __LINE__, __FILE__, $sql); } *************** *** 291,295 **** // 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++) { --- 287,291 ---- // 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 radio. However, these queries are very fast for ($i = 0; $i < count($groups_access); $i++) { *************** *** 352,355 **** --- 348,615 ---- // ---------------------------------------------------------------------------- + // ------------------------------------ + // All common functions are here! + // ------------------------------------ + // You cannot call this file directly from your browser + // + if ( !defined('IN_PORTAL') ) + { + die('Hacking attempt'); + } + + function radiocast_encode_ip($dotquad_ip) + { + $ip_sep = @explode('.', $dotquad_ip); + return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]); + } + + function radiocast_decode_ip($int_ip) + { + $hexipbang = @explode('.', chunk_split($int_ip, 2, '.')); + return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); + } + + // + // Create date/time from format and timezone + // + function radiocast_create_date($format = false, $gmepoch, $tz, $forcedate = false) + { + global $board_config, $lang, $mx_user; + static $translate; + + switch (PORTAL_BACKEND) + { + case 'internal': + + case 'phpbb2': + + if (empty($translate) && ($mx_user->lang['default_lang'] != 'english')) + { + @reset($lang['datetime']); + while ( list($match, $replace) = @each($lang['datetime']) ) + { + $translate[$match] = $replace; + } + } + + return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz)); + + break; + + case 'phpbb3': + + return $mx_user->format_date($gmepoch, $format, $forcedate); + + break; + } + } + + /** + * Get userdata + * + * Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced. + * Cached sql, since this function is used for every block. + * + * @param unknown_type $user id or name + * @param boolean $force_str force clean_username + * @return array + */ + function radiocast_get_userdata($user, $force_str = false) + { + global $db; + + if (!is_numeric($user) || $force_str) + { + $user = phpBB2::phpbb_clean_username($user); + } + else + { + $user = intval($user); + } + + $sql = "SELECT * + FROM " . USERS_TABLE . " + WHERE "; + $sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" . str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS; + if ( !($result = $db->sql_query($sql, 120)) ) + { + mx_message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql); + } + + $return = ($row = $db->sql_fetchrow($result)) ? $row : false; + $db->sql_freeresult($result); + return $return; + } + + function radiocast_get_username_string($mode, $user_id, $username, $username_colour = '') + { + global $phpbb_root_path, $phpEx, $mx_user, $phpbb_auth; + + $profile_url = ''; + $username_colour = ($username_colour) ? '#' . $username_colour : ''; + + if ($guest_username === false) + { + $username = ($username) ? $username : $mx_user->lang['GUEST']; + } + else + { + $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $mx_user->lang['GUEST']); + } + + // Only show the link if not anonymous + if ($user_id && $user_id != ANONYMOUS) + { + $profile_url = mx3_append_sid(PHPBB_URL . "memberlist.$phpEx", 'mode=viewprofile&u=' . (int) $user_id); + } + else + { + $profile_url = ''; + } + + switch ($mode) + { + case 'profile': + return $profile_url; + break; + + case 'username': + return $username; + break; + + case 'colour': + return $username_colour; + break; + + case 'full': + default: + + $tpl = ''; + if (!$profile_url && !$username_colour) + { + $tpl = '{USERNAME}'; + } + else if (!$profile_url && $username_colour) + { + $tpl = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>'; + } + else if ($profile_url && !$username_colour) + { + $tpl = '<a href="{PROFILE_URL}">{USERNAME}</a>'; + } + else if ($profile_url && $username_colour) + { + $tpl = '<a href="{PROFILE_URL}" style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</a>'; + } + + return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); + break; + } + } + + function radiocast_get_profile_url($mode, $user_id, $username = false, $user_color = false) + { + global $lang, $userdata, $phpEx, $theme; + + switch (PORTAL_BACKEND) + { + case 'internal': + + $radiocast_userdata = radiocast_get_userdata($user_id, false); + $username = ($username) ? $username : $radiocast_userdata['username']; + + if ($radiocast_userdata['user_level'] == ADMIN) + { + $user_color = $theme['fontcolor3']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else if ($radiocast_userdata['user_level'] == MOD) + { + $user_color = $theme['fontcolor2']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else + { + $user_colour = $theme['fontcolor1']; + $user_style = 'style="font-weight : bold;"'; + } + + $profile_url = ''; + + $full_url = (($user_id == ANONYMOUS) || ($user_id == radiocast_GUEST)) ? '<span ' . $user_style . '>' . $lang['Guest'] . '</span>' : '<span ' . $topic_poster_style . '>' . $username . '</span>'; + + break; + + case 'phpbb2': + + $radiocast_userdata = radiocast_get_userdata($user_id, false); + + $username = ($username) ? $username : $radiocast_userdata['username']; + + if ($radiocast_userdata['user_level'] == ADMIN) + { + $user_color = $theme['fontcolor3']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else if ($radiocast_userdata['user_level'] == MOD) + { + $user_color = $theme['fontcolor2']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else + { + $user_colour = $theme['fontcolor1']; + $user_style = 'style="font-weight : bold;"'; + } + + // Only show the link if not anonymous + if ($user_id && $user_id != ANONYMOUS) + { + $profile_url = mx_append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&u=" . (int) $user_id); + $full_url = '<a href="' . $profile_url . '"><span ' . $user_style. '>' . $username . '</span></a>'; + } + else + { + $profile_url = $lang['Guest']; + $full_url = $lang['Guest']; + } + + + break; + + case 'phpbb3': + + if (($username == false) || ($user_color == false)) + { + $radiocast_userdata = radiocast_get_userdata($user_id, false); + $user_id = $radiocast_userdata['user_id']; + $username = $radiocast_userdata['username']; + $user_colour = $radiocast_userdata['user_colour']; + } + $full_url = radiocast_get_username_string('full', $user_id, $username, $user_colour); + $profile_url = radiocast_get_username_string('profile', $user_id, $username, $user_colour); + break; + } + + switch ($mode) + { + case 'profile': + return $profile_url; + break; + + case 'username': + return $username; + break; + + case 'colour': + return $user_colour; + break; + + case 'full': + default: + return $full_url; + break; + } + } ?> \ No newline at end of file Index: radiocast_common.php =================================================================== RCS file: /cvsroot/mxbb/mx_radiocast/radiocast_mod/radiocast_common.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** radiocast_common.php 3 Jun 2008 20:13:37 -0000 1.5 --- radiocast_common.php 22 Jan 2009 08:29:51 -0000 1.6 *************** *** 16,29 **** define('IN_RADIOCAST', true); - if ( !defined('RADIOCAST_PATH') ) - { - define('RADIOCAST_PATH', 'radiocast_mod/'); - } - - if (!isset($radiocast_root_path) || empty($radiocast_root_path)) - { - $radiocast_root_path = $module_root_path . RADIOCAST_PATH . ''; - } - include($radiocast_root_path . 'radiocast_constants.'.$phpEx); --- 16,19 ---- *************** *** 71,75 **** { $radiocast_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; ! $radiocast_module_copyright .= 'mxBB <i> - ' . $radiocast_module_name . '</i> ' . $radiocast_module_version . ' © 2007 is powered by <a href="http://www.mxbb.net/">OryNider</a><br />'; $radiocast_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> & mxBB <i> - Music Center</i> v2.0.x © 2007, modified by <a href="http://www.mx-publisher.com/">MX-Team</a>]'; $radiocast_module_copyright .= '</div>'; --- 61,65 ---- { $radiocast_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; ! $radiocast_module_copyright .= 'mxBB <i> - ' . $radiocast_module_name . '</i> ' . $radiocast_module_version . ' © 2007 is powered by <a href="http://www.caleacrestina.com/">FlorinCB (OryNider)</a><br />'; $radiocast_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> & mxBB <i> - Music Center</i> v2.0.x © 2007, modified by <a href="http://www.mx-publisher.com/">MX-Team</a>]'; $radiocast_module_copyright .= '</div>'; *************** *** 78,82 **** { $radiocast_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; ! $radiocast_module_copyright .= 'mxBB <i> - Radio Cast</i> v1.0.x © 2007 is powered by <a href="http://www.mx-publisher.com/">OryNider</a><br />'; $radiocast_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> & mxBB <i> - Music Center</i> v2.0.x © 2007, modified by <a href="http://www.mx-publisher.com/">MX-Team</a>]'; $radiocast_module_copyright .= '</div>'; --- 68,72 ---- { $radiocast_module_copyright = '<div align="center" class="gensmall" style="font-family: Verdana, Arial, Helvetica, sans-serif; letter-spacing: -1px">'; ! $radiocast_module_copyright .= 'mxBB <i> - Radio Cast</i> v1.0.x © 2007 is powered by <a href="http://www.caleacrestina.com/">FlorinCB (OryNider)</a><br />'; $radiocast_module_copyright .= '[based on © 2003 <a href="http://cfmanager.net.tf" target="_blank">Cf Manager</a> & mxBB <i> - Music Center</i> v2.0.x © 2007, modified by <a href="http://www.mx-publisher.com/">MX-Team</a>]'; $radiocast_module_copyright .= '</div>'; *************** *** 90,99 **** 'RADIOCAST_COPYRIGHT' => $radiocast_module_copyright, 'L_INDEX' => '<<', ! 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'L_RADIOCAST_INDEX' => $lang['Radio_Cast'], 'L_MUSIC' => $lang['Radio'], ! 'U_MUSIC' => append_sid(this_rc_mxurl()), 'L_SEARCH' => $lang['Search'], ! 'U_MX_MUSIC' => append_sid(this_rc_portalurl()) ) ); --- 80,89 ---- 'RADIOCAST_COPYRIGHT' => $radiocast_module_copyright, 'L_INDEX' => '<<', ! 'U_INDEX' => mx_append_sid($mx_root_path . "index.".$phpEx), 'L_RADIOCAST_INDEX' => $lang['Radio_Cast'], 'L_MUSIC' => $lang['Radio'], ! 'U_MUSIC' => mx_append_sid(this_rc_mxurl()), 'L_SEARCH' => $lang['Search'], ! 'U_MX_MUSIC' => mx_append_sid(this_rc_portalurl()) ) ); Index: radiocast_constants.php =================================================================== RCS file: /cvsroot/mxbb/mx_radiocast/radiocast_mod/radiocast_constants.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** radiocast_constants.php 21 Mar 2008 08:51:09 -0000 1.2 --- radiocast_constants.php 22 Jan 2009 08:29:51 -0000 1.3 *************** *** 40,47 **** ! if (!$_GET['print']) // Do not "fix" with reuest wrapper!! ! { ! $mx_user->set_module_default_style('_core'); // For compatibility with core 2.8.x ! } // ------------------------------------------------------------------------- --- 40,44 ---- ! $mx_user->set_module_default_style('_core'); // For compatibility with core 2.8.x // ------------------------------------------------------------------------- |