| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- class get
- {
- public static function environnement()
- {
- if(!isset($_SERVER['HTTP_HOST'])){
- return "cms.";
- } elseif ($_SERVER['HTTP_HOST'] == DOMAIN_CMS) {
- return "cms.";
- } elseif ($_SERVER['HTTP_HOST'] == DOMAIN_EVENTS OR $_SERVER['HTTP_HOST'] == DOMAIN_CONTROL) {
- return "events.";
- }
- }
- public static function getDefautPage(){
- return HOME_TYPE_USER[session::getType()]["home"];
- }
-
- public static function isDefautMenu(array $_menu){
- return (core::ifGet("p") == FALSE AND in_array(self::getDefautPage(), $_menu)) ? TRUE : FALSE;
- }
- public static function page(?string $_page = NULL, array $vars = [])
- {
- if (isset($_page)) {
- $page = $_page;
- } elseif (core::ifGet("p")) {
- $page = core::getGet("p");
- } else {
- $page = self::getDefautPage();
- }
- if (access::check($page, "page") || in_array($page, WHITE_ACCESS)) {
- $file = DIR_PHP_VIEWS_PAGE . self::environnement() . $page . '.php';
- if (file_exists($file)) {
- extract($vars); // rend les variables disponibles dans la page
- include $file;
- } else {
- 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 (access::ifAccesss($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 javascript(string $_string){
- if (file_exists(DIR_PHP_JAVASCRIPT . self::environnement() . $_string . '.php')) {
- include DIR_PHP_JAVASCRIPT . self::environnement() . $_string . '.php';
- }
- }
- public static function json()
- {
- if (core::ifGet("file")) {
- if (access::check(core::getGet("file"), "json")) {
- // Exception
- if(core::getGet("file") == "documents" AND access::ifLimitAccessException("salaire")){
- $file = "documents-limited";
- } else {
- $file = core::getGet("file");
- }
- // Exception
- if (file_exists(DIR_DATAS_JSON . $file . '.json')) {
- header('Content-type: application/json');
- require_once DIR_DATAS_JSON . $file . '.json';
- exit();
- } else {
- echo json_encode("['No found']");
- exit();
- }
- } else {
- header('HTTP/1.0 401 Unauthorized');
- exit();
- }
- }
- }
- public static function jsonData()
- {
- if (core::ifGet("jsonData")) {
- if (access::check(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 jsonDateDataExcelProwebDossiers()
- {
- db::query("SELECT dateData FROM " . DB_T_EXCEL_PROWEB_DOSSIERS . " ORDER BY id DESC LIMIT 0, 1");
- $data = db::single();
- return (isset($data["dateData"])) ? $data["dateData"] : NULL;
- }
- public static function splitIdPage($_page = NULL)
- {
- $return = array(
- "page" => NULL,
- "id" => NULL,
- );
- $split = explode("-", $_page);
- foreach ($split as $val) {
- if (is_numeric($val)) {
- $return["id"] = $val;
- } else {
- $return["page"] .= $val . "-";
- }
- }
- $return["page"] = substr($return["page"], 0, -1);
- return $return;
- }
- public static function currentPage($_page = NULL)
- {
- if($_page != NULL){
- $page = self::splitIdPage($_page);
- } else {
- $page = NULL;
- }
- if (core::getGet("id") == $page["id"] AND core::getGet("p") == $page["page"]) {
- return " active";
- } elseif (core::getGet("p") == $_page) {
- return " active";
- } elseif (core::getGet("p") == $_page) {
- return " active";
- } elseif (self::getDefautPage() == $_page AND core::getGet("p") == $_page) {
- return " active";
- } elseif (self::getDefautPage() == $_page AND core::getGet("p") == "") {
- return " active";
- }
- }
- }
|