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


PHP OC_Preferences::getKeys方法代码示例

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


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

示例1: testGetKeys

 public function testGetKeys()
 {
     $query = \OC_DB::prepare('SELECT DISTINCT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?');
     $result = $query->execute(array('Someuser', 'getkeysapp'));
     $expected = array();
     while ($row = $result->fetchRow()) {
         $expected[] = $row['configkey'];
     }
     $this->assertEquals($expected, \OC_Preferences::getKeys('Someuser', 'getkeysapp'));
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:10,代码来源:preferences-singleton.php

示例2: loginWithCookie

 /**
  * perform login using the magic cookie (remember login)
  *
  * @param string $uid the username
  * @param string $currentToken
  * @return bool
  */
 public function loginWithCookie($uid, $currentToken)
 {
     $this->manager->emit('\\OC\\User', 'preRememberedLogin', array($uid));
     $user = $this->manager->get($uid);
     if (is_null($user)) {
         // user does not exist
         return false;
     }
     // get stored tokens
     $tokens = \OC_Preferences::getKeys($uid, 'login_token');
     // test cookies token against stored tokens
     if (!in_array($currentToken, $tokens, true)) {
         return false;
     }
     // replace successfully used token with a new one
     \OC_Preferences::deleteKey($uid, 'login_token', $currentToken);
     $newToken = \OC_Util::generateRandomBytes(32);
     \OC_Preferences::setValue($uid, 'login_token', $newToken, time());
     $this->setMagicInCookie($user->getUID(), $newToken);
     //login
     $this->setUser($user);
     $this->manager->emit('\\OC\\User', 'postRememberedLogin', array($user));
     return true;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:31,代码来源:session.php

示例3: tryRememberLogin

 protected static function tryRememberLogin()
 {
     if (!isset($_COOKIE["oc_remember_login"]) || !isset($_COOKIE["oc_token"]) || !isset($_COOKIE["oc_username"]) || !$_COOKIE["oc_remember_login"]) {
         return false;
     }
     OC_App::loadApps(array('authentication'));
     if (defined("DEBUG") && DEBUG) {
         OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
     }
     // confirm credentials in cookie
     if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) {
         // delete outdated cookies
         self::cleanupLoginTokens($_COOKIE['oc_username']);
         // get stored tokens
         $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token');
         // test cookies token against stored tokens
         if (in_array($_COOKIE['oc_token'], $tokens, true)) {
             // replace successfully used token with a new one
             OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']);
             $token = OC_Util::generate_random_bytes(32);
             OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time());
             OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
             // login
             OC_User::setUserId($_COOKIE['oc_username']);
             OC_Util::redirectToDefaultPage();
             // doesn't return
         }
         // if you reach this point you have changed your password
         // or you are an attacker
         // we can not delete tokens here because users may reach
         // this point multiple times after a password change
         OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN);
     }
     OC_User::unsetMagicInCookie();
     return true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:36,代码来源:base.php

示例4: cleanupLoginTokens

 /**
  * Remove outdated and therefore invalid tokens for a user
  * @param string $user
  */
 protected static function cleanupLoginTokens($user)
 {
     $cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
     $tokens = OC_Preferences::getKeys($user, 'login_token');
     foreach ($tokens as $token) {
         $time = OC_Preferences::getValue($user, 'login_token', $token);
         if ($time < $cutoff) {
             OC_Preferences::deleteKey($user, 'login_token', $token);
         }
     }
 }
开发者ID:pinoniq,项目名称:core,代码行数:15,代码来源:base.php

示例5: getData

 /**
  * get private data
  * @param string $user
  * @param string $app
  * @param string $key
  * @param bool $like use LIKE instead of = when comparing keys
  * @return array
  */
 public static function getData($user, $app = "", $key = "")
 {
     if ($app) {
         $apps = array($app);
     } else {
         $apps = OC_Preferences::getApps($user);
     }
     if ($key) {
         $keys = array($key);
     } else {
         foreach ($apps as $app) {
             $keys = OC_Preferences::getKeys($user, $app);
         }
     }
     $result = array();
     foreach ($apps as $app) {
         foreach ($keys as $key) {
             $value = OC_Preferences::getValue($user, $app, $key);
             $result[] = array('app' => $app, 'key' => $key, 'value' => $value);
         }
     }
     return $result;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:31,代码来源:ocs.php

示例6: getUserKeys

 /**
  * Get the keys of all stored by an app for the user
  *
  * @param string $userId the userId of the user that we want to store the value under
  * @param string $appName the appName that we stored the value under
  * @return string[]
  */
 public function getUserKeys($userId, $appName)
 {
     return \OC_Preferences::getKeys($userId, $appName);
 }
开发者ID:Romua1d,项目名称:core,代码行数:11,代码来源:allconfig.php


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