Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
code to show size of specified folder?
Old 01-26-2007, 05:55 PM Re: code to show size of specified folder?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I saved the code above and saved it to my server.

and i got pages of "Warning: filesize() [function.filesize]: stat failed for login.php in /home/dan/public_html/publichtmlsize.php on line 29"
with lots of differant file names (pages)

if it helps, line 29 is $ret+=filesize($file);

why was the script fail with these files? is it to do with file type or something like that?

btw at the end i got a total of 325.15 KB [in reality my cpanel says 227.62 MB
i am assumeing the error is in that it couldnt/didnt do all those files so that is just the total of the file which it could...

Thanks again.

Dan

I was going to talkupation you but i cant until i done it a bit more to other lol.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 01-26-2007, 06:59 PM Re: code to show size of specified folder?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Hmm, Like that, I cannot be sure, but it may be because the web server have not the permission to access them.

Can you do a
Code:
ls -la
in the directory you want to get total file size.

I'm guessing that files have a special permission for cpanel that is different thanthe permissions for the web server, and that could cause the problem.

You should have something like that in return:
Code:
drwxr-xr-x 11 tmo  users       440 Jul 19  2006 htdocs
It's the drwx-rx-rx part that is of interest.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 01-26-2007, 07:08 PM Re: code to show size of specified folder?
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
You might need to CHMod it if you aren't on a Windows server. I'm not as familiar with disk space functions compared with most, but try that out.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 01-27-2007, 05:39 AM Re: code to show size of specified folder?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
the server i use is linux, but i have xampp on my windows xp, so if necessary i can test on both.

but i thought it wouldnt work on windows? only linux.

im sorry the whole drwxr-xr-x 11 tmo users 440 Jul 19 2006 htdocs confussed me a bit, i vagly renconise it a bit, could you please exaplin exactly what it is.

dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-28-2007, 03:49 PM Re: code to show size of specified folder?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Sure, those are unix style file permissions.
http://en.wikipedia.org/wiki/Chmod#String_modes
3 groups of 3 properties

In the previous exemple:
drwxr-xr-x

d= directory.
Then, the 3 groups represent
1) The file/directory owner rigths
2) The users in the same group as the owner rights
3) The rights for the rest of the users on the system.
On each group, the property are:
1st position: reading right
2nd position: writing right
3rd position: execution right. The execution right on a directory allow or prevent the listing of the directory and recursivity through the directory tree. So, if someone has only reading rights on a directory, he won't be able to list the directory content, only read a file that he knows is there.

So, in a drwxr-xr-x, it means that this is a directory, with reading, writing, and executing rights for the dir. owner, reading and executing rigths for the group of the owner, and reading and executing rights for any user not in the owner's group.

Now, What I suspect, is that the directory you are trying to stat have been created via ftp, or any similar mechanism.
But, when you try to use PHP to stat it, it's the user who runs the web server process who tries to access the directory, not the one who might have created it.

This is for security purpose, the web server always have (or at least should) be running with the minimum rights possible, to prevent hackers to get in through stack overflow attacks.

But in that case, it may require that you change the directory permissions to allow the "all the other users" group to access and execute this directory.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to code to show size of specified folder?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16112 seconds with 11 queries