diff --git a/.htaccess b/.htaccess index 66ed3d0..712feb7 100644 --- a/.htaccess +++ b/.htaccess @@ -1,20 +1,27 @@ Options -Indexes RewriteEngine on -# Sécurité +## 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 +## Rewrite +# direct 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] +# html page +RewriteRule ^([0-9]+-[0-9]{1,2})/ index.php?action=html&id=$1&%{QUERY_STRING} [L] +# download force RewriteRule ^dl/([0-9]+-[0-9]{1,2})/(.+)$ index.php?action=dl&id=$1&file=$2 [L] +# delete 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] +# zip 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] +# Mes fichiers +RewriteRule ^My$ index.php?action=myFiles&%{QUERY_STRING} [L] +# Pages +RewriteRule ^(.+)\.html$ index.php?action=page&name=$1&%{QUERY_STRING} [L] # Error ErrorDocument 404 /index.php?action=404 ErrorDocument 403 /index.php?action=403 diff --git a/README.md b/README.md index 9ca7d20..5c654c2 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,54 @@ -Req -- http serveur compatible url rewriting (apache2 for exemple) -- +# file2link +PHP file sharing service [free of rights](https://en.wikipedia.org/wiki/Open_source) (license [Beerware](https://en.wikipedia.org/wiki/Beerware)) and free. -Install +**Demonstration : https://dl.zici.fr/** -ReadWrite is ok for "file" +## Requis -Configure -mv config.yaml.exemple config.yaml + - HTTP serveur htaccess compatible (url rewriting enable) + - PHP 5.6 minimum + - PHP GD lib + - No nessecary database +## Installation +Upload source content on you web server - - 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 +Move config file : -crontab... + mv config.yaml.exemple config.yaml -header-page.php -header.php -footer-page.php -footer.php -file2link_checkupdate -start-home.php -end-home.php +Change paramètre in config.yaml Make sure the consistency between: + - *maxUploadPerFile* is similar to PHP config *upload_max_filesize* and *post_max_size* + - *maxUploadNb* is similar to PHP config *max_file_uploads* + +Make sure the "files" directory is writable -php gd +## Changelog -resize for png (no transparent), gif, jpeg + - 0.1 (16/10/2019) + - Configure with YAML file + - Submit a file upload service with temporary link (Direct link, force download link, download multiple after zip) + - Limit in time + - Limit in number is possible + - Limit on type of file (mime) is possible + - Upload with progress bar in HTML5 + - Upload multi file + - Multilingual (French / English) + - Images resize possible + - Find these files before uploader (local storage) + - Housekeeping in files expired by cron job or by web traffic on the page + - Personnalize content page with include header-page.php, header.php, footer-page.php, footer.php, start-home.php, end-home.php + +# Licence + +Beerware : https://en.wikipedia.org/wiki/Beerware + +# Crédit -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 -============= +# Author -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 +David Mercereau [david #arobase# mercereau #point# info](http://david.mercereau.info/contact/) diff --git a/config.yaml.dist b/config.yaml.dist new file mode 100644 index 0000000..497d073 --- /dev/null +++ b/config.yaml.dist @@ -0,0 +1,57 @@ +shortTitle: "File 2 Link" +title: "A file against a temporary link" +backgroundImage: https://picsum.photos/1024/768?random=1 +baseUrl: https://yoururl.tdl/ +uploadDir: files # Dir in Read/Write accès +expireCron: web # 'web' or 'cli' +expireCronFreq: 86400 # juste for cron web, in second (exemple 86400 = 1j) +expireDay: + - 1 + - 7 + - 30 + - 90 + - 180 + - 365 +expireDayDefault : 7 +imageResize: # Propose resize images + - 0 # 0 = no resize + - 300 + - 800 + - 1024 + - 2048 + - 4096 +imageResizeDefault : 1024 +maxUploadPerFile: 30M # Exemple 100K, 30M, 12G +maxUploadTotal: 90M # Exemple 100K, 30M, 12G +maxUploadNb: 100 +mimeTypesConduct: allow # allow = Allow this, deny the rest / deny = Deny this, allow the rest +mimeTypes: # pattern for pgrep_match https://www.php.net/manual/function.preg-match.php + - ^text\/ + - ^image\/ + - ^audio\/ + - ^video\/ + - ^font\/ + - ^application\/x-bzip + - ^application\/x-csh$ + - ^application\/msword$ + - ^application\/vnd.openxmlformats-officedocument. + - ^application\/epub+zip$ + - ^application\/vnd.oasis.opendocument. + - ^application\/ogg + - ^application\/pdf$ + - ^application\/x-rar-compressed$ + - ^application\/vnd.ms-powerpoint$ + - ^application\/x-tar$ + - ^application\/vnd.visio$ + - ^application\/vnd.ms-excel$ + - ^application\/zip$ + - ^application\/x-7z-compressed$ +similarServicesView: true +similarServicesLink: + - Firefox Send + - ToffeeShare + - Envelop + - Framadrop +htmlPages: # This page is search in dir "htmlPages/$name.html" clear if you wan't disable + cgu: CGU # Print page "htmlPages/cgu.html" +checkUpdate: 86400 # in seconds or "false" for disable diff --git a/index.php b/index.php index 56665c1..7643169 100644 --- a/index.php +++ b/index.php @@ -15,6 +15,53 @@ if (isset($_GET['id'])){ $id = null; } +/* Language */ +if (isset($_GET['langueChange'])) { + $locale = lang2locale($_GET['langueChange']); + $localeshort=locale2lang($locale); + setcookie("langue",$localeshort,strtotime( '+1 year' ), '/'); +} else { + if (isset($_COOKIE['langue'])) { + $locale = lang2locale($_COOKIE['langue']); + $localeshort=locale2lang($locale); + } else { + $HTTP_ACCEPT_LANGUAGE=$_SERVER['HTTP_ACCEPT_LANGUAGE']; + //echo $HTTP_ACCEPT_LANGUAGE.'
'; + $lang_from_http_accept = explode(',', $HTTP_ACCEPT_LANGUAGE); + //echo $lang_from_http_accept[0].'
'; + $locale = lang2locale($lang_from_http_accept[0]); + if (substr($locale,0,2) != substr($lang_from_http_accept[0],0,2)) { + //echo "Non trouvé, 2ème tentative"; + $lang_from_http_accept = explode('-', $lang_from_http_accept[0]); + //echo $lang_from_http_accept[0].'
'; + $locale = lang2locale($lang_from_http_accept[0]); + } + //echo $locale.'
'; + $localeshort=locale2lang($locale); + } +} + +// Définition de la langue : +$results=putenv("LC_ALL=$locale.utf8"); +if (!$results) { + exit ('putenv failed'); +} +$results=putenv("LC_LANG=$locale.utf8"); +if (!$results) { + exit ('putenv failed'); +} +$results=putenv("LC_LANGUAGE=$locale.utf8"); +if (!$results) { + exit ('putenv failed'); +} +$results=setlocale(LC_ALL, "$locale.utf8"); +if (!$results) { + exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment'); +} +bindtextdomain("messages", "./lang"); +textdomain("messages"); +/* / language */ + 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'])); } @@ -109,7 +156,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') { - Upload + <?= $config['shortTitle'] ?> : <?= $config['title'] ?>