aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php18
1 files changed, 5 insertions, 13 deletions
diff --git a/index.php b/index.php
index 600b2f55..553f65e4 100644
--- a/index.php
+++ b/index.php
@@ -309,14 +309,6 @@ function setup_login_state() {
309$userIsLoggedIn = setup_login_state(); 309$userIsLoggedIn = setup_login_state();
310 310
311 311
312// -----------------------------------------------------------------------------------------------
313// Log to text file
314function logm($message)
315{
316 $t = strval(date('Y/m/d_H:i:s')).' - '.$_SERVER["REMOTE_ADDR"].' - '.strval($message)."\n";
317 file_put_contents($GLOBALS['config']['LOG_FILE'], $t, FILE_APPEND);
318}
319
320// ------------------------------------------------------------------------------------------ 312// ------------------------------------------------------------------------------------------
321// Sniff browser language to display dates in the right format automatically. 313// Sniff browser language to display dates in the right format automatically.
322// (Note that is may not work on your server if the corresponding local is not installed.) 314// (Note that is may not work on your server if the corresponding local is not installed.)
@@ -380,10 +372,10 @@ function check_auth($login,$password)
380 if ($login==$GLOBALS['login'] && $hash==$GLOBALS['hash']) 372 if ($login==$GLOBALS['login'] && $hash==$GLOBALS['hash'])
381 { // Login/password is correct. 373 { // Login/password is correct.
382 fillSessionInfo(); 374 fillSessionInfo();
383 logm('Login successful'); 375 logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], 'Login successful');
384 return True; 376 return True;
385 } 377 }
386 logm('Login failed for user '.$login); 378 logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], 'Login failed for user '.$login);
387 return False; 379 return False;
388} 380}
389 381
@@ -420,7 +412,7 @@ function ban_loginFailed()
420 if ($gb['FAILURES'][$ip]>($GLOBALS['config']['BAN_AFTER']-1)) 412 if ($gb['FAILURES'][$ip]>($GLOBALS['config']['BAN_AFTER']-1))
421 { 413 {
422 $gb['BANS'][$ip]=time()+$GLOBALS['config']['BAN_DURATION']; 414 $gb['BANS'][$ip]=time()+$GLOBALS['config']['BAN_DURATION'];
423 logm('IP address banned from login'); 415 logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], 'IP address banned from login');
424 } 416 }
425 $GLOBALS['IPBANS'] = $gb; 417 $GLOBALS['IPBANS'] = $gb;
426 file_put_contents($GLOBALS['config']['IPBANS_FILENAME'], "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"); 418 file_put_contents($GLOBALS['config']['IPBANS_FILENAME'], "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>");
@@ -444,7 +436,7 @@ function ban_canLogin()
444 // User is banned. Check if the ban has expired: 436 // User is banned. Check if the ban has expired:
445 if ($gb['BANS'][$ip]<=time()) 437 if ($gb['BANS'][$ip]<=time())
446 { // Ban expired, user can try to login again. 438 { // Ban expired, user can try to login again.
447 logm('Ban lifted.'); 439 logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], 'Ban lifted.');
448 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]); 440 unset($gb['FAILURES'][$ip]); unset($gb['BANS'][$ip]);
449 file_put_contents($GLOBALS['config']['IPBANS_FILENAME'], "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>"); 441 file_put_contents($GLOBALS['config']['IPBANS_FILENAME'], "<?php\n\$GLOBALS['IPBANS']=".var_export($gb,true).";\n?>");
450 return true; // Ban has expired, user can login. 442 return true; // Ban has expired, user can login.
@@ -641,7 +633,7 @@ class pageBuilder
641 $this->tpl->assign('versionError', ''); 633 $this->tpl->assign('versionError', '');
642 634
643 } catch (Exception $exc) { 635 } catch (Exception $exc) {
644 logm($exc->getMessage()); 636 logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], $exc->getMessage());
645 $this->tpl->assign('newVersion', ''); 637 $this->tpl->assign('newVersion', '');
646 $this->tpl->assign('versionError', escape($exc->getMessage())); 638 $this->tpl->assign('versionError', escape($exc->getMessage()));
647 } 639 }