QQues bugs corrigé et une GROSSE optimisation sur les quotas :

Les quota était recalculé une dizaine de fois par page... y compris le quota disque (donc avec un exec, etc).
Là, c'est calculé une fois par chargement.
This commit is contained in:
Alan Garcia 2011-03-06 21:28:14 +00:00
parent e0c1792d14
commit 73d9d06ace
5 changed files with 40 additions and 31 deletions

View File

@ -32,12 +32,13 @@ require_once("../class/config.php");
include_once ("head.php");
$p=$bro->GetPrefs();
if (! isset($R)) $R='';
if (!$R && $p["golastdir"]) {
$R=$p["lastdir"];
}
$R=$bro->convertabsolute($R,1);
// on fait ?
if ($formu) {
if (isset($formu) && $formu) {
switch ($formu) {
case 1: // Créer le répertoire $R.$nomfich
if (!$bro->CreateDir($R,$nomfich)) {
@ -115,7 +116,7 @@ if ($formu) {
}
}
if ($actextract) {
if (isset($actextract) && $actextract) {
print _("extracting...")."<br />\n"; flush();
if ($bro->ExtractFile($R. '/' . $file, $R)) {
echo "<p class=\"error\">";
@ -128,7 +129,7 @@ if ($actextract) {
}
/* Creation de la liste des fichiers courants */
$c=$bro->filelist($R, $_REQUEST['showdirsize']);
$c=$bro->filelist($R, isset($_REQUEST['showdirsize'])?$_REQUEST['showdirsize']:null );
if ($c===false) $error=$err->errstr();
?>
@ -143,7 +144,7 @@ if ($c===false) $error=$err->errstr();
<?php __("Path"); ?> / <a href="bro_main.php?R=/"><?php echo $mem->user["login"]; ?></a>&nbsp;/&nbsp;<?php echo $bro->PathList($R,"bro_main.php") ?>
</p>
<?php if ($error) echo "<p class=\"error\">$error</p>"; ?>
<?php if (isset($error) && $error) echo "<p class=\"error\">$error</p>"; ?>
<table><tr>
<td class="formcell">
@ -184,7 +185,7 @@ if ($c===false) $error=$err->errstr();
<?php
/* Renommer / Copier / Déplacer les fichiers : */
if ($formu==2 && $actrename && count($d)) {
if (isset($formu) && $formu==2 && $actrename && count($d)) {
echo "<table cellpadding=\"6\">\n";
echo "<form action=\"bro_main.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
@ -201,7 +202,7 @@ if ($formu==2 && $actrename && count($d)) {
}
/* [ML] Changer les permissions : */
if ($formu==2 && $_REQUEST['actperms'] && count($d)) {
if (isset($formu) && $formu==2 && $_REQUEST['actperms'] && count($d)) {
echo "<form action=\"bro_main.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
echo "<input type=\"hidden\" name=\"formu\" value=\"7\" />\n";

View File

@ -162,7 +162,7 @@ sub_domains_edit($domain);
modification des parametres dns
-->
<?php
if (!$r[noerase]) {
if (!$r['noerase']) {
?>
<hr />

View File

@ -37,7 +37,7 @@ $r=$mysql->get_dblist();
<hr id="topbar"/>
<br />
<?php
if ($error) {
if (isset($error) && $error) {
echo "<p class=\"error\">$error</p>";
}

View File

@ -693,10 +693,11 @@ class m_bro {
$path=$this->convertabsolute($path,1);
$a=explode("/",$path);
if (!is_array($a)) $a=array($a);
$c='';
for($i=0;$i<count($a);$i++) {
if ($a[$i]) {
$R.=$a[$i]."/";
$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a>&nbsp;/&nbsp;";
$R.=$a[$i]."/";
$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a>&nbsp;/&nbsp;";
}
}
return $c;

View File

@ -124,31 +124,37 @@ class m_quota {
* @Return array the quota used and total for this ressource (or for all ressource if unspecified)
*/
function getquota($ressource="") {
global $db,$err,$cuid;
global $db,$err,$cuid,$get_quota_cache;
$err->log("quota","getquota",$ressource);
$this->qlist(); // Generate the quota list.
$db->query("select * from quotas where uid='$cuid';");
if ($db->num_rows()==0) {
return array("t"=>0, "u"=>0);
if (! empty($get_quota_cache) ) {
// This function is called many time each webpage, so I cache the result
$this->quotas = $get_quota_cache;
} else {
while ($db->next_record()) {
$ttmp[]=$db->Record;
}
$this->qlist(); // Generate the quota list.
$db->query("select * from quotas where uid='$cuid';");
if ($db->num_rows()==0) {
return array("t"=>0, "u"=>0);
} else {
while ($db->next_record()) {
$ttmp[]=$db->Record;
}
foreach ($ttmp as $tt) {
$g=array("t"=>$tt["total"],"u"=>0);
if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) {
$g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]);
}
$this->quotas[$tt["name"]]=$g;
}
$g=array("t"=>$tt["total"],"u"=>0);
if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) {
$g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]);
}
$this->quotas[$tt["name"]]=$g;
}
}
reset($this->disk);
while (list($key,$val)=each($this->disk)) {
$a=array();
exec("/usr/lib/alternc/quota_get ".$cuid." ".$val,$a);
$this->quotas[$val]=array("t"=>$a[1],"u"=>$a[0]);
}
$get_quota_cache = $this->quotas;
}
reset($this->disk);
while (list($key,$val)=each($this->disk)) {
$a=array();
exec("/usr/lib/alternc/quota_get ".$cuid." ".$val,$a);
$this->quotas[$val]=array("t"=>$a[1],"u"=>$a[0]);
}
if ($ressource) {
return $this->quotas[$ressource];
} else {
@ -157,6 +163,7 @@ class m_quota {
}
/* ----------------------------------------------------------------- */
/** Set the quota for a user (and for a ressource)
* @param string $ressource ressource to set quota of