示例#1
0
文件: user.php 项目: bencochran/yeti
 public function actionAutocomplete()
 {
     if (!($active_user = User::get_active_user())) {
         buffer_end_clean();
         die;
     }
     $q = $this->get['q'];
     if (empty($q)) {
         die('[]');
     }
     $usernames = User::get_autocomplete($q, $active_user->admin, $active_user);
     $this->setVar('usernames', $usernames);
     $this->setLayout(NULL);
 }
示例#2
0
文件: user.php 项目: bencochran/yeti
 public static function require_admin()
 {
     if ($user = self::get_active_user()) {
         if ($user->admin) {
             return $user;
         } else {
             throw new Lvc_Exception('Non admin (' . $user->name . ') tried to access admin stuff.', 403);
         }
     } else {
         buffer_end_clean();
         $_SESSION['flash']['referrer'] = $_SERVER['REQUEST_URI'];
         header('Location: /user/login');
         die;
     }
 }
示例#3
0
<?php

if (empty($active_user) || empty($torrent)) {
    throw new Lvc_Exception('Download requested but I didn\'t have a user or torrent!');
}
buffer_end_clean();
// Set headers
header('Content-Type: application/x-bittorrent');
header('Content-Disposition: attachment; filename="' . $torrent->path . '"');
header('Content-Transfer-Encoding: binary');
header('Pragma: no-cache');
header('Expires: 0');
print $torrent->unique_for(array('user' => $active_user));
die;
示例#4
0
function require_active_user()
{
    static $user;
    if (empty($user)) {
        if (isset($_SESSION['user_uid'])) {
            $user = User::find(array('uid' => $_SESSION['user_uid'], 'include_hidden' => true));
        }
        if (empty($user)) {
            buffer_end_clean();
            $_SESSION['flash']['referrer'] = $_SERVER['REQUEST_URI'];
            header('Location: /user/login');
            die;
        }
    }
    return $user;
}