@@ -239,7 +239,7 @@ private function securityScan($string) {
239239 }
240240 }
241241 }
242- if ($ ok == true ) {
242+ if ($ ok ) {
243243 return true ;
244244 } else {
245245 if ($ ids_config ['sql_scan_action ' ] == 'warn ' ) {
@@ -252,6 +252,8 @@ private function securityScan($string) {
252252 }
253253 }
254254 }
255+
256+ return true ;
255257 }
256258
257259 private function _query ($ sQuery = '' ) {
@@ -298,7 +300,9 @@ private function _query($sQuery = '') {
298300 } while ($ ok == false );
299301
300302 $ sQuery = call_user_func_array (array (&$ this , '_build_query_string ' ), $ aArgs );
301- $ this ->securityScan ($ sQuery );
303+ if (!$ this ->securityScan ($ sQuery )) {
304+ return false ;
305+ }
302306 $ this ->_iQueryId = mysqli_query ($ this ->_iConnId , $ sQuery );
303307 if (!$ this ->_iQueryId ) {
304308 $ this ->_sqlerror ('Falsche Anfrage / Wrong Query ' , 'SQL-Query = ' . $ sQuery );
@@ -590,6 +594,7 @@ public function unquote($formfield) {
590594 }
591595
592596 public function toLower ($ record ) {
597+ $ out = [];
593598 if (is_array ($ record )) {
594599 foreach ($ record as $ key => $ val ) {
595600 $ key = strtolower ($ key );
@@ -678,7 +683,7 @@ public function getDatabaseSize($database_name) {
678683 $ result = $ db ->_query ("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema=' " .$ db ->escape ($ database_name )."' " );
679684 if (!$ result ) {
680685 $ db ->_sqlerror ('Unable to determine the size of database ' . $ database_name );
681- return ;
686+ return 0 ;
682687 }
683688 $ database_size = $ result ->getAsRow ();
684689 $ result ->free ();
@@ -1075,7 +1080,7 @@ function tableInfo($table_name) {
10751080 }
10761081
10771082 public function mapType ($ metaType , $ typeValue ) {
1078- global $ go_api ;
1083+ global $ app ;
10791084 $ metaType = strtolower ($ metaType );
10801085 switch ($ metaType ) {
10811086 case 'int16 ' :
@@ -1107,6 +1112,8 @@ public function mapType($metaType, $typeValue) {
11071112 return 'date ' ;
11081113 break ;
11091114 }
1115+ $ app ->error ('Unknown meta type: ' .$ metaType );
1116+ return false ;
11101117 }
11111118
11121119 /**
@@ -1157,7 +1164,7 @@ public function getPasswordHash($password, $hash_type = 'mysql_native_password')
11571164 if ($ hash_type == 'caching_sha2_password ' ) {
11581165 $ password_hash = $ this ->mysqlSha256Crypt ($ password , $ this ->genSalt (20 ), 5000 );
11591166 } else {
1160- $ password_hash = '* ' . strtoupper (sha1 (sha1 ($ password , true )));
1167+ $ password_hash = '* ' . strtoupper (sha1 (sha1 ($ password , true )));
11611168 }
11621169
11631170 return $ password_hash ;
@@ -1168,18 +1175,17 @@ public function getPasswordHash($password, $hash_type = 'mysql_native_password')
11681175 *
11691176 * @return string
11701177 */
1171- private function genSalt ($ size )
1172- {
1178+ private function genSalt ($ size ) {
11731179 $ salt = random_bytes ($ size );
1174- if ($ salt === false ) {
1180+ if ($ salt === false ) {
11751181 throw new Exception ('Cannot generate salt. ' );
11761182 }
1177- for ($ i = 0 ; $ i < $ size ; $ i ++) {
1183+ for ($ i = 0 ; $ i < $ size ; $ i ++) {
11781184 $ ord = ord ($ salt [$ i ]) & 0x7f ;
1179- if ($ ord < 32 ) {
1185+ if ($ ord < 32 ) {
11801186 $ ord += 32 ;
11811187 }
1182- if ($ ord == 36 /* $ */ ) {
1188+ if ($ ord == 36 /* $ */ ) {
11831189 $ ord += 1 ;
11841190 }
11851191 $ salt [$ i ] = chr ($ ord );
@@ -1199,10 +1205,9 @@ private function genSalt($size)
11991205 *
12001206 * @return string hashed password in MySQL format
12011207 */
1202- private function mysqlSha256Crypt ($ plaintext , $ salt , $ rounds )
1203- {
1208+ private function mysqlSha256Crypt ($ plaintext , $ salt , $ rounds ) {
12041209 $ plaintext_len = strlen ($ plaintext );
1205- $ salt_len = strlen ($ salt );
1210+ $ salt_len = strlen ($ salt );
12061211
12071212 // 1
12081213 $ ctxA = hash_init ('sha256 ' );
@@ -1221,14 +1226,14 @@ private function mysqlSha256Crypt($plaintext, $salt, $rounds)
12211226 // 8
12221227 $ B = hash_final ($ ctxB , true );
12231228 // 9
1224- for ($ i = $ plaintext_len ; $ i > 32 ; $ i -= 32 ) {
1229+ for ($ i = $ plaintext_len ; $ i > 32 ; $ i -= 32 ) {
12251230 hash_update ($ ctxA , $ B );
12261231 }
12271232 // 10
12281233 hash_update ($ ctxA , substr ($ B , 0 , $ i ));
12291234 // 11
1230- for ($ i = $ plaintext_len ; $ i > 0 ; $ i >>= 1 ) {
1231- if (($ i & 1 ) != 0 ) {
1235+ for ($ i = $ plaintext_len ; $ i > 0 ; $ i >>= 1 ) {
1236+ if (($ i & 1 ) != 0 ) {
12321237 hash_update ($ ctxA , $ B );
12331238 } else {
12341239 hash_update ($ ctxA , $ plaintext );
@@ -1239,50 +1244,50 @@ private function mysqlSha256Crypt($plaintext, $salt, $rounds)
12391244 // 13
12401245 $ ctxDP = hash_init ('sha256 ' );
12411246 // 14
1242- for ($ i = 0 ; $ i < $ plaintext_len ; $ i ++) {
1247+ for ($ i = 0 ; $ i < $ plaintext_len ; $ i ++) {
12431248 hash_update ($ ctxDP , $ plaintext );
12441249 }
12451250 // 15
12461251 $ DP = hash_final ($ ctxDP , true );
12471252 // 16
12481253 $ P = "" ;
1249- for ($ i = $ plaintext_len ; $ i > 32 ; $ i -= 32 ) {
1254+ for ($ i = $ plaintext_len ; $ i > 32 ; $ i -= 32 ) {
12501255 $ P .= $ DP ;
12511256 }
12521257 $ P .= substr ($ DP , 0 , $ i );
12531258 // 17
12541259 $ ctxDS = hash_init ('sha256 ' );
12551260 // 18
1256- for ($ i = 0 ; $ i < 16 + ord ($ A [0 ]); $ i ++) {
1261+ for ($ i = 0 ; $ i < 16 + ord ($ A [0 ]); $ i ++) {
12571262 hash_update ($ ctxDS , $ salt );
12581263 }
12591264 // 19
12601265 $ DS = hash_final ($ ctxDS , true );
12611266 // 20
12621267 $ S = "" ;
1263- for ($ i = $ salt_len ; $ i >= 32 ; $ i -= 32 ) {
1268+ for ($ i = $ salt_len ; $ i >= 32 ; $ i -= 32 ) {
12641269 $ S .= $ DS ;
12651270 }
12661271 $ S .= substr ($ DS , 0 , $ i );
12671272 // 21
12681273 $ C = "" ;
1269- for ($ i = 0 ; $ i < $ rounds ; $ i ++) {
1274+ for ($ i = 0 ; $ i < $ rounds ; $ i ++) {
12701275 $ ctxC = hash_init ('sha256 ' );
1271- if (($ i & 1 ) != 0 ) {
1276+ if (($ i & 1 ) != 0 ) {
12721277 hash_update ($ ctxC , $ P );
12731278 } else {
12741279 hash_update ($ ctxC , $ i == 0 ? $ A : $ C );
12751280 }
12761281
1277- if ($ i % 3 != 0 ) {
1282+ if ($ i % 3 != 0 ) {
12781283 hash_update ($ ctxC , $ S );
12791284 }
12801285
1281- if ($ i % 7 != 0 ) {
1286+ if ($ i % 7 != 0 ) {
12821287 hash_update ($ ctxC , $ P );
12831288 }
12841289
1285- if (($ i & 1 ) != 0 ) {
1290+ if (($ i & 1 ) != 0 ) {
12861291 hash_update ($ ctxC , $ i == 0 ? $ A : $ C );
12871292 } else {
12881293 hash_update ($ ctxC , $ P );
@@ -1291,14 +1296,15 @@ private function mysqlSha256Crypt($plaintext, $salt, $rounds)
12911296 }
12921297
12931298 // 22
1294- $ b64result = str_repeat (' ' , 43 );
1295- $ p = 0 ;
1296- $ b64_from_24bit = function ($ B2 , $ B1 , $ B0 , $ N ) use (&$ b64result , &$ p ) {
1299+ $ b64result = str_repeat (' ' , 43 );
1300+ $ p = 0 ;
1301+ $ b64_from_24bit = function ($ B2 , $ B1 , $ B0 , $ N ) use (&$ b64result , &$ p ) {
1302+ $ b64_alphabet = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " ;
12971303 $ w = ($ B2 << 16 ) | ($ B1 << 8 ) | $ B0 ;
12981304 $ n = $ N ;
1299- while (--$ n >= 0 ) {
1300- $ b64result [$ p ++] = " ./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " [$ w & 0x3f ];
1301- $ w = $ w >> 6 ;
1305+ while (--$ n >= 0 ) {
1306+ $ b64result [$ p ++] = $ b64_alphabet [$ w & 0x3f ];
1307+ $ w = $ w >> 6 ;
13021308 }
13031309 };
13041310 $ b64_from_24bit (ord ($ C [0 ]), ord ($ C [10 ]), ord ($ C [20 ]), 4 );
@@ -1329,10 +1335,11 @@ class db_result {
13291335
13301336 /**
13311337 *
1332- *
1338+ * @var mysqli_result|null
13331339 * @access private
13341340 */
13351341 private $ _iResId = null ;
1342+ /** @var mysqli|null */
13361343 private $ _iConnection = null ;
13371344
13381345
@@ -1544,7 +1551,7 @@ public function getAsRow() {
15441551 *
15451552 * @access public
15461553 * @param int $iStart offset to start read
1547- * @param int iLength amount of datasets to read
1554+ * @param int $ iLength amount of datasets to read
15481555 */
15491556 public function limit_result ($ iStart , $ iLength ) {
15501557 $ this ->aLimitedData = array_slice ($ this ->aResultData , $ iStart , $ iLength , true );
0 commit comments