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

View File

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

View File

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

View File

@ -693,6 +693,7 @@ class m_bro {
$path=$this->convertabsolute($path,1); $path=$this->convertabsolute($path,1);
$a=explode("/",$path); $a=explode("/",$path);
if (!is_array($a)) $a=array($a); if (!is_array($a)) $a=array($a);
$c='';
for($i=0;$i<count($a);$i++) { for($i=0;$i<count($a);$i++) {
if ($a[$i]) { if ($a[$i]) {
$R.=$a[$i]."/"; $R.=$a[$i]."/";

View File

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