Prechádzať zdrojové kódy

Checksum début d'implémentation

davidmercereau 2 rokov pred
rodič
commit
f50722a5d1

+ 0 - 0
files/checksum.db


+ 5 - 0
index.php

@@ -161,6 +161,11 @@ if ($passwordForm == false) {
         if (isset($_GET['file'])) {
             @unlink($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
             @unlink($config['uploadDir'].'/'.$id.'/.'.$_GET['file'].'.small');
+            // Checksum
+            $checksum = new Checksum();
+            $deleteFile = $checksum->deleteFile($config['uploadDir'].'/'.$id.'/'.$_GET['file']);
+            error_log('checksum>deleteFile : '.$config['uploadDir'].'/'.$id.'/'.$_GET['file']);
+            error_log('checksum>deleteFile return    : '.json_encode($deleteFile));
             // Si c'est le dernire, on supprime le tout
             $uploadDirId = $config['uploadDir'].'/'.$id.'/';
             $nbFile=0;

+ 0 - 1
lang/fr

@@ -1 +0,0 @@
-fr_FR/

BIN
lang/fr/LC_MESSAGES/messages.mo


+ 328 - 0
lang/fr/LC_MESSAGES/messages.po

@@ -0,0 +1,328 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2020-05-01 23:52+0200\n"
+"PO-Revision-Date: 2020-05-02 00:48+0200\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"Language: fr_FR\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.2.4\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: cron.php:8
+msgid "Start the command in the file2link directory"
+msgstr "Lancer la commande dans le répertoire de travail file2link"
+
+#: cron.php:11
+msgid "Completed"
+msgstr "Terminé"
+
+#: cron.php:13
+msgid "expireCron is not at \"cli\" mod (in config.yaml)"
+msgstr "expireCron n'est pas à la valeur \"cli\" (dans le config.yaml)"
+
+#: functions.php:94
+msgid "Expired"
+msgstr "Expiré"
+
+#: index.php:69
+#, php-format
+msgid "In coherence with your configuration (config.yaml) you must increase the PHP configuration upload_max_filesize to %s"
+msgstr "En cohérence avec votre configuration (config.yaml), vous devez modifier la configuration PHP upload_max_filesize à %s"
+
+#: index.php:72
+#, php-format
+msgid "In coherence with your configuration (config.yaml) you must increase the PHP configuration post_max_size to %s"
+msgstr "En cohérence avec votre configuration (config.yaml), vous devez modifier la configuration PHP post_max_size à %s"
+
+#: index.php:75
+#, php-format
+msgid "In coherence with your configuration (config.yaml) you must increase the PHP configuration max_file_uploads to %s"
+msgstr "En cohérence avec votre configuration (config.yaml), vous devez modifier la configuration PHP max_file_uploads à %s"
+
+#: index.php:207
+#, php-format
+msgid "this file exceeds the allowed size %s"
+msgstr "ce fichier dépasse la taille autorisée %s"
+
+#: index.php:208
+#, php-format
+msgid "The total size of the files exceeds the allowed size : %s"
+msgstr "La taille totale des fichiers dépasse la taille autorisée: %s"
+
+#: index.php:209
+#, php-format
+msgid "You can not send more than %d files at a time"
+msgstr "Vous ne pouvez pas envoyer plus de %d fichiers à la fois"
+
+#: index.php:210
+#, php-format
+msgid "this type of file isn\\'t allow"
+msgstr "ce type de fichier n’autorise pas"
+
+#: index.php:265
+msgid "Maintenance"
+msgstr "Maintenance"
+
+#: index.php:271
+msgid "Mode Maintenance as true"
+msgstr "Le mode maintenance est activé"
+
+#: index.php:278
+msgid "Similar services"
+msgstr "Services similaires"
+
+#: index.php:303
+msgid "Send / share your files"
+msgstr "Envoyer/partager vos fichier"
+
+#: index.php:316
+msgid "Expire"
+msgstr "Expiration"
+
+#: index.php:318
+msgid "days"
+msgstr "jours"
+
+#: index.php:320
+msgid "day"
+msgstr "jour"
+
+#: index.php:334
+msgid "Add files..."
+msgstr "Ajouter un fichier"
+
+#: index.php:339
+msgid "Start upload"
+msgstr "Démarrer l'envoi"
+
+#: index.php:343
+msgid "Cancel upload"
+msgstr "Annuler l'envoi"
+
+#: index.php:347
+msgid "See the files already sent"
+msgstr "Voir les fichiers déjà envoyés"
+
+#: index.php:354 index.php:408
+msgid "The total limit per upload is "
+msgstr "La limite totale par envoi est de "
+
+#: index.php:379
+msgid "The sharing will be accessible from"
+msgstr "Le partage sera accessible avec"
+
+#: index.php:381 index.php:383
+msgid "Options"
+msgstr "Options"
+
+#: index.php:384
+msgid "Images resize"
+msgstr "Redimensionner les images"
+
+#: index.php:389
+msgid "No resizing"
+msgstr "Pas de redimensionnement"
+
+#: index.php:399
+msgid "Protect with password"
+msgstr "Protéger avec un mot de passe"
+
+#: index.php:400
+msgid "Delete after access"
+msgstr "Supprimer après l'accès"
+
+#: index.php:400
+msgid "Number of accesses before deletion (1 minimum)"
+msgstr "Nombre d'accès avant suppression (1 minimum)"
+
+#: index.php:406
+msgid "The limit per file is "
+msgstr "La limite par fichier est "
+
+#: index.php:419
+#, php-format
+msgid "Error: The directory (%s) is not writable, please contact the service administrator"
+msgstr "Erreur: le répertoire (%s) n'est pas accessible en écriture, veuillez contacter l'administrateur du service"
+
+#: index.php:427
+msgid "Error: Incorrect password"
+msgstr "Erreur: mot de passe incorrect"
+
+#: index.php:431
+msgid "This file is protected by a password, thank you to indicate it below"
+msgstr "Ce fichier est protégé par un mot de passe, merci de l'indiquer ci-dessous"
+
+#: index.php:447 index.php:449
+msgid "The requested page does not exist"
+msgstr "La page demandée n'existe pas"
+
+#: index.php:470
+#, php-format
+msgid "These files will be automatically deleted on %s, ie in %d days"
+msgstr "Ces fichiers seront automatiquement supprimés le %s, c'est-à-dire dans %d jours"
+
+#: index.php:478
+#, php-format
+msgid "These files will be automatically deleted in %d access"
+msgstr "Ces fichiers seront automatiquement supprimés après %d accès"
+
+#: index.php:497
+msgid "View in list mode "
+msgstr "Afficher en mode liste "
+
+#: index.php:499
+msgid "View in gallery mode "
+msgstr "Afficher en mode galerie "
+
+#: index.php:504
+msgid "Error: Nothing to display"
+msgstr "Erreur: rien à afficher"
+
+#: index.php:509
+msgid "This page"
+msgstr "Cette page"
+
+#: index.php:544
+msgid "All"
+msgstr "Tout"
+
+#: index.php:544
+msgid "Delete all (permanently)"
+msgstr "Supprimer tout (définitivement)"
+
+#: index.php:545 index.php:547 index.php:549 index.php:580 index.php:581
+msgid "Click to copy the link to the clipboard"
+msgstr "Cliquer pour copier le lien dans le presse papier"
+
+#: index.php:576 index.php:701
+msgid "Size"
+msgstr "Taille"
+
+#: index.php:577
+msgid "Type"
+msgstr "Type"
+
+#: index.php:587
+msgid "Add files to this share"
+msgstr "Ajouter des fichiers à ce partage"
+
+#: index.php:671
+msgid "Are you sure you want to delete everything?"
+msgstr "Voulez-vous vraiment tout supprimer?"
+
+#: index.php:679
+msgid "Are you sure you want to delete it?"
+msgstr "Es-tu sûr de vouloir le supprimer?"
+
+#: index.php:697
+msgid "My files"
+msgstr "Mes fichiers"
+
+#: index.php:699 index.php:771
+msgid "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."
+msgstr "Service de partage de fichiers en ligne <a href=\"https://en.wikipedia.org/wiki/Open_source\"> libre de droits </a> (licence <a href = \"https://en.wikipedia.org/wiki/Beerware \"> Bière </a>) et gratuite."
+
+#: index.php:701
+msgid "Nb of files"
+msgstr "Nb de fichiers"
+
+#: index.php:701
+msgid "Creation date "
+msgstr "Date de création "
+
+#: index.php:701
+msgid "Expiration date"
+msgstr "Date d'expiration"
+
+#: index.php:701
+msgid "Remaining access"
+msgstr "Accès restant"
+
+#: index.php:701
+msgid "Password"
+msgstr "Mot de passe"
+
+#: index.php:701 my.php:64
+msgid "Link"
+msgstr "Lien"
+
+#: index.php:744
+msgid "All your files have expired."
+msgstr "Tous vos fichiers ont expiré."
+
+#: index.php:746
+msgid "No files, maybe all of them have expired."
+msgstr "Aucun fichier, peut-être que tous ont expiré."
+
+#: index.php:754 index.php:756
+msgid "Unauthorized access"
+msgstr "Accès non autorisé"
+
+#: index.php:760
+msgid "Not Found"
+msgstr "Introuvable"
+
+#: index.php:762
+msgid "This sharing does not exist, it has probably expired"
+msgstr "Ce partage n'existe pas, il a probablement expiré"
+
+#: index.php:785
+msgid "By"
+msgstr "Par"
+
+#: index.php:785
+msgid "Git repository"
+msgstr "Source git"
+
+#: index.php:786
+msgid "version"
+msgstr "version"
+
+#: index.php:786
+msgid "is an open software licensed <a href=\"https://en.wikipedia.org/wiki/Beerware\">Beerware</a>"
+msgstr "est un logiciel libre sous licence <a href=\"https://en.wikipedia.org/wiki/Beerware\"> Beerware </a>"
+
+#: index.php:865 index.php:903
+msgid "Cancel"
+msgstr "Annuler"
+
+#: my.php:42
+msgid "Multi"
+msgstr "Multi"
+
+#: my.php:57
+msgid "Unlimited"
+msgstr "Illimité"
+
+#: my.php:60
+msgid "Yes"
+msgstr "Oui"
+
+#: my.php:62
+msgid "No"
+msgstr "Non"
+
+#~ msgid "Send a new file"
+#~ msgstr "Envoyez un nouveau fichier"
+
+#~ msgid "The limit per file is %dM,  and the total limit per upload is %dM"
+#~ msgstr "La limite par fichier est de %dM et la limite totale par téléchargement est de %dM"
+
+#~ msgid "this type of file isn't allow"
+#~ msgstr "ce type de fichier n'est pas autorisé"
+
+#~ msgid "The total size of the files exceeds the allowed size %s"
+#~ msgstr "La taille totale des fichiers dépasse la taille autorisée %s"
+
+#~ msgid "Unknown error"
+#~ msgstr "Erreur inconnue"

+ 0 - 1
lang/oc

@@ -1 +0,0 @@
-oc_FR/

BIN
lang/oc/LC_MESSAGES/messages.mo


+ 336 - 0
lang/oc/LC_MESSAGES/messages.po

@@ -0,0 +1,336 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2019-12-05 14:57+0100\n"
+"PO-Revision-Date: 2020-04-01 12:48+0200\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 2.3\n"
+"Last-Translator: Quentin PAGÈS\n"
+"Language: oc\n"
+
+#: cron.php:8
+msgid "Start the command in the file2link directory"
+msgstr "Començar la comanda dins lo repertòri de file2link"
+
+#: cron.php:11
+msgid "Completed"
+msgstr "Acabat"
+
+#: cron.php:13
+msgid "expireCron is not at \"cli\" mod (in config.yaml)"
+msgstr "expireCron es pas al mòde \"cli\" (dins config.yaml)"
+
+#: functions.php:93
+msgid "Expired"
+msgstr "Expirats"
+
+#: index.php:68
+#, php-format
+msgid ""
+"In coherence with your configuration (config.yaml) you must increase the PHP "
+"configuration upload_max_filesize to %s"
+msgstr ""
+"Una incoeréncia amb vòstra configuracion (config.yaml), vos cal aumentar la "
+"configuracion PHP per upload_max_filesize a %s"
+
+#: index.php:71
+#, php-format
+msgid ""
+"In coherence with your configuration (config.yaml) you must increase the PHP "
+"configuration post_max_size to %s"
+msgstr ""
+"Una incoeréncia amb vòstra configuracion (config.yaml), vos cal aumentar la "
+"configuracion PHP per post_max_size a %s"
+
+#: index.php:74
+#, php-format
+msgid ""
+"In coherence with your configuration (config.yaml) you must increase the PHP "
+"configuration max_file_uploads to %s"
+msgstr ""
+"Una incoeréncia amb vòstra configuracion (config.yaml), vos cal aumentar la "
+"configuracion PHP per max_file_uploads a %s"
+
+#: index.php:208 upload.php:59
+#, php-format
+msgid "this file exceeds the allowed size %s"
+msgstr "aqueste fichièr subrepassa la talha autorizada %s"
+
+#: index.php:209
+#, php-format
+msgid "The total size of the files exceeds the allowed size : %s"
+msgstr "Aquesta talha totala de fichièrs subrepassa la talha autorizada : %s"
+
+#: index.php:210
+#, php-format
+msgid "You can not send more than %d files at a time"
+msgstr "Podètz pas enviar mai de %d fichièrs al còp"
+
+#: index.php:211
+#, php-format
+msgid "this type of file isn\\'t allow"
+msgstr "aqueste tipe de fichièr es pas autorizat"
+
+#: index.php:248
+msgid "Maintenance"
+msgstr "Mòde mentenença"
+
+#: index.php:254
+msgid "Mode Maintenance as true"
+msgstr "Mòde mentenença coma true"
+
+#: index.php:261
+msgid "Similar services"
+msgstr "Servicis semblables"
+
+#: index.php:286
+msgid "Send a new file"
+msgstr "Enviar un fichièr novèl"
+
+#: index.php:287 index.php:645
+msgid "See the files already sent"
+msgstr "Veire los fichièrs ja enviats"
+
+#: index.php:297
+#, php-format
+msgid ""
+"Error: The directory (%s) is not writable, please contact the service "
+"administrator"
+msgstr ""
+"Error : se pòt escriure dins lo repertòri (%s), mercés de contactar "
+"l’administrator de servici"
+
+#: index.php:304
+msgid "Error: Incorrect password"
+msgstr "Error : senhal incorrèct"
+
+#: index.php:308
+msgid "This file is protected by a password, thank you to indicate it below"
+msgstr "Aqueste fichièr es protegit amb un senhal, mercés de lo picar çai-jos"
+
+#: index.php:324 index.php:326
+msgid "The requested page does not exist"
+msgstr "La pagina demandada existís pas"
+
+#: index.php:346
+#, php-format
+msgid "These files will be automatically deleted on %s, ie in %d days"
+msgstr ""
+"Aquestes fichièrs seràn automaticament escafats lo %s, es a dire d’aquí %d "
+"jorns"
+
+#: index.php:354
+#, php-format
+msgid "These files will be automatically deleted in %d access"
+msgstr "Aquestes fichièrs seràn automaticament escafats d’aquí %d accèsses"
+
+#: index.php:373
+msgid "View in list mode "
+msgstr "Vista en lista "
+
+#: index.php:375
+msgid "View in gallery mode "
+msgstr "Vista en galariá "
+
+#: index.php:380
+msgid "Error: Nothing to display"
+msgstr "Error : pas res a afichar"
+
+#: index.php:385
+msgid "This page"
+msgstr "Aquesta pagina"
+
+#: index.php:420
+msgid "All"
+msgstr "Totes"
+
+#: index.php:420
+msgid "Delete all (permanently)"
+msgstr "Suprimir (definitivament)"
+
+#: index.php:421 index.php:423 index.php:425 index.php:456 index.php:457
+msgid "Click to copy the link to the clipboard"
+msgstr "Clicatz per copiar lo ligam al quichapapièr"
+
+#: index.php:452 index.php:569
+msgid "Size"
+msgstr "Talha"
+
+#: index.php:453
+msgid "Type"
+msgstr "Tipe"
+
+#: index.php:537
+msgid "Are you sure you want to delete everything?"
+msgstr "Volètz vertadièrament o suprimir tot ?"
+
+#: index.php:545
+msgid "Are you sure you want to delete it?"
+msgstr "Lo volètz vertadièrament suprimir ?"
+
+#: index.php:566
+msgid "My files"
+msgstr "Mos fichièrs"
+
+#: index.php:567 index.php:637
+msgid ""
+"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."
+msgstr ""
+"Servici de partatge de fichièr en linha <a href=\"https://en.wikipedia.org/"
+"wiki/Open_source\">liure de dreches</a> (licéncia <a href=\"https://en."
+"wikipedia.org/wiki/Beerware\">Beerware</a>) e gratuït."
+
+#: index.php:569
+msgid "Nb of files"
+msgstr "Nb de fichièrs"
+
+#: index.php:569
+msgid "Creation date "
+msgstr "Data de creacion "
+
+#: index.php:569
+msgid "Expiration date"
+msgstr "Data d'expiracion"
+
+#: index.php:569
+msgid "Remaining access"
+msgstr "Accèsses restants"
+
+#: index.php:569
+msgid "Password"
+msgstr "Senhal"
+
+#: index.php:569 my.php:64
+msgid "Link"
+msgstr "Ligam"
+
+#: index.php:612
+msgid "All your files have expired."
+msgstr "Totes vòstres fichièrs expirèron."
+
+#: index.php:614
+msgid "No files, maybe all of them have expired."
+msgstr "Cap de fichièr, benlèu qu’expirèron totes."
+
+#: index.php:622 index.php:623
+msgid "Unauthorized access"
+msgstr "Accès defendut"
+
+#: index.php:627
+msgid "Not Found"
+msgstr "Pas trobat"
+
+#: index.php:628
+msgid "This sharing does not exist, it has probably expired"
+msgstr "Aqueste partatge existís pas, es probable qu’expirèt"
+
+#: index.php:643
+msgid "Choose one or more files"
+msgstr "Causir un o mantun fichièr"
+
+#: index.php:644
+msgid "Send file"
+msgstr "Enviar fichièr"
+
+#: index.php:651
+msgid "Expire"
+msgstr "Expiracion"
+
+#: index.php:654
+msgid "days"
+msgstr "jorns"
+
+#: index.php:656
+msgid "day"
+msgstr "jorn"
+
+#: index.php:666 index.php:668
+msgid "Options"
+msgstr "Opcions"
+
+#: index.php:669
+msgid "Protect with password"
+msgstr "Protegir amb un senhal"
+
+#: index.php:670
+msgid "Delete after access"
+msgstr "Suprimir aprèp accès"
+
+#: index.php:670
+msgid "Number of accesses before deletion (1 minimum)"
+msgstr "Nombre d’accèsses abans supression (1 minimum)"
+
+#: index.php:673
+msgid "Images resize"
+msgstr "Redimencion d’imatge"
+
+#: index.php:678
+msgid "No resizing"
+msgstr "Cap de redimencion"
+
+#: index.php:688
+#, php-format
+msgid "The limit per file is %dM,  and the total limit per upload is %dM"
+msgstr "La limita per fichièr es %dM,  e la limita totala per mandadís es %dM"
+
+#: index.php:698
+msgid "By"
+msgstr "Per"
+
+#: index.php:698
+msgid "Git repository"
+msgstr "Repertòri Git"
+
+#: index.php:699
+msgid "version"
+msgstr "version"
+
+#: index.php:699
+msgid ""
+"is an open software licensed <a href=\"https://en.wikipedia.org/wiki/Beerware"
+"\">Beerware</a>"
+msgstr ""
+"es un logicial liure jos licéncia <a href=\"https://en.wikipedia.org/wiki/"
+"Beerware\">Beerware</a>"
+
+#: my.php:42
+msgid "Multi"
+msgstr "Multi"
+
+#: my.php:57
+msgid "Unlimited"
+msgstr "Cap de limit"
+
+#: my.php:60
+msgid "Yes"
+msgstr "Òc"
+
+#: my.php:62
+msgid "No"
+msgstr "Non"
+
+#: upload.php:53
+#, php-format
+msgid "this type of file isn't allow"
+msgstr "aqueste tipe de fichièr es pas autorizat"
+
+#: upload.php:65
+#, php-format
+msgid "The total size of the files exceeds the allowed size %s"
+msgstr "La talha totala de fichièrs subrepassa la talha autorizada %s"
+
+#: upload.php:87
+#, php-format
+msgid "Unknown error"
+msgstr "Error desconeguda"

+ 86 - 0
lib/Checksum.php

@@ -0,0 +1,86 @@
+<?php
+class Checksum{
+    private $config;
+    private $dbco;
+    // Récupération de la config
+    public function __construct(){
+		global $config;
+        $this->config = $config;
+        // # Sans effet
+        // if ($this->config->check_checksum !== true) {
+        //     return false;
+        // }
+        // Connect DB
+        try {
+            $this->dbco = new PDO('sqlite:'.$this->config['checksumDb']);
+            $this->dbco->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+        } catch ( PDOException $e ) {
+            die("Connexion à la base '".$this->config['checksumDb']."' : ".$e->getMessage());
+        }
+        // Create DB if not exists
+        try {
+            $create = $this->dbco->query("
+                CREATE TABLE IF NOT EXISTS checksum (
+                id INTEGER PRIMARY KEY,
+                file_path CHAR(250) NOT NULL,
+                file_md5sum CHAR(150) NOT NULL UNIQUE,
+                dateExpir INTEGER NOT NULL);
+            ");
+        } catch ( PDOException $e ) {
+            echo "Error initializing checksum tables";
+            die();
+        }
+	}
+
+    function cleanExpire() {
+        try {
+            $deletecmd = $this->dbco->prepare("DELETE FROM checksum WHERE  dateExpir < ".time());
+            $deletecmd->execute();
+        } catch (PDOException $e) {
+            return ['error' => $e->getMessage()];
+        }
+        return true;
+    }
+
+    function deleteFile($file_path) {
+        try {
+            $deletecmd = $this->dbco->prepare("DELETE FROM checksum WHERE file_path = :file_path");
+            $deletecmd->bindParam('file_path', $file_path, PDO::PARAM_STR);
+            $deletecmd->execute();
+        } catch (PDOException $e) {
+            return ['error' => $e->getMessage()];
+        }
+        return true;
+    }
+
+    function addFile($file_path, $file_md5sum, $dateExpir) {
+        try {
+            $insertcmd = $this->dbco->prepare("INSERT INTO checksum (file_path, file_md5sum, dateExpir) 
+                                            VALUES (:file_path, :file_md5sum, :dateExpir)");
+            $insertcmd->bindParam('file_path', $file_path, PDO::PARAM_STR);
+            $insertcmd->bindParam('file_md5sum', $file_md5sum, PDO::PARAM_STR);
+            $insertcmd->bindParam('dateExpir', $dateExpir, PDO::PARAM_INT);
+            $insertcmd->execute();
+        } catch (PDOException $e) {
+            return ['error' => $e->getMessage()];
+        }
+        return true;
+    }
+
+    function checkChecksum($checksum) {
+        if ($this->config['check_checksum'] != true) {
+            return false;
+        }
+        try {
+            $selectcmd = $this->dbco->prepare("SELECT id, file_path, dateExpir FROM checksum
+                                                    WHERE file_md5sum = :file_md5sum
+                                                    LIMIT 1");
+            $selectcmd->bindParam('file_md5sum', $checksum, PDO::PARAM_STR);
+            $selectcmd->execute();
+            return $selectcmd->fetch();
+        } catch (PDOException $e) {
+            return ['error' => $e->getMessage()];
+        }
+    }   
+}
+?>

+ 28 - 1
lib/UploadHandler.php

@@ -50,6 +50,7 @@ class UploadHandler
         global $id;
         $this->options = array(
             'script_url' => $this->get_full_url().'/'.$this->basename($this->get_server_var('SCRIPT_NAME')),
+            'id' => $id,
             'upload_dir' => $config['uploadDir'].'/'.$id.'/',
             'upload_url' => $config['baseUrl'].'/'.$id.'/',
             'input_stream' => 'php://input',
@@ -1158,13 +1159,39 @@ class UploadHandler
             if ($uploaded_file && is_uploaded_file($uploaded_file)) {
                 // multipart/formdata uploads (POST method uploads)
                 if ($append_file) {
+                    //error_log('file_put_contents');
                     file_put_contents(
                         $file_path,
                         fopen($uploaded_file, 'r'),
                         FILE_APPEND
                     );
                 } else {
-                    move_uploaded_file($uploaded_file, $file_path);
+                    //Checksum
+                    //error_log('move uploaded file');
+                    //error_log("file_path : ".$file_path);
+                    //error_log("uploaded_file : ".$uploaded_file);
+                    $md5sum_uploaded_file = md5_file($uploaded_file);
+                    //error_log("md5sum_uploaded_file : ".$md5sum_uploaded_file);
+                    $checksum = new Checksum();
+                    $checkChecksum = $checksum->checkChecksum($md5sum_uploaded_file);
+                    //error_log("checkChecksum : ".json_encode($checkChecksum));
+                    if ($checkChecksum == false) {
+                        //error_log("Le checksum n'existe pas, on upload normalement");
+                        move_uploaded_file($uploaded_file, $file_path);
+                        //error_log("id : ".$this->options['id']);
+                        $id_split = explode("-", $this->options['id']);
+                        $dateExpir = $id_split[0];
+                        //error_log("dateExpir : ".$dateExpir);
+                        $checksumAddFile=$checksum->addFile($file_path, $md5sum_uploaded_file, $dateExpir);
+                        if ($checksumAddFile != true) {
+                            error_log("checksumAddFile : ".json_encode($checksumAddFile));
+                        }
+                    } else {
+                        //error_log("Le checksum existe ! Création d'un lien : ".$checkChecksum['file_path']." vers ".$file_path);
+                        link($checkChecksum['file_path'], $file_path);
+                    }
+                    
+                    
                 }
             } else {
                 // Non-multipart uploads (PUT method support)

+ 7 - 2
lib/functions.php

@@ -1,5 +1,7 @@
 <?php 
 
+require('lib/Checksum.php');
+
 //							CODE			LOCALE (locale -a)
 $langueEtLocalDispo=array(	'fr'		=> 'fr_FR', 
 							'en'		=> 'en_US',
@@ -70,14 +72,17 @@ function genZip($id) {
 }
 
 function rrmdir($dir) { 
+	$checksum = new Checksum();
 	if (is_dir($dir)) { 
 		$objects = scandir($dir); 
 		foreach ($objects as $object) { 
 			if ($object != "." && $object != "..") { 
-				if (is_dir($dir."/".$object) && !is_link($dir."/".$object))
+				if (is_dir($dir."/".$object) && !is_link($dir."/".$object)) {
 					rrmdir($dir."/".$object);
-				else
+				} else {
 					unlink($dir."/".$object); 
+					$checksum->deleteByFile($dir."/".$object);
+				}
 			} 
 		}
 		rmdir($dir); 

+ 9 - 0
lib/jQuery-File-Upload/server/php/UploadHandler.php

@@ -200,6 +200,7 @@ class UploadHandler
     }
 
     protected function initialize() {
+        error_log('initialize');
         switch ($this->get_server_var('REQUEST_METHOD')) {
             case 'OPTIONS':
             case 'HEAD':
@@ -1152,6 +1153,13 @@ class UploadHandler
                 mkdir($upload_dir, $this->options['mkdir_mode'], true);
             }
             $file_path = $this->get_upload_path($file->name);
+            //Checksum
+            error_log("file_path : ".$file_path);
+            $checksum = new Checksum();
+            $checksum_file_path = $checksum->checkChecksum(md5_file($file_path));
+            error_log($checksum_file_path);
+            //var_dump($checksum->addFile("12121353-12", "toto.txt", "0000000001", 1681907411));
+            //
             $append_file = $content_range && is_file($file_path) &&
                 $file->size > $this->get_file_size($file_path);
             if ($uploaded_file && is_uploaded_file($uploaded_file)) {
@@ -1397,6 +1405,7 @@ class UploadHandler
     }
 
     public function post($print_response = true) {
+        error_log('post');
         if ($this->get_query_param('_method') === 'DELETE') {
             return $this->delete($print_response);
         }

+ 24 - 24
my.php

@@ -21,45 +21,45 @@ if (is_dir($uploadDirId)) {
     $contentTypeMultiple = false;
     $filesSize=0;
     foreach (scandir($uploadDirId) as $file) {
-	if (is_file($uploadDirId.'/'.$file) 
-	&& $file != $id.'.zip'
-	&& !preg_match('/^\.(.+)\.cfg$/', $file)
-	&& !preg_match('/^\.(.+)\.small$/', $file)) {
-	    $nbFile++;
-	    $filesSize=filesize($uploadDirId.'/'.$file)+$filesSize;
-	    $contentTypeNew=mime_content_type($uploadDirId.'/'.$file);
-	    if ($contentType == null) { 
-		$contentType = $contentTypeNew;
-	    } elseif ($contentType != $contentTypeNew) {
-		$contentTypeMultiple = true;
-	    }
-	}
+        if (is_file($uploadDirId.'/'.$file) 
+        && $file != $id.'.zip'
+        && !preg_match('/^\.(.+)\.cfg$/', $file)
+        && !preg_match('/^\.(.+)\.small$/', $file)) {
+            $nbFile++;
+            $filesSize=filesize($uploadDirId.'/'.$file)+$filesSize;
+            $contentTypeNew=mime_content_type($uploadDirId.'/'.$file);
+            if ($contentType == null) { 
+            $contentType = $contentTypeNew;
+            } elseif ($contentType != $contentTypeNew) {
+            $contentTypeMultiple = true;
+            }
+        }
     }
 
     echo '<tr onclick="location.href=\''.$config['baseUrl'].'/'.$id.'/'.'\'">';
     if ($contentTypeMultiple) {
-	echo '<td><div class="fi fi-size-xs fi-any">
-	    <div class="fi-content">'._('Multi').'</div>
-	</div></td>';
+        echo '<td><div class="fi fi-size-xs fi-any">
+            <div class="fi-content">'._('Multi').'</div>
+        </div></td>';
     } else {
-	$contentTypeSplit = explode('/', $contentType);
-	echo '<td><div class="fi fi-size-xs fi-'.$contentTypeSplit[1].'">
-	    <div class="fi-content">'.$contentTypeSplit[1].'</div>
-	</div></td>';
+        $contentTypeSplit = explode('/', $contentType);
+        echo '<td><div class="fi fi-size-xs fi-'.$contentTypeSplit[1].'">
+            <div class="fi-content">'.$contentTypeSplit[1].'</div>
+        </div></td>';
     }
     echo '<td>'.$nbFile.'</td>';
     echo '<td>'.date("Y/m/d", filectime($uploadDirId)).'</td>';
     echo '<td>'.date("Y/m/d", $idSplit[0]).'</td>';
     echo '<td>'.convertOctect2humain($filesSize).'</td>';
     if (is_file($uploadDirId.'/.access.cfg') ) {
-	echo '<td>'.file_get_contents($uploadDirId.'/.access.cfg').'</td>';
+    	echo '<td>'.file_get_contents($uploadDirId.'/.access.cfg').'</td>';
     }else{
-	echo '<td>'._('Unlimited').'</td>';
+	    echo '<td>'._('Unlimited').'</td>';
     }
     if (is_file($uploadDirId.'/.password.cfg') ) {
-	echo '<td> '._('Yes').' </td>';
+    	echo '<td> '._('Yes').' </td>';
     }else{
-	echo '<td> '._('No').' </td>';
+	    echo '<td> '._('No').' </td>';
     }
     echo '<td><a href="'.$config['baseUrl'].'/'.$id.'/'.'">'._('Link').'</a></td>';
     echo '</tr>';

+ 26 - 1
upload.php

@@ -1,12 +1,36 @@
 <?php
 
+
+
+
 if (!isset($_POST['expire']) or !isset($_POST['id']) or !isset($_POST['key'])) {
-    exit('No hack 1');
+   exit('No hack 1');
 }
 
 $config = yaml_parse_file('./config.yaml'); 
 include('./lib/functions.php');
 
+// # False = pas de checksum
+// var_dump(md5_file('files/checksum.db'));
+// var_dump(md5_file('checksum.db'));
+
+
+// require('lib/Checksum.php');
+
+// $checksum = new Checksum();
+
+// #var_dump($checksum->addFile("12121353-12", "toto.txt", "0000000001", 1681907411));
+
+// #var_dump($checksum->checkChecksum("0000000000"));
+// var_dump($checksum->checkChecksum("0000000001"));
+// var_dump($checksum->cleanExpire());
+// var_dump($checksum->checkChecksum("0000000000"));
+// #var_dump($checksum->deleteFile("12121353-12", 'toto.txt'));
+
+// #var_dump($checksum->checkChecksum("0000000000"));
+
+// exit();
+
 if (isset($_COOKIE['langue'])) {
 	$locale = lang2locale($_COOKIE['langue']);
 	$localeshort=locale2lang($locale);
@@ -77,5 +101,6 @@ if (isset($_POST['passwordCheckbox']) && isset($_POST['password']))  {
     }
 }
 
+
 require('lib/UploadHandler.php');
 $upload_handler = new UploadHandler();