<?php
include'cookie.php';
$fileStr=$_GET['fileStr'];
$user=$_GET['user'];
$filename=$_GET['filename'];
$file=urlencode($filename);
$fileid=$_GET['fileid'];
preg_match('/[0-9A-Z]{112}/', $fileStr, $fileStr);
$fileStr=$fileStr[0];
$host=$_SERVER['HTTP_HOST'];
$url="down.php?fileStr=$fileStr&user=$user&filename=$file";
if($downoff=="0"){
	$down="download.php?fileid=$fileid&user=$user&filename=$file";
	
}else{
	$down="down.php?fileStr=$fileStr&user=$user&filename=$file";	
}

?>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><?php echo $title; ?></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta name="renderer" content="webkit"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<script src="/static/js/mdui.js"></script>
	<link href="/static/css/mdui.css" rel="stylesheet">
	<script src="//cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<!-- MD语法解析JS -->
	<script src="/static/js/showdown.min.js"></script>
	<script src="//cdn.bootcss.com/layer/2.3/layer.js"></script>
	<style>
		.footer-copyright{
			position: absolute;
			height: 50px;
			text-align: center;
			line-height: 50px;
			width: 100%;
			font-size: 14px;
		}
		a{text-decoration:none;}
	</style>
</head>
<body class="mdui-drawer-body-center mdui-appbar-with-toolbar mdui-theme-primary-indigo mdui-theme-accent-pink">
	<header class="mdui-appbar mdui-appbar-fixed">
		<div class="mdui-toolbar <?php echo $headcolor ?>">
			<a href="/" class="mdui-typo-headline mdui-hidden-xs"><?php echo $title; ?></a>
			<div class="mdui-toolbar-spacer"></div>
			
			<div class='mdui-toolbar-spacer'></div>
			<form action='search.php' method='get' id='nameform'>
				<div class='mdui-textfield-not-empty' id='search_input' >
					
					<input  style='width:300px;height:35px;' class=' <?php echo $searchcolor ?>'  type='text'  name='name' placeholder='关键词搜索' />
					<input  type='hidden'  name='user' value='<?php echo $user;?>' />				
					<input  type='hidden'  name='shouye' value='<?php echo $shouye;?>' />					
				</div>

			</form>
<button  class='mdui-btn mdui-ripple <?php echo $searchcolor2 ?>'  type='submit' form='nameform' value='Submit'><i class='mdui-icon material-icons'>search</i></button>

						</div>			
			
			
		</div>
	</header>
	<!-- 主体 -->
	
	
	
	
	<div class="mdui-container">
		<div style="height: 30px;">&nbsp;</div>

<link href="https://cdn.bootcss.com/aplayer/1.10.1/APlayer.min.css" rel="stylesheet">
<div id="aplayer" class="mdui-center"></div>
<br>
<hr>
<br>
<div class="mdui-textfield">
  <label class="mdui-textfield-label">直链</label>
  <input onclick="oCopy(this)" class="mdui-textfield-input" type="text" value="<?php echo "$host/$down"; ?>" />
</div>
<script src="//s2.pstatp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.js"></script>
<script type="text/javascript">
  var color = color16();
  var cover;
  var artist;
  var lrc;
  const ap = new APlayer({
    container: document.getElementById('aplayer'),
    lrcType: 2,
    audio: [{
      name: '<?php echo $filename ?>',
      artist: '<?php echo $filename ?>',
      url: '<?php echo $url; ?>',
      cover: 'https://kp.idait.cn/static/img/avatar-1.jpg',
      theme: color,
    }],
  });
  // 获取歌手和歌词 不一定正确
  $.get('https://api.kieng.cn/musicsearch?str=<?php echo $filename ?>&type=qq',{},function(data){
    console.log(data.data[0])
    if (data.data[0] != '') {
      artist = data.data[0].author;
      cover = data.data[0].pic;
      lrc = data.data[0].lrc;
      ap.list.add([{
        name: '<?php echo $filename ?>',
        artist: artist,
        url: '<?php echo $url; ?>',
        cover: cover,
        lrc: lrc.replace(/n/g,"\n"),
        theme: color,
      }]);
      ap.list.hide();
      ap.skipForward();
      ap.lrc.show();
      console.log(lrc);
    }
    

  })
  function oCopy(obj){obj.select();document.execCommand("Copy");if(browserRedirect()){layer.msg('设备类型为手机，有一定几率复制失败！请查看剪切板是否成功复制')}}
  function color16(){
    var r = Math.floor(Math.random()*256);
    var g = Math.floor(Math.random()*256);
    var b = Math.floor(Math.random()*256);
    var color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
    return color;
  }
</script>

		<!-- MD -->
		<div class="mdui-panel" mdui-panel>
			<div class="mdui-panel-item mdui-panel-item-open">
				<div class="mdui-panel-item-header"><i class="mdui-icon material-icons">&#xe866;</i>&nbsp;&nbsp;&nbsp; README</div>
				<div class="mdui-panel-item-body">
					<div id="md-str" style="display: none;"><?php echo $body; ?></div>
					<div id="md"></div>
				</div>
			</div>
		</div>
		
	</div>
	
	<!-- 页脚 -->
	<div class="footer-copyright">
		Copyright © 2019 - 2020 | <a href="https://pan.yaohuo.tech"><?php echo $title; ?></a> All rights reserved.
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
            var content = $('#md-str').html(); //获取md文本内容
            var converter = new showdown.Converter(); //初始化转换器
            var htmlcontent = converter.makeHtml(content); //将MarkDown转为html格式的内容
            $("#md").html(htmlcontent);
        }); //添加到 div 中 显示出来
    </script>
    </html>