From 57e7b99e0ac3bd1f6594a2d1f2f1e7dc9109f87e Mon Sep 17 00:00:00 2001 From: Banana Date: Mon, 3 Oct 2022 11:13:27 +0200 Subject: [PATCH] some more php 8 syntax and cleanup --- CHANGELOG | 3 +- documentation/requirements.txt | 2 +- documentation/setup/bibliotheca.sql | 2 +- documentation/setup/install.txt | 10 ++--- webclient/api.php | 4 +- webclient/config/config-imdbweb.php.default | 28 ++++++------- .../config/config-musicbrainz.php.default | 14 +++---- webclient/config/config.php.default | 42 +++++++++---------- webclient/index.php | 6 +-- webclient/lib/gorenest.class.php | 2 +- .../lib/managecollectionfields.class.php | 4 +- webclient/lib/managecollections.class.php | 2 +- webclient/lib/manageentry.class.php | 16 +++---- webclient/lib/managetags.class.php | 10 ++--- webclient/lib/musicbrainz.class.php | 19 +++++---- webclient/lib/possessed.class.php | 13 +++--- webclient/lib/spectre.class.php | 8 ++-- webclient/lib/summoner.class.php | 3 +- webclient/lib/tentacle.class.php | 6 +-- webclient/lib/trite.class.php | 31 +++++++------- webclient/setup/index.php | 4 +- 21 files changed, 116 insertions(+), 113 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1c929dd..1ac0549 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,8 @@ * New field: artists - lookupmultiple field * Added setup process. See setup/install.txt for more details * Stats info page - * Some more PHP 7/8 syntax and support + * Some more PHP 8 syntax and support + * Needs PHP 8 as of this version 1.2 - NyLeve's Falls 20210717 * Updated requirements information diff --git a/documentation/requirements.txt b/documentation/requirements.txt index eff02e7..184a6ba 100644 --- a/documentation/requirements.txt +++ b/documentation/requirements.txt @@ -1,5 +1,5 @@ * A Webserver (tested on Apache 2.4) -* PHP 7+ with mysqli, mbstring, curl +* PHP 8+ with mysqli, mbstring, curl * MySQL 8+; MariaDB 10.2/MySQL 8 -- User with full rights on the Database. Including lock tables * At least 20MB webserver storage WITHOUT images diff --git a/documentation/setup/bibliotheca.sql b/documentation/setup/bibliotheca.sql index fa1241d..165a031 100644 --- a/documentation/setup/bibliotheca.sql +++ b/documentation/setup/bibliotheca.sql @@ -145,7 +145,7 @@ CREATE TABLE `#REPLACEME#_sys_fields` ( LOCK TABLES `#REPLACEME#_sys_fields` WRITE; /*!40000 ALTER TABLE `#REPLACEME#_sys_fields` DISABLE KEYS */; -INSERT INTO `#REPLACEME#_sys_fields` VALUES (1,'title','Title','text','entryText','`title` varchar(128) NOT NULL, ADD FULLTEXT (`title`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(2,'description','Description','text3','entryText','`description` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`description`)','',NULL,'string 255','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(3,'content','Main content','textarea','entryText','`content` text NULL DEFAULT NULL, ADD FULLTEXT (`content`)','',NULL,'mysql text','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(5,'tag','Tag','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(6,'category','Category','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(7,'publisher','Publisher','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(8,'developer','Developer','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(9,'platform','Platform','selection','entrySingleText','`platform` varchar(32) NULL DEFAULT NULL','','Nintendo,Nintendo Switch,PC,Playstation,Playstation 2,Playstation 3,Playstation 4,Playstation 5,Xbox,Xbox 360,Xbox One,Xbox One S,Xbox One X,Xbox Series S,Xbox Series X','One of Nintendo,Nintendo Switch,PC,Playstation,Playstation 2,Playstation 3,Playstation 4,Playstation 5,Xbox,Xbox 360,Xbox One,Xbox One S,Xbox One X,Xbox Series S,Xbox Series X','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(10,'storage','Storage','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(13,'rating','Rating','selection','entrySingleText','`rating` varchar(16) NULL DEFAULT NULL','','0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10','One of 0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(14,'year','Year','year','entrySingleNum','`year` int(10) NULL, ADD INDEX (`year`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(15,'coverimage','Cover image','upload',NULL,NULL,'',NULL,'One file in $_FILES[uploads] of post','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(16,'attachment','Attachments','upload_multiple',NULL,NULL,'',NULL,'Multiple in $_FILES[uploads] of post','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(17,'os','Operating system and version','selection','entrySingleNum','`os` varchar(32) NULL DEFAULT NULL','','DOS,Windows 1,Windows 2,Windows 3,Windows 95,Windows 99,Windows XP,Windows 2000,Windows ME,Windows Vista,Windows 8,Windows 10','One of DOS,Windows 1,Windows 2,Windows 3,Windows 95,Windows 99,Windows XP,Windows 2000,Windows ME,Windows Vista,Windows 8,Windows 10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(18,'actors','Actors','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(19,'countries','Countries','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(20,'directors','Directors','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(21,'genres','Genres','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(22,'languages','Languages','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(23,'runtime','Runtime (min)','number','entrySingleNum','`runtime` int(10) NULL, ADD INDEX (`runtime`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(24,'imdbrating','IMDB Rating','text','entrySingleText','`imdbrating` varchar(128) NULL DEFAULT NULL','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(25,'viewcount','View counter','number','entrySingleNum','`viewcount` int(10) NULL, ADD INDEX (`viewcount`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(26,'writers','Writers','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(27,'localizedTitle','localized Title','text','entryText','`localizedTitle` varchar(128) NULL DEFAULT NULL, ADD FULLTEXT (`localizedTitle`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(28,'gameEngine','Game Engine','text','entryText','`gameEngine` varchar(128) NOT NULL, ADD FULLTEXT (`gameEngine`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(29,'view','View','selection','entrySingleNum','`view` varchar(32) NULL DEFAULT NULL','','First person,Third person,Top-down','First person,Third person,Top-down','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(30,'sysReq','System Requirements','text3','entryText','`sysReq` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`sysReq`)','',NULL,'string 255','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(31,'artist','Artist','text','entrySingleText','`artist` varchar(128) NULL DEFAULT NULL','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(32,'artists','Artists','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'); +INSERT INTO `#REPLACEME#_sys_fields` VALUES (1,'title','Title','text','entryText','`title` varchar(128) NOT NULL, ADD FULLTEXT (`title`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(2,'description','Description','text3','entryText','`description` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`description`)','',NULL,'string 255','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(3,'content','Main content','textarea','entryText','`content` text NULL DEFAULT NULL, ADD FULLTEXT (`content`)','',NULL,'mysql text','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(5,'tag','Tag','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(6,'category','Category','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(7,'publisher','Publisher','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(8,'developer','Developer','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(9,'platform','Platform','selection','entrySingleText','`platform` varchar(32) NULL DEFAULT NULL','','Nintendo,Nintendo Switch,PC,Playstation,Playstation 2,Playstation 3,Playstation 4,Playstation 5,Xbox,Xbox 360,Xbox One,Xbox One S,Xbox One X,Xbox Series S,Xbox Series X','One of Nintendo,Nintendo Switch,PC,Playstation,Playstation 2,Playstation 3,Playstation 4,Playstation 5,Xbox,Xbox 360,Xbox One,Xbox One S,Xbox One X,Xbox Series S,Xbox Series X','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(10,'storage','Storage','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(13,'rating','Rating','selection','entrySingleText','`rating` varchar(16) NULL DEFAULT NULL','','0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10','One of 0/10,2/10,3/10,4/10,5/10,6/10,7/10,8/10,9/10,10/10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(14,'year','Year','year','entrySingleNum','`year` int(10) NULL, ADD INDEX (`year`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(15,'coverimage','Cover image','upload',NULL,NULL,'',NULL,'One file in $_FILES[uploads] of post','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(16,'attachment','Attachments','upload_multiple',NULL,NULL,'',NULL,'Multiple in $_FILES[uploads] of post','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(17,'os','Operating system and version','selection','entrySingleNum','`os` varchar(32) NULL DEFAULT NULL','','DOS,Windows 1,Windows 2,Windows 3,Windows 95,Windows 99,Windows XP,Windows 2000,Windows ME,Windows Vista,Windows 7,Windows 8,Windows 10, Windows 11','One of DOS,Windows 1,Windows 2,Windows 3,Windows 95,Windows 99,Windows XP,Windows 2000,Windows ME,Windows Vista,Windows 7 Windows 8,Windows 10, Windows 11','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(18,'actors','Actors','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(19,'countries','Countries','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(20,'directors','Directors','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(21,'genres','Genres','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(22,'languages','Languages','lookupmultiple','tag',NULL,'',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(23,'runtime','Runtime (min)','number','entrySingleNum','`runtime` int(10) NULL, ADD INDEX (`runtime`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(24,'imdbrating','IMDB Rating','text','entrySingleText','`imdbrating` varchar(128) NULL DEFAULT NULL','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(25,'viewcount','View counter','number','entrySingleNum','`viewcount` int(10) NULL, ADD INDEX (`viewcount`)','',NULL,'int 10','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(26,'writers','Writers','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(27,'localizedTitle','localized Title','text','entryText','`localizedTitle` varchar(128) NULL DEFAULT NULL, ADD FULLTEXT (`localizedTitle`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(28,'gameEngine','Game Engine','text','entryText','`gameEngine` varchar(128) NOT NULL, ADD FULLTEXT (`gameEngine`)','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(29,'view','View','selection','entrySingleNum','`view` varchar(32) NULL DEFAULT NULL','','First person,Third person,Top-down','First person,Third person,Top-down','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(30,'sysReq','System Requirements','text3','entryText','`sysReq` varchar(255) NULL DEFAULT NULL, ADD FULLTEXT (`sysReq`)','',NULL,'string 255','2021-08-08 10:52:44','2021-08-08 10:52:44',0,1,1,'rw-r--r--'),(31,'artist','Artist','text','entrySingleText','`artist` varchar(128) NULL DEFAULT NULL','',NULL,'string 128','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'),(32,'artists','Artists','lookupmultiple','tag',NULL,'allowSpace',NULL,'string 64','2021-08-08 10:52:44','2021-08-08 10:52:44',NULL,1,1,'rw-r--r--'); /*!40000 ALTER TABLE `#REPLACEME#_sys_fields` ENABLE KEYS */; UNLOCK TABLES; diff --git a/documentation/setup/install.txt b/documentation/setup/install.txt index e1be19b..d67b3a3 100644 --- a/documentation/setup/install.txt +++ b/documentation/setup/install.txt @@ -4,18 +4,18 @@ unpacked files 2. DB Setup Create a DB and choose a prefix (A _ is added automatically as separation) for your tables. -Write down those values. You need them later +Write down those values. You need them later. 3. Move files Move the content of webclient folder to your webspace. 4. File rights -Make sure that systemout folder is read/write accessible with your webserver user. Recursive. -Make sure that storage folder is read/write accessible with your webserver user. Recursive. +Make sure that systemout folder is read/write accessible for your webserver user. Recursive. +Make sure that storage folder is read/write accessible for your webserver user. Recursive. 5. Setup Open your browser and visit your newly created bibliotheca installation setup with /setup -Follow the instructions and remember your settings from step 2 +Follow the instructions and remember your settings from step 2. After completion the setup will delete itself. Remove the /setup from the url and you are done. 5. Access @@ -28,4 +28,4 @@ Create your own user. Create your first collection. To re run the setup: -Upload the setup folder again. It deletes itself after a successfull setup +Upload the setup folder again. It deletes itself after a successfull setup. diff --git a/webclient/api.php b/webclient/api.php index 6e2cbbc..f39ef22 100644 --- a/webclient/api.php +++ b/webclient/api.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,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) { diff --git a/webclient/config/config-imdbweb.php.default b/webclient/config/config-imdbweb.php.default index 03247d8..262481a 100644 --- a/webclient/config/config-imdbweb.php.default +++ b/webclient/config/config-imdbweb.php.default @@ -19,7 +19,7 @@ /** * Options for the imdb grabber * - * TOOL_IMDBWEB_SEARCH can be 'movie','tv','episode','game','all'. Default is movie + * TOOL_IMDBWEB_SEARCH can be 'movie = 'tv = 'episode = 'game = 'all'. Default is movie * TOOL_IMDBWEB_FIELDS is an array to define which fields from IMDB are displayed for selection * an empty array() shows all. * getAka, getAkas, getAspectRatio, getAwards, getBudget, getCast, getCastAndCharacter, CastAndCharacterAsUrl, @@ -35,23 +35,23 @@ * TOOL_IMDBWEB_BROWSERSTRING a current browser agent string. Should be updated from time to time. See default config file. * TOOL_IMDBWEB_BROWSER_ACCEPT_LANG should define in which language the content returns */ -define('TOOL_IMDBWEB_SEARCH','movie'); -define('TOOL_IMDBWEB_FIELDS', +const = TOOL_IMDBWEB_SEARCH = 'movie'; +const = TOOL_IMDBWEB_FIELDS = array( - 'getCast','getDescription', 'getDirector', 'getGenre', 'getPlot', 'getRating', 'getRuntime','getTitle', - 'getWriter', 'getYear' + 'getCast = 'getDescription = 'getDirector = 'getGenre = 'getPlot = 'getRating = 'getRuntime = 'getTitle = + 'getWriter = 'getYear' ) -); +; /* -define('TOOL_IMDBWEB_FIELDS_TO', +const = TOOL_IMDBWEB_FIELDS_TO = array( - 'getCast' => 'actors','getDescription' => 'description', 'getDirector' => 'directors', 'getGenre' => 'genres', - 'getPlot' => 'content', 'getRating' => 'imdbrating', 'getRuntime' => 'runtime','getTitle' => 'title', - 'getWriter' => 'writers', 'getYear' => 'year' + 'getCast' => 'actors = 'getDescription' => 'description = 'getDirector' => 'directors = 'getGenre' => 'genres = + 'getPlot' => 'content = 'getRating' => 'imdbrating = 'getRuntime' => 'runtime = 'getTitle' => 'title = + 'getWriter' => 'writers = 'getYear' => 'year' ) -); +; */ -define('TOOL_IMDBWEB_BROWSER_AGENT','Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0'); -define('TOOL_IMDBWEB_BROWSER_ACCEPT','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'); -define('TOOL_IMDBWEB_BROWSER_ACCEPT_LANG','en-US,en;q=0.5'); +const = TOOL_IMDBWEB_BROWSER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0'; +const = TOOL_IMDBWEB_BROWSER_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'; +const = TOOL_IMDBWEB_BROWSER_ACCEPT_LANG = 'en-US,en;q=0.5'; diff --git a/webclient/config/config-musicbrainz.php.default b/webclient/config/config-musicbrainz.php.default index eea23be..6ce41df 100644 --- a/webclient/config/config-musicbrainz.php.default +++ b/webclient/config/config-musicbrainz.php.default @@ -30,17 +30,17 @@ * TOOL_BRAINZ_RESULT_LIMIT How many entries the search will display */ -define('TOOL_BRAINZ_BROWSER_AGENT','Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0'); -define('TOOL_BRAINZ_BROWSER_ACCEPT','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'); -define('TOOL_BRAINZ_BROWSER_ACCEPT_LANG','en-US,en;q=0.5'); +const = TOOL_BRAINZ_BROWSER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0'; +const = TOOL_BRAINZ_BROWSER_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'; +const = TOOL_BRAINZ_BROWSER_ACCEPT_LANG = 'en-US,en;q=0.5'; -define('TOOL_BRAINZ_RESULT_LIMIT',10); +const = TOOL_BRAINZ_RESULT_LIMIT = 10; /* -define('TOOL_BRAINZ_FIELDS_TO', +const = TOOL_BRAINZ_FIELDS_TO = array( - 'album' => 'title','date' => 'year', 'artist' => 'artist', 'image' => 'coverimage', 'tracks' => 'content', + 'album' => 'title = 'date' => 'year = 'artist' => 'artist = 'image' => 'coverimage = 'tracks' => 'content = 'runtime' => 'runtime' ) -); +; */ diff --git a/webclient/config/config.php.default b/webclient/config/config.php.default index aa32af9..82f5527 100644 --- a/webclient/config/config.php.default +++ b/webclient/config/config.php.default @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,39 +17,39 @@ */ # set to true if you need debug messages in error log file -define('DEBUG',false); +const DEBUG = false; # set to ture if you need query log messages in error log file. -define('QUERY_DEBUG',false); +const QUERY_DEBUG = false; # timezone settings -define('TIMEZONE','~timezone~'); +const TIMEZONE = '~timezone~'; # path settings -define('PATH_ABSOLUTE','~pathabsolute~'); -define('PATH_SYSTEMOUT',PATH_ABSOLUTE.'/systemout'); -define('PATH_STORAGE',PATH_ABSOLUTE.'/storage'); -define('PATH_WEB_STORAGE','storage'); +const PATH_ABSOLUTE = '~pathabsolute~'; +const PATH_SYSTEMOUT = PATH_ABSOLUTE.'/systemout'; +const PATH_STORAGE = PATH_ABSOLUTE.'/storage'; +const PATH_WEB_STORAGE = 'storage'; # database config -define('DB_HOST','~dbhost~'); -define('DB_USERNAME','~dbuser~'); -define('DB_PASSWORD','~dbpassword~'); -define('DB_NAME','~dbname~'); -define('DB_PREFIX','~dbprefix~'); # a _ is added automatically as separation +const DB_HOST = '~dbhost~'; +const DB_USERNAME = '~dbuser~'; +const DB_PASSWORD = '~dbpassword~'; +const DB_NAME = '~dbname~'; +const DB_PREFIX = '~dbprefix~'; # a _ is added automatically as separation ## theme support # fallback is default theme -define('UI_THEME', 'default'); +const UI_THEME = 'default'; # session -define('SESSION_LIFETIME', 43200); // 8 hours -define('SESSION_NAME', "bibliotheca-session"); -define('SESSION_SAVE_PATH', PATH_SYSTEMOUT.'/session'); +const SESSION_LIFETIME = 43200; // 8 hours +const SESSION_NAME = "bibliotheca-session"; +const SESSION_SAVE_PATH = PATH_SYSTEMOUT.'/session'; # usersettings -define('ADMIN_GROUP_ID','1'); -define('ANON_USER_ID','2'); -define('ANON_GROUP_ID','3'); +const ADMIN_GROUP_ID = '1'; +const ANON_USER_ID = '2'; +const ANON_GROUP_ID = '3'; # view options -define('RESULTS_PER_PAGE',24); +const RESULTS_PER_PAGE = 24; diff --git a/webclient/index.php b/webclient/index.php index 65be066..a00841c 100644 --- a/webclient/index.php +++ b/webclient/index.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,14 @@ require_once './config/config.php'; -define('BIB_VERSION','1.x - Rrajigar Mine ()'); +const BIB_VERSION = '1.x - Rrajigar Mine ()'; mb_http_output('UTF-8'); 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)) { if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) { die('Malformed request. Make sure you know what you are doing.'); diff --git a/webclient/lib/gorenest.class.php b/webclient/lib/gorenest.class.php index 06bbdd9..f6791c0 100644 --- a/webclient/lib/gorenest.class.php +++ b/webclient/lib/gorenest.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/webclient/lib/managecollectionfields.class.php b/webclient/lib/managecollectionfields.class.php index 7110e11..481bfe3 100644 --- a/webclient/lib/managecollectionfields.class.php +++ b/webclient/lib/managecollectionfields.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -251,7 +251,7 @@ class ManageCollectionFields { * @param bool $sortAZ * @return array */ - public function getExistingFields($refresh=false, $sortAZ=false): array { + public function getExistingFields(bool $refresh=false, bool $sortAZ=false): array { if($refresh === false && !empty($this->_cacheExistingSysFields)) { return $this->_cacheExistingSysFields; } diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index 05b2055..b738eda 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/webclient/lib/manageentry.class.php b/webclient/lib/manageentry.class.php index a3e8aed..6b95311 100644 --- a/webclient/lib/manageentry.class.php +++ b/webclient/lib/manageentry.class.php @@ -22,35 +22,35 @@ class Manageentry { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Currently loaded collection to manage entries from * * @var string Number */ - private $_collectionId; + private string $_collectionId; /** * Placeholder in query strings for inserted DB id * * @var string */ - private $_replaceEntryString = 'REPLACE_ENTERY'; + private string $_replaceEntryString = 'REPLACE_ENTERY'; /** * Store edit fields info for runtime * * @var array */ - private $_cacheEditFields = array(); + private array $_cacheEditFields = array(); /** * ManageCollections constructor. @@ -81,7 +81,7 @@ class Manageentry { * @param bool $refresh * @return array */ - public function getEditFields($refresh=false): array { + public function getEditFields(bool $refresh=false): array { if($refresh === false && !empty($this->_cacheEditFields)) { return $this->_cacheEditFields; @@ -160,10 +160,10 @@ class Manageentry { * @param string $owner Number * @param string $group Number * @param string $rights - * @param mixed $update Either false for no update or the ID to update + * @param mixed|false $update Either false for no update or the ID to update * @return int */ - public function create(array $data, string $owner, string $group, string $rights, $update=false): int { + public function create(array $data, string $owner, string $group, string $rights, mixed $update=false): int { $ret = 0; if(DEBUG) error_log("[DEBUG] ".__METHOD__." data: ".var_export($data,true)); diff --git a/webclient/lib/managetags.class.php b/webclient/lib/managetags.class.php index 3d88d88..f633ba7 100644 --- a/webclient/lib/managetags.class.php +++ b/webclient/lib/managetags.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,21 +25,21 @@ class ManageTags { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Currently loaded collection to work with * * @var string Number */ - private $_collectionId; + private string $_collectionId; /** * ManageTags constructor. @@ -57,7 +57,7 @@ class ManageTags { * * @param string $collectionId Number */ - public function setCollection(string $collectionId) { + public function setCollection(string $collectionId): void { if(!empty($collectionId)) { $this->_collectionId = $collectionId; } diff --git a/webclient/lib/musicbrainz.class.php b/webclient/lib/musicbrainz.class.php index e492567..1a99b9a 100644 --- a/webclient/lib/musicbrainz.class.php +++ b/webclient/lib/musicbrainz.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,37 +31,37 @@ class Musicbrainz { /** * @var bool DEBUG */ - private $_DEBUG = false; + private bool $_DEBUG = false; /** * @var string The user agent used to make curl calls */ - private $_BROWSER_AGENT = ''; + private mixed $_BROWSER_AGENT = ''; /** * @var string The user agent lang used to make curl calls */ - private $_BROWSER_LANG = ''; + private mixed $_BROWSER_LANG = ''; /** * @var string The user agent accept used to make curl calls */ - private $_BROWSER_ACCEPT = ''; + private mixed $_BROWSER_ACCEPT = ''; /** * @var string The musicbrainz API release endpoint */ - private $_RELEASE_ENDPOINT = 'http://musicbrainz.org/ws/2/release/'; + private string $_RELEASE_ENDPOINT = 'http://musicbrainz.org/ws/2/release/'; /** * @var string The endpoint for images */ - private $_IMAGE_ENDPOINT = 'http://coverartarchive.org/release/'; + private string $_IMAGE_ENDPOINT = 'http://coverartarchive.org/release/'; /** * @var int The amount of entries returned for release search */ - private $_resultLimit = 10; + private int $_resultLimit = 10; /** * Musicbrainz constructor. @@ -284,7 +284,7 @@ class Musicbrainz { * @param integer $port * @return string */ - private function _curlCall(string $url, $port=80): string { + private function _curlCall(string $url, int $port=80): string { $ret = ''; $ch = curl_init(); @@ -303,6 +303,7 @@ class Musicbrainz { ); if($this->_DEBUG) { + $_headers = array(); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$_headers) { diff --git a/webclient/lib/possessed.class.php b/webclient/lib/possessed.class.php index 6e0c4eb..42ac6fe 100644 --- a/webclient/lib/possessed.class.php +++ b/webclient/lib/possessed.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,14 +30,14 @@ class Possessed { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Possessed constructor. @@ -117,7 +117,7 @@ class Possessed { * @param bool $active * @return bool */ - public function createUser(string $username, string $login, string $password, string $group, array $groups, $active=false): bool { + public function createUser(string $username, string $login, string $password, string $group, array $groups, bool $active=false): bool { $ret = false; if($this->_validNewLogin($login) && $this->_validUsergroup($group)) { @@ -190,7 +190,8 @@ class Possessed { * @param bool $refreshApiToken * @return bool */ - public function updateUser(string $id, string $username, string $login, string $password, string $group, array $groups, $active=false, $refreshApiToken=false): bool { + public function updateUser(string $id, string $username, string $login, string $password, string $group, + array $groups, bool $active=false, bool $refreshApiToken=false): bool { $ret = false; if($this->_validUpdateLogin($login,$id) && $this->_validUsergroup($group)) { @@ -579,7 +580,7 @@ class Possessed { * @param bool $clean * @return bool */ - private function _setGroupReleation(string $userid, array $group, $clean=false): bool { + private function _setGroupReleation(string $userid, array $group, bool $clean=false): bool { $ret = false; if(Summoner::validate($userid,'digit') diff --git a/webclient/lib/spectre.class.php b/webclient/lib/spectre.class.php index f92aa54..bd83cd9 100644 --- a/webclient/lib/spectre.class.php +++ b/webclient/lib/spectre.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,21 +26,21 @@ class Spectre { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Allowed request params * * @var array */ - private $_allowedRequests = array('default','list','add','addInfo'); + private array $_allowedRequests = array('default','list','add','addInfo'); /** * Spectre constructor. diff --git a/webclient/lib/summoner.class.php b/webclient/lib/summoner.class.php index 2a75a02..11521d1 100644 --- a/webclient/lib/summoner.class.php +++ b/webclient/lib/summoner.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,7 +126,6 @@ class Summoner { $value = preg_replace($pattern, '', $input); - #if($input === $value) { if($value === "") { $ret = true; } diff --git a/webclient/lib/tentacle.class.php b/webclient/lib/tentacle.class.php index 66ccd39..860fda5 100644 --- a/webclient/lib/tentacle.class.php +++ b/webclient/lib/tentacle.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2020 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,14 +26,14 @@ class Tentacle { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Tentacle constructor. diff --git a/webclient/lib/trite.class.php b/webclient/lib/trite.class.php index dc65c38..0c42f58 100644 --- a/webclient/lib/trite.class.php +++ b/webclient/lib/trite.class.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,28 +29,28 @@ class Trite { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * The user object to query with * * @var Doomguy */ - private $_User; + private Doomguy $_User; /** * Currently loaded collection to work with * * @var string */ - private $_id; + private string $_id; /** * Current loaded collection data as an array * * @var array */ - private $_collectionData; + private array $_collectionData; /** * Options for db queries @@ -61,22 +61,22 @@ class Trite { * * @var array */ - private $_queryOptions; + private array $_queryOptions; /** * Cache for already loaded collection fields * * @var array */ - private $_cacheExistingCollectionFields = array(); + private array $_cacheExistingCollectionFields = array(); /** * Trite constructor. * - * @param $databaseConnectionObject - * @param $userObj + * @param mysqli $databaseConnectionObject + * @param Doomguy $userObj */ - public function __construct($databaseConnectionObject, $userObj) { + public function __construct(mysqli $databaseConnectionObject, Doomguy $userObj) { $this->_DB = $databaseConnectionObject; $this->_User = $userObj; @@ -91,9 +91,10 @@ class Trite { * 'orderby' => $_sort, * 'sortDirection' => $_sortDirection * ); + * * @param array $options */ - public function setQueryOptions($options) { + public function setQueryOptions(array $options): void { if(!isset($options['limit'])) $options['limit'] = 5; if(!isset($options['offset'])) $options['offset'] = false; @@ -111,7 +112,7 @@ class Trite { * @param string $right The rights mode. read, write or delete * @return array */ - public function load(string $id,$right="read"): array { + public function load(string $id, string $right="read"): array { $this->_collectionData = array(); if(!empty($id) && Summoner::validate($id, 'digit')) { @@ -166,7 +167,7 @@ class Trite { * @param string $rightsMode * @return array */ - public function getCollections($rightsMode="read"): array { + public function getCollections(string $rightsMode="read"): array { $ret = array(); $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description` @@ -265,7 +266,7 @@ class Trite { * @param string $search String value to search value against * @return array */ - public function getTags($search=''): array { + public function getTags(string $search=''): array { $ret = array(); $queryStr = "SELECT `cf`.`fk_field_id` AS id, @@ -398,7 +399,7 @@ class Trite { * * @return void */ - private function _setDefaults() { + private function _setDefaults(): void { // default query options $options['limit'] = 5; $options['offset'] = false; diff --git a/webclient/setup/index.php b/webclient/setup/index.php index ae360d8..40b5113 100644 --- a/webclient/setup/index.php +++ b/webclient/setup/index.php @@ -2,7 +2,7 @@ /** * Bibliotheca * - * Copyright 2018-2021 Johannes Keßler + * Copyright 2018-2022 Johannes Keßler * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ ini_set('display_errors',true); date_default_timezone_set('Europe/Berlin'); # 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)) { if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) { die('Malformed request. Make sure you know what you are doing.'); -- 2.39.5