當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TBGContext::generateCSRFtoken方法代碼示例

本文整理匯總了PHP中TBGContext::generateCSRFtoken方法的典型用法代碼示例。如果您正苦於以下問題:PHP TBGContext::generateCSRFtoken方法的具體用法?PHP TBGContext::generateCSRFtoken怎麽用?PHP TBGContext::generateCSRFtoken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TBGContext的用法示例。


在下文中一共展示了TBGContext::generateCSRFtoken方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate

 /**
  * Generate a url based on a route
  * 
  * @param string $name The route key
  * @param array $params key=>value pairs of route parameters
  * @param boolean $relative Whether to generate an url relative to web root or an absolute 
  * 
  * @return string
  */
 public function generate($name, $params = array(), $relative = true, $querydiv = '/', $divider = '/', $equals = '/')
 {
     if (mb_substr($name, 0, 1) == '@') {
         $name = mb_substr($name, 1);
         $details = explode('?', $name);
         $name = array_shift($details);
         if (count($details)) {
             $param_details = array_shift($details);
             $param_details = explode('&', $param_details);
             foreach ($param_details as $detail) {
                 $param_detail = explode('=', $detail);
                 if (count($param_detail) > 1) {
                     $params[$param_detail[0]] = $param_detail[1];
                 }
             }
         }
     }
     if (!isset($this->routes[$name])) {
         TBGLogging::log("The route '{$name}' does not exist", 'routing', TBGLogging::LEVEL_FATAL);
         throw new Exception("The route '{$name}' does not exist");
     }
     list($url, $regexp, $names, $names_hash, $action, $module, $defaults, $csrf_enabled) = $this->routes[$name];
     $defaults = array('action' => $action, 'module' => $module);
     // all params must be given
     foreach ($names as $tmp) {
         if (!isset($params[$tmp]) && !isset($defaults[$tmp])) {
             throw new Exception(sprintf('Route named "%s" have a mandatory "%s" parameter', $name, $tmp));
         }
     }
     $params = self::arrayDeepMerge($defaults, $params);
     if ($csrf_enabled) {
         $params['csrf_token'] = TBGContext::generateCSRFtoken();
     }
     // in PHP 5.5, preg_replace with /e modifier is deprecated; preg_replace_callback is recommended
     $callback = function ($matches) use($params) {
         return array_key_exists($matches[1], $params) ? urlencode($params[$matches[1]]) : $matches[0];
     };
     $real_url = preg_replace_callback('/\\:([^\\/]+)/', $callback, $url);
     // we add all other params if *
     if (mb_strpos($real_url, '*')) {
         $tmp = array();
         foreach ($params as $key => $value) {
             if (isset($names_hash[$key]) || isset($defaults[$key])) {
                 continue;
             }
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     if (is_array($v)) {
                         foreach ($v as $vk => $vv) {
                             if (is_array($vv)) {
                                 foreach ($vv as $vvk => $vvv) {
                                     $tmp[] = "{$key}[{$k}][{$vk}][{$vvk}]" . $equals . urlencode($vvv);
                                 }
                             } else {
                                 $tmp[] = "{$key}[{$k}][{$vk}]" . $equals . urlencode($vv);
                             }
                         }
                     } else {
                         $tmp[] = "{$key}[{$k}]" . $equals . urlencode($v);
                     }
                 }
             } else {
                 $tmp[] = urlencode($key) . $equals . urlencode($value);
             }
         }
         $tmp = implode($divider, $tmp);
         if (mb_strlen($tmp) > 0) {
             $tmp = $querydiv . $tmp;
         }
         $real_url = preg_replace('/\\/\\*(\\/|$)/', "{$tmp}\$1", $real_url);
     }
     // strip off last divider character
     if (mb_strlen($real_url) > 1) {
         $real_url = rtrim($real_url, $divider);
     }
     if (!$relative) {
         return TBGContext::getURLhost() . TBGContext::getStrippedTBGPath() . $real_url;
     }
     return TBGContext::getStrippedTBGPath() . $real_url;
 }
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:89,代碼來源:TBGRouting.class.php

示例2: __

    ?>
</button>
			<button class="button button-green" style="<?php 
    if ($tbg_user->isConfirmedMemberOfScope($scope)) {
        ?>
display: none;<?php 
    }
    ?>
" onclick="TBG.Main.Helpers.Dialog.show('<?php 
    echo __('Confirm membership in this scope?');
    ?>
', '<?php 
    echo __('By confirming this membership you will be able to log into this scope, but users and administrators in this scope will also have access to your information (such as email, username, real name, etc.) just like a regular account in that installation.');
    ?>
', {yes: {click: function() {TBG.Main.Profile.confirmScopeMembership('<?php 
    echo make_url('account_confirm_scope', array('scope_id' => $scope->getID(), 'csrf_token' => TBGContext::generateCSRFtoken()));
    ?>
', <?php 
    echo $scope->getID();
    ?>
);}}, no: {click: TBG.Main.Helpers.Dialog.dismiss}});"><?php 
    echo __('Confirm membership');
    ?>
</button>
		</div>
	<?php 
}
?>
	<b><?php 
echo $scope->getName();
?>
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:31,代碼來源:_userscope.inc.php

示例3: csrf_tag

/**
 * Returns a csrf_token hidden input tag to use in forms
 *
 * @return string
 */
function csrf_tag()
{
    return '<input type="hidden" name="csrf_token" value="' . TBGContext::generateCSRFtoken() . '">';
}
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:9,代碼來源:ui.inc.php

示例4: __

            ?>
							<li id="openid_account_<?php 
            echo $details['id'];
            ?>
">
								<?php 
            if (count($tbg_user->getOpenIDAccounts()) > 1 || !$tbg_user->isOpenIDLocked()) {
                ?>
									<button class="button button-silver" onclick="TBG.Main.Helpers.Dialog.show('<?php 
                echo __('Remove this account link?');
                ?>
', '<?php 
                echo __('Do you really want to remove the link to this external account?') . '<br>' . __('By doing this, it will not be possible to log into this account via this authentication provider');
                ?>
', {yes: {click: function() {TBG.Main.Profile.removeOpenIDIdentity('<?php 
                echo make_url('account_remove_openid', array('openid' => $details['id'], 'csrf_token' => TBGContext::generateCSRFtoken()));
                ?>
', <?php 
                echo $details['id'];
                ?>
);}}, no: {click: TBG.Main.Helpers.Dialog.dismiss}});"><?php 
                echo __('Delete');
                ?>
</button>
								<?php 
            }
            ?>
								<?php 
            echo image_tag('openid_providers.small/' . $details['type'] . '.ico.png');
            ?>
								<span class="openid_provider_name">
開發者ID:oparoz,項目名稱:thebuggenie,代碼行數:31,代碼來源:myaccount.html.php


注:本文中的TBGContext::generateCSRFtoken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。