Project

General

Profile

« Previous | Next » 

Revision 31

Added by Manuela over 6 years ago

little fix in HttpRequester::__construct()

View differences:

branches/main/admin/interface/version.php
44 44
if (!defined('VERSION_LOADED')) {
45 45
    $sInfo = '
46 46
        VERSION  = "2.11.0-RC1"
47
        REVISION = "30"
47
        REVISION = "31"
48 48
        SP       = ""
49 49
    ';
50 50
    foreach (parse_ini_string($sInfo) as $item=>$value) {
branches/main/framework/HttpRequester.php
33 33
//declare(strict_types = 1);
34 34
//declare(encoding = 'UTF-8');
35 35

  
36
namespace bin;
36
namespace bin\requester;
37 37

  
38 38
use bin\interfaces\RequesterInterface;
39 39

  
......
50 50
 */
51 51
    public function __construct()
52 52
    {
53
//        $this->aServer = \filter_input_array(INPUT_SERVER);
54 53
        $aServer = \filter_input_array(INPUT_SERVER);
55 54
        switch (\strtolower($aServer['REQUEST_METHOD'])):
56 55
            case 'post':
......
60 59
                $this->aParameters = \filter_input_array(INPUT_GET);
61 60
                break;
62 61
            default:
63
                $this->aParameters = [];
64 62
                break;
65 63
        endswitch;
64
        if ($this->aParameters == null) { $this->aParameters = []; }
66 65
        foreach ($aServer as $sKey => $sValue) {
67
            if (substr_compare($sKey, 'HTTP_', 0, 5) === 0) {
66
            if (\substr_compare($sKey, 'HTTP_', 0, 5) === 0) {
68 67
                $this->aHeaders[$sKey] = $sValue;
69 68
            } else {
70 69
                $this->aServer[$sKey] = $sValue;
......
86 85
 */
87 86
    public function issetParam($sParamName)
88 87
    {
88

  
89 89
        return \array_key_exists($sParamName, $this->aParameters);
90 90
    }
91 91
/**
......
134 134
    public function getHeader($sHeaderName)
135 135
    {
136 136
        $sRetval = null;
137
        $sVarname = 'HTTP_'.preg_replace('/^http_/i', '', $sHeaderName);
137
        $sVarname = 'HTTP_'.\preg_replace('/^http_/i', '', $sHeaderName);
138 138
        if ($this->issetHeader($sVarname)) {
139 139
            $sRetval = $this->aHeaders($sVarname);
140 140
        }
branches/main/framework/initialize.php
207 207

  
208 208
function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine)
209 209
{
210
     if (!(error_reporting() & $iErrorCode) || ini_get('log_errors') == 0) {
211
        return false;
212
    }
213 210
    $bRetval = false;
214
    $sErrorLogFile = ini_get ('error_log');
215
    if (!is_writeable($sErrorLogFile)){return false;}
216
    $sErrorType = E_NOTICE ;
217
    $aErrors = array(
218
        E_USER_DEPRECATED   => 'E_USER_DEPRECATED',
219
        E_USER_NOTICE       => 'E_USER_NOTICE',
220
        E_USER_WARNING      => 'E_USER_WARNING',
221
        E_DEPRECATED        => 'E_DEPRECATED',
222
        E_NOTICE            => 'E_NOTICE',
223
        E_WARNING           => 'E_WARNING',
224
        E_CORE_WARNING      => 'E_CORE_WARNING',
225
        E_COMPILE_WARNING   => 'E_COMPILE_WARNING',
226
        E_STRICT            => 'E_STRICT',
227
        E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
228
    );
229
    if (array_key_exists($iErrorCode, $aErrors)) {
230
        $sErrorType = $aErrors[$iErrorCode];
231
        $bRetval = true;
211
    if ((error_reporting() & $iErrorCode) || ini_get('log_errors') != 0) {
212
        $sErrorLogFile = ini_get ('error_log');
213
        if (is_writeable($sErrorLogFile)) {
214
            $sErrorType = E_NOTICE ;
215
            $aErrors = [
216
                E_USER_DEPRECATED   => 'E_USER_DEPRECATED',
217
                E_USER_NOTICE       => 'E_USER_NOTICE',
218
                E_USER_WARNING      => 'E_USER_WARNING',
219
                E_DEPRECATED        => 'E_DEPRECATED',
220
                E_NOTICE            => 'E_NOTICE',
221
                E_WARNING           => 'E_WARNING',
222
                E_CORE_WARNING      => 'E_CORE_WARNING',
223
                E_COMPILE_WARNING   => 'E_COMPILE_WARNING',
224
                E_STRICT            => 'E_STRICT',
225
                E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
226
            ];
227
            if (array_key_exists($iErrorCode, $aErrors)) {
228
                $sErrorType = $aErrors[$iErrorCode];
229
                $bRetval = true;
230
            }
231
            $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
232
            $x = sizeof($aBt) -1;
233
            $iSize = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
234
            $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
235
                    . ' from '.str_replace(dirname(__DIR__), '', $aBt[$iSize]['file']).':['.$aBt[$iSize]['line'].'] '
236
                    . (isset($aBt[$iSize]['class']) ? $aBt[$iSize]['class'].$aBt[$iSize]['type'] : '').$aBt[$iSize]['function'].' '
237
                    . '"'.$sErrorText.'"'.PHP_EOL;
238
            file_put_contents($sErrorLogFile, $sEntry, FILE_APPEND);
239
        }
232 240
    }
233
    $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
234
    $x = sizeof($aBt) -1;
235
    $iSize = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
236
    $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
237
            . ' from '.str_replace(dirname(__DIR__), '', $aBt[$iSize]['file']).':['.$aBt[$iSize]['line'].'] '
238
            . (isset($aBt[$iSize]['class']) ? $aBt[$iSize]['class'].$aBt[$iSize]['type'] : '').$aBt[$iSize]['function'].' '
239
            . '"'.$sErrorText.'"'.PHP_EOL;
240
    file_put_contents($sErrorLogFile, $sEntry, FILE_APPEND);
241 241
    return $bRetval;
242 242
}
243 243
/**
......
279 279
        include __DIR__.'/CoreAutoloader.php';
280 280
    }
281 281
    \bin\CoreAutoloader::doRegister(dirname(__DIR__));
282
    \bin\CoreAutoloader::addNamespace([ // add several needed namespaces
282
    \bin\CoreAutoloader::addNamespace([ // add several needed namespaces->folder translations
283 283
    //  Namespace               Directory
284
        'bin'                => 'framework',
285
        'addon'              => 'modules',
286
        'vendor'             => 'include',
287
        'vendor\\jscalendar' => 'include/jscalendar',
288
        'bin\\db'            => 'framework/db',
289
        'bin\\security'      => 'framework',
290
        'bin\\interfaces'    => 'framework',
291
        'api'                => 'framework/api',
284
        'bin'                    => 'framework',
285
        'addon'                  => 'modules',
286
        'vendor'                 => 'include',
287
        'vendor\\jscalendar'     => 'include/jscalendar',
288
        'bin\\db'                => 'framework/db',
289
        'bin\\requester'         => 'framework',
290
        'bin\\requester\\filter' => 'framework',
291
        'bin\\security'          => 'framework',
292
        'bin\\interfaces'        => 'framework',
293
        'api'                    => 'framework/api',
292 294
    ]);
293 295

  
294 296
    // *** initialize Exception handling
......
319 321
    $aCfg = initReadSetupFile();
320 322
    initSetInstallWbConstants($aCfg);
321 323
// activate requester --------------------------------------------------------------------
322
    $oRequest = \bin\HttpRequester();
324
    $oRequest = new \bin\requester\HttpRequester();
323 325
// ---------------------------
324 326
// get Database connection data from configuration
325 327
    defined('ADMIN_DIRECTORY') ? '' : define('ADMIN_DIRECTORY', 'admin');
......
437 439
            $sLang = strtoupper($aMatches[1]);
438 440
            define('LANGUAGE', $slang);
439 441
            $_SESSION['LANGUAGE'] = $sLang;
442
//            // strtoupper() is deprecated and for backward compatibility only!
443
//            $sLang = strtoupper($oRequest->getParam('lang', FILTER_CALLBACK, [
444
//                new \bin\requester\filter\CoreFilters(['default'=>'en', 'seperator'=>'-']),
445
//                'FILTER_LANGUAGE_CODE'
446
//            ]));
447
//            define('LANGUAGE', $slang);
448
//            $_SESSION['LANGUAGE'] = $sLang;
440 449
        }
441 450
        $sCachePath = dirname(__DIR__).'/temp/cache/';
442 451
        if (!file_exists($sCachePath)) {

Also available in: Unified diff