From 5d3beefb302aa85ee09a7d91f5e9bfe6cb6791bf Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 5 Nov 2017 11:17:53 +0100 Subject: [PATCH] Added 'serverinfo.js' to have the module list in order for JAVASCRIPT to load module-specific content or not --- public_html/index.php | 39 ++++++++++++++++++++++++++++++++++++++- public_html/view/view.php | 1 + 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/public_html/index.php b/public_html/index.php index 757f78f..58c3ffd 100755 --- a/public_html/index.php +++ b/public_html/index.php @@ -51,7 +51,6 @@ /* (2) Gestion des SVG avec couleur modifiée */ - // path/to/resource/filename-HEXADE.svg $R->get('(.+)@([a-f0-9]{6})(\.svg)', function($matches){ $path = __PUBLIC__.'/'.$matches[0].$matches[2]; @@ -85,6 +84,44 @@ }); + /* (4) serverinfo.js -> generate it with no cache */ + $R->get('serverinfo.js', function($matches){ + + global $auth; + + // {1} Disable cache // + header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); + header('Cache-Control: post-check=0, pre-check=0', false); + header('Pragma: no-cache'); + header('Content-Type: text/javascript'); + + // {2} Generate content // + echo "var SERVER = {\n"; + echo "\tmodule: {\n"; + + // if connected to warehouse + if( $auth >= 1 ){ + + $m_id = array_keys($_SESSION['WAREHOUSE']['modules']); + + for( $m = 0 ; $m < count($m_id) ; $m++ ){ + + if( $m > 0 ) + echo ",\n"; + + echo "\t\t'".$_SESSION['WAREHOUSE']['modules'][$m_id[$m]]."': true"; + + } + } + + echo "\n\t}\n"; + echo "};\n"; + + die(); + + }); + + /* (3) On cree les regles de routage QUAND ON EST CONNECTE diff --git a/public_html/view/view.php b/public_html/view/view.php index 219e523..fa3d3e2 100755 --- a/public_html/view/view.php +++ b/public_html/view/view.php @@ -23,6 +23,7 @@ +