Файл: system/modules/audio_player.php
Строк: 256
<?php
/*
Appointment: Музыка
File: audio.php
*/
if($ajax == 'yes')
NoAjaxQuery();
if($ajax == 'yes')
NoAjaxQuery();
$act = $_GET['act'];
$user_id = $user_info['user_id'];
$metatags['title'] = $lang['audio'];
$id = intval($_POST['id']);
$cache_folder = 'user_'.$id;
switch($act){
case "translate":
$aid = intval($_POST['aid']);
//Выводим песню
$row = $db->super_query("SELECT artist, name FROM `".PREFIX."_audio` WHERE aid = '{$aid}'");
if($row){
//Выводим пред. статус
$checkPrevStatus = mozg_cache("user_{$user_id}/old_status");
$checkExp = explode('<audio', $checkPrevStatus);
if(!$checkPrevStatus AND !$checkExp[1]){
$myRow = $db->super_query("SELECT user_status FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
//Если ест пред статус, то сохраняем его в кеш, для воостановления
if($myRow['user_status']){
mozg_create_cache("user_{$user_id}/old_status", $myRow['user_status']);
}
}
$artist = $db->safesql($row['artist']);
$name = $db->safesql($row['name']);
$newStatus = '<div class="staticpl_translatl" onClick="gStatus.open()"><div class="statipl_music"></div>'.$artist.' – '.$name.'</div><audio'.$aid;
//Обновляем статус
$db->query("UPDATE `".PREFIX."_users` SET user_status = '{$newStatus}' WHERE user_id = '{$user_id}'");
//Чистим кеш
mozg_clear_cache_file("user_{$user_id}/profile_{$user_id}");
}
break;
//################### Выключение трансляции ###################//
case "notranslate":
//Выводим пред. статус
$checkPrevStatus = mozg_cache("user_{$user_id}/old_status");
$checkExp = explode('<audio', $checkPrevStatus);
if(!$checkExp[1]) $newStatus = $db->safesql($checkPrevStatus);
else $newStatus = '';
//Обновляем статус
$db->query("UPDATE `".PREFIX."_users` SET user_status = '{$newStatus}' WHERE user_id = '{$user_id}'");
//Чистим кеш
mozg_create_cache("user_{$user_id}/old_status", "");
mozg_clear_cache_file("user_{$user_id}/profile_{$user_id}");
break;
case "upload":
$tpl->load_template('audio_player/upload.tpl');
$tpl->compile('content');
break;
case "my":
//################### Вывод моих аудио ###################//
$get_user_id = intval($_POST['get_user_id']);
if(!$get_user_id) $get_user_id = $user_id;
$query = $db->safesql(ajax_utf8(strip_data(urldecode($_POST['query']))));
$doload = intval($_POST['doload']);
//Если страница вывзана через "Показать больше аудиозаписей"
$limit_select = 100000;
if($_POST['page_cnt'] > 0)
$page_cnt = intval($_POST['page_cnt'])*$limit_select;
else
$page_cnt = 0;
if($query != ''){
$query = strtr($query, array(' ' => '%')); //Замеянем пробелы на проценты чтоб тоиск был точнее
$where = "artist LIKE '%".$query."%' OR name LIKE '%".$query."%'";
}else{
$where = "auser_id = '".$get_user_id."'";
}
//Если страница вывзана через "Показать больше аудиозаписей"
if($page_cnt)
NoAjaxQuery();
$sql_ = $db->super_query("SELECT SQL_CALC_FOUND_ROWS aid, url, artist, name FROM `".PREFIX."_audio` WHERE {$where} ORDER by `adate` DESC LIMIT {$page_cnt}, {$limit_select}", 1);
if($sql_){
if(!$page_cnt && !$doload){
if($user_id != $get_user_id)
$user = $db->super_query("SELECT user_name FROM `".PREFIX."_users` WHERE user_id = '".$get_user_id."'");
$tpl->set('{name}', gramatikName($user['user_name']));
$tpl->set('{num}', $user['user_audio'].' '.gram_record($user['user_audio'], 'audio'));
$tpl->set('{uid}', $get_user_id);
if($get_user_id == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
$tpl->set_block("'\[not-owner\](.*?)\[/not-owner\]'si","");
} else {
$tpl->set('[not-owner]', '');
$tpl->set('[/not-owner]', '');
$tpl->set_block("'\[owner\](.*?)\[/owner\]'si","");
}
if($config['audio_mod_add'] == 'no')
$tpl->set_block("'\[admin-add\](.*?)\[/admin-add\]'si","");
else {
$tpl->set('[admin-add]', '');
$tpl->set('[/admin-add]', '');
}
$tpl->compile('content');
}
$tpl->load_template('audio_player/track.tpl');
$tpl->result['content'] .= "<div class="stgpl">Моя музыка</div>";
$jid = $page_cnt;
foreach($sql_ as $row){
$jid++;
$tpl->set('{jid}', $jid);
$tpl->set('{aid}', $row['aid']);
$tpl->set('{url}', $row['url']);
$tpl->set('{artist}', stripslashes($row['artist']));
$tpl->set('{name}', stripslashes($row['name']));
if($get_user_id == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
$tpl->set('{uid}', $get_user_id);
$tpl->set_block("'\[not-owner\](.*?)\[/not-owner\]'si","");
} else {
$tpl->set('[not-owner]', '');
$tpl->set('[/not-owner]', '');
$tpl->set_block("'\[owner\](.*?)\[/owner\]'si","");
}
$tpl->compile('content');
}
if(!$page_cnt){
$tpl->set('[not-page]', '');
$tpl->set('[/not-page]', '');
}else{
$tpl->set('[page]', '');
$tpl->set('[/page]', '');
}
if(!$page_cnt && !$doload){
$tpl->load_template('audio_player/bottom.tpl');
$tpl->set('{uid}', $get_user_id);
$tpl->compile('content');
}
} else {
if(!$page_cnt && !$doload){
$tpl->load_template('audio_player/none.tpl');
if($user_id != $get_user_id)
$user = $db->super_query("SELECT user_name FROM `".PREFIX."_users` WHERE user_id = '".$get_user_id."'");
$tpl->set('{name}', gramatikName($user['user_name']));
$tpl->set('{uid}', $get_user_id);
if($get_user_id == $user_id){
$tpl->set('[owner]', '');
$tpl->set('[/owner]', '');
$tpl->set('{uid}', $get_user_id);
$tpl->set_block("'\[not-owner\](.*?)\[/not-owner\]'si","");
} else {
$tpl->set('[not-owner]', '');
$tpl->set('[/not-owner]', '');
$tpl->set_block("'\[owner\](.*?)\[/owner\]'si","");
}
$tpl->compile('content');
}
}
break;
case "search":
$jid = intval($_GET['jid']);
if($jid) $sql_sort .= "AND aid= '{$jid}'";
if($_GET['page'] > 0) $page = intval($_GET['page']); else $page = 1;
$gcount = 100000;
$limit_page =($page-1)*$gcount;
$sql_query = "SELECT SQL_CALC_FOUND_ROWS ".PREFIX."_audio.aid, url, artist, name, auser_id, ".PREFIX."_users.user_search_pref FROM ".PREFIX."_audio LEFT JOIN ".PREFIX."_users ON ".PREFIX."_audio.auser_id = ".PREFIX."_users.user_id WHERE url LIKE '%{$query}%' {$sql_sort} ORDER by `aid` DESC LIMIT {$limit_page}, {$gcount}";
if($sql_query)
$sql_ = $db->super_query($sql_query, 1);
//Загружаем шаблон на вывод если он есть одного юзера и выводим
if($sql_){
$tpl->load_template('audio_player/sea.tpl');
$tpl->result['content'] .= "<div class="stgpl">Вся музыка </div>";
foreach($sql_ as $row_d){
$jid = 0;
$jid++;
$tpl->set('{jid}', $jid);
$tpl->set('{aid}', $row_d['aid']);
$tpl->set('{url}', $row_d['url']);
$tpl->set('{artist}', stripslashes($row_d['artist']));
$tpl->set('{name}', stripslashes($row_d['name']));
$tpl->set('{author-n}', substr($row_d['user_search_pref'], 0, 1));
$expName = explode(' ', $row_d['user_search_pref']);
$tpl->set('{author-f}', $expName[1]);
$tpl->set('{author-id}', $row_d['auser_id']);
$tpl->compile('content');
}
}
break;
case "friends":
$get_user_id = intval($_POST['get_user_id']);
if(!$get_user_id) $get_user_id = $user_id;
$sql_audio = $db->super_query("SELECT SQL_CALC_FOUND_ROWS url, artist, aid, name FROM `".PREFIX."_audio` WHERE auser_id = '".$get_user_id."' ORDER by `adate` DESC LIMIT 0, 10000", 1);
$tpl->load_template('audio_player/sea2.tpl');
$tpl->result['content'] .= "<div class="stgpl">Музыка друзей</div>";
foreach($sql_audio as $row_audio){
$jid++;
$tpl->set('{aid}', $row_audio['aid']);
$tpl->set('{jid}', $jid);
$tpl->set('{uid}', $get_user_id);
$tpl->set('{url}', $row_audio['url']);
$tpl->set('{artist}', stripslashes($row_audio['artist']));
$tpl->set('{name}', stripslashes($row_audio['name']));
$tpl->compile('content');
}
break;
case "search2":
NoAjaxQuery();
$sql_limit = 1000000;
if($_POST['page'] > 0) $page_cnt = intval($_POST['page'])*$sql_limit;
else $page_cnt = 0;
$pid = intval($_POST['pid']);
$query = $db->safesql(ajax_utf8(strip_data($_POST['query'])));
$query = strtr($query, array(' ' => '%')); //Замеянем пробелы на проценты чтоб тоиск был точнее
$row_count = $db->super_query("SELECT COUNT(*) AS cnt FROM `".PREFIX."_audio` WHERE MATCH (name, artist) AGAINST ('%{$query}%') OR artist LIKE '%{$query}%' OR name LIKE '%{$query}%'");
$sql_ = $db->super_query("SELECT SQL_CALC_FOUND_ROWS ".PREFIX."_audio.aid, url, artist, name, auser_id, ".PREFIX."_users.user_search_pref FROM ".PREFIX."_audio LEFT JOIN ".PREFIX."_users ON ".PREFIX."_audio.auser_id = ".PREFIX."_users.user_id WHERE MATCH (name, artist) AGAINST ('%{$query}%') OR artist LIKE '%{$query}%' OR name LIKE '%{$query}%' ORDER by `adate` DESC LIMIT {$page_cnt}, {$sql_limit}", 1);
$tpl->load_template('audio_player/sea.tpl');
$jid = intval($page_cnt);
if($sql_){
if(!$page_cnt)
$tpl->result['content'] .= "<script>langNumric('langNumric', '{$row_count['cnt']}', 'аудиозапись', 'аудиозаписи', 'аудиозаписей', 'аудиозапись', 'аудиозаписей');</script><div class="stgpl">Найдено <span >{$row_count['cnt']}</span> <span id="langNumric"></span> </div>";
foreach($sql_ as $row){
$jid++;
$tpl->set('{jid}', $jid);
$tpl->set('{aid}', $row['aid']);
$tpl->set('{url}', $row['url']);
$tpl->set('{artist}', stripslashes($row['artist']));
$tpl->set('{name}', stripslashes($row['name']));
$tpl->set('{author-n}', substr($row['user_search_pref'], 0, 1));
$expName = explode(' ', $row['user_search_pref']);
$tpl->set('{author-f}', $expName[1]);
$tpl->set('{author-id}', $row['auser_id']);
$tpl->set('{pid}', $pid);
$tpl->compile('content');
}
} else {
if(!$page_cnt){
$tpl->result['info'] .= "<div class="stgpl">Нет аудиозаписей </div>";
msgbox('', '<br /><br /><br />По запросу <b>'.stripslashes($query).'</b> не найдено ни одной аудиозаписи<br /><br /><br />', 'info_2');
}
}
AjaxTpl();
exit;
break;
case "radio":
$tpl->load_template('audio_player/radio.tpl');
$tpl->result['content'] .= "<div class="stgpl">Онлайн радио </div>";
$tpl->set('{title', $title);
$tpl->compile('content');
break;
default:
$row_t = $db->super_query("SELECT user_id, user_search_pref, user_audio,user_friends_num FROM `".PREFIX."_users` WHERE user_id = '{$user_id}'");
if($row_t['user_friends_num']){
$sql_friends = $db->super_query("SELECT SQL_CALC_FOUND_ROWS tb1.friend_id, tb2.user_search_pref, user_last_visit, user_audio, user_photo FROM `".PREFIX."_friends` tb1, `".PREFIX."_users` tb2 WHERE tb1.user_id = '{$user_id}' AND tb1.friend_id = tb2.user_id AND subscriptions = 0 ORDER by rand() DESC LIMIT 0, 6", 1);
$tpl->load_template('audio_player/profile_friends.tpl');
foreach($sql_friends as $row_friends){
if($row_friends['user_photo']) $ava_friends = $config['home_url'].'uploads/users/'.$row_friends['friend_id'].'/50_'.$row_friends['user_photo'];
else $ava_friends = "{theme}/images/no_ava_50.png";
if($row_friends )
$conta = $row_friends;
if($conta['user_audio']){
$cont=$conta['user_audio'].' '.gram_record($conta['user_audio'], 'audio');
} else
$cont= $conta['user_audio'].' '.gram_record($conta['user_audio'], 'audio');
$friend_info = explode(' ', $row_friends['user_search_pref']);
$name= $friend_info[0];
$last_name=$friend_info[1];
$uid= $row_friends['friend_id'];
if($conta['user_audio']>=1){
$friends .= '<div class="staticpl_audio" onclick="audio5.friends('.$uid.'); return false"><table><tr><td> <div><img src="'.$ava_friends.'"></div></td><td style="vertical-align:top;"><span style="color:#ffffff;">'.$name.' '.$last_name.'</span><br><br><b class="headm_newac2">'.$cont.'</b></td></tr></table></div>';
}else{
}
}
}
$doload = intval($_POST['doload']);
if($_GET['page'] > 0) $page = intval($_GET['page']); else $page = 1;
$gcount = 3;
$limit_page =($page-1)*$gcount;
$sql_query = "SELECT SQL_CALC_FOUND_ROWS ".PREFIX."_audio.aid, url, artist, name, auser_id, ".PREFIX."_users.user_search_pref FROM ".PREFIX."_audio LEFT JOIN ".PREFIX."_users ON ".PREFIX."_audio.auser_id = ".PREFIX."_users.user_id WHERE aid ORDER by `aid` DESC LIMIT {$limit_page}, {$gcount}";
if($sql_query)
$sql_ = $db->super_query($sql_query, 1);
//Загружаем шаблон на вывод если он есть одного юзера и выводим
if($sql_){
$tpl->load_template('audio_player/sea.tpl');
foreach($sql_ as $row_d){
$jid++;
$tpl->set('{jid}', $jid);
$tpl->set('{aid}', $row_d['aid']);
$tpl->set('{url}', $row_d['url']);
$tpl->set('{artist}', stripslashes($row_d['artist']));
$tpl->set('{name}', stripslashes($row_d['name']));
$tpl->set('{author-n}', substr($row_d['user_search_pref'], 0, 1));
$expName = explode(' ', $row_d['user_search_pref']);
$tpl->set('{author-f}', $expName[1]);
$tpl->set('{author-id}', $row_d['auser_id']);
$tpl->compile('audio');
}
}
if($row_t )
$cont = $row_t;
if($cont['user_audio']){
$tpl->set('{audio-num}', $cont['user_audio']);
} else
$tpl->set('{audio-num}', '0');
$where_sql .= "WHERE aid != ''";
$numRows = $db->super_query("SELECT COUNT(*) AS cnt FROM `".PREFIX."_audio` {$where_sql}");
$tpl->set('{count}', $numRows['cnt']);
$tpl->load_template('audio_player/head.tpl');
if($row_t['user_friends_num']>=1){
$tpl->set('[friends]', '');
$tpl->set('[/friends]', '');
$tpl->set('{friends}', $friends);
}else{
$tpl->set_block("'\[friends\](.*?)\[/friends\]'si","");
}
$tpl->set('{name}', stripslashes($row_d['name']));
$tpl->set('{audio}',$tpl->result['audio']);
$tpl->compile('content');
AjaxTpl();
die();
}
$tpl->clear();
$db->free();
?>