NEW Add $dolibarr_main_db_readonly in conf.php for readonly access.
This commit is contained in:
parent
af8c973050
commit
3fadd5cda5
@ -327,6 +327,7 @@ $configfileparameters = array(
|
|||||||
'dolibarr_main_db_character_set' => $langs->trans("DBStoringCharset"),
|
'dolibarr_main_db_character_set' => $langs->trans("DBStoringCharset"),
|
||||||
'dolibarr_main_db_collation' => $langs->trans("DBSortingCollation"),
|
'dolibarr_main_db_collation' => $langs->trans("DBSortingCollation"),
|
||||||
'?dolibarr_main_db_prefix' => $langs->trans("DatabasePrefix"),
|
'?dolibarr_main_db_prefix' => $langs->trans("DatabasePrefix"),
|
||||||
|
'dolibarr_main_db_readonly' => $langs->trans("ReadOnlyMode"),
|
||||||
'separator2' => '',
|
'separator2' => '',
|
||||||
'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"),
|
'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"),
|
||||||
'?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"),
|
'?multicompany_transverse_mode'=> $langs->trans("MultiCompanyMode"),
|
||||||
@ -449,6 +450,13 @@ foreach ($configfileparameters as $key => $value) {
|
|||||||
if (!empty($valuetoshow)) {
|
if (!empty($valuetoshow)) {
|
||||||
print img_warning($langs->trans('SwitchThisForABetterSecurity', 0));
|
print img_warning($langs->trans('SwitchThisForABetterSecurity', 0));
|
||||||
}
|
}
|
||||||
|
} elseif ($newkey == 'dolibarr_main_db_readonly') {
|
||||||
|
print ${$newkey};
|
||||||
|
|
||||||
|
$valuetoshow = ${$newkey};
|
||||||
|
if (!empty($valuetoshow)) {
|
||||||
|
print img_warning($langs->trans('ReadOnlyMode', 1));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print (empty(${$newkey}) ? '' : ${$newkey});
|
print (empty(${$newkey}) ? '' : ${$newkey});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,6 +151,15 @@ $dolibarr_main_db_character_set='utf8';
|
|||||||
$dolibarr_main_db_collation='utf8_unicode_ci';
|
$dolibarr_main_db_collation='utf8_unicode_ci';
|
||||||
|
|
||||||
|
|
||||||
|
// dolibarr_main_db_readonly
|
||||||
|
// Set this to 1 to have the application working in readonly mode. All sql access INSERT/UPDATE/DELETE/CREATE/ALTER/TRUNCATE/DROP will be disabled.
|
||||||
|
// Default value: 0
|
||||||
|
// Examples:
|
||||||
|
// $dolibarr_main_db_readonly='0';
|
||||||
|
//
|
||||||
|
$dolibarr_main_db_readonly=0;
|
||||||
|
|
||||||
|
|
||||||
// dolibarr_main_instance_unique_id
|
// dolibarr_main_instance_unique_id
|
||||||
// An secret ID that is unique for each installation.
|
// An secret ID that is unique for each installation.
|
||||||
// This value is also visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption.
|
// This value is also visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption.
|
||||||
|
|||||||
@ -266,7 +266,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function query($query, $usesavepoint = 0, $type = 'auto')
|
public function query($query, $usesavepoint = 0, $type = 'auto')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $dolibarr_main_db_readonly;
|
||||||
|
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
|
|
||||||
@ -278,6 +278,15 @@ class DoliDBMysqli extends DoliDB
|
|||||||
return false; // Return false = error if empty request
|
return false; // Return false = error if empty request
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
if (preg_match('/^(INSERT|UPDATE|DELETE|CREATE|ALTER|TRUNCATE|DROP)/i', $query)) {
|
||||||
|
$this->lasterror = 'Application in read-only mode';
|
||||||
|
$this->lasterrno = 'APPREADONLY';
|
||||||
|
$this->lastquery = $query;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->database_name) {
|
if (!$this->database_name) {
|
||||||
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
|
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
|
||||||
$ret = $this->db->query($query);
|
$ret = $this->db->query($query);
|
||||||
|
|||||||
@ -498,7 +498,7 @@ class DoliDBPgsql extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function query($query, $usesavepoint = 0, $type = 'auto')
|
public function query($query, $usesavepoint = 0, $type = 'auto')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $dolibarr_main_db_readonly;
|
||||||
|
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
|
|
||||||
@ -527,6 +527,18 @@ class DoliDBPgsql extends DoliDB
|
|||||||
$SYSLOG_SQL_LIMIT = 10000; // limit log to 10kb per line to limit DOS attacks
|
$SYSLOG_SQL_LIMIT = 10000; // limit log to 10kb per line to limit DOS attacks
|
||||||
dol_syslog('sql='.substr($query, 0, $SYSLOG_SQL_LIMIT), LOG_DEBUG);
|
dol_syslog('sql='.substr($query, 0, $SYSLOG_SQL_LIMIT), LOG_DEBUG);
|
||||||
}
|
}
|
||||||
|
if (empty($query)) {
|
||||||
|
return false; // Return false = error if empty request
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
if (preg_match('/^(INSERT|UPDATE|DELETE|CREATE|ALTER|TRUNCATE|DROP)/i', $query)) {
|
||||||
|
$this->lasterror = 'Application in read-only mode';
|
||||||
|
$this->lasterrno = 'APPREADONLY';
|
||||||
|
$this->lastquery = $query;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$ret = @pg_query($this->db, $query);
|
$ret = @pg_query($this->db, $query);
|
||||||
|
|
||||||
|
|||||||
@ -397,7 +397,7 @@ class DoliDBSqlite3 extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function query($query, $usesavepoint = 0, $type = 'auto')
|
public function query($query, $usesavepoint = 0, $type = 'auto')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $dolibarr_main_db_readonly;
|
||||||
|
|
||||||
$ret = null;
|
$ret = null;
|
||||||
|
|
||||||
@ -455,6 +455,15 @@ class DoliDBSqlite3 extends DoliDB
|
|||||||
return false; // Return false = error if empty request
|
return false; // Return false = error if empty request
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
if (preg_match('/^(INSERT|UPDATE|DELETE|CREATE|ALTER|TRUNCATE|DROP)/i', $query)) {
|
||||||
|
$this->lasterror = 'Application in read-only mode';
|
||||||
|
$this->lasterrno = 'APPREADONLY';
|
||||||
|
$this->lastquery = $query;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
|
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
|
||||||
try {
|
try {
|
||||||
//$ret = $this->db->exec($query);
|
//$ret = $this->db->exec($query);
|
||||||
|
|||||||
@ -96,9 +96,12 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
|
|||||||
$date_start = dol_get_first_day($year_start, 10, false);
|
$date_start = dol_get_first_day($year_start, 10, false);
|
||||||
$date_end = dol_get_last_day($year_start, 12, false);
|
$date_end = dol_get_last_day($year_start, 12, false);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main
|
||||||
|
*/
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
@ -186,9 +189,6 @@ if ($resql) {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
$thirdpartystatic = new Societe($db);
|
$thirdpartystatic = new Societe($db);
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,11 @@ foreach ($argv as $key => $val) {
|
|||||||
|
|
||||||
$now = $argv[1];
|
$now = $argv[1];
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
print "Mails sending disabled (useless in batch mode)\n";
|
print "Mails sending disabled (useless in batch mode)\n";
|
||||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|||||||
@ -108,6 +108,11 @@ if ($key != $conf->global->CRON_KEY) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-only mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
// If param userlogin is reserved word 'firstadmin'
|
// If param userlogin is reserved word 'firstadmin'
|
||||||
if ($userlogin == 'firstadmin') {
|
if ($userlogin == 'firstadmin') {
|
||||||
$sql = 'SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1';
|
$sql = 'SELECT login, entity from '.MAIN_DB_PREFIX.'user WHERE admin = 1 and statut = 1 ORDER BY entity LIMIT 1';
|
||||||
|
|||||||
@ -86,6 +86,11 @@ if (!empty($conf->global->MAILING_DELAY)) {
|
|||||||
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {
|
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-only mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$user = new User($db);
|
$user = new User($db);
|
||||||
// for signature, we use user send as parameter
|
// for signature, we use user send as parameter
|
||||||
if (!empty($login)) {
|
if (!empty($login)) {
|
||||||
|
|||||||
@ -57,6 +57,7 @@ require_once DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php";
|
|||||||
$version = DOL_VERSION;
|
$version = DOL_VERSION;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main
|
* Main
|
||||||
*/
|
*/
|
||||||
@ -71,6 +72,11 @@ if (!in_array($type, array('all', 'thirdparties', 'contacts', 'users', 'members'
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,11 @@ if ($mode != 'confirm') {
|
|||||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,";
|
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,";
|
||||||
$sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
|
$sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
|
||||||
if ($targettype == 'contacts') {
|
if ($targettype == 'contacts') {
|
||||||
|
|||||||
@ -76,6 +76,11 @@ if ($mode != 'confirm') {
|
|||||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,";
|
$sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,";
|
||||||
$sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
|
$sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
|
|||||||
@ -52,6 +52,7 @@ $langs->load("main");
|
|||||||
$version = DOL_VERSION;
|
$version = DOL_VERSION;
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Main
|
* Main
|
||||||
*/
|
*/
|
||||||
@ -66,6 +67,11 @@ if (!isset($argv[1])) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$diroutputpdf = $conf->facture->dir_output.'/temp';
|
$diroutputpdf = $conf->facture->dir_output.'/temp';
|
||||||
$newlangid = 'en_EN'; // To force a new lang id
|
$newlangid = 'en_EN'; // To force a new lang id
|
||||||
$filter = array();
|
$filter = array();
|
||||||
|
|||||||
@ -68,6 +68,11 @@ foreach ($argv as $key => $val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$now = $argv[1];
|
$now = $argv[1];
|
||||||
|
|
||||||
print "Mails sending disabled (useless in batch mode)\n";
|
print "Mails sending disabled (useless in batch mode)\n";
|
||||||
|
|||||||
@ -146,6 +146,11 @@ if ($typeid <= 0) {
|
|||||||
exit(-2);
|
exit(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||||
$input = trim(fgets(STDIN));
|
$input = trim(fgets(STDIN));
|
||||||
|
|||||||
@ -70,6 +70,12 @@ dol_syslog($script_file." launched with arg ".join(',', $argv));
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT rowid";
|
$sql = "SELECT rowid";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
||||||
|
|
||||||
|
|||||||
@ -88,6 +88,11 @@ foreach ($argv as $key => $val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
print "Mails sending disabled (useless in batch mode)\n";
|
print "Mails sending disabled (useless in batch mode)\n";
|
||||||
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; // On bloque les mails
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|||||||
@ -63,8 +63,18 @@ include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main
|
||||||
|
*/
|
||||||
|
|
||||||
$langs->load('main');
|
$langs->load('main');
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$joomlaserverinfoarray = preg_split('/(:|@|\/)/', $joomlaserverinfo);
|
$joomlaserverinfoarray = preg_split('/(:|@|\/)/', $joomlaserverinfo);
|
||||||
$joomlalogin = $joomlaserverinfoarray[0];
|
$joomlalogin = $joomlaserverinfoarray[0];
|
||||||
$joomlapass = $joomlaserverinfoarray[1];
|
$joomlapass = $joomlaserverinfoarray[1];
|
||||||
|
|||||||
@ -58,8 +58,18 @@ include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main
|
||||||
|
*/
|
||||||
|
|
||||||
$langs->load('main');
|
$langs->load('main');
|
||||||
|
|
||||||
|
if (!empty($dolibarr_main_db_readonly)) {
|
||||||
|
print "Error: instance in read-onyl mode\n";
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
$website = new Website($db);
|
$website = new Website($db);
|
||||||
$result = $website->fetch(0, $websiteref);
|
$result = $website->fetch(0, $websiteref);
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user