Файл: test.masteram.us/audio/index.php
Строк: 219
<?
include '../Core.php';
include_once 'config.php';
#### Аудио альбомы
if (isset($_GET['act'])) {$act = power($_GET['act']);} else {$act = 'index';}
switch ($act):
### Главная страница
case "index":
$set['title']=''.$ln['audio'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
$set['p_str']=20;
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> '.$ln['audio'].'<br/>';
echo'</div>';
echo'<div class="mess">';
$new =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `time`>'".$time."'-86400"),0);
$new = ($new>0) ? '<span style="color:#ff0000">+'.$new.'</span>' : '';
echo'<img src = "img/new.png" alt="!"> <a href="index.php?act=new">'.$ln['new'].'</a> '.$new.'<br/>';
$k_post =mysql_result(mysql_query("SELECT count(*) FROM `audio_cat`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo ''.$ln['null'].'';}
$q=mysql_query("SELECT * FROM `audio_cat` ORDER BY `num` DESC LIMIT " . $start . ", " . $set['p_str'] . "");
while ($data = mysql_fetch_assoc($q)){
$count =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id_cat`='".$data['id']."'"),0);
echo'<img src = "img/dir.png" alt="!"> <a href = "index.php?act=cat&id='.$data['id'].'">'.$data['name'].'</a> ('.$count.')<br/>';
}
echo'</div>';
### Управление разделами
if (user_access('audio_move_dir') || user_access('audio_add_dir')){
echo'<div class="mess">';
if(user_access('audio_move_dir')){echo'<a href="admin.php?act=index">'.$ln['pr'].'</a><br/>';}
if(user_access('audio_add_dir')){echo'<a href="admin.php?act=dir_add">'.$ln['add'].'</a><br/>';}
echo'</div>';
}
break;
### Новые файлы
case "new":
$set['title']=''.$ln['new'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> '.$ln['new'].'<br/>';
echo'</div>';
echo'<div class="mess">';
$k_post =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `time`>'".$time."'-86400"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo ''.$ln['null'].'';}
$q=mysql_query("SELECT * FROM `audio_file` WHERE `time`>'".$time."'-86400 ORDER BY `time` DESC LIMIT " . $start . ", " . $set['p_str'] . "");
while ($file = mysql_fetch_assoc($q)){
echo'<table><tr><td>';
echo'<img src="img/vk.png">';
echo'</td><td>';
echo' <a href="index.php?act=audio&id='.$file['id'].'">'.$file['artist'].' - '.$file['title'].'</a>';
echo''.$file['dlit'].' ('.size($file['size']).')<br/>';
$raiting = (!empty($file['rated'])) ? round($file['raiting'] / $file['rated'], 1) : 0;
echo '' . voter($raiting) . '<br /><hr>';
echo'</td></tr></table>';
}
echo'</div>';
break;
### Мои файлы
case "my":
$id = intval($_GET['id']);
$ank=get_user($id);
//$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $id LIMIT 1"));
$set['title']=' '.$ank['nick'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> '.$ank['nick'].'<br/>';
echo'</div>';
echo'<div class="mess">';
$k_post =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id_user`='".$id."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo ''.$ln['null'].'';}
$q=mysql_query("SELECT * FROM `audio_file` WHERE `id_user`='".$id."' ORDER BY `time` DESC LIMIT " . $start . ", " . $set['p_str'] . "");
while ($file = mysql_fetch_assoc($q)){
echo'<table><tr><td>';
echo'<img src="img/vk.png">';
echo'</td><td>';
echo' <a href="index.php?act=audio&id='.$file['id'].'">'.$file['artist'].' - '.$file['title'].'</a>';
echo''.$file['dlit'].' ('.size($file['size']).')<br/>';
$raiting = (!empty($file['rated'])) ? round($file['raiting'] / $file['rated'], 1) : 0;
echo '' . voter($raiting) . '<br /><hr>';
echo'</td></tr></table>';
}
echo'</div>';
if ($k_page>1)str('?act=my&id='.$id.'&',$k_page,$page); // Вывод страниц
break;
### Раздел
case "cat":
$id = intval($_GET['id']);
$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'time';
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_cat` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$catalog=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_cat` WHERE `id`= $id LIMIT 1"));
$set['title']=''.$catalog['name'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> '.$catalog['name'].'<br/>';
echo'</div>';
echo'<div class="mess">';
echo'sort: <a href ="?act=cat&id='.$id.'&sort=time">date</a> | <a href ="?act=cat&id='.$id.'&sort=artist">name</a> | <a href ="?act=cat&id='.$id.'&sort=load">total</a><br/>';
$k_post =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id_cat`='".$id."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo ''.$ln['null'].'';}
$q=mysql_query("SELECT * FROM `audio_file` WHERE `id_cat`='".$id."' ORDER BY `time` DESC LIMIT " . $start . ", " . $set['p_str'] . "");
while ($file = mysql_fetch_assoc($q)){
echo'<table><tr><td>';
echo'<img src="img/vk.png">';
echo'</td><td>';
echo' <a href="index.php?act=audio&id='.$file['id'].'">'.$file['artist'].' - '.$file['title'].'</a>';
echo''.$file['dlit'].' ('.size($file['size']).')<br/>';
$raiting = (!empty($file['rated'])) ? round($file['raiting'] / $file['rated'], 1) : 0;
echo '' . voter($raiting) . '<br /><hr>';
echo'</td></tr></table>';
}
echo'<a href="upload.php?dir='.$id.'">[+] </a><br/>';
echo'</div>';
if ($k_page>1)str('?act=cat&id='.$id.'&',$k_page,$page); // Вывод страниц
break;
### Аудио
case "audio":
$id = intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
$set['title']=''.$audio['artist'].' - '.$audio['title'].' '; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
$artist = (isset($audio['artist']) && $audio['artist']>NULL) ? $audio['artist'] : 'Неизвестный';
$title = (isset($audio['title']) && $audio['title']>NULL) ? $audio['title'] : 'Неизвестно';
$albom = (isset($audio['albom']) && $audio['albom']>NULL) ? '<b>Альбом</b>: '.$audio['albom'].'<br/>' : '';
$year = (isset($audio['year']) && $audio['year']>NULL) ? '<b>Год</b>: '.$audio['year'].'<br/>' : '';
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> <b>'.$artist.' - '.$title.'</b><br/>';
echo'</div>';
echo'<div class="mess">';
echo '<b></b>: '.$artist.'<br/>';
echo '<b></b>: '.$title.'<br/>';
echo $albom;
echo $year;
echo'<object type="application/x-shockwave-flash" data="player_mp3_maxi.swf" width="240" height="20">
<param name="FlashVars" value="mp3=files/'.$id.'.mp3&width=240&volume=100&volume=50&showvolume=1&buttonwidth=20&sliderheight=8&volumewidth=50&volumeheight=8&loadingcolor=c2c2c2&bgcolor1=919191&bgcolor2=1a1a1a&slidercolor1=c2c2c2&slidercolor2=919191&sliderovercolor=ffffff&buttoncolor=c2c2c2&buttonovercolor=ffffff" />
</object><br/>';
echo '<b></b>: '.$audio['dlit'].'<br />';
echo '<b></b>: '.$audio['kanal'].'<br/>';
echo '<b></b>: '.$audio['chastota'].'<br/>';
$ank = get_user($audio['id_user']);
//$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $audio[id_user] LIMIT 1"));
echo '<b>'.$ln['add'].'</b>: '.$ank['nick'].'<br/>';
echo '<b>time</b>: '.vremja($audio['time']).'<br/>';
$raiting = (!empty($audio['rated'])) ? round($audio['raiting'] / $audio['rated'], 1) : 0;
echo '<b></b>: ' . voter($raiting) . '<br />';
if (isset($user)) {
echo '<form action="index.php?act=vote&id='.$id.'" method="post">';
echo '<select name="score">';
echo '<option value="5">5</option>';
echo '<option value="4">4</option>';
echo '<option value="3">3</option>';
echo '<option value="2">2</option>';
echo '<option value="1">1</option>';
echo '</select>';
echo '<input type="submit" value="OK" /></form>';
}
echo '<img src = "img/save.gif"> <a href="?act=load&id='.$audio['id'].'">Скачать MP3 ('.size($audio['size']).'; '.$audio['bitreit'].')</a><br/>';
echo'</div>';
### Управление разделами
if(user_access('audio_edit_file') || user_access('audio_del_file') || $user['id']==$audio['id_user']){
echo'<div class="str">';
echo'Управление:';
echo'</div>';
echo'<div class="mess">';
if(user_access('audio_edit_file') || $user['id']==$audio['id_user']){echo'<a href="index.php?act=edit&id='.$audio['id'].'">Редактирование тегов</a><br/>';}
if(user_access('audio_del_file') || $user['id']==$audio['id_user']){echo'<a href="index.php?act=del&id='.$audio['id'].'">Удаление композиции</a><br/>';}
//echo'<a href="admin.php?act=dir_add">Создать папку</a><br/>';
echo'</div>';
}
break;
### голосование
case 'vote':
$id = intval($_GET['id']);
if (isset($_POST['score'])) {$score = abs(intval($_POST['score']));} else {$score = 0;}
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
$des=''.$audio['artist'].' - '.$audio['title'].'!';
include_once '../sys/inc/thead.php';
title();
mysql_query("UPDATE `audio_file` SET `raiting`= `raiting`+'".$score."', `rated`=`rated`+1 WHERE `id` = '$id' LIMIT 1");
echo'<div class="mess">';
echo '<b>OK "' . $score . '" !</b><br />';
echo'</div>';
echo'<a href="index.php?act=audio&id='.$id.'">'.$audio['artist'].' - '.$audio['title'].'</a>';
break;
### Скачать трекккк
case "load":
include_once 'downloadfile.php';
$id = intval($_GET['id']);
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
$name= $audio['artist'].' - '.$audio['title'];
$ras='mp3';
$rass='Addtype audio/mp3';
$size=$audio['size'];
mysql_query("UPDATE `audio_file` SET `load`= `load`+1 WHERE `id` = '$id' LIMIT 1");
DownloadFile(H.'audio/files/'.$audio['id'].'.mp3', $name.'.'.$ras, ras_to_mime($ras));
exit;
break;
### Редактирование
case "edit":
$id = intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
if($user['id']==$audio['id_user'] || user_access('audio_edit_file')){
$set['title']=' '.$audio['artist'].' - '.$audio['title'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
echo'<div class="str">';
echo'<img src = "img/dir_open.png"> <b>'.$audio['artist'].' - '.$audio['title'].'</b><br/>';
echo'</div>';
echo'<div class="mess">';
echo "<form method='post' enctype='multipart/form-data' action='?act=edit_save&id=".$_GET['id']."' >";
echo ":<br />";
echo "<input type='text' name='artist' value='$audio[artist]'><br />n";
echo ":<br />n";
echo "<input type='text' name='title' value='$audio[title]'><br />n";
echo ":<br />n";
echo "<input type='text' name='albom' value='$audio[albom]'><br />n";
echo "<input class='submit' type='submit' value='ok' /><br />n";
echo "</form>";
}else{header("location: /audio/index.php?");}
break;
case "edit_save":
$id = intval($_GET['id']);
$artist=my_esc($_POST['artist']);
$title=my_esc($_POST['title']);
$albom=my_esc($_POST['albom']);
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
if($user['id']==$audio['id_user'] || user_access('audio_edit_file')){
if (utf_strlen($artist) < 300 || utf_strlen($title) < 300 || utf_strlen($albom) < 300){
mysql_query("UPDATE `audio_file` SET `artist`='$artist', `title`='$title', `albom`='$albom' WHERE `id` = '$id' LIMIT 1");
header("Location: index.php?act=audio&id=$id");
}else{header("Location: index.php?act=audio&id=$id&error=64");}
}else{header("Location: index.php?act=audio&id=$id");}
break;
case "del":
$id = intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_file` WHERE `id`= $id LIMIT 1"));
if($user['id']==$audio['id_user'] || user_access('audio_del_file')){
$set['title']=' '.$audio['artist'].' - '.$audio['title'].''; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if(isset($_GET['ok'])){
unlink(H.'audio/files/'.$id.'.mp3');
mysql_query("DELETE FROM `audio_file` WHERE `id` = '$id'");
header("Location: index.php");
}
echo''.$audio['title'].' - '.$audio['title'].'<br/>';
echo "<form method='post' action='?act=del&id=".$id."&ok' >";
echo "<input class='submit' type='submit' value='YES' /> / <a href='index.php?act=audio&id=$id'>NO</a><br/>";
}else{header("Location: index.php?act=audio&id=$id");}
break;
default:
header("location: index.php?");
endswitch;
include_once '../sys/inc/tfoot.php';
?>