You are not logged in.
#1 2011-08-22 19:30:30
- focale31
- Member
How to set a limit per user
Hello,
here is a mod to limit the amount of images uploaded into the galleries (if your Sgal script is used by a lot of subscribers), i.e. a "quota" system for each user.
Notes : a new line is also needed in singapore.ini called $quota (i.e. max capacity for the folder of this user)
In newimage.tpl.php , i added a few lines :
Just before <form action="<?php echo $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data" method="post">
i added theses lines :
<?php
function DirSize($rep , $recursive=TRUE){
$size = 0;
if(!is_dir($rep) || !is_readable($rep))
return 0;
$fd = dir($rep);
while($file = $fd->read()){
if(($file != ".") && ($file != "..")){
if(@is_dir("$rep$file/"))
$size += $recursive?DirSize("$rep$file/"):0;
else
$size += filesize("$rep$file");
}
}
$fd->close();
return $size;
}
$rep = "galleries/";
$folder_size = Round((DirSize($rep)/1024000),1);
$quota = $sg->config->quota;
if ($quota != "" && $quota < $folder_size) {
echo $sg->translator->_g("here, a message for user if the folder is full");
}
else {
?>
and just after
</table>
</form>
i added :
<?php
} end of the test
?>
It works fine for my web site : http://www.focale31.com.
Hope this will help !
Herve (Toulouse - France)
Last edited by focale31 (2011-08-22 19:31:50)
Offline
#2 2011-08-22 19:50:03
- DC
- Administrator
Re: How to set a limit per user
It's cool you came up with this mod. I did a mod a ways back that only allowed so many images per a gallery, that mod just did a count. Your mod takes that idea even farther, very nice ... feel free to share any mods you come up with in this section of the forum.
Sorry, I had to move your other mod as it was not in the correct section.
I have not tested your mod yet but quick glance it looks good.
DC
To code or not to code that is the question?
Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php
Offline