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


PHP sfForm::isCSRFProtected方法代码示例

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


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

示例1: checkCSRFProtection

 /**
  * @see sfWebRequest
  */
 public function checkCSRFProtection()
 {
     try {
         parent::checkCSRFProtection();
     } catch (sfValidatorErrorSchema $e) {
         // retry checking for using sfForm (just for BC)
         $form = new sfForm();
         $form->bind($form->isCSRFProtected() ? array($form->getCSRFFieldName() => $this->getParameter($form->getCSRFFieldName())) : array());
         if (!$form->isValid()) {
             throw $form->getErrorSchema();
         }
     }
 }
开发者ID:shotaatago,项目名称:OpenPNE3,代码行数:16,代码来源:opWebRequest.class.php

示例2: checkCSRFProtection

 public function checkCSRFProtection()
 {
     $form = new sfForm();
     $form->bind($form->isCSRFProtected() ? array($form->getCSRFFieldName() => $this->getParameter($form->getCSRFFieldName())) : array());
     if (!$form->isValid()) {
         throw $form->getErrorSchema();
     }
 }
开发者ID:BGCX261,项目名称:zoorestaurant-svn-to-git,代码行数:8,代码来源:config_core_compile.yml.php

示例3: _method_javascript_function

function _method_javascript_function($method)
{
    $function = "var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'post'; f.action = this.href;";
    if ('post' != strtolower($method)) {
        $function .= "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); ";
        $function .= sprintf("m.setAttribute('name', 'sf_method'); m.setAttribute('value', '%s'); f.appendChild(m);", strtolower($method));
    }
    // CSRF protection
    $form = new sfForm();
    if ($form->isCSRFProtected()) {
        $function .= "var m = document.createElement('input'); m.setAttribute('type', 'hidden'); ";
        $function .= sprintf("m.setAttribute('name', '%s'); m.setAttribute('value', '%s'); f.appendChild(m);", $form->getCSRFFieldName(), $form->getCSRFToken());
    }
    $function .= "f.submit();";
    return $function;
}
开发者ID:nvidela,项目名称:kimkelen,代码行数:16,代码来源:UrlHelper.php

示例4: jq_remote_function

/**
 * Returns the javascript needed for a remote function.
 * Takes the same arguments as 'link_to_remote()'.
 *
 * Example:
 *   <select id="options" onchange="<?php echo remote_function(array('update' => 'options', 'url' => '@update_options')) ?>">
 *     <option value="0">Hello</option>
 *     <option value="1">World</option>
 *   </select>
 */
function jq_remote_function($options)
{
    // Defining elements to update
    if (isset($options['update']) && is_array($options['update'])) {
        // On success, update the element with returned data
        if (isset($options['update']['success'])) {
            $update_success = "#" . $options['update']['success'];
        }
        // On failure, execute a client-side function
        if (isset($options['update']['failure'])) {
            $update_failure = $options['update']['failure'];
        }
    } else {
        if (isset($options['update'])) {
            $update_success = "#" . $options['update'];
        }
    }
    // Update method
    $updateMethod = _update_method(isset($options['position']) ? $options['position'] : '');
    // Callbacks
    if (isset($options['loading'])) {
        $callback_loading = $options['loading'];
    }
    if (isset($options['complete'])) {
        $callback_complete = $options['complete'];
    }
    if (isset($options['success'])) {
        $callback_success = $options['success'];
    }
    $execute = 'false';
    if (isset($options['script']) && $options['script'] == '1') {
        $execute = 'true';
    }
    // Data Type
    if (isset($options['dataType'])) {
        $dataType = $options['dataType'];
    } elseif ($execute) {
        $dataType = 'html';
    } else {
        $dataType = 'text';
    }
    // POST or GET ?
    $method = 'POST';
    if (isset($options['method']) && strtoupper($options['method']) == 'GET') {
        $method = $options['method'];
    }
    // async or sync, async is default
    if (isset($options['type']) && $options['type'] == 'synchronous') {
        $type = 'false';
    }
    // Is it a form submitting
    if (isset($options['form'])) {
        $formData = 'jQuery(this).serialize()';
    } elseif (isset($options['submit'])) {
        $formData = '{\'#' . $options['submit'] . '\'}.serialize()';
    } elseif (isset($options['with'])) {
        $formData = $options['with'];
    } elseif (isset($options['csrf']) && $options['csrf'] == '1') {
        $form = new sfForm();
        if ($form->isCSRFProtected()) {
            $formData = '{' . $form->getCSRFFieldName() . ': \'' . $form->getCSRFToken() . '\'}';
        }
    }
    // build the function
    $function = "jQuery.ajax({";
    $function .= 'type:\'' . $method . '\'';
    $function .= ',dataType:\'' . $dataType . '\'';
    if (isset($type)) {
        $function .= ',async:' . $type;
    }
    if (isset($formData)) {
        $function .= ',data:' . $formData;
    }
    if (isset($update_success) and !isset($callback_success)) {
        $function .= ',success:function(data, textStatus){jQuery(\'' . $update_success . '\').' . $updateMethod . '(data);}';
    }
    if (isset($update_failure)) {
        $function .= ',error:function(XMLHttpRequest, textStatus, errorThrown){' . $update_failure . '}';
    }
    if (isset($callback_loading)) {
        $function .= ',beforeSend:function(XMLHttpRequest){' . $callback_loading . '}';
    }
    if (isset($callback_complete)) {
        $function .= ',complete:function(XMLHttpRequest, textStatus){' . $callback_complete . '}';
    }
    if (isset($callback_success)) {
        $function .= ',success:function(data, textStatus){' . $callback_success . '}';
    }
    $function .= ',url:\'' . url_for($options['url']) . '\'';
    $function .= '})';
//.........这里部分代码省略.........
开发者ID:slemoigne,项目名称:sympal,代码行数:101,代码来源:jQueryHelper.php

示例5: array

  <select name="batch_action">
    <option value="">[?php echo __('Choose an action', array(), 'sf_admin') ?]</option>
<?php 
    foreach ((array) $listActions as $action => $params) {
        ?>
    <?php 
        echo $this->addCredentialCondition('<option value="' . $action . '">[?php echo __(\'' . $params['label'] . '\', array(), \'sf_admin\') ?]</option>', $params);
        ?>

<?php 
    }
    ?>
  </select>
<?php 
    $form = new sfForm();
    if ($form->isCSRFProtected()) {
        ?>
  <input type="hidden" name="<?php 
        echo $form->getCSRFFieldName();
        ?>
" value="<?php 
        echo $form->getCSRFToken();
        ?>
" />
<?php 
    }
    ?>
  <input type="submit" value="[?php echo __('go', array(), 'sf_admin') ?]" />
</div>
<?php 
}
开发者ID:bshaffer,项目名称:Symplist,代码行数:31,代码来源:_list_batch_actions.php

示例6: _get_json_data_token

function _get_json_data_token()
{
    // CSRF protection
    $form = new sfForm();
    if ($form->isCSRFProtected()) {
        $token = sprintf("', %s: '%s", $form->getCSRFFieldName(), $form->getCSRFToken());
        return $token;
    } else {
        return '';
    }
}
开发者ID:retrofox,项目名称:sfPropelMooDooPlugin,代码行数:11,代码来源:mooDooUrlHelper.php


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