<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/system/function.php';
$title = 'GOload '.$lang['title'];
$title_main = $lang['archive_view'].' - GOload '.$lang['title'];
require_once SYS.'/header.php';
$id = abs(intval(@$_GET['arh']));
$file = $db->query('SELECT * FROM `file` WHERE `id` = '.$id)->fetch_assoc();
if ($file['pass'] == 0 or @$_COOKIE['filepass'] == $file['pass']) {
echo ' <div class="block col-md-8">
<h6 class="round_title">
<a class="left" onclick="window.history.back();">
<img src="/assets/img/left.svg">
</a>
<div class="title back">'.$lang['archive_view'].'</div>
</h6>
<div class="view line menu" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">';
if (!empty($_GET['arh']))
$arh = H.'/files/'.$file['file'];
if (!is_file(@$arh))
error($lang['err_archive1']);
if (!empty($_GET['act']))
$act = guard($_GET['act']);
else
$act = 'main';
$zip = new ZipArchive;
if ($zip->open($arh) === TRUE) {
switch ($act) {
case 'main':
echo '<div style="padding: 2px 0;">'.$lang['arh_objects'].': '.$zip->numFiles.'</div>
';
if ($zip->comment != NULL)
echo $lang['arh_comment'].': '.$zip->comment.'<br>
';
for ($i = 0; $i < $zip->numFiles; $i++) {
$t = $zip->statIndex($i);
if (preg_match('/\/$/', $t['name']))
echo '<i class="material-icons" style="font-size: 14px;position: relative;top: 2px;">folder</i> <strong>'.$t['name'].'</strong><br>
';
else {
echo '<div style="padding: 2px 0;"><a href="?arh='.$_GET['arh'].'&act=pre&index='.$t['index'].'">'.@array_pop(explode('/', $t['name'])).'</a> <b style="margin-left: 8px;"> '.sizer($t['size']).'</b></div>';
}
}
break;
case 'pre' :
if ($info = $zip->statIndex(abs((int)$_GET['index']))) {
echo '<i class="material-icons" style="font-size: 14px;position: relative;top: 2px;">insert_drive_file</i> '.$lang['file'].' <b>'.$info['name'].'</b><br><br>
'.$lang['size_zipped'].': <b>'.sizer($info['comp_size']).'</b><br>
'.$lang['size_unzipped'].': <b>'.sizer($info['size']).'</b><br>
'.$lang['compress_method'].': <b>'.$info['comp_method'].'</b><br>';
$textprev = array('php','sql','html','htm','xhtml','shtml','scss','less','css','js','json','svg','xml','rss','ini','htaccess','dat','log','txt','url','db','tpl','md','mf','yml','java','class','gradle',
'py','h','c','cpp','cs','cgi','csv');
$imageprev = array('png','jpg','jpeg','webp','gif','ico','bmp','cur');
$type = strtolower(substr($info['name'], strrpos($info['name'],'.')+1));
if ($info['size'] < 10 * 1048576 /* 1Mb */) {
if (in_array($type, $textprev)) {
$source = htmlspecialchars($zip->getFromIndex($info['index']), ENT_COMPAT, 'ISO-8859-1', true);
echo '
<link rel="stylesheet" href="/assets/highlight/syntax_theme.css">
<script src="/assets/highlight/highlight.pack.js"></script>
<script src="/assets/highlight/highlight-line-numbers.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();
</script>
<pre><code class="'.$type.'">'.$source.'</code></pre>';
} elseif (in_array($type, $imageprev)) {
echo '<div class="prev"><img src="data:image/'.$type.';base64,'.base64_encode($zip->getFromIndex($info['index'])).'" alt="" style="max-width:100%;"></div>';
}
}
} else
error($lang['err_archive2']);
break;
case 'down':
$index = abs((int)$_GET['index']);
if ($name = $zip->getNameIndex($index)) {
header('Content-Type: application/octet-stream', true);
header('Content-Disposition: attachment; filename="'.urlencode(basename($name)).'";');
echo $zip->getFromIndex($index);
} else
error($lang['err_archive2']);
break;
default:
error($lang['err_archive3']);
break;
}
$zip->close();
} else {
error($lang['err_archive4']);
}
echo '</div>
</div>
<div class="block col-md-8">
<div class="title">'.$lang['nav'].'</div>
<div class="link">
<a href="/">'.$lang['go_home'].'</a>
</div>
</div>
';
} else {
$title_main = $lang['enter_pass'].' - GOload '.$lang['title'];
require_once SYS.'/header.php';
echo '
<div class="block col-md-8">
<h6 class="round_title">
<a class="left" onclick="window.history.back();">
<img src="/assets/img/left.svg" alt="back">
</a>
<div class="title back"><a href="/">'.$title.'</a> | '.$lang['enter_pass'].'</div>
</h6>
';
if (isset($_REQUEST['submit'])) {
$pass = guard($_POST['pass']);
if ($pass != $file['pass']) {
error($lang['wrong_pass']);
}
setcookie('filepass', $file['pass'], time()+86400*365);
go('/modules/viewer/zip.php?arh='.$id);
}
echo ' <div class="menu" style="position: relative;height: 158px;">
<div class="empty pass">
<div class="empty_words">'.$lang['enter_pass_for'].'!</div>
</div>
</div>
<form action="" enctype="multipart/form-data" method="POST">
<div class="menu" style="text-align: center;">
<input type="number" name="pass" placeholder="'.$lang['password'].'" value="';
if (isset($admin)) echo $file['pass'];
echo '">
</div>
<div class="menu" style="text-align: center;padding-bottom: 16px;">
<input class="btn" type="submit" name="submit" value="'.$lang['next'].'">
</form>
</div>
</div>
';
echo '
<div class="block col-md-8">
<div class="title">'.$lang['nav'].'</div>
<div class="link">
<a href="/">'.$lang['go_home'].'</a>
</div>
</div>
';
}
require_once SYS.'/foot.php';
?>