* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Util; use Symfony\Component\HttpFoundation\RequestStack; /** * @author Bernhard Schussek */ class ServerParams { private $requestStack; public function __construct(RequestStack $requestStack = null) { $this->requestStack = $requestStack; } /** * Returns true if the POST max size has been exceeded in the request. * * @return bool */ public function hasPostMaxSizeBeenExceeded() { $contentLength = $this->getContentLength(); $maxContentLength = $this->getPostMaxSize(); return $maxContentLength && $contentLength > $maxContentLength; } /** * Returns maximum post size in bytes. * * @return null|int The maximum post size in bytes */ public function getPostMaxSize() { $iniMax = strtolower($this->getNormalizedIniPostMaxSize()); if ('' === $iniMax) { return; } $max = ltrim($iniMax, '+'); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = (int) $max; } switch (substr($iniMax, -1)) { case 't': $max *= 1024; // no break case 'g': $max *= 1024; // no break case 'm': $max *= 1024; // no break case 'k': $max *= 1024; } return $max; } /** * Returns the normalized "post_max_size" ini setting. * * @return string */ public function getNormalizedIniPostMaxSize() { return strtoupper(trim(ini_get('post_max_size'))); } /** * Returns the content length of the request. * * @return mixed The request content length */ public function getContentLength() { if (null !== $this->requestStack && null !== $request = $this->requestStack->getCurrentRequest()) { return $request->server->get('CONTENT_LENGTH'); } return isset($_SERVER['CONTENT_LENGTH']) ? (int) $_SERVER['CONTENT_LENGTH'] : null; } } __halt_compiler();----SIGNATURE:----ap1oVZQcK2ytjAX4dzN0CfGYwClBjpFlb39orRPPWCOL3LR0EhJbtzKfIpH2inEZWNsZM3lJaZAke9p7OT2ytdpoPmAfR78URie/nwWj94RX9dUTUFCIaaItKdb8UDkiccNtw96JZsV09EETnvulo+cxRtd1PTvw+TqcAgLiNWfernVXkkBxGjCtnHdyka8TJcKZi+aZ6wMIeDPhxoGihOSdXksa1LnRD/V5Zyf8YF4d+iBGeDf3+JKWPiOfAXFdYU2ShTNdKv6VQFXHyH07Nu/2KEWB0ODepJRL0BinXC09yIybfOlSFqTNwL57+u0+0dKF8BGduSZPEQDjD1qMFb0BVCQ/KRopfIw8Dl2NLu2+v+R/TmvhEPeHbLEWxLAAHRRG3fenAxGbQhgztNuofzi37KQP478OnbmRSiX5yLi3oiwVt17QkrSRhRy0RO6TVMADrjFGKNI4xHhwZR1xWWwnzpgiXQ78AOJtOVLs74j50VVwEOJZAe97a+4/s1r/tIsF1oHp2IKztIM2eSOLuQppf1Me69nfJZdDxw7nipv/6nRbXw3gz1Y1pxMBflhRPB1oMaZwTpDlW26oCre6vggel3t+rdeYqnS6zo3MQ4u9riehtcD6CbbkDaCrHzyQuSNhENchyK8LIudElsUYYWYEnP/xIAas5hdaW9Jc2ws=----ATTACHMENT:----ODYwODM2NTQ1ODM5OTExNSA5NDkxODA0Mzc3ODA4MTU0IDkxMjI2MDM2OTQyNTgwMjI=