<?php
$title_main = $lang['add_file'].' - 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['add_file'].'</div>
</h6>
';
$maxsize = $set['maxsize'];
if (isset($_REQUEST['submit'])) {
$opis = input(@$_POST['opis']);
$avtor = !isset($user) ? input(@$_POST['avtor']): $user['login'];
$pass = input(@$_POST['pass']);
$nsfw = input(@$_POST['nsfw']);
$access = input(@$_POST['access']);
$size = $_FILES['filename']['size'];
$del = input(@$_POST['del']);
if ($del != null) {
$avto = $del * 86400;
} else {
$avto = $set['del'] * 86400;
}
setcookie('username', $avtor, time()+86400*365);
if (!file_exists($_FILES['filename']['tmp_name'])) {
error($lang['err_choose_file']);
}
if ($size > (1048576 * $maxsize)) {
error($lang['maxsize'].' '.$maxsize.'Mb');
}
if ($size < 4) {
error($lang['err_empty_file']);
}
if (empty($avtor)) {
error($lang['err_enter_name']);
}
if ($del != null) {
if ($del > 10) {
error($lang['err']);
}
}
if (isset($user)) {
$user_file = $user['id'];
}
if ($pass != null) {
setcookie('filepass', $pass, time()+86400*365);
}
if ($nsfw != null) {
$nsfw = 'true';
} else {
$nsfw = 'false';
}
if ($access != null) {
$access = 'false';
} else {
$access = 'true';
}
$filetype = array('jpg', 'gif', 'png', 'jpeg', 'bmp', 'ico', 'svg', 'psd', 'eps', 'ai', 'xd', 'sketch', 'zip', 'rar', 'mp3', 'ogg', 'wav', 'oga', 'avi', 'mp4', 'webm', '3gp', 'jar', 'apk', 'pdf', 'doc', 'docx', 'txt', 'ttf', 'pptx', 'torrent');
$upfiletype = substr($_FILES['filename']['name'], strrpos($_FILES['filename']['name'], '.')+1);
if (!in_array(strtolower($upfiletype), $filetype)) {
error($lang['err_format_noallow']);
}
$files = $set['site'].'_'.mt_rand(1000,9999).'_'.time().'.'.$upfiletype;
move_uploaded_file($_FILES['filename']['tmp_name'], H.'/files/'.$files);
$upload = "INSERT INTO `file` (user, name, avtor, opis, file, format, pass, nsfw, access, time, del) VALUES('$user_file', '".input($_FILES['filename']['name'])."', '$avtor', '$opis', '$files', '".strtolower($upfiletype)."', '$pass', '$nsfw', '$access', '".time()."'+'".$avto."', '$del')";
$db->query($upload);
$sql = $db->insert_id;
go('/file'.$sql);
}
echo ' <div class="menu">
<center><big>'.$lang['maxsize'].' <b>'.$maxsize.'Mb</b></big></center></div>
<div class="view line menu">
<div><b>'.$lang['allowed_files'].'</b>: '.$lang['formats'].'</div><br>
<form action="" enctype="multipart/form-data" method="POST">'.$lang['add_choose_file'].'<br>
<div class="file_input_div">
<div class="file_input">
<label class="image_input_button mdl-button--fab mdl-button mdl-js-button mdl-button--mini-fab mdl-js-ripple-effect mdl-button--colored">
<img src="/assets/img/file_upload.svg">
<input id="file_input_file" class="none" name="filename" type="file">
</label>
</div>
<div id="file_input_text_div" class="mdl-textfield mdl-js-textfield textfield-demo">
<input class="file_input_text mdl-textfield__input" type="text" disabled readonly placeholder="'.$lang['add_choose_file'].'" id="file_input_text">
<label class="mdl-textfield__label" for="file_input_text"></label>
</div>
</div>
</div>
<div class="view line menu">'.$lang['rules_title2'].'<br>
<div class="md-radio md-radio-inline">
<input id="1" type="radio" name="del" value="1">
<label for="1">1 '.$lang['day'].'</label>
</div>
<div class="md-radio md-radio-inline">
<input id="2" type="radio" name="del" value="10" checked>
<label for="2">10 '.$lang['days'].'</label>
</div>
<div class="md-radio md-radio-inline">
<input id="3" type="radio" name="del" value="">
<label for="3">180 '.$lang['days'].'</label>
</div>
</div>
<div class="view line menu">'.$lang['your_name'].'<br>
<input type="text" name="avtor" maxlength="25" value="'.$_COOKIE['username'].'">
</div>
<div class="view line menu" style="padding: 0 0 8px;">
<div class="expanded">
<div class="expanded-item">
<div class="expanded-header">'.$lang['add_description_file'].'</div>
<div class="expanded-body">
<div class="expanded-contents">
<textarea name="opis" id="text" placeholder="'.$lang['description_file'].'" maxlength="228"></textarea>
<div>'.$lang['char_left'].': <span id="result">228</span></div>
</div>
</div>
</div>
</div>
<div class="expanded">
<div class="expanded-item">
<div class="expanded-header">'.$lang['add_password_file'].'</div>
<div class="expanded-body">
<div class="expanded-contents">
<input name="pass" type="number" placeholder="'.$lang['password'].'" maxlength="4">
</div>
</div>
</div>
</div>
</div>
<div class="view line menu">
<div class="md-checkbox">
<input id="4" type="checkbox" name="access" value="false">
<label for="4">'.$lang['access_file'].'</label>
</div>
<span>'.$lang['check_access_file'].'</span>
</div>
<div class="view line menu">
<div class="md-checkbox">
<input id="5" type="checkbox" name="nsfw" value="true">
<label for="5">'.$lang['nsfw_file'].'</label>
</div>
<span>'.$lang['check_nsfw_file'].'</span>
</div>
<div class="view line menu">
<input class="btn" type="submit" name="submit" value="'.$lang['upload'].'" onclick="this.value=\''.$lang['uploading'].'\'">
</form>
</div>
</div>
<script src="/assets/js/material.min.js"></script>
<script src="/assets/js/path.js"></script>
</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>
';
?>