Pas loin de la 0.1

This commit is contained in:
Root srvweb 2019-11-18 01:19:13 +01:00
commit 151ac5b2a7
32 changed files with 1443 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
files/*
config.yaml
stats
header-page.php
header.php
footer-page.php
footer.php
file2link_checkupdate
start-home.php
end-home.php
htmlPages/*.html

20
.htaccess Normal file
View File

@ -0,0 +1,20 @@
Options -Indexes
RewriteEngine on
# Sécurité
RewriteRule ^([0-9]+-[0-9]{1,2})/.key-[0-9]{12}$ /index.php?action=403
RewriteRule ^files/([0-9]+-[0-9]{1,2})/.key-[0-9]{12} /index.php?action=403
RewriteRule ^config.yaml$ index.php?action=403
RewriteRule ^cron.php$ index.php?action=403
# Rewrite
RewriteRule ^([0-9]+-[0-9]{1,2})/(.+)$ files/$1/$2 [L]
RewriteRule ^([0-9]+-[0-9]{1,2})/ index.php?action=html&id=$1 [L]
RewriteRule ^dl/([0-9]+-[0-9]{1,2})/(.+)$ index.php?action=dl&id=$1&file=$2 [L]
RewriteRule ^del/([0-9]+-[0-9]{1,2})/([0-9]{12})/(.+)$ index.php?action=del&id=$1&key=$2&file=$3 [L]
RewriteRule ^del/([0-9]+-[0-9]{1,2})/([0-9]{12})/$ index.php?action=del&id=$1&key=$2 [L]
RewriteRule ^([0-9]+-[0-9]{1,2})\.zip$ index.php?action=zip&id=$1 [L]
RewriteRule ^My$ index.php?action=myFiles [L]
RewriteRule ^(.+)\.html$ index.php?action=page&name=$1 [L]
# Error
ErrorDocument 404 /index.php?action=404
ErrorDocument 403 /index.php?action=403

83
README.md Normal file
View File

@ -0,0 +1,83 @@
Req
- http serveur compatible url rewriting (apache2 for exemple)
-
Install
ReadWrite is ok for "file"
Configure
mv config.yaml.exemple config.yaml
- conf en yaml
- sans bd
- bar de progression pour l'upload
- upload multi file
- upload dans /timestamp de l'expiration/3lettreouchiffre/nomDuFichier.ext
- limit type de fichier
- limite temps + taille
crontab...
header-page.php
header.php
footer-page.php
footer.php
file2link_checkupdate
start-home.php
end-home.php
php gd
resize for png (no transparent), gif, jpeg
Thank's :
Mime type icone : https://github.com/colorswall/CSS-file-icons
Icone : https://fontawesome.com Creative Commons Attribution 4.0 International license
emailPoubelle.php
=============
Un script pour un petit service d'email jetable
* [Démo](http://poubelle.zici.fr/)
* [Page du projet](http://forge.zici.fr/p/emailpoubelle-php/)
* [Download](http://forge.zici.fr/p/emailpoubelle-php/source/download/master/)
* [Bug report](http://forge.zici.fr/p/emailpoubelle-php/issues/)
Installation
-----------
Installation des dépendances :
pear install Net_DNS2
Télécharger & décompresser les sources :
mkdir -p /www/emailPoubelle/postfix
cd /tmp
wget -O emailPoubelle.zip https://framagit.org/kepon/emailPoubellePhp/-/archive/master/emailPoubellePhp-master.zip
unzip emailPoubelle.zip
cp -r emailpoubelle-php-master/* /var/www/emailPoubelle
Configure apache virtualhost (ou autres serveur http)
[...]
DocumentRoot /var/www/emailPoubelle/www
[...]
Configurer Postfix :
vi /etc/postfix/main.cf
[...]
virtual_alias_maps = hash:/www/emailPoubelle/var/virtual
touch /www/emailPoubelle/var/virtual
/usr/sbin/postmap /www/emailPoubelle/var/virtual
chown www-data /www/emailPoubelle/var/virtual
chown www-data /www/emailPoubelle/var/virtual.db
Ajouter dans le fichier /etc/aliases le devnull
echo "devnull: /dev/null" >> /etc/aliases
newaliases

BIN
android-chrome-192x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
android-chrome-512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

17
cron.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$config = yaml_parse_file('./config.yaml');
include('./lib/functions.php');
if ($config['expireCron'] == 'cli') {
if (!is_dir($config['uploadDir'])) {
exit(_('Start the command in the file2link directory'));
}
cronExpire();
echo _('Completed')."\n";
} else {
exit(_('expireCron is not at "cli" mod (in config.yaml)'));
}
?>

BIN
favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

BIN
favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,3 @@
<h1>CGU</h1>
<p>In Writing...</p>

431
index.php Normal file
View File

@ -0,0 +1,431 @@
<?php
define('VERSION', '0.1');
if (!is_readable('./config.yaml')) {
exit('Error: The configuration file is not present, move config.yaml.default to config.yaml');
}
$config = yaml_parse_file('./config.yaml');
include('./lib/functions.php');
if (isset($_GET['id'])){
$id = $_GET['id'];
if (!preg_match('/^[0-9]+-[0-9]{1,2}$/', $id)) {
exit('No Hack ID');
}
} else {
$id = null;
}
if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('upload_max_filesize'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration upload_max_filesize to %s'), $config['maxUploadPerFile']));
}
if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('post_max_size'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration post_max_size to %s'), $config['maxUploadPerFile']));
}
if (convertHumain2octect($config['maxUploadNb']) > convertHumain2octect(ini_get('max_file_uploads'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration max_file_uploads to %s'), $config['maxUploadNb']));
}
// ZIP ou DL
if (isset($_GET['action']) && ($_GET['action'] == 'zip' || $_GET['action'] == 'dl')) {
$uploadDirId=$config['uploadDir'].'/'.$id.'/';
if ($_GET['action'] == 'zip') {
genZip($id);
$filename = $id.'.zip';
$contentType='application/zip';
} elseif ($_GET['action'] == 'dl') {
$filename = $_GET['file'];
$contentType=mime_content_type($uploadDirId.$filename);
}
// HTTP Headers File Downloads
// https://perishablepress.com/press/2010/11/17/http-headers-file-downloads/
// http headers for zip downloads
if (headers_sent()) {
echo 'HTTP header already sent';
} else {
if (!is_file($uploadDirId.$filename)) {
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
echo 'File not found';
} else if (!is_readable($uploadDirId.$filename)) {
header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
echo 'File not readable';
} else {
header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: ".$contentType);
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($uploadDirId.$filename));
@readfile($uploadDirId.$filename);
}
}
exit();
}
// Del
if (isset($_GET['action']) && $_GET['action'] == 'del') {
echo $config['uploadDir'].'/'.$id.'/.key-'.$_GET['key'];
print_r($_GET);
if (! is_file($config['uploadDir'].'/'.$id.'/.key-'.$_GET['key']))
exit('No hack 5 - delete not Unauthorized');
// Si c'est juste un fichier
if (isset($_GET['file'])) {
@unlink($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
@unlink($config['uploadDir'].'/'.$id.'/.'.$_GET['file'].'.small');
// Si c'est le dernire, on supprime le tout
$uploadDirId = $config['uploadDir'].'/'.$id.'/';
$nbFile=0;
foreach (scandir($uploadDirId) as $file) {
if (is_file($uploadDirId.'/'.$file)
&& $file != $id.'.zip'
&& !preg_match('/^.key-[0-9]{12}$/', $file)
&& !preg_match('/^\.(.+)\.small$/', $file)) {
$nbFile++;
}
}
if ($nbFile == 0) {
rrmdir($config['uploadDir'].'/'.$id.'/');
}
} else {
// Si c'est le dossier
rrmdir($config['uploadDir'].'/'.$id.'/');
$nbFile = 0;
}
if ($nbFile == 0) {
header('Status: 301 Moved Permanently', false, 301);
header('Location: '.$config['baseUrl']);
} else {
header('Status: 301 Moved Permanently', false, 301);
header('Location: '.$config['baseUrl'].'/'.$id.'/');
}
exit();
}
@include_once('./header.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Upload</title>
<script src="<?= $config['baseUrl'] ?>lib/jquery-3.1.0.min.js"></script>
<script>
var Config_baseUrl = '<?= $config['baseUrl'] ?>'
var Config_maxUploadPerFile = <?= convertHumain2octect($config['maxUploadPerFile']) ?>
var Config_maxUploadTotal = <?= convertHumain2octect($config['maxUploadTotal']) ?>
var Config_maxUploadNb = <?= $config['maxUploadNb'] ?>
var Config_mimeTypesConduct = '<?= $config['mimeTypesConduct'] ?>'
var Config_mimeTypes = ['helloWorld'<?php foreach ($config['mimeTypes'] as $mimeTypes) { echo ', \''.$mimeTypes.'\'' ; } ?>];
var Msg_errorFileSize = '<?php printf(_('this file exceeds the allowed size %s'), $config['maxUploadPerFile']) ?>';
var Msg_errorTotalSize = '<?php printf(_('The total size of the files exceeds the allowed size : %s'), $config['maxUploadTotal']) ?>';
var Msg_errorUploadNb = '<?php printf(_('You can not send more than %d files at a time'), $config['maxUploadNb']) ?>';
var Msg_errorFileType = '<?php printf(_('this type of file isn\\\'t allow')) ?>';
</script>
<script src="<?= $config['baseUrl'] ?>lib/upload.js"></script>
<link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/style.css" />
<link rel="stylesheet" href="<?= $config['baseUrl'] ?>lib/css-file-icons.css" />
<link rel="apple-touch-icon" sizes="180x180" href="<?= $config['baseUrl'] ?>/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
</head>
<body>
<div id="langues">
<a href="https://crwd.in/calcpvautonome"><img class="drapeau" src="./lib/trad.png" alt="Help to translate" /></a>
</div>
<div id="languesLegende" style="display: none"></div>
<div id="page-wrap">
<?php @include_once('./header-page.php'); ?>
<?php
$similarServicesLink='';
if ($config['similarServicesView']) {
$similarServicesLink='<div class="similarServices">
<div class="similarHref"><a href="#similarServices" id="similarServices">'._('Similar services').'</a></div>
<div class="similarLink">';
foreach ($config['similarServicesLink'] as $link) {
$similarServicesLink.=$link.' ';
}
$similarServicesLink.='</div>
</div>';
}
$uploadDirId=$config['uploadDir'].'/'.$id;
$action = null;
if (isset($_GET['action'])) {
$action = $_GET['action'];
}
if (!is_writable($config['uploadDir'])) {
$action = 'ErrorUploadDir';
}
if ($action == 'html' && !is_dir($config['uploadDir'].'/'.$id)) {
$action = '404';
}
if (!$config['htmlPages'] && $action == 'page') {
$action = '404';
}
$echoNewUpload = '<div class="newUpload"><a href="'.$config['baseUrl'].'"><img src="'.$config['baseUrl'].'/lib/upload.svg" /></a>
<a class="myFiles" href="'.$config['baseUrl'].'/My"><img src="'.$config['baseUrl'].'/lib/folder.svg" /></a>
'.$similarServicesLink.'</div>
<script>
if (localStorage.getItem(\'myFiles\')) {
$(\'.myFiles\').show();
}
</script>';
switch ($action) {
case 'ErrorUploadDir':
echo '<div class="highlight-1">';
printf(_('Error: The directory (%s) is not writable, please contact the service administrator'), $config['uploadDir']);
echo '</div>';
break;
case 'page':
foreach ($config['htmlPages'] as $fileName => $name) {
if ($_GET['name'] == $fileName) {
$page['fileName'] = $fileName;
$page['name'] = $name;
}
}
if (empty($page['name'])) {
echo '<p>'._('The requested page does not exist').'</p>';
} elseif (!is_file('htmlPages/'.$page['fileName'].'.html')) {
echo '<p>'._('The requested page does not exist').'</p>';
} else {
include('htmlPages/'.$page['fileName'].'.html');
}
echo $echoNewUpload;
break;
case 'html':
echo '<h1>'.$config['shortTitle'].' : '.$config['title'].'</h1>';
$expire=explode('-', $id);
$dateExpire=date('d/m/Y H:m', $expire[0]);
$dStart = new DateTime(date('Y-m-d', $expire[0]));
$dEnd = new DateTime(date('Y-m-d'));
$dDiff = $dStart->diff($dEnd);
$dayExpire = $dDiff->format('%a');
$classExpire ='';
if ($dayExpire < 2) {
$classExpire='verySpeedDownload';
}elseif ($dayExpire < 5) {
$classExpire='speedDownload';
}
printf('<p class="'.$classExpire.'">'._('These files will be automatically deleted on %s, ie in %d days').'</p>', $dateExpire, $dayExpire);
$nbFile=0;
foreach (scandir($uploadDirId) as $file) {
if (is_file($uploadDirId.'/'.$file)
&& $file != $id.'.zip'
&& !preg_match('/^.key-[0-9]{12}$/', $file)
&& !preg_match('/^\.(.+)\.small$/', $file)) {
$filesInUploadDirId[]=$file;
$nbFile++;
}
}
if ($nbFile == 0) {
echo '<p>'._('Error: Nothing to display').'</p>';
} elseif ($nbFile == 1) {
echo '<div class="fileGlobal fileJust1 file-ext-html" >';
echo '<div class="file fileJust1 icone" onclick="location.href=\''.$linkDownload.'\'"><div class="fi fi-html fi-size"><div class="fi-content">html</div></div></div>';
echo '<div class="file fileJust1 name"><a href="'.$linkDownload.'" target="_blank">'._('This page').'</a></div>';
echo '<div class="file fileJust1 read input"><a href="'.$config['baseUrl'].$id.'/" target="_blank"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].$id.'/" readonly=""></div>';
echo '</div>';
} elseif ($nbFile > 1) {
$linkDownload=$config['baseUrl'].$id.'.zip';
echo '<div class="fileGlobal fileAll file-ext-zip" >';
echo '<div class="file fileAll icone" onclick="location.href=\''.$linkDownload.'\'"><div class="fi fi-zip fi-size-lg"><div class="fi-content">zip</div></div></div>';
echo '<div class="file fileAll name"><a href="'.$linkDownload.'" target="_blank">'._('All').'</a> - <a class="deleteLink" href="'.$config['baseUrl'].'del/'.$id.'/KEYHERE/"><img width="15" src="'.$config['baseUrl'].'/lib/trash.svg" /> '._('Delete all (permanently)').'</a></div>';
echo '<div class="file fileAll read input"><a href="'.$config['baseUrl'].$id.'/" target="_blank"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <input class="copy read fileAll" name="read" type="text" value="'.$config['baseUrl'].$id.'/" readonly=""></div>';
echo '<div class="file fileAll dl input"><a href="'.$linkDownload.'" target="_blank"><img src="'.$config['baseUrl'].'/lib/download.svg"</a> /><input class="copy dl fileAll" name="dl" type="text" value="'.$linkDownload.'" readonly=""></div>';
echo '</div>';
}
$idFile=0;
foreach ($filesInUploadDirId as $fileInUploadDirId) {
$pathInfo = pathinfo($uploadDirId.'/'.$fileInUploadDirId);
$linkDownload=$config['baseUrl'].'dl/'.$id.'/'.$fileInUploadDirId;
echo '<div class="fileGlobal file'.$idFile.' file-ext-'.$pathInfo['extension'].'" >';
echo '<div class="file file'.$idFile.' icone delete"><a href="'.$config['baseUrl'].'del/'.$id.'/KEYHERE/'.$pathInfo['basename'].'" class="deleteLink"><img src="'.$config['baseUrl'].'/lib/trash.svg" /></a></div>';
echo '<div class="file file'.$idFile.' icone" onclick="location.href=\''.$linkDownload.'\'">';
if (preg_match('/^image\/(png|jpeg|gif)$/', mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']))) {
if (!is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small')) {
resize_image($pathInfo['dirname'].'/'.$pathInfo['basename'], $pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small' , 60, 60);
}
if (is_file($pathInfo['dirname'].'/.'.$pathInfo['basename'].'.small')) {
echo '<img width="55" src="'.$config['baseUrl'].$config['uploadDir'].'/'.$id.'/.'.$pathInfo['basename'].'.small" />';
} else {
echo '<div class="fi fi-'.$pathInfo['extension'].' fi-size-lg"><div class="fi-content">'.$pathInfo['extension'].'</div></div>';
}
} else {
echo '<div class="fi fi-'.$pathInfo['extension'].' fi-size-lg"><div class="fi-content">'.$pathInfo['extension'].'</div></div>';
}
echo '</div>';
echo '<div class="file file'.$idFile.' name"><a href="'.$linkDownload.'" target="_blank">'.truncate($fileInUploadDirId, 40, '...', true).'</a></div>';
echo '<div class="file file'.$idFile.' info">';
echo '<span class="size file'.$idFile.'">'._('Size').' : '.convertOctect2humain(filesize($pathInfo['dirname'].'/'.$pathInfo['basename'])).'</span> ';
echo '<span class="type file'.$idFile.'">'._('Type').' : '.mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']).'</span> ';
//echo '<span class="size">'._('Type').' : '.mime_content_type($pathInfo['dirname'].'/'.$pathInfo['basename']).'</span> ';
echo '</div>';
echo '<div class="file file'.$idFile.' read input"><a href="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'" target="_blank"><img src="'.$config['baseUrl'].'/lib/eye.svg" /></a> <input class="copy read file'.$idFile.'" name="read" type="text" value="'.$config['baseUrl'].$id.'/'.$fileInUploadDirId.'" readonly=""></div>';
echo '<div class="file file'.$idFile.' dl input"><a href="'.$linkDownload.'" target="_blank"><img src="'.$config['baseUrl'].'/lib/download.svg" /></a> <input class="copy dl file'.$idFile.'" name="dl" type="text" value="'.$linkDownload.'" readonly=""></div>';
echo '</div>';
$idFile++;
}
echo $echoNewUpload;
?>
<script>
if (localStorage.getItem('myFiles')) {
var storageMyFiles = JSON.parse(localStorage.getItem('myFiles'));
if (storageMyFiles.items.filter(function(e) { return e.id === '<?= $id ?>'; }).length > 0) {
var searchWithId = storageMyFiles.items.filter(function(e) { return e.id === '<?= $id ?>'; })
var keyForThis = Object.values(searchWithId[0])[1];
$('.deleteAll').show();
$('.delete').show();
var links = $('.deleteLink');
for(var i = 0; i< links.length; i++){
var oldLink = links[i].href;
var newLink = oldLink.replace('KEYHERE', keyForThis);
links[i].href = newLink;
}
}
}
</script>
<?php
break;
case 'myFiles':
?>
<h1><?= $config['shortTitle'] ?> : <?= _('My files') ?></h1>
<p><?= _('Online file sharing service <a href="https://en.wikipedia.org/wiki/Open_source">free of rights</a> (license <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>) and free.') ?></p>
<div id="myFilesArea"></div>
<script>
var fileNotExpire=0;
if (localStorage.getItem('myFiles')) {
var tablePrepar = '<table><tr><th>Id</th><th><?= _('Expire') ?></th><th><?= _('Link') ?></th></tr>';
var storageMyFiles = JSON.parse(localStorage.getItem('myFiles'));
var newData = {items: []};
for (var i = 0; i < storageMyFiles.items.length; i++) {
var idSplit=storageMyFiles.items[i].id.split("-");
var timestampNow = Number(new Date());
var timestampExpire = idSplit[0]*1000;
// Ne pas afficher les expiré
if (timestampNow < timestampExpire) {
var dateExpire = new Date(idSplit[0]* 1000).toDateString();
var tablePrepar = tablePrepar + '<tr class="myFiles1"><td>'+storageMyFiles.items[i].id+'</td><td>'+dateExpire+'</td><td><a href="<?= $config['baseUrl'] ?>'+storageMyFiles.items[i].id+'/" target="_blank"><?= $config['baseUrl'] ?>'+storageMyFiles.items[i].id+'/</a></td></tr>\n';
var fileNotExpire=fileNotExpire+1;
// On update le maintient dans le stroage
newData.items.push(
{id: storageMyFiles.items[i].id, key: storageMyFiles.items[i].key}
);
}
}
// Ecriture du storage
localStorage.setItem('myFiles', JSON.stringify(newData));
var tablePrepar = tablePrepar + '</table>';
$('#myFilesArea').html(tablePrepar);
} else {
$('#myFilesArea').html('<span class="error myFiles0"><?= _('No files, maybe all of them have expired.') ?></span>');
}
if (fileNotExpire == 0) {
$('#myFilesArea').html('<span class="error myFiles0"><?= _('All your files have expired.') ?></span>');
}
</script>
<?php
echo $echoNewUpload;
break;
case '403':
echo '<h1>'.$config['shortTitle'].' : 403 '._('Unauthorized access').'</h1>';
echo '<p>'._('Unauthorized access').'</p>';
echo $echoNewUpload;
break;
case '404':
echo '<h1>'.$config['shortTitle'].' : 404 '._('Not Found').'</h1>';
echo '<p>'._('This sharing does not exist, it has probably expired').'</p>';
echo $echoNewUpload;
break;
default:
?>
<h1><?= $config['shortTitle'] ?> : <?= $config['title'] ?></h1>
<?php @include_once('./start-home.php'); ?>
<p><?= _('Online file sharing service <a href="https://en.wikipedia.org/wiki/Open_source">free of rights</a> (license <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>) and free.') ?></p>
<div id="preUpload"></div>
<!-- For upload results -->
<div id="result"></div>
<div class="uploadArea">
<div id="uploadInput"><input type="file" id="files" name="files[]" multiple/></div>
<div class="newUpload"><img class="btn-upload" src="<?= $config['baseUrl'] ?>/lib/upload.svg" />
<a class="myFiles" href="<?= $config['baseUrl'] ?>/My"><img src="<?= $config['baseUrl'] ?>/lib/folder.svg" /></a>
<script>
if (localStorage.getItem('myFiles')) {
$('.myFiles').show();
}
</script></div>
<div><?= _('Expire') ?> : <select name="expire" id="expire">
<?php
foreach ($config['expireDay'] as $expireDay) {
if ($expireDay == $config['expireDayDefault']) {
echo '<option value="'.$expireDay.'" selected="selected">'.$expireDay.' '._('day').'</option>';
} else {
echo '<option value="'.$expireDay.'" >'.$expireDay.' '._('day').'</option>';
}
}
?>
</select></div>
<div id="resizeForm"><?= _('Images resize') ?> : <select name="resize" id="resize">
<?php
foreach ($config['imageResize'] as $imageResize) {
$imageResizeName = $imageResize.'px';
if ($imageResize == 0) {
$imageResizeName = _('No resizing');
}
if ($imageResize == $config['imageResizeDefault']) {
echo '<option value="'.$imageResize.'" selected="selected">'.$imageResizeName.'</option>';
} else {
echo '<option value="'.$imageResize.'" >'.$imageResizeName.'</option>';
}
}
?>
</select></div>
<div class="limit"><?php printf(_('The limit per file is %dM, and the total limit per upload is %dM'), $config['maxUploadPerFile'], $config['maxUploadTotal']); ?></div>
<?= $similarServicesLink ?>
</div>
<!-- For progress bars -->
<div class="progress"></div>
<?php
@include_once('./end-home.php');
}
?>
<div id="footer">
<p class="footer_right"><?= _('By') ?> <a href="http://david.mercereau.info/">David Mercereau</a> (<a href="https://framagit.org/kepon/CalcPvAutonome"><?= _('Git repository') ?></a>)</p>
<p class="footer_left">file2link <?= _('version') ?> <?= VERSION ?> <?= _('is an open software licensed <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>') ?></p>
<?php
if ($config['htmlPages']) {
echo '<p class="footer_htmlPages">';
foreach ($config['htmlPages'] as $fileName => $name) {
echo ' <a href="'.$config['baseUrl'].$fileName.'.html">'.$name.'</a> ';
}
echo '</p>';
}
?>
</div>
<?= CheckUpdate(); ?>
<?php @include_once('./footer-page.php'); ?>
</div>
<div id="bg">
<img src="<?= $config['backgroundImage'] ?>" alt="">
</div>
</body>
</html>
<?php
if ($config['expireCron'] == 'web') {
if (is_file($config['uploadDir'].'/.cronWeb')) {
if (file_get_contents($config['uploadDir'].'/.cronWeb')+$config['expireCronFreq'] < time()) {
cronExpire();
file_put_contents($config['uploadDir'].'/.cronWeb', time());
}
} else {
file_put_contents($config['uploadDir'].'/.cronWeb', time());
}
}
@include_once('./footer.php');
?>

BIN
lib/aa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

1
lib/all.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="globe" class="svg-inline--fa fa-globe fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path fill="currentColor" d="M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"></path></svg>

After

Width:  |  Height:  |  Size: 968 B

1
lib/copy.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="copy" class="svg-inline--fa fa-copy fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z"></path></svg>

After

Width:  |  Height:  |  Size: 579 B

6
lib/css-file-icons.css Normal file

File diff suppressed because one or more lines are too long

1
lib/download.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="download" class="svg-inline--fa fa-download fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"></path></svg>

After

Width:  |  Height:  |  Size: 678 B

BIN
lib/drapaux.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
lib/en.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
lib/eye.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="eye" class="svg-inline--fa fa-eye fa-w-18" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M288 144a110.94 110.94 0 0 0-31.24 5 55.4 55.4 0 0 1 7.24 27 56 56 0 0 1-56 56 55.4 55.4 0 0 1-27-7.24A111.71 111.71 0 1 0 288 144zm284.52 97.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400c-98.65 0-189.09-55-237.93-144C98.91 167 189.34 112 288 112s189.09 55 237.93 144C477.1 345 386.66 400 288 400z"></path></svg>

After

Width:  |  Height:  |  Size: 655 B

63
lib/folder.svg Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
aria-hidden="true"
focusable="false"
data-prefix="far"
data-icon="folder"
class="svg-inline--fa fa-folder fa-w-16"
role="img"
viewBox="0 0 512 412"
version="1.1"
id="svg4"
sodipodi:docname="folder.svg"
width="512"
height="412"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="875"
id="namedview6"
showgrid="false"
inkscape:zoom="0.4609375"
inkscape:cx="256"
inkscape:cy="256"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M 464,78 H 272 L 217.37,23.37 c -6,-6 -14.14,-9.37 -22.63,-9.37 H 48 C 21.49,14 0,35.49 0,62 v 288 c 0,26.51 21.49,48 48,48 h 416 c 26.51,0 48,-21.49 48,-48 V 126 C 512,99.49 490.51,78 464,78 Z m 0,272 H 48 V 62 h 140.12 l 54.63,54.63 c 6,6 14.14,9.37 22.63,9.37 H 464 Z"
id="path2"
clip-path="none"
inkscape:connector-curvature="0"
style="fill:currentColor" />
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
lib/fr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

182
lib/functions.php Normal file
View File

@ -0,0 +1,182 @@
<?php
function CheckUpdate() {
global $config;
if ($config['checkUpdate']) {
if (! is_file($config['uploadDir'].'/.checkupdate') || filemtime($config['uploadDir'].'/.checkupdate') + $config['checkUpdate'] < time()) {
$file2link_get_version = file_get_contents('http://dl.zici.fr/file2link_checkupdate');
$file2link_version_file=fopen($config['uploadDir'].'/.checkupdate','w');
fputs($file2link_version_file, $file2link_get_version);
fclose($file2link_version_file);
}
$file_current_version = trim(file_get_contents($config['uploadDir'].'/.checkupdate'));
if ($file_current_version != '' && $file_current_version != VERSION) {
return '<p id="upgrade">Upgrade note: Your version is in '.VERSION.' while the current version is in '.$file_current_version.'</p>';
} else {
return false;
}
}
}
function convertHumain2octect($value) {
if (preg_match('/[0-9]+[Kk]$/', $value)) {
return intval($value) * 1024;
} elseif (preg_match('/[0-9]+[Mm]$/', $value)) {
return intval($value) * 1024 * 1024;
} elseif (preg_match('/[0-9]+[Gg]$/', $value)) {
return intval($value) * 1024 * 1024 * 1024;
} else {
return intval($value);
}
}
function convertOctect2humain($value) {
if ($value > 1000000000) {
$return=round($value/1024/1024/1024, 1).'Mo';
}elseif ($value > 1000000) {
$return=round($value/1024/1024, 1).'Mo';
}elseif ($value > 1000) {
$return=round($value/1024, 1).'Ko';
} else {
$return=$value;
}
return $return;
}
function checkMimeTypes($mimeTypesTest) {
global $config;
$mimeDetect=false;
foreach ($config['mimeTypes'] as $mimeTypes) {
if (preg_match('/'.$mimeTypes.'/', $mimeTypesTest)) {
$mimeDetect = true;
}
}
if (($config['mimeTypesConduct'] == 'allow' && $mimeDetect)
|| ($config['mimeTypesConduct'] == 'deny' && !$mimeDetect)) {
return true;
} else {
return false;
}
return $return;
}
function genZip($id) {
global $config;
$uploadDirId=$config['uploadDir'].'/'.$id;
$zipFile = $uploadDirId.'/'.$id.'.zip';
if (!is_file($zipFile)) {
$zip = new ZipArchive();
if ($zip->open($zipFile, ZipArchive::CREATE)!==TRUE) {
exit('Error in open <$zipFile>\n');
}
foreach (scandir($uploadDirId) as $file) {
if (is_file($uploadDirId.'/'.$file)) {
$zip->addFile($uploadDirId.'/'.$file,$file);
}
}
$zip->close();
}
}
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir."/".$object) && !is_link($dir."/".$object))
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
rmdir($dir);
}
}
function cronExpire() {
global $config;
foreach (scandir($config['uploadDir']) as $uploadDirId) {
if (!preg_match('/^\./', $uploadDirId) && is_dir($config['uploadDir'].'/'.$uploadDirId)) {
$uploadDirIdExplode = explode("-", $uploadDirId);
if ($uploadDirIdExplode[0] < time()) {
if ($config['expireCron'] == 'cli') {
echo $config['uploadDir'].'/'.$uploadDirId." "._('Expired')."\n";
}
rrmdir($config['uploadDir'].'/'.$uploadDirId);
}
}
}
}
// https://www.binarytides.com/php-resize-large-images-imagemagick/
function resize_image($src , $dest , $toWidth , $toHeight ) {
if(!file_exists($src)) {
echo '$src file does not exist';
return false;
} else {
//OPEN THE IMAGE INTO A RESOURCE
$img = imagecreatefromjpeg ($src); //try jpg
if(!$img) {
$img = imagecreatefromgif ($src); //try gif
}
if(!$img) {
$img = imagecreatefrompng ($src); //try png
}
if(!$img) {
die('Could Not create image resource $src');
}
//ORIGINAL DIMENTIONS
list( $width , $height ) = getimagesize( $src );
//ORIGINAL SCALE
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;
//NEW DIMENSIONS WITH SAME SCALE
if ($yscale > $xscale) {
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
} else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}
//NEW IMAGE RESOURCE
if(!($imageResized = imagecreatetruecolor($new_width, $new_height))) {
die('Could not create new image resource of width : $new_width , height : $new_height');
}
//RESIZE IMAGE
if(! imagecopyresampled($imageResized, $img , 0 , 0 , 0 , 0 , $new_width , $new_height , $width , $height)) {
die('Resampling failed');
}
//STORE IMAGE INTO DESTINATION
if(! imagejpeg($imageResized , $dest)) {
die('Could not save new file');
}
//Free the memory
imagedestroy($img);
imagedestroy($imageResized);
return true;
}
}
function truncate($string, $max_length = 30, $replacement = '', $trunc_at_space = false) {
$max_length -= strlen($replacement);
$string_length = strlen($string);
if($string_length <= $max_length)
return $string;
if( $trunc_at_space && ($space_position = strrpos($string, ' ', $max_length-$string_length)) )
$max_length = $space_position;
return substr_replace($string, $replacement, $max_length);
}
?>

4
lib/jquery-3.1.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

309
lib/style.css Normal file
View File

@ -0,0 +1,309 @@
body{
font-family: Helvetica, "Trebuchet MS" , Arial;
font-size: small;
}
/* L'image en background */
#bg {
position:fixed;
top:-50%;
left:-50%;
width:200%;
height:200%;
}
#bg img {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:auto;
min-width:50%;
min-height:50%;
}
/* Le carde de la page */
#page-wrap {
position: relative;
z-index: 2;
width: 90%;
margin: 50px auto;
padding: 5px 20px;
background: white;
-moz-box-shadow: 0 0 20px black;
-webkit-box-shadow: 0 0 20px black;
box-shadow: 0 0 20px black;
opacity: 0.90;
}
.similarHref a {
color: #7E7E7E;
}
.similarLink {
margin-top: 10px;
display:none;
}
/* Pied de page */
#footer {
color: #7E7E7E;
clear: both;
padding: 10px;
}
.footer_right {
float: right;
}
#footer a {
color: #7E7E7E;
}
.footer_htmlPages {
text-align: right;
}
@media screen and (max-width: 800px) {
#page-wrap {
width: 90%;
}
}
@media screen and (min-width: 800px) {
#page-wrap {
width: 600px;
}
}
.uploadArea {
text-align: center;
}
.uploadArea div {
margin: 30px;
}
.uploadResult {
font-weight: bold;
}
.uploadResult.ok {
color: #008000;
}
.uploadResult.nok {
color: #FF0000;
}
#resizeForm {
display: none;
}
.limit {
text-align: center;
color: #7E7E7E;
}
a {
color:#07396A;
text-decoration:underline;
}
.progress {
text-align: center;
padding: 20px;
}
progress {
width: 100%;
}
/* Infobulle */
a.bulles {
color:#07396A;
text-decoration:none;
cursor:pointer;
cursor:hand;
}
#tooltip {
text-align: left;
position:absolute;
z-index:9999;
color:#fff;
width:210px;
}
/* hack IE */
*html #tooltip .tipHeader {margin-bottom:-6px;}
#tooltip .tipBody {
background-color:#000;
padding:5px;
}
@media screen and (max-width: 800px) {
.file.icone,
.file.name,
.file.info,
.file.input {
margin: 0 auto;
text-align:center;
width: 90%;
}
input.copy {
width: 85%;
}
}
@media screen and (min-width: 800px) {
.file.icone {
float: left;
}
input.copy {
width: 75%;
}
}
.verySpeedDownload {
color: #FF0000;
font-weight: bold;
}
.speedDownload {
color: #FFA500;
font-weight: bold;
}
.fileGlobal {
padding-top: 10px;
}
.file {
padding: 4px;
}
.file.icone {
cursor: pointer;
margin: 10px;
padding: 10px;
}
.file.icone a {
text-decoration: none;
color : #FFFFFF;
}
.file.name {
font-size: 20px;
}
.file.name a {
text-decoration: none;
color: #000000;
}
.file.info {
color: #A1A1A1;
}
.file.info .type {
margin-left: 10px;
}
.file.input {
font-size: 5px;
}
.file.input img {
float: left;
width: 25px;
}
.file.delete {
width: 15px;
float: right;
}
input.copy {
background-image: url('/lib/copy.svg');
background-repeat: no-repeat;
background-position: center right;
background-color: #EBEBEB;
border: 1px solid #C6C6C6;
padding: 4px;
cursor: copy;
}
.delete,
.deleteAll,
.myFiles {
display: none;
}
.newUpload {
text-align: center;
margin: 10px;
margin-top: 40px;
cursor: pointer;
}
.newUpload img{
width: 100px;
}
.error.myFiles0 {
text-align:center;
}
.fileGlobal.fileAll,
.fileGlobal.fileJust1 {
background-color: #EBEBEB;
border-radius: 25px;
border: 2px solid #CACACA;
opacity:0.6;
padding-bottom: 10px;
}
.fileJust1.icone {
margin: 5px 10px;
padding: 5px 10px;
}
#myFilesArea table {
width: 100%;
}
#myFilesArea td,
#myFilesArea th {
text-align: center;
}
#upgrade {
text-align: right;
opacity:0.6;
}
#langues {
position: fixed;
top: 0px;
right: 20px;
padding: 6px;
border: 1px solid #2F2F2F;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
background: #333333;
-moz-box-shadow: 0 0 10px black;
-webkit-box-shadow: 0 0 10px black;
box-shadow: 0 0 10px black;
opacity: 0.70;
z-index: 999; /* Sit on top */
}
#languesLegende {
position: fixed;
top: 50px;
right: 25px;
padding: 8px;
border: 1px solid #6F6C2F;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
background: #E2DC8C;
-moz-box-shadow: 0 0 10px black;
-webkit-box-shadow: 0 0 10px black;
box-shadow: 0 0 10px black;
opacity: 0.70;
z-index: 999; /* Sit on top */
}
img.drapeau {
margin-right: 6px;
margin-left: 6px;
}
img.drapeauActif {
opacity: 0.50;
}
.formChoixDeLangue {
margin: 0;
padding: 0;
}
/* Highlighted Paragraphs */
.highlight-1, .highlight-2, .highlight-3 {
-moz-border-radius : 4px;
-webkit-border-radius : 4px;
padding : 5px 10px;
}
.highlight-1 {
background : #FFCCCC;
border : 1px dotted #FF9966;
}
.highlight-2 {
background : #FFFF99;
border : 1px dotted #FFCC33;
}
.highlight-3 {
background : #CCFF99;
border : 1px dotted #CCCC33;
}

BIN
lib/trad.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

68
lib/trash.svg Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="trash-alt"
class="svg-inline--fa fa-trash-alt fa-w-14"
role="img"
viewBox="0 0 448 512"
version="1.1"
id="svg3763"
sodipodi:docname="trash.svg"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata3769">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3767" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="875"
id="namedview3765"
showgrid="false"
inkscape:zoom="1.296875"
inkscape:cx="224"
inkscape:cy="256"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg3763" />
<path
fill="currentColor"
d="M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"
id="path3761" />
<path
style="fill:#d40000;stroke-width:0.77108431"
d="M 72.344937,511.00559 C 54.42167,507.98319 39.254173,494.15356 33.73047,475.79716 32.485948,471.66136 32.382124,459.86372 32.1833,299.99036 L 31.970173,128.61687 H 224.0016 416.03303 l -0.21644,171.37349 c -0.20179,159.7799 -0.30657,171.67342 -1.54877,175.8068 -4.76232,15.84645 -16.65419,28.39251 -31.80999,33.55987 l -6.16867,2.10321 -149.97591,0.1093 c -82.48674,0.0601 -151.772486,-0.19366 -153.968313,-0.56395 z m 60.360793,-63.52582 c 4.04507,-1.20125 8.02824,-4.505 10.19329,-8.45458 1.19138,-2.17339 1.31258,-11.38977 1.53173,-116.48061 0.16706,-80.11441 -0.0118,-115.28236 -0.60025,-118.0196 -1.60955,-7.48696 -8.06723,-12.64533 -15.8305,-12.64533 -7.76327,0 -14.22095,5.15837 -15.8305,12.64533 -0.58845,2.73724 -0.76731,37.90519 -0.60025,118.0196 0.21915,105.09084 0.34035,114.30722 1.53173,116.48061 2.09262,3.81746 6.12757,7.25553 9.86878,8.40892 4.52664,1.39552 5.18017,1.39859 9.73597,0.0457 z m 99.35642,-1.44644 c 1.67755,-0.91159 4.10646,-3.16197 5.39759,-5.00086 l 2.34749,-3.34342 0.21889,-115.78911 c 0.16226,-85.82578 -0.0118,-116.63164 -0.67258,-119.04499 -1.02517,-3.74415 -5.18561,-8.39233 -8.90133,-9.94486 -3.25153,-1.35857 -9.63171,-1.36742 -12.86173,-0.0178 -1.37751,0.57556 -3.63294,2.17485 -5.01207,3.55399 -5.11077,5.11076 -4.77118,-3.68058 -4.77118,123.51847 0,102.58945 0.13425,115.91457 1.19343,118.44952 3.73028,8.92782 14.25447,12.40482 23.06149,7.61909 z m 92.64358,1.44644 c 4.04507,-1.20125 8.02824,-4.505 10.19329,-8.45458 1.19138,-2.17339 1.31258,-11.38977 1.53173,-116.48061 0.16706,-80.11441 -0.0118,-115.28236 -0.60025,-118.0196 -1.60955,-7.48696 -8.06723,-12.64533 -15.8305,-12.64533 -7.76327,0 -14.22095,5.15837 -15.8305,12.64533 -0.58845,2.73724 -0.76731,37.90519 -0.60025,118.0196 0.21915,105.09084 0.34035,114.30722 1.53173,116.48061 2.09262,3.81746 6.12757,7.25553 9.86878,8.40892 4.52664,1.39552 5.18017,1.39859 9.73597,0.0457 z"
id="path3771"
inkscape:connector-curvature="0" />
<path
style="fill:#d40000;stroke-width:0.77108431"
d="M 8.795978,93.666105 C 6.926865,92.679325 4.3566265,90.394957 3.0843373,88.589725 L 0.77108434,85.307481 0.52907235,65.563793 C 0.32366018,48.805968 0.47623857,45.324749 1.5379805,42.544618 3.0732202,38.52465 7.7568902,34.154201 11.70446,33.058023 13.66644,32.513212 35.006904,32.238489 75.588264,32.235626 l 60.937666,-0.0043 5.37559,-10.889534 C 148.08976,8.8060345 151.64293,4.6307944 158.21539,2.1717172 162.25509,0.66027312 164.09155,0.61686747 224,0.61686747 c 60.01656,0 61.7382,0.0408952 65.80677,1.56314323 6.32645,2.3670268 10.66385,7.526665 16.67557,19.8367463 l 4.98836,10.214568 60.93935,0.0043 c 40.58255,0.0029 61.92351,0.277586 63.88549,0.822398 3.94757,1.096177 8.63124,5.466626 10.16648,9.486594 1.06174,2.780132 1.21432,6.261351 1.00891,23.019176 l -0.24201,19.74367 -2.31326,3.282244 c -1.27229,1.805232 -3.84253,4.0896 -5.71163,5.07638 l -3.3984,1.794136 H 224 12.194365 Z"
id="path3773"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

163
lib/upload.js Normal file
View File

@ -0,0 +1,163 @@
$(function () {
function checkMimeTypes(mimeTypesTest) {
var mimeDetect=false;
Config_mimeTypes.forEach(function(item, index, array) {
var regex = item.replace(/\//g, "\\\/");
if (mimeTypesTest.match(regex) != undefined) {
mimeDetect=true;
}
});
if ((Config_mimeTypesConduct == 'allow' && mimeDetect)
|| (Config_mimeTypesConduct == 'deny' && !mimeDetect)) {
return true;
} else {
return false;
}
}
/**
* Function called to upload one file.
* @param file
* @param item
*/
function uploadFile(item, file, expire, random, resize, key) {
// Add progress bar
$('.progress').show();
$('.progress').append('<span class="file-' + item + '">' + file.name + '</span><br /><progress class="progress-' + item + '" value="0" max="100"></progress>');
// Create object XMLHttpRequest
var request = new XMLHttpRequest();
// Event progress to change value of progress bar
request.upload.addEventListener('progress', function (e) {
$('.progress-' + item).css('display', 'block');
var value = Math.round((e.loaded / e.total) * 100);
$('.progress-' + item).attr("value", value);
}, false);
// Create object FormData
var formData = new FormData();
// Add file to FormData
formData.append('random', random);
formData.append('item', item);
formData.append('file', file);
formData.append('expire', expire);
formData.append('resize', resize);
formData.append('key', key);
// File to call
request.open('post', 'upload.php');
// Function called when request ended
request.onload = function (e) {
$('#result').append(request.response);
};
// Send request
request.send(formData);
}
/**
* Function called to upload files.
*/
function upload() {
// Vide les messages si jamais il y en avait
$( "#preUpload" ).html( "" );
var upload = true;
// Get files
var files = $('#files')[0].files;
var expire = Math.floor(Date.now() / 1000 + $('#expire').val() * 86400);
var random = Math.floor(Math.random() * Math.floor(99));
// Check size and mime
var fileAlreadyUploadSizeTotal = 0;
for (var i = 0; i < files.length; i++) {
// Size
fileAlreadyUploadSizeTotal = fileAlreadyUploadSizeTotal + document.getElementById("files").files[i].size;
if (document.getElementById("files").files[i].size > Config_maxUploadPerFile) {
$('#preUpload').append('<div class="highlight-1">' + document.getElementById("files").files[i].name + ' : ' + Msg_errorFileSize + '</div>');
upload = false;
}
// Mime
if (!checkMimeTypes(document.getElementById("files").files[i].type)) {
$('#preUpload').append('<div class="highlight-1">' + document.getElementById("files").files[i].name + ' : ' + Msg_errorFileType + '</div>');
upload = false;
}
}
if (fileAlreadyUploadSizeTotal > Config_maxUploadTotal) {
$('#preUpload').append('<div class="highlight-1">' + Msg_errorTotalSize + '</div>');
upload = false;
}
if (files.length > Config_maxUploadNb) {
$('#preUpload').append('<div class="highlight-1">' + Msg_errorUploadNb + '</div>');
upload = false;
}
if (files.length == 0) {
upload = false;
}
// Upload file by file
if (upload == true) {
// Session pour compter le nombre de fichier en cours de download
sessionStorage.setItem('uploadWait', files.length);
$( ".uploadArea" ).hide();
// On lance l'upload fichier par fichier:
for (var i = 0; i < files.length; i++) {
if (i == 0) {
// On mémorise l'upload dans le localStorage
if (localStorage.getItem('myFiles')) {
var data = JSON.parse(localStorage.getItem('myFiles'));
} else {
var data = {items: []};
}
var keyGen = Math.floor(Math.random() * (999999999999 - 100000000000) + 100000000000);
data.items.push(
{id: expire + '-' + random, key: keyGen}
);
localStorage.setItem('myFiles', JSON.stringify(data));
}
uploadFile(i, files[i], expire, random, $('#resize').val(), keyGen);
}
}
}
// Copy on clipart : https://stackoverflow.com/questions/44888884/copying-to-clipboard-textbox-value-using-jquery-javascript
function copyToClipboard(text) {
var textArea = document.createElement( "textarea" );
textArea.value = text;
document.body.appendChild( textArea );
textArea.select();
try {
var successful = document.execCommand( 'copy' );
var msg = successful ? 'successful' : 'unsuccessful';
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild( textArea );
}
$('.btn-upload').on('click', upload);
$( "#similarServices" ).click(function() {
$('.similarHref').hide();
$('.similarLink').show();
});
$(document).on('click', '.copy', function(e){
e.preventDefault();
copyToClipboard($(this).val());
});
$("input[type=file]").on('change',function(){
$('#resizeForm').hide();
for (var i = 0; i < this.files.length; i++) {
var mime = this.files[i].type;
if (mime.match('^image\/(png|jpeg|gif)$')) {
$('#resizeForm').show();
}
}
});
});

1
lib/upload.svg Normal file
View File

@ -0,0 +1 @@
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="cloud-upload-alt" class="svg-inline--fa fa-cloud-upload-alt fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z"></path></svg>

After

Width:  |  Height:  |  Size: 683 B

3
robots.txt Executable file
View File

@ -0,0 +1,3 @@
User-Agent: *
Allow: /
Disallow: /*

1
site.webmanifest Normal file
View File

@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

74
upload.php Normal file
View File

@ -0,0 +1,74 @@
<?php
if (!isset($_POST['expire']) or !isset($_POST['item']) or !isset($_POST['key']) or !isset($_FILES) or !isset($_POST['random'])) {
exit('No hack 1');
}
$config = yaml_parse_file('./config.yaml');
include('./lib/functions.php');
// Vérification si le calcul d'expiration est conforme à la config
// Complexe, dépend trop du temps d'upload côté client
/*if ($_POST['expire'] <= time()+$config['expireDay'][count($config['expireDay'])-1]*86400+5) {
exit('No hack 2');
}
*/
// Définition des variables
$uploadDir = $config['uploadDir'].'/'.$_POST['expire'].'-'.$_POST['random'];
$uploadFile = preg_replace("#[^a-zA-Z0-9.]#", "", basename($_FILES['file']['name']));
// Création du répertoire
if (!is_dir($uploadDir)) {
mkdir($uploadDir);
} else {
$fileAlreadyUploadSizeTotal=0;
foreach (scandir($uploadDir) as $fileAlreadyUpload) {
if (is_file($uploadDir.'/'.$fileAlreadyUpload)) {
$fileAlreadyUploadSizeTotal=filesize($uploadDir.'/'.$fileAlreadyUpload)+$fileAlreadyUploadSizeTotal;
}
}
}
if (!is_file($uploadDir.'/.key-'.$_POST['key'])) {
touch($uploadDir.'/.key-'.$_POST['key']);
}
if (!checkMimeTypes($_FILES['file']['type'])) {
printf('<div class="highlight-1">'._('this type of file isn\'t allow').'</div>');
echo "<script>
$( '.progress-".$_POST['item']."').remove();
$('.file-".$_POST['item']."').append(' : <spam class=\"file-".$_POST['item']." uploadResult nok\">KO</spam>');
</script>";
} else if ($_FILES['file']['size'] > convertHumain2octect($config['maxUploadPerFile'])) {
printf('<div class="highlight-1">'.basename($_FILES['file']['name']).' : '._('this file exceeds the allowed size %s').'</div>', $config['maxUploadPerFile']);
echo "<script>
$( '.progress-".$_POST['item']."').remove();
$('.file-".$_POST['item']."').append(' : <spam class=\"file-".$_POST['item']." uploadResult nok\">KO</spam>');
</script>";
} else if ($fileAlreadyUploadSizeTotal > convertHumain2octect($config['maxUploadTotal'])) {
printf('<div class="highlight-1">'._('The total size of the files exceeds the allowed size %s').'</div>', $config['maxUploadTotal']);
echo "<script>
$( '.progress-".$_POST['item']."').remove();
$('.file-".$_POST['item']."').append(' : <spam class=\"file-".$_POST['item']." uploadResult nok\">KO</spam>');
</script>";
} else {
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadDir.'/'.$uploadFile)
&& $_FILES['file']['error'] == 0) {
if (isset($_POST['resize']) && $_POST['resize'] != 0) {
@resize_image($uploadDir.'/'.$uploadFile , $uploadDir.'/'.$uploadFile.'.resize' , $_POST['resize'] , $_POST['resize']);
@rename($uploadDir.'/'.$uploadFile.'.resize', $uploadDir.'/'.$uploadFile);
}
echo "<script>
sessionStorage.setItem('uploadWait', Number(sessionStorage.getItem('uploadWait'))-1);
$( '.progress-".$_POST['item']."').remove();
$('.file-".$_POST['item']."').append(' : <spam class=\"file-".$_POST['item']." uploadResult ok\">Ok</spam>');
if (sessionStorage.getItem('uploadWait') <= 0) {
sessionStorage.removeItem('uploadWait');
window.location.href = Config_baseUrl + '".$_POST['expire']."-".$_POST['random']."/';
}
</script>";
} else {
printf('<div class="highlight-1">'._('Unknown error').'</div>');
echo "<script>sessionStorage.setItem('uploadWait', sessionStorage.getItem('uploadWait')+1);</script>";
}
}