<?php
require_once 'inc/cached.php';
cachedTOP(18000);
$stop_cached = true;

require_once 'inc/mysqli.php';
include 'inc/functions.php';

$file = $db->getRow('SELECT * FROM `files` WHERE `id` = ?i',$_GET['id']);

if($_SERVER['REQUEST_URI'] == '/song.php?id='.$file['id'].'&name='.rus2eng(str2url($file['artist'].' '.$file['title']))){
	header("HTTP/1.1 301 Moved Permanently"); 
	header('Location: /song/'.$file['id'].'/'.rus2eng(str2url($file['artist'].' '.$file['title'])).'/');
	exit;
}

$pathinfo = pathinfo($file['filename'], PATHINFO_EXTENSION);

if(empty($file['id'])){
	
	$title = 'Такой композиции не существует';
	$desc = 'Такой композиции не существует';
	
	include 'inc/head.php';
	echo '<div class="left-menu"><div class="main-block">Такой композиции не существует!'; 

	echo '</div><div style="clear: both;"></div></div>';
	
	include 'inc/right.php';
	include 'inc/foot.php'; exit;
}

$title = $file['artist'].' - '.$file['title'].' » музыкальные новинки на телефон в хорошем качестве. Скачать бесплатно музыку 2018';
$desc = 'Скачать песню '.$file['artist'].' - '.$file['title'].' бесплатно и другие песни исполнителя без регистрации '.$file['artist'].'. Формат: '.$pathinfo.', Продолжительность: '.$file['playtime_string'];
$key = $file['artist'].', '.$file['title'].', популярное, скачать, бесплатно, песню, похожая, музыка, русская, зарубежная, исполнитель, телефон, слушать, mp3, продолжительность, размер, рейтинг, дата релиза';
$news_keywords = $file['artist'].', '.$file['title'];

$url_sourse = URL.'play/'.base64_encode($file['filename']);

$time = explode(':', $file['playtime_string']);

$m_duration = ($time[0]*60)+$time[1];

$schema = 1;

include 'inc/head.php';

$time_schema = explode(':', $file['playtime_string']);

if(file_exists('style/artist/'.md5($file['artist']).'_large.png')){
	$cover = URL.'style/artist/'.md5($file['artist']).'_large.png';
}elseif(file_exists('style/artist/'.md5($file['artist']).'_large.jpg')){
	$cover = URL.'style/artist/'.md5($file['artist']).'_large.jpg';
}else{
	$cover = URL.'style/img/cover-175.jpg';
}
if(mb_substr($file['bitrate'],0,3,'UTF-8') <= 320){
	$bitrate = mb_substr($file['bitrate'],0,3,'UTF-8');
}else{
	$bitrate = mb_substr($file['bitrate'],0,2,'UTF-8');
}
?>

<div class="left-menu">
<div class="blok-speedbar">
 <span id="speedbar"> 
  <span itemscope itemtype="https://www.schema.org/SiteNavigationElement">
	<span itemprop="name"><a href="/" itemprop="url">Главная</a></span> 
	  <?php
			
		if($file['lang'] == 'ru'){
			echo ' » <span itemprop="name"><a href="/song-list/russkaya-muzyka/" itemprop="url">Русская музыка</a></span>';
		}
		if($file['lang'] == 'en'){
			echo ' » <span itemprop="name"><a href="/song-list/zarubezhnaya-muzyka/" itemprop="url">Зарубежная музыка</a></span>';
		}
		echo ' » '.$file['artist'].' - '.$file['title'];
	   ?>
	</span>
   </span>
</div>
  <div class="main-block">
  
  <span itemprop="audio" itemscope itemtype="https://schema.org/AudioObject">
  <link itemprop="url" href="https://<?=$_SERVER['HTTP_HOST']?>/<?=$file['id']?>/<?=rus2eng(str2url($file['artist'].' '.$file['title']))?>/"> 
    <div class="block-title"><h1><span itemprop="name" >Скачать <?=$file['artist']?> – <?=$file['title']?> бесплатно</span></h1><img src="<?=URL?>style/img/title.png" alt="<?=$file['artist']?> – <?=$file['title']?>"></div>

	<meta itemprop="encodingFormat" content="mp3">
	<link  itemprop="contentUrl" href="<?=URL?>play/<?=base64_encode($file['filename'])?>/">
	
	<div class="song-info">
	
	<div class="song-info-image">
		<img itemprop="thumbnailUrl" src="<?=$cover?>" alt="<?=$file['artist']?> – <?=$file['title']?>" title="<?=$file['artist']?> – <?=$file['title']?>">
	</div>
	
	<div class="song-info-stat">
		<div class="song-info-stat-item"><img src="<?=URL?>style/img/human.png" alt="Исполнитель"> Исполнитель: <a href="/artist/<?=$file['id']?>/<?=rus2eng(str2url($file['artist']))?>/"><?=$file['artist']?></a></div>
		<div class="song-info-stat-item"><img src="<?=URL?>style/img/time.png" alt="Продолжительность"> Продолжительность: <span itemprop="timeRequired" content="PT<?=$time_schema[0]?>M<?=$time_schema[1]?>S" ><?=$file['playtime_string']?></span></div>
        <div class="song-info-stat-item"><img src="<?=URL?>style/img/size.png" alt="Размер"> Размер: <?=formatSize($file['filesize'])?></div>
        <div class="song-info-stat-item"><img src="<?=URL?>style/img/date.png" alt="Дата релиза"> Дата релиза: <span itemprop="dateCreated" ><?=date('d-m-Y', $file['date_add'])?></span></div>
        <div class="song-info-stat-item"><img src="<?=URL?>style/img/rating.png" alt="Рейтинг"> Рейтинг: 

<span itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating">
	<meta itemprop="ratingValue" content="<?=substr($file['rating'], 0, 3)?>">
	<meta itemprop="ratingCount" content="<?=$file['golos']?>">
</span>

	<span id="rating">
        <input type="hidden" name="val" value="<?=$file['rating']?>">
        <input type="hidden" name="id" value="<?=$file['id']?>">
          
	</span></div>
	</div>
	
		<!--<div class="share42init"></div>-->
	</div>
	<ul class="playlist">
		<li style="margin: 0 -11px;">
			<div class="playlist-btn" style="margin-top: 4px;">
				<a rel="nofollow" href="javascript:void(0);" style="background-color: #C0392B !important;" class="playlist-play no-ajax" data-url="<?=URL?>play/<?=base64_encode($file['filename'])?>/" title="Слушать <?=$file['name_full']?>">(Слушать <?=$file['name_full']?>)</a>		
			</div>

			<div class="playlist-right" style="margin-top: 4px;">
				 <span class="playlist-duration"><?=$file['playtime_string']?></span>
			</div>

			<div class="playlist-name marquee" style="margin-top: 5px;">
				<span itemprop="producer" class="playlist-name-artist"><?=$file['artist']?></span> - 
				<span class="playlist-name-title"><em><?=$file['title']?></em></span>
			</div>
		</li>
	</ul>

	<div style="clear: both;height: 10px;"></div>
	<div class="download-links">
		<a rel="nofollow" href="<?=URL?>/load.php?f=<?=base64_encode($file['filename'])?>" class="download" download="<?=$file['artist']?> – <?=$file['title']?>" title="Скачать <?=$file['artist']?> – <?=$file['title']?>"><span>Скачать MP3</span></a>
		<div style="clear: both;"></div>
	</div>
		
   </span>
	</div>
	<div class="main-block">
    <div class="block-title"><h3>Похожая музыка</h3><img src="<?=URL?>style/img/rekomend.png" alt="Похожая музыка"></div>
		<ul class="playlist" itemscope itemtype="https://schema.org/MusicGroup">

			<?php 
				
				$data = $db->getAll("SELECT * FROM `files` WHERE `lang` = ?s and `id` > ?i  ORDER BY `id` LIMIT 7", $file['lang'], ($file['id']+7));
				
				if(count($data) == 0){
					$data = $db->getAll("SELECT * FROM `files` WHERE `lang` = ?s and `id` > ?i  ORDER BY `id` LIMIT 7", $file['lang'], ($file['id']-10));
				}
				
				if(count($data) == 0){
					echo 'Совпадений не найдено :(';
				}
				
				foreach($data as $file){
					
				$time_schema = explode(':', $file['playtime_string']);
			?>
			
				<li itemprop="track" itemscope itemtype="https://schema.org/MusicRecording">
				<meta itemprop="name" content="<?=$file['artist']?> - <?=$file['title']?>">
				
                    <div class="playlist-btn">
						<a rel="nofollow" href="javascript:void(0);" class="playlist-play no-ajax" data-url="<?=URL?>play/<?=base64_encode($file['filename'])?>/" title="Слушать <?=$file['name_full']?>">(Слушать <?=$file['name_full']?>)</a>
                    </div>

                    <div class="playlist-right">
                        <span class="playlist-duration" itemprop="duration" content="PT<?=$time_schema[0]?>M<?=$time_schema[1]?>S"><?=$file['playtime_string']?></span>
                    </div>

				<a itemprop="url" href="/song/<?=$file['id']?>/<?=rus2eng(str2url($file['artist'].' '.$file['title']))?>/">
                    <div class="playlist-name marquee">
						<span class="playlist-name-artist"><b><?=$file['artist']?></b></span><br />
						<span class="playlist-name-title"><em><?=$file['title']?></em></span>
                    </div>
				</a>
                </li>
			
			<?php
				}
			?>

        </ul>
		
    </div>
  
<div style="clear: both;"></div>  
</div>

<?php include 'inc/right.php'; ?>

<?php include 'inc/foot.php'; ?>