andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


How to get started

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> User Quota
View previous topic :: View next topic  
Author Message
vaseyandco
Newbie


Joined: 26 Aug 2003
Posts: 1
Location: Leeds, UK

PostPosted: Tue Aug 26, 2003 3:38 pm    Post subject: How to get started Reply with quote

I have the code, but I'm not sure how to get going.

I want to show the users used quota, However I dont know what I need to do, how to call the file.

What i was thinking, user puts in user name, (clicks) server does a quota -u on the server and generates a graph from the demo the graphs look great. but I'm not sure how to get going.

Any help would be appreciated. on message board or msn.
Thanks
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Aug 26, 2003 4:01 pm    Post subject: Reply with quote

Hi Vaseyandco,

Welcome to the board!

First start by checking out this thread:

http://php.amnuts.com/forums/viewtopic.php?t=31

This gives and example of how to get the user's quota. Bare in mind, though, that this may or may not produce the desired results on your platform. Best to check the output returned to see if it's in a meaningful format.

Then you could do something as simple as:

PHP:
<?php

require("class.userquota.php");
$uq = new userQuota($quota$used);
$uq->setOutputImage();
$uq->setImageProperties(50TRUETRUETRUE'DDDDDD''ED1C24''FFFFFF''55555');
$uq->displayQuota();

?>


which is an example taken from this thread:

http://php.amnuts.com/forums/viewtopic.php?t=46

where you pass it two variables, $quota and $used, which you could gather from your quota generating function (see first thread.)

Any problems, just post back up! Smile

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Aug 29, 2003 2:20 am    Post subject: Reply with quote

Hi,

Another option, rather than using the 'quota' command is to use the 'du' command, such as:

du -s /path/to/username

For example, if I did this on one of my accounts:

du -s /home/amnuts

then I get the following displayed back:

66432 /home/amnuts

I can then split that and I have my disk space used. Of course, if you have a seperate www space then you may want to run a similar command on that and add it to the home figure.

Now that I have my used disk space, I supply what the quota for my account is and I can generate the chart. So to totally wing it first thing in the morning just as I've gotten in to work (in other words, this may not working correctly! Wink ), you could end up with somethig like this:

PHP:
<?php

$quota 
30 1024;  // 30Mb quota, but we want it in bytes
$homepath '/home/';
$username $_POST['user'];

exec('du -s ' $homepath escapeshellcmd($username), $return);
list(
$used$path) = split(' '$return);

if (
$used)
{
     require(
"class.userquota.php"); 
     
$uq = new userQuota($quota$used$username);
     
$uq->setOutputImage(); 
     
$uq->setImageProperties(75TRUETRUETRUE'DDDDDD''ED1C24''FFFFFF''55555'); 
     
$uq->displayQuota(); 

?>


Something like that, anyway. Smile
Hope it helps.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> User Quota All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group