Файл: system/inc/radio.php
Строк: 1006
<?
if(!defined('MOZG'))
die('Hacking attempt!');
require_once ( ENGINE_DIR . "/modules/radio/data/config.php" );
$allow_edit_radio = array(1);
if( !in_array($user_info['user_group'], $allow_edit_radio) ) msgbox( "Ошибка", "Вам запрещено просматривать данный раздел", "javascript:history.go(-1)" );
if ( isset ( $_REQUEST['id'] )) $id = intval( $_REQUEST['id'] ); else $id = "";
if ( isset ( $_REQUEST['action'] )) $action = $_REQUEST['action']; else $action = "";
function makeDropDown($options, $name, $selected) {
$output = "<select size=1 name="$name">rn";
foreach ( $options as $value => $description ) {
$output .= "<option value="$value"";
if( $selected == $value ) {
$output .= " selected ";
}
$output .= ">$description</option>n";
}
$output .= "</select>";
return $output;
}
function showRow($title = "", $description = "", $field = "", $last = "") {
echo "<tr>
<td style="padding:4px" class="option">
<b>$title</b>";
if($description !="") echo "<br /><span class=small>$description</span>";
echo "<td width="45%" align="left" style="padding:4px">
$field
</tr>";
if($last != "yes") echo "<tr><td background="engine/skins/images/mline.gif" height=1 colspan=2></td></tr>";
$bg = "";
$i ++;
}
function top_menu( $what ){
echoheader();
echo <<<HTML
<div class="hardcore">
HTML;
if( $what == "radio" ) echo "<span class="active">Радиостанции</span><a href="?mod=radio&action=category">Категории</a><a href="?mod=radio&action=settings">Настройки</a></div>";
elseif( $what == "radio_edit" ) echo "<a href="?mod=radio"><</a><span class="active">Радиостанции</span><a href="?mod=radio&action=category">Категории</a><a href="?mod=radio&action=settings">Настройки</a></div>";
elseif( $what == "cat" ) echo "<a href="?mod=radio">Радиостанции</a><span class="active">Категории</span><a href="?mod=radio&action=settings">Настройки</a></div>";
elseif( $what == "cat_edit" ) echo "<a href="?mod=radio">Радиостанции</a><a href="?mod=radio&action=category"><</a><span class="active">Категории</span><a href="?mod=radio&action=settings">Настройки</a></div>";
elseif( $what == "settings" ) echo "<a href="?mod=radio">Радиостанции</a><a href="?mod=radio&action=category">Категории</a><span class="active">Настройки</span></div>";
}
########################################################################################
########################################################################################
########################################################################################
// Категории // Категории // Категории // Категории // Категории // Категории // Категории // Категории
########################################################################################
########################################################################################
########################################################################################
// ********************************************************************************
// Список категорий
// ********************************************************************************
if( $action == 'category' ) {
top_menu( "cat" );
echo <<<HTML
<script>
$(document).ready(function() {
$('#add_cat').submit(function() {
if( $('input[name="cat_name"]').val() == "" ) {
DLEalert('Имя категории является обязательным при добавление категории!', '$lang[p_info]');
return false;
}
if( $('input[name="alt_cat_name"]').val() == "" ) {
DLEalert('Альтернативное имя категории является обязательным при добавление категории!', '$lang[p_info]');
return false;
}
});
$(".delete_me").click(function() {
var b = {}, link = $(this).attr("href");
b[dle_act_lang[1]] = function() {
$(this).dialog("close");
};
b[dle_act_lang[0]] = function() {
$(this).dialog("close");
document.location=link;
};
$("#dlepopup").remove();
$("body").append("<div id='dlepopup' title='Предупреждениe' style='display:none'><div id='dlepopupmessage'><br />Вы уверены, что хотите удалить категорию?</div></div>");
$('#dlepopup').dialog({
autoOpen: true, width: 200, buttons: b
});
return false;
});
});
</script>
<form method="post" id="add_cat" action="" >
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Добавление новой категории</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td width="260" style="padding:4px; height:42px;">Имя:</td>
<td>
<input class="edit bk" type="text" name="cat_name">
<br /><span class="small">пример: <b>Популярная музыка</b></span>
</td>
</tr>
<tr>
<td style="padding:4px; height:42px;">Альтернативное имя:</td>
<td>
<input class="edit bk" type="text" name="alt_cat_name">
<br /><span class="small">пример: <b>pop-music</b></span>
</td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;"> </td>
<td>
<input type="submit" class="submit" value="Добавить категорию" />
<input type="hidden" name="mod" value="radio" />
<input type="hidden" name="user_hash" value="$dle_login_hash" />
<input type="hidden" name="action" value="add" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</form>
<form method="post" action="">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Список категорий</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td style="padding:2px;">ID</td>
<td style="padding:2px;">Position</td>
<td>Название</td>
<td>Альт название</td>
<td width="120">Действия</td>
</tr>
<tr>
<td colspan="7"><div class="hr_line"></div></td>
</tr>
HTML;
$cat_found = FALSE;
$db->query( "SELECT * FROM " . PREFIX . "_radio_cat ORDER BY posi ASC, id ASC" );
while ( $row = $db->get_row() ) {
$cat_found = TRUE;
if( $config['allow_alt_url'] == "yes" ) $link = "<a class="list" href="" . $config['home_url'] . "radio/" . $row['alt_name'] . "/">" . stripslashes( $row['name'] ) . "</a>";
else $link = "<a class="list" href="" . $config['home_url'] . "index.php?go=radio&category=" . $row['name'] . "">" . stripslashes( $row['name'] ) . "</a>";
echo "<tr class="bj">
<td height="24"> <b>" . $row['id'] . "</b></td>
<td><input class="edit" type="text" size="5" name="posi[{$row['id']}]" maxlength="5" value="{$row['posi']}"></td>
<td>" . $link . "</td>
<td>" . $row['alt_name'] . "</td>
<td class="list"><nobr>[<a href="?mod=radio&action=edit&id=" . $row['id'] . "">Редактировать</a>] [<a class="delete_me maintitle" href="?mod=radio&user_hash=" . $dle_login_hash . "&action=remove&id=" . $row['id'] . "">Удалить</a>]</nobr></td>
</tr>";
}
$db->free();
if( $cat_found ) {
echo <<<HTML
<tr>
<td colspan="7" style="padding:5px;"><input type="hidden" name="action" value="sort"><input type="submit" id="posi" class="submit" value="Сортировать" /></td>
</tr>
HTML;
} else {
echo <<<HTML
<tr><td colspan=5><table width="100%">
<tr>
<td height="100" align="center">Категорий нет Вы можете обойтись и без них)</td>
</tr>
</table></td></tr>
HTML;
}
echo <<<HTML
</table>
</td>
</tr>
</table>
</div></form>
HTML;
echohtmlend();
}
// ********************************************************************************
// Редактирование категории
// ********************************************************************************
elseif( $action == "edit" ) {
if( ! $id ) msg( "error", $lang['cat_error'], $lang['cat_noid'], "$PHP_SELF?mod=radio&action=category" );
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_radio_cat WHERE id = '$id'" );
if( ! $row['id'] ) msg( "error", $lang['cat_error'], "Не существует категорий с таким ID", "$PHP_SELF?mod=radio&action=category" );
$row['name'] = stripslashes( preg_replace( array ("'"'", "'''" ), array (""", "'" ), $row['name'] ) );
top_menu( "cat_edit" );
echo <<<HTML
<form method="post" action="">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Редактирование</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td width="260" style="padding:4px; height:42px;">Имя:</td>
<td>
<input class="edit bk" type="text" name="cat_name" value="{$row['name']}">
<br /><span class="small">пример: <b>Популярная музыка</b></span>
</td>
</tr>
<tr>
<td style="padding:4px; height:42px;">Альтернативное имя:</td>
<td>
<input class="edit bk" type="text" name="alt_cat_name" value="{$row['alt_name']}">
<br /><span class="small">пример: <b>pop-music</b></span>
</td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;"> </td>
<td>
<input type="submit" class="submit" value="{$lang['vote_edit']}">
<input type="hidden" name="action" value="doedit">
<input type="hidden" name="user_hash" value="$dle_login_hash" />
<input type="hidden" name="id" value="$row[id]">
</tr>
</table>
</td>
</tr>
</table>
</div></form>
HTML;
echohtmlend();
}
// ********************************************************************************
// Добавление категории
// ********************************************************************************
elseif( $action == "add" ) {
$cat_name = $db->safesql( htmlspecialchars( strip_tags( stripslashes($_POST['cat_name'] ) ), ENT_QUOTES) );
$alt_cat_name = totranslit( stripslashes( $_POST['alt_cat_name'] ), true, false );
if($cat_name ){
if($alt_cat_name ){
$row = $db->super_query( "SELECT alt_name FROM " . PREFIX . "_radio_cat WHERE alt_name ='{$alt_cat_name}'" );
$db->query( "INSERT INTO " . PREFIX . "_radio_cat (name, alt_name) values ('$cat_name', '$alt_cat_name')" );
@unlink( ENGINE_DIR . '/cache/system/radio_cat.php' );
msgbox('Информация', 'Категория добавлена', '?mod=radio&action=category');
}else msgbox( "Ошибка", 'Укажите альтернативное название категории', "javascript:history.go(-1)" );
}else msgbox( "Ошибка", 'Укажите название категории', "javascript:history.go(-1)" );
}
// ********************************************************************************
// Сортировка категорий
// ********************************************************************************
elseif( $action == "sort" ) {
foreach ( $_POST["posi"] as $id => $posi ) {
if( $posi != "" ) {
$posi = intval( $posi );
$id = intval( $id );
$db->query( "UPDATE " . PREFIX . "_radio_cat SET posi='{$posi}' WHERE id = '{$id}'" );
}
}
@unlink( ENGINE_DIR . '/cache/system/radio_cat.php' );
header( "Location: ?mod=radio&action=category" );
}
// ********************************************************************************
// Удаление категории
// ********************************************************************************
elseif( $action == "remove" ) {
if( $id ){
$db->query( "DELETE FROM " . PREFIX . "_radio_cat WHERE id='$id'" );
@unlink( ENGINE_DIR . '/cache/system/radio_cat.php' );
msgbox( "Информация", 'Категория удалена', "?mod=radio&action=category" );
}else msgbox( "Ошибка", 'Категории не существует', "mod=radio&action=category" );
}
// ********************************************************************************
// Запись отредактированной категории
// ********************************************************************************
elseif( $action == "doedit" ) {
$cat_name = $db->safesql( htmlspecialchars( strip_tags( stripslashes($_POST['cat_name'] ) ), ENT_QUOTES) );
$alt_cat_name = totranslit( stripslashes( $_POST['alt_cat_name'] ), true, false );
if($id ) {
if( $cat_name == "" ){
$row = $db->super_query( "SELECT id, alt_name FROM " . PREFIX . "_radio_cat WHERE alt_name = '$alt_cat_name'" );
if( $row['id'] and $row['id'] != $id ) msg( "error", $lang['cat_error'], $lang['cat_eradd'], "javascript:history.go(-1)" );
$db->query( "UPDATE " . PREFIX . "_radio_cat set name='$cat_name', alt_name='$alt_cat_name' WHERE id='$id'" );
@unlink( ENGINE_DIR . '/cache/system/radio_cat.php' );
msgbox( "Информация ", 'Категория отредактирована', "?mod=radio&action=category" );
}else msgbox( "Ошибка", 'Не указано название', "?mod=radio&action=category" );
}else msgbox( "Ошибка", 'Категории не существует', "?mod=radio&action=category" );
}
########################################################################################
########################################################################################
########################################################################################
// Настройки // Настройки // Настройки // Настройки // Настройки // Настройки // Настройки // Настройки
########################################################################################
########################################################################################
########################################################################################
// ********************************************************************************
// Настройки
// ********************************************************************************
elseif( $action == "settings" ) {
top_menu( "settings" );
echo <<<HTML
<form action="$PHP_SELF?mod=radio&action=save_settings" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка модуля </div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
HTML;
showRow( "Включить модуль ", "", makeDropDown( array ("on" => 'Да', "off" => 'Нет' ), "save_con[work]", "{$radio_config['work']}" ) );
showRow( "Вид модального окна:", "", makeDropDown( array ("pop" => "Pop-up", "jq" => "jQuery UI Dialog" ), "save_con[modal]", "{$radio_config['modal']}" ) );
showRow( "Количество радиостанций на страницу:", "Количество радиостанций, которое будет выводиться на страницу", "<input class="edit bk" type=text style="text-align: center;" name="save_con[perpage]" value="{$radio_config['perpage']}" size=6>" );
showRow( "Интервал обновления информации (в секундах!):", "Рекомендую ставить интервал не менее 10 секунд", "<input class="edit bk" type=text style="text-align: center;" name="save_con[timer]" value="{$radio_config['timer']}" size=6>" );
showRow( "Размер логотипа радиостанции:", "Существует две возможности использования данной настройки:<br/><br/><b>Первая:</b> Вы вводите допустимые размеры в пикселях любой из сторон оригинального изображения. Например: <b>60</b><br/><b>Вторая:</b> Вы задаете ширину и высоту оригинального изображения в формате ширина x высота. Например: <b>60x60</b>", "<input class="edit bk" type=text name="save_con[cover]" value="{$radio_config['cover']}" size=20>" );
echo <<<HTML
</table>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка мета тегов списка радиостанций</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
HTML;
showRow( "Заголовок (Title):", "пример: http://mysite.com/uploads/banner.jpg", "<input class="edit bk" type=text name="save_con[title]" value="{$radio_config['title']}" size=60>" );
showRow( "Описание (Description):", "Краткое описание, не более 200 символов", "<input class="edit bk" type=text name="save_con[description]" value="{$radio_config['description']}" size=60>" );
showRow( "Ключевые слова (Keywords):", "Введите через запятую основные ключевые слова для модуля "DLE Radio"", "<input class="edit bk" type=text name="save_con[keywords]" value="{$radio_config['keywords']}" size=60>" );
echo <<<HTML
</table>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Настройка вывода баннера в модальном окне радиостанции</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
HTML;
showRow( "Показывать баннер в всплывающем окне?:", "", makeDropDown( array ("yes" => "Да", "no" => "Нет" ), "save_con[banner]", "{$radio_config['banner']}" ) );
showRow( "Код баннера:", "HTML код баннера", "<textarea rows="4" style="width:98%; padding:3px;" name="save_con[banner_code]" class="bk">{$radio_config[banner_code]}</textarea>" );
if( !is_writable(ENGINE_DIR . '/data/radio_config.php' )) {
$lang['stat_system'] = str_replace ("{file}", "engine/data/radio_config.php", $lang['stat_system']);
$fail = "<br /><br /><div class="ui-state-error ek37 ui-corner-all" style="padding:10px;">{$lang['stat_system']}</div>";
} else $fail = "";
echo <<<HTML
<tr>
<td style="padding:10px; text-align: center;" colspan="2"><input type="hidden" name="user_hash" value="$dle_login_hash" /><input type="submit" class="submit" value=" Сохранить " class="buttons">{$fail}</td>
</tr>
</table>
</tr>
</table>
</div></form>
HTML;
echohtmlend();
}
// ********************************************************************************
// Сохранение настроек
// ********************************************************************************
elseif( $action == "save_settings" ) {
$save_con = $_POST['save_con'];
$save_con['work'] = ( isset( $save_con['work'] ) && $save_con['work'] == "on" ? $save_con['work'] = "on" : $save_con['work'] = "off" );
$save_con['banner'] = ( isset( $save_con['banner'] ) && $save_con['banner'] == "yes" ? $save_con['banner'] = "yes" : $save_con['banner'] = "no" );
$save_con['perpage'] = ( isset( $save_con['perpage'] ) ? $save_con['perpage'] = intval( $save_con['perpage'] ) : $save_con['perpage'] = "" );
$save_con['timer'] = ( isset( $save_con['work'] ) ? $save_con['timer'] = intval( $save_con['timer'] ) : $save_con['timer'] = "15" );
$save_con['banner_code'] = $db->safesql( $save_con['banner_code'] );
$find[] = "'r'";
$replace[] = "";
$find[] = "'n'";
$replace[] = "";
$save_con = $save_con + $radio_config;
$handler = fopen( ENGINE_DIR . "/modules/radio/data/config.php", "w" );
fwrite( $handler, "<?PHP nn// Radio Configurationsn// by Elegant Division (http://e-div.com)nn$radio_config = array (n" );
foreach ( $save_con as $name => $value ) {
$value = trim( stripslashes( $value ) );
$value = htmlspecialchars( $value, ENT_QUOTES);
$value = preg_replace( $find, $replace, $value );
$name = trim( stripslashes( $name ) );
$name = htmlspecialchars( $name, ENT_QUOTES );
$name = preg_replace( $find, $replace, $name );
$value = str_replace( "$", "$", $value );
$value = str_replace( "{", "{", $value );
$value = str_replace( "}", "}", $value );
$name = str_replace( "$", "$", $name );
$name = str_replace( "{", "{", $name );
$name = str_replace( "}", "}", $name );
fwrite( $handler, " '{$name}' => "{$value}",n" );
}
fwrite( $handler, ");nn?>" );
fclose( $handler );
msgbox( "", 'Настройки сохранены', '?mod=radio' );
}
########################################################################################
########################################################################################
########################################################################################
// Радиостанции // Радиостанции // Радиостанции // Радиостанции // Радиостанции // Радиостанции
########################################################################################
########################################################################################
########################################################################################
// ********************************************************************************
// Редактирование радиостанции
// ********************************************************************************
elseif( $action == "edit_station" ) {
// begin cat
$radio_cat_info = array();
$cat_list = "";
$cat_found = FALSE;
$db->query ( "SELECT * FROM " . PREFIX . "_radio_cat ORDER BY posi ASC, id ASC" );
while ( $row = $db->get_row () ) {
$cat_found = TRUE;
$cat_list .= "<option value="" . intval( $row['id'] ) . "">" . stripslashes( $row['name'] ) . "</option>";
$radio_cat_info[$row['id']] = array();
foreach ( $row as $key => $value ) {
$radio_cat_info[$row['id']][$key] = stripslashes ( $value );
}
}
if( $cat_found == FALSE ) $cat_list = "<option value="">-- Создайте категории --</option>";
$cat_list = "<select name="category" style="width: 160px; margin: 4px 0;">" . $cat_list . "</select>";
$db->free ();
function cur_cat($category = 0) {
global $radio_cat_info;
foreach ( $radio_cat_info as $id => $category_name ) {
$returnstring .= "<option value="" . $id . '" ';
if( $category == $id ) $returnstring .= 'selected = "selected"';
$returnstring .= '>' . $category_name["name"] . '</option>';
}
$cat_list = "<select name="category" style="width: 160px; margin: 4px 0;">" . $returnstring . "</select>";
return $cat_list;
}
// end cat
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_radio WHERE id = '$id'" );
top_menu( "radio_edit" );
$row['name'] = stripslashes( preg_replace( array ("'"'", "'''" ), array (""", "'" ), $row['name'] ) );
$row['descr'] = stripslashes( $row['descr'] );
$server = "<select id="server" name="server" style="width: 120px; margin: 0 6px 0 0; padding: 2px;"><option value="0" disabled="disabled">-- Выберите сервер --</option>";
if( $row['server'] == 0 ) $server .= "<option value="0" selected="selected">Непонятно</option>"; else $server .= "<option value="0">Непонятно</option>";
if( $row['server'] == 1 ) $server .= "<option value="1" selected="selected">SHOUTcast</option>"; else $server .= "<option value="1">SHOUTcast</option>";
if( $row['server'] == 2 ) $server .= "<option value="2" selected="selected">IceCast</option>"; else $server .= "<option value="2">IceCast</option>";
if( $row['server'] == 3 ) $server .= "<option value="3" selected="selected">Steamcast</option>"; else $server .= "<option value="3">Steamcast</option>";
$server .= "</select>";
$work = ( $row['work'] == "1" ? "<option value="1" selected="selected">Да</option><option value="0">Нет</option>" : "<option value="1">Да</option><option value="0" selected="selected">Нет</option>" );
$lastfm = ( $row['lastfm'] == "1" ? "<option value="1" selected="selected">Да</option><option value="0">Нет</option>" : "<option value="1">Да</option><option value="0" selected="selected">Нет</option>" );
$playnow = ( $row['playnow'] == "1" ? "<option value="1" selected="selected">Да</option><option value="0">Нет</option>" : "<option value="1">Да</option><option value="0" selected="selected">Нет</option>" );
$del_cover = ( $row['cover'] ? " <label for="del_cover"><input type="checkbox" value="yes" name="del_cover" id="del_cover">Удалить логотип?</label>" : "" );
$coverbg = ( $row['cover'] ? "<img src="" . $config['home_url'] . "uploads/radio/" . $row['cover'] . "">" : "" );
$cat_list = cur_cat( $row['category'] );
echo <<<HTML
<form method="post" action="" id="edit_station" enctype="multipart/form-data">
<div style="padding-top:5px;padding-bottom:2px; position: relative;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Редактирование</div></td>
</tr>
</table>
{$coverbg}
<div class="unterline"></div>
<table width="100%" class="addstation">
<tr>
<td width="260" style="padding:4px;">Название радиостанций:</td>
<td><input class="edit bk" type="text" name="name" size="40" value="{$row['name']}" /><br /><span class=small>пример: <b>Русское Радио</b></span></td>
</tr>
<tr>
<td style="padding:4px;">{$lang['cat_url']}</td>
<td><input class="edit bk" type="text" name="alt_name" size="40" value="{$row['alt_name']}" /><br /><span class=small>пример: <b>russkoe-radio</b></span></td></td>
</tr>
<tr>
<td style="padding:4px;">IP и порт сервера:</td>
<td>{$server}<input class="edit bk" type="text" name="station_url" value="{$row['stream']}" size="40" />
<br /><span class="small smes"></span></td>
</tr>
<tr>
<td style="padding:4px;">Битрейт:</td>
<td><input class="edit bk" type="text" name="bitrate" size="5" value="{$row['bitrate']}" /> kbps<br /><span class=small>пример: <b>128</b></span></td>
</tr>
</table>
<table width="100%" class="addstation addon" style="display: none;">
<tr>
<td width="260" style="padding:4px;">Парсить название исполнителя и трека:</td>
<td><select name="playnow" size="1">{$playnow}</td>
</tr>
<tr><td background="engine/skins/images/mline.gif" colspan="2" style="padding: 0; height: 1px;"></td></tr>
<tr>
<td style="padding:4px;">Парсить информацию о исполнителе:<br/><span class=small>Информация с сайта Last.fm</span></td>
<td><select name="lastfm" size="1">{$lastfm}</select></td>
</tr>
<tr><td background="engine/skins/images/mline.gif" colspan="2" style="padding: 0; height: 1px;"></td></tr>
</table>
<table width="100%" class="addstation">
<tr>
<td width="260" style="padding:4px;">Радиостанция работает?</td>
<td><select name="work" size="1">{$work}</select></td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;">Категория:</td>
<td>{$cat_list}</td>
</tr>
<tr>
<td style="padding:4px;">Описание:</td>
<td><textarea class="bk" name="descr" style="width:98%; padding:3px;" rows="2">{$row['descr']}</textarea><br/><span class=small>Только текст, до 255 символов, без html/bbcode!</span></td>
</tr>
<tr>
<td style="padding:4px;">Логотип радиостанции:</td>
<td><input type="file" name="cover" size="26">{$del_cover}<br/><span class=small>Поддерживаются форматы JPG, PNG и GIF, с размером до 500kb</span></td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;"> </td>
<td>
<input type="submit" class="submit" value="Сохранить" />
<input type="hidden" name="action" value="station_doedit" />
<input type="hidden" name="user_hash" value="{$dle_login_hash}" />
<input type="hidden" name="id" value="{$row[id]}" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div></form>
HTML;
echohtmlend();
}
// ********************************************************************************
// Добавление / редактирование радиостанции
// ********************************************************************************
elseif( $action == "add_station" OR $action == "station_doedit" ) {
if ( isset( $_REQUEST['station_url'] ) AND preg_match( "/^[0-9a-zA-Z_-/:.]*$/i", trim($_REQUEST['station_url'] ))) $station_url = $_REQUEST['station_url']; else $station_url = '';
$name = $db->safesql( htmlspecialchars( strip_tags( stripslashes($_POST['name'] ) ), ENT_QUOTES) );
$alt_name = totranslit( stripslashes( $_POST['alt_name'] ), true, false );
$radio_id = intval( $_POST['id'] );
if( $action == "add_station" ) {
$row = $db->super_query( "SELECT alt_name FROM " . PREFIX . "_radio WHERE alt_name ='{$alt_name}'" );
if( $row['alt_name'] ) msgbox( "error", "Радиостанция с таким названием уже существует", "?mod=radio" );
} elseif( $action == "station_doedit" AND $radio_id ) {
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_radio WHERE alt_name = '{$alt_name}'" );
if( $row['id'] and $row['id'] != $radio_id ) msgbox( "error", "Выбраной радиостанции не существует", "javascript:history.go(-1)" );
} else die("error");
$description = $db->safesql( substr( strip_tags( stripslashes( $_POST['descr'] ) ), 0, 255 ) );
$server = intval( $_POST['server'] );
$category = ( $_POST['category'] > 0 ? $category = intval( $_POST['category'] ) : $category = "0" );
$bitrate = ( $_POST['bitrate'] > 0 ? $bitrate = intval( $_POST['bitrate'] ) : $bitrate = "" );
$playnow = ( $_POST['playnow'] == "1" ? $playnow = "1" : $playnow = "0" );
$lastfm = ( $_POST['lastfm'] == "1" ? $lastfm = "1" : $lastfm = "0" );
$work = ( $_POST['work'] == "1" ? $work = "1" : $work = "0" );
// Cover
$cover = $_FILES['cover']['tmp_name'];
$cover_name = $_FILES['cover']['name'];
$cover_size = $_FILES['cover']['size'];
$cover_name_arr = explode( ".", $cover_name );
$type = totranslit(end( $cover_name_arr ));
if( $cover_name != "" ) $cover_name = totranslit( stripslashes( $cover_name_arr[0] ) ) . "." . $type;
if( stripos ( $cover_name, "php" ) !== false ) die("Hacking attempt!");
$file_prefix = rand( 1000, 9999 ) . "_";
if( is_uploaded_file( $cover ) ) {
if( $cover_size < 500000 ) {
$allowed_extensions = array ("jpg", "png", "jpe", "jpeg", "gif" );
if( in_array( $type, $allowed_extensions ) AND $cover_name ) {
include_once ENGINE_DIR . '/classes/thumb.class.php';
$res = @move_uploaded_file( $cover, ROOT_DIR. "/uploads/radio/temp_" . $file_prefix . $alt_name . "." . $type );
if( $res ) {
@chmod( ROOT_DIR. "/uploads/radio/temp_" . $file_prefix . $alt_name . "." . $type, 0666 );
$thumb = new thumbnail( ROOT_DIR. "/uploads/radio/temp_" . $file_prefix . $alt_name . "." . $type );
if( $thumb->size_auto( $radio_config['cover'] ) ) {
$thumb->jpeg_quality(95);
$thumb->save( ROOT_DIR. "/uploads/radio/" . $file_prefix . $alt_name . "." . $type );
} else {
@rename(ROOT_DIR. "/uploads/radio/temp_" . $file_prefix . $alt_name . "." . $type, ROOT_DIR. "/uploads/radio/" . $file_prefix . $alt_name . "." . $type );
}
@chmod( ROOT_DIR. "/uploads/radio/" . $file_prefix . $alt_name . "." . $type, 0666 );
$cover_name = $file_prefix . $alt_name . "." . $type;
if( $row['cover'] ) @unlink( ENGINE_DIR . "/uploads/radio/" . totranslit($row['cover']) );
} else msgbox( "error", "Произошла ошибка при загрузки логотипa.", "javascript:history.go(-1)" );
} else msgbox( "error", "К загрузке разрешены только файлы с расширением JPG, PNG или GIF.", "javascript:history.go(-1)" );
} else msgbox( "error", "Максимальный размер логотипa не должен превышать 500 Kb.", "javascript:history.go(-1)" );
@unlink( ROOT_DIR. "/uploads/radio/temp_" . $file_prefix . $alt_name . "." . $type );
}
if( $action == "add_station" ) {
$db->query( "INSERT INTO " . PREFIX . "_radio (name, alt_name, descr, category, stream, server, bitrate, playnow, lastfm, work, cover) values ('$name', '$alt_name', '$description', '$category', '$station_url', '$server', '$bitrate', '$playnow', '$lastfm', '$work', '$cover_name')" );
msgbox( "Информация", "Радиостанция добавлена", "?mod=radio" );
} elseif( $action == "station_doedit" AND $radio_id ) {
// delete cover
if( $_POST['del_cover'] == "yes" ) {
@unlink( ROOT_DIR. "/uploads/radio/" . totranslit($row['cover']) );
$db->query( "UPDATE " . PREFIX . "_radio set cover='' WHERE id = '{$radio_id}'" );
}
if($cover_name AND $_POST['del_cover'] != "yes" ) $cover_name = $row['cover'];
$db->query( "UPDATE " . PREFIX . "_radio set name='$name', alt_name='$alt_name', descr='$description', category='$category', stream='$station_url', server='$server', bitrate='$bitrate', playnow='$playnow', lastfm='$lastfm', work='$work', cover='$cover_name' WHERE id='{$radio_id}'" );
msgbox( "Информация", "Радиостанция отредактирована", "?mod=radio" );
} else die("error");
}
// ********************************************************************************
// Сортировка радиостанции
// ********************************************************************************
elseif( $action == "sort_station" ) {
foreach ( $_POST["posi"] as $id => $posi ) {
if( $posi != "" ) {
$posi = intval( $posi );
$id = intval( $id );
$db->query( "UPDATE " . PREFIX . "_radio SET posi='{$posi}' WHERE id = '{$id}'" );
}
}
header( "Location:?mod=radio" );
}
// ********************************************************************************
// Удаление radio
// ********************************************************************************
elseif( $action == "remove_station" ) {
if( ! $id ) msg( "error", $lang['cat_error'], $lang['cat_noid'], "$PHP_SELF?mod=radio" );
$db->query( "DELETE FROM " . PREFIX . "_radio WHERE id='$id'" );
msgbox( "Информация", "Радиостанция удалена!", "?mod=radio" );
}
// ********************************************************************************
// Список радиостанций
// ********************************************************************************
else {
top_menu( "radio" );
// begin cat
$radio_cat_info = array();
$cat_list = "";
$cat_found = FALSE;
$db->query ( "SELECT * FROM " . PREFIX . "_radio_cat ORDER BY posi ASC, id ASC" );
while ( $row = $db->get_row () ) {
$cat_found = TRUE;
$cat_list .= "<option value="" . intval( $row['id'] ) . "">" . stripslashes( $row['name'] ) . "</option>";
$radio_cat_info[$row['id']] = array();
foreach ( $row as $key => $value ) {
$radio_cat_info[$row['id']][$key] = stripslashes ( $value );
}
}
if( $cat_found == FALSE ) $cat_list = "<option value="">-- Создайте категории --</option>";
$cat_list = "<select name="category" style="width: 180px; margin: 4px 0;">" . $cat_list . "</select>";
$db->free ();
// end cat
$server = "<select name="server" style="margin: 0 6px 0 0; padding: 2px;" id="server"><option value="0" disabled="disabled">-- Выберите сервер --</option><option value="0">Непонятно</option><option value="1">SHOUTcast</option><option value="2">IceCast</option><option value="3">Steamcast</option></select>";
echo <<<HTML
<form method="post" action="" id="add_station" enctype="multipart/form-data">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Добавление радиостанции</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td width="260" style="padding:4px;">Название радиостанций:</td>
<td><input class="edit bk" type="text" name="name" size="40" /><br /><span class=small>пример: <b>Русское Радио</b></span></td>
</tr>
<tr>
<td style="padding:4px;">Альтернативное имя:</td>
<td><input class="edit bk" type="text" name="alt_name" size="40" /><br /><span class=small>пример: <b>russkoe-radio</b></span></td></td>
</tr>
<tr>
<td style="padding:4px;">IP и порт сервера:</td>
<td>{$server} <input class="edit bk" type="text" name="station_url" value="http://" size="40" />
<br /><span class="small smes"></span></td>
</tr>
<tr>
<td style="padding:4px;">Битрейт:</td>
<td><input class="edit bk" type="text" name="bitrate" size="5" /> kbps<br /><span class=small>пример: <b>128</b></span></td>
</tr>
</table>
<table width="100%" class="addstation addon" style="display: none;">
<tr>
<td width="260" style="padding:4px;">Парсить название исполнителя и трека:</td>
<td><select name="playnow" size="1"><option value="1">Да</option><option value="0">Нет</option></td>
</tr>
<tr>
<td style="padding:4px;">Парсить информацию о исполнителе:<br/><span class=small>Информация с сайта Last.fm</span></td>
<td><select name="lastfm" size="1"><option value="1">Да</option><option value="0">Нет</option></select></td>
</tr>
</table>
<table width="100%" class="addstation">
<tr>
<td width="260" style="padding:4px;">Радиостанция работает?</td>
<td><select name="work" size="1"><option value="1">Да</option><option value="0">Нет</option></select></td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;">Категория:</td>
<td>{$cat_list}</td>
</tr>
<tr>
<td style="padding:4px;">Описание:</td>
<td><textarea class="bk" name="descr" style="width:98%; padding:3px;" rows="2"></textarea><br/><span class=small>Только текст, до 255 символов, без html/bbcode!</span></td>
</tr>
<tr>
<td style="padding:4px;">Логотип радиостанции:</td>
<td><input type="file" name="cover" size="26"><br/><span class=small>Поддерживаются форматы JPG, PNG и GIF, с размером до 500kb</span></td>
</tr>
<tr>
<td colspan="2"><div class="hr_line"></div></td>
</tr>
<tr>
<td style="padding:4px;"> </td>
<td>
<input type="submit" class="submit" value="Добавить радиостанцию" />
<input type="hidden" name="mod" value="radio" />
<input type="hidden" name="user_hash" value="$dle_login_hash" />
<input type="hidden" name="action" value="add_station" /></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div></form>
<script language="javascript" type="text/javascript">
<!--
var windowSizeArray = [ "width=540,height=500,scrollbars=yes" ];
$(document).ready(function(){
$(".play a").click(function (event){
var url = $(this).attr("href");
var windowName = "popUp";//$(this).attr("name");
window.open(url, windowName, windowSizeArray);
event.preventDefault();
});
});
-->
</script>
<form method="post" action="">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Список радиостанций</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td style="padding:2px;" width="40">ID</td>
<td style="padding:2px;" width="60">Position</td>
<td>Радиостанция</td>
<td>Альт.:</td>
<td>Категория:</td>
<td style="text-align: center; width: 90px;">Просмотров</td>
<td style="text-align: center; width: 90px;">Работает?</td>
<td style="text-align: center; width: 120px;">Действие:</td>
</tr>
<tr>
<td colspan="8"><div class="hr_line"></div></td>
</tr>
HTML;
$station_found = FALSE;
$db->query( "SELECT * FROM " . PREFIX . "_radio ORDER BY work ASC, posi ASC" );
while ( $row = $db->get_row() ) {
$station_found = TRUE;
if( $config['allow_alt_url'] == "yes" ) $link = "<a class="list" href="" . $config['home_url'] . "playradio/" . $row['alt_name'] . ".html">" . stripslashes( $row['name'] ) . "</a>";
else $link = "<a class="list" href="" . $config['home_url'] . "system/modules/radio/radio.php?radio=" . $row['alt_name'] . "">" . stripslashes( $row['name'] ) . "</a>";
$work = ( $row['work'] == "1" ? "<span style="color: green;">да</span>" : "<span style="color: red;">нет</span>" );
$cat = ( $row['category'] ? "<a href="?mod=radio&action=edit&id=" . intval( $row['category'] ) . "">" . stripslashes( $radio_cat_info[intval($row['category'])]['name'] ) . "</a>" : "---" );
echo "<tr class="bj">
<td height="22"> <b>" . $row['id'] . "</b></td>
<td><input class="edit" type="text" size="5" name="posi[{$row['id']}]" maxlength="5" value="{$row['posi']}"></td>
<td class="play{$link}</td>
<td>" . $row['alt_name'] . "</td>
<td>{$cat}</td>
<td style="text-align: center;">" . $row['views'] . "</td>
<td style="text-align: center;">" . $work . "</td>
<td class="list"><nobr>[<a href="?mod=radio&action=edit_station&id=" . $row['id'] . "">Ред.</a>] [<a class="delete_me maintitle" href="?mod=radio&user_hash=" . $dle_login_hash . "&action=remove_station&id=" . $row['id'] . "">Уд.</a>]</nobr></td>
</tr> ";
}
$db->free();
if( $station_found ) {
echo <<<HTML
<tr>
<td colspan="8" style="padding:5px;"><input type="hidden" name="action" value="sort_station"><input type="submit" id="posi" class="submit" value="Отсортировать радиостанции" /></td>
</tr>
HTML;
} else {
echo <<<HTML
<tr><td colspan="8"><table width="100%">
<tr>
<td height="100" align="center"><b>Радиостанции нет</b></td>
</tr>
</table></td></tr>
HTML;
}
echo <<<HTML
</table>
</td>
</tr>
</table>
</div></form>
HTML;
htmlclear();
echohtmlend();
}
?>