3 require_once(
"/usr/share/alternc/panel/class/config_nochk.php");
9 echo
"usage : script -[m|l|d]\n";
12 #arguments can be a mailbox or a domain or a login
15 #parser les arguments correctement.
16 #We check that only one type of option is specified
24 #we check that for that type only one option is specified
34 #function taking a query used to select the mailbox(es) root and updating their quotas into the mailbox table
38 $query=
"SELECT mailbox.id,concat(path, '/Maildir/') as dir
41 join address on address.id = mailbox.address_id
42 join domaines on domaines.id = address.domain_id
49 while ($db->next_record()) {
52 $size = exec (
"/usr/bin/du -sb $dir|cut -f1" );
53 if(!
$db2->query(
"UPDATE mailbox set bytes=".intval($size).
" where id=".intval($id).
";")){
54 echo
"Fail updating quota for mailbox : $id\n";
60 #We construct a sql query to get the mailbox root based on the option.
63 if (!filter_var(
$val,FILTER_VALIDATE_EMAIL)) {
64 usage(
"The email you entered is syntaxically incorrect");
67 $cond =
"WHERE concat(address.address,'@',domaines.domaine) ='".$val.
"'" ;
70 $login=strtolower(
$val);
71 if (!preg_match(
"#^[a-z0-9]+$#",$login)) {
72 usage(
"the login you entered is syntaxically incorrect");
75 $cond =
"join membres on domaines.compte = membres.uid WHERE membres.login = '".mysql_real_escape_string($login).
"'";
79 usage(
"The domain you entered is syntaxically incorrect");
82 $cond =
"WHERE domaines.domaine = '".mysql_real_escape_string(
$val).
"'" ;