Fix warning because of missing log directory.

This commit is contained in:
Alexandre Rosenfeld
2011-01-31 14:45:57 +00:00
parent e6f8dc3355
commit aed9d5c6d5
2 changed files with 19 additions and 7 deletions

View File

@@ -382,12 +382,18 @@ class database extends database_base {
if ( substr($sQuery,0, 4) == 'DESC' ) $found = true; if ( substr($sQuery,0, 4) == 'DESC' ) $found = true;
if ( substr($sQuery,0, 4) == 'USE ' ) $found = true; if ( substr($sQuery,0, 4) == 'USE ' ) $found = true;
if ( ! $found ) { if ( ! $found ) {
$logFile = PATH_DATA . 'log' . PATH_SEP . 'query.log'; $logDir = PATH_DATA . 'log';
if (!file_exists($logDir))
if (!mkdir($logDir))
return;
$logFile = "$logDir/query.log";
$fp = fopen ( $logFile, 'a+' ); $fp = fopen ( $logFile, 'a+' );
if ($fp !== false) {
fwrite ( $fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n" ); fwrite ( $fp, date("Y-m-d H:i:s") . " " . $this->sDataBase . " " . $sQuery . "\n" );
fclose ( $fp ); fclose ( $fp );
} }
} }
}
catch (Exception $oException) { catch (Exception $oException) {
} }
} }

View File

@@ -42,11 +42,17 @@ class languages {
*/ */
function log ( $text ) function log ( $text )
{ {
$logFile = PATH_DATA . 'log' . PATH_SEP . 'query.log'; $logDir = PATH_DATA . 'log';
if (!file_exists($logDir))
if (!mkdir($logDir))
return;
$logFile = "$logDir/query.log";
$fp = fopen ( $logFile, 'a+' ); $fp = fopen ( $logFile, 'a+' );
if ($fp !== false) {
fwrite ( $fp, date("Y-m-d H:i:s") . " " . $text . "\n" ); fwrite ( $fp, date("Y-m-d H:i:s") . " " . $text . "\n" );
fclose ( $fp ); fclose ( $fp );
} }
}
/* /*
* Import a language file * Import a language file