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


PHP Acl::authorize方法代码示例

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


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

示例1: setAcl

 function setAcl($openid)
 {
     Acl::authorize('openid', $openid);
     $pool = DBModel::getInstance();
     $context = Model_Context::getInstance();
     $blogid = intval($context->getProperty('blog.id'));
     $pool->reset('UserSettings');
     $pool->setQualifier('name', 'like', 'openid.', true);
     $pool->setQualifier('value', 'equals', $openid, true);
     $pool->setOrder('userid', 'ASC');
     $result = $pool->getCell('userid');
     $userid = null;
     if ($result) {
         $userid = $result;
         Acl::authorize('textcube', $userid);
     }
     if (!empty($userid) && in_array("group.writers", Acl::getCurrentPrivilege())) {
         Session::authorize($blogid, $userid);
     } else {
         Session::authorize($blogid, SESSION_OPENID_USERID);
     }
 }
开发者ID:Avantians,项目名称:Textcube,代码行数:22,代码来源:Textcube.Control.Openid.php

示例2: authenticate

 function authenticate($blogid, $loginid, $password, $blogapi = false)
 {
     $session = array();
     Acl::clearAcl();
     $pool = DBModel::getInstance();
     $blogApiPassword = Setting::getBlogSettingGlobal("blogApiPassword", "");
     $pool->reset("Users");
     if (strlen($password) == 32 && preg_match('/[0-9a-f]{32}/i', $password)) {
         // Traditional md5 Raw login. ( with/without auth token)
         $userid = User::getUserIdByEmail($loginid);
         if (!empty($userid) && !is_null($userid)) {
             $pool->reset('UserSettings');
             $pool->setQualifier('userid', 'equals', intval($userid));
             $pool->setQualifier('name', 'equals', 'AuthToken', true);
             $authtoken = $query->getCell('value');
             $pool->reset("Users");
             if (!empty($authtoken) && $authtoken === $password) {
                 // If user requested auth token, use it to confirm.
                 $session['userid'] = $userid;
             } else {
                 // login with md5 hash
                 $pool->setQualifier("password", "eq", md5($password), true);
             }
         } else {
             return false;
         }
     } else {
         if ($blogapi && !empty($blogApiPassword)) {
             // BlogAPI login
             $pool->setQualifierSet(array("password", "eq", md5($password), true), "OR", array($password, "eq", $blogApiPassword, true));
         } else {
             // Normal login
             $pool->setQualifier("password", "eq", md5($password), true);
         }
     }
     if (empty($session)) {
         $pool->setQualifier("loginid", "eq", $loginid, true);
         $session = $pool->getRow("userid, loginid");
     }
     if (empty($session)) {
         /* You should compare return value with '=== false' which checks with variable types*/
         return false;
     }
     $userid = $session['userid'];
     Acl::authorize('textcube', $userid);
     $pool->reset("Users");
     $pool->setAttribute("lastlogin", Timestamp::getUNIXtime());
     $pool->setQualifier("loginid", "eq", $loginid, true);
     $pool->update();
     //		POD::execute("DELETE FROM {$database['prefix']}UserSettings WHERE userid = '$userid' AND name = 'AuthToken' LIMIT 1");
     return $userid;
 }
开发者ID:Avantians,项目名称:Textcube,代码行数:52,代码来源:30-Auth.php

示例3: authenticate

 function authenticate($blogid, $loginid, $password, $blogapi = false)
 {
     global $database;
     $session = array();
     Acl::clearAcl();
     $loginid = POD::escapeString($loginid);
     $blogApiPassword = Setting::getBlogSettingGlobal("blogApiPassword", "");
     if (strlen($password) == 32 && preg_match('/[0-9a-f]{32}/i', $password)) {
         // Raw login. ( with/without auth token)
         $userid = User::getUserIdByEmail($loginid);
         if (!empty($userid) && !is_null($userid)) {
             $query = DBModel::getInstance();
             $query->reset('UserSettings');
             $query->setQualifier('userid', 'equals', intval($userid));
             $query->setQualifier('name', 'equals', 'AuthToken', true);
             $authtoken = $query->getCell('value');
             if (!empty($authtoken) && $authtoken === $password) {
                 // If user requested auth token, use it to confirm.
                 $session['userid'] = $userid;
             } else {
                 // login with md5 hash
                 $secret = 'password = \'' . md5($password) . '\'';
             }
         } else {
             return false;
         }
     } else {
         if ($blogapi && !empty($blogApiPassword)) {
             // BlogAPI login
             $password = POD::escapeString($password);
             $secret = '(password = \'' . md5($password) . '\' OR \'' . $password . '\' = \'' . $blogApiPassword . '\')';
         } else {
             // Normal login
             $secret = 'password = \'' . md5($password) . '\'';
         }
     }
     if (empty($session)) {
         $session = POD::queryRow("SELECT userid, loginid, name FROM {$database['prefix']}Users WHERE loginid = '{$loginid}' AND {$secret}");
     }
     if (empty($session)) {
         /* You should compare return value with '=== false' which checks with variable types*/
         return false;
     }
     $userid = $session['userid'];
     Acl::authorize('textcube', $userid);
     POD::execute("UPDATE {$database['prefix']}Users SET lastlogin = " . Timestamp::getUNIXtime() . " WHERE loginid = '{$loginid}'");
     //		POD::execute("DELETE FROM {$database['prefix']}UserSettings WHERE userid = '$userid' AND name = 'AuthToken' LIMIT 1");
     return $userid;
 }
开发者ID:ragi79,项目名称:Textcube,代码行数:49,代码来源:30-Auth.php


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