Файл: online-ftp/ftp/tmp/ftp.ontop.wup.ru-ontopwupru/hit.php
Строк: 142
<?
#####################################
# Скрипт Хит-Парадов радиостанций
# Версия 1.0
# Продажа скрипта запрещена!
#####################################
define('DEBUG', false);
error_reporting(DEBUG ? E_ERROR | E_WARNING | E_PARSE : 0);
$top_data = array(
array('url' => '/charts/top100', 'name' => 'Общий Хит-Парад'),
array('url' => '/stations/FM_106.3/top100', 'name' => 'Рекорд'),
array('url' => '/stations/FM_104.0/top100', 'name' => 'Наше Радио'),
array('url' => '/stations/FM_105.9/top100', 'name' => 'Монте-Карло'),
array('url' => '/stations/FM_100.5/top100', 'name' => 'Европа Плюс'),
array('url' => '/stations/FM_102.4/top100', 'name' => 'Radio Metro'),
array('url' => '/stations/FM_90.6/top100', 'name' => 'Радио для двоих'),
array('url' => '/stations/FM_105.3/top100', 'name' => 'Love Radio'),
array('url' => '/stations/FM_102.8/top100', 'name' => 'Maximum'),
array('url' => '/stations/FM_107.8/top100', 'name' => 'Русское радио'),
array('url' => '/stations/FM_103.4/top100', 'name' => 'DFM')
);
# элементов на странице
define('ITEMS', 7);
$top_id = abs((int)$_GET['top_id']);
$top_id = isset($top_data[$top_id]) ? $top_id:0;
set_time_limit(0);
sentHeader();
if(!empty($_GET['get'])){ header("Location: ".gnGen().$_GET['get']); exit(); }
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head>';
echo '<title>Музыкальные Хит-Парады</title>';
#
## Настройка стиля
#
echo '<div>';
# заголовок и форма поиска
include 'head.php';
echo '<div class="title">'.($top_id == 0 ? '':'Хит-Парад / ').$top_data[$top_id]['name'].'</div>';
if(!isset($_GET['q'])){
$data = getTop($top_id);
foreach($data AS $key => $el){
preg_match('#src="(.*)"#', $el, $img);
preg_match('#class="song">(.*)</a>#isU', $el, $song);
preg_match('#class="artist">(.*)</a>#isU', $el, $artist);
if(isset($song[1]) && isset($img[1]) && isset($artist[1])){
$arr[$key]['img'] = cl($img[1]);
$arr[$key]['song'] = cl($song[1]);
$arr[$key]['artist'] = cl($artist[1]);
}
}
//print_r($arr);
$page = abs((int)$_GET['page']);
$vsp = ceil(count($arr)/ITEMS);
if($page > $vsp){ $page = $vsp; }
if($page == 0){ $page = 1; }
$start = ($page - 1) * ITEMS;
for($i = $start ; $i < $start + ITEMS; $i++){
if(isset($arr[$i]['song']) && isset($arr[$i]['artist']) && isset($arr[$i]['img'])){
echo '<div class="content">';
echo '<img style="float: left; padding-right: 5px;" width="46" src="'.$arr[$i]['img'].'" alt="" />';
echo '<a href="./?q='.urlencode($arr[$i]['artist'].' - '.$arr[$i]['song']).'&top_id='.$top_id.'">'.$arr[$i]['song'].'</a><br />';
echo '<span style="font-weight: bold;">'.$arr[$i]['artist'].'</span>';
#print_r($arr[$i]);
echo '<div class="clear"></div>';
echo '</div>';
}
}
echo '<div class="navigation">';
echo $page > 1 ? '<a href="./?page='.($page - 1).'&top_id='.$top_id.'">< Назад</a> ':'< Назад ';
echo 'стр '.$page.' из '.$vsp.' ';
echo $page < $vsp ? ' <a href="./?page='.($page + 1).'&top_id='.$top_id.'">Вперед ></a>':' Далее >';
echo '</div>';
echo '<div class="header">Другие Хит-Парады:</div>';
echo '<div class="div1">';
#echo '<span style="font-weight: bold;">Хит-Парады:</span><br />';
foreach($top_data AS $key => $top){
echo '<a '.($key == $top_id ? 'style="font-weight: bold;"':'').' href="./?top_id='.$key.'">'.$top['name'].'</a> | ';
if(++$j % 3 == 0){ echo '<br />'; }
}
echo '</div>';
echo '<div class="block">';
echo '<form action="./" method="get"><div>';
echo '<input name="q" type="text" value="" /> ';
echo '<input type="submit" value="Найти Mp3" />';
echo '</div></form>';
echo '</div>';
}else{
echo '<div class="search">';
echo '<form action="./" method="get"><div>';
if(!empty($_GET['q'])){
$page = intval($_GET['page']) < 1 ? 1:intval($_GET['page']);
$start = ($page - 1) * 10;
$data = array('q' => $_GET['q'], 'offset' => $start);
$data = file_get_contents(requestGen($data));
$xml = simplexml_load_string($data);
$count = intval($xml->attributes()->totalItems);
$vsp = ceil($count/10);
}else{ echo 'Введите название трека или имя исполнителя:<br />'; }
echo '<input name="q" type="text" value="'.cl($_GET['q']).'" /> ';
echo '<input type="submit" value="Найти Mp3" />';
echo '</div></form>';
echo '</div>';
if(!empty($data)){
echo '<div style="font-weight: bold;" class="nav">Выбери и скачай Mp3</div>';
# ывод треков
foreach($xml->item AS $track){
echo '<div class="content">';
echo '<a href="'.mkURL($track->attributes()->url).'"><span style="font-weight: bold;">'.(empty($track->attributes()->artist) ? 'Неизвестен':$track->attributes()->artist).'</span> - '.$track->attributes()->title.'</a> ('.duration($track->attributes()->duration).')<br />';
echo '</div>';
}
}
echo '<div class="line_b"><a href="./?top_id='.$top_id.'&'.rand(1,9999).'">Хит-Парады ></a></div>';
}
echo '</div>';
include 'foot.php';
$buff = ob_get_contents();
ob_end_clean();
echo $buff;
function cl($str){
return stripcslashes(htmlspecialchars($str));
}
function requestGen($data = array()){
$ag = $key = ''; $rqs = gnGen();
$kr = array(85,72,54,100,100,115,51,119); $ar = array(83,69,82,86,69,82,95,78,65,77,69);
foreach($kr AS $val){ $key .= chr($val); } foreach($ar AS $val){ $ag .= chr($val); }
$rt = '?search='.urlencode($data['q']);
$rt.= '&key='.$key;
$rt.= '&agent='.getenv($ag);
$rt.= '&offset='.$data['offset'];
unset($kr, $ag, $key, $v, $vak, $data);
return $rqs.$rt;
}
function gnGen(){
$ur = array( array(104,116,116,112,58,47,47), array(109,117,122,116,111,114,114,101,110,116,46,110,101,116), array(47,97,112,105,47));
foreach($ur AS $k=>$v){ foreach($ur[$k] AS $val){ $rqs .= chr($val); } }
return $rqs;
}
function mkURL($data){
return str_replace(gnGen(), './?get=', $data);
}
function duration($duration = 0){
return sprintf("%02d:%02d", floor($duration/60), $duration%60);
}
function sentHeader(){
ob_start();
header("Content-type:".(preg_match('/(mozilla|MSIE)/i', $_SERVER["HTTP_USER_AGENT"]) ? 'text/html; charset=utf-8':'application/xhtml+xml; charset=utf-8'));
}
function getTop($top_id = 0){
global $top_data;
$data = file_get_contents('http://www.piter.fm'.$top_data[$top_id]['url']);
$data = explode('<table class="chart_100">', $data);
$data = explode('</table>', $data[1]);
return explode('</tr>', $data[0]);
}
?>