get.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. class get
  3. {
  4. public static function environnement()
  5. {
  6. if ($_SERVER['HTTP_HOST'] == DOMAIN_CMS) {
  7. return "cms.";
  8. } elseif ($_SERVER['HTTP_HOST'] == DOMAIN_EVENTS or $_SERVER['HTTP_HOST'] == DOMAIN_CONTROL) {
  9. return "events.";
  10. }
  11. }
  12. public static function page(string $_page = NULL)
  13. {
  14. if (isset($_page)) {
  15. $page = $_page;
  16. } elseif (core::ifGet("p")) {
  17. $page = core::getGet("p");
  18. } else {
  19. if (session::accessUserByType(1)) { // Admin
  20. $page = DEFAUT_PAGE;
  21. } elseif (session::accessUserByType(3)) { // Assistance sociale
  22. $page = DEFAUT_PAGE_SOCIAL;
  23. }
  24. }
  25. if (session::accessElement($page, "page")) {
  26. (file_exists(DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php')) ?
  27. require_once DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php' : alert::recError("Page introuvable : " . $page);
  28. } else {
  29. alert::recError("La page que vous tentez de charger ne vous est pas disponible.");
  30. }
  31. }
  32. public static function submit()
  33. {
  34. if (core::ifPost("from")) {
  35. $submit = core::getPost("from");
  36. } elseif (core::ifGet("from")) {
  37. $submit = core::getGet("from");
  38. } else {
  39. alert::recError("Submit introuvable #1");
  40. header("Location: /");
  41. exit();
  42. }
  43. if (session::accessElement($submit, "submit")) {
  44. if (file_exists(DIR_PHP_SUBMIT . self::environnement() . $submit . '.php')) {
  45. require_once DIR_PHP_SUBMIT . self::environnement() . $submit . '.php';
  46. } else {
  47. alert::recError("Submit introuvable #2");
  48. header("Location: /");
  49. exit();
  50. }
  51. }
  52. }
  53. public static function json()
  54. {
  55. if (core::ifGet("file")) {
  56. if (session::accessElement(core::getGet("file"), "json")) {
  57. if (file_exists(DIR_DATAS_JSON . core::getGet("file") . '.json')) {
  58. require_once DIR_DATAS_JSON . core::getGet("file") . '.json';
  59. exit();
  60. } else {
  61. exit();
  62. }
  63. } else {
  64. header('HTTP/1.0 401 Unauthorized');
  65. exit();
  66. }
  67. }
  68. }
  69. public static function jsonData()
  70. {
  71. if (core::ifGet("jsonData")) {
  72. if (session::accessElement(core::getGet("jsonData"), "json") == TRUE) {
  73. if (file_exists(DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php')) {
  74. require_once DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php';
  75. exit();
  76. } else {
  77. exit();
  78. }
  79. } else {
  80. header('HTTP/1.0 401 Unauthorized');
  81. exit();
  82. }
  83. }
  84. }
  85. public static function jsonDateDataExcel()
  86. {
  87. db::query("SELECT dateData FROM " . DB_T_EXCEL . " ORDER BY id DESC LIMIT 0, 1");
  88. $data = db::single();
  89. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  90. }
  91. public static function jsonDateDataExcelProweb()
  92. {
  93. db::query("SELECT dateData FROM " . DB_T_EXCEL_PROWEB . " ORDER BY id DESC LIMIT 0, 1");
  94. $data = db::single();
  95. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  96. }
  97. public static function currentPage($_page = NULL)
  98. {
  99. if (core::getGet("p") == $_page) {
  100. return " active";
  101. } elseif (!core::ifGet("p") and (($_SESSION["user"]["idType"] == 1 and $_page == DEFAUT_PAGE) or ($_SESSION["user"]["idType"] == 3 and $_page == DEFAUT_PAGE_SOCIAL))) {
  102. return " active";
  103. }
  104. }
  105. }