Pārlūkot izejas kodu

Allow different folder for logfiles

Hendrik Grewe 10 gadi atpakaļ
vecāks
revīzija
a1a4c1ec7f
2 mainītis faili ar 16 papildinājumiem un 7 dzēšanām
  1. 3 2
      config/config.inc.php
  2. 13 5
      include/php/global.inc.php

+ 3 - 2
config/config.inc.php

@@ -64,6 +64,7 @@ define("MIN_PASS_LENGTH", 8);
  * Default: Do not write logfile
  */
 
-// define("WRITE_LOG", true);
+# define("WRITE_LOG", true);
+# define("WRITE_LOG_PATH","/var/log/webmum/");
 
-?>
+?>

+ 13 - 5
include/php/global.inc.php

@@ -94,14 +94,22 @@ 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, $text."\n");
-		fclose($logfile);
+	if(defined('WRITE_LOG') && defined('WRITE_LOG_PATH')){
+		echo WRITE_LOG_PATH;
+		$logdestination = realpath(WRITE_LOG_PATH).DIRECTORY_SEPARATOR."log";
+		echo $logdestination;
+		if(is_writable(WRITE_LOG_PATH)){
+			$logfile = fopen($logdestination, "a") or die("Unable to create or open logfile \"$logdestination\" in root directory!");
+			fwrite($logfile, $text."\n");
+			fclose($logfile);
+		}
+		else{
+			die("Directory \"WRITE_LOG_PATH\" is not writable");
+		}
 	}
 }
 
 
 
 
-?>
+?>