From dd3253af2dbf2b4c5c1c1a23a46a268db3dda22c Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 31 Jan 2013 12:54:12 +0000
Subject: [PATCH] Awstats ready for Desktop, TNG
---
awstats/bureau/admin/aws_del.php | 20 +++++------
awstats/bureau/admin/aws_list.php | 53 ++++++++++++++----------------
awstats/bureau/admin/aws_pass.php | 4 +--
awstats/bureau/admin/aws_users.php | 22 ++++++++-----
awstats/bureau/admin/menu_aws.php | 5 +--
awstats/bureau/class/m_aws.php | 31 +++++++++--------
6 files changed, 71 insertions(+), 64 deletions(-)
diff --git a/awstats/bureau/admin/aws_del.php b/awstats/bureau/admin/aws_del.php
index 3b7e5655..d603ff06 100644
--- a/awstats/bureau/admin/aws_del.php
+++ b/awstats/bureau/admin/aws_del.php
@@ -29,16 +29,16 @@ $error="";
reset($_POST);
$found=false;
while (list($key,$val)=each($_POST)) {
- if (substr($key,0,4)=="del_") {
- // Effacement du jeu de stats $val
- $r=$aws->delete_stats($val);
- $found=true;
- if (!$r) {
- $error.=$err->errstr()."
";
- } else {
- $error.=sprintf(_("The statistics %s has been successfully deleted"),$r)."
";
- }
- }
+ if (substr($key,0,4)=="del_") {
+ // Effacement du jeu de stats $val
+ $r=$aws->delete_stats($val);
+ $found=true;
+ if (!$r) {
+ $error.=$err->errstr()."
";
+ } else {
+ $error.=sprintf(_("The statistics %s has been successfully deleted"),$r)."
";
+ }
+ }
}
if (!$found) {
diff --git a/awstats/bureau/admin/aws_list.php b/awstats/bureau/admin/aws_list.php
index d168ceec..e6c4f6c5 100644
--- a/awstats/bureau/admin/aws_list.php
+++ b/awstats/bureau/admin/aws_list.php
@@ -24,6 +24,14 @@
*/
require_once("../class/config.php");
include_once("head.php");
+?>
+
+
+
+
+$error
"; $error=''; } ?>
+
+get_list()) {
@@ -31,25 +39,18 @@ if (!$r=$aws->get_list()) {
$nosta=true;
}
+if (!empty($error)) { echo "
$error
"; $error=''; }
?>
-
-
-
-
-
-cancreate("aws")) { ?>
-
-
-
-$error";
- }
-if (!$nosta) {
-?>
+
+
+cancreate("aws")) { ?>
+
+
+
+
+
-
diff --git a/awstats/bureau/admin/aws_pass.php b/awstats/bureau/admin/aws_pass.php
index c2eef55e..ed63f811 100644
--- a/awstats/bureau/admin/aws_pass.php
+++ b/awstats/bureau/admin/aws_pass.php
@@ -61,7 +61,7 @@ include_once("head.php");
-
+
diff --git a/awstats/bureau/admin/menu_aws.php b/awstats/bureau/admin/menu_aws.php
index d096ea48..5e596db0 100644
--- a/awstats/bureau/admin/menu_aws.php
+++ b/awstats/bureau/admin/menu_aws.php
@@ -32,9 +32,10 @@
$q = $quota->getquota("aws");
$r = $quota->getquota("dom");
if (isset($q["t"]) && isset($r["u"]) && $q["t"] > 0 && $r["u"] > 0) {
-
?>
diff --git a/awstats/bureau/class/m_aws.php b/awstats/bureau/class/m_aws.php
index 8dbdb665..88a944ae 100644
--- a/awstats/bureau/class/m_aws.php
+++ b/awstats/bureau/class/m_aws.php
@@ -368,8 +368,8 @@ class m_aws {
$this->allow_login($v,$id, 1);
}
}
- $this->_createconf($id);
- $this->_createhtpasswd();
+ if (!$this->_createconf($id) ) return false;
+ if (!$this->_createhtpasswd() ) return false;
mkdir($this->CACHEDIR."/".$hostname,0777);
return true;
} else {
@@ -468,9 +468,9 @@ class m_aws {
return false;
}
$pass=crypt($pass);
+ // FIXME retourner une erreur l'insert se passe pas bien
$db->query("INSERT INTO aws_users (uid,login,pass) VALUES ('$cuid','$login','$pass');");
- $this->_createhtpasswd();
- return true;
+ return $this->_createhtpasswd();
}
@@ -489,8 +489,7 @@ class m_aws {
}
$pass=crypt($pass);
$db->query("UPDATE aws_users SET pass='$pass' WHERE login='$login';");
- $this->_createhtpasswd();
- return true;
+ return $this->_createhtpasswd();
}
@@ -590,10 +589,9 @@ class m_aws {
foreach ($t as $i) {
$this->_delconf($i);
}
- $this->_createhtpasswd();
$db->query("DELETE FROM aws_access WHERE uid='$cuid'");
$db->query("DELETE FROM aws_users WHERE uid='$cuid';");
- return true;
+ return $this->_createhtpasswd();
}
@@ -616,8 +614,7 @@ class m_aws {
$db->query("DELETE FROM aws_access WHERE uid='$cuid' AND id='".$i[1]."';");
$this->_delconf($i[0]);
}
- $this->_createhtpasswd();
- return true;
+ return $this->_createhtpasswd();
}
@@ -685,7 +682,11 @@ class m_aws {
*/
function _createconf($id,$nochk=0) {
global $db,$err,$cuid;
- $s=implode("",file($this->TEMPLATEFILE));
+ $s=@implode("",file($this->TEMPLATEFILE));
+ if (!$s) {
+ $err->raise("aws",_("Problem to create the configuration"));
+ return false;
+ }
if ($nochk) {
$db->query("SELECT * FROM aws WHERE id='$id';");
} else {
@@ -716,14 +717,18 @@ class m_aws {
/* ----------------------------------------------------------------- */
function _createhtpasswd() {
- global $db;
- $f=fopen($this->HTAFILE,"wb");
+ global $db, $err;
+ $f=@fopen($this->HTAFILE,"wb");
if ($f) {
$db->query("SELECT login,pass FROM aws_users;");
while ($db->next_record()) {
fputs($f,$db->f("login").":".$db->f("pass")."\n");
}
fclose($f);
+ return true;
+ } else {
+ $err->raise("aws",sprintf(_("Problem to edit file %s"), $this->HTAFILE));
+ return false;
}
}