Re: [PHP] calculating kilobytes

2003-02-15 Thread joe

Greg Donald [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Fri, 14 Feb 2003, joe wrote:

 i searched and i tried and i failed. most of the functions dont work in
safe
 mode, some didnt do what i wanted (returned the whole drive size instead
of
 one directroy) etc.
 my head hurts already and i think i am on the verge on nervous breakdown
 because i have been trying to solve this problem for days so could
 somebody please drop me a function here?
 thank you...

 Most people who write code for other people on request are compensated in
 one form or another.  This is a listserv, I doubt anyone here will do
 your work for you for free.  This is place where people get _assistance_
 with code they already attempted to write themselves.  If you tried and
 failed already like you say, post your broken code and people will help
 you figure out your errors.  That's pretty much how it works.

 Also, what you ask may simply not be possible in safe mode, but there's no
 way to tell since you posted no code.


 --
 Greg Donald
 http://destiney.com


whan can i say... i dont have any broken code because im missing the MAIN
ingredient. The right command. For instance i tried disk_total_space(). You
can mark the right folder in that command but somehow it STILL shows the
total size of the hard drive. seriously, i dont have 3.9 gigabytes of files
in my directory.
then i tried something like this:
$quota=100; // max MB

function obsah($adr,$total,$dir,$size){
$dp=OpenDir($adr);

 do{
   $itm=ReadDir($dp);
   if (Is_Dir($adr/$itm)($itm!=.)($itm!=..)($itm!=)){
obsah($adr/$itm,$total,$dir,$size);
 $dir++;
 }
   elseif (($itm!=.)($itm!=..)($itm!=)){
$size=$size+FileSize($adr/$itm);
 $total++;
  }
 } while ($itm!=false);

CloseDir($dp);
}

obsah(.,$total,$dir,$size);
$freeA=BcDIV($size,1024*1024,2);
$freeB=$quota-$freeA;

echo CENTERFONT FACE=arial SIZE=2
Engaged place: B$freeA/B MB
Free place: B$freeB/B MB
B$total/B files in B$dir/B dirs
/FONT/CENTER;

but OpenDir() is not allowed in safe mode so that doesnt work
i dont know what to do anymore. just lead me to the right command please. i
dont even care if it doesnt read the subdirectories



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-15 Thread Tom Rogers
Hi,

Saturday, February 15, 2003, 5:17:59 AM, you wrote:
j hi
j first of all i think this is a great community here :)

j now to the point...
j i need a script. it should work on safe mode php so it should be as simple
j as possible.
j it should calculate all the file sizes in the directory that it is in and in
j the subdirectories also (only 1 level subdirectories). it should echo the
j total size of the uploaded files.
j then it should take the filesize and substract it from 25 megabytes. that is
j the limit on this server. then it should echo the result (the maximum number
j of kilobytes that can still fit on this account).
j unfortunately i have insuffitient knowlege to do it miself.
j i just want to thank anyone who can help me.
j if you want to send it to my email then its [EMAIL PROTECTED] . or you can
j just write it here.

j thank you :)

These commands might help if they work with safe mode and your on unix of some
sort

echo exec(du -c -h /home/tigger,$results).'br';
echo exec(du -c /home/tigger,$results).'br';

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-15 Thread Don Read

On 14-Feb-2003 joe wrote:
 
 Jason Wong [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Saturday 15 February 2003 03:17, joe wrote:

  now to the point...
  i need a script. it should work on safe mode php so it should be as
 simple
  as possible.
  it should calculate all the file sizes in the directory that it is in
 and
  in the subdirectories also (only 1 level subdirectories). it should echo
  the total size of the uploaded files.
  then it should take the filesize and substract it from 25 megabytes.
 that
  is the limit on this server. then it should echo the result (the maximum
  number of kilobytes that can still fit on this account).
  unfortunately i have insuffitient knowlege to do it miself.
  i just want to thank anyone who can help me.

 Most of the functions that you need to accomplish this can be found in
 chapters 'Directory functions'  'Filesystem functions'.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 We gave you an atomic bomb, what do you want, mermaids?
 -- I. I. Rabi to the Atomic Energy Commission
 */

 
 i searched and i tried and i failed. most of the functions dont work in safe
 mode, some didnt do what i wanted (returned the whole drive size instead of
 one directroy) etc.
 my head hurts already and i think i am on the verge on nervous breakdown
 because i have been trying to solve this problem for days so could
 somebody please drop me a function here?
 thank you...
 
 

untested ...

write a shell script (and put in your safe_mode_exec_dir):
---
#!/bin/sh

/usr/bin/du -k $1 | tail -1
exit 0
---

then use popen/fgets to call the script and parse output.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- Beer is proof that God loves us and wants us to be happy.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-15 Thread Jason Sheets
I tend to stay away from executing shell commands when it is not
necessary.

I've written a script for you that will do what I think you want it to
do.  It will go n levels deep and get the file size in KB of each file,
then it will return that.

You can tell the script to ignore certain files (by default it ignores .
and .., you may want to tell it to ignore itself as well) and what
directory to give the size of.

The source code is available at
http://php.shadonet.com/diskspace.php.txt

I've verified this works on my machine (4.3.0) and another machine
(4.0.6) in safe mode.

Jason
On Sat, 2003-02-15 at 10:08, Don Read wrote:
 
 On 14-Feb-2003 joe wrote:
  
  Jason Wong [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Saturday 15 February 2003 03:17, joe wrote:
 
   now to the point...
   i need a script. it should work on safe mode php so it should be as
  simple
   as possible.
   it should calculate all the file sizes in the directory that it is in
  and
   in the subdirectories also (only 1 level subdirectories). it should echo
   the total size of the uploaded files.
   then it should take the filesize and substract it from 25 megabytes.
  that
   is the limit on this server. then it should echo the result (the maximum
   number of kilobytes that can still fit on this account).
   unfortunately i have insuffitient knowlege to do it miself.
   i just want to thank anyone who can help me.
 
  Most of the functions that you need to accomplish this can be found in
  chapters 'Directory functions'  'Filesystem functions'.
 
  --
  Jason Wong - Gremlins Associates - www.gremlins.biz
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet Applications Development *
  --
  Search the list archives before you post
  http://marc.theaimsgroup.com/?l=php-general
  --
  /*
  We gave you an atomic bomb, what do you want, mermaids?
  -- I. I. Rabi to the Atomic Energy Commission
  */
 
  
  i searched and i tried and i failed. most of the functions dont work in safe
  mode, some didnt do what i wanted (returned the whole drive size instead of
  one directroy) etc.
  my head hurts already and i think i am on the verge on nervous breakdown
  because i have been trying to solve this problem for days so could
  somebody please drop me a function here?
  thank you...
  
  
 
 untested ...
 
 write a shell script (and put in your safe_mode_exec_dir):
 ---
 #!/bin/sh
 
 /usr/bin/du -k $1 | tail -1
 exit 0
 ---
 
 then use popen/fgets to call the script and parse output.
 
 Regards,
 -- 
 Don Read   [EMAIL PROTECTED]
 -- Beer is proof that God loves us and wants us to be happy.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] calculating kilobytes

2003-02-14 Thread joe
hi
first of all i think this is a great community here :)

now to the point...
i need a script. it should work on safe mode php so it should be as simple
as possible.
it should calculate all the file sizes in the directory that it is in and in
the subdirectories also (only 1 level subdirectories). it should echo the
total size of the uploaded files.
then it should take the filesize and substract it from 25 megabytes. that is
the limit on this server. then it should echo the result (the maximum number
of kilobytes that can still fit on this account).
unfortunately i have insuffitient knowlege to do it miself.
i just want to thank anyone who can help me.
if you want to send it to my email then its [EMAIL PROTECTED] . or you can
just write it here.

thank you :)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-14 Thread Jason Wong
On Saturday 15 February 2003 03:17, joe wrote:

 now to the point...
 i need a script. it should work on safe mode php so it should be as simple
 as possible.
 it should calculate all the file sizes in the directory that it is in and
 in the subdirectories also (only 1 level subdirectories). it should echo
 the total size of the uploaded files.
 then it should take the filesize and substract it from 25 megabytes. that
 is the limit on this server. then it should echo the result (the maximum
 number of kilobytes that can still fit on this account).
 unfortunately i have insuffitient knowlege to do it miself.
 i just want to thank anyone who can help me.

Most of the functions that you need to accomplish this can be found in 
chapters 'Directory functions'  'Filesystem functions'.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
We gave you an atomic bomb, what do you want, mermaids?
-- I. I. Rabi to the Atomic Energy Commission
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Fw: [PHP] calculating kilobytes

2003-02-14 Thread Kevin Stone
Joe, you might try something like this instead of a slow PHP function.  I
based it off of a user example on the PHP site.  This is tested and I use it
often for various purposes.  I think it may be ideal for you becuase it is
extremely fast.  Requires Linux though I'm certain there's an equivilant
command in Windows.

---
$dir=/path/to/home/directory/;
$out = `find $dir -depth -type f`;
$files = explode(\n, $out);
$numfiles = count($files);

for ($i=0; $i$numfiles; $i++)
{
 $filelist .= $files[$i].br;
 if (false != ($size = @filesize($files[$i])));
 {
  $totalfilesize += $size;
 }
}

echo $numfiles. filesbr;
echo $totalfilesize. kilobytes totalbr;
echo $filelist;


Let me know how that works for you.

- Kevin


- Original Message -
From: joe [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 14, 2003 12:17 PM
Subject: [PHP] calculating kilobytes


 hi
 first of all i think this is a great community here :)

 now to the point...
 i need a script. it should work on safe mode php so it should be as simple
 as possible.
 it should calculate all the file sizes in the directory that it is in and
in
 the subdirectories also (only 1 level subdirectories). it should echo the
 total size of the uploaded files.
 then it should take the filesize and substract it from 25 megabytes. that
is
 the limit on this server. then it should echo the result (the maximum
number
 of kilobytes that can still fit on this account).
 unfortunately i have insuffitient knowlege to do it miself.
 i just want to thank anyone who can help me.
 if you want to send it to my email then its [EMAIL PROTECTED] . or you can
 just write it here.

 thank you :)



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-14 Thread joe

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Saturday 15 February 2003 03:17, joe wrote:

  now to the point...
  i need a script. it should work on safe mode php so it should be as
simple
  as possible.
  it should calculate all the file sizes in the directory that it is in
and
  in the subdirectories also (only 1 level subdirectories). it should echo
  the total size of the uploaded files.
  then it should take the filesize and substract it from 25 megabytes.
that
  is the limit on this server. then it should echo the result (the maximum
  number of kilobytes that can still fit on this account).
  unfortunately i have insuffitient knowlege to do it miself.
  i just want to thank anyone who can help me.

 Most of the functions that you need to accomplish this can be found in
 chapters 'Directory functions'  'Filesystem functions'.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 We gave you an atomic bomb, what do you want, mermaids?
 -- I. I. Rabi to the Atomic Energy Commission
 */


i searched and i tried and i failed. most of the functions dont work in safe
mode, some didnt do what i wanted (returned the whole drive size instead of
one directroy) etc.
my head hurts already and i think i am on the verge on nervous breakdown
because i have been trying to solve this problem for days so could
somebody please drop me a function here?
thank you...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] calculating kilobytes

2003-02-14 Thread Greg Donald
On Fri, 14 Feb 2003, joe wrote:

i searched and i tried and i failed. most of the functions dont work in safe
mode, some didnt do what i wanted (returned the whole drive size instead of
one directroy) etc.
my head hurts already and i think i am on the verge on nervous breakdown
because i have been trying to solve this problem for days so could
somebody please drop me a function here?
thank you...

Most people who write code for other people on request are compensated in 
one form or another.  This is a listserv, I doubt anyone here will do 
your work for you for free.  This is place where people get _assistance_ 
with code they already attempted to write themselves.  If you tried and 
failed already like you say, post your broken code and people will help 
you figure out your errors.  That's pretty much how it works.

Also, what you ask may simply not be possible in safe mode, but there's no 
way to tell since you posted no code.


-- 
Greg Donald
http://destiney.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php