More 'direct mysql_query' removal

This commit is contained in:
domi 2012-08-25 13:25:51 +00:00
parent 92965e64bd
commit 18da67edd9
1 changed files with 42 additions and 51 deletions

View File

@ -55,15 +55,9 @@ if (isset($error) && $error) {
if ($cuid != 2000) if ($cuid != 2000)
{ {
$mList = array(); $mList = array();
$res = mysql_query("SELECT * FROM membres WHERE creator = '" . $cuid . "'"); $membres_list = $admin->get_list(0, $cuid);
while ($n = @mysql_fetch_array($res)) foreach ($membres_list as $n) {
{ $domList = $dom->enum_domains($n["uid"]);
$domList = array();
$res2 = mysql_query("SELECT * FROM domaines WHERE compte = '" . $n["uid"] . "'");
while ($n2 = @mysql_fetch_array($res2))
{
$domList[] = $n2["domaine"];
}
$mList[$n["uid"]] = array ( $mList[$n["uid"]] = array (
"login" => $n["login"], "login" => $n["login"],
"domaines" => $domList, "domaines" => $domList,
@ -110,7 +104,7 @@ if (isset($error) && $error) {
$totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko $totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko
list($dc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM domaines;")); $dc = $dom->count_domains_all();
$mc = $quota->get_size_mail_count_all(); $mc = $quota->get_size_mail_count_all();
$mlc = $quota->get_size_mailman_count_all(); $mlc = $quota->get_size_mailman_count_all();
$dbc = $quota->get_size_db_count_all(); $dbc = $quota->get_size_db_count_all();
@ -180,17 +174,11 @@ if (isset($error) && $error) {
if ($cuid != 2000) if ($cuid != 2000)
{ {
$mList = array(); $mList = array();
$res = mysql_query("SELECT * FROM membres WHERE creator = '" . $cuid . "'"); $membres_list = $admin->get_list(0, $cuid);
while ($n = @mysql_fetch_array($res)) foreach ($membres_list as $minfo) {
{ $domList = $dom->enum_domains($minfo['uid']);
$domList = array(); $mList[$muid] = array (
$res2 = mysql_query("SELECT * FROM domaines WHERE compte = '" . $n["uid"] . "'"); "login" => $minfo['login'],
while ($n2 = @mysql_fetch_array($res2))
{
$domList[] = $n2["domaine"];
}
$mList[$n["uid"]] = array (
"login" => $n["login"],
"domaines" => $domList, "domaines" => $domList,
); );
} }
@ -218,7 +206,7 @@ if ($cuid != 2000)
} }
} }
$mlc = $quota->get_size_mailman_count_domain($mUID); $mlc = $quota->get_size_mailman_count_user($mUID);
$tmpdb = $quota->get_size_db_sum_user($mData["login"]); $tmpdb = $quota->get_size_db_sum_user($mData["login"]);
$totaldb += $tmpdb; $totaldb += $tmpdb;
$dbc = $quota->get_size_db_count_user($mData["login"]); $dbc = $quota->get_size_db_count_user($mData["login"]);
@ -236,38 +224,39 @@ else
$totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko $totaltotal=$totalweb+$totallist+$totalmail+($totaldb/1024); // en Ko
if ($totaltotal==0) $totaltotal=1; if ($totaltotal==0) $totaltotal=1;
if ($cuid != 2000) if ($cuid != 2000) {
{ $membres_list = $admin->get_list(0, $cuid);
$r = mysql_query("SELECT * FROM membres WHERE creator = '" . $cuid . "' ORDER BY login;"); } else {
} $membres_list = $admin->get_list(1);
else
{
$r=mysql_query("SELECT * FROM membres ORDER BY login;");
} }
while ($c=mysql_fetch_array($r)) { foreach ($membres_list as $c) {
echo "<tr><td>"; echo "<tr><td>";
// On affiche le compte et ses domaines : // On affiche le compte et ses domaines :
echo "<b><a href=\"quotas_users.php?mode=".$mode."&sd=".$sd."&usr=".$c["uid"]."\">".$c["login"]."</a></b><br />\n"; echo "<b><a href=\"quotas_users.php?mode=".$mode."&sd=".$sd."&usr=".$c["uid"]."\">".$c["login"]."</a></b><br />\n";
$s=mysql_query("SELECT * FROM domaines WHERE compte='".$c["uid"]."';"); $domaines_list = $dom->enum_domains($c["uid"]);
$dc=0; // Domain Count $dc=0; // Domain Count
$ms=0; // Mail Space $ms=0; // Mail Space
$mls=0; $mls=0;
while ($d=mysql_fetch_array($s)) { foreach ($domaines_list as $d) {
if ($sd) echo "&nbsp;&nbsp;&nbsp;-&nbsp;".$d["domaine"]."<br />\n"; if ($sd) echo "&nbsp;&nbsp;&nbsp;-&nbsp;{$d}<br />\n";
$dc++; $dc++;
$mstmp = $quota->get_size_mail_sum_domain($d["domaine"]); $mstmp = $quota->get_size_mail_sum_domain($d);
$ms+=$mstmp; $ms+=$mstmp;
$mlstmp = $quota->get_size_mailman_sum_domain($d["domaine"]); $mlstmp = $quota->get_size_mailman_sum_domain($d);
$mls+=$mlstmp; $mls+=$mlstmp;
} }
// Mail Count // Mail Count
list($mc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM mail_domain WHERE type=0 AND uid='".$c["uid"]."';")); $maildomains_list = $mail->enum_domains($c["uid"]);
$mc = 0;
foreach ($maildomains_list as $md) {
$mc += $md['nb_mail'];
}
// Mailman List Count // Mailman List Count
list($mlc)=@mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM mailman WHERE uid='".$c["uid"]."';")); $mlc = $mailman->count_ml_user($c["uid"]);
echo "</td><td>$dc</td><td>$mc</td><td>$mlc</td><td"; echo "</td><td>$dc</td><td>$mc</td><td>$mlc</td><td";
if ($mode!=2) echo " style=\"text-align: right\""; if ($mode!=2) echo " style=\"text-align: right\"";
echo ">"; echo ">";
@ -381,23 +370,25 @@ echo "</tr>";
<?php <?php
} else { // Mode affichage d'UN seul compte } else { // Mode affichage d'UN seul compte
if ($cuid != 2000) $oneuser_ok = false;
{ if ($cuid != 2000) {
$c=@mysql_fetch_array(mysql_query("SELECT * FROM membres WHERE uid='".$usr."' AND creator = '" . $cuid . "';")); $c = $admin->get($usr);
} $mcreator = $admin->get_creator($c['uid']);
else if ($mcreator['uid'] == $cuid) {
{ $oneuser_ok = true;
$c=@mysql_fetch_array(mysql_query("SELECT * FROM membres WHERE uid='".$usr."';")); }
} else {
$c = $admin->get($usr);
if ($c != false) {
$oneuser_ok = true;
}
} }
if (!empty($c)) if ($oneuser_ok) { # quotas_oneuser.php will used prefilled $c
{
define("QUOTASONE","1"); define("QUOTASONE","1");
require_once("quotas_oneuser.php"); require_once("quotas_oneuser.php");
} ?>
<?php
} }
} // endif un seul compte
?> ?>
<?php include_once("foot.php"); ?> <?php include_once("foot.php"); ?>