• Welcome to Simple Machines Community Forum. Please login or sign up.

What's the PHP functions and variables to display these two server settings

Started by Biology Forums, October 27, 2014, 02:02:52 AM

Previous topic - Next topic

Biology Forums

Max attachment size per post and Max size per attachment.

I know there are php functions that can find those

For example, if I have set on my server:

php_value post_max_size 16M
php_value upload_max_filesize 6M

How do I find these numbers:

echo SOMEFUNCTION(php_value post_max_size);
   Would display: 16M

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Arantor

Max attachment size per post and max size per attachment are stored in $modSettings...
No good deed goes unpunished
All helpful urges should be circumvented

JBlaze

Quote from: Arantor on October 27, 2014, 01:52:18 PM
Max attachment size per post and max size per attachment are stored in $modSettings...

Is it really? I honestly never knew it stored the server's ini variables in the database...
Jason Clemons
Former Team Member 2009 - 2012

Arantor

There are two quite separate things here. The fact that the OP is conflating the two is of no help in this matter, of course.

Firstly you have the stuff in php.ini which is a master limiter on file uploads. This is a limit on the physical POST request, and limits the maximum of any file attached to any one POST request as well as the maximum of the total POST size for that request. This prevents you having one request with many large files.

This is the stuff set by way of the php_value or php_flag directives.

Meanwhile the two settings being referred to by name in the OP are neither of these things. Maximum attachment size is a purely SMF setting (but still the max_post_size must be adhered to), defaults to 128KB, and the maximum size per post is a limit again enforced by SMF, too.

For example on this site, the settings in question are "maximum total size 14000KB, maximum individual size 5096KB" and neither of those are the same as the maximum physical limits imposed in php.ini
No good deed goes unpunished
All helpful urges should be circumvented

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

Arantor

That's the best part - we're *both* right because the OP is talking about two different things at once, and you answered one, I sort of thought about the other. OP should clarify which he is talking about.
No good deed goes unpunished
All helpful urges should be circumvented

Biology Forums

I just wanted a way to retrieve these two server settings using PHP.

What must I echo to find these two numbers?

Arantor

That's the point... there are two completely different sets of things that are relevant.

The SMF-set limits are different to the server limits. And BOTH must be adhered to within the attachments system. Which one are you hoping to show to users, exactly?
No good deed goes unpunished
All helpful urges should be circumvented

Biology Forums

I don't want to show it to users except for admins inside the attachments settings. In the future, I want an admin to know what the maximum value can be for each of these setting based on the maximum set in PHP.ini so that they don't set a value beyond what the server has max'ed at and scratch their heads as to why things aren't working.

Max attachment size per post: CHOSEN VALUE
(Server max allowed: ____)
Max size per attachment: CHOSEN VALUE
(Server max allowed: ____)
Max number of attachments per post: CHOSEN VALUE
(Server max allowed: ____)

Arantor

Great, that's what I was trying to get at.

1. Why would general admins be touching this stuff anyway? Surely you as administrator would set it - and tell the admins to leave it alone.

2. There is a server limit that applies to max attachments per post but only if you try to upload them all at once; you can safely bypass that server limit by uploading fewer attachments, and then editing the post to attach more. No point in exposing that limit (default 20)

3. No point exposing the limit on max attachment size per post since in reality again this can be gotten around; the limit here is to only allow xMB worth of attachments on a post at once, but that can be beaten by just making another post with more attachments. No point then in exposing any limit.

4. Max size per attachment is the only one where the limit makes sense, and that's still controlled by two limits, meaning that you can expose both of the server values in question and STILL have it fail because of the way this works and how virtually everyone sets it wrong in the first place. Meaning that you might as well not bother exposing it, just setting it high enough in the server and configure the admin panel to compensate - or just tell your administrators to leave it the hell alone unless they ask the server admin since this gets set how it gets set for a reason.
No good deed goes unpunished
All helpful urges should be circumvented

Biology Forums


Advertisement: