<?php

require dirname(__FILE__) . '/../includes/common.php';
session_start();
print_header('下载文件');
if (!isset($_SERVER['QUERY_STRING']) || !isset($_SESSION['uid'])) {
    alert_error('找不到文件', false);
}
if (!loginFromDatabase($_SESSION['uid'])) {
    alert_error('cookie失效,或者百度封了IP!', false);
}
$link = getDownloadLinkLocatedownloadV40(urldecode($_SERVER['QUERY_STRING']));
$link2 = getDownloadLinkLocatedownloadV10(urldecode($_SERVER['QUERY_STRING']));
$link3 = getDownloadLinkDownload(urldecode($_SERVER['QUERY_STRING']));
if (!$link) {
    alert_error('找不到文件', false);
}
echo '<p>高速下载地址,如下载不走,请刷新几次直到出现新的地址:<br /><br />';
echo '<a target="_blank" rel="noreferrer" href="' . $link3 . '">' . $link3 . '</a><br /><br />';
echo '旧接口下载地址1(限速,可能限IP):<br />';
foreach ($link as $v) {
    echo '<br /><a target="_blank" rel="noreferrer" href="' . $v . '">' . $v . '</a><br />';
}
echo '</p><p>旧接口下载地址2(限速,不限IP):<br />';
foreach ($link2 as $v) {
    echo '<br /><a target="_blank" rel="noreferrer" href="' . $v . '">' . $v . '</a><br />';
}
?>
</p>
</body>
</html>
     echo '<h1>文件不存在QuQ</h1>';
     $mysql->exec('update watchlist set failed=3 where id=' . $_SERVER['QUERY_STRING']);
     die;
 } else {
     if ($force_direct_link || $enable_direct_link && (!isset($_GET['nodirectdownload']) || $res['link'] == '/s/notallow')) {
         if (isset($meta['info'][0]['dlink'])) {
             if ($force_direct_link) {
                 echo '由于管理员配置,当前全部文件只允许直链下载。<br /><br /><br />';
             } else {
                 if ($res['link'] !== '/s/notallow') {
                     echo '若要转存文件,<a href="jump.php?' . $id . '&nodirectdownload=1">前往提取页</a> (提取密码:' . $res['pass'] . ')<br /><br /><br />';
                 } else {
                     echo '本文件只允许直链下载。<br /><br /><br />';
                 }
             }
             $link2 = getDownloadLinkDownload($res['name']);
             //getDownloadLinkLocatedownloadV40($res['name']);
             $link = getDownloadLinkLocatedownloadV10($res['name']);
             if ($link === false) {
                 echo '这个视频文件被温馨提示掉了,请点击上方的“前往提取页”尝试进行修复。若显示“本文件只允许直链下载”,请联系分享者。';
                 die;
             }
             //文件有效!如果没有保存分片信息,现在保存
             if ($res['block_list'] == NULL && $meta['info'][0]['block_list']) {
                 $mysql->query("insert into block_list values({$_SERVER['QUERY_STRING']}, '" . json_encode($meta['info'][0]['block_list']) . "')");
             }
             if (isset($enable_direct_video_play) && $enable_direct_video_play) {
                 $subname = substr($res['name'], strlen($res['name']) - 3);
                 if ($subname == 'mp4' || $subname == 'avi' || $subname == 'flv') {
                     echo '本文件为视频,可以在线播放:<br />若无法播放,请刷新多试几次,因为百度的部分服务器不允许断点续传。<br /><video controls="controls" preload="none">';
                     echo '<source src="' . $link2 . '" />';