Systemtest_tk/subs/parts/userarea/fileshare.php
2019-08-08 16:35:16 +03:00

95 lines
3.9 KiB
PHP

<?php
/**
* /subs/parts/userarea/fileshare.php
* @version 1.0.1
* @desc Userarea: fileshare
* @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk)
* @copy 2018 Fándly Gergő Zoltán
* License:
Systemtest.tk website's.
Copyright (C) 2018 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div id="filelist">
<h3><?php echo $lang['files'] ?></h3>
<table class="footable" style="text-align: left">
<thead>
<tr>
<th><?php echo $lang['name'] ?></th>
<th data-breakpoints="xs sm"><?php echo $lang['extension'] ?></th>
<th data-breakpoints="xs sm"><?php echo $lang['size'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['reference'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['operations'] ?></th>
</tr>
</thead>
<tbody>
<?php
$sql=$db->prepare("SELECT id, token, name, extension, size FROM files WHERE owner=:uid");
$sql->execute(array(":uid"=>$_SESSION['id']));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['name']."</td>
<td>".$row['extension']."</td>
<td>".($row['size']/1000000)." MB</td>
<td>
<textarea rows=\"3\" cols=\"30\" readonly>https://systemtest.tk/uploads/".$row['token']."</textarea>
<button type=\"button\" onclick=\"copyRefToClipboard(this)\">".$lang['copytoclip']."</button>
</td>
<td>
<button type=\"button\" onclick=\"deleteFileFromServer(".$row['id'].", this)\">".$lang['delete']."</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
<hr class="separator">
<div id="quota">
<h3><?php echo $lang['quota'] ?></h3>
<?php
$sql=$db->prepare("SELECT SUM(size) AS sum FROM files WHERE owner=:uid");
$sql->execute(array(":uid"=>$_SESSION['id']));
$used=$sql->fetch(PDO::FETCH_ASSOC)['sum']; //in B
$sql=$db->prepare("SELECT quota FROM users WHERE id=:uid");
$sql->execute(array(":uid"=>$_SESSION['id']));
$total=$sql->fetch(PDO::FETCH_ASSOC)['quota']; //in MB
?>
<div class="progressbar" style="width: 90%; margin: auto">
<div style="width: <?php echo $total!=-1?($used*100/($total*1000000)):"100" ?>%">
<span><?php echo round($used/1000000, 1)."MB&nbsp;/&nbsp;".($total!=-1?$total:$lang['unlimited']." ")."MB" ?></span>
</div>
</div>
</div>
<hr class="placeholder">
<div id="upload">
<h3><?php echo $lang['upload'] ?></h3>
<form method="POST" action="" class="ajaxform" id="uploadForm">
<input type="file" name="fileinput" multiple onchange="loadFileList(this)">
</form>
<hr class="placeholder">
<div id="files">
<!-- files to upload -->
</div>
<hr class="placeholder">
<button type="button" class="red" onclick="clearMyFiles()"><i class="fa fa-minus-circle"></i> <?php echo $lang['clear'] ?></button>
<button type="button" class="green" onclick="startFileUpload()"><i class="fa fa-upload"></i> <?php echo $lang['upload'] ?></button>
</div>