From 79c6d2fe507d48c21557ef50af0aa93016828623 Mon Sep 17 00:00:00 2001 From: Dominique FOURNIER Date: Fri, 7 May 2021 11:45:26 +0200 Subject: [PATCH] Remove all the require_once : use autoloader --- src/authentication.php | 9 +-------- src/authhtpasswd.php | 2 -- src/authimap.php | 3 --- src/authjwt.php | 5 +---- src/authldap.php | 2 -- src/authorizationdb.php | 4 ---- src/authshibboleth.php | 2 -- src/authsql.php | 3 --- src/authsympa.php | 2 -- src/authzgroups.php | 2 -- src/authzgroupsoo.php | 2 -- src/daemon.php | 3 --- src/dblayer.php | 3 --- src/dblayerauthzgroups.php | 2 -- src/dblayeroo.php | 1 - src/form.php | 2 -- src/getopts.php | 2 -- src/graph.php | 2 -- src/httpclient.php | 2 -- src/jwt.php | 2 -- src/outputcsv.php | 2 -- src/outputhtml.php | 2 -- src/outputjson.php | 2 -- src/outputrest.php | 3 --- src/outputtxt.php | 2 -- src/outputxml.php | 2 -- src/queuefile.php | 3 --- src/ratelimitfile.php | 3 --- src/renderer.php | 3 +-- src/rest.php | 2 -- src/route.php | 6 ------ src/routeSQL.php | 5 ----- src/rss.php | 3 --- src/spfcheck.php | 2 -- src/userssql.php | 3 --- src/xmppclient.php | 2 -- 36 files changed, 3 insertions(+), 97 deletions(-) diff --git a/src/authentication.php b/src/authentication.php index 6c0f6e1..672f28c 100644 --- a/src/authentication.php +++ b/src/authentication.php @@ -7,12 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); -require_once ("domframework/authparams.php"); -require_once ("domframework/authsession.php"); -require_once ("domframework/ratelimit.php"); -require_once ("domframework/ratelimitfile.php"); - /** All the authentication protocol */ class authentication { @@ -318,7 +312,6 @@ class authentication if (isset ($this->authServers["authjwt"]["serverKey"])) { // Set the JSON Web Token as the authentication is valid - require_once ("domframework/authjwt.php"); $algorithm = "HS256"; $cipherKey = null; $cacheDir = "data/jwtCache"; @@ -418,7 +411,7 @@ class authentication if (! is_string ($method)) throw new \Exception ("The authentication method is not a string", 500); $classname = "auth$method"; - require_once ("domframework/$classname.php"); + //require_once ("domframework/$classname.php"); if (! array_key_exists ($classname, $authServers)) throw new \Exception ("No authentication server '$classname' enabled", 500); diff --git a/src/authhtpasswd.php b/src/authhtpasswd.php index 2054620..4d49209 100644 --- a/src/authhtpasswd.php +++ b/src/authhtpasswd.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); - /** User authentication against .htpasswd file A .htpasswd can be created by the 'htpasswd' command for Apache, and contain toto@toto.com:$2y$05$uHCUNqicE7Pku3MK1qZaDuJxP/pocqCcEAnacZBjsfWgW9EcuG5y2 diff --git a/src/authimap.php b/src/authimap.php index 50f1588..d5a7d7a 100644 --- a/src/authimap.php +++ b/src/authimap.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); -require_once ("domframework/imap.php"); - /** User authentication against IMAP server */ class authimap extends auth { diff --git a/src/authjwt.php b/src/authjwt.php index 5d29810..8ad8cc4 100644 --- a/src/authjwt.php +++ b/src/authjwt.php @@ -7,10 +7,7 @@ namespace Domframework; -require_once ("domframework/jwt.php"); -require_once ("domframework/uuid.php"); - -/** User authentication against JSON Web Token +/bin/bash: n : commande introuvable * To use it, the $serverKey must be defined. It can be created by example, * by using $serverKey = sha1 (microtime (true)); */ diff --git a/src/authldap.php b/src/authldap.php index 7e909c2..f93dc4b 100644 --- a/src/authldap.php +++ b/src/authldap.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); - /** User authentication against LDAP server */ class authldap extends auth { diff --git a/src/authorizationdb.php b/src/authorizationdb.php index 4356baf..6179d57 100644 --- a/src/authorizationdb.php +++ b/src/authorizationdb.php @@ -7,10 +7,6 @@ namespace Domframework; -error_reporting (E_ALL); -require_once ("domframework/dblayer.php"); -require_once ("domframework/authorization.php"); - /** All the needed functions to authorize or deny access to an authenticated user */ class authorizationdb extends authorization diff --git a/src/authshibboleth.php b/src/authshibboleth.php index c61481a..9238bd6 100644 --- a/src/authshibboleth.php +++ b/src/authshibboleth.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); - /** User authentication against Shibboleth */ class authshibboleth extends auth { diff --git a/src/authsql.php b/src/authsql.php index 64fe151..87a4756 100644 --- a/src/authsql.php +++ b/src/authsql.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/dblayer.php"); -require_once ("domframework/auth.php"); - /** User authentication against SQL database */ class authsql extends auth { diff --git a/src/authsympa.php b/src/authsympa.php index 37db4fa..f5782d9 100644 --- a/src/authsympa.php +++ b/src/authsympa.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/auth.php"); - /** User authentication against SYMPA server Sympa is a mailling list server. It can handle authentication with - a username (a email adress) diff --git a/src/authzgroups.php b/src/authzgroups.php index 7c99cf6..b64c362 100644 --- a/src/authzgroups.php +++ b/src/authzgroups.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/dblayer.php"); - /** All the needed functions to authorize or deny access to an authenticated user by its groups membership */ class authzgroups diff --git a/src/authzgroupsoo.php b/src/authzgroupsoo.php index 74bc68a..64366a3 100644 --- a/src/authzgroupsoo.php +++ b/src/authzgroupsoo.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/dblayeroo.php"); - /** All the needed functions to authorize or deny access to an authenticated * user by its groups membership * Based on dblayeroo diff --git a/src/daemon.php b/src/daemon.php index 03f6f4d..8618393 100644 --- a/src/daemon.php +++ b/src/daemon.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/fork.php"); -require_once ("domframework/file.php"); - /** Manage a daemon. * Allow to start, stop, get status of a callable method */ diff --git a/src/dblayer.php b/src/dblayer.php index 28ece6c..84135a1 100644 --- a/src/dblayer.php +++ b/src/dblayer.php @@ -37,8 +37,6 @@ Optionnaly, you can add the - public $debug = TRUE : enable the debug on screen (NOT FOR PROD !!) */ -require_once ("domframework/verify.php"); - /** Permit abstraction on the differents SQL databases available */ class dblayer { @@ -1631,7 +1629,6 @@ class dblayer /** POC : error_reporting (E_ALL); -require_once ("domframework/dbLayer.php"); class zone extends dbLayer { // The database must be initialized with diff --git a/src/dblayerauthzgroups.php b/src/dblayerauthzgroups.php index 4fe29fd..dd01cf0 100644 --- a/src/dblayerauthzgroups.php +++ b/src/dblayerauthzgroups.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/dblayer.php"); - /** DBLayer with authorization * All the actions in database are conditionned to the rights in authzgroups */ diff --git a/src/dblayeroo.php b/src/dblayeroo.php index 77d3475..6d0c32c 100644 --- a/src/dblayeroo.php +++ b/src/dblayeroo.php @@ -3480,7 +3480,6 @@ class dblayeroo $backtrace = debug_backtrace (); if ($this->debug) { - require_once ("domframework/backtrace.php"); backtrace::show (debug_backtrace ()); } if (! array_key_exists (1, $backtrace)) diff --git a/src/form.php b/src/form.php index e82445c..70324d9 100644 --- a/src/form.php +++ b/src/form.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/csrf.php"); - /** This class permit to create easily some forms to HTML (or text mode in * future). * Each field can be checked in AJAX or HTML. diff --git a/src/getopts.php b/src/getopts.php index 5ffd22d..064fdac 100644 --- a/src/getopts.php +++ b/src/getopts.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/verify.php"); - /** Manage the options provided on the command line * Parameters can be : * - Manage -d -dd -ddd as -d -d -d diff --git a/src/graph.php b/src/graph.php index c6682cc..ce4a5cc 100644 --- a/src/graph.php +++ b/src/graph.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/color.php"); - /** This class allow to generate an image which is a graphic. A graphic takes * an array of values and draw the lines/histo... like a spreadsheet * graph methods are : diff --git a/src/httpclient.php b/src/httpclient.php index 7208832..29f0dea 100644 --- a/src/httpclient.php +++ b/src/httpclient.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/tcpclient.php"); - /** This programe allow to get a HTTP page from a site, and examine the content. * It will store the Cookies, allow to do the redirects, follow links and * get form / input and send the values. diff --git a/src/jwt.php b/src/jwt.php index 1fc7e72..efe4aca 100644 --- a/src/jwt.php +++ b/src/jwt.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/encrypt.php"); - /** Allow to manage the JSON Web Tokens * Based on https://tools.ietf.org/html/rfc7519 * diff --git a/src/outputcsv.php b/src/outputcsv.php index e631ed3..0df9afb 100644 --- a/src/outputcsv.php +++ b/src/outputcsv.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); - /** Display in CSV the data provided */ class outputcsv extends output diff --git a/src/outputhtml.php b/src/outputhtml.php index c6b4675..df25319 100644 --- a/src/outputhtml.php +++ b/src/outputhtml.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); - /** Display in HTML the data provided, with the layout support */ class outputhtml extends output diff --git a/src/outputjson.php b/src/outputjson.php index b376b36..54dccf1 100644 --- a/src/outputjson.php +++ b/src/outputjson.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); - /** Display in JSON the data provided * The data must NOT be binary ! */ diff --git a/src/outputrest.php b/src/outputrest.php index e2adef9..5acff3e 100644 --- a/src/outputrest.php +++ b/src/outputrest.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); -require_once ("domframework/rest.php"); - /** Display in REST the data provided. * Allow all the output types : JSON, XML, TXT... */ diff --git a/src/outputtxt.php b/src/outputtxt.php index 8530f17..d9d3397 100644 --- a/src/outputtxt.php +++ b/src/outputtxt.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); - /** Display in Text the data provided */ class outputtxt extends output diff --git a/src/outputxml.php b/src/outputxml.php index 7941eb6..6ac1187 100644 --- a/src/outputxml.php +++ b/src/outputxml.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/output.php"); - /** Display in XML the data provided */ class outputxml extends output diff --git a/src/queuefile.php b/src/queuefile.php index 68f3213..6692dec 100644 --- a/src/queuefile.php +++ b/src/queuefile.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/queue.php"); -require_once ("domframework/file.php"); - /** Manage a queue in file * A process can add entries to the end of a queue * A process can get all the entries in a queue diff --git a/src/ratelimitfile.php b/src/ratelimitfile.php index b4ca091..66e9701 100644 --- a/src/ratelimitfile.php +++ b/src/ratelimitfile.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/lockfile.php"); -require_once ("domframework/ratelimit.php"); - /** The rate limit with file storage */ class ratelimitfile extends ratelimit diff --git a/src/renderer.php b/src/renderer.php index 9642e65..6442dee 100644 --- a/src/renderer.php +++ b/src/renderer.php @@ -34,7 +34,7 @@ class renderer { // If the output is not defined in domframework, it will not be loaded but // without error, it can be loaded by the autoloader - @require_once ("domframework/output$this->output.php"); + //@require_once ("domframework/output$this->output.php"); $class = __NAMESPACE__."\\output$this->output"; $obj = new $class (); $res = call_user_func_array (array ($obj, "out"), @@ -118,7 +118,6 @@ class renderer { if ($layoutfile !== false && ! file_exists ($layoutfile)) throw new \Exception ("Layout file $layoutfile not found", 500); - require_once ("domframework/outputhtml.php"); if ($route === null) $route = new route (); // Return a $dataflash with the displayed flash in Bootstrap diff --git a/src/rest.php b/src/rest.php index 6705fd7..becbbb8 100644 --- a/src/rest.php +++ b/src/rest.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/http.php"); - /** Allow to manage the REST protocol by using the users output types */ class rest diff --git a/src/route.php b/src/route.php index 57cb105..092c21d 100644 --- a/src/route.php +++ b/src/route.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/http.php"); -require_once ("domframework/ratelimitfile.php"); - /** The routing module, base of the DomFramework */ class route @@ -536,7 +533,6 @@ class route { $this->error ($e); } - require_once ("domframework/renderer.php"); $renderer = new renderer (); $renderer->result = $data; $renderer->output = $this->output; @@ -592,7 +588,6 @@ class route { $this->error ($e); } - require_once ("domframework/renderer.php"); $renderer = new renderer (); $renderer->result = $data; $renderer->output = $this->output; @@ -685,7 +680,6 @@ class route } // TODO : If the output is HTML, add the header line : // echo " \n"; - require_once ("domframework/renderer.php"); $renderer = new renderer (); $renderer->result = $message; $renderer->output = $this->output; diff --git a/src/routeSQL.php b/src/routeSQL.php index 06648e0..97778af 100644 --- a/src/routeSQL.php +++ b/src/routeSQL.php @@ -7,10 +7,6 @@ namespace Domframework; -require_once ("domframework/route.php"); -require_once ("domframework/form.php"); -require_once ("domframework/renderer.php"); - /** Automatic Routing for SQL database * Allow to do CRUD on data with only one line in index.php */ @@ -1901,7 +1897,6 @@ $content .= "\n"; */ private function rendererhtml ($data) { - require_once ("domframework/outputhtml.php"); $route = new route (); $html = new outputhtml (); diff --git a/src/rss.php b/src/rss.php index 9e8a6c0..4a153c3 100644 --- a/src/rss.php +++ b/src/rss.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/verify.php"); -require_once ("domframework/convert.php"); - /** Create the RSS pages for the websites * Specification http://www.rssboard.org/rss-specification */ diff --git a/src/spfcheck.php b/src/spfcheck.php index 5e44fe8..b89229c 100644 --- a/src/spfcheck.php +++ b/src/spfcheck.php @@ -7,8 +7,6 @@ namespace Domframework; -require ("domframework/ipaddresses.php"); - /** This class allow to get a SPF record for a domain and check an IP against * the rules set in SPF record. * It also says in which rule the IP match diff --git a/src/userssql.php b/src/userssql.php index 3184a3c..1e680c4 100644 --- a/src/userssql.php +++ b/src/userssql.php @@ -7,9 +7,6 @@ namespace Domframework; -require_once ("domframework/dblayer.php"); -require_once ("domframework/users.php"); - /** Store the users in SQL database. Manage the creation of the users, * modification, delete, password management */ diff --git a/src/xmppclient.php b/src/xmppclient.php index 4fd643c..eff9875 100644 --- a/src/xmppclient.php +++ b/src/xmppclient.php @@ -7,8 +7,6 @@ namespace Domframework; -require_once ("domframework/tcpclient.php"); - /** This class allow to send XMPP messages to a server. * If the server supports it, crypt the connection by StartTLS before auth */