| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- class get
- {
- public static function environnement()
- {
- if ($_SERVER['HTTP_HOST'] == DOMAIN_CMS) {
- return "cms.";
- } elseif ($_SERVER['HTTP_HOST'] == DOMAIN_EVENTS or $_SERVER['HTTP_HOST'] == DOMAIN_CONTROL) {
- return "events.";
- }
- }
- public static function page(string $_page = NULL)
- {
- if (isset($_page)) {
- $page = $_page;
- } elseif (core::ifGet("p")) {
- $page = core::getGet("p");
- } else {
- if (session::accessUserByType(1)) { // Admin
- $page = DEFAUT_PAGE;
- } elseif (session::accessUserByType(3)) { // Assistance sociale
- $page = DEFAUT_PAGE_SOCIAL;
- }
- }
- if (session::accessElement($page, "page")) {
- (file_exists(DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php')) ?
- require_once DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php' : alert::recError("Page introuvable : " . $page);
- } else {
- alert::recError("La page que vous tentez de charger ne vous est pas disponible.");
- }
- }
- public static function submit()
- {
- if (core::ifPost("from")) {
- $submit = core::getPost("from");
- } elseif (core::ifGet("from")) {
- $submit = core::getGet("from");
- } else {
- alert::recError("Submit introuvable #1");
- header("Location: /");
- exit();
- }
- if (session::accessElement($submit, "submit")) {
- if (file_exists(DIR_PHP_SUBMIT . self::environnement() . $submit . '.php')) {
- require_once DIR_PHP_SUBMIT . self::environnement() . $submit . '.php';
- } else {
- alert::recError("Submit introuvable #2");
- header("Location: /");
- exit();
- }
- }
- }
- public static function json()
- {
- if (core::ifGet("file")) {
- if (session::accessElement(core::getGet("file"), "json")) {
- if (file_exists(DIR_DATAS_JSON . core::getGet("file") . '.json')) {
- header('Content-type: application/json');
- require_once DIR_DATAS_JSON . core::getGet("file") . '.json';
- exit();
- } else {
- exit();
- }
- } else {
- header('HTTP/1.0 401 Unauthorized');
- exit();
- }
- }
- }
- public static function jsonData()
- {
- if (core::ifGet("jsonData")) {
- if (session::accessElement(core::getGet("jsonData"), "json") == TRUE) {
- if (file_exists(DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php')) {
- require_once DIR_DATAS_JSONDATA . self::environnement() . core::getGet("jsonData") . '.php';
- exit();
- } else {
- exit();
- }
- } else {
- header('HTTP/1.0 401 Unauthorized');
- exit();
- }
- }
- }
- public static function jsonDateDataExcel()
- {
- db::query("SELECT dateData FROM " . DB_T_EXCEL . " ORDER BY id DESC LIMIT 0, 1");
- $data = db::single();
- return (isset($data["dateData"])) ? $data["dateData"] : NULL;
- }
- public static function jsonDateDataExcelProweb()
- {
- db::query("SELECT dateData FROM " . DB_T_EXCEL_PROWEB . " ORDER BY id DESC LIMIT 0, 1");
- $data = db::single();
- return (isset($data["dateData"])) ? $data["dateData"] : NULL;
- }
- public static function currentPage($_page = NULL)
- {
- if (core::getGet("p") == $_page) {
- return " active";
- } elseif (!core::ifGet("p") and (($_SESSION["user"]["idType"] == 1 and $_page == DEFAUT_PAGE) or ($_SESSION["user"]["idType"] == 3 and $_page == DEFAUT_PAGE_SOCIAL))) {
- return " active";
- }
- }
- }
|