<?php
include("./includes/common.php");

$hash = isset($_GET['hash'])?trim($_GET['hash']):exit();
$row = $DB->getRow("SELECT * FROM pre_file WHERE hash=:hash", [':hash'=>$hash]);
if(!$row)exit('404 Not Found');
if($row['block']!=0)exit('File is blocked!');
$name = $row['name'];
$type = $row['type'];
$viewurl = 'down.php/'.$row['hash'].'.'.$type;
$viewurl_all = $siteurl.'view.php/'.$row['hash'].'.'.$type;

$view_type = get_view_type($type);

$title = '文件查看器 - '.$conf['title'];

@header('Content-Type: text/html; charset=UTF-8');
include SYSTEM_ROOT.'header.php';
?>
<div id="viewer" style="height:720px">文件加载中，请稍后……</div>
<script src="https://cdn.jsdelivr.net/npm/@file-viewer/web-full@latest/dist/flyfish-file-viewer-web-full.iife.js"></script>
<script>
  FlyfishFileViewerWebFull.mountViewer(document.getElementById('viewer'), {
    url: '<?php echo $viewurl?>',
    options: {
      theme: 'light',
      toolbar: { position: 'bottom-right' }
    }
  })
</script>
<?php include SYSTEM_ROOT.'footer.php';?>
</body>
</html>