<?php
/* --------------------------------------------------------------
FileLog.php 2011-09-08 gambio
Gambio GmbH
http://www.gambio.de
Copyright (c) 2011 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
class FileLog
{
var $v_log_active = true;
var $v_file_base = '';
var $v_file_suffix = '';
var $v_max_filesize = 0;
function FileLog($p_file_base, $p_log_active=true)
{
$this->v_file_base = $p_file_base;
$this->v_file_suffix = $this->get_secure_token();
if(defined('SQL_LOG_MAX_FILESIZE') && (double)SQL_LOG_MAX_FILESIZE > 0)
{
$this->v_max_filesize = (double)SQL_LOG_MAX_FILESIZE * 1024 * 1024;
}
else
{
$this->v_max_filesize = 1 * 1024 * 1024;
}
}
function get_file_path()
{
$t_path = 'logfiles/'.$this->v_file_base.'-'.$this->v_file_suffix.'.log';
return $t_path;
}
function write($p_string)
{
if($this->v_log_active == false)
{
# log deactivated. cancel write.
return true;
}
if((file_exists(DIR_FS_CATALOG . $this->get_file_path()) == false &&
is_writeable(DIR_FS_CATALOG . 'logfiles/') == false)
||
(file_exists(DIR_FS_CATALOG . $this->get_file_path()) == true &&
is_writeable(DIR_FS_CATALOG . $this->get_file_path()) == false))
{
return false;
}
if(@filesize(DIR_FS_CATALOG . $this->get_file_path()) >= $this->v_max_filesize && is_writeable(DIR_FS_CATALOG . 'logfiles/') == true)
{
$t_file_content = file_get_contents(DIR_FS_CATALOG . $this->get_file_path());
$t_gz_file_content = gzencode($t_file_content, 9);
$t_gz_filename = $this->v_file_base . '-' . $this->v_file_suffix . '_' . date('Ymd_His') . '.log.gz';
$fp = fopen(DIR_FS_CATALOG . 'logfiles/' . $t_gz_filename, 'w+');
fwrite($fp, $t_gz_file_content);
fclose($fp);
unlink(DIR_FS_CATALOG . $this->get_file_path());
}
$fp = fopen(DIR_FS_CATALOG . $this->get_file_path(), 'a+');
fwrite($fp, $p_string);
fclose($fp);
return true;
}
function set_log_active($p_status)
{
$this->v_log_active = $p_status;
}
function get_secure_token()
{
static $t_secure_token;
if($t_secure_token === null && is_dir(DIR_FS_CATALOG . 'media'))
{
$t_dh = opendir(DIR_FS_CATALOG . 'media');
if($t_dh !== false)
{
while(($t_file = readdir($t_dh)) !== false)
{
// search for secure token file
if(strpos($t_file, 'secure_token_') !== false)
{
$t_secure_token = str_replace('secure_token_', '', $t_file);
break;
}
}
if($t_secure_token === null)
{
$t_secure_token = md5(mt_rand());
$fp = fopen(DIR_FS_CATALOG . 'media/secure_token_' . $t_secure_token, 'w');
fwrite($fp, '.');
fclose($fp);
}
}
}
return $t_secure_token;
}
}
?>| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| csstidy/ | 2013-11-12 21:03 | 125.89 KB | 76129f60960:kunden | dxwrx-rx-r | |
| lib/ | 2013-11-12 21:03 | 601.96 KB | 76129f60960:kunden | dxwrx-rx-r | |
| ErrorHandler.php | 2013-11-12 21:03 | 10.34 KB | 76129f60960:kunden | -xw-x----- | |
| FileLog.php | 2013-11-12 21:02 | 2.93 KB | 76129f60960:kunden | -xw-x----- | |
| GMAltText.php | 2013-11-12 21:03 | 2.94 KB | 76129f60960:kunden | -xw-x----- | |
| GMAttributesCalculator.php | 2013-11-12 21:03 | 4.65 KB | 76129f60960:kunden | -xw-x----- | |
| GMCSSMonitor.php | 2013-11-12 21:03 | 13.19 KB | 76129f60960:kunden | -xw-x----- | |
| GMCSSOptimizer.php | 2013-11-12 21:03 | 32.87 KB | 76129f60960:kunden | -xw-x----- | |
| GMCat.php | 2013-11-12 21:03 | 9.08 KB | 76129f60960:kunden | -xw-x----- | |
| GMCounter.php | 2013-11-12 21:03 | 17.05 KB | 76129f60960:kunden | -xw-x----- | |
| GMEbay.php | 2013-11-12 21:02 | 9.16 KB | 76129f60960:kunden | -xw-x----- | |
| GMGMotion.php | 2013-11-12 21:02 | 24.31 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintCartManager.php | 2013-11-12 21:03 | 14.66 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintConfiguration.php | 2013-11-12 21:03 | 2.17 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintContentManager.php | 2013-11-12 21:02 | 8.79 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintElements.php | 2013-11-12 21:03 | 15.79 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintFileManager.php | 2013-11-12 21:02 | 6.06 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintOrderElements.php | 2013-11-12 21:03 | 7.46 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintOrderManager.php | 2013-11-12 21:03 | 6.27 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintOrderSurfaces.php | 2013-11-12 21:03 | 6.41 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintOrderSurfacesManager.php | 2013-11-12 21:03 | 4.86 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintProductManager.php | 2013-11-12 21:02 | 4.55 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintSurfaces.php | 2013-11-12 21:03 | 9.99 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintSurfacesGroupsManager.php | 2013-11-12 21:03 | 1.96 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintSurfacesManager.php | 2013-11-12 21:03 | 9.62 KB | 76129f60960:kunden | -xw-x----- | |
| GMGPrintWishlistManager.php | 2013-11-12 21:03 | 14.81 KB | 76129f60960:kunden | -xw-x----- | |
| GMJSON.php | 2013-11-12 21:03 | 2.44 KB | 76129f60960:kunden | -xw-x----- | |
| GMJanolaw.php | 2013-11-12 21:03 | 3.76 KB | 76129f60960:kunden | -xw-x----- | |
| GMLangFileMaster.php | 2013-11-12 21:03 | 965 B | 76129f60960:kunden | -xw-x----- | |
| GMLightboxControl.php | 2013-11-12 21:03 | 691 B | 76129f60960:kunden | -xw-x----- | |
| GMLogoManager.php | 2013-11-12 21:03 | 6.78 KB | 76129f60960:kunden | -xw-x----- | |
| GMMeta.php | 2013-11-12 21:02 | 8.29 KB | 76129f60960:kunden | -xw-x----- | |
| GMProduct.php | 2013-11-12 21:03 | 2.37 KB | 76129f60960:kunden | -xw-x----- | |
| GMSEOBoost.php | 2013-11-12 21:03 | 25.63 KB | 76129f60960:kunden | -xw-x----- | |
| GMSitemap.php | 2013-11-12 21:03 | 5.32 KB | 76129f60960:kunden | -xw-x----- | |
| GMStatusbar.php | 2013-11-12 21:02 | 2.46 KB | 76129f60960:kunden | -xw-x----- | |
| GMTSWidget.php | 2013-11-12 21:03 | 4.93 KB | 76129f60960:kunden | -xw-x----- | |
| GMTabTokenizer.php | 2013-11-12 21:03 | 2.81 KB | 76129f60960:kunden | -xw-x----- | |
| GMTracker.php | 2013-11-12 21:03 | 3.49 KB | 76129f60960:kunden | -xw-x----- | |
| JSON.php | 2013-11-12 21:03 | 39.98 KB | 76129f60960:kunden | -xw-x----- | |
| application_top.php | 2013-11-12 21:03 | 34.02 KB | 76129f60960:kunden | -xw-x----- | |