le reste des fichiers & style.css

This commit is contained in:
quenenni 2017-08-17 03:32:18 +02:00
parent dec3ac1b9a
commit 6b7d5e7d90
19 changed files with 117 additions and 282 deletions

View File

@ -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();
<hr id="topbar"/>
<br />
<?php if (isset($error) && $error) { ?>
<p class="alert alert-danger"><?php echo $error ?></p>
<?php } ?>
<?php
echo $msg->msg_html_all()
?>
<form method="post" action="cron.php" id="main" name="cron" >
<?php csrf_get(); ?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -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';
}
?>
<p id="logo"> <img src="<?php echo $logo; ?>" border="0" alt="<?php __("Web Hosting Control Panel"); ?>" title="<?php __("Web Hosting Control Panel"); ?>" />
<p id='logo'> <img src="<?php echo $logo; ?>" border="0" height="100px" alt="<?php __("Web Hosting Control Panel"); ?>" title="<?php __("Web Hosting Control Panel"); ?>" />
</p>
<p>&nbsp;</p>
<?php if (isset($error) && $error) echo "<div class='alert alert-danger'>$error</div>"; ?>
<?php echo $msg->msg_html_all(); ?>
<br/>
<?php
if (isset($_GET['authip_token'])) $authip_token=$_GET['authip_token'];

View File

@ -20,25 +20,25 @@ if (!empty($s_protocol)) {
getFields($fields);
if (! $authip->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();
<hr id="topbar"/>
<br />
<?php if (isset($error) && $error) { ?>
<p class="alert alert-danger"><?php echo $error ; $error=''; ?></p>
<?php } ?>
<?php
echo $msg->msg_html_all();
?>
<p><?php __("Here you can add rules to restrict access to AlternC's services, filtered by IP. First, add trusted IPs in the 'Known IP and networks' list. Then, add rules to grant access on services to the chosen IPs from this list.") ?></p>
@ -164,7 +164,7 @@ foreach($list_ip as $i) {
}
echo "<tr class='lst' ><td>{$i['infos']}</td><td>{$i['ip_human']}</td><td>$txt</td>";
?>
<td><div class="ina edit"><a href="javascript:edit_ip(<?php echo "'".htmlentities($i['id'])."','".htmlentities($i['ip_human'])."','".htmlentities($i['infos'])."'"; ?>);"><?php __("Edit"); ?></a></div></td>
<td><div class="ina edit"><a href="javascript:edit_ip(<?php echo "'".htmlentities($i['id'])."','".htmlentities($i['ip_human'])."',".htmlentities($i['infos']); ?>);"><?php __("Edit"); ?></a></div></td>
<td><div class="ina delete"><a href="ip_main.php?delete_id=<?php echo urlencode($i["id"]) ?>"><?php __("Delete"); ?></a></div></td>
</tr>
@ -174,7 +174,7 @@ foreach($list_ip as $i) {
<hr/>
<h3><?php __("Add an IP or a networks");?></h3>
<p><a href="javascript:edit_ip('','<?php ehe(get_remote_ip())."','Home IP'";?>);" ><?php echo __("Add my current IP"); ?></a></p>
<p><a href="javascript:edit_ip('','<?php ehe(get_remote_ip()."','Home IP'");?>);" ><?php echo __("Add my current IP"); ?></a></p>
<span id="form_add_ip">
<form method="post" action="ip_main.php" name="main" >
<?php csrf_get(); ?>

View File

@ -34,9 +34,5 @@ $fields = array (
);
getFields($fields);
if (empty($file)) {
$error="";
}
$log->download_link($file);
?>

View File

@ -36,11 +36,11 @@ $list=$log->list_logs_directory_all($log->get_logs_directory());
<hr id="topbar"/>
<br />
<?php
if (isset($error) && $error) {
echo "<p class=\"alert alert-danger\">$error</p>";
}
echo $msg->msg_html_all();
if(!$list || empty($list['dir'])){
echo "<p class=\"alert alert-danger\">"._("You have no web logs to list at the moment.")."</p>";
$msg->raise('Info', "logs", _("You have no web logs to list at the moment."));
echo $msg->msg_html_all();
include_once('foot.php');
exit;
}

View File

@ -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) {
} ?>
<select id="lines" name="lines" onchange="document.forms['update'].submit()">
<?php
$alines=array(10=>10, 20=>20, 30=>30, 50=>50, 100=>100, 200=>200, 500=>500, 1000=>1000, 5000=>5000);
$alines=array(10=>10, 20=>20, 30=>30, 50=>50, 100=>100, 200=>200, 500=>500, 1000=>1000);
eoption($alines,$lines);
?>
</select> <?php __("Last lines shown"); ?>
@ -73,11 +69,7 @@ eoption($alines,$lines);
<hr id="topbar"/>
<br />
<?php
if (isset($error) && $error) {
echo "<p class=\"alert alert-danger\">$error</p>";
}
echo $msg->msg_html_all();
?>
<pre style=" white-space: pre-wrap; /* CSS 3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */

View File

@ -43,6 +43,7 @@ if ($mem->user["lastfail"]) {
printf(_("%1\$d login failed since last login")."<br />",$mem->user["lastfail"]);
}
echo $msg->msg_html_all();
if (!empty($error) ) { echo "<p class='alert alert-danger'>$error</p>";$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'));

View File

@ -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 '<div class="menutoplogo">';
if ( ! empty($logo) && ! is_null($logo)) {
echo "<img src=\"".$logo."\" border='0' alt='AlternC' width='45px' height='46px' />";
}
echo "<img src='images/logo3.png' border='0' alt='AlternC' ".(( ! empty($logo) && ! is_null($logo))?"width='140px'":"")." height='40px' />";
echo "</div>";
?>
<img src="<?php echo $logo; ?>" class="menutoplogo" border="0" alt="AlternC" />
<p class="currentuser"><?php echo sprintf(_("Welcome %s"),$mem->user["login"]); ?></p>
<?php

View File

@ -25,7 +25,7 @@
require_once("../class/config.php");
require_once("head.php");
$error=_("There is currently no webmail configured. If you need one, contact your server administrator");
$msg->raise('Info', "mail", _("There is currently no webmail configured. If you need one, contact your server administrator");
include("index.php");

View File

@ -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;
}

View File

@ -53,15 +53,9 @@ include_once("head.php");
<hr/>
<br/>
<?php if (!empty($error)) { ?>
<div>
<span class="alert alert-danger">
<?php echo implode(" - ", array_unique($error)); ?>
</span>
</div>
<br/>
<?php } ?>
<?php
echo $msg->msg_html_all();
?>
<div>
<?php if (empty($infos)) {

View File

@ -43,13 +43,13 @@ class m_action {
/**
* Plans the cration of a file
*
* @global \m_err $err
* @global m_messages $msg
* @global string $L_INOTIFY_DO_ACTION
* @return boolean
*/
function do_action() {
global $err, $L_INOTIFY_DO_ACTION;
$err->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() {

View File

@ -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'];

View File

@ -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()) {

View File

@ -1,144 +0,0 @@
<?php
/*
$Id: m_err.php,v 1.4 2004/05/19 14:23:06 benjamin Exp $
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file: Benjamin Sonntag, Franck Missoum
----------------------------------------------------------------------
*/
/**
* Classe de gestion des erreurs apparaissant lors d'appels API.
*
* <p>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.</p>
* <p>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
* </p>
* 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 */

View File

@ -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;

View File

@ -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));

View File

@ -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();