Remove all the require_once : use autoloader

This commit is contained in:
2021-05-07 11:45:26 +02:00
parent b1e513126e
commit 79c6d2fe50
36 changed files with 3 additions and 97 deletions
+1 -8
View File
@@ -7,12 +7,6 @@
namespace Domframework; 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 */ /** All the authentication protocol */
class authentication class authentication
{ {
@@ -318,7 +312,6 @@ class authentication
if (isset ($this->authServers["authjwt"]["serverKey"])) if (isset ($this->authServers["authjwt"]["serverKey"]))
{ {
// Set the JSON Web Token as the authentication is valid // Set the JSON Web Token as the authentication is valid
require_once ("domframework/authjwt.php");
$algorithm = "HS256"; $algorithm = "HS256";
$cipherKey = null; $cipherKey = null;
$cacheDir = "data/jwtCache"; $cacheDir = "data/jwtCache";
@@ -418,7 +411,7 @@ class authentication
if (! is_string ($method)) if (! is_string ($method))
throw new \Exception ("The authentication method is not a string", 500); throw new \Exception ("The authentication method is not a string", 500);
$classname = "auth$method"; $classname = "auth$method";
require_once ("domframework/$classname.php"); //require_once ("domframework/$classname.php");
if (! array_key_exists ($classname, $authServers)) if (! array_key_exists ($classname, $authServers))
throw new \Exception ("No authentication server '$classname' enabled", throw new \Exception ("No authentication server '$classname' enabled",
500); 500);
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against .htpasswd file /** User authentication against .htpasswd file
A .htpasswd can be created by the 'htpasswd' command for Apache, and contain A .htpasswd can be created by the 'htpasswd' command for Apache, and contain
toto@toto.com:$2y$05$uHCUNqicE7Pku3MK1qZaDuJxP/pocqCcEAnacZBjsfWgW9EcuG5y2 toto@toto.com:$2y$05$uHCUNqicE7Pku3MK1qZaDuJxP/pocqCcEAnacZBjsfWgW9EcuG5y2
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/auth.php");
require_once ("domframework/imap.php");
/** User authentication against IMAP server */ /** User authentication against IMAP server */
class authimap extends auth class authimap extends auth
{ {
+1 -4
View File
@@ -7,10 +7,7 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/jwt.php"); /bin/bash: n : commande introuvable
require_once ("domframework/uuid.php");
/** User authentication against JSON Web Token
* To use it, the $serverKey must be defined. It can be created by example, * To use it, the $serverKey must be defined. It can be created by example,
* by using $serverKey = sha1 (microtime (true)); * by using $serverKey = sha1 (microtime (true));
*/ */
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against LDAP server */ /** User authentication against LDAP server */
class authldap extends auth class authldap extends auth
{ {
-4
View File
@@ -7,10 +7,6 @@
namespace Domframework; 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 /** All the needed functions to authorize or deny access to an authenticated
user */ user */
class authorizationdb extends authorization class authorizationdb extends authorization
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against Shibboleth */ /** User authentication against Shibboleth */
class authshibboleth extends auth class authshibboleth extends auth
{ {
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/dblayer.php");
require_once ("domframework/auth.php");
/** User authentication against SQL database */ /** User authentication against SQL database */
class authsql extends auth class authsql extends auth
{ {
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against SYMPA server /** User authentication against SYMPA server
Sympa is a mailling list server. It can handle authentication with Sympa is a mailling list server. It can handle authentication with
- a username (a email adress) - a username (a email adress)
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/dblayer.php");
/** All the needed functions to authorize or deny access to an authenticated /** All the needed functions to authorize or deny access to an authenticated
user by its groups membership */ user by its groups membership */
class authzgroups class authzgroups
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/dblayeroo.php");
/** All the needed functions to authorize or deny access to an authenticated /** All the needed functions to authorize or deny access to an authenticated
* user by its groups membership * user by its groups membership
* Based on dblayeroo * Based on dblayeroo
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/fork.php");
require_once ("domframework/file.php");
/** Manage a daemon. /** Manage a daemon.
* Allow to start, stop, get status of a callable method * Allow to start, stop, get status of a callable method
*/ */
-3
View File
@@ -37,8 +37,6 @@ Optionnaly, you can add the
- public $debug = TRUE : enable the debug on screen (NOT FOR PROD !!) - public $debug = TRUE : enable the debug on screen (NOT FOR PROD !!)
*/ */
require_once ("domframework/verify.php");
/** Permit abstraction on the differents SQL databases available */ /** Permit abstraction on the differents SQL databases available */
class dblayer class dblayer
{ {
@@ -1631,7 +1629,6 @@ class dblayer
/** POC : /** POC :
error_reporting (E_ALL); error_reporting (E_ALL);
require_once ("domframework/dbLayer.php");
class zone extends dbLayer class zone extends dbLayer
{ {
// The database must be initialized with // The database must be initialized with
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/dblayer.php");
/** DBLayer with authorization /** DBLayer with authorization
* All the actions in database are conditionned to the rights in authzgroups * All the actions in database are conditionned to the rights in authzgroups
*/ */
-1
View File
@@ -3480,7 +3480,6 @@ class dblayeroo
$backtrace = debug_backtrace (); $backtrace = debug_backtrace ();
if ($this->debug) if ($this->debug)
{ {
require_once ("domframework/backtrace.php");
backtrace::show (debug_backtrace ()); backtrace::show (debug_backtrace ());
} }
if (! array_key_exists (1, $backtrace)) if (! array_key_exists (1, $backtrace))
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/csrf.php");
/** This class permit to create easily some forms to HTML (or text mode in /** This class permit to create easily some forms to HTML (or text mode in
* future). * future).
* Each field can be checked in AJAX or HTML. * Each field can be checked in AJAX or HTML.
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/verify.php");
/** Manage the options provided on the command line /** Manage the options provided on the command line
* Parameters can be : * Parameters can be :
* - Manage -d -dd -ddd as -d -d -d * - Manage -d -dd -ddd as -d -d -d
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/color.php");
/** This class allow to generate an image which is a graphic. A graphic takes /** 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 * an array of values and draw the lines/histo... like a spreadsheet
* graph methods are : * graph methods are :
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/tcpclient.php");
/** This programe allow to get a HTTP page from a site, and examine the content. /** 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 * It will store the Cookies, allow to do the redirects, follow links and
* get form / input and send the values. * get form / input and send the values.
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/encrypt.php");
/** Allow to manage the JSON Web Tokens /** Allow to manage the JSON Web Tokens
* Based on https://tools.ietf.org/html/rfc7519 * Based on https://tools.ietf.org/html/rfc7519
* *
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
/** Display in CSV the data provided /** Display in CSV the data provided
*/ */
class outputcsv extends output class outputcsv extends output
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
/** Display in HTML the data provided, with the layout support /** Display in HTML the data provided, with the layout support
*/ */
class outputhtml extends output class outputhtml extends output
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
/** Display in JSON the data provided /** Display in JSON the data provided
* The data must NOT be binary ! * The data must NOT be binary !
*/ */
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
require_once ("domframework/rest.php");
/** Display in REST the data provided. /** Display in REST the data provided.
* Allow all the output types : JSON, XML, TXT... * Allow all the output types : JSON, XML, TXT...
*/ */
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
/** Display in Text the data provided /** Display in Text the data provided
*/ */
class outputtxt extends output class outputtxt extends output
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/output.php");
/** Display in XML the data provided /** Display in XML the data provided
*/ */
class outputxml extends output class outputxml extends output
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/queue.php");
require_once ("domframework/file.php");
/** Manage a queue in file /** Manage a queue in file
* A process can add entries to the end of a queue * A process can add entries to the end of a queue
* A process can get all the entries in a queue * A process can get all the entries in a queue
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/lockfile.php");
require_once ("domframework/ratelimit.php");
/** The rate limit with file storage /** The rate limit with file storage
*/ */
class ratelimitfile extends ratelimit class ratelimitfile extends ratelimit
+1 -2
View File
@@ -34,7 +34,7 @@ class renderer
{ {
// If the output is not defined in domframework, it will not be loaded but // If the output is not defined in domframework, it will not be loaded but
// without error, it can be loaded by the autoloader // 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"; $class = __NAMESPACE__."\\output$this->output";
$obj = new $class (); $obj = new $class ();
$res = call_user_func_array (array ($obj, "out"), $res = call_user_func_array (array ($obj, "out"),
@@ -118,7 +118,6 @@ class renderer
{ {
if ($layoutfile !== false && ! file_exists ($layoutfile)) if ($layoutfile !== false && ! file_exists ($layoutfile))
throw new \Exception ("Layout file $layoutfile not found", 500); throw new \Exception ("Layout file $layoutfile not found", 500);
require_once ("domframework/outputhtml.php");
if ($route === null) if ($route === null)
$route = new route (); $route = new route ();
// Return a $dataflash with the displayed flash in Bootstrap // Return a $dataflash with the displayed flash in Bootstrap
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/http.php");
/** Allow to manage the REST protocol by using the users output types /** Allow to manage the REST protocol by using the users output types
*/ */
class rest class rest
-6
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/http.php");
require_once ("domframework/ratelimitfile.php");
/** The routing module, base of the DomFramework /** The routing module, base of the DomFramework
*/ */
class route class route
@@ -536,7 +533,6 @@ class route
{ {
$this->error ($e); $this->error ($e);
} }
require_once ("domframework/renderer.php");
$renderer = new renderer (); $renderer = new renderer ();
$renderer->result = $data; $renderer->result = $data;
$renderer->output = $this->output; $renderer->output = $this->output;
@@ -592,7 +588,6 @@ class route
{ {
$this->error ($e); $this->error ($e);
} }
require_once ("domframework/renderer.php");
$renderer = new renderer (); $renderer = new renderer ();
$renderer->result = $data; $renderer->result = $data;
$renderer->output = $this->output; $renderer->output = $this->output;
@@ -685,7 +680,6 @@ class route
} }
// TODO : If the output is HTML, add the header line : // TODO : If the output is HTML, add the header line :
// echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n"; // echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n";
require_once ("domframework/renderer.php");
$renderer = new renderer (); $renderer = new renderer ();
$renderer->result = $message; $renderer->result = $message;
$renderer->output = $this->output; $renderer->output = $this->output;
-5
View File
@@ -7,10 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/route.php");
require_once ("domframework/form.php");
require_once ("domframework/renderer.php");
/** Automatic Routing for SQL database /** Automatic Routing for SQL database
* Allow to do CRUD on data with only one line in index.php * Allow to do CRUD on data with only one line in index.php
*/ */
@@ -1901,7 +1897,6 @@ $content .= "</li>\n";
*/ */
private function rendererhtml ($data) private function rendererhtml ($data)
{ {
require_once ("domframework/outputhtml.php");
$route = new route (); $route = new route ();
$html = new outputhtml (); $html = new outputhtml ();
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/verify.php");
require_once ("domframework/convert.php");
/** Create the RSS pages for the websites /** Create the RSS pages for the websites
* Specification http://www.rssboard.org/rss-specification * Specification http://www.rssboard.org/rss-specification
*/ */
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require ("domframework/ipaddresses.php");
/** This class allow to get a SPF record for a domain and check an IP against /** This class allow to get a SPF record for a domain and check an IP against
* the rules set in SPF record. * the rules set in SPF record.
* It also says in which rule the IP match * It also says in which rule the IP match
-3
View File
@@ -7,9 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/dblayer.php");
require_once ("domframework/users.php");
/** Store the users in SQL database. Manage the creation of the users, /** Store the users in SQL database. Manage the creation of the users,
* modification, delete, password management * modification, delete, password management
*/ */
-2
View File
@@ -7,8 +7,6 @@
namespace Domframework; namespace Domframework;
require_once ("domframework/tcpclient.php");
/** This class allow to send XMPP messages to a server. /** This class allow to send XMPP messages to a server.
* If the server supports it, crypt the connection by StartTLS before auth * If the server supports it, crypt the connection by StartTLS before auth
*/ */