2
0

get.class.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 getDefautPage(){
  13. if(session::getType() == 3){ // Assistance sociale
  14. return DEFAUT_PAGE_SOCIAL;
  15. } else {
  16. return DEFAUT_PAGE;
  17. }
  18. }
  19. public static function isDefautPage(string $_page){
  20. return (core::ifGet("p") == FALSE AND $_page == self::getDefautPage()) ? TRUE : FALSE;
  21. }
  22. public static function page(string $_page = NULL)
  23. {
  24. if (isset($_page)) {
  25. $page = $_page;
  26. } elseif (core::ifGet("p")) {
  27. $page = core::getGet("p");
  28. } else {
  29. $page = self::getDefautPage();
  30. }
  31. if (access::check($page, "page") OR in_array($page, WHITE_ACCESS)) {
  32. (file_exists(DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php')) ?
  33. require_once DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php' : alert::recError("Page introuvable : " . $page);
  34. } else {
  35. alert::recError("La page que vous tentez de charger ne vous est pas disponible.");
  36. }
  37. }
  38. public static function submit()
  39. {
  40. if (core::ifPost("from")) {
  41. $submit = core::getPost("from");
  42. } elseif (core::ifGet("from")) {
  43. $submit = core::getGet("from");
  44. } else {
  45. alert::recError("Submit introuvable #1");
  46. header("Location: /");
  47. exit();
  48. }
  49. if (access::ifAccesss($submit)) {
  50. if (file_exists(DIR_PHP_SUBMIT . self::environnement() . $submit . '.php')) {
  51. require_once DIR_PHP_SUBMIT . self::environnement() . $submit . '.php';
  52. } else {
  53. alert::recError("Submit introuvable #2");
  54. header("Location: /");
  55. exit();
  56. }
  57. }
  58. }
  59. public static function json()
  60. {
  61. if (core::ifGet("file")) {
  62. if (access::check(core::getGet("file"), "json")) {
  63. if (file_exists(DIR_DATAS_JSON . core::getGet("file") . '.json')) {
  64. header('Content-type: application/json');
  65. require_once DIR_DATAS_JSON . core::getGet("file") . '.json';
  66. exit();
  67. } else {
  68. exit();
  69. }
  70. } else {
  71. header('HTTP/1.0 401 Unauthorized');
  72. exit();
  73. }
  74. }
  75. }
  76. public static function jsonData()
  77. {
  78. if (core::ifGet("jsonData")) {
  79. if (access::check(core::getGet("jsonData"), "json") == TRUE) {
  80. if (file_exists(DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php')) {
  81. require_once DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php';
  82. exit();
  83. } else {
  84. exit();
  85. }
  86. } else {
  87. header('HTTP/1.0 401 Unauthorized');
  88. exit();
  89. }
  90. }
  91. }
  92. public static function jsonDateDataExcel()
  93. {
  94. db::query("SELECT dateData FROM " . DB_T_EXCEL . " ORDER BY id DESC LIMIT 0, 1");
  95. $data = db::single();
  96. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  97. }
  98. public static function jsonDateDataExcelProweb()
  99. {
  100. db::query("SELECT dateData FROM " . DB_T_EXCEL_PROWEB . " ORDER BY id DESC LIMIT 0, 1");
  101. $data = db::single();
  102. return (isset($data["dateData"])) ? $data["dateData"] : NULL;
  103. }
  104. public static function splitIdPage($_page = NULL)
  105. {
  106. $return = array(
  107. "page" => NULL,
  108. "id" => NULL,
  109. );
  110. $split = explode("-", $_page);
  111. foreach ($split as $val) {
  112. if (is_numeric($val)) {
  113. $return["id"] = $val;
  114. } else {
  115. $return["page"] .= $val . "-";
  116. }
  117. }
  118. $return["page"] = substr($return["page"], 0, -1);
  119. return $return;
  120. }
  121. public static function currentPage($_page = NULL)
  122. {
  123. if($_page != NULL){
  124. $page = self::splitIdPage($_page);
  125. } else {
  126. $page = NULL;
  127. }
  128. if (core::getGet("id") == $page["id"] AND core::getGet("p") == $page["page"]) {
  129. return " active";
  130. } elseif (core::getGet("p") == $_page) {
  131. return " active";
  132. } elseif (core::getGet("p") == $_page) {
  133. return " active";
  134. } elseif (self::isDefautPage($_page)) {
  135. return " active";
  136. }
  137. }
  138. }