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


PHP BaseForm::isCSRFProtected方法代码示例

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


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

示例1: getToken

 public static function getToken()
 {
     $form = new BaseForm();
     if ($form->isCSRFProtected()) {
         return $form->getCSRFToken();
     }
     return '';
 }
开发者ID:limitium,项目名称:uberlov,代码行数:8,代码来源:CSRF.php

示例2: jquery_ajax

/**
 * Load a remote page using an HTTP request
 * @param array $configurations A set of key/value pairs that configure the
 * default Ajax request. Important frequency value makes the ajax call is executed
 * periodically
 * @param boolean $isInternal If this function is inner a javascript body
 * @return string jQuery syntax
 */
function jquery_ajax($configurations = null, $isInternal = false)
{
    if (is_array($configurations) && sizeof($configurations) > 0) {
        $suffix = '';
        $prefix = '';
        if (isset($configurations['frequency'])) {
            $suffix = 'setInterval(function(){';
            $prefix = '}, ' . (int) $configurations['frequency'] * 1000 . ')';
        }
        if (isset($configurations['condition']) && trim($configurations['condition']) != '') {
            $prefix = isset($configurations['onFailureCondition']) ? sprintf('} else {%s} ', $configurations['onFailureCondition']) . $prefix : '}' . $prefix;
            $suffix .= sprintf("if(%s){ ", $configurations['condition']);
        }
        if (isset($configurations['confirmation']) && trim($configurations['confirmation']) != '') {
            $prefix = isset($configurations['onNoConfirmation']) ? sprintf('} else {%s} ', $configurations['onNoConfirmation']) . $prefix : '}' . $prefix;
            $suffix .= sprintf("if(confirm('%s')){ ", $configurations['confirmation']);
        }
        if (isset($configurations['csrf']) && $configurations['csrf']) {
            $sfForm = new BaseForm();
            if ($sfForm->isCSRFProtected()) {
                $csrfArray = array($sfForm->getCSRFFieldName() => "'" . $sfForm->getCSRFToken() . "'");
                $configurations['data'] = isset($configurations['data']) ? array_merge($configurations['data'], $csrfArray) : $csrfArray;
            }
        }
        if (isset($configurations['listener']) && is_array($configurations['listener'])) {
            $listener = $configurations['listener'];
            $selector = isset($listener['selector']) ? $listener['selector'] : 'document';
            $event = isset($listener['event']) ? $listener['event'] : 'ready';
            $ajaxTemplate = ui_ajax_pattern($configurations);
            if ($isInternal) {
                return $suffix . jquery_support($selector, $event, like_function($suffix . jquery_support(null, 'ajax', $ajaxTemplate) . $prefix));
            } else {
                return add_jquery_support($selector, $event, like_function($suffix . jquery_support(null, 'ajax', $ajaxTemplate) . $prefix));
            }
        } else {
            $ajaxTemplate = ui_ajax_pattern($configurations);
            return $suffix . jquery_support(null, 'ajax', $ajaxTemplate) . $prefix;
        }
    }
}
开发者ID:alexhandzhiev,项目名称:sifact,代码行数:48,代码来源:ysJQueryRevolutionsHelper.php

示例3: checkCSRFProtection

 public function checkCSRFProtection()
 {
     $form = new BaseForm();
     $form->bind($form->isCSRFProtected() ? array($form->getCSRFFieldName() => $this->getParameter($form->getCSRFFieldName())) : array());
     if (!$form->isValid()) {
         throw $form->getErrorSchema();
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:8,代码来源:sfWebRequest.class.php

示例4: checkAll

            <li><?php echo link_to(__('Restore'), 'sfSimpleBlogPostAdmin/restoreVersion?id='.$version->getId().'&version='.$version->getVersion(), array('confirm' => __('Are your sure?'), 'method' => 'put')) ?></li>
            <li><?php echo link_to(__('Delete'), 'sfSimpleBlogPostAdmin/deleteVersion?id='.$version->getId().'&version='.$version->getVersion(), array('confirm' => __('Are your sure?'), 'method' => 'delete')) ?></li>
          </ul>
        </td>
      </tr>
    </tbody>
  <?php endforeach; ?>
    <tfoot>
      <tr>
        <th colspan="5">&nbsp</th>
      </tr>
    </tfoot>
  </table>
  </fieldset>
  <?php if (count($versions) > 0): ?>
    <?php $form = new BaseForm(); if ($form->isCSRFProtected()): ?>
      <input type="hidden" name="<?php echo $form->getCSRFFieldName() ?>" value="<?php echo $form->getCSRFToken() ?>" />
    <?php endif; ?>
    <input type="submit" value="Delete Versions" />
  <?php endif; ?>
  </form>
  
</div>
<script type="text/javascript">
/* <![CDATA[ */
function checkAll()
{
  var boxes = document.getElementsByTagName('input'); for(var index = 0; index < boxes.length; index++) { box = boxes[index]; if (box.type == 'checkbox' && box.className == 'sf_admin_batch_checkbox') box.checked = document.getElementById('sf_admin_list_batch_checkbox').checked } return true;
}
/* ]]> */
</script>
开发者ID:nibsirahsieu,项目名称:sfSimpleBlog15Plugin,代码行数:31,代码来源:_versions.php

示例5: _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 BaseForm();
    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:nurfiantara,项目名称:ehri-ica-atom,代码行数:16,代码来源:UrlHelper.php

示例6: array

        <option value="batchDelete"><?php 
        echo __('Delete', array(), 'sf_admin');
        ?>
</option>
      <?php 
    }
    ?>
 
      
      <?php 
    $form = new BaseForm();
    ?>
 
      
      <?php 
    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');
    ?>
开发者ID:ndachez,项目名称:dachez,代码行数:31,代码来源:_list_batch_actions.php

示例7: getCsrfToken

 /**
  * Get CSRF token
  * 
  * @return  string|false    CSRF token string
  */
 public function getCsrfToken()
 {
     if (is_null($this->csrfToken)) {
         $this->csrfToken = $this->csrfField = false;
         $form = new BaseForm();
         if ($form->isCSRFProtected()) {
             $this->csrfToken = $form->getCSRFToken();
             $this->csrfField = $form->getCSRFFieldName();
         }
     }
     return $this->csrfToken;
 }
开发者ID:relo-san,项目名称:dinDoctrineModulePlugin,代码行数:17,代码来源:dinModelGeneratorHelper.php


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