Project

General

Profile

Revision 2129

Added by Manuela over 7 years ago

  1. framework/WbDatabase typo corrections
    ! framework/initialize.php added ErrorHandler and ERROR-LOG file

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
19 Jun -2015 Build 2129 Manuela v.d.Decken(DarkViper)
15
# framework/WbDatabase typo corrections
16
! framework/initialize.php added ErrorHandler and ERROR-LOG file
14 17
18 Jun -2015 Build 2128 Manuela v.d.Decken(DarkViper)
15 18
# framework/WbDatabase correction in ::fetchAsscoc()
16 19
18 Jun -2015 Build 2127 Manuela v.d.Decken(DarkViper)
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.4');
54
if(!defined('REVISION')) define('REVISION', '2128');
54
if(!defined('REVISION')) define('REVISION', '2129');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/framework/WbDatabaseHelper.php
75 75
        $keys = 0;
76 76
        $sql = 'SHOW INDEX FROM `'.$table_name.'`';
77 77
        if (($res_keys = $this->doQuery($sql))) {
78
            while (($rec_key = $res_keys->fetchRow(MYSQL_ASSOC))) {
78
            while (($rec_key = $res_keys->fetchAssoc())) {
79 79
                if ( $rec_key['Key_name'] == $index_name ) {
80 80
                    $keys++;
81 81
                }
......
114 114
                return ( $this->isField($table_name, $field_name) ) ? true : false;
115 115
            }
116 116
        } else {
117
            $this->set_error('field \''.$field_name.'\' already exists');
117
            $this->setError('field \''.$field_name.'\' already exists');
118 118
        }
119 119
        return false;
120 120
    }
......
257 257
        $engineValue = (version_compare($mysqlVersion, '5.0') < 0) ? 'Type' : 'Engine';
258 258
        $sql = 'SHOW TABLE STATUS FROM `' . $this->sDbName . '` LIKE \'' . $table . '\'';
259 259
        if (($result = $this->doQuery($sql))) {
260
            if (($row = $result->fetchRow(MYSQL_ASSOC))) {
260
            if (($row = $result->fetchAssoc())) {
261 261
                $retVal = $row[$engineValue];
262 262
            }
263 263
        }
......
290 290
        $retval = true;
291 291
        $sNameValPairs = '';
292 292
        foreach ($key as $index => $val) {
293
            $sNameValPairs .= ', (\''.$index.'\', \''.$val.'\')';
293
            $sNameValPairs .= ', (\''.$index.'\', \''.$oDb->escapeString($val).'\')';
294 294
        }
295 295
        $sValues = ltrim($sNameValPairs, ', ');
296 296
        if ($sValues != '') {
branches/2.8.x/wb/framework/WbDatabase.php
185 185
        $oRetval = null;
186 186
        $this->iQueryCount++;
187 187
        $mysql = new mysql($this->oDbHandle, $statement);
188
        $this->set_error($mysql->error($this->oDbHandle));
188
        $this->setError($mysql->error($this->oDbHandle));
189 189
        if (!$mysql->error()) {
190 190
            $oRetval = $mysql;
191 191
        }
192
        $this->set_error($mysql->error($this->oDbHandle));
192
        $this->setError($mysql->error($this->oDbHandle));
193 193
        return $oRetval;
194 194
    }
195 195
/**
......
439 439
 */
440 440
    public function fetchAssoc()
441 441
    {
442
        return mysqli_fetch_row($this->result);
442
        return mysqli_fetch_assoc($this->result);
443 443
    }
444 444
/**
445 445
 * fetchArray
......
477 477
 */
478 478
    public function fetchAll($iType = MYSQLI_ASSOC)
479 479
    {
480
        $iType = $iType != MYSQLI_NUM ? MYSQL_ASSOC : MYSQLI_NUM;
480
        $iType = $iType != MYSQLI_NUM ? MYSQLI_ASSOC : MYSQLI_NUM;
481 481
        return mysqli_fetch_all($this->result, $iType);
482 482
    }
483 483
/**
branches/2.8.x/wb/framework/initialize.php
215 215
        return $aRetval;
216 216
    }
217 217

  
218
    function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine)
219
    {
220
        if (!(error_reporting() & $iErrorCode)) {
221
            return false;
222
        }
223
        $bRetval = false;
224
        $aErrors = array(
225
            E_USER_DEPRECATED => 'E_USER_DEPRECATED',
226
            E_USER_NOTICE     => 'E_USER_NOTICE',
227
            E_USER_WARNING    => 'E_USER_WARNING',
228
            E_DEPRECATED      => 'E_DEPRECATED',
229
            E_NOTICE          => 'E_NOTICE',
230
            E_WARNING         => 'E_WARNING',
231
            E_CORE_WARNING    => 'E_CORE_WARNING',
232
            E_COMPILE_WARNING => 'E_COMPILE_WARNING',
233
            E_STRICT          => 'E_STRICT',
234
        );
235
        if (array_key_exists($iErrorCode, $aErrors)) {
236
            $sErrorType = $aErrors[$iErrorCode];
237
            $bRetval = true;
238
        }
239
        $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
240
        $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
241
                . ' from '.str_replace(dirname(__DIR__), '', $aBt[2]['file']).':['.$aBt[2]['line'].'] '
242
                . (@$aBt[2]['class'] ? $aBt[2]['class'].$aBt[2]['type'] : '').$aBt[2]['function'].' '
243
                . '"'.$sErrorText.'"'.PHP_EOL;
244
        file_put_contents(dirname(__DIR__).'/temp/ERROR.LOG', $sEntry, FILE_APPEND);
245
        return $bRetval;
246
    }
218 247
/* ***************************************************************************************
219 248
 * Start initialization                                                                  *
220 249
 ****************************************************************************************/
250
// activate errorhandler
251
    set_error_handler('WbErrorHandler');
221 252
// reset global output buffering
222 253
    while (ob_get_level()) { ob_end_clean(); }
223 254
// test for existing and active old config.php
......
242 273
    if (! defined('SYSTEM_RUN')) { define('SYSTEM_RUN', true); }
243 274
// load configuration ---
244 275
    $aCfg = initReadSetupFile();
276

  
245 277
// sanitize $_SERVER['HTTP_REFERER'] ---
246 278
    initSetInstallPathConstants();
247 279
    initSanitizeHttpReferer(WB_URL);
......
294 326
// load global settings from database and define global consts from ---
295 327
    $sql = 'SELECT `name`, `value` FROM `'.$oDb->TablePrefix.'settings`';
296 328
    if(($oSettings = $oDb->doQuery($sql))) {
297
        if(!$oSettings->numRows()) { throw new AppException('no settings found'); }
298
        while($aSetting = $oSettings->fetchRow(MYSQL_ASSOC)) {
299
            //sanitize true/false values
300
            $aSetting['value'] = ($aSetting['value'] == 'true'
301
                                  ? true
302
                                  : ($aSetting['value'] == 'false'
303
                                     ? false
304
                                     : $aSetting['value'])
305
                                 );
306
            $sSettingName = strtoupper($aSetting['name']);
307
            switch($sSettingName):
308
                case 'STRING_FILE_MODE':
309
                    $iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
310
                    if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated
311
                    if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); }
312
                    if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated
313
                    if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); }
314
                    break;
315
                case 'STRING_DIR_MODE':
316
                    $iTmp = (intval(octdec($aSetting['value'])) |0711);
317
                    if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated
318
                    if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); }
319
                    if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated
320
                    if(!defined('DIR_MODE_STRING')) { define('DIR_MODE_STRING', sprintf('0%03o', $iTmp)); }
321
                    break;
322
                case 'PAGES_DIRECTORY':
323
                    // sanitize pages_directory
324
                    $sTmp = trim($aSetting['value'], '/');
325
                    $sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
326
                    if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); }
327
                    break;
328
                default: // make global const from setting
329
                    if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
330
                    break;
331
            endswitch;
329
        if (($aRecords = $oSettings->fetchAll(MYSQLI_NUM))) {
330
            $iNum = sizeof($aRecords);
331
            for ($i = 0; $i < $iNum; $i++) {
332
                $aSetting = $aRecords[$i];
333
                //sanitize true/false values
334
                $aSetting['value'] = ($aSetting['value'] == 'true'
335
                                      ? true
336
                                      : ($aSetting['value'] == 'false'
337
                                         ? false
338
                                         : $aSetting['value'])
339
                                     );
340
                $sSettingName = strtoupper($aSetting['name']);
341
                switch($sSettingName):
342
                    case 'STRING_FILE_MODE':
343
                        $iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
344
                        if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated
345
                        if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); }
346
                        if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated
347
                        if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); }
348
                        break;
349
                    case 'STRING_DIR_MODE':
350
                        $iTmp = (intval(octdec($aSetting['value'])) |0711);
351
                        if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated
352
                        if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); }
353
                        if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated
354
                        if(!defined('DIR_MODE_STRING')) { define('DIR_MODE_STRING', sprintf('0%03o', $iTmp)); }
355
                        break;
356
                    case 'PAGES_DIRECTORY':
357
                        // sanitize pages_directory
358
                        $sTmp = trim($aSetting['value'], '/');
359
                        $sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
360
                        if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); }
361
                        break;
362
                    default: // make global const from setting
363
                        if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
364
                        break;
365
                endswitch;
366
            }
367
        } else {
368
            throw new AppException('no settings found');
332 369
        }
333
    }else { throw new AppException($database->get_error()); }
370
    } else {
371
        throw new AppException($oDb->getError());
372
    }
373
    $oReg->getWbConstants();
334 374
// set error-reporting from loaded settings ---
335
    if(intval(ER_LEVEL) > 0 ) {
336
        error_reporting(ER_LEVEL);
337
        if( intval(ini_get ( 'display_errors' )) == 0 ) {
338
            ini_set('display_errors', 1);
339
        }
375
    $iErrorLevel = intval(ER_LEVEL);
376
    if ($iErrorLevel >= 0 && $iErrorLevel <= E_ALL) {
377
        error_reporting($iErrorLevel);
378
    } else {
379
    // on invalid value in ER_LEVEL activate E_ALL
380
        error_reporting(E_ALL);
340 381
    }
382
// activate display_errors
383
    if( intval(ini_get ( 'display_errors' )) == 0 ) {
384
        ini_set('display_errors', 1);
385
    }
341 386
// Start a session ---
342 387
    if(!defined('SESSION_STARTED')) {
343 388
        session_name(APP_NAME.'_session_id');
......
367 412
// *** begin deprecated part *************************************************************
368 413
// load settings for use in Captch and ASP module
369 414
    if (!defined('WB_INSTALL_PROCESS') && !defined('ENABLED_CAPTCHA')) {
370
        $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
415
        $sql = 'SELECT * FROM `'.$oDb->TablePrefix.'mod_captcha_control`';
371 416
        // request settings from database
372
        if(($oSettings = $database->query($sql))) {
373
            if(($aSetting = $oSettings->fetchRow(MYSQL_ASSOC))) {
417
        if(($oSettings = $oDb->doQuery($sql))) {
418
            if(($aSetting = $oSettings->fetchAssoc())) {
374 419
                define('ENABLED_CAPTCHA', ($aSetting['enabled_captcha'] == '1'));
375 420
                define('ENABLED_ASP', ($aSetting['enabled_asp'] == '1'));
376 421
                define('CAPTCHA_TYPE', $aSetting['captcha_type']);

Also available in: Unified diff