Revision 1689
Added by darkviper over 13 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
=============================================================================== |
| 13 | 13 |
|
| 14 |
|
|
| 14 |
08 May-2012 Build 1689 Werner v.d.Decken(DarkViper) |
|
| 15 |
# fixed Errorhandling for old class.database |
|
| 15 | 16 |
08 May-2012 Build 1688 Dietmar Woellbrink (Luisehahne) |
| 16 | 17 |
! update upgrade-script first remove access files in an existing pages folder |
| 17 | 18 |
before rebuilding them |
| branches/2.8.x/wb/upgrade-script.php | ||
|---|---|---|
| 23 | 23 |
$admin = new admin('Addons', 'modules', false, false);
|
| 24 | 24 |
|
| 25 | 25 |
$oldVersion = 'Version '.WB_VERSION; |
| 26 |
$oldVersion .= (defined('WB_SP') ? '.'.WB_SP : '');
|
|
| 26 |
$oldVersion .= (defined('WB_SP') ? WB_SP : '');
|
|
| 27 | 27 |
$oldRevision = (defined('WB_REVISION') ? ' Revision ['.WB_REVISION.'] ' : '') ;
|
| 28 | 28 |
$newVersion = 'Version '.VERSION; |
| 29 |
$newVersion .= (defined('SP') ? '.'.SP : '');
|
|
| 29 |
$newVersion .= (defined('SP') ? SP : '');
|
|
| 30 | 30 |
$newRevision = (defined('REVISION') ? ' Revision ['.REVISION.'] ' : '');
|
| 31 | 31 |
|
| 32 | 32 |
// set addition settings if not exists, otherwise upgrade will be breaks |
| ... | ... | |
| 65 | 65 |
'[ADMIN]/pages/settings2.php', |
| 66 | 66 |
|
| 67 | 67 |
'[FRAMEWORK]/class.msg_queue.php', |
| 68 |
'[FRAMEWORK]/class.database.php', |
|
| 68 |
'[FRAMEWORK]/class.logfile.php', |
|
| 69 |
// '[FRAMEWORK]/class.database.php', |
|
| 69 | 70 |
|
| 70 | 71 |
); |
| 71 | 72 |
|
| ... | ... | |
| 453 | 454 |
|
| 454 | 455 |
echo (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />"); |
| 455 | 456 |
|
| 456 |
if(version_compare(WB_REVISION, REVISION, '<='))
|
|
| 457 |
if(version_compare(WB_REVISION, REVISION, '<')) |
|
| 457 | 458 |
{
|
| 458 | 459 |
echo '<h3>Step '.(++$stepID).': Updating core tables</h3>'; |
| 459 | 460 |
|
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 51 | 51 |
|
| 52 | 52 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 53 | 53 |
if(!defined('VERSION')) define('VERSION', '2.8.3');
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1688');
|
|
| 54 |
if(!defined('REVISION')) define('REVISION', '1689');
|
|
| 55 | 55 |
if(!defined('SP')) define('SP', '');
|
| branches/2.8.x/wb/framework/class.logfile.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category event logging |
|
| 5 |
* @package core |
|
| 6 |
* @author Independend-Software-Team |
|
| 7 |
* @author WebsiteBaker Project |
|
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.2 |
|
| 12 |
* @requirements PHP 5.2.2 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* @description definition of all core constants. |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
/** |
|
| 20 |
* Description of classlog |
|
| 21 |
* |
|
| 22 |
* @author wkl |
|
| 23 |
*/ |
|
| 24 |
class LogFile {
|
|
| 25 |
|
|
| 26 |
private $_fh; // file-handle for logfile |
|
| 27 |
private $_log_path; // path to logfile |
|
| 28 |
private $_log_file; // name of logfile |
|
| 29 |
private $_error = false; // store internal errors |
|
| 30 |
/* |
|
| 31 |
* class can not be instanciated standalone |
|
| 32 |
*/ |
|
| 33 |
protected function __construct( $log_file ) |
|
| 34 |
{
|
|
| 35 |
$this->_log_file = $log_file; |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
/* |
|
| 39 |
* open the logfile for append |
|
| 40 |
*/ |
|
| 41 |
private function openLogFile() |
|
| 42 |
{
|
|
| 43 |
$this->_fh = fopen($this->_log_path.$this->_log_file, 'ab'); |
|
| 44 |
return isset($this->_fh); |
|
| 45 |
} |
|
| 46 |
/* |
|
| 47 |
* provide read-only properties |
|
| 48 |
*/ |
|
| 49 |
public function __get($property) |
|
| 50 |
{
|
|
| 51 |
switch(strtolower($property)): |
|
| 52 |
case 'error': |
|
| 53 |
return $this->_error; |
|
| 54 |
break; |
|
| 55 |
default: |
|
| 56 |
return null; |
|
| 57 |
endswitch; |
|
| 58 |
} |
|
| 59 |
/* |
|
| 60 |
* flush and close logfile |
|
| 61 |
*/ |
|
| 62 |
private function closeLogFile() |
|
| 63 |
{
|
|
| 64 |
if( isset($this->_fh) ) |
|
| 65 |
{
|
|
| 66 |
fflush($this->_fh); |
|
| 67 |
fclose($this->_fh); |
|
| 68 |
unset($this->_fh); |
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/* |
|
| 73 |
* @param string $logdir: directory to place the logfile |
|
| 74 |
* @return bool: true if directory is valid and writeable |
|
| 75 |
* @description: |
|
| 76 |
*/ |
|
| 77 |
public function setLogDir( $logdir ) |
|
| 78 |
{
|
|
| 79 |
$this->_error = false; |
|
| 80 |
$retval = false; |
|
| 81 |
if( ($logdir = realpath($logdir)) ) |
|
| 82 |
{
|
|
| 83 |
$logdir = rtrim(str_replace('\\', '/', $logdir), '/');
|
|
| 84 |
if( defined('WB_PATH') )
|
|
| 85 |
{
|
|
| 86 |
$sysroot = WB_PATH; |
|
| 87 |
} |
|
| 88 |
else |
|
| 89 |
{
|
|
| 90 |
$script_filename = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
|
|
| 91 |
$script_name = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
|
|
| 92 |
$sysroot = str_replace($script_name, '', $script_filename); |
|
| 93 |
} |
|
| 94 |
if( stripos($logdir, $sysroot) === 0 ) |
|
| 95 |
{
|
|
| 96 |
if( is_writable($logdir)) |
|
| 97 |
{
|
|
| 98 |
if( file_exists($logdir.'/'.$this->_log_file) ) |
|
| 99 |
{
|
|
| 100 |
if( is_writable($logdir.'/'.$this->_log_file) ) |
|
| 101 |
{
|
|
| 102 |
$this->_log_path = $logdir.'/'; |
|
| 103 |
$retval = true; |
|
| 104 |
}else |
|
| 105 |
{
|
|
| 106 |
$this->_error = 'existing logfile is not writable! ['.$logdir.$this->_log_file.']'; |
|
| 107 |
} |
|
| 108 |
} |
|
| 109 |
else |
|
| 110 |
{
|
|
| 111 |
$this->_log_path = $logdir.'/'; |
|
| 112 |
$retval = true; |
|
| 113 |
} |
|
| 114 |
}else |
|
| 115 |
{
|
|
| 116 |
$this->_error = 'access denied for directory ['.$logdir.']'; |
|
| 117 |
} |
|
| 118 |
}else |
|
| 119 |
{
|
|
| 120 |
$this->_error = 'logdir [ '.$logdir.' ] points outside of DOCUMENT_ROOT [ '.$sysroot.' ]'; |
|
| 121 |
} |
|
| 122 |
}else |
|
| 123 |
{
|
|
| 124 |
$this->_error = 'logdir can not be resolved ['.$logdir.']'; |
|
| 125 |
} |
|
| 126 |
return $retval; |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
/* |
|
| 130 |
* @param string $line: preformatted message to write into the logfile |
|
| 131 |
* @return none: an error will throw a exception |
|
| 132 |
*/ |
|
| 133 |
protected function writeRaw( $message ) |
|
| 134 |
{
|
|
| 135 |
array_unshift( $message, (defined($_SESSION['USER_ID'])?$_SESSION['USER_ID']:0) ); |
|
| 136 |
array_unshift( $message, (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'#') ); |
|
| 137 |
array_unshift( $message, gmdate(DATE_W3C) ); |
|
| 138 |
if( isset($this->_log_path) ){
|
|
| 139 |
if($this->openLogFile()) |
|
| 140 |
{
|
|
| 141 |
if( fputcsv($this->_fh, $message, ',', '"') !== false ) |
|
| 142 |
{
|
|
| 143 |
$this->closeLogFile(); |
|
| 144 |
} |
|
| 145 |
else |
|
| 146 |
{
|
|
| 147 |
throw new Exception('unable to append line ['.$this->_log_path.$this->_log_file.']');
|
|
| 148 |
} |
|
| 149 |
} |
|
| 150 |
else |
|
| 151 |
{
|
|
| 152 |
throw new Exception('unable to open logfile ['.$this->_log_path.$this->_log_file.']');
|
|
| 153 |
} |
|
| 154 |
}else |
|
| 155 |
{
|
|
| 156 |
throw new Exception('undefined path for logfile ['.$this->_log_file.']');
|
|
| 157 |
} |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
} // end of class |
|
| 161 |
|
|
| 162 |
/* |
|
| 163 |
* Errorlog handler |
|
| 164 |
*/ |
|
| 165 |
class ErrorLog extends LogFile{
|
|
| 166 |
|
|
| 167 |
private static $_instance; |
|
| 168 |
|
|
| 169 |
protected function __construct() |
|
| 170 |
{
|
|
| 171 |
parent::__construct('error.log');
|
|
| 172 |
} |
|
| 173 |
|
|
| 174 |
private function __clone() {}
|
|
| 175 |
|
|
| 176 |
public static function handle() |
|
| 177 |
{
|
|
| 178 |
if (!isset(self::$_instance)) {
|
|
| 179 |
$c = __CLASS__; |
|
| 180 |
self::$_instance = new $c; |
|
| 181 |
} |
|
| 182 |
return self::$_instance; |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
/* |
|
| 186 |
* @param string $message: message to write into the logfile |
|
| 187 |
* @param string $file: (optional) name of the file where the error occures |
|
| 188 |
* @param string $function: (optional) name of the function where the error occures |
|
| 189 |
* @param string $line: (optional) number of the line where the error occures |
|
| 190 |
* @return none: an error will throw a exception |
|
| 191 |
*/ |
|
| 192 |
public function write( $message, $file = '#', $function = '#', $line = '#' ) |
|
| 193 |
{
|
|
| 194 |
if( !is_array($message) ) |
|
| 195 |
{
|
|
| 196 |
$message = array($file, $function, $line, $message); |
|
| 197 |
} |
|
| 198 |
self::handle()->writeRaw( $message ); |
|
| 199 |
} |
|
| 200 |
} // end of class |
|
| 201 |
|
|
| 202 |
/* |
|
| 203 |
* Accesslog handler |
|
| 204 |
*/ |
|
| 205 |
class AccessLog extends LogFile{
|
|
| 206 |
|
|
| 207 |
private static $_instance; |
|
| 208 |
|
|
| 209 |
protected function __construct() |
|
| 210 |
{
|
|
| 211 |
parent::__construct('access.log');
|
|
| 212 |
} |
|
| 213 |
|
|
| 214 |
private function __clone() {}
|
|
| 215 |
|
|
| 216 |
public static function handle() |
|
| 217 |
{
|
|
| 218 |
if (!isset(self::$_instance)) {
|
|
| 219 |
$c = __CLASS__; |
|
| 220 |
self::$_instance = new $c; |
|
| 221 |
} |
|
| 222 |
return self::$_instance; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/* |
|
| 226 |
* @param string $message: message to write into the logfile |
|
| 227 |
* @return none: an error will throw a exception |
|
| 228 |
*/ |
|
| 229 |
public function write( $message ) |
|
| 230 |
{
|
|
| 231 |
if( !is_array($message) ) |
|
| 232 |
{
|
|
| 233 |
$message = array($message); |
|
| 234 |
} |
|
| 235 |
self::handle()->writeRaw( $message ); |
|
| 236 |
} |
|
| 237 |
} // end of class |
|
| 238 |
|
|
| 239 |
|
|
| 240 |
?> |
|
| 241 | 0 | |
| branches/2.8.x/wb/framework/class.database | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* Temporary class to detect invalid instancing |
|
| 4 |
* |
|
| 5 |
* @author wkl |
|
| 6 |
*/ |
|
| 7 |
class database {
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
public function __construct() {
|
|
| 11 |
|
|
| 12 |
$y = debug_backtrace(); |
|
| 13 |
echo '<div style="margin: 100px auto; width: 70%">'; |
|
| 14 |
echo '<p style="color: #dd0000; font-weight: bold;">Runtime Error !!</p>'; |
|
| 15 |
echo '<p>Ouups... there is a invalid statement found!!</p>'; |
|
| 16 |
echo '<p>In File: <b>'.$y[0]['file'].'</b> Line: <b>'.$y[0]['line'].'</b><br />tried to create an invalid <b>'.$y[0]['class'].'</b> - object</p>'; |
|
| 17 |
echo '<p>Please contact the module author to solve this problem.</p>'; |
|
| 18 |
echo '<p>Also you can get information and help from the '; |
|
| 19 |
echo '<a href="http://www.websitebaker2.org/forum/index.php/board,2.0.html">WebsiteBaker Forum</a></p>'; |
|
| 20 |
echo '<hr />'; |
|
| 21 |
echo '<p style="color: #dd0000; font-weight: bold;">Runtime Error !!</p>'; |
|
| 22 |
echo '<p>Ouups... hier wurde ein ungültiges Kommando gefunden!!</p>'; |
|
| 23 |
echo '<p>In Datei: <b>'.$y[0]['file'].'</b> - Zeile: <b>'.$y[0]['line'].'</b><br />es wurde versucht, ein ungültiges <b>'.$y[0]['class'].'</b> - Objekt zu erstellen.</p>'; |
|
| 24 |
echo '<p>Bitte kontaktieren Sie den Modulautor um dieses Problem zu lösen.</p>'; |
|
| 25 |
echo '<p>Ebenso können sie auch Informationen und Hilfe im '; |
|
| 26 |
echo '<a href="http://www.websitebaker2.org/forum/index.php/board,31.0.html">WebsiteBaker Forum</a> finden.</p>'; |
|
| 27 |
echo '</div>'; |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
|
|
| 31 |
} |
|
| branches/2.8.x/wb/framework/class.database.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* Temporary class to detect invalid instancing |
|
| 4 |
* |
|
| 5 |
* @author wkl |
|
| 6 |
*/ |
|
| 7 |
class database {
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
public function __construct() {
|
|
| 11 |
|
|
| 12 |
$this->showError(); |
|
| 13 |
} |
|
| 14 |
|
|
| 15 |
public function __call($name, $arguments) {
|
|
| 16 |
$this->showError(); |
|
| 17 |
} |
|
| 18 |
private function showError() {
|
|
| 19 |
|
|
| 20 |
$y = debug_backtrace(); |
|
| 21 |
$msg = '<div style="margin: 100px auto; width: 70%">'; |
|
| 22 |
$msg .= '<p style="color: #dd0000; font-weight: bold;">Runtime Error !!</p>'; |
|
| 23 |
$msg .= '<p>Ouups... there is a invalid statement found!!</p>'; |
|
| 24 |
$msg .= '<p>In File: <b>'.$y[0]['file'].'</b> Line: <b>'.$y[0]['line'].'</b><br />tried to create an invalid <b>'.$y[0]['class'].'</b> - object</p>'; |
|
| 25 |
$msg .= '<p>Please contact the module author to solve this problem.</p>'; |
|
| 26 |
$msg .= '<p>Also you can get information and help from the '; |
|
| 27 |
$msg .= '<a href="http://www.websitebaker2.org/forum/index.php/board,2.0.html">WebsiteBaker Forum</a></p>'; |
|
| 28 |
$msg .= '<hr />'; |
|
| 29 |
$msg .= '<p style="color: #dd0000; font-weight: bold;">Runtime Error !!</p>'; |
|
| 30 |
$msg .= '<p>Ouups... hier wurde ein ungültiges Kommando gefunden!!</p>'; |
|
| 31 |
$msg .= '<p>In Datei: <b>'.$y[0]['file'].'</b> - Zeile: <b>'.$y[0]['line'].'</b><br />es wurde versucht, ein ungültiges <b>'.$y[0]['class'].'</b> - Objekt zu erstellen.</p>'; |
|
| 32 |
$msg .= '<p>Bitte kontaktieren Sie den Modulautor um dieses Problem zu lösen.</p>'; |
|
| 33 |
$msg .= '<p>Ebenso können sie auch Informationen und Hilfe im '; |
|
| 34 |
$msg .= '<a href="http://www.websitebaker2.org/forum/index.php/board,31.0.html">WebsiteBaker Forum</a> finden.</p>'; |
|
| 35 |
$msg .= '</div>'; |
|
| 36 |
die($msg); |
|
| 37 |
|
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
} |
|
| 0 | 41 | |
| branches/2.8.x/wb/framework/LogfileDev.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category event logging |
|
| 5 |
* @package core |
|
| 6 |
* @author Independend-Software-Team |
|
| 7 |
* @author WebsiteBaker Project |
|
| 8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 9 |
* @link http://www.websitebaker2.org/ |
|
| 10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 11 |
* @platform WebsiteBaker 2.8.2 |
|
| 12 |
* @requirements PHP 5.2.2 and higher |
|
| 13 |
* @version $Id$ |
|
| 14 |
* @filesource $HeadURL$ |
|
| 15 |
* @lastmodified $Date$ |
|
| 16 |
* @description definition of all core constants. |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
/** |
|
| 20 |
* !!! This class is exclusive for developing purposes !!!! |
|
| 21 |
* |
|
| 22 |
* @author wkl |
|
| 23 |
*/ |
|
| 24 |
class LogfileDev {
|
|
| 25 |
|
|
| 26 |
private $_fh; // file-handle for logfile |
|
| 27 |
private $_log_path; // path to logfile |
|
| 28 |
private $_log_file; // name of logfile |
|
| 29 |
private $_error = false; // store internal errors |
|
| 30 |
/* |
|
| 31 |
* class can not be instanciated standalone |
|
| 32 |
*/ |
|
| 33 |
protected function __construct( $log_file ) |
|
| 34 |
{
|
|
| 35 |
$this->_log_file = $log_file; |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
/* |
|
| 39 |
* open the logfile for append |
|
| 40 |
*/ |
|
| 41 |
private function openLogFile() |
|
| 42 |
{
|
|
| 43 |
$this->_fh = fopen($this->_log_path.$this->_log_file, 'ab'); |
|
| 44 |
return isset($this->_fh); |
|
| 45 |
} |
|
| 46 |
/* |
|
| 47 |
* provide read-only properties |
|
| 48 |
*/ |
|
| 49 |
public function __get($property) |
|
| 50 |
{
|
|
| 51 |
switch(strtolower($property)): |
|
| 52 |
case 'error': |
|
| 53 |
return $this->_error; |
|
| 54 |
break; |
|
| 55 |
default: |
|
| 56 |
return null; |
|
| 57 |
endswitch; |
|
| 58 |
} |
|
| 59 |
/* |
|
| 60 |
* flush and close logfile |
|
| 61 |
*/ |
|
| 62 |
private function closeLogFile() |
|
| 63 |
{
|
|
| 64 |
if( isset($this->_fh) ) |
|
| 65 |
{
|
|
| 66 |
fflush($this->_fh); |
|
| 67 |
fclose($this->_fh); |
|
| 68 |
unset($this->_fh); |
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/* |
|
| 73 |
* @param string $logdir: directory to place the logfile |
|
| 74 |
* @return bool: true if directory is valid and writeable |
|
| 75 |
* @description: |
|
| 76 |
*/ |
|
| 77 |
public function setLogDir( $logdir ) |
|
| 78 |
{
|
|
| 79 |
$this->_error = false; |
|
| 80 |
$retval = false; |
|
| 81 |
if( ($logdir = realpath($logdir)) ) |
|
| 82 |
{
|
|
| 83 |
$logdir = rtrim(str_replace('\\', '/', $logdir), '/');
|
|
| 84 |
if( defined('WB_PATH') )
|
|
| 85 |
{
|
|
| 86 |
$sysroot = WB_PATH; |
|
| 87 |
} |
|
| 88 |
else |
|
| 89 |
{
|
|
| 90 |
$script_filename = str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']);
|
|
| 91 |
$script_name = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
|
|
| 92 |
$sysroot = str_replace($script_name, '', $script_filename); |
|
| 93 |
} |
|
| 94 |
if( stripos($logdir, $sysroot) === 0 ) |
|
| 95 |
{
|
|
| 96 |
if( is_writable($logdir)) |
|
| 97 |
{
|
|
| 98 |
if( file_exists($logdir.'/'.$this->_log_file) ) |
|
| 99 |
{
|
|
| 100 |
if( is_writable($logdir.'/'.$this->_log_file) ) |
|
| 101 |
{
|
|
| 102 |
$this->_log_path = $logdir.'/'; |
|
| 103 |
$retval = true; |
|
| 104 |
}else |
|
| 105 |
{
|
|
| 106 |
$this->_error = 'existing logfile is not writable! ['.$logdir.$this->_log_file.']'; |
|
| 107 |
} |
|
| 108 |
} |
|
| 109 |
else |
|
| 110 |
{
|
|
| 111 |
$this->_log_path = $logdir.'/'; |
|
| 112 |
$retval = true; |
|
| 113 |
} |
|
| 114 |
}else |
|
| 115 |
{
|
|
| 116 |
$this->_error = 'access denied for directory ['.$logdir.']'; |
|
| 117 |
} |
|
| 118 |
}else |
|
| 119 |
{
|
|
| 120 |
$this->_error = 'logdir [ '.$logdir.' ] points outside of DOCUMENT_ROOT [ '.$sysroot.' ]'; |
|
| 121 |
} |
|
| 122 |
}else |
|
| 123 |
{
|
|
| 124 |
$this->_error = 'logdir can not be resolved ['.$logdir.']'; |
|
| 125 |
} |
|
| 126 |
return $retval; |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
/* |
|
| 130 |
* @param string $line: preformatted message to write into the logfile |
|
| 131 |
* @return none: an error will throw a exception |
|
| 132 |
*/ |
|
| 133 |
protected function writeRaw( $message ) |
|
| 134 |
{
|
|
| 135 |
array_unshift( $message, (defined($_SESSION['USER_ID'])?$_SESSION['USER_ID']:0) ); |
|
| 136 |
array_unshift( $message, (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'#') ); |
|
| 137 |
array_unshift( $message, gmdate(DATE_W3C) ); |
|
| 138 |
if( isset($this->_log_path) ){
|
|
| 139 |
if($this->openLogFile()) |
|
| 140 |
{
|
|
| 141 |
if( fputcsv($this->_fh, $message, ',', '"') !== false ) |
|
| 142 |
{
|
|
| 143 |
$this->closeLogFile(); |
|
| 144 |
} |
|
| 145 |
else |
|
| 146 |
{
|
|
| 147 |
throw new Exception('unable to append line ['.$this->_log_path.$this->_log_file.']');
|
|
| 148 |
} |
|
| 149 |
} |
|
| 150 |
else |
|
| 151 |
{
|
|
| 152 |
throw new Exception('unable to open logfile ['.$this->_log_path.$this->_log_file.']');
|
|
| 153 |
} |
|
| 154 |
}else |
|
| 155 |
{
|
|
| 156 |
throw new Exception('undefined path for logfile ['.$this->_log_file.']');
|
|
| 157 |
} |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
} // end of class |
|
| 161 |
|
|
| 162 |
/* |
|
| 163 |
* Errorlog handler |
|
| 164 |
*/ |
|
| 165 |
class ErrorLog extends LogFile{
|
|
| 166 |
|
|
| 167 |
private static $_instance; |
|
| 168 |
|
|
| 169 |
protected function __construct() |
|
| 170 |
{
|
|
| 171 |
parent::__construct('error.log');
|
|
| 172 |
} |
|
| 173 |
|
|
| 174 |
private function __clone() {}
|
|
| 175 |
|
|
| 176 |
public static function handle() |
|
| 177 |
{
|
|
| 178 |
if (!isset(self::$_instance)) {
|
|
| 179 |
$c = __CLASS__; |
|
| 180 |
self::$_instance = new $c; |
|
| 181 |
} |
|
| 182 |
return self::$_instance; |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
/* |
|
| 186 |
* @param string $message: message to write into the logfile |
|
| 187 |
* @param string $file: (optional) name of the file where the error occures |
|
| 188 |
* @param string $function: (optional) name of the function where the error occures |
|
| 189 |
* @param string $line: (optional) number of the line where the error occures |
|
| 190 |
* @return none: an error will throw a exception |
|
| 191 |
*/ |
|
| 192 |
public function write( $message, $file = '#', $function = '#', $line = '#' ) |
|
| 193 |
{
|
|
| 194 |
if( !is_array($message) ) |
|
| 195 |
{
|
|
| 196 |
$message = array($file, $function, $line, $message); |
|
| 197 |
} |
|
| 198 |
self::handle()->writeRaw( $message ); |
|
| 199 |
} |
|
| 200 |
} // end of class |
|
| 201 |
|
|
| 202 |
/* |
|
| 203 |
* Accesslog handler |
|
| 204 |
*/ |
|
| 205 |
class AccessLog extends LogFile{
|
|
| 206 |
|
|
| 207 |
private static $_instance; |
|
| 208 |
|
|
| 209 |
protected function __construct() |
|
| 210 |
{
|
|
| 211 |
parent::__construct('access.log');
|
|
| 212 |
} |
|
| 213 |
|
|
| 214 |
private function __clone() {}
|
|
| 215 |
|
|
| 216 |
public static function handle() |
|
| 217 |
{
|
|
| 218 |
if (!isset(self::$_instance)) {
|
|
| 219 |
$c = __CLASS__; |
|
| 220 |
self::$_instance = new $c; |
|
| 221 |
} |
|
| 222 |
return self::$_instance; |
|
| 223 |
} |
|
| 224 |
|
|
| 225 |
/* |
|
| 226 |
* @param string $message: message to write into the logfile |
|
| 227 |
* @return none: an error will throw a exception |
|
| 228 |
*/ |
|
| 229 |
public function write( $message ) |
|
| 230 |
{
|
|
| 231 |
if( !is_array($message) ) |
|
| 232 |
{
|
|
| 233 |
$message = array($message); |
|
| 234 |
} |
|
| 235 |
self::handle()->writeRaw( $message ); |
|
| 236 |
} |
|
| 237 |
} // end of class |
|
| 238 |
|
|
| 239 |
|
|
| 240 |
?> |
|
| 0 | 241 | |
| branches/2.8.x/wb/framework/WbAutoloader.php | ||
|---|---|---|
| 32 | 32 |
*/ |
| 33 | 33 |
static public function CoreAutoloader($sClassName) |
| 34 | 34 |
{
|
| 35 |
$sClassName = preg_replace(self::$_aSearchpatterns, self::$_aReplacements, $sClassName); |
|
| 36 |
$sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php';
|
|
| 37 |
if(is_file($sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php')) {
|
|
| 38 |
include($sFileName); |
|
| 35 |
if($sClassName == 'database'){
|
|
| 36 |
$sFileName = dirname(__FILE__).'/class.database.php'; |
|
| 37 |
if(is_file($sFileName)) { include($sFileName); }
|
|
| 38 |
}else {
|
|
| 39 |
$sClassName = preg_replace(self::$_aSearchpatterns, self::$_aReplacements, $sClassName); |
|
| 40 |
$sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php';
|
|
| 41 |
if(is_file($sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php')) {
|
|
| 42 |
include($sFileName); |
|
| 43 |
} |
|
| 39 | 44 |
} |
| 40 | 45 |
} |
| 41 | 46 |
} // end class Autoloader |
Also available in: Unified diff
fixed Errorhandling for old class.database