| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- class core
- {
- public static function switch()
- {
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- if (isset($_POST["from"])) {
- if ($_POST["from"] == "cse.invent" and isset($_POST["token"])) {
- include_once ROOT_DIR . "/core/submit/record.jwt.php";
- } elseif ($_POST["from"] == "video.form.add") {
- include_once ROOT_DIR . "/core/submit/video.add.php";
- } elseif ($_POST["from"] == "video.form") {
- include_once ROOT_DIR . "/core/submit/video.edit.php";
- } elseif ($_POST["from"] == "video.cut") {
- include_once ROOT_DIR . "/core/submit/video.cut.php";
- } else {
- echo "Error : switch :. from else post";
- var_dump($_POST);
- exit();
- }
- } else {
- echo "Error : switch :. from post";
- exit();
- }
- } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
- if (isset($_GET["video"])) {
- include_once ROOT_DIR . "/core/page/video.show.php";
- } elseif (isset($_GET["preview"])) {
- include_once ROOT_DIR . "/core/page/video.preview.php";
- } elseif (isset($_GET["delete"])) {
- include_once ROOT_DIR . "/core/submit/video.delete.php";
- } else {
- require_once ROOT_DIR . "/core/controllers/session.php";
- include_once ROOT_DIR . "/core/page/_header.php";
- if (empty($_GET["video"]) and empty($_GET["preview"]) and empty($_GET["edit"]) and empty($_GET["cut"])) {
- include_once ROOT_DIR . "/core/page/videos.all.php";
- } elseif (isset($_GET["edit"]) and $_GET["edit"] == "add") {
- include_once ROOT_DIR . "/core/page/video.form.add.php";
- } elseif (isset($_GET["edit"]) and $_GET["edit"] != "add") {
- include_once ROOT_DIR . "/core/page/video.form.php";
- } elseif (isset($_GET["cut"])) {
- include_once ROOT_DIR . "/core/page/video.cut.php";
- } else {
- echo "Error : switch :. from get";
- exit();
- }
- include_once ROOT_DIR . "/core/page/_footer.php";
- }
- } else {
- echo "Error : switch";
- exit();
- }
- }
- public static function print_r($_debug, int $_exit = NULL)
- {
- echo "<pre>";
- if (is_array($_debug)) {
- print_r($_debug);
- } elseif (is_object($_debug)) {
- var_dump($_debug);
- } else {
- echo $_debug;
- }
- echo "</pre>";
- ($_exit != NULL) ? exit() : NULL;
- }
- public static function formatDuration(float $seconds = NULL, string $type = NULL)
- {
- if ($seconds == NULL) {
- return NULL;
- }
- // Calculer les heures
- $hours = floor($seconds / 3600);
- // Calculer les minutes restantes après avoir soustrait les heures
- $minutes = floor(($seconds % 3600) / 60);
- // Calculer les secondes restantes après avoir soustrait les minutes
- $remainingSeconds = $seconds % 60;
- // Retourner la durée formatée en "H:i:s"
- if ($type == ":") {
- return sprintf("%02d:%02d:%02d", $hours, $minutes, $remainingSeconds);
- } else {
- return sprintf("%02dh %02dm %02ds", $hours, $minutes, $remainingSeconds);
- }
- }
- }
|