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
*/
//namespace Domframework;
/** User authentication (abstract class) */
class auth
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
require_once ("domframework/authparams.php");
require_once ("domframework/authsession.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against .htpasswd file
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
require_once ("domframework/imap.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/jwt.php");
require_once ("domframework/uuid.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against LDAP server */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** All the needed functions to authorize or deny access to an authenticated
user */
class authorization
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
error_reporting (E_ALL);
require_once ("domframework/dblayer.php");
require_once ("domframework/authorization.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Takes the email and the password of the user */
class authparams
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** User authentication against SESSION */
class authsession extends auth
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against Shibboleth */
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/dblayer.php");
require_once ("domframework/auth.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/auth.php");
/** User authentication against SYMPA server
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/dblayer.php");
/** All the needed functions to authorize or deny access to an authenticated
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/dblayeroo.php");
/** All the needed functions to authorize or deny access to an authenticated
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Display the backtrace in HTML with clicks to display the content
*/
class backtrace
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** A cache manager in file
*/
class cachefile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** This class permit to cache the ouptut of a code. If the cache is already
* available, use it.
* It resend the headers as the ouptut send them
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** An certificate authority
*/
class certificationauthority
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Allow to interract with controllers and models from the CLI */
class cli
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Convert the name of colors to RGB
*/
class color
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage the configurations of the module done by administrator in a config
* file
* It is based on the module configuration defaults
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** 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
* display directely on screen
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Convert a format to another one
*/
class convert
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** CSRF protection
* 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/fork.php");
require_once ("domframework/file.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** DBJSON : a NoSQL DB in JSON
* Documentation
* - A filter is an array containing the fields and the values to found
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
// dblayer.php
/* Documentation :
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/dblayer.php");
/** DBLayer with authorization
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Permit abstraction on the differents SQL databases available
*/
class dblayeroo
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Allow to encrypt/decrypt data
*/
class encrypt
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The file method allow to manage files like PHP with a working chroot on all
* plateforms, and a right management compatible with database
* Don't follow links !
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage the fork of children in Posix mode
*/
class fork
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/csrf.php");
/** This class permit to create easily some forms to HTML (or text mode in
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The Full Text Search
* 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/verify.php");
/** Manage the options provided on the command line
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/color.php");
/** This class allow to generate an image which is a graphic. A graphic takes
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** HTTP Helper : understand the best choices provided by browser, the HTTP
* codes
*/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/tcpclient.php");
/** This programe allow to get a HTTP page from a site, and examine the content.
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** IMAP connection abstraction
In the IMAP terminology, "mailbox" is a folder in the mailbox of the user */
class imap
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage .ini files like in php.ini
Support the sections (or not) */
class inifile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage the IP addresses conversions */
class ipaddresses
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/encrypt.php");
/** Allow to manage the JSON Web Tokens
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Language class : change the messages
*/
class language
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The lock management of files
*/
class lockfile
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The logger class permit to log the information from the soft
* It allow to debug too
*/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage the MAC addresses
* Based on :
* https://www.stetsenko.net/2011/01/php-mac-address-validating-and-formatting/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The class to create a complete email. Can read an email from a content
*/
class mail
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Convert the Markdown text to html format
*/
class markdown
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Module management
*/
class module
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Class used to display data
*/
class output
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
/** Display in CSV the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** 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
* paused transfert by getting the range of download.
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
/** Display in HTML the data provided, with the layout support
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
/** Display in JSON the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
require_once ("domframework/rest.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
/** Display in Text the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/output.php");
/** Display in XML the data provided
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** A class to manage the password hashing, password generation
*/
class password
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Manage a queue in multiple storages
* A process can add entries to the end of a queue
* A process can get all the entries in a queue
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/queue.php");
require_once ("domframework/file.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The rate limit abstract class
*/
class ratelimit
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/lockfile.php");
require_once ("domframework/ratelimit.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Display the data in HTML with a FLASH method to display the errors
*/
class renderer
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/http.php");
/** Allow to manage the REST protocol by using the users output types
+19 -8
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** This class analyze the provided robots.txt file content and allow to
* get the configured data for DomSearch.
* 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 ("/");
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
// User-Agent line arriving after a Allow/Disallow.
// Comments and empty lines are removed
@@ -82,14 +98,9 @@ class robotstxt
$line = trim ($content[$i]);
if (stripos ($line, "Sitemap:") === 0)
{
$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[$i] = dgettext ("domframework",
"Sitemap : Invalid URL provided");
// Already managed in the general parser. Not needed in the specific
// user-agent parser. Must at least be catched to not generate an
// error
}
elseif (stripos ($line, "Host:") === 0)
{
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/http.php");
require_once ("domframework/ratelimitfile.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/route.php");
require_once ("domframework/form.php");
require_once ("domframework/renderer.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/verify.php");
require_once ("domframework/convert.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** This class allow to read the sitemaps files available in websites, and give
* the available URL and parameters
*/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Allow to send mails by smtp
*/
class smtp
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require ("domframework/ipaddresses.php");
/** 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
*/
//namespace Domframework;
/** This class allow to manage Server-Sent Events
* 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
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** TCP Client
* Allow to create TCP connections to a server.
* 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
*/
//namespace Domframework;
/** 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
* 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.
*/
require_once ("domframework/console.php");
require_once ("domframework/dblayeroo.php");
require_once ("domframework/getopts.php");
require_once ("domframework/config.php");
@@ -56,13 +57,32 @@ class main
*/
public function __construct ()
{
global $argv;
if (! key_exists (1, $argv))
// Manage the Getopts
$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");
if (! file_exists ($argv[1]))
touch ($argv[1]);
if (count ($getopts->restOfLine ()) > 1)
throw new Exception ("Too much configuration file provided");
$configurationFile = current ($getopts->restOfLine ());
if (! file_exists ($configurationFile))
touch ($configurationFile);
$config = new configuration ();
$config->confFile = $argv[1];
$config->confFile = $configurationFile;
$db = $config->get ("db");
$tables = $config->get ("tables");
$tablesRel = $config->get ("tablesRel");
@@ -84,7 +104,11 @@ class main
else
$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)
{
// Step 0: ask the connection parameters
@@ -177,6 +201,9 @@ class main
echo "# For each destination table, if a source table is provided,\n".
"# for each field, provide the source SQL request (can be field,\n".
"# CONCAT(), text between simple quotes, null...)\n";
if ($config->get("fields"))
$value = $config->get("fields");
else
$value = array ();
foreach ($tablesRel as $dstTable=>$srcTable)
{
@@ -199,11 +226,14 @@ class main
$value[$dstTable][$field] = "";
while (1)
{
$value[$dstTable][$field] = $this->ask (
"Destination Table '$dstTable' field '$field'");
$oldval = (isset ($config->get("fields")[$dstTable][$field])) ?
$config->get("fields")[$dstTable][$field] : "";
$answer = $this->ask (
"Destination Table '$dstTable' field '$field'", $oldval);
$value[$dstTable][$field] = $answer;
if (trim ($value[$dstTable][$field]) !== "")
continue 2;
// TODO : Check if the field is provided (think about function)
break;
// TODO : Check if the field is valid (think about function)
$this->error ("The field source must be defined !");
}
}
@@ -303,12 +333,15 @@ class main
$dstDB->primary ($dstSchema["primary"]);
foreach ($srcDB->directQuery ($sql) as $row)
{
echo ".";
//print_r ($row);
$dstDB->clearRequest ();
$dstDB->insert ()
->setValues ($row)
->execute ();
->setValues ($row);
if (! $getopts->get ("Debug"))
echo ".";
else
echo $dstDB->getDisplayQuery ();
$dstDB->execute ();
}
echo "\n";
}
@@ -322,12 +355,11 @@ class main
* @param string $question the question message
* @return string The answer
*/
public function ask ($question)
public function ask ($question, $proposal = "")
{
echo "$question: ";
$fp = fopen ("php://stdin", "r");
$rc = trim (fgets ($fp));
return $rc;
$console = new console ();
$console->echo ("$question: ");
return trim ($console->readline ($proposal));
}
/** Display an error to the user
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** The abstraction class of the users
* Allow to manage the users in multiple storages (SQL, HTPasswd, passwd file).
* CRUD the users and allow to modify the password
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/dblayer.php");
require_once ("domframework/users.php");
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Generate a UUID v4
*/
class uuid
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Permit to check the validity of fields
*/
class verify
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** This is the version of DomFramework.
* It can be used to test if the framework is uptodate for the application
* with :
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
/** Create a diff from two strings, array or files
* The output is compatible with "patch" command.
*/
+2
View File
@@ -5,6 +5,8 @@
* @license BSD
*/
//namespace Domframework;
require_once ("domframework/tcpclient.php");
/** This class allow to send XMPP messages to a server.