Module: nagvis Branch: master Commit: d11526ce7a93e278703a0a531494d7f93b749c34 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=d11526ce7a93e278703a0a531494d7f93b749c34
Author: LaMi <[email protected]> Date: Thu Apr 29 23:34:47 2010 +0200 #274 Added javascript powered cookie detection on login page --- .../frontend/nagvis-js/classes/NagVisLoginView.php | 4 +++- share/userfiles/templates/default.login.html | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/share/frontend/nagvis-js/classes/NagVisLoginView.php b/share/frontend/nagvis-js/classes/NagVisLoginView.php index b94941e..6a2a8ec 100644 --- a/share/frontend/nagvis-js/classes/NagVisLoginView.php +++ b/share/frontend/nagvis-js/classes/NagVisLoginView.php @@ -62,7 +62,9 @@ class NagVisLoginView { 'maxUsernameLength' => AUTH_MAX_USERNAME_LENGTH, 'langName' => $this->CORE->getLang()->getText('Name'), 'langPassword' => $this->CORE->getLang()->getText('Password'), - 'langLogin' => $this->CORE->getLang()->getText('Login') + 'langLogin' => $this->CORE->getLang()->getText('Login'), + 'langTitleCookiesDisabled' => $this->CORE->getLang()->getText('Cookies disabled'), + 'langTextCookiesDisabled' => $this->CORE->getLang()->getText('NagVis is unable to set a cookie in your browser. Please enable cookies for at least the NagVis host.'), ); // Build page based on the template file and the data array diff --git a/share/userfiles/templates/default.login.html b/share/userfiles/templates/default.login.html index cb8f320..8d3b1a3 100644 --- a/share/userfiles/templates/default.login.html +++ b/share/userfiles/templates/default.login.html @@ -13,7 +13,20 @@ <link rel="shortcut icon" href="{$htmlBase}frontend/nagvis-js/images/internal/favicon.png" /> <meta name='robots' content='noindex,nofollow' /> <script type="text/javascript"> - oGeneralProperties = {$generalProperties}; + oGeneralProperties = {$generalProperties}; + + function checkCookies() { + // Would rather use navigator.cookieEnabled but this is not very reliable + document.cookie = "_testcookie"; + var iLikeCookies = (document.cookie.indexOf("_testcookie") != -1) ? true : false; + + if(!iLikeCookies) + frontendMessage(\{'type': 'CRITICAL', 'message': '{$langTextCookiesDisabled}', 'title': '{$langTitleCookiesDisabled}'}); + else \{ + var d = new Date(); + document.cookie = "_testcookie;expires=" + d.toGMTString() + ";" + ";"; + } + } </script> </head> <body class="login"> @@ -38,7 +51,7 @@ </div> <script type="text/javascript"> -try\{document.getElementById('user_login').focus();}catch(e)\{} +try\{document.getElementById('user_login').focus();}catch(e)\{}; checkCookies(); </script> </body> </html> ------------------------------------------------------------------------------ _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
