- Unicité des sous-domaines surveillés par awstats
- champs de type 'only-dns' pas affichés - type des champs affichés entre parenthèse - descriptions des erreurs mises à jour
This commit is contained in:
parent
831d399e8b
commit
9e486bc4f6
|
@ -56,11 +56,14 @@ include_once("head.php");
|
||||||
<tr><th><?php __("Hostaliases"); ?></th><td>
|
<tr><th><?php __("Hostaliases"); ?></th><td>
|
||||||
<?php // TODO : put them on 2 columns (at least)
|
<?php // TODO : put them on 2 columns (at least)
|
||||||
$hl=$aws->host_list();
|
$hl=$aws->host_list();
|
||||||
|
reset($hl);
|
||||||
$hatab=$aws->get_hostaliases($id);
|
$hatab=$aws->get_hostaliases($id);
|
||||||
foreach ($hl as $ho) {
|
while (list($key,$val)=each($hl)) {
|
||||||
|
$ho=$val["hostname"];
|
||||||
|
$ty=$val["desc"];
|
||||||
echo "<input type=\"checkbox\" name=\"hostaliases[]\" id=\"ha_$ho\" value=\"$ho\"";
|
echo "<input type=\"checkbox\" name=\"hostaliases[]\" id=\"ha_$ho\" value=\"$ho\"";
|
||||||
if (in_array($ho,explode(" ",$hatab[0]))) echo " checked=\"checked\"";
|
if (in_array($ho,explode(" ",$hatab[0]))) echo " checked=\"checked\"";
|
||||||
echo " /><label for=\"ha_$ho\">$ho</label><br />\n";
|
echo " /><label for=\"ha_$ho\">$ho ($ty)</label><br />\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
|
@ -32,14 +32,22 @@ $fields = array (
|
||||||
);
|
);
|
||||||
getFields($fields);
|
getFields($fields);
|
||||||
|
|
||||||
$r=$aws->add_stats($hostname,$awsusers,$hostaliases,$public);
|
if ($aws->check_host_available($hostname)) {
|
||||||
if (!$r) {
|
$r=$aws->add_stats($hostname,$awsusers,$hostaliases,$public);
|
||||||
$error=$err->errstr();
|
if (!$r) {
|
||||||
include("aws_add.php");
|
$error=$err->errstr();
|
||||||
exit();
|
include("aws_add.php");
|
||||||
} else {
|
exit();
|
||||||
$error=_("The statistics has been successfully created");
|
} else {
|
||||||
include("aws_list.php");
|
$error=_("The statistics has been successfully created");
|
||||||
exit();
|
include("aws_list.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$error=$err->errstr();
|
||||||
|
include("aws_add.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -92,7 +92,7 @@ class m_aws {
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$r[]=array(
|
$r[]=array(
|
||||||
"id"=>$db->f("id"),
|
"id"=>$db->f("id"),
|
||||||
"hostname"=>$db->f("hostname"),
|
"hostname"=>$db->f("hostname")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$t=array();
|
$t=array();
|
||||||
|
@ -102,11 +102,15 @@ class m_aws {
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$u.=$db->f("login")." ";
|
$u.=$db->f("login")." ";
|
||||||
}
|
}
|
||||||
$t[]=array("id"=>$v["id"],"hostname"=>$v["hostname"],"users"=>$u);
|
$t[]=array(
|
||||||
|
"id"=>$v["id"],
|
||||||
|
"hostname"=>$v["hostname"],
|
||||||
|
"users"=>$u
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $t;
|
return $t;
|
||||||
} else {
|
} else {
|
||||||
$err->raise("aws",1); // No statistics currently defined
|
$err->raise("aws",_("No statistics currently defined"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,26 +150,33 @@ class m_aws {
|
||||||
"public"=>$public
|
"public"=>$public
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$err->raise("aws",2); // This statistic does not exist
|
$err->raise("aws",_("This statistic does not exist"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Return the list of domains / subdomains allowed for this member
|
/** Return the list of domains / subdomains allowed for this member with the type (MX,URL,...)
|
||||||
*
|
*
|
||||||
* @return array an array of allowed domains / subdomains.
|
* @return array an array of allowed domains / subdomains.
|
||||||
*/
|
*/
|
||||||
function host_list() {
|
function host_list() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$r=array();
|
$r=array();
|
||||||
$db->query("SELECT domaine,sub FROM sub_domaines WHERE compte='$cuid' ORDER BY domaine,sub;");
|
$db->query("SELECT sd.domaine, sd.sub, dt.name, dt.description FROM sub_domaines sd, domaines_type dt WHERE compte='$cuid' AND lower(sd.type) = lower(dt.name) AND dt.only_dns = false ORDER BY domaine,sub;");
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
if ($db->f("sub")) {
|
if ($db->f("sub")) {
|
||||||
$r[]=$db->f("sub").".".$db->f("domaine");
|
$r[]=array(
|
||||||
|
"hostname"=>$db->f("sub").".".$db->f("domaine"),
|
||||||
|
"type"=>$db->f("name"),
|
||||||
|
"desc"=>$db->f("description")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$r[]=$db->f("domaine");
|
$r[]=array(
|
||||||
|
"hostname"=>$db->f("domaine"),
|
||||||
|
"type"=>"CACA",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -209,15 +220,39 @@ class m_aws {
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
* Draw options for a select html code with the list of allowed domains
|
* Draw options for a select html code with the list of allowed and availables domains
|
||||||
* for this member.
|
* for this member.
|
||||||
*/
|
*/
|
||||||
function select_host_list($current) {
|
function select_host_list($current) {
|
||||||
$r=$this->host_list();
|
$r=$this->host_list();
|
||||||
reset($r);
|
reset($r);
|
||||||
while (list($key,$val)=each($r)) {
|
while (list($key,$val)=each($r)) {
|
||||||
if ($current==$val) $c=" selected=\"selected\""; else $c="";
|
$ho=$val["hostname"];
|
||||||
echo "<option$c>$val</option>";
|
$ty=$val["desc"];
|
||||||
|
if ($current==$ho) $c=" selected=\"selected\""; else $c="";
|
||||||
|
if ($this->check_host_available($ho)) echo "<option value=\"$ho\"$c>$ho ("._($ty).")</option>";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* Check if hosts is already used by awstats
|
||||||
|
* of available for this member.
|
||||||
|
*/
|
||||||
|
function check_host_available($current) {
|
||||||
|
global $err;
|
||||||
|
$err->log("aws","check_host_available",$current);
|
||||||
|
$r=$this->get_list();
|
||||||
|
if(is_array($r)){
|
||||||
|
reset($r);
|
||||||
|
while (list($key,$val)=each($r)) {
|
||||||
|
if ($current==$val["hostname"]) {
|
||||||
|
$err->raise("aws",_("Host already managed by awstats!"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +310,7 @@ class m_aws {
|
||||||
$err->log("aws","delete_stats",$id);
|
$err->log("aws","delete_stats",$id);
|
||||||
$db->query("SELECT hostname FROM aws WHERE id='$id' and uid='$cuid';");
|
$db->query("SELECT hostname FROM aws WHERE id='$id' and uid='$cuid';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("aws",2); // This statistic does not exist
|
$err->raise("aws",_("This statistic does not exist"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -303,15 +338,21 @@ class m_aws {
|
||||||
$err->log("aws","add_stats",$hostname);
|
$err->log("aws","add_stats",$hostname);
|
||||||
$ha="";
|
$ha="";
|
||||||
$r=$this->host_list();
|
$r=$this->host_list();
|
||||||
if (!in_array($hostname,$r) || $hostname=="") {
|
$hosts=array();
|
||||||
$err->raise("aws",3); // This hostname does not exist
|
foreach ($r as $key=>$val) {
|
||||||
|
$hosts[]=$val["hostname"];
|
||||||
|
}
|
||||||
|
reset($hosts);
|
||||||
|
if (!in_array($hostname,$hosts) || $hostname=="") {
|
||||||
|
$err->raise("aws",_("This hostname does not exist (Domain name)"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the hostaliases array (it should contains valid domains)
|
// Parse the hostaliases array (it should contains valid domains)
|
||||||
if (is_array($hostaliases)) {
|
if (is_array($hostaliases)) {
|
||||||
foreach($hostaliases as $ho) {
|
foreach($hostaliases as $ho) {
|
||||||
if (!in_array($hostname,$r) || $hostname=="") {
|
if (!in_array($ho,$hosts) || $hostname=="") {
|
||||||
$err->raise("aws",3); // This hostname does not exist
|
$err->raise("aws",_("This hostname does not exist (Hostaliases)"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$ha .= "$ho ";
|
$ha .= "$ho ";
|
||||||
|
@ -331,7 +372,7 @@ class m_aws {
|
||||||
mkdir($this->CACHEDIR."/".$hostname,0777);
|
mkdir($this->CACHEDIR."/".$hostname,0777);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$err->raise("aws",4); // Your stat quota is over...
|
$err->raise("aws",_("Your stat quota is over..."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +385,7 @@ class m_aws {
|
||||||
$db->query("SELECT login FROM aws_users WHERE uid='$cuid';");
|
$db->query("SELECT login FROM aws_users WHERE uid='$cuid';");
|
||||||
$res=array();
|
$res=array();
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
$err->raise("aws",13); // No user currently defined
|
$err->raise("aws",_("No user currently defined"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
|
@ -402,7 +443,7 @@ class m_aws {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("aws","del_login");
|
$err->log("aws","del_login");
|
||||||
if (!$this->login_exists($login,1)) {
|
if (!$this->login_exists($login,1)) {
|
||||||
$err->raise("aws",5); // Login does not exists
|
$err->raise("aws",_("Login does not exists")); // Login does not exists
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("DELETE FROM aws_users WHERE uid='$cuid' AND login='$login';");
|
$db->query("DELETE FROM aws_users WHERE uid='$cuid' AND login='$login';");
|
||||||
|
@ -418,11 +459,11 @@ class m_aws {
|
||||||
$err->log("aws","add_login");
|
$err->log("aws","add_login");
|
||||||
|
|
||||||
if (!($login=$this->_check($login))) {
|
if (!($login=$this->_check($login))) {
|
||||||
$err->raise("aws",6); // Login incorrect
|
$err->raise("aws",_("Login incorrect")); // Login incorrect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!($this->login_exists($login,0))) {
|
if (!($this->login_exists($login,0))) {
|
||||||
$err->raise("aws",7); // Login does not exist
|
$err->raise("aws",_("Login does not exist")); // Login does not exist
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pass=crypt($pass);
|
$pass=crypt($pass);
|
||||||
|
@ -438,11 +479,11 @@ class m_aws {
|
||||||
$err->log("aws","change_pass");
|
$err->log("aws","change_pass");
|
||||||
|
|
||||||
if (!($login=$this->_check($login))) {
|
if (!($login=$this->_check($login))) {
|
||||||
$err->raise("aws",6); // Login incorrect
|
$err->raise("aws",_("Login incorrect")); // Login incorrect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!($this->login_exists($login))) {
|
if (!($this->login_exists($login))) {
|
||||||
$err->raise("aws",5); // Login does not exists
|
$err->raise("aws",_("Login does not exists")); // Login does not exists
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pass=crypt($pass);
|
$pass=crypt($pass);
|
||||||
|
@ -458,21 +499,21 @@ class m_aws {
|
||||||
$err->log("aws","allow_login");
|
$err->log("aws","allow_login");
|
||||||
|
|
||||||
if (!($login=$this->_check($login))) {
|
if (!($login=$this->_check($login))) {
|
||||||
$err->raise("aws",6); // Login incorrect
|
$err->raise("aws",_("Login incorrect")); // Login incorrect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$this->login_exists($login)) {
|
if (!$this->login_exists($login)) {
|
||||||
$err->raise("aws",5); // Login does not exists
|
$err->raise("aws",_("Login does not exists")); // Login does not exists
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
$err->raise("aws",2); // The requested statistic does not exist.
|
$err->raise("aws",_("The requested statistic does not exist.")); // The requested statistic does not exist.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
|
$db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
|
||||||
if ($db->next_record()) {
|
if ($db->next_record()) {
|
||||||
$err->raise("aws",8); // This login is already allowed for this statistics.
|
$err->raise("aws",_("This login is already allowed for this statistics.")); // This login is already allowed for this statistics.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("INSERT INTO aws_access (uid,id,login) VALUES ('$cuid','$id','$login');");
|
$db->query("INSERT INTO aws_access (uid,id,login) VALUES ('$cuid','$id','$login');");
|
||||||
|
@ -491,7 +532,7 @@ class m_aws {
|
||||||
|
|
||||||
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
$err->raise("aws",2); // The requested statistic does not exist.
|
$err->raise("aws",_("The requested statistic does not exist.")); // The requested statistic does not exist.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("DELETE FROM aws_access WHERE id='$id';");
|
$db->query("DELETE FROM aws_access WHERE id='$id';");
|
||||||
|
@ -509,21 +550,21 @@ class m_aws {
|
||||||
$err->log("aws","deny_login");
|
$err->log("aws","deny_login");
|
||||||
|
|
||||||
if (!($login=$this->_check($login))) {
|
if (!($login=$this->_check($login))) {
|
||||||
$err->raise("aws",6); // Login incorrect
|
$err->raise("aws",_("Login incorrect")); // Login incorrect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$this->login_exists($login,0)) {
|
if (!$this->login_exists($login,0)) {
|
||||||
$err->raise("aws",5); // Login does not exists
|
$err->raise("aws",_("Login does not exists")); // Login does not exists
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
$db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
$err->raise("aws",2); // The requested statistic does not exist.
|
$err->raise("aws",_("The requested statistic does not exist.")); // The requested statistic does not exist.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
|
$db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
|
||||||
if (!$db->next_record()) {
|
if (!$db->next_record()) {
|
||||||
$err->raise("aws",9); // This login is already denied for this statistics.
|
$err->raise("aws",_("This login is already denied for this statistics.")); // This login is already denied for this statistics.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("DELETE FROM aws_access WHERE id='$id' AND login='$login';");
|
$db->query("DELETE FROM aws_access WHERE id='$id' AND login='$login';");
|
||||||
|
@ -611,11 +652,11 @@ class m_aws {
|
||||||
}
|
}
|
||||||
$r=$this->prefix_list();
|
$r=$this->prefix_list();
|
||||||
if (!in_array($prefix,$r)) {
|
if (!in_array($prefix,$r)) {
|
||||||
$err->raise("aws",10); // prefix not allowed.
|
$err->raise("aws",_("prefix not allowed.")); // prefix not allowed.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!preg_match('/^[0-9a-z_-]*$/', $postfix)){
|
if (!preg_match('/^[0-9a-z_-]*$/', $postfix)){
|
||||||
$err->raise("aws",11); // Forbidden caracters in the postfix.
|
$err->raise("aws",_("Forbidden caracters in the postfix.")); // Forbidden caracters in the postfix.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $login;
|
return $login;
|
||||||
|
@ -629,7 +670,7 @@ class m_aws {
|
||||||
function _delconf($hostname) {
|
function _delconf($hostname) {
|
||||||
global $err;
|
global $err;
|
||||||
if (!preg_match('/^[._a-z0-9-]*$/', $hostname)){
|
if (!preg_match('/^[._a-z0-9-]*$/', $hostname)){
|
||||||
$err->raise("aws",12); // Hostname is incorrect
|
$err->raise("aws",_("Hostname is incorrect")); // Hostname is incorrect
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@unlink($this->CONFDIR."/awstats.".$hostname.".conf");
|
@unlink($this->CONFDIR."/awstats.".$hostname.".conf");
|
||||||
|
@ -650,7 +691,7 @@ class m_aws {
|
||||||
$db->query("SELECT * FROM aws WHERE id='$id' AND uid='$cuid';");
|
$db->query("SELECT * FROM aws WHERE id='$id' AND uid='$cuid';");
|
||||||
}
|
}
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("aws",2); // This statistic does not exist
|
$err->raise("aws",_("This statistic does not exist")); // This statistic does not exist
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
|
Loading…
Reference in New Issue