diff --git a/bureau/admin/cron.php b/bureau/admin/cron.php index 9422cd41..e1912153 100755 --- a/bureau/admin/cron.php +++ b/bureau/admin/cron.php @@ -8,10 +8,8 @@ $fields = array ( getFields($fields); if (!empty($cronupdate)) { - if (! $cron->update($cronupdate)) { - $error=$err->errstr(); - } else { - $error=_("Save done."); + if ($cron->update($cronupdate)) { + $msg->raise("ok", "mysql", _("Save done.")); } } @@ -22,9 +20,9 @@ $lst_cron = $cron->lst_cron();

- -

- +msg_html_all() +?>
diff --git a/bureau/admin/favicon.ico b/bureau/admin/favicon.ico index 4893b459..c34bfd95 100644 Binary files a/bureau/admin/favicon.ico and b/bureau/admin/favicon.ico differ diff --git a/bureau/admin/index.php b/bureau/admin/index.php index 0763c50d..26f19d0a 100755 --- a/bureau/admin/index.php +++ b/bureau/admin/index.php @@ -26,15 +26,12 @@ require_once("../class/config_nochk.php"); -if ($mem->checkid()) { +if ($mem->checkid(false)) { Header("Location: /main.php"); exit; } -if (!$mem->del_session()) { - // No need to draw an error message ... - //$error=$err->errstr(); -} +$mem->del_session(); $H=getenv("HTTP_HOST"); @@ -72,11 +69,10 @@ if ( empty($logo) || ! $logo ) { $logo = 'images/logo.png'; } ?> - -

 

- $error"; ?> + msg_html_all(); ?>
ip_affected_save($s_ipsub, $s_protocol, $$val) ) { - $error="Error during ip_affected_save"; + $msg->raise('Error', "ftp", _("Error during ip_affected_save")); // à traduire } } if (!empty($delete_affected_id)) { if (! $authip->ip_affected_delete($delete_affected_id)) { - $error="Error during deletion"; + $msg->raise('Error', "ftp", _("Error during deletion")); // à traduire } } if (!empty($delete_id)) { if (! $authip->ip_delete($delete_id)) { - $error="Error during deletion"; + $msg->raise('Error', "ftp", _("Error during deletion")); // à traduire } } if (!empty($ipsub)) { if (! $authip->ip_save($id, $ipsub, $infos)) { - $error="Error during recording"; + $msg->raise('Error', "ftp", _("Error during recording")); // à traduire } } @@ -51,9 +51,9 @@ $lac = $authip->list_affected();

- -

- +msg_html_all(); +?>

@@ -164,7 +164,7 @@ foreach($list_ip as $i) { } echo "{$i['infos']}{$i['ip_human']}$txt"; ?> -
);">
+
);">
">
@@ -174,7 +174,7 @@ foreach($list_ip as $i) {

-

);" >

+

);" >

diff --git a/bureau/admin/logs_download.php b/bureau/admin/logs_download.php index f8ec3397..23237506 100644 --- a/bureau/admin/logs_download.php +++ b/bureau/admin/logs_download.php @@ -34,9 +34,5 @@ $fields = array ( ); getFields($fields); -if (empty($file)) { -$error=""; -} - $log->download_link($file); ?> diff --git a/bureau/admin/logs_list.php b/bureau/admin/logs_list.php index ab7ffa1b..cc260922 100644 --- a/bureau/admin/logs_list.php +++ b/bureau/admin/logs_list.php @@ -36,11 +36,11 @@ $list=$log->list_logs_directory_all($log->get_logs_directory());

$error

"; -} +echo $msg->msg_html_all(); + if(!$list || empty($list['dir'])){ - echo "

"._("You have no web logs to list at the moment.")."

"; + $msg->raise('Info', "logs", _("You have no web logs to list at the moment.")); + echo $msg->msg_html_all(); include_once('foot.php'); exit; } diff --git a/bureau/admin/logs_tail.php b/bureau/admin/logs_tail.php index b268ceb4..ad83df2e 100644 --- a/bureau/admin/logs_tail.php +++ b/bureau/admin/logs_tail.php @@ -36,10 +36,6 @@ $fields = array ( ); getFields($fields); -if (empty($file)) { -$error=""; -} - include_once("head.php"); $string=$log->tail($file,$lines); @@ -63,7 +59,7 @@ if (!$string) { } ?> @@ -73,11 +69,7 @@ eoption($alines,$lines);

$error

"; -} - - +echo $msg->msg_html_all(); ?>
",$mem->user["lastfail"]);
 }
 
+echo $msg->msg_html_all();
 if (!empty($error) ) { echo "

$error

";$error=''; } $feed_url = variable_get('rss_feed', '', 'This is an RSS feed that will be displayed on the users homepages when they log in.', array('desc'=>'URL','type'=>'string')); diff --git a/bureau/admin/menu.php b/bureau/admin/menu.php index 1c0a4026..bab8291e 100644 --- a/bureau/admin/menu.php +++ b/bureau/admin/menu.php @@ -31,12 +31,14 @@ require_once("../class/config.php"); // Getting logo $logo = variable_get('logo_menu', '' ,'You can specify a logo for the menu, example /images/my_logo.png .', array('desc'=>'URL','type'=>'string')); -if ( empty($logo) || ! $logo ) { - $logo = 'images/logo3.png'; -} +echo '"; ?> -

user["login"]); ?>

raise('Info', "mail", _("There is currently no webmail configured. If you need one, contact your server administrator"); include("index.php"); diff --git a/bureau/admin/styles/style.css b/bureau/admin/styles/style.css index 78c3dc62..5dc859c9 100644 --- a/bureau/admin/styles/style.css +++ b/bureau/admin/styles/style.css @@ -283,6 +283,7 @@ img { } .alert > p, .alert > ul { margin-bottom: 0; + margin-top: 0; } .alert > p + p { margin-top: 5px; @@ -351,7 +352,7 @@ img { /* Alert icons */ #content .alert { - background-position: 12px 10px; + background-position: 12px center; background-repeat: no-repeat; padding-left: 48px; } @@ -610,11 +611,11 @@ table.searchtable td { } -#newdomwww, #sub, #usernpfx, #dbnpfx { +#newdomwww, #sub, #usernpfx, #dbnpfx, #account_namefx { border-right: 0; padding-right: 0; } -#newdomain, #newsubname, #usern, #dbn { +#newdomain, #newsubname, #usern, #dbn, #account_name { border-left: 0; padding-left: 0; } diff --git a/bureau/admin/vm.php b/bureau/admin/vm.php index 6c9c3dc9..97088eda 100755 --- a/bureau/admin/vm.php +++ b/bureau/admin/vm.php @@ -53,15 +53,9 @@ include_once("head.php");

- -
- - - - -
-
- +msg_html_all(); +?>
log("action", "do_action"); + global $msg, $L_INOTIFY_DO_ACTION; + $msg->log("action", "do_action"); if (!@touch($L_INOTIFY_DO_ACTION)) { return FALSE; } @@ -152,14 +152,14 @@ class m_action { * * @global int $cuid * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @param string $archive Directory to archive within the archive_del_data folder if set in variable sql table * If archive_del_data is not set we delete the folder * @param string $dir sub_directory of the archive directory * @return boolean */ function archive($archive, $dir = "html") { - global $cuid, $db, $err; + global $cuid, $db, $msg; $arch = variable_get('archive_del_data'); if (empty($arch)) { @@ -170,7 +170,7 @@ class m_action { $db->query("select login from membres where uid= ?;", array($cuid)); $db->next_record(); if (!$db->Record["login"]) { - $err->raise("action", _("Login corresponding to $cuid not found")); + $msg->raise('Error', "action", _("Login corresponding to $cuid not found")); return false; } $uidlogin = $cuid . "-" . $db->Record["login"]; @@ -187,15 +187,15 @@ class m_action { * function inserting the action in the sql table * * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @param string $type * @param string|integer $user wich user do we impersonate? * @param mixed $parameters * @return boolean */ function set($type, $user, $parameters) { - global $db, $err; - $err->log("action", "set", $type); + global $db, $msg; + $msg->log("action", "set", $type); $serialized = serialize($parameters); $type = strtoupper($type); if (in_array($type, array('CHMOD', @@ -212,7 +212,7 @@ class m_action { } if (!$db->query($query)) { - $err->raise("action", _("Error setting actions")); + $msg->raise('Error', "action", _("Error setting actions")); return false; } return $this->do_action(); @@ -221,17 +221,17 @@ class m_action { /** * This seems to be unused ? * - * @global m_err $err + * @global m_messages $msg * @global m_mysql $db * @return boolean */ function get_old() { - global $err, $db; + global $msg, $db; $purge = "select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;"; $result = $db->query($purge); if (!$result) { - $err->raise("action", _("Error selecting old actions")); + $msg->raise('Error', "action", _("Error selecting old actions")); return false; } return $db->num_rows($result); @@ -239,13 +239,13 @@ class m_action { /** * - * @global m_err $err + * @global m_messages $msg * @global m_mysql $db * @param type $all * @return boolean */ function purge($all = null) { - global $err, $db; + global $msg, $db; if (is_null($all)) { $purge = "delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2 and status = 0;"; } else { @@ -253,7 +253,7 @@ class m_action { } $result = $db->query($purge); if (!$result) { - $err->raise("action", _("Error purging old actions")); + $msg->raise('Error', "action", _("Error purging old actions")); return false; } return $db->num_rows($result); @@ -263,11 +263,10 @@ class m_action { * function returning the first not locked line of the action table * * @global m_mysql $db - * @global m_err $err * @return boolean or array */ function get_action() { - global $db, $err; + global $db; $tab = array(); $db->query('select * from actions where end = 0 and begin = 0 order by id limit 1;'); @@ -283,14 +282,14 @@ class m_action { * function locking an entry while it is being executed by the action script * * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @param int $id * @return boolean */ function begin($id) { - global $db, $err; + global $db, $msg; if (!$db->query("update actions set begin=now() where id= ? ;", array($id))) { - $err->raise("action", _("Error locking the action : $id")); + $msg->raise('Error', "action", _("Error locking the action : $id")); return false; } return true; @@ -300,15 +299,15 @@ class m_action { * function locking an entry while it is being executed by the action script * * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @param int $id * @param integer $return * @return boolean */ function finish($id, $return = 0) { - global $db, $err; + global $db, $msg; if (!$db->query("update actions set end=now(),status=? where id= ?;", array($return, $id))) { - $err->raise("action", _("Error unlocking the action : $id")); + $msg->raise('Error', "action", _("Error unlocking the action : $id")); return false; } return true; @@ -317,14 +316,14 @@ class m_action { /** * * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @param int $id * @return boolean */ function reset_job($id) { - global $db, $err; + global $db, $msg; if (!$db->query("update actions set end=0,begin=0,status='' where id= ?;", array($id))) { - $err->raise("action", _("Error unlocking the action : $id")); + $msg->raise('Error', "action", _("Error unlocking the action : $id")); return false; } return true; @@ -334,7 +333,7 @@ class m_action { * Returns a list of actions marked as executable and ready for execution * * @global m_mysql $db - * @global m_err $err + * @global m_messages $msg * @return boolean */ function get_job() { diff --git a/bureau/class/m_authip.php b/bureau/class/m_authip.php index 0f8c74bf..c8d77bd0 100644 --- a/bureau/class/m_authip.php +++ b/bureau/class/m_authip.php @@ -102,7 +102,7 @@ class m_authip { * @return boolean Retourne FALSE si erreur, sinon TRUE */ function ip_delete($id) { - global $db, $cuid; + global $db, $cuid, $msg; $id = intval($id); $db->query("SELECT id FROM authorised_ip_affected where authorised_ip_id = ?;", array($id)); @@ -110,7 +110,7 @@ class m_authip { $this->ip_affected_delete($db->f('id')); } if (!$db->query("delete from authorised_ip where id= ? and ( uid= ? or uid=0) limit 1;", array($id, $cuid))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } return true; @@ -126,9 +126,9 @@ class m_authip { * @return array */ function get_allowed($s) { - global $db, $cuid; + global $db, $cuid, $msg; if (!$db->query("select ai.ip, ai.subnet, ai.infos, aia.parameters from authorised_ip ai, authorised_ip_affected aia where aia.protocol= ? and aia.authorised_ip_id = ai.id and ai.uid= ?;", array($s, $cuid))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } $r = Array(); @@ -145,9 +145,9 @@ class m_authip { * @return boolean */ function is_wl($ip) { - global $db; + global $db, $msg; if (!$db->query("select ai.ip, ai.subnet from authorised_ip ai where ai.uid='0';")) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } while ($db->next_record()) { @@ -205,7 +205,7 @@ class m_authip { * */ function ip_save($id, $ipsub, $infos, $uid = null) { - global $db, $mem; + global $db, $mem, $msg; // If we ask for uid=0, we have to check to be super-user // else, juste use global cuid; @@ -216,7 +216,7 @@ class m_authip { } $id = intval($id); - $infos = mysql_real_escape_string($infos); + $infos = $db->quote(trim($infos)); // Extract subnet from ipsub $tmp = explode('/', $ipsub); @@ -224,7 +224,7 @@ class m_authip { // Error if $ip not an IP if (!checkip($ip) && !checkipv6($ip)) { - echo "Failed : not an IP address"; + $msg->raise('Error', 'authip', _("Failed : not an IP address")); // à traduire return false; } @@ -249,8 +249,8 @@ class m_authip { foreach ($list_affected as $k => $v) { $this->call_hooks("authip_on_delete", $k); } - if (!$db->query("update authorised_ip set ip= ?, subnet= ?, infos= ? where id= ? and uid=? ;", array($id, $subnetn, $infos, $id, $cuid))) { - echo "query failed: " . $db->Error; + if (!$db->query("update authorised_ip set ip= ?, subnet= ?, infos= ? where id= ? and uid=? ;", array($ip, $subnet, $infos, $id, $cuid))) { + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } foreach ($list_affected as $k => $v) { @@ -258,7 +258,7 @@ class m_authip { } } else { // Insert if (!$db->query("insert into authorised_ip (uid, ip, subnet, infos) values (?, ?, ?, ?);", array($cuid, $ip, $subnet, $infos))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } } @@ -313,20 +313,20 @@ class m_authip { * @return boolean Retourne FALSE si erreur, sinon TRUE */ function ip_affected_save($authorised_ip_id, $protocol, $parameters, $id = null) { - global $db; + global $db, $msg; $authorised_ip_id = intval($authorised_ip_id); if ($id) { $id = intval($id); $this->call_hooks("authip_on_delete", $id); if (!$db->query("update authorised_ip_affected set authorised_ip_id= ?, protocol= ?, parameters= ? where id = ? limit 1;", array($authorised_ip_id, $protocol, $parameters, $id))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } $this->call_hooks("authip_on_create", $id); } else { if (!$db->query("insert into authorised_ip_affected (authorised_ip_id, protocol, parameters) values (?, ?, ?);", array($authorised_ip_id, $protocol, $parameters))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } $this->call_hooks("authip_on_create", $db->lastid()); @@ -344,14 +344,14 @@ class m_authip { * @return boolean Retourne FALSE si erreur, sinon TRUE */ function ip_affected_delete($id) { - global $db; + global $db, $msg; $id = intval($id); // Call hooks $this->call_hooks("authip_on_delete", $id); if (!$db->query("delete from authorised_ip_affected where id= ? limit 1;", array($id))) { - echo "query failed: " . $db->Error; + $msg->raise('Error', 'authip', _("query failed: " . $db->Error)); return false; } return true; @@ -362,18 +362,18 @@ class m_authip { * affectationt ip<=>ressource dont l'id est en parametre * * @global m_hooks $hooks - * @global m_err $err + * @global m_messages $msg * @param string $function Nom de la fonction a rechercher et appeller dans les classes * @param integer $affectation_id Id de l'affectation correspondante * @return boolean Retourne TRUE */ function call_hooks($function, $affectation_id) { - global $hooks, $err; + global $hooks, $msg; // On récure l'objet dont on parle $d = $this->list_affected(); if (!isset($d[$affectation_id])) { - $err->raise('authip', _("Object not available")); + $msg->raise('Error', 'authip', _("Object not available")); return false; } @@ -382,7 +382,7 @@ class m_authip { // On en déduis la classe qui le concerne $e = $this->get_auth_class(); if (!isset($e[$affectation['protocol']])) { - $err->raise('authip', sprintf(_("Can't identified class for the protocole %s"), $affectation['protocol'])); + $msg->raise('Error', 'authip', sprintf(_("Can't identified class for the protocole %s"), $affectation['protocol'])); return false; } $c = $e[$affectation['protocol']]['class']; diff --git a/bureau/class/m_cron.php b/bureau/class/m_cron.php index b439477b..bba8214d 100644 --- a/bureau/class/m_cron.php +++ b/bureau/class/m_cron.php @@ -54,8 +54,8 @@ class m_cron { * @return array an hash for each crontab. */ function lst_cron() { - global $cuid, $db, $err; - $err->log("cron", "lst_cron"); + global $cuid, $db, $msg; + $msg->log("cron", "lst_cron"); $db->query("SELECT * FROM cron WHERE uid = ? ORDER BY url;", array($cuid)); $r = Array(); while ($db->next_record()) { @@ -112,8 +112,8 @@ class m_cron { * @return boolean TRUE if the crontab has been deleted */ function delete_one($id) { - global $db, $err, $cuid; - $err->log("cron", "delete_one"); + global $db, $msg, $cuid; + $msg->log("cron", "delete_one"); return $db->query("DELETE FROM cron WHERE id= ? AND uid= ? LIMIT 1;", array(intval($id), $cuid)); } @@ -123,8 +123,8 @@ class m_cron { * @return boolean TRUE if the crontab has been edited */ private function _update_one($url, $user, $password, $email, $schedule, $id = null) { - global $db, $err, $quota, $cuid; - $err->log("cron", "update_one"); + global $db, $msg, $quota, $cuid; + $msg->log("cron", "update_one"); if (empty($url) && !is_null($id)) { return $this->delete_one($id); @@ -132,7 +132,7 @@ class m_cron { if (filter_var($url, FILTER_VALIDATE_URL) === false) { - $err->raise("cron", _("URL not valid")); + $msg->raise('Error', "cron", _("URL not valid")); return false; } $url = urlencode($url); @@ -144,7 +144,7 @@ class m_cron { //@todo remove checkmail cf functions.php if (!empty($email) && !checkmail($email) == 0) { - $err->raise("cron", _("Email address is not valid")); + $msg->raise('Error', "cron", _("Email address is not valid")); return false; } $email = urlencode($email); @@ -155,7 +155,7 @@ class m_cron { if (is_null($id)) { // if a new insert, quotacheck $q = $quota->getquota("cron"); if ($q["u"] >= $q["t"]) { - $err->raise("cron", _("You quota of cron entries is over. You cannot create more cron entries")); + $msg->raise('Error', "cron", _("You quota of cron entries is over. You cannot create more cron entries")); return false; } } else { // if not a new insert, check the $cuid @@ -163,8 +163,8 @@ class m_cron { if (!$db->next_record()) { return "false"; } // return false if pb - if ($db->f('uid') != $cuid) { - $err->raise("cron", _("Identity problem")); + if ($db->f('uid') != $cuid) { + $msg->raise('Error', "cron", _("Identity problem")); return false; } } @@ -196,8 +196,8 @@ class m_cron { /** hook for quota computation */ function hook_quota_get() { - global $cuid, $db, $err; - $err->log("cron", "alternc_get_quota"); + global $cuid, $db, $msg; + $msg->log("cron", "alternc_get_quota"); $q = Array("name" => "cron", "description" => _("Scheduled tasks"), "used" => 0); $db->query("select count(*) as cnt from cron where uid = ? ;", array($cuid)); if ($db->next_record()) { diff --git a/bureau/class/m_err.php b/bureau/class/m_err.php deleted file mode 100644 index e9c4d93a..00000000 --- a/bureau/class/m_err.php +++ /dev/null @@ -1,144 +0,0 @@ -Cette classe gère les erreurs qui peuvent apparaitre lors d'appels - * à l'API d'AlternC. Ces erreurs sont stockées sous la forme de 2 nombres - * (Classe ID et Numéro d'erreur) ainsi qu'un texte facultatif associé. - * Des textes d'erreurs localisés sont aussi disponibles.

- *

Cette classe se charge aussi d'insérer les appels à l'API d'AlternC - * dans les logs du système dans /var/log/alternc/bureau.log - *

- * Copyleft {@link http://alternc.net/ AlternC Team} - * - * @copyright AlternC-Team 2002-11-01 http://alternc.net/ - */ -class m_err { - - /** Numero de classe d'erreur actuelle */ - var $clsid = 0; - - /** Dernière erreur enregistrée par la classe */ - var $error = 0; - - /** Paramètre chaine eventuellement associé à la dernière erreur */ - var $param = ""; - - /** Emplacement du fichier de logs d'AlternC */ - var $logfile = "/var/log/alternc/bureau.log"; - - /** - * Leve une erreur, signale celle-ci dans les logs et stocke le code erreur - * - * Cette fonction lance une erreur, l'ajoute dans les logs d'AlternC, - * et la met à disposition pour le bureau virtuel pour affichage ultérieur. - * - * @todo ne plus utiliser $error de façon numérique, nulle part - * - * @param integer $clsid Classe qui lève l'erreur - * @param mixed $error Numéro de l'erreur ou chaîne décrivant l'erreur - * @param string $param Paramètre chaine associé à l'erreur (facultatif) - * @return boolean TRUE si l'erreur est connue, FALSE sinon. - * - */ - function raise($clsid, $error, $param = "") { - /* Leve une exception. Si elle existe, sinon, stocke un message d'erreur sur erreur ... */ - if (_("err_" . $clsid . "_" . $error) != "err_" . $clsid . "_" . $error || is_string($error)) { - $this->clsid = $clsid; - $this->error = $error; - $args = func_get_args(); - $this->param = array_slice($args, 2); - $this->logerr(); - return true; - } else { - $this->clsid = "err"; - $this->error = 1; - $this->param = "Error # $error in Class $clsid, Value is $param. (sorry, no text for this error in your language at the moment)"; - $this->logerr(); - return false; - } - } - - /** - * Retourne la chaine d'erreur correspondant à la dernière erreur rencontrée - * - * Si la dernière erreur rencontrée est connue, retourne l'erreur en toute lettre - * dans la langue actuellement sélectionnée, ou en anglais par défaut. - * Si l'erreur n'est pas connue, retourne son numéro de classe et d'ereur. - * - * @return string Chaine d'erreur. - * - */ - function errstr() { - if (is_string($this->error)) { - // new way of handling errors: message directly in the class - $str = $this->error . "\n"; - } else { - // old way: message in the locales files (ugly) - $str = _("err_" . $this->clsid . "_" . $this->error) . "\n"; - } - $args = $this->param; - if (is_array($args)) { - array_unshift($args, $str); - $msg = call_user_func_array("sprintf", $args); - return $msg; - } else { - return $args; - } - } - - /** - * Envoi un log d'erreur dans /var/log/alternc/bureau.log - * - * Cette fonction Loggue la dernière erreur dans /var/log sur la machine, - * permettant ainsi aux admins de savoir ce qu'il se passe... - * Elle est appelée automatiquement par error - * @access private - */ - function logerr() { - global $mem; - @file_put_contents($this->logfile, date("d/m/Y H:i:s") . " - " . get_remote_ip() . " - ERROR - " . $mem->user["login"] . " - " . $this->errstr(), FILE_APPEND); - } - - /** - * Envoi un log d'appel d'API dans /var/log/alternc/bureau.log - * - * Cette fonction loggue dans /var/log l'appel à la fonction de l'API - * d'AlternC. - * - * @param integer $clsid Numéro de la classe dont on a appelé une fonction - * @param string $function Nom de la fonction appelée - * @param string $param Paramètre (facultatif) passés à la fonction de l'API. - * @return boolean TRUE si le log a été ajouté, FALSE sinon - * - */ - function log($clsid, $function, $param = "") { - global $mem; - return @file_put_contents($this->logfile, date("d/m/Y H:i:s") . " - " . get_remote_ip() . " - CALL - " . $mem->user["login"] . " - $clsid - $function - $param\n", FILE_APPEND); - } - -} - -/* Classe m_err */ diff --git a/bureau/class/m_log.php b/bureau/class/m_log.php index eabe4ad0..65eb3378 100644 --- a/bureau/class/m_log.php +++ b/bureau/class/m_log.php @@ -34,8 +34,8 @@ class m_log { } function list_logs_directory($dir) { - global $cuid, $err; - $err->log("log", "list_logs_directory"); + global $cuid, $msg; + $msg->log("log", "list_logs_directory"); $c = array(); foreach (glob("${dir}/*log*") as $absfile) { @@ -72,8 +72,8 @@ class m_log { } function list_logs_directory_all($dirs) { - global $err; - $err->log("log", "get_logs_directory_all"); + global $msg; + $msg->log("log", "get_logs_directory_all"); $c = array(); foreach ($dirs as $dir => $val) { $c[$dir] = $this->list_logs_directory($val); @@ -82,8 +82,8 @@ class m_log { } function get_logs_directory() { - global $cuid, $mem, $err; - $err->log("log", "get_logs_directory"); + global $cuid, $mem, $msg; + $msg->log("log", "get_logs_directory"); // Return an array to allow multiple directory in the future if (defined('ALTERNC_LOGS_ARCHIVE')) { $c = array("dir" => ALTERNC_LOGS_ARCHIVE . "/" . $cuid . "-" . $mem->user["login"]); @@ -94,8 +94,8 @@ class m_log { } function download_link($file) { - global $err; - $err->log("log", "download_link"); + global $msg; + $msg->log("log", "download_link"); header("Content-Disposition: attachment; filename=" . $file . ""); header("Content-Type: application/force-download"); header("Content-Transfer-Encoding: binary"); @@ -106,8 +106,8 @@ class m_log { } function tail($file, $lines = 20) { - global $err; - $err->log("log", "tail"); + global $msg; + $msg->log("log", "tail"); $lines = intval($lines); if ($lines <= 0) { $lines = 20; diff --git a/bureau/class/m_lxc.php b/bureau/class/m_lxc.php index 27095129..ef97c0cf 100644 --- a/bureau/class/m_lxc.php +++ b/bureau/class/m_lxc.php @@ -69,8 +69,8 @@ class m_lxc implements vm { * HOOK: remove VM history for AlternC account */ function hook_admin_del_member() { - global $db, $err, $cuid; - $err->log("lxc", "alternc_del_member"); + global $db, $msg, $cuid; + $msg->log("lxc", "alternc_del_member"); $db->query("DELETE FROM vm_history WHERE uid= ?", array($cuid)); return true; } @@ -123,10 +123,10 @@ class m_lxc implements vm { * for user $login having hashed password $pass and uid $uid */ public function start($login = FALSE, $pass = FALSE, $uid = FALSE) { - global $mem, $db, $err, $mysql; + global $mem, $db, $msg, $mysql; if ($this->getvm() !== FALSE) { - $err->raise('lxc', _('VM already started')); + $msg->raise('Error', 'lxc', _('VM already started')); return FALSE; } unset($this->error); @@ -150,7 +150,7 @@ class m_lxc implements vm { $uid = $mem->user['uid']; if ($error != 0) { - $err->raise('lxc', _($msg)); + $msg->raise('Error', 'lxc', _($msg)); return FALSE; } $db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES (?, ?, ?, ?);", array($hostname, $date_start, $uid, $res)); diff --git a/bureau/class/variables.php b/bureau/class/variables.php index 43ab6d43..7aa67596 100644 --- a/bureau/class/variables.php +++ b/bureau/class/variables.php @@ -110,8 +110,8 @@ function variable_get($name, $default = null, $createit_comment = null) { * of serialization as necessary. */ function variable_set($name, $value, $comment = null) { - global $conf, $db, $err, $hooks; - $err->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+'); + global $conf, $db, $msg, $hooks; + $msg->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+'); variable_init_maybe();