Skip to content

Commit

Permalink
[php:core] supports to exceed the max_input_vars of PHP settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Oct 17, 2016
1 parent c33c328 commit 4b0dea6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
12 changes: 11 additions & 1 deletion php/elFinder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,8 @@ protected function tmb($args) {
$targets = $args['targets'];

foreach ($targets as $target) {
elFinder::extendTimeLimit();

if (($volume = $this->volume($target)) != false
&& (($tmb = $volume->tmb($target)) != false)) {
$result['images'][$target] = $tmb;
Expand Down Expand Up @@ -1490,6 +1492,8 @@ protected function duplicate($args) {
$suffix = empty($args['suffix']) ? 'copy' : $args['suffix'];

foreach ($targets as $target) {
elFinder::extendTimeLimit();

if (($volume = $this->volume($target)) == false
|| ($src = $volume->file($target)) == false) {
$result['warning'] = $this->error(self::ERROR_COPY, '#'.$target, self::ERROR_FILE_NOT_FOUND);
Expand Down Expand Up @@ -1519,6 +1523,8 @@ protected function rm($args) {
$result = array('removed' => array());

foreach ($targets as $target) {
elFinder::extendTimeLimit();

if (($volume = $this->volume($target)) == false) {
$result['warning'] = $this->error(self::ERROR_RM, '#'.$target, self::ERROR_FILE_NOT_FOUND);
return $result;
Expand All @@ -1542,7 +1548,7 @@ protected function rm($args) {
* @param resource $fp
* @return string or bool(false)
* @retval string contents
* @retval false error
* @rettval false error
* @author Naoki Sawada
**/
protected function get_remote_contents( &$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null ) {
Expand Down Expand Up @@ -1881,6 +1887,8 @@ protected function chmod($args) {
$files = array();
$errors = array();
foreach($targets as $target) {
elFinder::extendTimeLimit();

$file = $volume->chmod($target, $mode);
if ($file) {
$files = array_merge($files, is_array($file)? $file : array($file));
Expand Down Expand Up @@ -2363,6 +2371,8 @@ protected function paste($args) {
}

foreach ($targets as $target) {
elFinder::extendTimeLimit();

if (($srcVolume = $this->volume($target)) == false) {
$result['warning'] = $this->error($error, '#'.$target, self::ERROR_FILE_NOT_FOUND);
break;
Expand Down
37 changes: 23 additions & 14 deletions php/elFinderConnector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,33 @@ public function __construct($elFinder, $debug=false) {
public function run() {
$isPost = $this->reqMethod === 'POST';
$src = $isPost ? $_POST : $_GET;
if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
// for support IE XDomainRequest()
$maxInputVars = (! $src || isset($src['targets']))? ini_get('max_input_vars') : null;
if ((! $src || $maxInputVars) && $rawPostData = file_get_contents('php://input')) {
// for max_input_vars and supports IE XDomainRequest()
$parts = explode('&', $rawPostData);
foreach($parts as $part) {
list($key, $value) = array_pad(explode('=', $part), 2, '');
$key = rawurldecode($key);
if (substr($key, -2) === '[]') {
$key = substr($key, 0, strlen($key) - 2);
if (!isset($src[$key])) {
$src[$key] = array();
if (! $src || $maxInputVars < count($parts)) {
$src = array();
foreach($parts as $part) {
list($key, $value) = array_pad(explode('=', $part), 2, '');
$key = rawurldecode($key);
if (preg_match('/^(.+?)\[([^\[\]]*)\]$/', $key, $m)) {
$key = $m[1];
$idx = $m[2];
if (!isset($src[$key])) {
$src[$key] = array();
}
if ($idx) {
$src[$key][$idx] = rawurldecode($value);
} else {
$src[$key][] = rawurldecode($value);
}
} else {
$src[$key] = rawurldecode($value);
}
$src[$key][] = rawurldecode($value);
} else {
$src[$key] = rawurldecode($value);
}
$_POST = $this->input_filter($src);
$_REQUEST = $this->input_filter(array_merge_recursive($src, $_REQUEST));
}
$_POST = $this->input_filter($src);
$_REQUEST = $this->input_filter(array_merge_recursive($src, $_REQUEST));
}
$cmd = isset($src['cmd']) ? $src['cmd'] : '';
$args = array();
Expand Down

0 comments on commit 4b0dea6

Please sign in to comment.