Source of file ServerParams.php
Size: 1,507 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Validator\Util; /** * @author Bernhard Schussek <bschussek@gmail.com> */ class ServerParams { /** * Returns maximum post size in bytes. * * @return null|integer The maximum post size in bytes */ public function getPostMaxSize() { $iniMax = $this->getNormalizedIniPostMaxSize(); if ('' === $iniMax) { return null; } if (preg_match('#^\+?(0X?)?(.*?)([KMG]?)$#', $iniMax, $match)) { $shifts = array('' => 0, 'K' => 10, 'M' => 20, 'G' => 30); $bases = array('' => 10, '0' => 8, '0X' => 16); return intval($match[2], $bases[$match[1]]) << $shifts[$match[3]]; } return 0; } /** * 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() { return isset($_SERVER['CONTENT_LENGTH']) ? (int) $_SERVER['CONTENT_LENGTH'] : null; } } |