|
From: FlorinCB <ory...@us...> - 2008-09-07 18:11:11
|
Update of /cvsroot/mxbb/mx_music/music_box/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9110/music_box/includes Modified Files: music_functions.php music_integration.php Log Message: upgrade not ready yet Index: music_functions.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/music_box/includes/music_functions.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** music_functions.php 29 Jan 2008 07:51:05 -0000 1.2 --- music_functions.php 7 Sep 2008 18:06:29 -0000 1.3 *************** *** 20,24 **** --- 20,353 ---- } + function music_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 music_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 music_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 music_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 music_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 music_get_profile_url($mode, $user_id, $username = false, $user_color = false) + { + global $lang, $userdata; + + switch (PORTAL_BACKEND) + { + case 'internal': + + $music_userdata = music_get_userdata($user_id, false); + $username = ($username) ? $username : $music_userdata['username']; + + if ($music_userdata['user_level'] == ADMIN) + { + $user_color = $theme['fontcolor3']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else if ($music_userdata['user_level'] == MOD) + { + $user_color = $theme['fontcolor2']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else + { + $user_colour = $theme['fontcolor1']; + $topic_poster_style = 'style="font-weight : bold;"'; + } + + $profile_url = ''; + + $full_url = ($user_id == ANONYMOUS) ? '<span ' . $topic_poster_style . '>' . $lang['Guest'] . '</span>' : '<span ' . $topic_poster_style . '>' . $username . '</span>'; + + break; + + case 'phpbb2': + + $music_userdata = music_get_userdata($user_id, false); + + $username = ($username) ? $username : $music_userdata['username']; + + if ($music_userdata['user_level'] == ADMIN) + { + $user_color = $theme['fontcolor3']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else if ($music_userdata['user_level'] == MOD) + { + $user_color = $theme['fontcolor2']; + $user_style = 'style="color:#' . $user_color . '; font-weight : bold;"'; + } + else + { + $user_colour = $theme['fontcolor1']; + $topic_poster_style = 'style="font-weight : bold;"'; + } + + // Only show the link if not anonymous + if ($user_id && $user_id != ANONYMOUS) + { + $profile_url = mx3_append_sid(PHPBB_URL . "profile.$phpEx", 'mode=viewprofile&u=' . (int) $user_id); + $full_url = '<a href="' . $profile_url . '"><span ' . $topic_poster_style . '>' . $username . '</span></a>'; + } + else + { + $profile_url = $lang['Guest']; + $full_url = $lang['Guest']; + } + + + break; + + case 'phpbb3': + + if (($username == false) || ($user_color == false)) + { + $music_userdata = music_get_userdata($user_id, false); + $user_id = $music_userdata['user_id']; + $username = $music_userdata['username']; + $user_colour = $music_userdata['user_colour']; + } + $full_url = music_get_username_string('full', $user_id, $username, $user_colour); + $profile_url = music_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; + } + } + + function music_comment_sql_smilies($auth_data) + { + global $db, $template, $board_config; + + $inline_columns = 6; + $max_smilies = 42; + + switch (PORTAL_BACKEND) + { + case 'internal': + $smiley_path_url = PHPBB_URL; //change this to PORTAL_URL when shared folder will be removed + $fields = 'smilies'; + $smiley_url = 'smile_url'; + $emotion = 'emoticon'; + $table = SMILIES_TABLE; + break; + case 'phpbb2': + $smiley_path_url = PHPBB_URL; + $fields = 'smilies'; + $smiley_url = 'smile_url'; + $emotion = 'emoticon'; + $table = SMILIES_TABLE; + break; + case 'phpbb3': + $smiley_path_url = PHPBB_URL; + $fields = 'smiley'; + $smiley_url = 'smiley_url'; + $emotion = 'emotion'; + $table = SMILIES_TABLE; + $board_config['smilies_path'] = str_replace("smiles", "smilies", $board_config['smilies_path']); + break; + } + + switch (PORTAL_BACKEND) + { + case 'internal': + case 'phpbb2': + $sql = 'SELECT * + FROM ' . $table . ' + GROUP BY ' . $smiley_url . ' + ORDER BY smilies_id'; + break; + + case 'phpbb3': + $sql = 'SELECT * + FROM ' . $table . ' + GROUP BY code + ORDER BY smiley_order'; + break; + } + + if (!$result = $db->sql_query_limit($sql, $max_smilies)) + { + mx_message_die(GENERAL_ERROR, "Couldn't retrieve smilies list", '', __LINE__, __FILE__, $sql); + } + $smilies_count = $db->sql_numrows($result); + $smilies_data = $db->sql_fetchrowset($result); + + if ($auth_data == true) + { + for ($i = 1; $i < $smilies_count + 1; $i++) + { + $template->assign_block_vars('switch_comment_post.smilies', array( + 'CODE' => $smilies_data[$i - 1]['code'], + 'URL' => $smiley_path_url . $board_config['smilies_path'] . '/' . $smilies_data[$i - 1][$smiley_url], + 'DESC' => $smilies_data[$i - 1][$emotion] + )); + if ( is_integer($i / $inline_columns) ) + { + $template->assign_block_vars('switch_comment_post.smilies.new_col', array()); + } + } + } + + } Index: music_integration.php =================================================================== RCS file: /cvsroot/mxbb/mx_music/music_box/includes/music_integration.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** music_integration.php 4 Sep 2008 20:55:33 -0000 1.3 --- music_integration.php 7 Sep 2008 18:06:29 -0000 1.4 *************** *** 49,53 **** function this_mo_mxurl($args = '', $force_standalone_mode = false, $new_pageid = '') { ! global $mx_root_path, $phpbb_root_path, $module_root_path, $mx_request_vars; global $music_index, $phpEx, $integration_enabled, $is_block, $mx_mod_rewrite; --- 49,53 ---- function this_mo_mxurl($args = '', $force_standalone_mode = false, $new_pageid = '') { ! global $mx_root_path, $phpbb_root_path, $module_root_path, $mx_request_vars, $page_id; global $music_index, $phpEx, $integration_enabled, $is_block, $mx_mod_rewrite; *************** *** 64,68 **** } ! $pageid = ($new_pageid) ? intval($new_pageid) : $mx_request_vars->request('page', MX_TYPE_INT, 1); $args .= ($args == '' ? '' : '&' ) . 'modrewrite=no'; --- 64,68 ---- } ! $pageid = ($new_pageid) ? intval($new_pageid) : ($page_id && is_numeric($page_id)) ? intval($page_id) : $mx_request_vars->request('page', MX_TYPE_INT, $music_index); $args .= ($args == '' ? '' : '&' ) . 'modrewrite=no'; *************** *** 78,82 **** { $mxurl = $mx_root_path . 'index.' . $phpEx; ! if( is_numeric($page_id) && !empty($page_id) ) { $mxurl .= '?page=' . $pageid . $dynamicId. ($args == '' ? '' : '&' . $args); --- 78,82 ---- { $mxurl = $mx_root_path . 'index.' . $phpEx; ! if( is_numeric($pageid) && !empty($pageid) ) { $mxurl .= '?page=' . $pageid . $dynamicId. ($args == '' ? '' : '&' . $args); |