commit c754cb47e0686886d77615fe0af4f37ade3b5512 Author: Esenjin_Asakha Date: Fri Dec 27 14:23:39 2024 +0000 initialisation du projet (partie 1) diff --git a/cyla2api.php b/cyla2api.php new file mode 100644 index 0000000..d09b2cb --- /dev/null +++ b/cyla2api.php @@ -0,0 +1,32 @@ +'; // URL to shrink +$format = 'simple'; // output format: 'json', 'xml' or 'simple' + +// EDIT THIS: the URL of the API file +$api_url = 'http://ersatz.xyz/yourls-api.php'; + +// Init the CURL session +$ch = curl_init(); +curl_setopt( $ch, CURLOPT_URL, $api_url ); +curl_setopt( $ch, CURLOPT_HEADER, 0 ); // No header in the result +curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); // Return, do not echo result +curl_setopt( $ch, CURLOPT_POST, 1 ); // This is a POST request +curl_setopt( $ch, CURLOPT_POSTFIELDS, array( // Data to POST + 'url' => $url, + 'format' => $format, + 'action' => 'shorturl', + 'signature' => $signature, + ) ); + +// Fetch and return content +$data = curl_exec($ch); +curl_close($ch); + +// Do something with the result. Here, we just echo it. +echo $data; + diff --git a/gallery.php b/gallery.php new file mode 100644 index 0000000..5d1a5fe --- /dev/null +++ b/gallery.php @@ -0,0 +1,311 @@ + $file, + 'url' => 'file/' . rawurlencode($file), + 'shareUrl' => 'share/' . rawurlencode($file), + 'date' => filemtime($path), + 'type' => strtolower(pathinfo($file, PATHINFO_EXTENSION)) + ]; + } + } + + // Tri + usort($files, function($a, $b) use ($sortBy, $sortDesc) { + $result = $sortBy === 'date' + ? $b['date'] - $a['date'] + : strcasecmp($a['name'], $b['name']); + return $sortDesc ? $result : -$result; + }); + + // Pagination + $offset = $page * FILES_PER_PAGE; + return array_slice($files, $offset, FILES_PER_PAGE); +} + +if (!$authenticated) { + // Afficher le formulaire de connexion + include 'header.php'; + ?> +
+ + +
+ + + + + + Galerie de fichiers + + + +
+ + +
+ +
+
+
Chargement...
+ + + + diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..c79ead2 --- /dev/null +++ b/upload.php @@ -0,0 +1,59 @@ + $maxsize) { + throw new Exception(); + } + + //Generate a file name, and regenerate it if a file with that name already exists + do { + $newname = strtoupper(substr(hash("sha256", $filename . (rand() * 100)), 0, 6)) . "." . $extension; + } while (file_exists("/file/" . $newname)); + + //Set file location + $location = 'file/' . $newname; + + //Move file to storage folder + if(!move_uploaded_file($filetmp, $location)) { + throw new Exception("Impossible de déplacer le fichier dans le dossier où il devrait être. Vous devriez probablement parler de ce sujet à @Sangigi_Fuchsia sur twitter, car la faute provient probablement du serveur."); + } + + if (!header('Location: share/' . $newname)) { + throw new Exception("Echec de la redirection."); + } +} +//Catch errors and output them +catch (Exception $e) { + echo $e->getMessage(); +}