Compare commits

..

6 Commits

Author SHA1 Message Date
Dominique FOURNIER f6782c18dc Add not enabled namespace on each file 2021-05-06 14:00:03 +02:00
Dominique FOURNIER 5748fe7ae8 RobotsTXT : Manage correctely the Sitemaps 2021-05-06 13:42:41 +02:00
Dominique FOURNIER 5ac09bb36b sqlMigrate : update comment 2021-03-16 15:41:51 +01:00
Dominique FOURNIER 556fb57233 sqlMigrate : add --execute option to use the configuration file 2021-03-16 15:38:21 +01:00
Dominique FOURNIER cde2738fe9 sqlMigrate : Allow Debug to display the executed INSERT 2021-03-16 15:31:48 +01:00
Dominique FOURNIER aeab871d9d sqlMigrate : allow to return at the specified step by getopt. Use readline to provide the already defined valued in configuration file (if exists) 2021-03-16 15:25:04 +01:00
83 changed files with 232 additions and 27 deletions
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** User authentication (abstract class) */ /** User authentication (abstract class) */
class auth class auth
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
require_once ("domframework/authparams.php"); require_once ("domframework/authparams.php");
require_once ("domframework/authsession.php"); require_once ("domframework/authsession.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
/** User authentication against .htpasswd file /** User authentication against .htpasswd file
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
require_once ("domframework/imap.php"); require_once ("domframework/imap.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/jwt.php"); require_once ("domframework/jwt.php");
require_once ("domframework/uuid.php"); require_once ("domframework/uuid.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
/** User authentication against LDAP server */ /** User authentication against LDAP server */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** 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 authorization class authorization
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
error_reporting (E_ALL); error_reporting (E_ALL);
require_once ("domframework/dblayer.php"); require_once ("domframework/dblayer.php");
require_once ("domframework/authorization.php"); require_once ("domframework/authorization.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Takes the email and the password of the user */ /** Takes the email and the password of the user */
class authparams class authparams
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** User authentication against SESSION */ /** User authentication against SESSION */
class authsession extends auth class authsession extends auth
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
/** User authentication against Shibboleth */ /** User authentication against Shibboleth */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/dblayer.php"); require_once ("domframework/dblayer.php");
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/auth.php"); require_once ("domframework/auth.php");
/** User authentication against SYMPA server /** User authentication against SYMPA server
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/dblayer.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/dblayeroo.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Display the backtrace in HTML with clicks to display the content /** Display the backtrace in HTML with clicks to display the content
*/ */
class backtrace class backtrace
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** A cache manager in file /** A cache manager in file
*/ */
class cachefile class cachefile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class permit to cache the ouptut of a code. If the cache is already /** This class permit to cache the ouptut of a code. If the cache is already
* available, use it. * available, use it.
* It resend the headers as the ouptut send them * It resend the headers as the ouptut send them
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** An certificate authority /** An certificate authority
*/ */
class certificationauthority class certificationauthority
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Allow to interract with controllers and models from the CLI */ /** Allow to interract with controllers and models from the CLI */
class cli class cli
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Convert the name of colors to RGB /** Convert the name of colors to RGB
*/ */
class color class color
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage the configurations of the module done by administrator in a config /** Manage the configurations of the module done by administrator in a config
* file * file
* It is based on the module configuration defaults * It is based on the module configuration defaults
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Allow to manage a linux Console to have a minimal but working text interface /** Allow to manage a linux Console to have a minimal but working text interface
* When using this class, you must use the $console::echo method and not * When using this class, you must use the $console::echo method and not
* display directely on screen * display directely on screen
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Convert a format to another one /** Convert a format to another one
*/ */
class convert class convert
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** CSRF protection /** CSRF protection
* By default, the CSRF protection is active if a SESSION is active too. * By default, the CSRF protection is active if a SESSION is active too.
* It can be disabled if needed. An Exception is raised if the form is send * It can be disabled if needed. An Exception is raised if the form is send
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/fork.php"); require_once ("domframework/fork.php");
require_once ("domframework/file.php"); require_once ("domframework/file.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** DBJSON : a NoSQL DB in JSON /** DBJSON : a NoSQL DB in JSON
* Documentation * Documentation
* - A filter is an array containing the fields and the values to found * - A filter is an array containing the fields and the values to found
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
// dblayer.php // dblayer.php
/* Documentation : /* Documentation :
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/dblayer.php"); require_once ("domframework/dblayer.php");
/** DBLayer with authorization /** DBLayer with authorization
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Permit abstraction on the differents SQL databases available /** Permit abstraction on the differents SQL databases available
*/ */
class dblayeroo class dblayeroo
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Allow to encrypt/decrypt data /** Allow to encrypt/decrypt data
*/ */
class encrypt class encrypt
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The file method allow to manage files like PHP with a working chroot on all /** The file method allow to manage files like PHP with a working chroot on all
* plateforms, and a right management compatible with database * plateforms, and a right management compatible with database
* Don't follow links ! * Don't follow links !
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage the fork of children in Posix mode /** Manage the fork of children in Posix mode
*/ */
class fork class fork
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/csrf.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The Full Text Search /** The Full Text Search
* Analyze the provided search text (like a search engine), and create the * Analyze the provided search text (like a search engine), and create the
* sql query to found the answer. It also allow to check if a sentence is valid * sql query to found the answer. It also allow to check if a sentence is valid
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/verify.php"); require_once ("domframework/verify.php");
/** Manage the options provided on the command line /** Manage the options provided on the command line
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/color.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** HTTP Helper : understand the best choices provided by browser, the HTTP /** HTTP Helper : understand the best choices provided by browser, the HTTP
* codes * codes
*/ */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/tcpclient.php"); 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.
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** IMAP connection abstraction /** IMAP connection abstraction
In the IMAP terminology, "mailbox" is a folder in the mailbox of the user */ In the IMAP terminology, "mailbox" is a folder in the mailbox of the user */
class imap class imap
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage .ini files like in php.ini /** Manage .ini files like in php.ini
Support the sections (or not) */ Support the sections (or not) */
class inifile class inifile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage the IP addresses conversions */ /** Manage the IP addresses conversions */
class ipaddresses class ipaddresses
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/encrypt.php"); require_once ("domframework/encrypt.php");
/** Allow to manage the JSON Web Tokens /** Allow to manage the JSON Web Tokens
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Language class : change the messages /** Language class : change the messages
*/ */
class language class language
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The lock management of files /** The lock management of files
*/ */
class lockfile class lockfile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The logger class permit to log the information from the soft /** The logger class permit to log the information from the soft
* It allow to debug too * It allow to debug too
*/ */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage the MAC addresses /** Manage the MAC addresses
* Based on : * Based on :
* https://www.stetsenko.net/2011/01/php-mac-address-validating-and-formatting/ * https://www.stetsenko.net/2011/01/php-mac-address-validating-and-formatting/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The class to create a complete email. Can read an email from a content /** The class to create a complete email. Can read an email from a content
*/ */
class mail class mail
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Convert the Markdown text to html format /** Convert the Markdown text to html format
*/ */
class markdown class markdown
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Module management /** Module management
*/ */
class module class module
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Class used to display data /** Class used to display data
*/ */
class output class output
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); require_once ("domframework/output.php");
/** Display in CSV the data provided /** Display in CSV the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class allow a program to download a specific file from the filesystem, /** This class allow a program to download a specific file from the filesystem,
* without using too much memory. In also allow to manage the resuming of a * without using too much memory. In also allow to manage the resuming of a
* paused transfert by getting the range of download. * paused transfert by getting the range of download.
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); require_once ("domframework/output.php");
/** Display in JSON the data provided /** Display in JSON the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); require_once ("domframework/output.php");
require_once ("domframework/rest.php"); require_once ("domframework/rest.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); require_once ("domframework/output.php");
/** Display in Text the data provided /** Display in Text the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/output.php"); require_once ("domframework/output.php");
/** Display in XML the data provided /** Display in XML the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** A class to manage the password hashing, password generation /** A class to manage the password hashing, password generation
*/ */
class password class password
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Manage a queue in multiple storages /** Manage a queue in multiple storages
* 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/queue.php"); require_once ("domframework/queue.php");
require_once ("domframework/file.php"); require_once ("domframework/file.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The rate limit abstract class /** The rate limit abstract class
*/ */
class ratelimit class ratelimit
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/lockfile.php"); require_once ("domframework/lockfile.php");
require_once ("domframework/ratelimit.php"); require_once ("domframework/ratelimit.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Display the data in HTML with a FLASH method to display the errors /** Display the data in HTML with a FLASH method to display the errors
*/ */
class renderer class renderer
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/http.php"); 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
+19 -8
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class analyze the provided robots.txt file content and allow to /** This class analyze the provided robots.txt file content and allow to
* get the configured data for DomSearch. * get the configured data for DomSearch.
* It allow to examine an URL against the robots.txt file and return if the URL * It allow to examine an URL against the robots.txt file and return if the URL
@@ -74,6 +76,20 @@ class robotstxt
$this->allow = array ("/"); $this->allow = array ("/");
return $this; return $this;
} }
// The sitemaps are not restricted to the user-agent
foreach (preg_grep ("~Sitemap:\s+~i", $content) as $nb => $line)
{
$url = $this->getValueFromLine ($line);
if (!! filter_var ($url, FILTER_VALIDATE_URL) &&
(substr ($url, 0, 7) === "http://" ||
substr ($url, 0, 8) === "https://"))
$this->sitemaps[] = $url;
else
$this->errors[$nb] = dgettext ("domframework",
"Sitemap : Invalid URL provided");
}
// Get the Allow and Disallow lines. The stop will arrive on first // Get the Allow and Disallow lines. The stop will arrive on first
// User-Agent line arriving after a Allow/Disallow. // User-Agent line arriving after a Allow/Disallow.
// Comments and empty lines are removed // Comments and empty lines are removed
@@ -82,14 +98,9 @@ class robotstxt
$line = trim ($content[$i]); $line = trim ($content[$i]);
if (stripos ($line, "Sitemap:") === 0) if (stripos ($line, "Sitemap:") === 0)
{ {
$url = $this->getValueFromLine ($line); // Already managed in the general parser. Not needed in the specific
if (!! filter_var ($url, FILTER_VALIDATE_URL) && // user-agent parser. Must at least be catched to not generate an
(substr ($url, 0, 7) === "http://" || // error
substr ($url, 0, 8) === "https://"))
$this->sitemaps[] = $url;
else
$this->errors[$i] = dgettext ("domframework",
"Sitemap : Invalid URL provided");
} }
elseif (stripos ($line, "Host:") === 0) elseif (stripos ($line, "Host:") === 0)
{ {
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/http.php"); require_once ("domframework/http.php");
require_once ("domframework/ratelimitfile.php"); require_once ("domframework/ratelimitfile.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/route.php"); require_once ("domframework/route.php");
require_once ("domframework/form.php"); require_once ("domframework/form.php");
require_once ("domframework/renderer.php"); require_once ("domframework/renderer.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/verify.php"); require_once ("domframework/verify.php");
require_once ("domframework/convert.php"); require_once ("domframework/convert.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class allow to read the sitemaps files available in websites, and give /** This class allow to read the sitemaps files available in websites, and give
* the available URL and parameters * the available URL and parameters
*/ */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Allow to send mails by smtp /** Allow to send mails by smtp
*/ */
class smtp class smtp
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require ("domframework/ipaddresses.php"); 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class allow to manage Server-Sent Events /** This class allow to manage Server-Sent Events
* The browser will be connected to a not ending loop. This loop will send * The browser will be connected to a not ending loop. This loop will send
* ping regularly. If the backend value change, it will be sent to the * ping regularly. If the backend value change, it will be sent to the
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** TCP Client /** TCP Client
* Allow to create TCP connections to a server. * Allow to create TCP connections to a server.
* If both IPv6 and IPv4 are allowed by the server, try in IPv6 then back in * If both IPv6 and IPv4 are allowed by the server, try in IPv6 then back in
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This class allow to start a TCP server and call a function each time a /** This class allow to start a TCP server and call a function each time a
* client is connected on it. Each client is separated in a child, so the * client is connected on it. Each client is separated in a child, so the
* server allow to have multiple simultaneous connections. * server allow to have multiple simultaneous connections.
+50 -18
View File
@@ -14,6 +14,7 @@
* informations will be stored. The file will be created if it doesn't exists. * informations will be stored. The file will be created if it doesn't exists.
*/ */
require_once ("domframework/console.php");
require_once ("domframework/dblayeroo.php"); require_once ("domframework/dblayeroo.php");
require_once ("domframework/getopts.php"); require_once ("domframework/getopts.php");
require_once ("domframework/config.php"); require_once ("domframework/config.php");
@@ -56,13 +57,32 @@ class main
*/ */
public function __construct () public function __construct ()
{ {
global $argv; // Manage the Getopts
if (! key_exists (1, $argv)) $getopts = new getopts ();
$getopts->add ("Help", "?h", array ("help"), "Help of the software");
$getopts->add ("Step", "", array ("step:"), "Restart at provided step",
"StepIdentifier");
$getopts->add ("Debug", "", array ("debug"), "Display the SQL requests");
$getopts->add ("Execute", "", array ("execute"),
"Execute the configuration without requesting data (start at step 5)");
if ($getopts->get ("Help"))
die ($getopts->help ());
if ($getopts->get ("Step"))
{
if (intval ($getopts->get ("Step")) < 0 ||
intval ($getopts->get ("Step")) > 6)
die ("Invalid Step provided (Must be between 0 and 6)\n");
}
if (empty ($getopts->restOfLine ()))
throw new Exception ("No configuration file provided"); throw new Exception ("No configuration file provided");
if (! file_exists ($argv[1])) if (count ($getopts->restOfLine ()) > 1)
touch ($argv[1]); throw new Exception ("Too much configuration file provided");
$configurationFile = current ($getopts->restOfLine ());
if (! file_exists ($configurationFile))
touch ($configurationFile);
$config = new configuration (); $config = new configuration ();
$config->confFile = $argv[1]; $config->confFile = $configurationFile;
$db = $config->get ("db"); $db = $config->get ("db");
$tables = $config->get ("tables"); $tables = $config->get ("tables");
$tablesRel = $config->get ("tablesRel"); $tablesRel = $config->get ("tablesRel");
@@ -84,7 +104,11 @@ class main
else else
$step = 6; $step = 6;
// TODO : Overload here the steps with the getopts if ($getopts->get ("Step"))
$step = intval ($getopts->get ("Step"));
if ($getopts->get ("Execute"))
$step = 5;
if ($step === 0) if ($step === 0)
{ {
// Step 0: ask the connection parameters // Step 0: ask the connection parameters
@@ -177,6 +201,9 @@ class main
echo "# For each destination table, if a source table is provided,\n". echo "# For each destination table, if a source table is provided,\n".
"# for each field, provide the source SQL request (can be field,\n". "# for each field, provide the source SQL request (can be field,\n".
"# CONCAT(), text between simple quotes, null...)\n"; "# CONCAT(), text between simple quotes, null...)\n";
if ($config->get("fields"))
$value = $config->get("fields");
else
$value = array (); $value = array ();
foreach ($tablesRel as $dstTable=>$srcTable) foreach ($tablesRel as $dstTable=>$srcTable)
{ {
@@ -199,11 +226,14 @@ class main
$value[$dstTable][$field] = ""; $value[$dstTable][$field] = "";
while (1) while (1)
{ {
$value[$dstTable][$field] = $this->ask ( $oldval = (isset ($config->get("fields")[$dstTable][$field])) ?
"Destination Table '$dstTable' field '$field'"); $config->get("fields")[$dstTable][$field] : "";
$answer = $this->ask (
"Destination Table '$dstTable' field '$field'", $oldval);
$value[$dstTable][$field] = $answer;
if (trim ($value[$dstTable][$field]) !== "") if (trim ($value[$dstTable][$field]) !== "")
continue 2; break;
// TODO : Check if the field is provided (think about function) // TODO : Check if the field is valid (think about function)
$this->error ("The field source must be defined !"); $this->error ("The field source must be defined !");
} }
} }
@@ -303,12 +333,15 @@ class main
$dstDB->primary ($dstSchema["primary"]); $dstDB->primary ($dstSchema["primary"]);
foreach ($srcDB->directQuery ($sql) as $row) foreach ($srcDB->directQuery ($sql) as $row)
{ {
echo ".";
//print_r ($row); //print_r ($row);
$dstDB->clearRequest (); $dstDB->clearRequest ();
$dstDB->insert () $dstDB->insert ()
->setValues ($row) ->setValues ($row);
->execute (); if (! $getopts->get ("Debug"))
echo ".";
else
echo $dstDB->getDisplayQuery ();
$dstDB->execute ();
} }
echo "\n"; echo "\n";
} }
@@ -322,12 +355,11 @@ class main
* @param string $question the question message * @param string $question the question message
* @return string The answer * @return string The answer
*/ */
public function ask ($question) public function ask ($question, $proposal = "")
{ {
echo "$question: "; $console = new console ();
$fp = fopen ("php://stdin", "r"); $console->echo ("$question: ");
$rc = trim (fgets ($fp)); return trim ($console->readline ($proposal));
return $rc;
} }
/** Display an error to the user /** Display an error to the user
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** The abstraction class of the users /** The abstraction class of the users
* Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file). * Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file).
* CRUD the users and allow to modify the password * CRUD the users and allow to modify the password
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/dblayer.php"); require_once ("domframework/dblayer.php");
require_once ("domframework/users.php"); require_once ("domframework/users.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Generate a UUID v4 /** Generate a UUID v4
*/ */
class uuid class uuid
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Permit to check the validity of fields /** Permit to check the validity of fields
*/ */
class verify class verify
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** This is the version of DomFramework. /** This is the version of DomFramework.
* It can be used to test if the framework is uptodate for the application * It can be used to test if the framework is uptodate for the application
* with : * with :
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
/** Create a diff from two strings, array or files /** Create a diff from two strings, array or files
* The output is compatible with "patch" command. * The output is compatible with "patch" command.
*/ */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD * @license BSD
*/ */
//namespace Domframework;
require_once ("domframework/tcpclient.php"); 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.