Added 'serverinfo.js' to have the module list in order for JAVASCRIPT to load module-specific content or not

This commit is contained in:
xdrm-brackets 2017-11-05 11:17:53 +01:00
parent eb79b1d8bb
commit 5d3beefb30
2 changed files with 39 additions and 1 deletions

View File

@ -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

View File

@ -23,6 +23,7 @@
<!-- Icone -->
<link rel='icon' href='/src/logauth.ico'>
<script type='text/javascript' src='/serverinfo.js' ></script> <!-- Gestion dynamique des saisies -->
<!-- Dépendences Javascript -->
<script type='text/javascript' src='/js/lib/min/input-checker.js' ></script> <!-- Gestion dynamique des saisies -->