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


PHP IsAuthorized函数代码示例

本文整理汇总了PHP中IsAuthorized函数的典型用法代码示例。如果您正苦于以下问题:PHP IsAuthorized函数的具体用法?PHP IsAuthorized怎么用?PHP IsAuthorized使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: UserLogin

if (isset($_POST['login'])) {
    $Username = $_POST['username'];
    $Password = $_POST['password'];
    $output = UserLogin($Username, $Password);
    var_dump($output);
    // If success, redirect to dashboard.php
}
if (isset($_POST['register'])) {
    echo "why";
    $Username = $_POST['username'];
    $Password = $_POST['password'];
    $output = CreateUser($Username, $Password);
    var_dump($output);
}
// Verify that we're authorized
if (!isset($_SESSION["Token"]) || !IsAuthorized()) {
    // Redirect to index.php
    header("Location: index.php");
}
$_SESSION["LastMessageID"] = 0;
/**
   $output = CreateGame("GameTest", "Evan");
   if(IsUserTurn($_SESSION["Username"], $_SESSION["GameID"]))
       HitPlayer("Evan");
   if(IsUserTurn($_SESSION["Username"], $_SESSION["GameID"]))
       FoldPlayer();

   UpdateBoard();

   ResetEntireDatabase();
   // Check if user logged in, if so show leaderboard, if not, login / registration
开发者ID:evreichard,项目名称:PHPlackjack,代码行数:31,代码来源:dashboard.php

示例2: PmWikiAuth

function PmWikiAuth($pagename, $level, $authprompt=true, $since=0) {
  global $DefaultPasswords, $GroupAttributesFmt, $AllowPassword,
    $AuthCascade, $FmtV, $AuthPromptFmt, $PageStartFmt, $PageEndFmt, 
    $AuthId, $AuthList, $NoHTMLCache;
  static $acache;
  SDV($GroupAttributesFmt,'$Group/GroupAttributes');
  SDV($AllowPassword,'nopass');
  $page = ReadPage($pagename, $since);
  if (!$page) { return false; }
  if (!isset($acache)) 
    SessionAuth($pagename, (@$_POST['authpw']) 
                           ? array('authpw' => array($_POST['authpw'] => 1))
                           : '');
  if (@$AuthId) {
    $AuthList["id:$AuthId"] = 1;
    $AuthList["id:-$AuthId"] = -1;
    $AuthList["id:*"] = 1;
  }
  $gn = FmtPageName($GroupAttributesFmt, $pagename);
  if (!isset($acache[$gn])) {
    $gp = ReadPage($gn, READPAGE_CURRENT);
    foreach($DefaultPasswords as $k => $v) {
      $x = array(2, array(), '');
      $acache['@site'][$k] = IsAuthorized($v, 'site', $x);
      $AuthList["@_site_$k"] = $acache['@site'][$k][0] ? 1 : 0;
      $acache[$gn][$k] = IsAuthorized($gp["passwd$k"], 'group', 
                                      $acache['@site'][$k]);
    }
  }
  foreach($DefaultPasswords as $k => $v) 
    list($page['=auth'][$k], $page['=passwd'][$k], $page['=pwsource'][$k]) =
      IsAuthorized($page["passwd$k"], 'page', $acache[$gn][$k]);
  foreach($AuthCascade as $k => $t) {
    if ($page['=auth'][$k]+0 == 2) {
      $page['=auth'][$k] = $page['=auth'][$t];
      if ($page['=passwd'][$k] = $page['=passwd'][$t])         # assign
        $page['=pwsource'][$k] = "cascade:$t";
    }
  }
  if (@$page['=auth']['admin']) 
    foreach($page['=auth'] as $lv=>$a) @$page['=auth'][$lv] = 3;
  if (@$page['=passwd']['read']) $NoHTMLCache |= 2;
  if ($level=='ALWAYS' || @$page['=auth'][$level]) return $page;
  if (!$authprompt) return false;
  $GLOBALS['AuthNeeded'] = (@$_POST['authpw']) 
    ? $page['=pwsource'][$level] . ' ' . $level : '';
  PCache($pagename, $page);
  $postvars = '';
  foreach($_POST as $k=>$v) {
    if ($k == 'authpw' || $k == 'authid') continue;
    $v = str_replace('$', '$', 
             htmlspecialchars(stripmagic($v), ENT_COMPAT));
    $postvars .= "<input type='hidden' name='$k' value=\"$v\" />\n";
  }
  $FmtV['$PostVars'] = $postvars;
  SDV($AuthPromptFmt,array(&$PageStartFmt,
    "<p><b>$[Password required]</b></p>
      <form name='authform' action='{$_SERVER['REQUEST_URI']}' method='post'>
        $[Password]: <input tabindex='1' type='password' name='authpw' 
          value='' />
        <input type='submit' value='OK' />\$PostVars</form>
        <script language='javascript' type='text/javascript'><!--
          document.authform.authpw.focus() //--></script>", &$PageEndFmt));
  PrintFmt($pagename,$AuthPromptFmt);
  exit;
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:66,代码来源:pmwiki.php


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