Quotas en un seul hooks. Avec normalement du cache.
This commit is contained in:
parent
270aef8532
commit
1faef827b6
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_adm.php,v 1.4 2004/11/04 06:33:23 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file: Benjamin Sonntag
|
||||
Purpose of file: Menu of the super-admins
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############################# */
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_aide.php,v 1.3 2004/05/19 14:23:06 benjamin Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_brouteur.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,13 +18,10 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# BROUTEUR ############# */
|
||||
?>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title"><img src="images/folder.png" alt="<?php __("File browser"); ?>" /> <a href="bro_main.php"><?php __("File browser"); ?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_mail.php,v 1.3 2004/05/19 14:23:06 benjamin Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,15 +19,12 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# CRON ############# */
|
||||
|
||||
$q = $quota->getquota("cron");
|
||||
if ($q['t'] > 0) {
|
||||
if ($q['t'] > 0 || $q['u'] > 0) {
|
||||
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_dom.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,15 +19,12 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# DOMAINES ############# */
|
||||
$q = $quota->getquota("dom");
|
||||
|
||||
if ($q["t"] > 0)
|
||||
if ($q["t"] > 0 || $q['u'] > 0)
|
||||
{
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_ftp.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,16 +19,13 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# FTP ############# */
|
||||
|
||||
$q = $quota->getquota("ftp");
|
||||
|
||||
if ($q["t"] > 0) {
|
||||
if ($q["t"] > 0 || $q['u'] > 0) {
|
||||
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_ip.php
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# IP ############# */
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_logs.php
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file: Lerider Steven
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# LOGS ############# */
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_mail.php,v 1.3 2004/05/19 14:23:06 benjamin Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,16 +19,13 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# MAILS ############# */
|
||||
|
||||
$q = $quota->getquota("mail");
|
||||
$r = $quota->getquota("dom");
|
||||
if ($q["t"] > 0 && $r["u"] > 0) {
|
||||
if ($q["t"] > 0 || $r["u"] > 0) {
|
||||
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_mem.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
@ -33,4 +26,4 @@
|
|||
</div>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title"><img src="images/exit.png" alt="<?php __("Logout"); ?>" /> <a href="mem_logout.php" target="_parent"><?php __("Logout"); ?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_piwik.php,v 1.1 2004/05/24 15:28:42 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,14 +19,11 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# PIWIK ############# */
|
||||
$q = $quota->getquota("piwik");
|
||||
if (!empty($piwik->piwik_server_uri) && $q["t"] > 0 && $r["u"] > 0) {
|
||||
if (!empty($piwik->piwik_server_uri) && ($q["t"] > 0 || $r["u"] > 0)) {
|
||||
?>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title"><img src="images/stat.png" alt="<?php __("Piwik statistics"); ?>" /> <a href="piwik_userlist.php"><?php __("Piwik statistics"); ?> (<?php echo $q["u"]; ?>/<?php echo $q["t"]; ?>)</a></div>
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_quota.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,9 +19,6 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
?>
|
||||
<div class="menu-box">
|
||||
|
@ -47,6 +40,7 @@ $first=true;
|
|||
while (list($key,$val)=each($qlist)) {
|
||||
$col=3-$col;
|
||||
|
||||
// FIXME: rewrite it
|
||||
if (($key == 'bw_web' || $key == 'web') && (isset($q[$key]["t"]) && $q[$key]["t"] > 0)) {
|
||||
if ($first) {
|
||||
echo '<dt id="#quotas">' . _("Quotas") . '</dt>';
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_sql.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,12 +19,9 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
$q = $quota->getquota("mysql");
|
||||
if ($q["t"]) {
|
||||
if ($q["t"] > 0 || $q['u'] >0) {
|
||||
?>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title">
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_sta2.php,v 1.1 2004/05/24 15:28:42 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
https://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
|
@ -23,15 +19,12 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# STATS ############# */
|
||||
$q = $quota->getquota("sta2");
|
||||
$r = $quota->getquota("dom");
|
||||
if ($q["t"] > 0 && $r["u"] > 0) {
|
||||
if ($q["t"] > 0 || $r["u"] > 0) {
|
||||
?>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title"><img src="images/stat.png" alt="<?php __("Raw web statistics"); ?>" /> <a href="sta2_list.php"><?php __("Raw web statistics"); ?> (<?php echo $q["u"]; ?>/<?php echo $q["t"]; ?>)</a></div>
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: menu_web.php,v 1.2 2003/06/10 06:42:25 root Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
@ -23,13 +19,10 @@
|
|||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file:
|
||||
Purpose of file:
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ############# WEB ACCESS ############# */
|
||||
?>
|
||||
<div class="menu-box">
|
||||
<div class="menu-title"><img src="images/password.png" alt="<?php __("Protected folders"); ?>" /> <a href="hta_list.php"><?php __("Protected folders"); ?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -152,26 +152,18 @@ class m_cron {
|
|||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** hook for quota name
|
||||
*/
|
||||
function hook_quota_names() {
|
||||
return array("cron"=>_("Scheduled tasks"));
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** hook for quota computation
|
||||
*/
|
||||
function hook_quota_get() {
|
||||
global $cuid,$db,$err;
|
||||
$err->log("cron","alternc_get_quota");
|
||||
$q=Array("name"=>"cron", "description"=>_("Scheduled tasks"), "used"=>0);
|
||||
$db->query("select count(*) as cnt from cron where uid = $cuid;");
|
||||
if ($db->next_record()) {
|
||||
return $db->f('cnt');
|
||||
$q['used']=$db->f('cnt');
|
||||
}
|
||||
return false;
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,14 +85,6 @@ class m_dom {
|
|||
function m_dom() {
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Quota name
|
||||
*/
|
||||
function hook_quota_names() {
|
||||
return array("dom"=>_("Domain name"));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Retourne un tableau contenant les types de domaines
|
||||
|
@ -1280,14 +1272,15 @@ class m_dom {
|
|||
* @return integer the number of service used or false if an error occured
|
||||
* @access private
|
||||
*/
|
||||
function hook_quota_get($name) {
|
||||
function hook_quota_get() {
|
||||
global $db,$err,$cuid;
|
||||
if ($name=="dom") {
|
||||
$err->log("dom","get_quota");
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM domaines WHERE compte='$cuid'");
|
||||
$db->next_record();
|
||||
return $db->f("cnt");
|
||||
} else return false;
|
||||
$err->log("dom","get_quota");
|
||||
$q=Array("name"=>"dom", "description"=>_("Domain name"), "used"=>0);
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM domaines WHERE compte='$cuid'");
|
||||
if ($db->next_record() ) {
|
||||
$q['used']=$db->f("cnt");
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,14 +38,6 @@ class m_ftp {
|
|||
function m_ftp() {
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Quota name
|
||||
*/
|
||||
function alternc_quota_names() {
|
||||
return "ftp";
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
|
@ -365,14 +357,15 @@ class m_ftp {
|
|||
* @return integer the number of service used or false if an error occured
|
||||
* @access private
|
||||
*/
|
||||
function alternc_get_quota($name) {
|
||||
function hook_quota_get() {
|
||||
global $db,$err,$cuid;
|
||||
if ($name=="ftp") {
|
||||
$err->log("ftp","getquota");
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM ftpusers WHERE uid='$cuid'");
|
||||
$db->next_record();
|
||||
return $db->f("cnt");
|
||||
} else return false;
|
||||
$err->log("ftp","getquota");
|
||||
$q=Array("name"=>"ftp", "description"=>_("FTP accounts"), "used"=>0);
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM ftpusers WHERE uid='$cuid'");
|
||||
if ($db->next_record()) {
|
||||
$q['used']=$db->f("cnt");
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,15 +65,6 @@ class m_mail {
|
|||
*/
|
||||
var $total;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** Quota list (hook for quota class, returns an array of hashes)
|
||||
*/
|
||||
function hook_quota_names() {
|
||||
return array("mail"=>_("Email addresses"));
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** get_quota (hook for quota class), returns the number of used
|
||||
* service for a quota-bound service
|
||||
|
@ -81,15 +72,15 @@ class m_mail {
|
|||
* @return the number of used service for the specified quota,
|
||||
* or false if I'm not the one for the named quota
|
||||
*/
|
||||
function hook_quota_get($name) {
|
||||
function hook_quota_get() {
|
||||
global $db,$err,$cuid;
|
||||
if ($name=="mail") {
|
||||
$err->log("mail","getquota");
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM address a, domaines d WHERE a.domain_id=d.id AND d.compte=$cuid AND a.type='';");
|
||||
$db->next_record();
|
||||
return $db->f("cnt");
|
||||
$err->log("mail","getquota");
|
||||
$q=Array("name"=>"mail", "description"=>_("Email addresses"), "used"=>0);
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM address a, domaines d WHERE a.domain_id=d.id AND d.compte=$cuid AND a.type='';");
|
||||
if ($db->next_record()) {
|
||||
$q['used']=$db->f("cnt");
|
||||
}
|
||||
return false;
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,15 +48,6 @@ class m_piwik {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Quota name
|
||||
*/
|
||||
function hook_quota_names() {
|
||||
return array("piwik"=>_("Statistics through Piwik accounts"));
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** hook called when an AlternC account is deleted
|
||||
*/
|
||||
|
@ -72,14 +63,14 @@ class m_piwik {
|
|||
* @return integer the number of service used or false if an error occured
|
||||
* @access private
|
||||
*/
|
||||
function hook_quota_get($name) {
|
||||
function hook_quota_get() {
|
||||
global $db, $cuid;
|
||||
if ($name=="piwik") {
|
||||
$db->query("SELECT COUNT(id) AS nb FROM piwik_users WHERE uid='$cuid'");
|
||||
$db->next_record();
|
||||
return $db->f('nb');
|
||||
} else
|
||||
return false;
|
||||
$db->query("SELECT COUNT(id) AS nb FROM piwik_users WHERE uid='$cuid'");
|
||||
$q=Array("name"=>"piwik", "description"=>_("Statistics through Piwik accounts"), "used"=>0);
|
||||
if ($db->next_record()) {
|
||||
$q['used']=$db->f('nb');
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -74,32 +74,10 @@ class m_quota {
|
|||
while (list($key,$val)=each($this->disk)) {
|
||||
$qlist[$key]=_("quota_".$key); // those are specific disks quotas.
|
||||
}
|
||||
// TODO: old hook method FIXME: remove this when unused
|
||||
foreach($classes as $c) {
|
||||
if (method_exists($GLOBALS[$c],"alternc_quota_names")) {
|
||||
$res=$GLOBALS[$c]->alternc_quota_names(); // returns a string or an array.
|
||||
if($res != "") {
|
||||
if (is_array($res)) {
|
||||
foreach($res as $k) {
|
||||
$qlist[$k]=_("quota_".$k);
|
||||
$this->clquota[$k]=$c;
|
||||
}
|
||||
} else {
|
||||
$qlist[$res]=_("quota_".$res);
|
||||
$this->clquota[$res]=$c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->getquota() as $qq) {
|
||||
$qlist[$qq['name']]=$qq['description'];
|
||||
}
|
||||
// New Hook
|
||||
$qname=$hooks->invoke("hook_quota_names"); // return strings or arrays
|
||||
foreach($qname as $res)
|
||||
if ($res && is_array($res)) {
|
||||
foreach($res as $k=>$v) {
|
||||
$qlist[$k]=$v;
|
||||
$this->clquota[$k]=$k;
|
||||
}
|
||||
}
|
||||
return $qlist;
|
||||
}
|
||||
|
||||
|
@ -116,48 +94,27 @@ class m_quota {
|
|||
// This function is called many time each webpage, so I cache the result
|
||||
$this->quotas = $get_quota_cache[$cuid];
|
||||
} else {
|
||||
$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->f("name")]=$db->Record;
|
||||
}
|
||||
foreach($this->clquota as $k=>$v) {
|
||||
if (!isset($ttmp[$k])) {
|
||||
$ttmp[$k]=array("name" => $k, "total" => 0);
|
||||
}
|
||||
}
|
||||
// TODO: old hook method FIXME: remove when unused
|
||||
foreach ($ttmp as $tt) {
|
||||
if (! isset( $this->clquota[$tt["name"]] )) continue;
|
||||
if (method_exists($GLOBALS[$this->clquota[$tt["name"]]],"alternc_get_quota")) {
|
||||
$this->quotas[$tt["name"]] =
|
||||
array(
|
||||
"t"=>$tt["total"],
|
||||
"u"=> $GLOBALS[$this->clquota[$tt["name"]]]->alternc_get_quota($tt["name"])
|
||||
);
|
||||
}
|
||||
}
|
||||
// New Hook :
|
||||
foreach ($ttmp as $tt) {
|
||||
$res=$hooks->invoke("hook_quota_get",array($tt["name"]));
|
||||
foreach($res as $r) {
|
||||
if ($r!==false) {
|
||||
$this->quotas[$tt["name"]]=array("t"=>$tt["total"],"u"=>$r);
|
||||
}
|
||||
}
|
||||
$res=$hooks->invoke("hook_quota_get");
|
||||
foreach($res as $r) {
|
||||
$this->quotas[$r['name']]=$r;
|
||||
$this->quotas[$r['name']]['u']=$r['used']; // retrocompatibilité
|
||||
$this->quotas[$r['name']]['t']=0; // Default quota = 0
|
||||
}
|
||||
reset($this->disk);
|
||||
while (list($key,$val)=each($this->disk)) {
|
||||
$a=array();
|
||||
exec("/usr/lib/alternc/quota_get ".$cuid ,$a);
|
||||
$this->quotas[$val]=array("t"=>$a[1],"u"=>$a[0]);
|
||||
$this->quotas[$val]=array("name"=>"$val", 'description'=>_("quota_".$val), "t"=>$a[1],"u"=>$a[0]);
|
||||
}
|
||||
|
||||
// Get the allowed quota from database.
|
||||
$db->query("select name, total from quotas where uid='$cuid';");
|
||||
while ( $db->next_record() ) {
|
||||
$this->quotas[$db->f('name')]['t']=$db->f('total');
|
||||
}
|
||||
|
||||
$get_quota_cache[$cuid] = $this->quotas;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ressource) {
|
||||
if (isset($this->quotas[$ressource]) ) {
|
||||
|
@ -262,7 +219,6 @@ class m_quota {
|
|||
function addtype($type) {
|
||||
global $db,$err;
|
||||
$qlist=$this->qlist();
|
||||
reset($qlist);
|
||||
if(empty($type)) return false;
|
||||
$type=strtolower($type);
|
||||
if (!preg_match("#^[a-z0-9]*$#",$type)) {
|
||||
|
@ -301,7 +257,6 @@ class m_quota {
|
|||
function deltype($type) {
|
||||
global $db;
|
||||
$qlist=$this->qlist();
|
||||
reset($qlist);
|
||||
|
||||
if($db->query("UPDATE membres SET type='default' WHERE type='$type'") &&
|
||||
$db->query("DELETE FROM defquotas WHERE type='$type'")) {
|
||||
|
|
|
@ -47,16 +47,6 @@ class m_sta2 {
|
|||
function m_sta2() {
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** Hook function that returns the quota names for this class
|
||||
*
|
||||
* @return string the quota names for this class
|
||||
*/
|
||||
function alternc_quota_names() {
|
||||
return "sta2";
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/** Returns the list of domains and/or subdomains for this account
|
||||
*
|
||||
|
@ -271,14 +261,15 @@ class m_sta2 {
|
|||
* @return integer the number of service used or false if an error occured
|
||||
* @access private
|
||||
*/
|
||||
function alternc_get_quota($name) {
|
||||
function hook_quota_get() {
|
||||
global $db,$err,$cuid;
|
||||
if ($name=="sta2") {
|
||||
$err->log("sta2","get_quota");
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM stats2 WHERE mid='$cuid'");
|
||||
$db->next_record();
|
||||
return $db->f("cnt");
|
||||
} else return false;
|
||||
$err->log("sta2","get_quota");
|
||||
$q=Array("name"=>"sta2", "description"=>_("RAW Statistics"), "used"=>0);
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM stats2 WHERE mid='$cuid'");
|
||||
if ($db->next_record()) {
|
||||
$q['used']=$db->f("cnt");
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -214,3 +214,6 @@ CREATE TABLE IF NOT EXISTS `piwik_sites` (
|
|||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||
|
||||
|
||||
-- No longer MySQL User quotas
|
||||
DELETE FROM defquotas WHERE quota = 'mysql_users';
|
||||
DELETE FROM quotas WHERE name = 'mysql_users';
|
||||
|
|
Loading…
Reference in New Issue