当前位置: 首页>>代码示例>>PHP>>正文


PHP sfToolkit::stripslashesDeep方法代码示例

本文整理汇总了PHP中sfToolkit::stripslashesDeep方法的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit::stripslashesDeep方法的具体用法?PHP sfToolkit::stripslashesDeep怎么用?PHP sfToolkit::stripslashesDeep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfToolkit的用法示例。


在下文中一共展示了sfToolkit::stripslashesDeep方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 /**
  * @see sfWebRequest
  */
 public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
 {
     parent::initialize($dispatcher, $parameters, $attributes, $options);
     $this->parameterHolder = new opParameterHolder();
     $this->attributeHolder = new opParameterHolder();
     $this->parameterHolder->add($parameters);
     $this->attributeHolder->add($attributes);
     // POST parameters
     $this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
     $this->parameterHolder->add($this->getParameters);
     // POST parameters
     $this->postParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_POST) : $_POST;
     $this->parameterHolder->add($this->postParameters);
     if ($this->isMethod(sfWebRequest::POST)) {
         $this->parameterHolder->remove('sf_method');
     }
     // additional parameters
     $this->requestParameters = $this->parseRequestParameters();
     $this->parameterHolder->add($this->requestParameters);
     $this->fixParameters();
 }
开发者ID:shotaatago,项目名称:OpenPNE3,代码行数:24,代码来源:opWebRequest.class.php

示例2: getCookie

 /**
  * Gets a cookie value.
  *
  * @param  string $name          Cookie name
  * @param  string $defaultValue  Default value returned when no cookie with given name is found
  *
  * @return mixed
  */
 public function getCookie($name, $defaultValue = null)
 {
     $retval = $defaultValue;
     if (isset($_COOKIE[$name])) {
         $retval = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_COOKIE[$name]) : $_COOKIE[$name];
     }
     return $retval;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:16,代码来源:sfWebRequest.class.php

示例3: parse

 /**
  * Parses a URL to find a matching route.
  *
  * Returns null if no route match the URL.
  *
  * @param  string URL to be parsed
  *
  * @return array  An array of parameters
  */
 public function parse($url)
 {
     // an URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does.
     if ($url && '/' != $url[0]) {
         $url = '/' . $url;
     }
     // we remove the query string
     if ($pos = strpos($url, '?')) {
         $url = substr($url, 0, $pos);
     }
     // we remove multiple /
     $url = preg_replace('#/+#', '/', $url);
     foreach ($this->routes as $route_name => $route) {
         $out = array();
         $r = null;
         list($route, $regexp, $names, $names_hash, $defaults, $requirements, $suffix) = $route;
         $break = false;
         if (preg_match($regexp, $url, $r)) {
             $break = true;
             // remove the first element, which is the url
             array_shift($r);
             // hack, pre-fill the default route names
             foreach ($names as $name) {
                 $out[$name] = null;
             }
             // defaults
             foreach ($defaults as $name => $value) {
                 if (preg_match('#[a-z_\\-]#i', $name)) {
                     $out[$name] = urldecode($value);
                 } else {
                     $out[$value] = true;
                 }
             }
             $pos = 0;
             foreach ($r as $found) {
                 // if $found is a named url element (i.e. ':action')
                 if (isset($names[$pos])) {
                     $out[$names[$pos]] = urldecode($found);
                 } else {
                     $pass = explode('/', $found);
                     $found = '';
                     for ($i = 0, $max = count($pass); $i < $max; $i += 2) {
                         if (!isset($pass[$i + 1])) {
                             continue;
                         }
                         $found .= $pass[$i] . '=' . $pass[$i + 1] . '&';
                     }
                     parse_str($found, $pass);
                     if (get_magic_quotes_gpc()) {
                         $pass = sfToolkit::stripslashesDeep((array) $pass);
                     }
                     foreach ($pass as $key => $value) {
                         // we add this parameters if not in conflict with named url element (i.e. ':action')
                         if (!isset($names_hash[$key])) {
                             $out[$key] = $value;
                         }
                     }
                 }
                 $pos++;
             }
             // we must have found all :var stuffs in url? except if default values exists
             foreach ($names as $name) {
                 if ($out[$name] == null) {
                     $break = false;
                 }
             }
             if ($break) {
                 // we store route name
                 $this->setCurrentRouteName($route_name);
                 if (sfConfig::get('sf_logging_enabled')) {
                     sfLogger::getInstance()->info('{sfRouting} match route [' . $route_name . '] "' . $route . '"');
                 }
                 break;
             }
         }
     }
     // no route found
     if (!$break) {
         if (sfConfig::get('sf_logging_enabled')) {
             sfLogger::getInstance()->info('{sfRouting} no matching route found');
         }
         return null;
     }
     return $out;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:94,代码来源:sfRouting.class.php

示例4: loadParameters

 protected function loadParameters()
 {
     if (get_magic_quotes_gpc()) {
         $_GET = sfToolkit::stripslashesDeep($_GET);
     }
     $this->getParameterHolder()->addByRef($_GET);
     $pathInfo = $this->getPathInfo();
     if ($pathInfo) {
         $r = sfRouting::getInstance();
         if ($r->hasRoutes()) {
             $results = $r->parse($pathInfo);
             if ($results !== null) {
                 $this->getParameterHolder()->addByRef($results);
             } else {
                 $this->setParameter('module', sfConfig::get('sf_error_404_module'));
                 $this->setParameter('action', sfConfig::get('sf_error_404_action'));
             }
         } else {
             $array = explode('/', trim($pathInfo, '/'));
             $count = count($array);
             for ($i = 0; $i < $count; $i++) {
                 if ($count > $i + 1) {
                     $this->getParameterHolder()->setByRef($array[$i], $array[++$i]);
                 }
             }
         }
     }
     if (get_magic_quotes_gpc()) {
         $_POST = sfToolkit::stripslashesDeep((array) $_POST);
     }
     $this->getParameterHolder()->addByRef($_POST);
     foreach ($this->getParameterHolder()->getAll() as $key => $value) {
         if (0 === stripos($key, '_sf_')) {
             $this->getParameterHolder()->remove($key);
             $this->setParameter($key, $value, 'symfony/request/sfWebRequest');
             unset($_GET[$key]);
         }
     }
     if (sfConfig::get('sf_logging_enabled')) {
         $this->getContext()->getLogger()->info(sprintf('{sfRequest} request parameters %s', str_replace("\n", '', var_export($this->getParameterHolder()->getAll(), true))));
     }
 }
开发者ID:kotow,项目名称:work,代码行数:42,代码来源:config_core_compile.yml.php

示例5: addslashes

$php = <<<EOF
<?php
  \$pluginDirs = '/*/modules/lib/helper';
  \$pluginDirs = '/*/lib/helper';

EOF;

$t->is(sfToolkit::stripComments($php), $php, '::stripComments() correctly handles comments within strings');


// ::stripslashesDeep()
$t->diag('::stripslashesDeep()');
$t->is(sfToolkit::stripslashesDeep('foo'), 'foo', '::stripslashesDeep() strip slashes on string');
$t->is(sfToolkit::stripslashesDeep(addslashes("foo's bar")), "foo's bar", '::stripslashesDeep() strip slashes on array');
$t->is(sfToolkit::stripslashesDeep(array(addslashes("foo's bar"), addslashes("foo's bar"))), array("foo's bar", "foo's bar"), '::stripslashesDeep() strip slashes on deep arrays');
$t->is(sfToolkit::stripslashesDeep(array(array('foo' => addslashes("foo's bar")), addslashes("foo's bar"))), array(array('foo' => "foo's bar"), "foo's bar"), '::stripslashesDeep() strip slashes on deep arrays');

// ::clearDirectory()
$t->diag('::clearDirectory()');
$tmp_dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'symfony_tests_'.rand(1, 999);
mkdir($tmp_dir);
file_put_contents($tmp_dir.DIRECTORY_SEPARATOR.'test', 'ok');
mkdir($tmp_dir.DIRECTORY_SEPARATOR.'foo');
file_put_contents($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar', 'ok');
sfToolkit::clearDirectory($tmp_dir);
$t->ok(!is_dir($tmp_dir.DIRECTORY_SEPARATOR.'foo'), '::clearDirectory() removes all directories from the directory parameter');
$t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar'), '::clearDirectory() removes all directories from the directory parameter');
$t->ok(!is_file($tmp_dir.DIRECTORY_SEPARATOR.'test'), '::clearDirectory() removes all directories from the directory parameter');
rmdir($tmp_dir);

// ::clearGlob()
开发者ID:nationalfield,项目名称:symfony,代码行数:31,代码来源:sfToolkitTest.php

示例6: loadParameters

 /**
  * Loads GET, PATH_INFO and POST data into the parameter list.
  *
  */
 protected function loadParameters()
 {
     // GET parameters
     $this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
     $this->parameterHolder->add($this->getParameters);
     // additional parameters
     $this->requestParameters = $this->parseRequestParameters();
     $this->parameterHolder->add($this->requestParameters);
     // POST parameters
     $this->postParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_POST) : $_POST;
     $this->parameterHolder->add($this->postParameters);
     // move symfony parameters to attributes (parameters prefixed with _sf_)
     foreach ($this->parameterHolder->getAll() as $key => $value) {
         if (0 === stripos($key, '_sf_')) {
             $this->parameterHolder->remove($key);
             $this->setAttribute($key, $value);
         }
     }
     if (sfConfig::get('sf_logging_enabled')) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Request parameters %s', str_replace("\n", '', var_export($this->getParameterHolder()->getAll(), true))))));
     }
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:26,代码来源:sfWebRequest.class.php


注:本文中的sfToolkit::stripslashesDeep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。