2
0

core.class.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. class core
  3. {
  4. public static function switch()
  5. {
  6. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  7. if (isset($_POST["from"])) {
  8. if ($_POST["from"] == "cse.invent" and isset($_POST["token"])) {
  9. include_once ROOT_DIR . "/core/submit/record.jwt.php";
  10. } elseif ($_POST["from"] == "video.form.add") {
  11. include_once ROOT_DIR . "/core/submit/video.add.php";
  12. } elseif ($_POST["from"] == "video.form") {
  13. include_once ROOT_DIR . "/core/submit/video.edit.php";
  14. } elseif ($_POST["from"] == "video.cut") {
  15. include_once ROOT_DIR . "/core/submit/video.cut.php";
  16. } else {
  17. echo "Error : switch :. from else post";
  18. var_dump($_POST);
  19. exit();
  20. }
  21. } else {
  22. echo "Error : switch :. from post";
  23. exit();
  24. }
  25. } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
  26. if (isset($_GET["video"])) {
  27. include_once ROOT_DIR . "/core/page/video.show.php";
  28. } elseif (isset($_GET["preview"])) {
  29. include_once ROOT_DIR . "/core/page/video.preview.php";
  30. } elseif (isset($_GET["delete"])) {
  31. include_once ROOT_DIR . "/core/submit/video.delete.php";
  32. } else {
  33. require_once ROOT_DIR . "/core/controllers/session.php";
  34. include_once ROOT_DIR . "/core/page/_header.php";
  35. if (empty($_GET["video"]) and empty($_GET["preview"]) and empty($_GET["edit"]) and empty($_GET["cut"])) {
  36. include_once ROOT_DIR . "/core/page/videos.all.php";
  37. } elseif (isset($_GET["edit"]) and $_GET["edit"] == "add") {
  38. include_once ROOT_DIR . "/core/page/video.form.add.php";
  39. } elseif (isset($_GET["edit"]) and $_GET["edit"] != "add") {
  40. include_once ROOT_DIR . "/core/page/video.form.php";
  41. } elseif (isset($_GET["cut"])) {
  42. include_once ROOT_DIR . "/core/page/video.cut.php";
  43. } else {
  44. echo "Error : switch :. from get";
  45. exit();
  46. }
  47. include_once ROOT_DIR . "/core/page/_footer.php";
  48. }
  49. } else {
  50. echo "Error : switch";
  51. exit();
  52. }
  53. }
  54. public static function print_r($_debug, int $_exit = NULL)
  55. {
  56. echo "<pre>";
  57. if (is_array($_debug)) {
  58. print_r($_debug);
  59. } elseif (is_object($_debug)) {
  60. var_dump($_debug);
  61. } else {
  62. echo $_debug;
  63. }
  64. echo "</pre>";
  65. ($_exit != NULL) ? exit() : NULL;
  66. }
  67. public static function formatDuration(float $seconds = NULL, string $type = NULL)
  68. {
  69. if ($seconds == NULL) {
  70. return NULL;
  71. }
  72. // Calculer les heures
  73. $hours = floor($seconds / 3600);
  74. // Calculer les minutes restantes après avoir soustrait les heures
  75. $minutes = floor(($seconds % 3600) / 60);
  76. // Calculer les secondes restantes après avoir soustrait les minutes
  77. $remainingSeconds = $seconds % 60;
  78. // Retourner la durée formatée en "H:i:s"
  79. if ($type == ":") {
  80. return sprintf("%02d:%02d:%02d", $hours, $minutes, $remainingSeconds);
  81. } else {
  82. return sprintf("%02dh %02dm %02ds", $hours, $minutes, $remainingSeconds);
  83. }
  84. }
  85. }