private static function getPutParameters($input) { $putdata = $input; if (function_exists('mb_parse_str')) { mb_parse_str($putdata, $outputdata); } else { parse_str($putdata, $outputdata); } return $outputdata; }
public static function getInputData() { if (self::$inputData === null) { $inputData = []; $rawInput = file_get_contents('php://input'); if (!empty($rawInput)) { mb_parse_str($rawInput, $inputData); } self::$inputData = $inputData; } return self::$inputData; }
function f_contents(&$text){ $phrase = 'СТРАНИЦА'; if (mb_strpos($text, $phrase) === false) { return true; } $regex = '/{('. $phrase .'=)\s*(.*?)}/ui'; $matches = array(); preg_match_all($regex, $text, $matches, PREG_SET_ORDER); $GLOBALS['pt'] = array(); foreach ($matches as $elm) { $elm[0] = str_replace('{', '', $elm[0]); $elm[0] = str_replace('}', '', $elm[0]); mb_parse_str($elm[0], $args); $title = @$args[$phrase]; if ($title) { $GLOBALS['pt'][] = $title; } $text = str_replace('{'.$phrase.'='.$title.'}', '', $text ); } return true; }
/** * Retorna o conteudo do request parseado para GET, POST, PUT e DELETE * ou lança uma exceção caso o tipo de content-type seja inválido * @return array */ public function getParsedBody() { if (!in_array($this->getMethod(), ['GET', 'POST'])) { if ($this->getContentType() == 'application/x-www-form-urlencoded') { $input_contents = file_get_contents("php://input"); if (function_exists('mb_parse_str')) { mb_parse_str($input_contents, $post_vars); } else { parse_str($input_contents, $post_vars); } if (count($_GET) > 0) { $post_vars = array_merge($post_vars, $_GET); } return $post_vars; } else { throw new \UnexpectedValueException('Content-type não aceito'); } } elseif ($this->getMethod() == 'POST') { if (count($_GET) > 0) { $_POST = array_merge($_POST, $_GET); } return $_POST; } elseif ($this->getMethod() == 'GET') { return $_GET; } }
function f_includes(&$text){ $phrase = 'ФАЙЛ'; if (mb_strpos($text, $phrase) === false){ return true; } $regex = '/{('.$phrase.'=)\s*(.*?)}/i'; $matches = array(); preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); foreach ($matches as $elm) { $elm[0] = str_replace('{', '', $elm[0]); $elm[0] = str_replace('}', '', $elm[0]); mb_parse_str( $elm[0], $args ); $file=@$args[$phrase]; if ($file){ $output = getLink($file); } else { $output = ''; } $text = str_replace('{'.$phrase.'='.$file.'}', $output, $text ); } return true; }
function f_banners(&$text) { $phrase = 'БАННЕР'; if (mb_strpos($text, $phrase) === false) { return true; } if (!cmsCore::getInstance()->isComponentEnable('banners')) { return true; } $regex = '/{(' . $phrase . '=)\\s*(.*?)}/i'; $matches = array(); preg_match_all($regex, $text, $matches, PREG_SET_ORDER); if (!$matches) { return true; } cmsCore::loadModel('banners'); foreach ($matches as $elm) { $elm[0] = str_replace('{', '', $elm[0]); $elm[0] = str_replace('}', '', $elm[0]); mb_parse_str($elm[0], $args); $position = @$args[$phrase]; if ($position) { $output = cms_model_banners::getBannerHTML($position); } else { $output = ''; } $text = str_replace('{' . $phrase . '=' . $position . '}', $output, $text); } return true; }
/** * Parses a string using mb_parse_str() if available. * NOTE: This differs from parse_str() by returning the results * instead of placing them in the local scope! * * @param str $str * @return array */ function elgg_parse_str($str) { if (is_callable('mb_parse_str')) { mb_parse_str($str, $results); } else { parse_str($str, $results); } return $results; }
public static function queryString() { $queryString = array(); if (function_exists('mb_parse_str')) { mb_parse_str($_SERVER['QUERY_STRING'], $queryString); } else { parse_str($_SERVER['QUERY_STRING'], $queryString); } return $queryString; }
protected function parseLinkUrl($url) { try { $urlParams = mb_substr($url, mb_strpos($url, '?') + 1); $array = []; mb_parse_str(htmlspecialchars_decode($urlParams), $array); if (!filter_var($array['q'], FILTER_VALIDATE_URL)) { throw new GoogleParserException($array['q'] . ' invalid url'); } return $array['q']; } catch (GoogleParserException $e) { throw $e; } }
/** * Returns rest request parameters. * @return array the request parameters */ public function getRestParams() { $result = []; $httpMethod = array('get', 'put', 'delete', 'put', 'patch', 'options'); if (!isset($_SERVER['REQUEST_METHOD']) || !in_array(strtolower($_SERVER['REQUEST_METHOD']), $httpMethod)) { return $result; } if (function_exists('mb_parse_str')) { mb_parse_str(file_get_contents('php://input'), $result); } else { parse_str(file_get_contents('php://input'), $result); } return $result; }
/** * Function fetch params from php://input. * @return array HTTP params */ public function getInputParams() { $result = array(); $rawBody = Yii::app()->request->rawBody; if (is_null($result = json_decode($rawBody, true))) { if (function_exists('mb_parse_str')) { mb_parse_str(Yii::app()->request->rawBody, $result); } else { parse_str(Yii::app()->request->rawBody, $result); } } if (!is_array($result) || empty($result) && !empty($_POST)) { $result = $_POST; } return $result; }
public function getInput(string $method) : array { if ($method == 'GET') { return array('data' => json_decode($_GET, true)); } else { if ($method == 'POST') { return array('data' => json_decode($_POST, true)); } else { if ($method == 'PUT') { mb_parse_str(file_get_contents("php://input"), $result); return array('data' => json_decode($result, true)); } else { throw new \Hx\Http\HttpException("UrlEncoded input decoder not support request method <{$method}>"); } } } }
function replace_text($text, $phrase) { $regex = '/{(' . $phrase['title'] . '=)\\s*(.*?)}/ui'; $matches = array(); preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $elm) { $elm[0] = str_replace(array('{', '}'), '', $elm[0]); mb_parse_str($elm[0], $args); $arg = @$args[$phrase['title']]; if ($arg) { $output = call_user_func($phrase['function'], $arg); } else { $output = ''; } $text = str_replace('{' . $phrase['title'] . '=' . $arg . '}', $output, $text); } return $text; }
/** * Генерирует URL согласно настройкам или локальному режиму * * @param string $queryString * @param bool|array $mode * * @return string */ public function createUrl($queryString, $mode = false) { if (substr($queryString, 0, 4) === 'http') { return $queryString; } $queryString = trim($queryString, '/'); if (is_array($mode) && !empty($this->config['url_manager'])) { $config = array_merge($this->config['url_manager'], $mode); } elseif (!is_array($mode) && !empty($this->config['url_manager'])) { $config = $this->config['url_manager']; } $protocol = !empty($config['https']) ? 'https://' : 'http://'; $hostName = $this->request->getHostName(); $scriptName = null; if (!empty($config['show_script'])) { $query = trim($_SERVER['PHP_SELF'], '/'); $scriptName = '/' . explode('/', $query)[0]; } if (true === $mode) { $basePath = $protocol . $hostName . $scriptName; } elseif (false === $mode) { $basePath = $scriptName; } else { $basePath = isset($config['absolute']) && true === $config['absolute'] ? $protocol . $hostName . $scriptName : $scriptName; } if (isset($config['pretty']) && false === $config['pretty']) { if ($queryString[0] === '?') { return $basePath . '?' . ltrim($queryString, '?'); } else { $param = $this->parser->parseRoutes($queryString); return $basePath . '?' . http_build_query($param); } } else { if ($queryString[0] !== '?') { return $basePath . '/' . $queryString; } else { mb_parse_str($queryString, $param); $param = $this->router->hashFromParam($param); $queryString = implode('/', $param); return $basePath . '/' . $queryString; } } }
function f_filelink(&$text) { $phrase = 'СКАЧАТЬ'; //echo "<pre>"; var_dump($text); if (mb_strpos($text, $phrase) === false) { return true; } //$regex = '/{('.$phrase.'=)\s*(.*?)---(.*?)}/i'; $regex = '/{(' . $phrase . '=\\s*.*?)---(.*?)}/i'; //$regex = '/{('.$phrase.'=)\s*(.*?)}/i'; $matches = array(); preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $elm) { //echo "<pre>"; var_dump($matches); /* $elm[0] = str_replace('{', '', $elm[0]); $elm[0] = str_replace('}', '', $elm[0]); */ //mb_parse_str( $elm[0], $args ); mb_parse_str($elm[1], $args); $file = @$args[$phrase]; if ($file) { // echo "<pre>"; var_dump($file); $output = getDownLoadLink($file, $elm[2]); } else { $output = ''; } $text = str_replace('{' . $phrase . '=' . $file . '---' . $elm[2] . '}', $output, $text); /*echo "<pre>"; var_dump($elm[2]); if($elm[2]){ $text = str_replace('{'.$phrase.'='.$file.'---'.$elm[2].'}', $output, $text ); } else{ $text = str_replace('{'.$phrase.'='.$file.'}', $output, $text ); }*/ } return true; }
public function getPostCut($post_content) { $regex = '/\\[(cut=)\\s*(.*?)\\]/ui'; $matches = array(); preg_match_all($regex, $post_content, $matches, PREG_SET_ORDER); if (is_array($matches)) { $elm = $matches[0]; $elm[0] = str_replace('[', '', $elm[0]); $elm[0] = str_replace(']', '', $elm[0]); mb_parse_str($elm[0], $args); $cut .= '[cut=' . $args['cut'] . '...]'; } return $cut; }
/** * Retrieve the body of the request. * * @param bool $raw return body in it's raw format * @return string */ public function getBody($raw = true) { if (!$this->body) { $this->body = file_get_contents('php://input'); } if (!$raw) { $type = $this->getContentType(); if (in_array($type, $this->contentTypes['form'])) { return mb_parse_str($this->body); } elseif (in_array($type, $this->contentTypes['json'])) { return json_decode($this->body); } elseif (in_array($type, $this->contentTypes['xml'])) { return simplexml_load_string($this->body); } } return $this->body; }
/** * Set Default Parsed Body * * @return void */ protected function setDefaultParsedBody() { if (in_array($this->getHeaderLine('Content-Type'), ['application/x-www-form-urlencoded', 'multipart/form-data']) && $this->method === 'POST') { $this->parsed_body = $_POST; } else { mb_parse_str($this->getBody()->getContents(), $parsed_body); $this->parsed_body = $parsed_body; } }
/** * Пагинация в query string (/?page=2) * * @param string $name - имя параметра пагинации */ public function query($name = 'page') { $query_string = Request::query(); mb_parse_str($query_string, $query_array); $path_string = Request::path(); $list_array = array(); foreach ($this->result['list'] as $number) { $outputList = array(); $outputList['number'] = $number; if ($number == 1) { $query_array = array_delete_key($query_array, $name); $query_string = http_build_query($query_array); $outputList['url'] = $query_string != "" ? $path_string . "?" . $query_string : $path_string; } else { $query_array[$name] = $number; $query_string = http_build_query($query_array); $outputList['url'] = $path_string . "?" . $query_string; } $list_array[] = $outputList; } $this->result['list'] = $list_array; //----- if ($this->result['current'] == 1 or $this->result['prev'] == 1) { $query_array = array_delete_key($query_array, $name); $query_string = http_build_query($query_array); $this->result['prev_url'] = $query_string != "" ? $path_string . "?" . $query_string : $path_string; } else { $query_array[$name] = $this->result['prev']; $query_string = http_build_query($query_array); $this->result['prev_url'] = $path_string . "?" . $query_string; } //----- if ($this->result['current'] == 1) { $query_array = array_delete_key($query_array, $name); $query_string = http_build_query($query_array); $this->result['current_url'] = $query_string != "" ? $path_string . "?" . $query_string : $path_string; } else { $query_array[$name] = $this->result['current']; $query_string = http_build_query($query_array); $this->result['current_url'] = $path_string . "?" . $query_string; } //----- if ($this->result['current'] == $this->result['total']) { $query_array[$name] = $this->result['current']; $query_string = http_build_query($query_array); } else { $query_array[$name] = $this->result['next']; $query_string = http_build_query($query_array); } $this->result['next_url'] = $path_string . "?" . $query_string; //----- $query_array = array_delete_key($query_array, $name); $query_string = http_build_query($query_array); $this->result['first_url'] = $query_string != "" ? $path_string . "?" . $query_string : $path_string; if ($this->result['total'] > 1) { $query_array[$name] = $this->result['total']; $query_string = http_build_query($query_array); $this->result['last_url'] = $path_string . "?" . $query_string; } else { $this->result['last_url'] = $this->result['first_url']; } //----- return $this->result; }
/** * Разбирает в массив QUERY_STRING * * @return array */ protected function parseQueryString() { $queryString = urldecode($_SERVER['QUERY_STRING']); mb_parse_str($queryString, $result); return $result; }
public static function _video($action, $attributes, $content, $params, &$node_object) { $vid = false; if (isset($attributes['default']) && preg_match('/^(google|youtube|metacafe|myvideo|vimeo)$/i', $attributes['default'])) { $vid = true; } if ($action == 'validate') { if ($vid) { return preg_match('/^[\\w\\d-]+$/i', $content) && preg_match('/^(google|youtube|metacafe|myvideo|vimeo)$/i', $attributes['default']); } else { $URL = parse_url($content); if (!is_bool($URL) && isset($URL['host']) && (isset($URL['query']) || isset($URL['path']))) { return true; } } } else { if ($vid) { switch ($attributes['default']) { case 'google': return '<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=' . $content . '&hl=de&fs=true" style="width:400px;height:326px" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash"></embed>'; case 'youtube': return '<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/' . $content . '&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $content . '&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>'; case 'myvideo': return '<object style="width:470px;height:285px;" width="470" height="285"><param name="movie" value="http://www.myvideo.de/movie/' . $content . '"></param><param name="AllowFullscreen" value="true"></param><param name="AllowScriptAccess" value="always"></param><embed src="http://www.myvideo.de/movie/' . $content . '" width="470" height="285" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"></embed></object>'; case 'metacafe': return '<embed src="http://www.metacafe.com/fplayer/' . $content . '/video.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always"></embed>'; case 'vimeo': return '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' . $content . '&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=ff9933&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=' . $content . '&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=ff9933&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>'; default: /** * STATISCHE SPRACE */ return '<div>' . 'Das angegebene Video konnte nicht verarbeitet werden.' . '</div>'; } } else { $URL = parse_url($content); $host =& $URL['host']; if (isset($URL['query'])) { $QS; mb_parse_str($URL['query'], $QS); if (preg_match('/youtube/i', $host) && isset($QS['v'])) { return '<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/' . $QS['v'] . '&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $QS['v'] . '&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>'; } elseif (preg_match('/video\\.google/i', $host) && isset($QS['docid'])) { return '<embed id="VideoPlayback" src="http://video.google.com/googleplayer.swf?docid=' . $QS['docid'] . '&hl=de&fs=true" style="width:400px;height:326px" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>'; } } else { $paths = explode('/', $URL['path']); if (preg_match('/myvideo/i', $host)) { return '<object style="width:470px;height:285px;" width="470" height="285"><param name="movie" value="http://www.myvideo.de/movie/' . $paths[2] . '"></param><param name="AllowFullscreen" value="true"></param><param name="AllowScriptAccess" value="always"></param><embed src="http://www.myvideo.de/movie/' . $paths[2] . '" width="470" height="285" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"></embed></object>'; } elseif (preg_match('/metacafe/i', $host)) { return '<embed src="http://www.metacafe.com/fplayer/' . $paths[2] . '/video.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowFullScreen="true" allowScriptAccess="always"></embed>'; } elseif (preg_match('/vimeo/i', $host)) { return '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' . $paths[1] . '&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=ff9933&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=' . $paths[1] . '&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=ff9933&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>'; } } /** * STATISCHE SPRACHE */ return '<div>' . 'Der gewünschte Video-Service wird nicht unterstützt.' . '</div>'; } } }
/** * Returns the PUT or DELETE request parameters. * @return array the request parameters * @since 1.1.7 */ protected function getRestParams() { $result = array(); if (function_exists('mb_parse_str')) { mb_parse_str(file_get_contents('php://input'), $result); } else { parse_str(file_get_contents('php://input'), $result); } return $result; }
<?php ini_set('include_path', dirname(__FILE__)); include_once 'common.inc'; $testmoo = "blah blah"; var_dump(mb_parse_str("testmoo")); var_dump($testmoo); var_dump(mb_parse_str("test=moo")); var_dump($test);
public function getRestParams() { if ($this->_restParams === null) { $result = array(); if (function_exists('mb_parse_str')) { mb_parse_str($this->getRawBody(), $result); } else { parse_str($this->getRawBody(), $result); } $this->_restParams = $result; } return $this->_restParams; }
/** * Fetch POST data * * This method returns a key-value array of data sent in the HTTP request body, or * the value of a hash key if requested; if the array key does not exist, NULL is returned. * * @param string $key * @return array|mixed|null * @throws \RuntimeException If environment input is not available */ public function post($key = null) { if (!isset($this->env['slim.input'])) { throw new \RuntimeException('Missing slim.input in environment variables'); } if (!isset($this->env['slim.request.form_hash'])) { $this->env['slim.request.form_hash'] = array(); if ($this->isFormData() && is_string($this->env['slim.input'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['slim.tests.ignore_multibyte'])) { mb_parse_str($this->env['slim.input'], $output); } else { parse_str($this->env['slim.input'], $output); } $this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); } else { $this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); } } if ($key) { if (isset($this->env['slim.request.form_hash'][$key])) { return $this->env['slim.request.form_hash'][$key]; } else { return null; } } else { return $this->env['slim.request.form_hash']; } }
/** * Преобразует строку URL в массив согласно роутам * * @param string $string * * @return array */ public function hashFromString($string) { $string = trim($string, '/?'); if (false !== strpos($string, '&')) { mb_parse_str($string, $param); $param = $this->hashFromQueryString($param); } else { $param = explode('/', $string); } return $param; }
function test($query) { $foo = ''; $bar = ''; mb_parse_str($query, $array); var_dump($array); var_dump($foo); var_dump($bar); mb_parse_str($query); var_dump($foo); var_dump($bar); }
/** * Returns the request parameters given in the request body. * * Request parameters are determined using the parsers configured in [[parsers]] property. * If no parsers are configured for the current [[contentType]] it uses the PHP function `mb_parse_str()` * to parse the [[rawBody|request body]]. * @return array the request parameters given in the request body. * @throws \yii\base\InvalidConfigException if a registered parser does not implement the [[RequestParserInterface]]. * @see getMethod() * @see getBodyParam() * @see setBodyParams() */ public function getBodyParams() { if ($this->_bodyParams === null) { if (isset($_POST[$this->methodParam])) { $this->_bodyParams = $_POST; unset($this->_bodyParams[$this->methodParam]); return $this->_bodyParams; } $contentType = $this->getContentType(); if (($pos = strpos($contentType, ';')) !== false) { // e.g. application/json; charset=UTF-8 $contentType = substr($contentType, 0, $pos); } if (isset($this->parsers[$contentType])) { $parser = Yii::createObject($this->parsers[$contentType]); if (!$parser instanceof RequestParserInterface) { throw new InvalidConfigException("The '{$contentType}' request parser is invalid. It must implement the yii\\web\\RequestParserInterface."); } $this->_bodyParams = $parser->parse($this->getRawBody(), $contentType); } elseif (isset($this->parsers['*'])) { $parser = Yii::createObject($this->parsers['*']); if (!$parser instanceof RequestParserInterface) { throw new InvalidConfigException("The fallback request parser is invalid. It must implement the yii\\web\\RequestParserInterface."); } $this->_bodyParams = $parser->parse($this->getRawBody(), $contentType); } elseif ($this->getMethod() === 'POST') { // PHP has already parsed the body so we have all params in $_POST $this->_bodyParams = $_POST; } else { $this->_bodyParams = []; mb_parse_str($this->getRawBody(), $this->_bodyParams); } } return $this->_bodyParams; }
/** * Returns the PUT or DELETE request parameters. * @return array the request parameters */ public function getRestParams() { if (null == $this->_restParams) { $this->_restParams = array(); if (function_exists('mb_parse_str')) { mb_parse_str(file_get_contents('php://input'), $this->_restParams); } else { parse_str(file_get_contents('php://input'), $this->_restParams); } } return $this->_restParams; }
function cpAddParam($query, $param, $value) { $new_query = ''; mb_parse_str($query, $params); $l = 0; $added = false; foreach ($params as $key => $val) { $l++; if ($key != $param && $key != 'nofilter') { $new_query .= $key . '=' . $val; } else { $new_query .= $key . '=' . $value; $added = true; } if ($l < sizeof($params)) { $new_query .= '&'; } } if (!$added) { if (mb_strlen($new_query) > 1) { $new_query .= '&' . $param . '=' . $value; } else { $new_query .= $param . '=' . $value; } } return $new_query; }