2
0
forked from Wavyzz/dolibarr

Fix: seul le superadmin peut changer la config de syslog

This commit is contained in:
Regis Houssin
2009-05-07 09:06:57 +00:00
parent 1359c09238
commit f1a5c6fae3
8 changed files with 30 additions and 40 deletions

View File

@@ -39,7 +39,7 @@ $langs->load("other");
*/
if (! empty($_POST["action"]) && $_POST["action"] == 'setlevel')
{
dolibarr_set_const($db,"SYSLOG_LEVEL",$_POST["level"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db,"SYSLOG_LEVEL",$_POST["level"],'chaine',0,'',0);
dol_syslog("admin/syslog: level ".$_POST["level"]);
}
@@ -53,8 +53,8 @@ if (! empty($_POST["action"]) && $_POST["action"] == 'set')
// Only LOG_USER supported on Windows
if (! empty($_SERVER["WINDIR"])) $_POST["facility"]='LOG_USER';
dolibarr_del_const($db,"SYSLOG_FILE",$conf->entity);
dolibarr_set_const($db,"SYSLOG_FACILITY",$_POST["facility"],'chaine',0,'',$conf->entity);
dolibarr_del_const($db,"SYSLOG_FILE",0);
dolibarr_set_const($db,"SYSLOG_FACILITY",$_POST["facility"],'chaine',0,'',0);
dol_syslog("admin/syslog: facility ".$_POST["facility"]);
}
else
@@ -71,8 +71,8 @@ if (! empty($_POST["action"]) && $_POST["action"] == 'set')
if ($file)
{
fclose($file);
dolibarr_del_const($db,"SYSLOG_FACILITY",$conf->entity);
dolibarr_set_const($db,"SYSLOG_FILE",$_POST["filename"],'chaine',0,'',$conf->entity);
dolibarr_del_const($db,"SYSLOG_FACILITY",0);
dolibarr_set_const($db,"SYSLOG_FILE",$_POST["filename"],'chaine',0,'',0);
dol_syslog("admin/syslog: file ".$_POST["filename"]);
}
else
@@ -97,12 +97,18 @@ print '<br>';
$def = array();
$syslogfacility=$defaultsyslogfacility=dolibarr_get_const($db,"SYSLOG_FACILITY",$conf->entity);
$syslogfile=$defaultsyslogfile=dolibarr_get_const($db,"SYSLOG_FILE",$conf->entity);
$syslogfacility=$defaultsyslogfacility=dolibarr_get_const($db,"SYSLOG_FACILITY",0);
$syslogfile=$defaultsyslogfile=dolibarr_get_const($db,"SYSLOG_FILE",0);
if (! $defaultsyslogfacility) $defaultsyslogfacility='LOG_USER';
if (! $defaultsyslogfile) $defaultsyslogfile='dolibarr.log';
if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity)
{
print '<div class="error">'.$langs->trans("ContactSuperAdminForChange").'</div>';
$option = 'disabled="disabled"';
}
// Output mode
print_titre($langs->trans("SyslogOutput"));
@@ -112,21 +118,20 @@ print '<input type="hidden" name="action" value="set">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Parameter").'</td>';
print '<td align="right" colspan="2"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '<td align="right" colspan="2"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=true;
$var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlogoutput\" value=\"syslog\" ".($syslogfacility?" checked":"")."> ".$langs->trans("SyslogSyslog")."</td>";
print '<td colspan="3">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" value="'.$defaultsyslogfacility.'">';
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="syslog" '.($syslogfacility?" checked":"").'> '.$langs->trans("SyslogSyslog").'</td>';
print '<td colspan="3">'.$langs->trans("SyslogFacility").': <input type="text" class="flat" name="facility" '.$option.' value="'.$defaultsyslogfacility.'">';
print ' '.img_info('Only LOG_USER supported on Windows');
print '</td></tr>';
$var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlogoutput\" value=\"file\"".($syslogfile?" checked":"")."> ".$langs->trans("SyslogSimpleFile")."</td>";
print '<td width="250" nowrap>'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" size="60" value="'.$defaultsyslogfile.'">';
print '<tr '.$bc[$var].'><td width="140"><input '.$bc[$var].' type="radio" name="optionlogoutput" '.$option.' value="file" '.($syslogfile?" checked":"").'> '.$langs->trans("SyslogSimpleFile").'</td>';
print '<td width="250" nowrap>'.$langs->trans("SyslogFilename").': <input type="text" class="flat" name="filename" '.$option.' size="60" value="'.$defaultsyslogfile.'">';
print '</td>';
$htmltext = $langs->trans("SyslogFilenameDesc",$conf->syslog->dir_output);
print "<td align=\"left\">".$html->textwithpicto('',$htmltext);
print "<td align=\"left\">".$html->textwithpicto('',$langs->trans("YouCanUseDOL_DATA_ROOT"));
print '</td></tr>';
print "</table>\n";
@@ -138,12 +143,12 @@ print '<input type="hidden" name="action" value="setlevel">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Parameter").'</td>';
print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '<td align="right"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n";
$var=true;
$var=!$var;
print '<tr '.$bc[$var].'><td width=\"140\">'.$langs->trans("SyslogLevel").'</td>';
print '<td colspan="2"><select class="flat" name="level">';
print '<td colspan="2"><select class="flat" name="level" '.$option.'>';
print '<option value="'.LOG_EMERG.'" '.($conf->global->SYSLOG_LEVEL==LOG_EMERG?'SELECTED':'').'>LOG_EMERG ('.LOG_EMERG.')</option>';
print '<option value="'.LOG_ALERT.'" '.($conf->global->SYSLOG_LEVEL==LOG_ALERT?'SELECTED':'').'>LOG_ALERT ('.LOG_ALERT.')</option>';
print '<option value="'.LOG_CRIT.'" '.($conf->global->SYSLOG_LEVEL==LOG_CRIT?'SELECTED':'').'>LOG_CRIT ('.LOG_CRIT.')</option>';

View File

@@ -787,7 +787,7 @@ LDAPGroupsSynchro=Groups
LDAPContactsSynchro=Contacts
LDAPMembersSynchro=Members
LDAPSynchronization=LDAP synchronisation
LDAPFunctionsNotAvailableOnPHP=LDAP functions are not availbale on your PHP
LDAPFunctionsNotAvailableOnPHP=LDAP functions are not available on your PHP
LDAPToDolibarr=LDAP -> Dolibarr
DolibarrToLDAP=Dolibarr -> LDAP
LDAPNamingAttribute=Key in LDAP
@@ -927,7 +927,7 @@ SyslogFacility=Facility
SyslogLevel=Level
SyslogSimpleFile=File
SyslogFilename=File name and path
SyslogFilenameDesc = This log file is located by default in the directory:<br><b>%s</b><br><br>You can set a different path to store this file.
YouCanUseDOL_DATA_ROOT=You can use DOL_DATA_ROOT/dolibarr.log for a log file in Dolibarr "documents" directory. You can set a different path to store this file.
ErrorUnknownSyslogConstant=Constant %s is not a known syslog constant
##### Donations #####
DonationsSetup=Donation module setup

View File

@@ -926,7 +926,7 @@ SyslogFacility = Facility
SyslogLevel = Niveau
SyslogSimpleFile = Fichier
SyslogFilename = Nom et chemin du fichier
SyslogFilenameDesc = Ce fichier de log est situé par défaut dans le répertoire:<br><b>%s</b><br><br>Vous pouvez néanmoins définir un chemin différent pour stocker ce fichier.
YouCanUseDOL_DATA_ROOT = Vous pouvez utiliser DOL_DATA_ROOT/dolibarr.log pour un log dans le répertoire "documents" de Dolibarr. Vous pouvez néanmoins définir un chemin différent pour stocker ce fichier.
ErrorUnknownSyslogConstant = La constante %s n'est pas une constante syslog connue
##### Donations ##### = undefined
DonationsSetup = Configuration du module Dons

View File

@@ -200,11 +200,6 @@ function dol_syslog($message, $level=LOG_INFO)
{
$filelog=SYSLOG_FILE;
$filelog=eregi_replace('DOL_DATA_ROOT',DOL_DATA_ROOT,$filelog);
// Check if syslog module has been setup with a full path
if (! eregi('(^[A-Za-z0-9_\-\\/:]+[\\/]+)([A-Za-z0-9_\-]+[.]?[A-Za-z0-9]+)?$', SYSLOG_FILE) && ! empty($conf->syslog->dir_output))
{
$filelog = $conf->syslog->dir_output."/".$filelog;
}
if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen($filelog,"a+");
else $file=fopen($filelog,"a+");

View File

@@ -284,12 +284,6 @@ if (! isset($_SESSION["dol_login"]))
{
$test=false;
$conf->authmode=$mode; // This properties is defined only when logged
// TODO Call function to check entity
if ($conf->multicompany->enabled && isset($_POST["entity"]))
{
$entitytotest=$_POST["entity"];
}
}
}
else

View File

@@ -114,10 +114,6 @@ require_once(DOL_DOCUMENT_ROOT."/core/conf.class.php");
$conf = new Conf();
// Retrieve the entity
// Removed: The session has not been initialized yet so using SESSION is forbidden here
//if (isset($_SESSION["dol_entity"])) $conf->entity = $_SESSION["dol_entity"];
// Identifiant propres au serveur base de donnee
$conf->db->host = $dolibarr_main_db_host;
if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=0; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql'

View File

@@ -1225,7 +1225,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 0";
$sql.= " AND p.fk_user_author = ".$user->id;
$sql.= " ORDER BY p.datec DESC, tms DESC";
@@ -1342,7 +1342,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$sql = "SELECT s.nom, s.rowid as socid, c.rowid as commandeid, c.ref,".$db->pdate("c.date_commande")." as dc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql.= " WHERE c.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " AND c.fk_statut = 0";
$sql.= " AND c.fk_user_author = ".$user->id;
$sql.= " ORDER BY c.date_creation DESC";
@@ -1455,7 +1455,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut = 0";
$sql.= " AND f.fk_user_author = ".$user->id;
$sql.= " ORDER BY f.datec DESC, f.rowid DESC";
@@ -1516,7 +1516,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$sql = "SELECT s.nom, s.rowid as socid, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut = 0";
$sql.= " AND f.fk_user_author <> ".$user->id;
$sql.= " ORDER BY f.datec DESC, f.rowid DESC";

View File

@@ -3,8 +3,8 @@
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auuguria.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by