From: Banana Date: Mon, 2 Jan 2023 12:25:11 +0000 (+0100) Subject: php 8.1 stuff X-Git-Tag: 1.1~19 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=07b8fc58212cbe9b5fe8bfb996681da0f4e3c711;p=scientia.git php 8.1 stuff --- diff --git a/CHANGELOG b/CHANGELOG index 7204f1c..08f75ed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 1.x Atlas - + i18n. See upgrade-from-1.0.txt for more details. + + PHP 8.1 stuff 1.0 Lykos - 2022-11-12 diff --git a/webroot/api.php b/webroot/api.php index 0594a27..ac7ff84 100644 --- a/webroot/api.php +++ b/webroot/api.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2022 Johannes Keßler + * Copyright 2023 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -20,7 +20,7 @@ mb_internal_encoding('UTF-8'); ini_set('error_reporting',-1); // E_ALL & E_STRICT ## check request -$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); +$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW); if(!empty($_urlToParse)) { # see http://de2.php.net/manual/en/regexp.reference.unicode.php if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) { @@ -61,12 +61,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE'] === 'appli && isset(UPLOAD_SECRET[$payload['asl']]) ) { if(DEBUG) error_log("[DEBUG] Valid payload so far"); - if(!empty($payload['data'])) { - $filteredData = filter_var($payload['data'],FILTER_SANITIZE_FULL_SPECIAL_CHARS); - if(!empty($filteredData)) { - if(DEBUG) error_log("[DEBUG] Validated payload"); - $_create = true; - } + $filteredData = filter_var($payload['data'],FILTER_SANITIZE_FULL_SPECIAL_CHARS); + if(!empty($filteredData)) { + if(DEBUG) error_log("[DEBUG] Validated payload"); + $_create = true; } } } @@ -89,9 +87,6 @@ if($_create === false) { exit(); } -# database object -$DB = false; - ## DB connection $DB = new mysqli(DB_HOST, DB_USERNAME,DB_PASSWORD, DB_NAME); if ($DB->connect_errno) exit('Can not connect to MySQL Server'); @@ -103,7 +98,7 @@ $driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; require_once 'lib/entry.class.php'; $Entry = new Entry($DB); $do = $Entry->create($filteredData); -if($do !== false) { +if(!empty($do)) { $contentBody['message'] = date('/Y/m/d/').$do; } else { @@ -118,3 +113,4 @@ header('X-PROVIDED-BY: scientia'); header($contentType); http_response_code($httpResponseCode); echo json_encode($contentBody); +$DB->close(); diff --git a/webroot/index.php b/webroot/index.php index 2409bf7..97d81eb 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2022 Johannes Keßler + * Copyright 2023 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -53,9 +53,6 @@ Summoner::simpleAuth(); # i18n $i18n = new I18n(); -# database object -$DB = false; - ## DB connection $DB = new mysqli(DB_HOST, DB_USERNAME,DB_PASSWORD, DB_NAME); if ($DB->connect_errno) exit('Can not connect to MySQL Server'); @@ -69,7 +66,7 @@ $_view = 'list'; $_year = date('Y'); $_month = date('m'); $_day = date('d'); -$_id = false; +$_id = ''; $_requestDateProvided = ''; $TemplateData = array(); diff --git a/webroot/lib/i18n.class.php b/webroot/lib/i18n.class.php index 6ded228..1bebd80 100644 --- a/webroot/lib/i18n.class.php +++ b/webroot/lib/i18n.class.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2022 Johannes Keßler + * Copyright 2023 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -19,12 +19,12 @@ class I18n { /** * @var string The lang code */ - private $_defaultLangToUse = 'en'; + private string $_defaultLangToUse = 'en'; /** * @var array The loaded lang information from the file */ - private $_langData = array(); + private array $_langData = array(); /** * i18n constructor. @@ -61,4 +61,4 @@ class I18n { } return $ret; } -} \ No newline at end of file +} diff --git a/webroot/lib/summoner.class.php b/webroot/lib/summoner.class.php index 34bd8a0..4ee5b87 100644 --- a/webroot/lib/summoner.class.php +++ b/webroot/lib/summoner.class.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2022 Johannes Keßler + * Copyright 2023 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -174,10 +174,10 @@ class Summoner { * Decode a base64-encoded big-endian integer of up to 64 bits. * * @see https://www.jwz.org/base64-shortlinks/ - * @param int $id - * @return false|int|string|string[] + * @param string $id + * @return int */ - static function b64sl_unpack_id(int $id) { + static function b64sl_unpack_id(string $id): int { $id = str_replace ('-', '+', $id); // decode URL-unsafe "+" "/" $id = str_replace ('_', '/', $id); $id = base64_decode ($id); @@ -198,7 +198,7 @@ class Summoner { * @param $key string * @return mixed */ - static function ifset(array $array, string $key) { + static function ifset(array $array, string $key): mixed { return isset($array[$key]) ? $array[$key] : false; } @@ -206,7 +206,7 @@ class Summoner { * a very simple HTTP_AUTH authentication. * Needs FRONTEND_USERNAME and FRONTEND_PASSWORD defined */ - static function simpleAuth() { + static function simpleAuth(): void { if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] !== FRONTEND_USERNAME || $_SERVER['PHP_AUTH_PW'] !== FRONTEND_PASSWORD ) { diff --git a/webroot/view/_head.php b/webroot/view/_head.php index 0d50458..918a5a4 100644 --- a/webroot/view/_head.php +++ b/webroot/view/_head.php @@ -2,7 +2,7 @@ -