le reste des fichiers & style.css
This commit is contained in:
parent
dec3ac1b9a
commit
6b7d5e7d90
|
@ -8,10 +8,8 @@ $fields = array (
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
|
|
||||||
if (!empty($cronupdate)) {
|
if (!empty($cronupdate)) {
|
||||||
if (! $cron->update($cronupdate)) {
|
if ($cron->update($cronupdate)) {
|
||||||
$error=$err->errstr();
|
$msg->raise("ok", "mysql", _("Save done."));
|
||||||
} else {
|
|
||||||
$error=_("Save done.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +20,9 @@ $lst_cron = $cron->lst_cron();
|
||||||
<hr id="topbar"/>
|
<hr id="topbar"/>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<?php if (isset($error) && $error) { ?>
|
<?php
|
||||||
<p class="alert alert-danger"><?php echo $error ?></p>
|
echo $msg->msg_html_all()
|
||||||
<?php } ?>
|
?>
|
||||||
|
|
||||||
<form method="post" action="cron.php" id="main" name="cron" >
|
<form method="post" action="cron.php" id="main" name="cron" >
|
||||||
<?php csrf_get(); ?>
|
<?php csrf_get(); ?>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -26,15 +26,12 @@
|
||||||
|
|
||||||
require_once("../class/config_nochk.php");
|
require_once("../class/config_nochk.php");
|
||||||
|
|
||||||
if ($mem->checkid()) {
|
if ($mem->checkid(false)) {
|
||||||
Header("Location: /main.php");
|
Header("Location: /main.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$mem->del_session()) {
|
$mem->del_session();
|
||||||
// No need to draw an error message ...
|
|
||||||
//$error=$err->errstr();
|
|
||||||
}
|
|
||||||
|
|
||||||
$H=getenv("HTTP_HOST");
|
$H=getenv("HTTP_HOST");
|
||||||
|
|
||||||
|
@ -72,11 +69,10 @@ if ( empty($logo) || ! $logo ) {
|
||||||
$logo = 'images/logo.png';
|
$logo = 'images/logo.png';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<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 id="logo"> <img src="<?php echo $logo; ?>" border="0" alt="<?php __("Web Hosting Control Panel"); ?>" title="<?php __("Web Hosting Control Panel"); ?>" />
|
|
||||||
</p>
|
</p>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<?php if (isset($error) && $error) echo "<div class='alert alert-danger'>$error</div>"; ?>
|
<?php echo $msg->msg_html_all(); ?>
|
||||||
<br/>
|
<br/>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['authip_token'])) $authip_token=$_GET['authip_token'];
|
if (isset($_GET['authip_token'])) $authip_token=$_GET['authip_token'];
|
||||||
|
|
|
@ -20,25 +20,25 @@ if (!empty($s_protocol)) {
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
|
|
||||||
if (! $authip->ip_affected_save($s_ipsub, $s_protocol, $$val) ) {
|
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 (!empty($delete_affected_id)) {
|
||||||
if (! $authip->ip_affected_delete($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 (!empty($delete_id)) {
|
||||||
if (! $authip->ip_delete($delete_id)) {
|
if (! $authip->ip_delete($delete_id)) {
|
||||||
$error="Error during deletion";
|
$msg->raise('Error', "ftp", _("Error during deletion")); // à traduire
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($ipsub)) {
|
if (!empty($ipsub)) {
|
||||||
if (! $authip->ip_save($id, $ipsub, $infos)) {
|
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"/>
|
<hr id="topbar"/>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<?php if (isset($error) && $error) { ?>
|
<?php
|
||||||
<p class="alert alert-danger"><?php echo $error ; $error=''; ?></p>
|
echo $msg->msg_html_all();
|
||||||
<?php } ?>
|
?>
|
||||||
|
|
||||||
<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>
|
<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>";
|
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>
|
<td><div class="ina delete"><a href="ip_main.php?delete_id=<?php echo urlencode($i["id"]) ?>"><?php __("Delete"); ?></a></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ foreach($list_ip as $i) {
|
||||||
<hr/>
|
<hr/>
|
||||||
<h3><?php __("Add an IP or a networks");?></h3>
|
<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">
|
<span id="form_add_ip">
|
||||||
<form method="post" action="ip_main.php" name="main" >
|
<form method="post" action="ip_main.php" name="main" >
|
||||||
<?php csrf_get(); ?>
|
<?php csrf_get(); ?>
|
||||||
|
|
|
@ -34,9 +34,5 @@ $fields = array (
|
||||||
);
|
);
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
|
|
||||||
if (empty($file)) {
|
|
||||||
$error="";
|
|
||||||
}
|
|
||||||
|
|
||||||
$log->download_link($file);
|
$log->download_link($file);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -36,11 +36,11 @@ $list=$log->list_logs_directory_all($log->get_logs_directory());
|
||||||
<hr id="topbar"/>
|
<hr id="topbar"/>
|
||||||
<br />
|
<br />
|
||||||
<?php
|
<?php
|
||||||
if (isset($error) && $error) {
|
echo $msg->msg_html_all();
|
||||||
echo "<p class=\"alert alert-danger\">$error</p>";
|
|
||||||
}
|
|
||||||
if(!$list || empty($list['dir'])){
|
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');
|
include_once('foot.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,6 @@ $fields = array (
|
||||||
);
|
);
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
|
|
||||||
if (empty($file)) {
|
|
||||||
$error="";
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once("head.php");
|
include_once("head.php");
|
||||||
|
|
||||||
$string=$log->tail($file,$lines);
|
$string=$log->tail($file,$lines);
|
||||||
|
@ -63,7 +59,7 @@ if (!$string) {
|
||||||
} ?>
|
} ?>
|
||||||
<select id="lines" name="lines" onchange="document.forms['update'].submit()">
|
<select id="lines" name="lines" onchange="document.forms['update'].submit()">
|
||||||
<?php
|
<?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);
|
eoption($alines,$lines);
|
||||||
?>
|
?>
|
||||||
</select> <?php __("Last lines shown"); ?>
|
</select> <?php __("Last lines shown"); ?>
|
||||||
|
@ -73,11 +69,7 @@ eoption($alines,$lines);
|
||||||
<hr id="topbar"/>
|
<hr id="topbar"/>
|
||||||
<br />
|
<br />
|
||||||
<?php
|
<?php
|
||||||
if (isset($error) && $error) {
|
echo $msg->msg_html_all();
|
||||||
echo "<p class=\"alert alert-danger\">$error</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<pre style=" white-space: pre-wrap; /* CSS 3 */
|
<pre style=" white-space: pre-wrap; /* CSS 3 */
|
||||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||||
|
|
|
@ -43,6 +43,7 @@ if ($mem->user["lastfail"]) {
|
||||||
printf(_("%1\$d login failed since last login")."<br />",$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=''; }
|
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'));
|
$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'));
|
||||||
|
|
|
@ -31,12 +31,14 @@ require_once("../class/config.php");
|
||||||
|
|
||||||
// Getting logo
|
// 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'));
|
$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>
|
<p class="currentuser"><?php echo sprintf(_("Welcome %s"),$mem->user["login"]); ?></p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
require_once("../class/config.php");
|
require_once("../class/config.php");
|
||||||
require_once("head.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");
|
include("index.php");
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,7 @@ img {
|
||||||
}
|
}
|
||||||
.alert > p, .alert > ul {
|
.alert > p, .alert > ul {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.alert > p + p {
|
.alert > p + p {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
@ -351,7 +352,7 @@ img {
|
||||||
|
|
||||||
/* Alert icons */
|
/* Alert icons */
|
||||||
#content .alert {
|
#content .alert {
|
||||||
background-position: 12px 10px;
|
background-position: 12px center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
padding-left: 48px;
|
padding-left: 48px;
|
||||||
}
|
}
|
||||||
|
@ -610,11 +611,11 @@ table.searchtable td {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#newdomwww, #sub, #usernpfx, #dbnpfx {
|
#newdomwww, #sub, #usernpfx, #dbnpfx, #account_namefx {
|
||||||
border-right: 0;
|
border-right: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
#newdomain, #newsubname, #usern, #dbn {
|
#newdomain, #newsubname, #usern, #dbn, #account_name {
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,15 +53,9 @@ include_once("head.php");
|
||||||
<hr/>
|
<hr/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php if (!empty($error)) { ?>
|
<?php
|
||||||
<div>
|
echo $msg->msg_html_all();
|
||||||
<span class="alert alert-danger">
|
?>
|
||||||
<?php echo implode(" - ", array_unique($error)); ?>
|
|
||||||
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<br/>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<?php if (empty($infos)) {
|
<?php if (empty($infos)) {
|
||||||
|
|
|
@ -43,13 +43,13 @@ class m_action {
|
||||||
/**
|
/**
|
||||||
* Plans the cration of a file
|
* Plans the cration of a file
|
||||||
*
|
*
|
||||||
* @global \m_err $err
|
* @global m_messages $msg
|
||||||
* @global string $L_INOTIFY_DO_ACTION
|
* @global string $L_INOTIFY_DO_ACTION
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function do_action() {
|
function do_action() {
|
||||||
global $err, $L_INOTIFY_DO_ACTION;
|
global $msg, $L_INOTIFY_DO_ACTION;
|
||||||
$err->log("action", "do_action");
|
$msg->log("action", "do_action");
|
||||||
if (!@touch($L_INOTIFY_DO_ACTION)) {
|
if (!@touch($L_INOTIFY_DO_ACTION)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -152,14 +152,14 @@ class m_action {
|
||||||
*
|
*
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_mysql $db
|
* @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
|
* @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
|
* If archive_del_data is not set we delete the folder
|
||||||
* @param string $dir sub_directory of the archive directory
|
* @param string $dir sub_directory of the archive directory
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function archive($archive, $dir = "html") {
|
function archive($archive, $dir = "html") {
|
||||||
global $cuid, $db, $err;
|
global $cuid, $db, $msg;
|
||||||
|
|
||||||
$arch = variable_get('archive_del_data');
|
$arch = variable_get('archive_del_data');
|
||||||
if (empty($arch)) {
|
if (empty($arch)) {
|
||||||
|
@ -170,7 +170,7 @@ class m_action {
|
||||||
$db->query("select login from membres where uid= ?;", array($cuid));
|
$db->query("select login from membres where uid= ?;", array($cuid));
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
if (!$db->Record["login"]) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$uidlogin = $cuid . "-" . $db->Record["login"];
|
$uidlogin = $cuid . "-" . $db->Record["login"];
|
||||||
|
@ -187,15 +187,15 @@ class m_action {
|
||||||
* function inserting the action in the sql table
|
* function inserting the action in the sql table
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string|integer $user wich user do we impersonate?
|
* @param string|integer $user wich user do we impersonate?
|
||||||
* @param mixed $parameters
|
* @param mixed $parameters
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function set($type, $user, $parameters) {
|
function set($type, $user, $parameters) {
|
||||||
global $db, $err;
|
global $db, $msg;
|
||||||
$err->log("action", "set", $type);
|
$msg->log("action", "set", $type);
|
||||||
$serialized = serialize($parameters);
|
$serialized = serialize($parameters);
|
||||||
$type = strtoupper($type);
|
$type = strtoupper($type);
|
||||||
if (in_array($type, array('CHMOD',
|
if (in_array($type, array('CHMOD',
|
||||||
|
@ -212,7 +212,7 @@ class m_action {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$db->query($query)) {
|
if (!$db->query($query)) {
|
||||||
$err->raise("action", _("Error setting actions"));
|
$msg->raise('Error', "action", _("Error setting actions"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->do_action();
|
return $this->do_action();
|
||||||
|
@ -221,17 +221,17 @@ class m_action {
|
||||||
/**
|
/**
|
||||||
* This seems to be unused ?
|
* This seems to be unused ?
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function get_old() {
|
function get_old() {
|
||||||
global $err, $db;
|
global $msg, $db;
|
||||||
|
|
||||||
$purge = "select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
$purge = "select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
||||||
$result = $db->query($purge);
|
$result = $db->query($purge);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$err->raise("action", _("Error selecting old actions"));
|
$msg->raise('Error', "action", _("Error selecting old actions"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $db->num_rows($result);
|
return $db->num_rows($result);
|
||||||
|
@ -239,13 +239,13 @@ class m_action {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param type $all
|
* @param type $all
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function purge($all = null) {
|
function purge($all = null) {
|
||||||
global $err, $db;
|
global $msg, $db;
|
||||||
if (is_null($all)) {
|
if (is_null($all)) {
|
||||||
$purge = "delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2 and status = 0;";
|
$purge = "delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2 and status = 0;";
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,7 +253,7 @@ class m_action {
|
||||||
}
|
}
|
||||||
$result = $db->query($purge);
|
$result = $db->query($purge);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$err->raise("action", _("Error purging old actions"));
|
$msg->raise('Error', "action", _("Error purging old actions"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $db->num_rows($result);
|
return $db->num_rows($result);
|
||||||
|
@ -263,11 +263,10 @@ class m_action {
|
||||||
* function returning the first not locked line of the action table
|
* function returning the first not locked line of the action table
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
|
||||||
* @return boolean or array
|
* @return boolean or array
|
||||||
*/
|
*/
|
||||||
function get_action() {
|
function get_action() {
|
||||||
global $db, $err;
|
global $db;
|
||||||
|
|
||||||
$tab = array();
|
$tab = array();
|
||||||
$db->query('select * from actions where end = 0 and begin = 0 order by id limit 1;');
|
$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
|
* function locking an entry while it is being executed by the action script
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function begin($id) {
|
function begin($id) {
|
||||||
global $db, $err;
|
global $db, $msg;
|
||||||
if (!$db->query("update actions set begin=now() where id= ? ;", array($id))) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -300,15 +299,15 @@ class m_action {
|
||||||
* function locking an entry while it is being executed by the action script
|
* function locking an entry while it is being executed by the action script
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param integer $return
|
* @param integer $return
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function finish($id, $return = 0) {
|
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))) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -317,14 +316,14 @@ class m_action {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function reset_job($id) {
|
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))) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -334,7 +333,7 @@ class m_action {
|
||||||
* Returns a list of actions marked as executable and ready for execution
|
* Returns a list of actions marked as executable and ready for execution
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_messages $msg
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function get_job() {
|
function get_job() {
|
||||||
|
|
|
@ -102,7 +102,7 @@ class m_authip {
|
||||||
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
||||||
*/
|
*/
|
||||||
function ip_delete($id) {
|
function ip_delete($id) {
|
||||||
global $db, $cuid;
|
global $db, $cuid, $msg;
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
|
|
||||||
$db->query("SELECT id FROM authorised_ip_affected where authorised_ip_id = ?;", array($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'));
|
$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))) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -126,9 +126,9 @@ class m_authip {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_allowed($s) {
|
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))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$r = Array();
|
$r = Array();
|
||||||
|
@ -145,9 +145,9 @@ class m_authip {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function is_wl($ip) {
|
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';")) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
|
@ -205,7 +205,7 @@ class m_authip {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function ip_save($id, $ipsub, $infos, $uid = null) {
|
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
|
// If we ask for uid=0, we have to check to be super-user
|
||||||
// else, juste use global cuid;
|
// else, juste use global cuid;
|
||||||
|
@ -216,7 +216,7 @@ class m_authip {
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
$infos = mysql_real_escape_string($infos);
|
$infos = $db->quote(trim($infos));
|
||||||
|
|
||||||
// Extract subnet from ipsub
|
// Extract subnet from ipsub
|
||||||
$tmp = explode('/', $ipsub);
|
$tmp = explode('/', $ipsub);
|
||||||
|
@ -224,7 +224,7 @@ class m_authip {
|
||||||
|
|
||||||
// Error if $ip not an IP
|
// Error if $ip not an IP
|
||||||
if (!checkip($ip) && !checkipv6($ip)) {
|
if (!checkip($ip) && !checkipv6($ip)) {
|
||||||
echo "Failed : not an IP address";
|
$msg->raise('Error', 'authip', _("Failed : not an IP address")); // à traduire
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ class m_authip {
|
||||||
foreach ($list_affected as $k => $v) {
|
foreach ($list_affected as $k => $v) {
|
||||||
$this->call_hooks("authip_on_delete", $k);
|
$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))) {
|
if (!$db->query("update authorised_ip set ip= ?, subnet= ?, infos= ? where id= ? and uid=? ;", array($ip, $subnet, $infos, $id, $cuid))) {
|
||||||
echo "query failed: " . $db->Error;
|
$msg->raise('Error', 'authip', _("query failed: " . $db->Error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
foreach ($list_affected as $k => $v) {
|
foreach ($list_affected as $k => $v) {
|
||||||
|
@ -258,7 +258,7 @@ class m_authip {
|
||||||
}
|
}
|
||||||
} else { // Insert
|
} else { // Insert
|
||||||
if (!$db->query("insert into authorised_ip (uid, ip, subnet, infos) values (?, ?, ?, ?);", array($cuid, $ip, $subnet, $infos))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,20 +313,20 @@ class m_authip {
|
||||||
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
||||||
*/
|
*/
|
||||||
function ip_affected_save($authorised_ip_id, $protocol, $parameters, $id = null) {
|
function ip_affected_save($authorised_ip_id, $protocol, $parameters, $id = null) {
|
||||||
global $db;
|
global $db, $msg;
|
||||||
$authorised_ip_id = intval($authorised_ip_id);
|
$authorised_ip_id = intval($authorised_ip_id);
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
$this->call_hooks("authip_on_delete", $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))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$this->call_hooks("authip_on_create", $id);
|
$this->call_hooks("authip_on_create", $id);
|
||||||
} else {
|
} else {
|
||||||
if (!$db->query("insert into authorised_ip_affected (authorised_ip_id, protocol, parameters) values (?, ?, ?);", array($authorised_ip_id, $protocol, $parameters))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$this->call_hooks("authip_on_create", $db->lastid());
|
$this->call_hooks("authip_on_create", $db->lastid());
|
||||||
|
@ -344,14 +344,14 @@ class m_authip {
|
||||||
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
* @return boolean Retourne FALSE si erreur, sinon TRUE
|
||||||
*/
|
*/
|
||||||
function ip_affected_delete($id) {
|
function ip_affected_delete($id) {
|
||||||
global $db;
|
global $db, $msg;
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
|
|
||||||
// Call hooks
|
// Call hooks
|
||||||
$this->call_hooks("authip_on_delete", $id);
|
$this->call_hooks("authip_on_delete", $id);
|
||||||
|
|
||||||
if (!$db->query("delete from authorised_ip_affected where id= ? limit 1;", array($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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -362,18 +362,18 @@ class m_authip {
|
||||||
* affectationt ip<=>ressource dont l'id est en parametre
|
* affectationt ip<=>ressource dont l'id est en parametre
|
||||||
*
|
*
|
||||||
* @global m_hooks $hooks
|
* @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 string $function Nom de la fonction a rechercher et appeller dans les classes
|
||||||
* @param integer $affectation_id Id de l'affectation correspondante
|
* @param integer $affectation_id Id de l'affectation correspondante
|
||||||
* @return boolean Retourne TRUE
|
* @return boolean Retourne TRUE
|
||||||
*/
|
*/
|
||||||
function call_hooks($function, $affectation_id) {
|
function call_hooks($function, $affectation_id) {
|
||||||
global $hooks, $err;
|
global $hooks, $msg;
|
||||||
|
|
||||||
// On récure l'objet dont on parle
|
// On récure l'objet dont on parle
|
||||||
$d = $this->list_affected();
|
$d = $this->list_affected();
|
||||||
if (!isset($d[$affectation_id])) {
|
if (!isset($d[$affectation_id])) {
|
||||||
$err->raise('authip', _("Object not available"));
|
$msg->raise('Error', 'authip', _("Object not available"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ class m_authip {
|
||||||
// On en déduis la classe qui le concerne
|
// On en déduis la classe qui le concerne
|
||||||
$e = $this->get_auth_class();
|
$e = $this->get_auth_class();
|
||||||
if (!isset($e[$affectation['protocol']])) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$c = $e[$affectation['protocol']]['class'];
|
$c = $e[$affectation['protocol']]['class'];
|
||||||
|
|
|
@ -54,8 +54,8 @@ class m_cron {
|
||||||
* @return array an hash for each crontab.
|
* @return array an hash for each crontab.
|
||||||
*/
|
*/
|
||||||
function lst_cron() {
|
function lst_cron() {
|
||||||
global $cuid, $db, $err;
|
global $cuid, $db, $msg;
|
||||||
$err->log("cron", "lst_cron");
|
$msg->log("cron", "lst_cron");
|
||||||
$db->query("SELECT * FROM cron WHERE uid = ? ORDER BY url;", array($cuid));
|
$db->query("SELECT * FROM cron WHERE uid = ? ORDER BY url;", array($cuid));
|
||||||
$r = Array();
|
$r = Array();
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
|
@ -112,8 +112,8 @@ class m_cron {
|
||||||
* @return boolean TRUE if the crontab has been deleted
|
* @return boolean TRUE if the crontab has been deleted
|
||||||
*/
|
*/
|
||||||
function delete_one($id) {
|
function delete_one($id) {
|
||||||
global $db, $err, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$err->log("cron", "delete_one");
|
$msg->log("cron", "delete_one");
|
||||||
return $db->query("DELETE FROM cron WHERE id= ? AND uid= ? LIMIT 1;", array(intval($id), $cuid));
|
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
|
* @return boolean TRUE if the crontab has been edited
|
||||||
*/
|
*/
|
||||||
private function _update_one($url, $user, $password, $email, $schedule, $id = null) {
|
private function _update_one($url, $user, $password, $email, $schedule, $id = null) {
|
||||||
global $db, $err, $quota, $cuid;
|
global $db, $msg, $quota, $cuid;
|
||||||
$err->log("cron", "update_one");
|
$msg->log("cron", "update_one");
|
||||||
|
|
||||||
if (empty($url) && !is_null($id)) {
|
if (empty($url) && !is_null($id)) {
|
||||||
return $this->delete_one($id);
|
return $this->delete_one($id);
|
||||||
|
@ -132,7 +132,7 @@ class m_cron {
|
||||||
|
|
||||||
|
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
|
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
|
||||||
$err->raise("cron", _("URL not valid"));
|
$msg->raise('Error', "cron", _("URL not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$url = urlencode($url);
|
$url = urlencode($url);
|
||||||
|
@ -144,7 +144,7 @@ class m_cron {
|
||||||
|
|
||||||
//@todo remove checkmail cf functions.php
|
//@todo remove checkmail cf functions.php
|
||||||
if (!empty($email) && !checkmail($email) == 0) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
$email = urlencode($email);
|
$email = urlencode($email);
|
||||||
|
@ -155,7 +155,7 @@ class m_cron {
|
||||||
if (is_null($id)) { // if a new insert, quotacheck
|
if (is_null($id)) { // if a new insert, quotacheck
|
||||||
$q = $quota->getquota("cron");
|
$q = $quota->getquota("cron");
|
||||||
if ($q["u"] >= $q["t"]) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
} else { // if not a new insert, check the $cuid
|
} else { // if not a new insert, check the $cuid
|
||||||
|
@ -163,8 +163,8 @@ class m_cron {
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
return "false";
|
return "false";
|
||||||
} // return false if pb
|
} // return false if pb
|
||||||
if ($db->f('uid') != $cuid) {
|
if ($db->f('uid') != $cuid) {
|
||||||
$err->raise("cron", _("Identity problem"));
|
$msg->raise('Error', "cron", _("Identity problem"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,8 +196,8 @@ class m_cron {
|
||||||
/** hook for quota computation
|
/** hook for quota computation
|
||||||
*/
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $cuid, $db, $err;
|
global $cuid, $db, $msg;
|
||||||
$err->log("cron", "alternc_get_quota");
|
$msg->log("cron", "alternc_get_quota");
|
||||||
$q = Array("name" => "cron", "description" => _("Scheduled tasks"), "used" => 0);
|
$q = Array("name" => "cron", "description" => _("Scheduled tasks"), "used" => 0);
|
||||||
$db->query("select count(*) as cnt from cron where uid = ? ;", array($cuid));
|
$db->query("select count(*) as cnt from cron where uid = ? ;", array($cuid));
|
||||||
if ($db->next_record()) {
|
if ($db->next_record()) {
|
||||||
|
|
|
@ -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 */
|
|
|
@ -34,8 +34,8 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
function list_logs_directory($dir) {
|
function list_logs_directory($dir) {
|
||||||
global $cuid, $err;
|
global $cuid, $msg;
|
||||||
$err->log("log", "list_logs_directory");
|
$msg->log("log", "list_logs_directory");
|
||||||
|
|
||||||
$c = array();
|
$c = array();
|
||||||
foreach (glob("${dir}/*log*") as $absfile) {
|
foreach (glob("${dir}/*log*") as $absfile) {
|
||||||
|
@ -72,8 +72,8 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
function list_logs_directory_all($dirs) {
|
function list_logs_directory_all($dirs) {
|
||||||
global $err;
|
global $msg;
|
||||||
$err->log("log", "get_logs_directory_all");
|
$msg->log("log", "get_logs_directory_all");
|
||||||
$c = array();
|
$c = array();
|
||||||
foreach ($dirs as $dir => $val) {
|
foreach ($dirs as $dir => $val) {
|
||||||
$c[$dir] = $this->list_logs_directory($val);
|
$c[$dir] = $this->list_logs_directory($val);
|
||||||
|
@ -82,8 +82,8 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_logs_directory() {
|
function get_logs_directory() {
|
||||||
global $cuid, $mem, $err;
|
global $cuid, $mem, $msg;
|
||||||
$err->log("log", "get_logs_directory");
|
$msg->log("log", "get_logs_directory");
|
||||||
// Return an array to allow multiple directory in the future
|
// Return an array to allow multiple directory in the future
|
||||||
if (defined('ALTERNC_LOGS_ARCHIVE')) {
|
if (defined('ALTERNC_LOGS_ARCHIVE')) {
|
||||||
$c = array("dir" => ALTERNC_LOGS_ARCHIVE . "/" . $cuid . "-" . $mem->user["login"]);
|
$c = array("dir" => ALTERNC_LOGS_ARCHIVE . "/" . $cuid . "-" . $mem->user["login"]);
|
||||||
|
@ -94,8 +94,8 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_link($file) {
|
function download_link($file) {
|
||||||
global $err;
|
global $msg;
|
||||||
$err->log("log", "download_link");
|
$msg->log("log", "download_link");
|
||||||
header("Content-Disposition: attachment; filename=" . $file . "");
|
header("Content-Disposition: attachment; filename=" . $file . "");
|
||||||
header("Content-Type: application/force-download");
|
header("Content-Type: application/force-download");
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
|
@ -106,8 +106,8 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tail($file, $lines = 20) {
|
function tail($file, $lines = 20) {
|
||||||
global $err;
|
global $msg;
|
||||||
$err->log("log", "tail");
|
$msg->log("log", "tail");
|
||||||
$lines = intval($lines);
|
$lines = intval($lines);
|
||||||
if ($lines <= 0) {
|
if ($lines <= 0) {
|
||||||
$lines = 20;
|
$lines = 20;
|
||||||
|
|
|
@ -69,8 +69,8 @@ class m_lxc implements vm {
|
||||||
* HOOK: remove VM history for AlternC account
|
* HOOK: remove VM history for AlternC account
|
||||||
*/
|
*/
|
||||||
function hook_admin_del_member() {
|
function hook_admin_del_member() {
|
||||||
global $db, $err, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$err->log("lxc", "alternc_del_member");
|
$msg->log("lxc", "alternc_del_member");
|
||||||
$db->query("DELETE FROM vm_history WHERE uid= ?", array($cuid));
|
$db->query("DELETE FROM vm_history WHERE uid= ?", array($cuid));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,10 @@ class m_lxc implements vm {
|
||||||
* for user $login having hashed password $pass and uid $uid
|
* for user $login having hashed password $pass and uid $uid
|
||||||
*/
|
*/
|
||||||
public function start($login = FALSE, $pass = FALSE, $uid = FALSE) {
|
public function start($login = FALSE, $pass = FALSE, $uid = FALSE) {
|
||||||
global $mem, $db, $err, $mysql;
|
global $mem, $db, $msg, $mysql;
|
||||||
|
|
||||||
if ($this->getvm() !== FALSE) {
|
if ($this->getvm() !== FALSE) {
|
||||||
$err->raise('lxc', _('VM already started'));
|
$msg->raise('Error', 'lxc', _('VM already started'));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
unset($this->error);
|
unset($this->error);
|
||||||
|
@ -150,7 +150,7 @@ class m_lxc implements vm {
|
||||||
$uid = $mem->user['uid'];
|
$uid = $mem->user['uid'];
|
||||||
|
|
||||||
if ($error != 0) {
|
if ($error != 0) {
|
||||||
$err->raise('lxc', _($msg));
|
$msg->raise('Error', 'lxc', _($msg));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES (?, ?, ?, ?);", array($hostname, $date_start, $uid, $res));
|
$db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES (?, ?, ?, ?);", array($hostname, $date_start, $uid, $res));
|
||||||
|
|
|
@ -110,8 +110,8 @@ function variable_get($name, $default = null, $createit_comment = null) {
|
||||||
* of serialization as necessary.
|
* of serialization as necessary.
|
||||||
*/
|
*/
|
||||||
function variable_set($name, $value, $comment = null) {
|
function variable_set($name, $value, $comment = null) {
|
||||||
global $conf, $db, $err, $hooks;
|
global $conf, $db, $msg, $hooks;
|
||||||
$err->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+');
|
$msg->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+');
|
||||||
|
|
||||||
variable_init_maybe();
|
variable_init_maybe();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue