Update of /cvsroot/mxbb/mx_radiocast/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1615/includes Added Files: index.html radiocast_add.php radiocast_cat.php radiocast_comment.php radiocast_comment_delete.php radiocast_comment_edit.php radiocast_delete.php radiocast_download.php radiocast_edit.php radiocast_list.php radiocast_modcp.php radiocast_player.php radiocast_rate.php radiocast_station.php radiocast_stream.php Log Message: --- NEW FILE: radiocast_comment.php --- <?php /** * * @package mxBB Portal Module - mx_radiocast * @version $Id: radiocast_comment.php,v 1.1 2007/06/06 23:03:49 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // MX if ( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // Let's include some stuff... // $phpEx = substr(strrchr(__FILE__, '.'), 1); if ( !defined('TEMPLATE_ROOT_PATH') ) { include_once($mx_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_validate.'.$phpEx); // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); // // End session management // } $radiocast_root_path = $module_root_path . 'radiocast_mod/'; // // Get general radiocast information // include_once($radiocast_root_path . 'radiocast_common.'.$phpEx); // ------------------------------------ // Check feature enabled // ------------------------------------ if( $radiocast_config['comment'] == 0 ) { mx_message_die(GENERAL_MESSAGE, $lang['Not_Authorised']); } // ------------------------------------ // Check the request // ------------------------------------ if( isset($HTTP_GET_VARS['station_id']) ) { $station_id = intval($HTTP_GET_VARS['station_id']); } else if( isset($HTTP_POST_VARS['station_id']) ) { $station_id = intval($HTTP_POST_VARS['station_id']); } else { if( isset($HTTP_GET_VARS['comment_id']) ) { $comment_id = intval($HTTP_GET_VARS['comment_id']); } else if( isset($HTTP_POST_VARS['comment_id']) ) { $comment_id = intval($HTTP_POST_VARS['comment_id']); } else { mx_message_die(GENERAL_ERROR, 'Bad request'); } } // ------------------------------------ // Get $station_id from $comment_id // ------------------------------------ if( isset($comment_id) ) { $sql = "SELECT comment_id, comment_station_id FROM ". RADIOCAST_COMMENT_TABLE ." WHERE comment_id = '$comment_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query comment and station information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( empty($row) ) { mx_message_die(GENERAL_ERROR, 'This comment does not exist'); } $station_id = $row['comment_station_id']; } // ------------------------------------ // Get this station info // ------------------------------------ $sql = "SELECT s.*, u.user_id, u.username, COUNT(c.comment_id) as comments_count FROM ". RADIOCAST_TABLE ." AS s LEFT JOIN ". USERS_TABLE ." AS u ON s.station_user_id = u.user_id LEFT JOIN ". RADIOCAST_COMMENT_TABLE ." AS c ON s.station_id = c.comment_station_id WHERE station_id = '$station_id' GROUP BY s.station_id LIMIT 1"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query station information', '', __LINE__, __FILE__, $sql); } $thisstation = $db->sql_fetchrow($result); $cat_id = $thisstation['station_cat_id']; $user_id = $thisstation['station_user_id']; $total_comments = $thisstation['comments_count']; $comments_per_page = $board_config['posts_per_page']; if( empty($thisstation) ) { mx_message_die(GENERAL_ERROR, $lang['Song_not_exist'] . ' -> ' . $station_id); } // ------------------------------------ // Get the current Category Info // ------------------------------------ $sql = "SELECT * FROM ". RADIOCAST_CAT_TABLE ." WHERE cat_id = '$cat_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query category information', '', __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); if (empty($thiscat)) { mx_message_die(GENERAL_ERROR, $lang['Category_not_exist']); } // ------------------------------------ // Check the permissions // ------------------------------------ $auth_data = radiocast_user_access($cat_id, $thiscat, 1, 0, 0, 1, 1, 1); if ($auth_data['view'] == 0) { if (!$userdata['session_logged_in']) { mx_redirect(append_sid($mx_root_path . "login.php?redirect=" . this_rc_loginurl("radiocast_mode=radiocast_comment&station_id=$station_id"), true)); exit; } else { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } /* +---------------------------------------------------------- | Main work here... +---------------------------------------------------------- */ if( !isset($HTTP_POST_VARS['comment']) ) { /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Comments Screen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ // ------------------------------------ // Get the comments thread // Beware: when this script was called with comment_id (without start) // ------------------------------------ if( !isset($comment_id) ) { if( isset($HTTP_GET_VARS['start']) ) { $start = intval($HTTP_GET_VARS['start']); } else if( isset($HTTP_POST_VARS['start']) ) { $start = intval($HTTP_POST_VARS['start']); } else { $start = 0; } } else { // We must do a query to co-ordinate this comment $sql = "SELECT COUNT(comment_id) AS count FROM ". RADIOCAST_COMMENT_TABLE ." WHERE comment_station_id = $station_id AND comment_id < $comment_id"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain comments information from the database', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( !empty($row) ) { $start = floor( $row['count'] / $comments_per_page ) * $comments_per_page; } else { $start = 0; } } if( isset($HTTP_GET_VARS['sort_order']) ) { switch ($HTTP_GET_VARS['sort_order']) { case 'ASC': $sort_order = 'ASC'; break; default: $sort_order = 'DESC'; } } else if( isset($HTTP_POST_VARS['sort_order']) ) { switch ($HTTP_POST_VARS['sort_order']) { case 'ASC': $sort_order = 'ASC'; break; default: $sort_order = 'DESC'; } } else { $sort_order = 'ASC'; } if ($total_comments > 0) { $limit_sql = ($start == 0) ? $comments_per_page : $start .','. $comments_per_page; $sql = "SELECT c.*, u.user_id, u.username FROM ". RADIOCAST_COMMENT_TABLE ." AS c LEFT JOIN ". USERS_TABLE ." AS u ON c.comment_user_id = u.user_id WHERE c.comment_station_id = '$station_id' ORDER BY c.comment_id $sort_order LIMIT $limit_sql"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain comments information from the database', '', __LINE__, __FILE__, $sql); } $commentrow = array(); while( $row = $db->sql_fetchrow($result) ) { $commentrow[] = $row; } for ($i = 0; $i < count($commentrow); $i++) { if( ($commentrow[$i]['user_id'] == RADIOCAST_GUEST) or ($commentrow[$i]['username'] == '') ) { $poster = ($commentrow[$i]['comment_username'] == '') ? $lang['Guest'] : $commentrow[$i]['comment_username']; } else { $poster = '<a href="'. append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $commentrow[$i]['user_id']) .'">'. $commentrow[$i]['username'] .'</a>'; } if ($commentrow[$i]['comment_edit_count'] > 0) { $sql = "SELECT c.comment_id, c.comment_edit_user_id, u.user_id, u.username FROM ". RADIOCAST_COMMENT_TABLE ." AS c LEFT JOIN ". USERS_TABLE ." AS u ON c.comment_edit_user_id = u.user_id WHERE c.comment_id = '".$commentrow[$i]['comment_id']."' LIMIT 1"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain last edit information from the database', '', __LINE__, __FILE__, $sql); } $lastedit_row = $db->sql_fetchrow($result); $edit_info = ($commentrow[$i]['comment_edit_count'] == 1) ? $lang['Edited_time_total'] : $lang['Edited_times_total']; $edit_info = '<br /><br />» '. sprintf($edit_info, $lastedit_row['username'], create_date($board_config['default_dateformat'], $commentrow[$i]['comment_edit_time'], $board_config['board_timezone']), $commentrow[$i]['comment_edit_count']) .'<br />'; } else { $edit_info = ''; } $template->assign_block_vars('commentrow', array( 'ID' => $commentrow[$i]['comment_id'], 'POSTER' => $poster, 'TIME' => create_date($board_config['default_dateformat'], $commentrow[$i]['comment_time'], $board_config['board_timezone']), 'IP' => ($userdata['user_level'] == ADMIN) ? '-----------------------------------<br />' . $lang['IP_Address'] . ': <a href="http://www.nic.com/cgi-bin/whois.cgi?query=' . decode_ip($commentrow[$i]['comment_user_ip']) . '" target="_blank">' . decode_ip($commentrow[$i]['comment_user_ip']) .'</a><br />' : '', 'TEXT' => nl2br($commentrow[$i]['comment_text']), 'EDIT_INFO' => $edit_info, 'EDIT' => ( ( $auth_data['edit'] and ($commentrow[$i]['comment_user_id'] == $userdata['user_id']) ) or ($auth_data['moderator'] and ($thiscat['cat_edit_level'] != RADIOCAST_ADMIN) ) or ($userdata['user_level'] == ADMIN) ) ? '<a href="'. append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment_edit&comment_id=". $commentrow[$i]['comment_id'])) .'">'. $lang['Edit_station'] .'</a>' : '', 'DELETE' => ( ( $auth_data['delete'] and ($commentrow[$i]['comment_user_id'] == $userdata['user_id']) ) or ($auth_data['moderator'] and ($thiscat['cat_delete_level'] != RADIOCAST_ADMIN) ) or ($userdata['user_level'] == ADMIN) ) ? '<a href="'. append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment_delete&comment_id=". $commentrow[$i]['comment_id'])) .'">'. $lang['Delete_station'] .'</a>' : '' ) ); } $template->assign_block_vars('switch_comment', array()); $template->assign_vars(array( 'PAGINATION' => generate_pagination(append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment&station_id=$station_id&sort_order=$sort_order")), $total_comments, $comments_per_page, $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $comments_per_page ) + 1 ), ceil( $total_comments / $comments_per_page )) ) ); } // // Start output of page // $page_title = $lang['Radio']; if ( !$is_block ) { include($mx_root_path . 'includes/page_header.'.$phpEx); } $template->set_filenames(array( 'body' => 'radiocast_comment_body.tpl') ); if( ($thisstation['station_user_id'] == RADIOCAST_GUEST) or ($thisstation['username'] == '') ) { $poster = ($thisstation['station_username'] == '') ? $lang['Guest'] : $thisstation['station_username']; } else { $poster = '<a href="'. append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $thisstation['user_id']) .'">'. $thisstation['username'] .'</a>'; } //--------------------------------- // Comment Posting Form //--------------------------------- if ($auth_data['comment'] == 1) { $template->assign_block_vars('switch_comment_post', array()); if( !$userdata['session_logged_in'] ) { $template->assign_block_vars('switch_comment_post.logout', array()); } } $template->assign_vars(array( 'CAT_TITLE' => $thiscat['cat_title'], 'U_VIEW_CAT' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_cat&cat_id=$cat_id")), 'U_STATION' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_page&station_id=$station_id")), 'STATION_TITLE' => $thisstation['station_title'], 'SINGER' => nl2br($thisstation['station_singer']), 'POSTER' => $poster, 'STATION_TIME' => create_date($board_config['default_dateformat'], $thisstation['station_time'], $board_config['board_timezone']), 'STATION_VIEW' => $thisstation['station_view_count'], 'STATION_COMMENTS' => $total_comments, 'L_STATION_TITLE' => $lang['Song_Title'], 'L_SINGER' => $lang['Singer'], 'L_POSTER' => $lang['Poster'], 'L_POSTED' => $lang['Posted'], 'L_VIEW' => $lang['View'], 'L_COMMENTS' => $lang['Comments'], 'L_POST_YOUR_COMMENT' => $lang['Post_your_comment'], 'L_MESSAGE' => $lang['Message'], 'L_USERNAME' => $lang['Username'], 'L_COMMENT_NO_TEXT' => $lang['Comment_no_text'], 'L_COMMENT_TOO_LONG' => $lang['Comment_too_long'], 'L_MAX_LENGTH' => $lang['Max_length'], 'S_MAX_LENGTH' => $radiocast_config['desc_length'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_ASC' => $lang['Sort_Ascending'], 'L_DESC' => $lang['Sort_Descending'], 'SORT_ASC' => ($sort_order == 'ASC') ? 'selected="selected"' : '', 'SORT_DESC' => ($sort_order == 'DESC') ? 'selected="selected"' : '', 'L_SUBMIT' => $lang['Submit'], 'L_INDEX' => '<<', 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'L_RADIOCAST_INDEX' => $lang['Radio_Cast'], 'L_RADIOCAST' => $lang['Radio'], 'U_RADIOCAST' => append_sid(this_rc_mxurl()), 'U_MX_RADIOCAST' => append_sid(this_rc_portalurl()), 'S_RADIOCAST_ACTION' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment&station_id=$station_id")) ) ); // // Generate the page // $template->pparse('body'); if ( !$is_block ) { include($mx_root_path . 'includes/page_tail.'.$phpEx); } } else { /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Comment Submited ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ // ------------------------------------ // Check the permissions: COMMENT // ------------------------------------ if ($auth_data['comment'] == 0) { if (!$userdata['session_logged_in']) { mx_redirect(append_sid($mx_root_path . "login.php?redirect=" . this_rc_mxurl("radiocast_mode=radiocast_comment&station_id=$station_id"), true)); } else { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } $comment_text = str_replace("\'", "''", htmlspecialchars(substr(trim($HTTP_POST_VARS['comment']), 0, $radiocast_config['desc_length']))); $comment_username = (!$userdata['session_logged_in']) ? str_replace("\'", "''", substr(htmlspecialchars(trim($HTTP_POST_VARS['comment_username'])), 0, 32)) : str_replace("'", "''", htmlspecialchars(trim($userdata['username']))); if( empty($comment_text) ) { mx_message_die(GENERAL_ERROR, $lang['Comment_no_text']); } // -------------------------------- // Check station Locked // -------------------------------- if( ($thisstation['station_lock'] == 1) and (!$auth_data['moderator']) ) { mx_message_die(GENERAL_ERROR, $lang['Song_Locked']); } // -------------------------------- // Check username for guest posting // -------------------------------- if (!$userdata['session_logged_in']) { if ($comment_username != '') { $result = validate_username($comment_username); if ( $result['error'] ) { mx_message_die(GENERAL_MESSAGE, $result['error_msg']); } } } // -------------------------------- // Prepare variables // -------------------------------- $comment_time = time(); $comment_user_id = $userdata['user_id']; $comment_user_ip = $userdata['session_ip']; // -------------------------------- // Get $comment_id // -------------------------------- $sql = "SELECT MAX(comment_id) AS max FROM ". RADIOCAST_COMMENT_TABLE; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not found comment_id', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $comment_id = $row['max'] + 1; // -------------------------------- // Insert into DB // -------------------------------- $sql = "INSERT INTO ". RADIOCAST_COMMENT_TABLE ." (comment_id, comment_station_id, comment_user_id, comment_username, comment_user_ip, comment_time, comment_text) VALUES ('$comment_id', '$station_id', '$comment_user_id', '$comment_username', '$comment_user_ip', '$comment_time', '$comment_text')"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not insert new entry', '', __LINE__, __FILE__, $sql); } // -------------------------------- // Complete... now send a message to user // -------------------------------- $template->assign_vars(array( 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment&comment_id=$comment_id")) . '#'.$comment_id.'">') ); $message = $lang['Stored'] . "<br /><br />" . sprintf($lang['Click_view_message'], "<a href=\"" . append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment&comment_id=$comment_id")) . "#$comment_id\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_radiocast_index'], "<a href=\"" . append_sid(this_rc_mxurl()) . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); } ?> --- NEW FILE: radiocast_player.php --- <?php /** * * @package mxBB Portal Module - mx_radiocast * @version $Id: radiocast_player.php,v 1.1 2007/06/06 23:03:52 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ /*********************************************************************** * MODIFICATIONS * --------------- * started : Saturday, January 18, 2004 * copyright : © Cf Manager * web : http://cfmanager.net.tf * version : 2.0.5 * * Credits: * -modified for mx_radiocast by OryNider * ************************************************************************/ // MX if ( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // Let's include some stuff... // $phpEx = substr(strrchr(__FILE__, '.'), 1); if ( !defined('TEMPLATE_ROOT_PATH') ) { include_once($mx_root_path . 'common.' . $phpEx); // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); // // End session management // } $radiocast_root_path = $module_root_path . 'radiocast_mod/'; $station_image_path = RADIOCAST_IMAGE_UPLOAD_PATH; $station_image_default = $mx_images['no_image']; // The default image // // Get general radiocast information // include_once($radiocast_root_path . 'radiocast_common.'.$phpEx); // ------------------------------------ // Check the request // ------------------------------------ if( isset($HTTP_GET_VARS['station_id']) ) { $station_id = intval($HTTP_GET_VARS['station_id']); } else if( isset($HTTP_POST_VARS['station_id']) ) { $station_id = intval($HTTP_POST_VARS['station_id']); } else { mx_message_die(GENERAL_ERROR, 'No station_id set'); } if( isset($HTTP_GET_VARS['block_mode']) ) { if ($HTTP_GET_VARS['block_mode'] == 'true') { $block_mode = 'true'; } else { $block_mode = 'false'; } } else { $block_mode = 'false'; } if( isset($HTTP_GET_VARS['player_mode']) ) { if ($HTTP_GET_VARS['player_mode'] == 'media') { $player_mode = 'media'; } elseif ($HTTP_GET_VARS['player_mode'] == 'real') { $player_mode = 'real'; } } else { $player_mode = 'media'; } if( isset($HTTP_GET_VARS['stream_mode']) ) { if ($HTTP_GET_VARS['stream_mode'] == 'forced') { $stream_mode = 'forced'; } elseif ($HTTP_GET_VARS['stream_mode'] == 'direct') { $stream_mode = 'direct'; } } else { $stream_mode = 'direct'; } // ------------------------------------ // PREVIOUS & NEXT // ------------------------------------ if( isset($HTTP_GET_VARS['mode']) ) { if( ($HTTP_GET_VARS['mode'] == 'next') or ($HTTP_GET_VARS['mode'] == 'previous') ) { $sql = "SELECT station_id, station_cat_id, station_user_id FROM ". RADIOCAST_TABLE ." WHERE station_id = $station_id"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query station information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( empty($row) ) { mx_message_die(GENERAL_ERROR, 'Bad station_id'); } $sql = "SELECT new.station_id, new.station_time FROM ". RADIOCAST_TABLE ." AS new, ". RADIOCAST_TABLE ." AS cur WHERE cur.station_id = $station_id AND new.station_id <> cur.station_id AND new.station_cat_id = cur.station_cat_id"; $sql .= ($HTTP_GET_VARS['mode'] == 'next') ? " AND new.station_time >= cur.station_time" : " AND new.station_time <= cur.station_time"; $sql .= ($HTTP_GET_VARS['mode'] == 'next') ? " ORDER BY station_time ASC LIMIT 1" : " ORDER BY station_time DESC LIMIT 1"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query station information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); if( empty($row) ) { mx_message_die(GENERAL_ERROR, $lang['Station_not_exist']); } $station_id = $row['station_id']; // NEW station_id } } // ------------------------------------ // Get this station info // ------------------------------------ $sql = "SELECT s.*, u.user_id, u.username, r.rate_station_id, AVG(r.rate_point) AS rating, COUNT(DISTINCT c.comment_id) AS comments FROM ". RADIOCAST_TABLE ." AS s LEFT JOIN ". USERS_TABLE ." AS u ON s.station_user_id = u.user_id LEFT JOIN ". RADIOCAST_RATE_TABLE ." AS r ON s.station_id = r.rate_station_id LEFT JOIN ". RADIOCAST_COMMENT_TABLE ." AS c ON s.station_id = c.comment_station_id WHERE station_id = '$station_id' GROUP BY s.station_id"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query station information', '', __LINE__, __FILE__, $sql); } $thisstation = $db->sql_fetchrow($result); $cat_id = $thisstation['station_cat_id']; $user_id = $thisstation['station_user_id']; if( empty($thisstation['station_url']) && !file_exists(RADIOCAST_UPLOAD_PATH . $thisstation['station_filename']) ) { mx_message_die(GENERAL_ERROR, $lang['Station_not_exist']); } if ( $thisstation['station_imagename'] == '' ) { $img_id = $station_image_default; } else { $img_id = ( $station_image_path . $thisstation['station_imagename'] ); } function mx_radiocast_sitesufix($domain) { $domaintmp = explode(".", $domain); $y = count($domaintmp) - 1; $r = $domaintmp[$y];; return $r; } if ( $thisstation['station_url'] == '' ) { $station_filetype = substr($thisstation['station_filename'], strlen($thisstation['station_filename']) - 3, 3); $station_filename = ( !empty($thisstation['station_filename']) ? $thisstation['station_filename'] : '' ); } elseif ( substr($thisstation['station_url'], strlen($thisstation['station_url']) - 3, 3) == '' ) { $sitesufix = mx_radiocast_sitesufix($thisstation['station_url']); $station_filetype = '.' . $sitesufix; $station_url = $thisstation['station_url']; } else { $station_filetype = substr($thisstation['station_url'], strlen($thisstation['station_url']) - 3, 3); $station_url = $thisstation['station_url']; } // ------------------------------------ // Get the current Category Info // ------------------------------------ $sql = "SELECT * FROM ". RADIOCAST_CAT_TABLE ." WHERE cat_id = '$cat_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query category information', '', __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); if (empty($thiscat)) { mx_message_die(GENERAL_ERROR, $lang['Category_not_exist']); } // ------------------------------------ // Check the permissions // ------------------------------------ $radiocast_user_access = radiocast_user_access($cat_id, $thiscat, 1, 0, 0, 0, 0, 0); // UPLOAD if ($radiocast_user_access['view'] == 0) { if (!$userdata['session_logged_in']) { mx_redirect(append_sid($mx_root_path . "login.php?redirect=" . this_rc_loginurl("radiocast_mode=radiocast_player&station_id=$station_id"), true)); } else { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } // ------------------------------------ // Check station Approval // ------------------------------------ if ($userdata['user_level'] != ADMIN) { if( ($thiscat['cat_approval'] == ADMIN) or (($thiscat['cat_approval'] == MOD) and !$radiocast_user_access['moderator']) ) { if ($thisstation['station_approval'] != 1) { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } } // ------------------------------------ // Increase view counter // ------------------------------------ $sql = "UPDATE ". RADIOCAST_TABLE ." SET station_view_count = station_view_count + 1 WHERE station_id = '$station_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not update station information', '', __LINE__, __FILE__, $sql); } /* +---------------------------------------------------------- | Main work here... +---------------------------------------------------------- */ // // Start output of page // $page_title = $lang['Radio']; if ( (!$is_block) && (!$block_mode) ) { include($mx_root_path . 'includes/page_header.'.$phpEx); } $template->set_filenames(array( 'body' => 'radiocast_player_body.tpl') ); if( ($thisstation['station_user_id'] == RADIOCAST_GUEST) or ($thisstation['username'] == '') ) { $poster = ($thisstation['station_username'] == '') ? $lang['Guest'] : $thisstation['station_username']; } else { $poster = '<a href="'. append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&". POST_USERS_URL .'='. $thisstation['user_id']) .'">'. $thisstation['username'] .'</a>'; } if ($radiocast_config['rate']) { $template->assign_block_vars('rate_switch', array()); } if ($radiocast_config['comment']) { $template->assign_block_vars('comment_switch', array()); } if ($radiocast_config['download']) { $template->assign_block_vars('download_switch', array()); } // // Media Center // if ( ($station_filetype == 'swf') or ($station_filetype == '.swf') ) { $template->assign_block_vars('flash', array()); $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=$station_id")); $url_video = $thisstation['station_url']; } else if ( $station_filetype == 'ram' ) { $template->assign_block_vars('ram', array()); $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=$station_id")); $url_video = $url_download; } else if ( $station_filetype == '.rm' ) { $template->assign_block_vars('rm', array()); $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=$station_id")); $url_video = $url_download; } else if ( $station_filetype == '.qt' ) { $template->assign_block_vars('qt', array()); $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=$station_id")); $url_video = $url_download; } else if ( ($station_filetype == 'ogg') or ($station_filetype == '.ogg') ) { $template->assign_block_vars('ogg', array()); if ( $thisstation['station_url'] == '' ) { $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=$station_id")); $url_video = $url_download; } else { $lang['Download'] = ( !empty($lang['Listen']) ? $lang['Listen'] : 'Listen URL' ); $url_download = $thisstation['station_url']; $url_video = $url_download; $media_width = '480'; } } else if ($stream_mode == 'forced') { $template->assign_block_vars('realandmedia', array()); if ($player_mode == 'real') { $template->assign_block_vars('real', array()); } elseif ($player_mode == 'media') { $template->assign_block_vars('media', array()); } else { $template->assign_block_vars('media', array()); } if( ($station_filetype == 'pls') && !empty($thisstation['station_url']) ) { $url_download = append_sid($module_root_path . 'radiocast.' . $phpEx . '?radiocast_mode=radiocast_stream&station_id=' . $station_id); $lang['Download'] = ( !empty($lang['Listen']) ? $lang['Listen'] : 'Listen URL' ); $url_video = $url_download; } else { //$url_download = append_sid($module_root_path . 'radiocast.' . $phpEx . '?radiocast_mode=radiocast_download&station_id=' . $station_id); $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=" . $station_id)); $url_video = $url_download; } } else { $template->assign_block_vars('realandmedia', array()); if ($player_mode == 'real') { $template->assign_block_vars('real', array()); } elseif ($player_mode == 'media') { $template->assign_block_vars('media', array()); } else { $template->assign_block_vars('media', array()); } if( ($station_filetype == 'pls') && !empty($thisstation['station_url']) ) { $url_download = append_sid($module_root_path . 'radiocast.' . $phpEx . '?radiocast_mode=radiocast_stream&station_id=' . $station_id); $lang['Download'] = ( !empty($lang['Listen']) ? $lang['Listen'] : 'Listen URL' ); $url_video = $url_download; } else { if( !empty($thisstation['station_url']) ) { $url_download = append_sid($thisstation['station_url']); } else { $url_download = append_sid(this_rc_mxurl("radiocast_mode=radiocast_download&station_id=" . $station_id)); } $lang['Download'] = ( !empty($lang['Listen']) ? $lang['Listen'] : 'Listen URL' ); $url_video = $url_download; } } //$url_station = append_sid($module_root_path . 'radiocast.' . $phpEx . '?radiocast_mode=radiocast_station&station_id=" . $station_id . "&player_mode=" . $player_mode . "&stream_mode=" . $stream_mode); $url_station = append_sid(this_rc_mxurl("radiocast_mode=radiocast_station&station_id=" . $station_id . "&player_mode=" . $player_mode . "&stream_mode=" . $stream_mode)); $url_media = append_sid(this_rc_mxurl("radiocast_mode=radiocast_player&station_id=" . $station_id . "&player_mode=" . 'media' . "&stream_mode=" . $stream_mode . "&block_mode=" . $block_mode)); $url_real = append_sid(this_rc_mxurl("radiocast_mode=radiocast_player&station_id=" . $station_id . "&player_mode=" . 'real' . "&stream_mode=" . $stream_mode . "&block_mode=" . $block_mode)); $url_forced = append_sid(this_rc_mxurl("radiocast_mode=radiocast_player&station_id=" . $station_id . "&player_mode=" . $player_mode . "&stream_mode=" . 'forced' . "&block_mode=" . $block_mode)); $url_window = append_sid($module_root_path . "radiocast." . $phpEx . "?radiocast_mode=radiocast_player&station_id=" . $station_id . "&player_mode=" . $player_mode . "&stream_mode=" . $stream_mode . "&block_mode=" . 'true'); $template->assign_vars(array( 'CAT_TITLE' => $thiscat['cat_title'], 'U_VIEW_CAT' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_cat&cat_id=$cat_id")), //'U_STATION' => append_sid($module_root_path . 'radiocast.' . $phpEx . '?radiocast_mode=radiocast_station&station_id=' . $station_id), 'U_STATION' => $url_station, 'U_WINDOW' => $url_window, 'U_WMP' => $url_media, 'U_REAL' => $url_real, 'U_FORCED' => $url_forced, 'U_IMG' => append_sid("$img_id"), 'IMG_REAL_FRONT' => $mx_images['real_front'], 'IMG_WMP_FRONT' => $mx_images['wmp_front'], 'IMG_IFRAME_BG' => $mx_images['iframe_bg'], 'STATION_TITLE' => $thisstation['station_title'], 'STATION_URL' => $thisstation['station_url'], 'VIDEO_URL' => $url_video, 'STATION_DESC' => nl2br($thisstation['station_desc']), 'SINGER' => $thisstation['station_singer'], 'POSTER' => $poster, 'MODULE_PATH' => $module_root_path, 'STATION_TIME' => create_date($board_config['default_dateformat'], $thisstation['station_time'], $board_config['board_timezone']), 'STATION_VIEW' => $thisstation['station_view_count'], 'STATION_DOWNLOAD' => ( !empty($thisstation['station_download_count']) ? $thisstation['station_download_count'] : '0' ), 'STATION_RATING' => ($thisstation['rating'] != 0) ? round($thisstation['rating'], 2) : $lang['Not_rated'], 'STATION_COMMENTS' => $thisstation['comments'], 'U_RATE' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_rate&station_id=$station_id")), 'U_COMMENT' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_comment&station_id=$station_id")), 'U_DOWNLOAD' => $url_download, 'U_NEXT' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_player&station_id=$station_id&mode=next")), 'U_PREVIOUS' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_player&station_id=$station_id&mode=previous")), 'L_NEXT' => $lang['Next'], 'L_PREVIOUS' => $lang['Previous'], 'NAV_SEP' => $lang['Nav_Separator'], 'NAV_DOT' => '•', 'RADIOCAST_VERSION' => '2' . $radiocast_config['radiocast_version'], 'L_INDEX' => '<<', 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'L_RADIOCAST_INDEX' => $lang['Radio_Cast'], 'L_RADIOCAST' => $lang['Radio'], 'U_RADIOCAST' => append_sid(this_rc_portalurl()), 'U_MX_RADIOCAST' => append_sid(this_rc_portalurl()), 'WIDTH' => ( !empty($media_width) ? $media_width : '320' ), 'HEIGHT' => ( !empty($media_height) ? $media_height : '300' ), 'L_RATING' => $lang['Rating'], 'L_STATION_TITLE' => $lang['Station_Title'], 'L_STATION_DESC' => $lang['Station_Desc'], 'L_SINGER' => $lang['Singer'], 'L_POSTER' => $lang['Poster'], 'L_POSTED' => $lang['Posted'], 'L_VIEW' => $lang['View'], 'L_DOWNLOAD' => $lang['Download'], 'L_COMMENTS' => $lang['Comments']) ); // // Generate the page // $template->pparse('body'); if ( (!$is_block) && (!$block_mode) ) { include($mx_root_path . 'includes/page_tail.'.$phpEx); } ?> --- NEW FILE: radiocast_add.php --- <?php /** * * @package mxBB Portal Module - mx_radiocast * @version $Id: radiocast_add.php,v 1.1 2007/06/06 23:03:48 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // MX if ( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // Let's include some stuff... // $phpEx = substr(strrchr(__FILE__, '.'), 1); if ( !defined('TEMPLATE_ROOT_PATH') ) { include_once($mx_root_path . 'common.' . $phpEx); // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); // // End session management // } $radiocast_root_path = $module_root_path . 'radiocast_mod/'; $station_image_path = RADIOCAST_IMAGE_UPLOAD_PATH; // // Get general music information // include_once($radiocast_root_path . 'radiocast_common.'.$phpEx); /* +---------------------------------------------------------- | Common Check +---------------------------------------------------------- */ // ------------------------------------ // Check the request // for this Upload script, we prefer POST to GET // ------------------------------------ if( isset($HTTP_POST_VARS['cat_id']) ) { $cat_id = intval($HTTP_POST_VARS['cat_id']); } else if( isset($HTTP_GET_VARS['cat_id']) ) { $cat_id = intval($HTTP_GET_VARS['cat_id']); } else { mx_message_die(GENERAL_ERROR, 'No categories specified'); } // ------------------------------------ // Get the current Category Info // ------------------------------------ $sql = "SELECT c.*, COUNT(s.station_id) AS count FROM ". RADIOCAST_CAT_TABLE ." AS c LEFT JOIN ". RADIOCAST_TABLE ." AS s ON c.cat_id = s.station_cat_id WHERE c.cat_id = '$cat_id' GROUP BY c.cat_id LIMIT 1"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query category information', '', __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); $current_stations = $thiscat['count']; if (empty($thiscat)) { mx_message_die(GENERAL_ERROR, $lang['Category_not_exist']); } // ------------------------------------ // Check the permissions // ------------------------------------ $radiocast_user_access = radiocast_user_access($cat_id, $thiscat, 0, 1, 0, 0, 0, 0); // UPLOAD if ($radiocast_user_access['upload'] == 0) { if (!$userdata['session_logged_in']) { mx_redirect(append_sid($mx_root_path . "login.php?redirect=" . this_rc_loginurl("radiocast_mode=radiocast_add&cat_id=$cat_id"), true)); } else { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); } } /* +---------------------------------------------------------- | Upload Quota Check +---------------------------------------------------------- */ // ------------------------------------ // Check music Configuration Quota // ------------------------------------ if ($radiocast_config['max_stations'] >= 0) { // // $current_stations was set at "Get the current Category Info" // if( $current_stations >= $radiocast_config['max_stations'] ) { mx_message_die(GENERAL_MESSAGE, $lang['RadioCast_reached_quota']); } } // ------------------------------------ // Check User Limit // ------------------------------------ $check_user_limit = FALSE; if( ($userdata['user_level'] != ADMIN) and ($userdata['session_logged_in']) ) { if ($radiocast_user_access['moderator']) { if ($radiocast_config['mod_stations_limit'] >= 0) { $check_user_limit = 'mod_stations_limit'; } } else { if ($radiocast_config['user_stations_limit'] >= 0) { $check_user_limit = 'user_stations_limit'; } } } // Do the check here if ($check_user_limit != FALSE) { $sql = "SELECT COUNT(station_id) AS count FROM ". RADIOCAST_TABLE ." WHERE station_user_id = '". $userdata['user_id'] ."' AND station_cat_id = '$cat_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not count your station', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $own_stations = $row['count']; if( $own_stations >= $radiocast_config[$check_user_limit] ) { mx_message_die(GENERAL_MESSAGE, $lang['User_reached_stations_quota']); } } /* +---------------------------------------------------------- | Main work here... +---------------------------------------------------------- */ if( !isset($HTTP_POST_VARS['station_title']) ) // is it not submitted? { // -------------------------------- // Build categories select // -------------------------------- $sql = "SELECT * FROM " . RADIOCAST_CAT_TABLE ." ORDER BY cat_order ASC"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql); } $catrows = array(); while( $row = $db->sql_fetchrow($result) ) { $thiscat_access = radiocast_user_access($row['cat_id'], $row, 0, 1, 0, 0, 0, 0); // UPLOAD if ($thiscat_access['upload'] == 1) { $catrows[] = $row; } } $select_cat = '<select name="cat_id">'; for ($i = 0; $i < count($catrows); $i++) { $select_cat .= '<option value="'. $catrows[$i]['cat_id'] .'" '; $select_cat .= ($cat_id == $catrows[$i]['cat_id']) ? 'selected="selected"' : ''; $select_cat .= '>'. $catrows[$i]['cat_title'] .'</option>'; } $select_cat .= '</select>'; // // Start output of page // $page_title = $lang['Radio']; if ( !$is_block ) { include($mx_root_path . 'includes/page_header.'.$phpEx); } $template->set_filenames(array( 'body' => 'radiocast_add_body.tpl') ); $template->assign_vars(array( 'U_VIEW_CAT' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_cat&cat_id=$cat_id")), 'CAT_TITLE' => $thiscat['cat_title'], 'L_ADD_STATION' => $lang['Add_Station'], 'L_USERNAME' => $lang['Username'], 'L_STATION_TITLE' => $lang['Station_Title'], 'L_STATION_URL' => $lang['Station_url'], 'L_STATION_DESC' => $lang['Station_Desc'], 'L_SINGER' => $lang['Singer'], 'L_PLAIN_TEXT_ONLY' => $lang['Plain_text_only'], 'L_MAX_LENGTH' => $lang['Max_length'], 'S_STATION_DESC_MAX_LENGTH' => $radiocast_config['desc_length'], 'L_ADD_STATION_FROM_MACHINE' => $lang['Add_station_from_machine'], 'L_STATION_IMAGE' => $lang['Station_image'], 'L_STATION_IMAGE_DESC' => $lang['Station_image_desc'], 'L_NO_IMAGE' => $lang['No_image'], 'L_ADD_IMAGE' => $lang['Upload_image'], 'L_ADD_TO_CATEGORY' => $lang['Add_to_Category'], 'SELECT_CAT' => $select_cat, 'L_MAX_FILESIZE' => $lang['Max_file_size'], 'S_MAX_FILESIZE' => $radiocast_config['max_file_size'], // Media Center 'L_ALLOWED_FILE' => $lang['Allowed_file'], 'S_MP3' => ($radiocast_config['mp3_allowed'] == 1) ? 'MP3,' : '', 'S_WAV' => ($radiocast_config['wav_allowed'] == 1) ? 'WAV,' : '', 'S_WMA' => ($radiocast_config['wma_allowed'] == 1) ? 'WMA,' : '', 'S_WMV' => ($radiocast_config['wmv_allowed'] == 1) ? 'WMV,' : '', 'S_MIDI' => ($radiocast_config['mid_allowed'] == 1) ? 'MIDI,' : '', 'S_RAM' => ($radiocast_config['ram_allowed'] == 1) ? 'RAM,' : '', 'S_AU' => ($radiocast_config['au_allowed'] == 1) ? 'AU,' : '', 'S_MPEG' => ($radiocast_config['mpeg_allowed'] == 1) ? 'MPEG,' : '', 'S_AVI' => ($radiocast_config['avi_allowed'] == 1) ? 'AVI,' : '', 'S_SWF' => ($radiocast_config['swf_allowed'] == 1) ? 'SWF,' : '', 'S_QT' => ($radiocast_config['qt_allowed'] == 1) ? 'QT,' : '', 'S_RM' => ($radiocast_config['rm_allowed'] == 1) ? 'RM,' : '', // Media Center 'L_ADD_NO_TITLE' => $lang['Add_no_title'], 'L_ADD_NO_FILE' => $lang['Upload_no_file'], 'L_ADD_BOTH_FILE' => $lang['Upload_both_file'], 'L_DESC_TOO_LONG' => $lang['Desc_too_long'], 'L_RESET' => $lang['Reset'], 'L_SUBMIT' => $lang['Submit'], 'NAV_SEP' => $lang['Nav_Separator'], 'NAV_DOT' => '•', 'RADIOCAST_VERSION' => '2' . $radiocast_config['radiocast_version'], 'L_INDEX' => '<<', 'U_INDEX' => append_sid($mx_root_path . "index.".$phpEx), 'L_RADIOCAST_INDEX' => $lang['Radio_Cast'], 'L_RADIOCAST' => $lang['Radio'], 'U_RADIOCAST' => append_sid(this_rc_mxurl()), 'U_MX_RADIOCAST' => append_sid(this_rc_portalurl()), 'S_RADIOCAST_ACTION' => append_sid(this_rc_mxurl("radiocast_mode=radiocast_add&cat_id=" . $cat_id)), ) ); // // Generate the page // $template->pparse('body'); if ( !$is_block ) { include($mx_root_path . 'includes/page_tail.'.$phpEx); } } else { // -------------------------------- // Check posted info // -------------------------------- $station_title = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['station_title']))); $station_url = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['station_url']))); $image_system = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['image_system']))); $station_desc = str_replace("\'", "''", htmlspecialchars(substr(trim($HTTP_POST_VARS['station_desc']), 0, $radiocast_config['desc_length']))); $station_singer = str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['station_singer']))); $station_username = (!$userdata['session_logged_in']) ? substr(str_replace("\'", "''", htmlspecialchars(trim($HTTP_POST_VARS['station_username']))), 0, 32) : str_replace("'", "''", $userdata['username']); if( empty($station_title) ) { mx_message_die(GENERAL_ERROR, $lang['Missed_station_title']); } // -------------------------------- // Check username for guest posting // -------------------------------- if (!$userdata['session_logged_in']) { if ($station_username != '') { $result = validate_username($station_username); if ( $result['error'] ) { mx_message_die(GENERAL_MESSAGE, $result['error_msg']); } } } // -------------------------------- // Get File Upload Info // -------------------------------- $filetype = ( !empty($HTTP_POST_FILES['station_file']['type']) ) ? $HTTP_POST_FILES['station_file']['type'] : $HTTP_POST_VARS['station_url']['type']; $filesize = ( !empty($HTTP_POST_FILES['station_file']['size']) ) ? $HTTP_POST_FILES['station_file']['size'] : $HTTP_POST_VARS['station_url']['size']; $filetmp = ( !empty($HTTP_POST_FILES['station_file']['tmp_name']) ) ? $HTTP_POST_FILES['station_file']['tmp_name'] : $HTTP_POST_VARS['station_url']['tmp_name']; // -------------------------------- // Get Station Image Upload Info // -------------------------------- $imagetype = ( !empty($HTTP_POST_FILES['station_image']['type']) ) ? $HTTP_POST_FILES['station_image']['type'] : ''; $imagesize = ( !empty($HTTP_POST_FILES['station_image']['size']) ) ? $HTTP_POST_FILES['station_image']['size'] : 0; $imagetmp = ( !empty($HTTP_POST_FILES['station_image']['tmp_name']) ) ? $HTTP_POST_FILES['station_image']['tmp_name'] : ''; // -------------------------------- // Check image size // -------------------------------- if( $image_system == '1' ) { if( $imagesize > $radiocast_config['max_image_size'] ) { mx_message_die(GENERAL_MESSAGE, $lang['Bad_upload_image_size']); } } // -------------------------------- // Check image type // -------------------------------- if( $image_system == '1' ) { switch ($imagetype) { case 'image/jpeg': case 'image/jpg': case 'image/pjpeg': $station_imagetype = '.jpg'; break; case 'image/gif': $station_imagetype = '.gif'; break; case 'image/png': case 'image/x-png': $station_imagetype = '.png'; break; default: mx_message_die(GENERAL_ERROR, $lang['Not_allowed_image_type']); } } // -------------------------------- // Prepare variables // -------------------------------- $station_time = time(); $station_user_id = $userdata['user_id']; $station_user_ip = $userdata['session_ip']; // -------------------------------- // Check file size // -------------------------------- if( empty($station_url) ) { if( ($filesize == 0) or ($filesize > $radiocast_config['max_file_size']) ) { mx_message_die(GENERAL_MESSAGE, $lang['Bad_upload_file_size']); } } // -------------------------------- // Check file type // -------------------------------- if( empty($station_url) ) { switch ($filetype) { case 'audio/mpeg': case 'audio/x-mpeg': case 'audio/mp3': case 'audio/mpg': if ($radiocast_config['mp3_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mp3'; break; case 'audio/wav': if ($radiocast_config['wav_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wav'; break; case 'audio/x-ms-wma': if ($radiocast_config['wma_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wma'; break; // // Extra extensions // case 'video/x-ms-wmv': if ($radiocast_config['wmv_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wmv'; break; case 'video/mpeg': if ($radiocast_config['mpeg_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mpeg'; break; case 'video/avi': case 'video/x-msvideo': if ($radiocast_config['avi_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.avi'; break; case 'application/x-shockwave-flash': if ($radiocast_config['swf_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.swf'; break; case 'video/quicktime': if ($radiocast_config['qt_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.qt'; break; case 'audio/x-midi': case 'audio/mid': case 'audio/midi': if ($radiocast_config['mid_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mid'; break; case 'audio/x-pn-realaudio': if ($radiocast_config['ram_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.ram'; break; case 'audio/basic': if ($radiocast_config['au_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.au'; break; case 'audio/vnd.rn-realmedia': case 'application/vnd.rn-realmedia': case 'video/vnd.rn-realvideo': case 'application/vnd': if ($radiocast_config['rm_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.rm'; break; // End extra default: mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } } else { switch ($filetype) { case 'audio/mpeg': case 'audio/x-mpeg': case 'audio/mp3': case 'audio/mpg': if ($radiocast_config['mp3_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mp3'; break; case 'audio/wav': if ($radiocast_config['wav_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wav'; break; case 'audio/x-ms-wma': if ($radiocast_config['wma_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wma'; break; // // Extra extensions // case 'video/x-ms-wmv': if ($radiocast_config['wmv_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.wmv'; break; case 'video/mpeg': if ($radiocast_config['mpeg_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mpeg'; break; case 'video/avi': case 'video/x-msvideo': if ($radiocast_config['avi_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.avi'; break; case 'application/x-shockwave-flash': if ($radiocast_config['swf_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.swf'; break; case 'video/quicktime': if ($radiocast_config['qt_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.qt'; break; case 'audio/x-midi': case 'audio/mid': case 'audio/midi': if ($radiocast_config['mid_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.mid'; break; case 'audio/x-pn-realaudio': if ($radiocast_config['ram_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.ram'; break; case 'audio/basic': if ($radiocast_config['au_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.au'; break; case 'audio/vnd.rn-realmedia': case 'application/vnd.rn-realmedia': case 'video/vnd.rn-realvideo': case 'application/vnd': if ($radiocast_config['rm_allowed'] == 0) { mx_message_die(GENERAL_ERROR, $lang['Not_allowed_file_type']); } $station_filetype = '.rm'; break; default: $station_filetype = '.pls'; break; // End extra } } // -------------------------------- // Generate filename // -------------------------------- srand((double)microtime()*1000000); // for older than version 4.2.0 of PHP do { $station_filename = md5(uniqid(rand())) . $station_filetype; } while( file_exists(RADIOCAST_UPLOAD_PATH . $station_filename) ); // -------------------------------- // Generate imagename // -------------------------------- if( $image_system == '1' ) { do { $station_imagename = md5(uniqid(rand())) . $station_imagetype; } while( file_exists($station_image_path . $station_imagename) ); } else { $station_imagename = ''; } // -------------------------------- // Move this file to upload directory // -------------------------------- if( empty($station_url) ) { $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; if ( @$ini_val('open_basedir') != '' ) { if ( @phpversion() < '4.0.3' ) { mx_message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin', '', __LINE__, __FILE__); } $move_file = 'move_uploaded_file'; } else { $move_file = 'copy'; } $move_file($filetmp, RADIOCAST_UPLOAD_PATH . $station_filename); @chmod(RADIOCAST_UPLOAD_PATH . $station_filename, 0777); } // -------------------------------- // Move Station image to directory // -------------------------------- if( $image_system == '1' ) { if( !empty($HTTP_POST_FILES['station_image']['tmp_name']) ) { $ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var'; if ( @$ini_val('open_basedir') != '' ) { if ( @phpversion() < '4.0.3' ) { mx_message_die(GENERAL_ERROR, 'open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin', '', __LINE__, __FILE__); } $move_file = 'move_uploaded_file'; } else { $move_file = 'copy'; } $move_file($imagetmp, $station_image_path . $station_imagename); @chmod($station_image_path . $station_imagename, 0777); } } // -------------------------------- // Check its image size // -------------------------------- if( $image_system == '1' ) { if( !empty($HTTP_POST_FILES['station_image']['size']) ) { $image_size = getimagesize($station_image_path . $station_imagename); $image_width = $image_size[0]; $image_height = $image_size[1]; if ( ($image_width > $radiocast_config['max_image_width']) or ($image_height > $radiocast_config['max_image_height']) ) { @unlink($station_image_path . $station_imagename); mx_message_die(GENERAL_ERROR, 'Your uploaded image size is too big'); } } } // -------------------------------- // Check Station Approval // -------------------------------- $station_approval = ($thiscat['cat_approval'] == 0) ? 1 : 0; // -------------------------------- // Insert into DB // -------------------------------- $sql3 = "INSERT INTO ". RADIOCAST_TABLE ." (station_filename, station_imagename, station_title, station_url, station_desc, station_singer, station_user_id, station_username, station_user_ip, station_time, station_cat_id, station_approval) VALUES ('$station_filename', '$station_imagename', '$station_title', '$station_url', '$station_desc', '$station_singer', '$station_user_id', '$station_username', '$station_user_ip', '$station_time', '$cat_id', '$station_approval')"; if( !$result = $db->sql_query($sql3) ) { mx_message_die(GENERAL_ERROR, 'Could not insert new entry', '', __LINE__, __FILE__, $sql3); } // -------------------------------- // Complete... now send a message to user // -------------------------------- if ($thiscat['cat_approval'] == 0) { $message = $lang['RadioCast_add_successful']; } else { $message = $lang['RadioCast_add_need_approval']; } if ($thiscat['cat_approval'] == 0) { $template->assign_vars(array( 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid(this_rc_mxurl("radiocast_mode=radiocast_cat&cat_id=$cat_id")) . '">') ); } //$message .= $sql3; $message .= "<br /><br />" . sprintf($lang['Click_return_category'], "<a href=\"" . append_sid(this_rc_mxurl("radiocast_mode=radiocast_cat&cat_id=$cat_id")) . "\">", "</a>"); $message .= "<br /><br />" . sprintf($lang['Click_return_radiocast_index'], "<a href=\"" . append_sid(this_rc_mxurl()) . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); } ?> --- NEW FILE: radiocast_station.php --- <?php /** * * @package mxBB Portal Module - mx_radiocast * @version $Id: radiocast_station.php,v 1.1 2007/06/06 23:03:53 orynider Exp $ * @copyright (c) 2007 [ory...@rd..., OryNider] mxBB Development Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ // MX if ( !defined('IN_PORTAL') ) { die("Hacking attempt"); } // // Let's include some stuff... // $phpEx = substr(strrchr(__FILE__, '.'), 1); if ( !defined('TEMPLATE_ROOT_PATH') ) { include_once($mx_root_path . 'common.' . $phpEx); // // Start session management // $mx_user->init($user_ip, PAGE_INDEX); // // End session management // } $radiocast_root_path = $module_root_path . 'radiocast_mod/'; // // Get general music information // include_once($radiocast_root_path . 'radiocast_common.'.$phpEx); // ------------------------------------ // Check the request // ------------------------------------ if( isset($HTTP_GET_VARS['station_id']) ) { $station_id = intval($HTTP_GET_VARS['station_id']); } else if( isset($HTTP_POST_VARS['station_id']) ) { $station_id = intval($HTTP_POST_VARS['station_id']); } else { die('No stations specified'); } if( isset($HTTP_GET_VARS['player_mode']) ) { if ($HTTP_GET_VARS['player_mode'] == 'media') { $player_mode = 'media'; } elseif ($HTTP_GET_VARS['player_mode'] == 'real') { $player_mode = 'real'; } } else { $player_mode = 'media'; } if( isset($HTTP_GET_VARS['stream_mode']) ) { if ($HTTP_GET_VARS['stream_mode'] == 'forced') { $stream_mode = 'forced'; } elseif ($HTTP_GET_VARS['stream_mode'] == 'direct') { $stream_mode = 'direct'; } } else { $stream_mode = 'direct'; } // ------------------------------------ // Get this station info // ------------------------------------ $sql = "SELECT * FROM ". RADIOCAST_TABLE ." WHERE station_id = '$station_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query station information', '', __LINE__, __FILE__, $sql); } $thisstation = $db->sql_fetchrow($result); $cat_id = $thisstation['station_cat_id']; $user_id = $thisstation['station_user_id']; if ( $thisstation['station_url'] == '' ) { $station_filetype = substr($thisstation['station_filename'], strlen($thisstation['station_filename']) - 3, 3); $station_filename = $thisstation['station_filename']; } else { $station_filetype = substr($thisstation['station_url'], strlen($thisstation['station_url']) - 3, 3); $station_url = $thisstation['station_url']; } // ------------------------------------ // Get the current Category Info // ------------------------------------ $sql = "SELECT * FROM ". RADIOCAST_CAT_TABLE ." WHERE cat_id = '$cat_id'"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query category information', '', __LINE__, __FILE__, $sql); } $thiscat = $db->sql_fetchrow($result); if (empty($thiscat)) { die($lang['Category_not_exist']); } // ------------------------------------ // Check the permissions // ------------------------------------ $radiocast_user_access = radiocast_user_access($cat_id, $thiscat, 1, 0, 0, 0, 0, 0); // VIEW if ($radiocast_user_access['view'] == 0) { die($lang['Not_Authorised']); } // ------------------------------------ // Check station Approval // ------------------------------------ if ($userdata['user_level'] != ADMIN) { if( ($thiscat['cat_approval'] == ADMIN) or (($thiscat['cat_approval'] == MOD) and !$radiocast_user_access['moderator']) ) { if ($thisstation['station_approval'] != 1) { die($lang['Not_Authorised']); } } } // ------------------------------------ // Check hotlink // ------------------------------------ if( ($radiocast_config['hotlink_prevent'] == 1) and (isset($HTTP_SERVER_VARS['HTTP_REFERER'])) ) { $check_referer = explode('?', $HTTP_SERVER_VARS['HTTP_REFERER']); $check_referer = trim($check_referer[0]); $good_referers = array(); if ($radiocast_config['hotlink_allowed'] != '') { $good_referers = explode(',', $radiocast_config['hotlink_allowed']); } $good_referers[] = $board_config['server_name'] . $board_config['script_path']; $errored = TRUE; for ($i = 0; $i < count($good_referers); $i++) { $good_referers[$i] = trim($good_referers[$i]); if( (strstr($check_referer, $good_referers[$i])) and ($good_referers[$i] != '') ) { $errored = FALSE; } } if ($errored) { die($lang['Not_Authorised']); } } /* +---------------------------------------------------------- | Main work here... +---------------------------------------------------------- */ // ------------------------------------ // Send the station // ------------------------------------ if ( $thisstation['station_url'] == '' ) { switch ( $station_filetype ) { case 'mp3': header('Content-type: audio/mp3'); break; case 'wav': header('Content-type: audio/wav'); break; case 'wma': header('Content-type: audio/x-ms-wma'); break; case 'wmv': header('Content-type: video/x-ms-wmv'); break; case 'peg': header('Content-type: video/mpeg'); break; case 'avi': header('Content-type: video/x-msvideo'); break; case 'swf': header('Content-type: application/x-shockwave-flash'); break; case '.au': header('Content-type: audio/basic'); break; case 'mid': header('Content-type: audio/mid'); break; case '.qt': header('Content-type: video/quicktime'); break; case 'ram': header('Content-type: audio/x-pn-realaudio'); ... [truncated message content] |