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:
parent
e0c1792d14
commit
73d9d06ace
|
@ -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> / <?php echo $bro->PathList($R,"bro_main.php") ?>
|
<?php __("Path"); ?> / <a href="bro_main.php?R=/"><?php echo $mem->user["login"]; ?></a> / <?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";
|
||||||
|
|
|
@ -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 />
|
||||||
|
|
|
@ -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>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -693,10 +693,11 @@ 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]."/";
|
||||||
$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a> / ";
|
$c.="<a href=\"$action?R=".urlencode($R)."\">".$a[$i]."</a> / ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $c;
|
return $c;
|
||||||
|
|
|
@ -124,31 +124,37 @@ 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);
|
||||||
$this->qlist(); // Generate the quota list.
|
if (! empty($get_quota_cache) ) {
|
||||||
$db->query("select * from quotas where uid='$cuid';");
|
// This function is called many time each webpage, so I cache the result
|
||||||
if ($db->num_rows()==0) {
|
$this->quotas = $get_quota_cache;
|
||||||
return array("t"=>0, "u"=>0);
|
|
||||||
} else {
|
} else {
|
||||||
while ($db->next_record()) {
|
$this->qlist(); // Generate the quota list.
|
||||||
$ttmp[]=$db->Record;
|
$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) {
|
foreach ($ttmp as $tt) {
|
||||||
$g=array("t"=>$tt["total"],"u"=>0);
|
$g=array("t"=>$tt["total"],"u"=>0);
|
||||||
if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) {
|
if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) {
|
||||||
$g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]);
|
$g["u"]=$GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"]);
|
||||||
}
|
}
|
||||||
$this->quotas[$tt["name"]]=$g;
|
$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) {
|
if ($ressource) {
|
||||||
return $this->quotas[$ressource];
|
return $this->quotas[$ressource];
|
||||||
} else {
|
} else {
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue