Файл: system/modules/radio/radio.php
Строк: 96
<?PHP
#==========================================
# DLE Radio v.1
#==========================================
# author: Elegant Division
# url: http://e-div.com
# e-mail: info@e-div.com
#==========================================
@session_start();
@ob_start();
@ob_implicit_flush(0);
@error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
define('MOZG', true);
define('ROOT_DIR', dirname (__FILE__));
define('ENGINE_DIR', ROOT_DIR.'/system');
header('Content-type: text/html; charset=windows-1251');
// settings
require ENGINE_DIR . "/data/config.php";
require ENGINE_DIR . "/modules/radio/data/config.php";
if ($config['home_url'] == "") {
$config['home_url'] = explode ( "system/modules/radio/radio.php", $_SERVER['PHP_SELF'] );
$config['home_url'] = reset ( $config['home_url'] );
$config['home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['home_url'];
}
require_once ENGINE_DIR . "/classes/mysql.php";
require_once ENGINE_DIR . "/data/db.php";
require_once ENGINE_DIR . "/modules/functions.php";
require_once ENGINE_DIR . "/classes/templates.php";
if( $radio_config['work'] == "off" ) {
echo "Модуль временно отключён!";
}else
if ( isset( $_REQUEST['radio'] )) $radio_url = @$db->safesql ( strip_tags ( str_replace ( '/', '', urldecode ( $_REQUEST['radio'] ) ) ) ); else $radio_url = '';
if(! $radio_url ) die( "Hacking attempt!" );
if( preg_match( "/[||'|<|>|"|!|?|$|@|/|\|&~*+]/", $radio_url ) ) die("Not allowed user radio url!");
#####################################################################
// SQL
if( $radio_url == "random" ) $radio_sql = " ORDER by RAND()";
else $radio_sql = " AND alt_name = '" . $radio_url . "'";
$row = $db->super_query( "SELECT * FROM " . PREFIX . "_radio WHERE work='1'" . $radio_sql );
// check if radio exist
if( !$row['id'] ) die( "Выбранная радиостанция не существует или отключена!" );
// update views
$db->query( "UPDATE " . PREFIX . "_radio SET views=views+1 WHERE id='" . intval( $row['id'] ) . "'" );
$tpl->load_template( "radio/radio.tpl" );
$PHP_SELF = $config['home_url'] . "index.php";
if( $row['descr'] ) $tpl->set( "{descr}", stripslashes( $row['descr'] ));
else $tpl->set( "{descr}", "" );
// category
if( $row['category'] > 0 ) {
$radio_cat_info = get_vars ( "radio_cat" );
if ( !is_array ( $radio_cat_info )) {
$radio_cat_info = array();
$db->query ( "SELECT * FROM " . PREFIX . "_radio_cat ORDER BY posi ASC" );
while ( $row = $db->get_row () ) {
$radio_cat_info[$row['id']] = array();
foreach ( $row as $key => $value ) $radio_cat_info[$row['id']][$key] = stripslashes( $value );
}
set_vars ( "radio_cat", $radio_cat_info );
$db->free ();
}
$tpl->set( "{cat}", stripslashes( $radio_cat_info[intval( $row['category'] )]['name'] ));
} else $tpl->set( "{cat}", "" );
if( $row['bitrate'] ) $tpl->set( "{bitrate}", intval( $row['bitrate'] ) . " kbps" );
else $tpl->set( "{bitrate}", "" );
$tpl->set( "{rand-link}", $config['home_url'] . "system/modules/radio/radio.php?radio=random" );
// Banner
if( $radio_config['banner'] == "yes" AND $radio_config['banner_code'] ) {
$tpl->set( "{banner}", htmlspecialchars_decode( str_replace( """, """, $radio_config['banner_code'] ), ENT_NOQUOTES ));
} else $tpl->set( "{banner}", "<a href="$PHP_SELF?go=feedback" target="_blank"><img src="{theme}/radio/files/banner.jpg" alt="" /></a>" );
// play now
$server_url = stripslashes( $row['stream'] );
$row['playnow'] = intval( $row['playnow'] );
$row['lastfm'] = intval( $row['lastfm'] );
$row['server'] = intval( $row['server'] );
if( $row['server'] == 1 ) $server = "/;stream.nsv&type=mp3"; // SHOUTcast
elseif( $row['server'] == 2 ) $server = ""; // IceCast
//elseif( $row['server'] == 3 ) $server = ""; // Steamcast
else $server = "";
if( $row['playnow'] == "1" AND $row['server'] == "1" ) {
$playnow = "<h2 id="song">Загрузка...</h2>";
// Last.fm info
if( $row['lastfm'] == "1" ) {
$lastfm_cover = "<div class="cover"><b></b><img src="{theme}/nocover.jpg" alt="No cover" /></div>";
$lastfm_bio = "Информация отсутствует";
} else {
$lastfm_cover = "";
$lastfm_bio = "";
}
if( $radio_config['timer'] ) $radio_config['timer'] = "15";
$head .= "<script type="text/javascript" src="{$config['home_url']}templates/Default/radio/files/parser.js"></script>";
} else {
$playnow = "";
$lastfm_cover = "";
$lastfm_bio = "";
$js = "";
}
$tpl->set( "{header}", $head . $js );
$tpl->set( "{station}", stripslashes( $row['name'] ) );
$tpl->set( "{playnow}", $playnow );
$tpl->set( "{cover}", $lastfm_cover );
$tpl->set( "{bio}", $lastfm_bio );
$tpl->set( "{stream}", $server_url . $server );
$tpl->compile( 'content' );
$tpl->result['content'] = str_replace( '{theme}', $config['home_url'] . 'templates/Default/radio/files', $tpl->result['content'] );
echo $tpl->result['content'];
$db->free();
?>