Jump to content

[SOLVED] Help With Quota %


steviez

Recommended Posts

Hi,

 

I am trying to make my code work, if my users have a quota limit of say 100MB and they try to upload a file bigger than what quota they have left i need it to not allow then to do so.

 

My code so far for their quota:

 

<?php
// Select Total Space Used
$sql = "SELECT SUM(size) AS sum_size FROM `uploads` WHERE uploader = '".$user_name."' ";
$result = mysql_query($sql) or die(mysql_error());
$i = mysql_fetch_array($result);
$space_used =  $i['sum_size'];  
$max_space = $settings['max_free_space'] * 1024 *1024; //100MB

// If Over Account Quota 
if($space_used > $max_space){
    $over_use = true;
}else{
    $over_use = false;
}

$smarty->assign("over_use", $over_use);

// Show Space Used As %
$smarty->assign("used",number_format($space_used/$max_space*100,0)."%");
$smarty->assign("used_sub",ByteSize($space_used)." out of allowed ".ByteSize($max_space));

?>

 

Is this possable?

Link to comment
https://forums.phpfreaks.com/topic/78548-solved-help-with-quota/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.