示例#1
0
文件: chat.php 项目: netixx/frankiz
 function handler_chat_avatar($page, $hruid)
 {
     global $globals;
     $filter = new UFC_Hruid($hruid);
     $uf = new UserFilter($filter);
     $user = $uf->get(true);
     //add boolean
     if (!$user) {
         header($_SERVER['SERVER_PROTOCOL'] . '404 Not Found');
         $image = new StaticImage($globals->images->man);
         // for some reason mime isn't picked up: for valid images mime == null is enough to be displayed correctly
         // for $globals->images->man neither 1 nor null does the trick
     } else {
         $user->select(UserSelect::login());
         $image = $user->image();
     }
     $image->send("micro");
     exit;
 }
示例#2
0
文件: admin.php 项目: netixx/frankiz
 function handler_debug($page)
 {
     global $globals;
     if (Env::has("reload")) {
         S::user()->select(UserSelect::login());
     }
     if ($globals->debug & DEBUG_BT) {
         $sessions = array();
         foreach ($_SESSION as $key => $val) {
             ob_start();
             var_dump($val);
             $str = ob_get_clean();
             $str = str_replace("\n", '', $str);
             $str = str_replace('{', '</span><ul><li><span>', $str);
             $str = str_replace('[', '</span></li><li><span>[', $str);
             $str = str_replace('}', '</li></span></ul>', $str);
             $str = preg_replace('/<span> *<\\/span>/i', '', $str);
             $str = preg_replace('/<li> *<\\/li>/i', '', $str);
             $sessions[$key] = $str;
         }
         $page->assign('session', $sessions);
     }
     $page->assign('title', 'Debug');
     $page->changeTpl('admin/debug.tpl');
 }
示例#3
0
 public function handler_defaultfilters($page)
 {
     S::user()->select(UserSelect::login());
     if (Env::has('options')) {
         $groups = new Collection('Group');
         $gids = explode(';', Env::s('promo'));
         if (Env::t('promo', '') != '') {
             $groups->add($gids);
         }
         $groups->select(GroupSelect::base());
         S::user()->defaultFilters($groups);
     }
     $page->assign('user', S::user());
     $page->addCssLink('profile.css');
     $page->assign('title', "Filtre par défaut");
     $page->changeTpl('profile/defaultfilters.tpl');
 }
示例#4
0
文件: user.php 项目: netixx/frankiz
 public static function getSilentWithValues($login, $values)
 {
     global $globals;
     if ($login == 0) {
         // If the anonymous_user is already in session
         if (S::has('anonymous_user')) {
             return S::v('anonymous_user');
         }
         $uid = IPAddress::getInstance()->is_x_internal() ? $globals->anonymous->internal : $globals->anonymous->external;
         S::set('newuid', $uid);
         try {
             $u = new User($uid);
             $u->select(UserSelect::login());
         } catch (Exception $e) {
             S::kill('newuid');
             throw $e;
         }
         S::kill('newuid');
         S::set('anonymous_user', $u);
         return $u;
     }
     throw new Exception('DEPRECATED call to getSilentWithValues()');
 }
示例#5
0
 /** Check that we have at least $level auth
  */
 protected function doAuth($level)
 {
     //If only AUTH_COOKIE is required, and we haven't checked the presence of a cookie, do it now
     if ($level == AUTH_COOKIE && !S::has('cookie_uid')) {
         $this->tryCookie();
     }
     //If AUTH_COOKIE is required, and it has succeeded
     if ($level == AUTH_COOKIE && S::has('cookie_uid')) {
         if (!S::logged()) {
             S::set('auth', AUTH_COOKIE);
         }
         $uid = S::i('cookie_uid');
         S::set('newuid', $uid);
         try {
             $u = new User($uid);
             $u->select(UserSelect::login());
         } catch (Exception $e) {
             S::kill('newuid');
             throw $e;
         }
         S::kill('newuid');
         return $u;
     }
     /*If we are here, we want AUTH_MDP
       So we check if the required fields are here */
     // FIXME : lesser checks until new mechanism is ready
     //if(!Post::has('username') || !Post::has('response') || !S::has('challenge'))
     if (!Post::has('username') || !Post::has('password')) {
         return null;
     }
     /* So we come from an authentication form */
     if (S::suid()) {
         $login = S::suid('uid');
         $redirect = false;
     } else {
         $login = Env::v('username');
         $redirect = false;
         if (Post::has('domain')) {
             Cookie::set('domain', Post::v('domain'), 300);
         }
     }
     // FIXME : using Post::v('password') until new authentication mechanism is ready
     $uid = $this->checkPassword($login, Post::v('password'), is_numeric($login) ? 'uid' : 'alias');
     if (!is_null($uid) && S::suid()) {
         if (S::suid('uid') == $uid) {
             $uid = S::i('uid');
         } else {
             $uid = null;
         }
     }
     if (!is_null($uid)) {
         S::set('auth', AUTH_MDP);
         S::kill('challenge');
         // Register a temporary session UID to query well user information
         S::set('newuid', $uid);
         try {
             $user = new User($uid);
             S::logger($uid)->log('auth_ok');
             $user->select(UserSelect::login());
             S::kill('newuid');
         } catch (Exception $e) {
             throw $e;
         }
         S::kill('newuid');
         return $user;
     }
 }