Revision 30
Added by Manuela almost 7 years ago
branches/main/admin/interface/version.php | ||
---|---|---|
43 | 43 |
/* -------------------------------------------------------- */ |
44 | 44 |
if (!defined('VERSION_LOADED')) { |
45 | 45 |
$sInfo = ' |
46 |
VERSION = "2.10.1-dev"
|
|
47 |
REVISION = "29"
|
|
46 |
VERSION = "2.11.0-RC1"
|
|
47 |
REVISION = "30"
|
|
48 | 48 |
SP = "" |
49 | 49 |
'; |
50 | 50 |
foreach (parse_ini_string($sInfo) as $item=>$value) { |
branches/main/framework/HttpRequester.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
* Copyright (C) 2017 Manuela v.d.Decken <manuela@isteam.de> |
|
5 |
* |
|
6 |
* DO NOT ALTER OR REMOVE COPYRIGHT OR THIS HEADER |
|
7 |
* |
|
8 |
* This program is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, version 2 of the License. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License 2 for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License 2 |
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
*/ |
|
20 |
/** |
|
21 |
* Description of HttpRequester |
|
22 |
* |
|
23 |
* @package Core package |
|
24 |
* @copyright Manuela v.d.Decken <manuela@isteam.de> |
|
25 |
* @author Manuela v.d.Decken <manuela@isteam.de> |
|
26 |
* @license GNU General Public License 2.0 |
|
27 |
* @version 0.0.1 |
|
28 |
* @revision $Id$ |
|
29 |
* @since File available since 04.10.2017 |
|
30 |
* @deprecated no / since 0000/00/00 |
|
31 |
* @description xxx |
|
32 |
*/ |
|
33 |
//declare(strict_types = 1); |
|
34 |
//declare(encoding = 'UTF-8'); |
|
35 |
|
|
36 |
namespace bin; |
|
37 |
|
|
38 |
use bin\interfaces\RequesterInterface; |
|
39 |
|
|
40 |
/** |
|
41 |
* short description of class |
|
42 |
*/ |
|
43 |
class HttpRequester implements RequesterInterface |
|
44 |
{ |
|
45 |
private $aParameters = []; |
|
46 |
private $aServer = []; |
|
47 |
private $aHeaders = []; |
|
48 |
/** |
|
49 |
* construct and initialize the class |
|
50 |
*/ |
|
51 |
public function __construct() |
|
52 |
{ |
|
53 |
// $this->aServer = \filter_input_array(INPUT_SERVER); |
|
54 |
$aServer = \filter_input_array(INPUT_SERVER); |
|
55 |
switch (\strtolower($aServer['REQUEST_METHOD'])): |
|
56 |
case 'post': |
|
57 |
$this->aParameters = \filter_input_array(INPUT_POST); |
|
58 |
break; |
|
59 |
case 'get': |
|
60 |
$this->aParameters = \filter_input_array(INPUT_GET); |
|
61 |
break; |
|
62 |
default: |
|
63 |
$this->aParameters = []; |
|
64 |
break; |
|
65 |
endswitch; |
|
66 |
foreach ($aServer as $sKey => $sValue) { |
|
67 |
if (substr_compare($sKey, 'HTTP_', 0, 5) === 0) { |
|
68 |
$this->aHeaders[$sKey] = $sValue; |
|
69 |
} else { |
|
70 |
$this->aServer[$sKey] = $sValue; |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
74 |
/** |
|
75 |
* returns a list of all parameters |
|
76 |
* @return array |
|
77 |
*/ |
|
78 |
public function getParamNames() |
|
79 |
{ |
|
80 |
return \array_keys($this->aParameters); |
|
81 |
} |
|
82 |
/** |
|
83 |
* check if parameter exists |
|
84 |
* @param string $sParamName |
|
85 |
* @return bool |
|
86 |
*/ |
|
87 |
public function issetParam($sParamName) |
|
88 |
{ |
|
89 |
return \array_key_exists($sParamName, $this->aParameters); |
|
90 |
} |
|
91 |
/** |
|
92 |
* read a variable from commandline |
|
93 |
* @param string $sParamName |
|
94 |
* @param int $iFilterType |
|
95 |
* @param mixed $mOptions |
|
96 |
* @return mixed | null on error |
|
97 |
* @throws \InvalidArgumentException |
|
98 |
* @description the method is 100% compatible to the PHP function filter_var() |
|
99 |
*/ |
|
100 |
public function getParam($sParamName, $iFilterType = null, $mOptions = null) |
|
101 |
{ |
|
102 |
$mRetval = null; |
|
103 |
try { |
|
104 |
if (!$this->issetParam($sParamName)) { throw new \Exception('error on getParam()'); } |
|
105 |
$mRetval = $this->aParameters[$sParamName]; |
|
106 |
if (!\is_null($iFilterType)) { |
|
107 |
if (!\is_null($mOptions)) { |
|
108 |
$mRetval = \filter_var($mRetval, $iFilterType, $mOptions); |
|
109 |
} else { |
|
110 |
$mRetval = \filter_var($mRetval, $iFilterType); |
|
111 |
} |
|
112 |
} |
|
113 |
} catch (\Exception $ex) { |
|
114 |
$mRetval = null; |
|
115 |
// throw new \InvalidArgumentException('error on getParam()', $ex->getCode(), $ex); |
|
116 |
} |
|
117 |
return $mRetval; |
|
118 |
} |
|
119 |
/** |
|
120 |
* |
|
121 |
* @param string $sHeaderName |
|
122 |
* @return mixed | null on error |
|
123 |
*/ |
|
124 |
public function issetHeader($sHeaderName) |
|
125 |
{ |
|
126 |
$sVarname = 'HTTP_'.preg_replace('/^http_/i', '', $sHeaderName); |
|
127 |
return \array_key_exists($sVarname, $this->aHeaders); |
|
128 |
} |
|
129 |
/** |
|
130 |
* get header vars ($_SERVER['HTTP_'*]) |
|
131 |
* @param string $sHeaderName |
|
132 |
* @return mixed | null on error |
|
133 |
*/ |
|
134 |
public function getHeader($sHeaderName) |
|
135 |
{ |
|
136 |
$sRetval = null; |
|
137 |
$sVarname = 'HTTP_'.preg_replace('/^http_/i', '', $sHeaderName); |
|
138 |
if ($this->issetHeader($sVarname)) { |
|
139 |
$sRetval = $this->aHeaders($sVarname); |
|
140 |
} |
|
141 |
return $sRetval; |
|
142 |
} |
|
143 |
/** |
|
144 |
* |
|
145 |
* @param string $sVarName |
|
146 |
* @return type |
|
147 |
*/ |
|
148 |
public function issetServerVar($sVarName) |
|
149 |
{ |
|
150 |
return \array_key_exists($sVarName, $this->aServer); |
|
151 |
} |
|
152 |
/** |
|
153 |
* get server vars excluding $_SERVER['HTTP_'*] |
|
154 |
* @param string $sVarName |
|
155 |
* @return mixed | null on error |
|
156 |
*/ |
|
157 |
public function getServerVar($sVarName) |
|
158 |
{ |
|
159 |
$sRetval = null; |
|
160 |
if ($this->issetHeader($sVarName)) { |
|
161 |
$sRetval = $this->aHeaders($sVarName); |
|
162 |
} |
|
163 |
return $sRetval; |
|
164 |
} |
|
165 |
|
|
166 |
} |
|
0 | 167 |
branches/main/framework/RequesterInterface.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/* |
|
4 |
* Copyright (C) 2017 Manuela v.d.Decken <manuela@isteam.de> |
|
5 |
* |
|
6 |
* DO NOT ALTER OR REMOVE COPYRIGHT OR THIS HEADER |
|
7 |
* |
|
8 |
* This program is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, version 2 of the License. |
|
11 |
* |
|
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
* GNU General Public License 2 for more details. |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License 2 |
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19 |
*/ |
|
20 |
/** |
|
21 |
* Description of RequesterInterface |
|
22 |
* |
|
23 |
* @package Core package |
|
24 |
* @copyright Manuela v.d.Decken <manuela@isteam.de> |
|
25 |
* @author Manuela v.d.Decken <manuela@isteam.de> |
|
26 |
* @license GNU General Public License 2.0 |
|
27 |
* @version 0.0.1 |
|
28 |
* @revision $Id$ |
|
29 |
* @since File available since 04.10.2017 |
|
30 |
* @deprecated no / since 0000/00/00 |
|
31 |
* @description xxx |
|
32 |
*/ |
|
33 |
//declare(strict_types = 1); |
|
34 |
//declare(encoding = 'UTF-8'); |
|
35 |
|
|
36 |
namespace bin\interfaces; |
|
37 |
|
|
38 |
// use |
|
39 |
|
|
40 |
/** |
|
41 |
* short description of interface |
|
42 |
*/ |
|
43 |
interface RequesterInterface |
|
44 |
{ |
|
45 |
public function getParamNames(); |
|
46 |
public function issetParam($sName); |
|
47 |
public function getParam($sName, $iFilterType = null, $mOptions = null); |
|
48 |
public function getHeader($sName); |
|
49 |
} |
|
0 | 50 |
branches/main/framework/initialize.php | ||
---|---|---|
205 | 205 |
} |
206 | 206 |
} |
207 | 207 |
|
208 |
/** |
|
209 |
* WbErrorHandler() |
|
210 |
* |
|
211 |
* @param mixed $iErrorCode |
|
212 |
* @param mixed $sErrorText |
|
213 |
* @param mixed $sErrorFile |
|
214 |
* @param mixed $iErrorLine |
|
215 |
* @return |
|
216 |
*/ |
|
217 | 208 |
function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine) |
218 | 209 |
{ |
219 | 210 |
if (!(error_reporting() & $iErrorCode) || ini_get('log_errors') == 0) { |
... | ... | |
289 | 280 |
} |
290 | 281 |
\bin\CoreAutoloader::doRegister(dirname(__DIR__)); |
291 | 282 |
\bin\CoreAutoloader::addNamespace([ // add several needed namespaces |
283 |
// Namespace Directory |
|
292 | 284 |
'bin' => 'framework', |
293 | 285 |
'addon' => 'modules', |
294 | 286 |
'vendor' => 'include', |
... | ... | |
296 | 288 |
'bin\\db' => 'framework/db', |
297 | 289 |
'bin\\security' => 'framework', |
298 | 290 |
'bin\\interfaces' => 'framework', |
291 |
'api' => 'framework/api', |
|
299 | 292 |
]); |
300 | 293 |
|
301 | 294 |
// *** initialize Exception handling |
... | ... | |
319 | 312 |
ini_set('log_errors', 1); |
320 | 313 |
ini_set ('error_log', $sErrorLogFile); |
321 | 314 |
|
322 |
// activate errorhandler *****************************************************************
|
|
315 |
// activate errorhandler -----------------------------------------------------------------
|
|
323 | 316 |
set_error_handler('WbErrorHandler', -1 ); |
324 | 317 |
defined('SYSTEM_RUN') ? '' : define('SYSTEM_RUN', true); |
325 | 318 |
// load configuration --- |
326 | 319 |
$aCfg = initReadSetupFile(); |
327 | 320 |
initSetInstallWbConstants($aCfg); |
321 |
// activate requester -------------------------------------------------------------------- |
|
322 |
$oRequest = \bin\HttpRequester(); |
|
328 | 323 |
// --------------------------- |
329 | 324 |
// get Database connection data from configuration |
330 | 325 |
defined('ADMIN_DIRECTORY') ? '' : define('ADMIN_DIRECTORY', 'admin'); |
331 | 326 |
if ( |
332 |
!(preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY) &&
|
|
333 |
is_dir(dirname(__DIR__).'/'.ADMIN_DIRECTORY))
|
|
327 |
!preg_match('/xx[a-z_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY) ||
|
|
328 |
!is_dir(dirname(__DIR__).'/'.ADMIN_DIRECTORY)
|
|
334 | 329 |
) { |
335 | 330 |
throw new RuntimeException('Invalid admin-directory set: ' . ADMIN_DIRECTORY); |
336 | 331 |
} |
... | ... | |
395 | 390 |
if (!$x) { |
396 | 391 |
throw new RuntimeException('no settings found'); |
397 | 392 |
} |
398 |
defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
|
|
399 |
ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ?'1':'0'));
|
|
393 |
defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', ($oRequest->issetHeader('DNT')));
|
|
394 |
ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ? '1' : '0'));
|
|
400 | 395 |
|
401 | 396 |
defined('DEBUG') ? '' : define('DEBUG', false); |
402 | 397 |
$string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644'; |
403 | 398 |
defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode)); |
404 | 399 |
$string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755'; |
405 | 400 |
defined('OCTAL_DIR_MODE') ? '' : define('OCTAL_DIR_MODE', (int) octdec($string_dir_mode)); |
406 |
// $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : ''; |
|
407 |
// $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php'; |
|
408 |
// require_once($sSecMod); |
|
409 |
if (!defined('WB_INSTALL_PROCESS')) { |
|
401 |
if (!defined('WB_INSTALL_PROCESS') && !defined('WB_UPGRADE_PROCESS')) { |
|
410 | 402 |
// get CAPTCHA and ASP settings |
411 | 403 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`'; |
412 | 404 |
if (($get_settings = $database->query($sql)) && |
... | ... | |
422 | 414 |
throw new RuntimeException('CAPTCHA-Settings not found'); |
423 | 415 |
} |
424 | 416 |
} |
425 |
|
|
426 | 417 |
// Start a session |
427 | 418 |
if (!defined('SESSION_STARTED')) { |
428 | 419 |
session_name(APP_NAME.'-sid'); |
... | ... | |
434 | 425 |
} |
435 | 426 |
// Get users language |
436 | 427 |
if ( |
437 |
isset($_GET['lang']) AND |
|
438 |
$_GET['lang'] != '' AND |
|
439 |
!is_numeric($_GET['lang']) AND |
|
440 |
strlen($_GET['lang']) == 2 |
|
428 |
($sLang = $oRequest->issetParam('lang')) == null || |
|
429 |
!preg_match('/^([a-z]{2})(?:[\-_]([a-z]{2})(?:[\-_]([a-z\-_]{2,8}))?)?$/i', $sLang, $aMatches) |
|
441 | 430 |
) { |
442 |
define('LANGUAGE', strtoupper($_GET['lang'])); |
|
443 |
$_SESSION['LANGUAGE']=LANGUAGE; |
|
444 |
} else { |
|
445 | 431 |
if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') { |
446 | 432 |
define('LANGUAGE', $_SESSION['LANGUAGE']); |
447 | 433 |
} else { |
448 | 434 |
define('LANGUAGE', DEFAULT_LANGUAGE); |
449 | 435 |
} |
436 |
} else { |
|
437 |
$sLang = strtoupper($aMatches[1]); |
|
438 |
define('LANGUAGE', $slang); |
|
439 |
$_SESSION['LANGUAGE'] = $sLang; |
|
450 | 440 |
} |
451 | 441 |
$sCachePath = dirname(__DIR__).'/temp/cache/'; |
452 | 442 |
if (!file_exists($sCachePath)) { |
... | ... | |
472 | 462 |
require $slangFile; |
473 | 463 |
} |
474 | 464 |
} |
465 |
// activate Translate -------------------------------------------------------------------- |
|
475 | 466 |
$oTrans = Translate::getInstance(); |
476 | 467 |
$oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none' |
468 |
// activate SecureTokens ----------------------------------------------------------------- |
|
469 |
$oApp = (object) [ |
|
470 |
'oRequester' => $oRequest, |
|
471 |
'oRegistry' => (object) [ |
|
472 |
'SecTokenFingerprint' => (bool) SEC_TOKEN_FINGERPRINT, |
|
473 |
'SecTokenNetmask4' => SEC_TOKEN_NETMASK4, |
|
474 |
'SecTokenNetmask6' => SEC_TOKEN_NETMASK6, |
|
475 |
'SecTokenLifeTime' => SEC_TOKEN_LIFE_TIME |
|
476 |
] |
|
477 |
]; |
|
478 |
\bin\SecureTokens::getInstance($oApp); |
|
479 |
\bin\SecureTokens::checkFTAN(); |
|
480 |
// --------------------------------------------------------------------------------------- |
|
477 | 481 |
// Get users timezone |
478 | 482 |
if (isset($_SESSION['TIMEZONE'])) { |
479 | 483 |
define('TIMEZONE', $_SESSION['TIMEZONE']); |
Also available in: Unified diff
updatet version to 2.11.0-RC1
added first version of HttpRequester