Adds variable log path
This commit is contained in:
commit
2e53674f70
3 changed files with 22 additions and 13 deletions
|
@ -190,13 +190,14 @@ You can then login into the admin dashboard with that e-mail address and the cor
|
|||
|
||||
### Logfile
|
||||
|
||||
When logging is enabled, WebMUM will write messages into the file log/log.txt (e.g. when a login attempt fails).
|
||||
When logging is enabled, WebMUM will write messages into a file "webmum.log" in a specified directory (e.g. when a login attempt fails).
|
||||
|
||||
To enable logging, comment in the line
|
||||
To enable logging, comment in the lines
|
||||
|
||||
// define("WRITE_LOG", true);
|
||||
# define("WRITE_LOG", true);
|
||||
# define("WRITE_LOG_PATH","/var/www/webmum/log/");
|
||||
|
||||
... and make sure that PHP has permissions to write the log file to log/log.txt.
|
||||
... and make sure that PHP has permissions to write the log file to the directory defined in WRITE_LOG_PATH.
|
||||
|
||||
"Login-failed-messages" have the following scheme:
|
||||
|
||||
|
|
|
@ -58,12 +58,14 @@ define("ADMIN_EMAIL", "admin@domain.tld");
|
|||
define("MIN_PASS_LENGTH", 8);
|
||||
|
||||
/*
|
||||
* Write log file to log/log.txt ? Failed login attempts will be written to the logfile.
|
||||
* Write log file? Failed login attempts will be written to the logfile.
|
||||
* You can mointor the logfile with fail2ban and ban attackers' IP-addresses.
|
||||
* Make sure that PHP has permission to create the log directory and log.txt (write permissions for php user)
|
||||
* Make sure that PHP has permission to create the log directory and webmum.log (write permissions for php user)
|
||||
*
|
||||
* Default: Do not write logfile
|
||||
*/
|
||||
|
||||
// define("WRITE_LOG", true);
|
||||
# define("WRITE_LOG", true);
|
||||
# define("WRITE_LOG_PATH","/var/www/webmum/log/");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -94,14 +94,20 @@ function write_pass_hash_to_db($pass_hash, $uid){
|
|||
* Add message to logfile
|
||||
*/
|
||||
function writeLog($text){
|
||||
if(defined('WRITE_LOG')){
|
||||
$logfile = fopen("log/log.txt", "a") or die("Unable to create / open logfile \"log/log.txt\" in root directory!");
|
||||
fwrite($logfile, date('M d H:i:s').": ".$text."\n");
|
||||
fclose($logfile);
|
||||
if(defined('WRITE_LOG') && defined('WRITE_LOG_PATH')){
|
||||
$logdestination = realpath(WRITE_LOG_PATH).DIRECTORY_SEPARATOR."webmum.log";
|
||||
if(is_writable(WRITE_LOG_PATH)){
|
||||
$logfile = fopen($logdestination, "a") or die("Unable to create or open logfile \"".$logdestination."\" in root directory!");
|
||||
fwrite($logfile, date('M d H:i:s').": ".$text."\n");
|
||||
fclose($logfile);
|
||||
}
|
||||
else{
|
||||
die("Directory \"".WRITE_LOG_PATH."\" is not writable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue