2
0

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) OR session::accessUserByType(4)) { // 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. header('Content-type: application/json');
  59. require_once DIR_DATAS_JSON . core::getGet("file") . '.json';
  60. exit();
  61. } else {
  62. exit();
  63. }
  64. } else {
  65. header('HTTP/1.0 401 Unauthorized');
  66. exit();
  67. }
  68. }
  69. }
  70. public static function jsonData()
  71. {
  72. if (core::ifGet("jsonData")) {
  73. if (session::accessElement(core::getGet("jsonData"), "json") == TRUE) {
  74. if (file_exists(DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php')) {
  75. require_once DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php';
  76. exit();
  77. } else {
  78. exit();
  79. }
  80. } else {
  81. header('HTTP/1.0 401 Unauthorized');
  82. exit();
  83. }
  84. }
  85. }
  86. public static function jsonDateDataExcel()
  87. {
  88. db::query("SELECT dateData FROM " . DB_T_EXCEL . " ORDER BY id DESC LIMIT 0, 1");
  89. $data = db::single();
  90. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  91. }
  92. public static function jsonDateDataExcelProweb()
  93. {
  94. db::query("SELECT dateData FROM " . DB_T_EXCEL_PROWEB . " ORDER BY id DESC LIMIT 0, 1");
  95. $data = db::single();
  96. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  97. }
  98. public static function currentPage($_page = NULL)
  99. {
  100. if (core::getGet("p") == $_page) {
  101. return " active";
  102. } elseif (!core::ifGet("p") and (($_SESSION["user"]["idType"] == 1 and $_page == DEFAUT_PAGE) or ($_SESSION["user"]["idType"] == 3 and $_page == DEFAUT_PAGE_SOCIAL))) {
  103. return " active";
  104. }
  105. }
  106. }