![]() |
|
|
|||||||
| For more information about the ads and why they're here, please see the FAQ |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi All!
This is my Quota Fix for Cpanel User. ONLY FOR CPANEL USER!
easy! let's do it!0) go to /etc and set the chmod 664 for the file userdomains 1) download gauge.zip file attach and unzip into skins/default/images or your_skin_dir/images 2) open program/steps/mail/func.ini and search for: Code:
function rcmail_quota_display($attrib) Code:
function rcmail_quota_display($attrib)
{
global $IMAP, $OUTPUT, $JS_OBJECT_NAME;
if (!$attrib['id'])
$attrib['id'] = 'rcmquotadisplay';
$OUTPUT->add_script(sprintf("%s.gui_object('quotadisplay', '%s');", $JS_OBJECT_NAME, $attrib['id']));
// allow the following attributes to be added to the <span> tag
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
//Cpanel Quota Fix by Fabio Vaona
$cpanel_uname = '';
$quota_text = rcube_label('unknown');
$this_user = explode('@',$_SESSION['username']);
$file = file("/etc/userdomains"); //this file must have 664 permissions
foreach($file as $line)
{
if (eregi($this_user[1],$line))
{
$line = explode(':',$line);
$cpanel_uname = trim($line[1]);
break;
}
}
if ($cpanel_uname != '')
{
$file = file("/home/$cpanel_uname/etc/".$this_user[1]."/quota");
foreach($file as $line)
{
if (eregi($this_user[0],$line))
{
$line = explode(':',$line);
$quota_max = trim($line[1]);
break;
}
}
if ($quota_max == '') $quota_text = rcube_label('unlimited');
else
{
$q_userd = getdirquota("/home/$cpanel_uname/mail/".$this_user[1]."/".$this_user[0]);
$q_percent = round(($q_userd*100)/$quota_max , 2);
if($q_percent < 10) $q_img = 'spazio0.gif';
elseif($q_percent < 20) $q_img = 'spazio20.gif';
elseif($q_percent < 40) $q_img = 'spazio40.gif';
elseif($q_percent < 60) $q_img = 'spazio60.gif';
elseif($q_percent < 80) $q_img = 'spazio80.gif';
else $q_img = 'spazio100.gif';
$quota_text = "<img src=\"".$CONFIG['skin_path']."/images/$q_img\"> ".CoolSize($q_userd)." / ".CoolSize($quota_max). " ($q_percent %)";//sprintf("%.2fMB / %.2fMB (%.0f%%)", disk_total_space("/home/$cpanel_uname/mail/".$this_user[1]."/".$this_user[0]) / 1000000.0, $quota_max / 1000000.0, 33);
}
}
$out = '<span' . $attrib_str . '>';
$out .= $quota_text;
$out .= '</span>';
return $out;
}
function getdirquota($dirname)
{
$space = 0;
if ($handle = opendir($dirname))
{
$dirname == "." ? $dirname = "" : $dirname = $dirname."/";
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != "")
{
if (!is_dir($dirname.$file))
{
$space += filesize($dirname.$file);
}
}
}
closedir($handle);
}
return $space;
}
function CoolSize($size)
{
$mb = 1024*1024;
if ( $size > $mb ) $mysize = sprintf ("%01.2f",$size/$mb) . " MB";
elseif ( $size >= 1024 ) $mysize = sprintf ("%01.2f",$size/1024) . " Kb";
else $mysize = $size . " bytes";
return $mysize;
}
I moved the text up: 4) open skins/default/templates/mail.html 5) cut Code:
<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" /> Code:
<div id="listcontrols"> Code:
<div id="messagetoolbar"> Let me know! Fabio ![]() |
|
#2
|
|||
|
|||
|
or.. you can upgrade the the latest cpanel. They have switched to a new IMAP server that supports quotas correctly with RC.
|
|
#3
|
|||
|
|||
|
What version do you mean ?
My ISP is running version: 10.9.0-STABLE 35 without quota support.... ![]() |
|
#4
|
|||
|
|||
|
I don't know if into upgade version of cpanel the "rc quota usage" works...
if not, my solution works. The only problem is on /etc/userdomains file chmod. I have notice that cpanel reset chmod 660 on /etc/userdomains every day! So i can't read this file by php.... The solution is set a root cron jon that copy this file into another... I have cerate the follow script file named /etc/rcscript Code:
su -l root -c "chmod 666 /etc/userdomains" su -l root -c "cp /etc/userdomains /etc/rcscript" su -l root -c "chmod 666 /etc/rcdomains" su -l root -c "chmod 660 /etc/userdomains" Code:
30 0 * * * root /etc/rcscript replace: Code:
$file = file("/etc/userdomains"); //this file must have 664 permissions
Code:
$file = file("/etc/rcdomains");
so, every night at 00:30 the system start /etc/rcscript as root that copy /etc/userdomains into /etc/rcdomains ciao Fabio ![]() |
|
#5
|
|||
|
|||
|
Worked perfectly for me. Thanks.
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
| For more information about the ads and why they're here, please see the FAQ |