Example #1
0
 /**
  * Destroy user session.
  */
 public function actionLogout()
 {
     try {
         $user = new AuthUser();
         $user->signOut();
         $this->flashSuccess = "You have been logged out";
     } catch (AuthUserNotAuthenticatedException $e) {
         $this->flashSuccess = 'You are already logged out';
     }
     // create token & display login form
     $this->bag->token = Fari_FormToken::create();
     $this->renderAction('login');
 }
Example #2
0
 /**
  * 验证当前访问节点是否有权限
  * @param string $module	模块名称
  * @param string $node		节点名称
  * @return bool ture/false:
  */
 static function checkLogin($module, $node)
 {
     // 判断该项目是否需要认证
     if (C('USER_AUTH_ON') === false) {
         return true;
     }
     // 判断当前模块是否为不需要认证模块
     if (C('NOT_AUTH_NODE') != '') {
         $notauths = explode(',', C('NOT_AUTH_NODE'));
         if (in_array($module . '-' . $node, $notauths)) {
             return true;
         }
     }
     // 认证方式1为登陆认证,2为实时认证
     if (C('USER_AUTH_TYPE') === 1) {
         $accesslists = isset($_SESSION[C('USER_AUTH_KEY')]) ? $_SESSION[C('USER_AUTH_KEY')] : AuthUser::getAccessList();
     }
     if (C('USER_AUTH_TYPE') === 2) {
         $accesslists = AuthUser::getAccessList();
     }
     //print_r($accesslists);exit;
     //         print_r($_SESSION);exit;
     if (isset($accesslists[$module]) && in_array($node, $accesslists[$module])) {
         return true;
     } else {
         return false;
     }
 }
 public static function _checkLog()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
 }
Example #4
0
 function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
 }
Example #5
0
 /**
  * Saves the settings.
  */
 private final function _save()
 {
     $data = $_POST['setting'];
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'setting')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             Observer::notify('csrf_token_invalid', AuthUser::getUserName());
             redirect(get_url('setting'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         Observer::notify('csrf_token_not_found', AuthUser::getUserName());
         redirect(get_url('setting'));
     }
     if (!isset($data['allow_html_title'])) {
         $data['allow_html_title'] = 'off';
     }
     use_helper('Kses');
     $allowed = array('img' => array('src' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'b' => array(), 'blockquote' => array('cite' => array()), 'br' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'p' => array(), 'strike' => array(), 'strong' => array());
     $data['admin_title'] = kses(trim($data['admin_title']), $allowed);
     Setting::saveFromData($data);
     Flash::set('success', __('Settings have been saved!'));
     redirect(get_url('setting'));
 }
Example #6
0
 private static function _checkPermission()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
 }
 public function submit_address($fields = array())
 {
     $checkout = $this->config['checkoutPath'];
     $out = null;
     // wolf authentication
     if (!AuthUser::isLoggedIn() && (!isset($_SESSION['shipping_address']) || empty($_SESSION['shipping_address'])) || 1 == 1) {
         $out .= "<div class=\"shipping_address_form\">";
         $out .= "<div id=\"form_response\"><h2 class=\"checkout-error error-message\">Please provide the following information!</h2></div>";
         //$out .= "<div id=\"form_response\"><h2 class=\"checkout-error error-message\">Please provide the following information!</h2><div>";
         //$this->disablePaypalCheckout = " disabled='disabled'";
         $out .= " <form id=\"shipping_address\" name=\"shipping_address\" action=\"" . $_SERVER['REQUEST_URI'] . "\" method=\"post\">";
         $out .= " <p><label>Delivery Address</label></p><br/><br/>";
         if (!empty($fields)) {
             foreach ($fields['label'] as $k => $label) {
                 $out .= $this->draw_field($k, $fields);
             }
         }
         //$out .= " <input onclick=\"submit_any_form('#submit_address');\" name=\"submit_address\" id=\"submit_address\" type=\"submit\" value=\"Save Addres\" />";
         $out .= " <input class=\"ajaxsubmit\" name=\"submit_address\" id=\"submit_address\" type=\"submit\" value=\"Save Addres\" />";
         $out .= " </form>";
         $out .= "</div>";
     } else {
         $out = '';
     }
     // display shipping address form
     if ($checkout != $this->config['checkoutPath'] || 1 == 1) {
         return $out;
     } else {
         return null;
     }
 }
 public function beforeSave()
 {
     $this->created_on = date('Y-m-d H:i:s');
     $this->username = AuthUser::getRecord()->name;
     $this->message = __($this->message, array(':username' => $this->username));
     return true;
 }
Example #9
0
 /**
  * @method POST
  */
 function pay()
 {
     // parse request
     parse_str($this->request->data, $request);
     $token = $request['token'];
     $plan = $request['plan'];
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         Stripe::setApiKey(STRIPE_API_KEY);
         // create a new customer and subscribe them to the plan
         $customer = Stripe_Customer::create(array("card" => $token, "plan" => $plan, "email" => $authUser->Email));
         // get back the id and the end period for the plan
         $id = $customer->id;
         $end = $customer->subscription->current_period_end;
         // #debug print 'end='.$end;
         date_default_timezone_set('UTC');
         // create a date from the timestamp returned by Stripe
         $renewalDate = gmdate("Y-m-d H:i:s", intval($end));
         // #debug print ' renewalDate='.$renewalDate;
         // by default, you should not have to update a payment
         $updatePayment = 0;
         // update the db and session
         Site::SetSubscription($authUser->SiteUniqId, $plan, $id, $renewalDate, $updatePayment);
         AuthUser::SetPlan($plan, $renewalDate, $updatePayment);
         // return a json response
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
Example #10
0
    public function __construct()
    {
        $mod = trim($_GET['mod']);
        $act = trim($_GET['act']);
        if (C('IS_AUTH_ON') === true) {
            if (!AuthUser::checkLogin($mod, $act)) {
                if (!$_SESSION[C("USER_AUTH_ID")]) {
                    echo '<script language="javascript"> 
					        self.location="index.php?mod=public&act=login";
					   	  </script>';
                } elseif ($_SESSION[C("USER_AUTH_ID")]) {
                    //$data   = array('data'=>array('您尚未有此权限'), 'link'=>$_SERVER['HTTP_REFERER']);
                    //goErrMsgPage($data);exit;
                    echo '您尚未有此权限';
                    exit;
                } else {
                    //$data   = array('data'=>array('还未登陆!'), 'link'=>'index.php?mod=public&act=login');
                    //goErrMsgPage($data);exit;
                    echo '还未登陆!';
                    exit;
                }
                exit;
            }
        }
        self::$_username = isset($_SESSION['userName']) ? $_SESSION['userName'] : "";
        self::$_userid = isset($_SESSION[C("USER_AUTH_ID")]) ? $_SESSION[C("USER_AUTH_ID")] : 0;
        self::$_companyid = isset($_SESSION['companyId']) ? $_SESSION['companyId'] : 0;
        self::$_systemid = C('AUTH_SYSTEM_ID');
        //初始化smarty
        require WEB_PATH . 'lib/template/smarty/Smarty.class.php';
        $this->smarty = new Smarty();
        $this->smarty->template_dir = WEB_PATH . 'html/template/v1/';
        $this->smarty->compile_dir = WEB_PATH . 'smarty/templates_c/';
        $this->smarty->config_dir = WEB_PATH . 'smarty/configs/';
        $this->smarty->cache_dir = WEB_PATH . 'smarty/cache/';
        $this->smarty->debugging = false;
        $this->smarty->caching = false;
        $this->smarty->cache_lifetime = 120;
        //初始化提交过来的变量(post and get)
        if (isset($_GET)) {
            foreach ($_GET as $gk => $gv) {
                $this->smarty->assign('g_' . $gk, $gv);
            }
        }
        if (isset($_POST)) {
            foreach ($_POST as $pk => $pv) {
                $this->smarty->assign('p_' . $pk, $pv);
            }
        }
        $this->smarty->assign('mod', $mod);
        //模块权限
        $this->smarty->assign('act', $act);
        //操作权限
        $this->smarty->assign('_username', self::$_username);
        $this->smarty->assign('_userid', self::$_userid);
        //初始化当前页码
        $this->page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
        $this->smarty->assign("page", $this->page);
    }
Example #11
0
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $this->assignToLayout('sidebar', new View('translate/sidebar'));
 }
Example #12
0
 function deactivate_plugin($plugin)
 {
     if (!AuthUser::hasPermission('administrator')) {
         Flash::set('error', __('You do not have permission to access the requested page!'));
         redirect(get_url());
     }
     Plugin::deactivate($plugin);
 }
Example #13
0
 function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $this->setLayout('backend');
 }
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         echo 'Please Login';
         header('location:index.php?job=login');
     }
 }
Example #15
0
 public function __construct()
 {
     $mod = trim($_GET['mod']);
     $act = trim($_GET['act']);
     ####################  smarty初始化 start ####################
     require WEB_PATH . 'lib/template/smarty/Smarty.class.php';
     $this->smarty = new Smarty();
     $this->smarty->template_dir = WEB_PATH . 'html/template/v1' . DIRECTORY_SEPARATOR;
     $this->smarty->compile_dir = WEB_PATH . 'smarty/templates_c' . DIRECTORY_SEPARATOR;
     $this->smarty->config_dir = WEB_PATH . 'smarty/configs' . DIRECTORY_SEPARATOR;
     $this->smarty->cache_dir = WEB_PATH . 'smarty/cache' . DIRECTORY_SEPARATOR;
     $this->smarty->debugging = false;
     $this->smarty->caching = false;
     $this->smarty->cache_lifetime = 120;
     ####################  smarty初始化  end ####################
     if (C('IS_AUTH_ON') === true) {
         if (AuthUser::checkLogin($mod, $act)) {
             //$this->error('请先登录', 'index.php?mod=public&act=login');
         }
     }
     if (!in_array($act, array('login', 'logout', 'userLogin'))) {
         $now_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         //记录当前页面url
         setcookie('now_url', $now_url, time() + 86400);
     }
     $this->_menul1 = isset($_SESSION['menul1']) ? $_SESSION['menul1'] : array();
     $this->_menul2 = isset($_SESSION['menul2']) ? $_SESSION['menul2'] : array();
     $this->_menul3 = isset($_SESSION['menul3']) ? $_SESSION['menul3'] : array();
     $this->_username = isset($_SESSION['userCnName']) ? $_SESSION['userCnName'] : "xx";
     $this->_userid = isset($_SESSION['userId']) ? $_SESSION['userId'] : 0;
     $this->_companyid = isset($_SESSION['companyId']) ? $_SESSION['companyId'] : 0;
     $this->_systemid = '12';
     //初始化提交过来的变量(post and get)
     if (isset($_GET)) {
         foreach ($_GET as $gk => $gv) {
             $this->smarty->assign('g_' . $gk, $gv);
         }
     }
     if (isset($_POST)) {
         foreach ($_POST as $pk => $pv) {
             $this->smarty->assign('p_' . $pk, $pv);
         }
     }
     $this->smarty->assign('curusername', $_SESSION['userName']);
     //设置当前用户名
     $this->smarty->assign('mod', $mod);
     //模块权限
     $this->smarty->assign('act', $act);
     //操作权限
     $this->smarty->assign('_username', $this->_username);
     $this->smarty->assign('_userid', $this->_userid);
     $this->smarty->assign('menul1', $this->_menul1);
     $this->smarty->assign('menul2', $this->_menul2);
     $this->smarty->assign('menul3', $this->_menul3);
     //初始化当前页码
     $this->page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     $this->smarty->assign("page", $this->page);
 }
Example #16
0
 public function beforeUpdate()
 {
     if (!Observer::notify('layout_before_edit', $this)) {
         return false;
     }
     $this->updated_by_id = AuthUser::getId();
     $this->updated_on = date('Y-m-d H:i:s');
     return true;
 }
Example #17
0
 function ru_logout()
 {
     // Allow plugins to handle logout events
     Observer::notify('logout_requested');
     $username = AuthUser::getUserName();
     AuthUser::logout();
     Observer::notify('admin_after_logout', $username);
     redirect(get_url());
 }
Example #18
0
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $this->setLayout('backend');
     $this->assignToLayout('sidebar', new View('../../plugins/frog_tags/views/sidebar'));
 }
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $this->setLayout('backend');
     $this->assignToLayout('sidebar', new View('fnbgallery/sidebar'));
 }
 function __construct()
 {
     if (defined('CMS_BACKEND')) {
         AuthUser::load();
         if (!AuthUser::isLoggedIn()) {
             redirect(get_url('login'));
         }
     }
 }
 public function beforeSave()
 {
     $this->created_on = date("Y-m-d H:i:s");
     if (!AuthUser::isLoggedIn()) {
         $this->username = "******";
     } else {
         $this->username = AuthUser::getRecord()->name;
     }
     return true;
 }
 function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $_SESSION['assets_folder'] = isset($_SESSION['assets_folder']) ? $_SESSION['assets_folder'] : assets_default_folder();
     $this->setLayout('backend');
     $this->assignToLayout('sidebar', new View('../../plugins/assets/views/sidebar'));
 }
Example #23
0
 public function __construct()
 {
     // Check to make sure user is logged in.
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     $this->setLayout('backend');
     $this->assignToLayout('sidebar', new View('../../plugins/tinymce/views/sidebar'));
 }
 public function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         echo 'Please Login';
         header('location:index.php?job=login');
     }
     //首页最近文章
     //$this->recent_post = Article::getPost(5, true);
     //侧栏分类
     $this->categories = Category::findAll();
     if (is_array($this->categories) && count($this->categories) > 0) {
         $temp = array();
         foreach ($this->categories as $k => $v) {
             $temp[$v->id] = get_object_vars($v);
         }
         $this->cahce_categories = $temp;
         $temp = array();
     }
     //Tags 后期改进为热词形式
     $hot_tags = Tag::findAll(20);
     //mprint_r($hot_tags, '$hot_tags');
     if (count($hot_tags) > 0) {
         $first = current($hot_tags);
         $last = end($hot_tags);
         foreach ($hot_tags as $k => $v) {
             $tags_list[$k]['word'] = $v->name;
             $tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
         }
     }
     $this->tags_list = $tags_list;
     $tags = Tag::findAll();
     //var_dump($tags);
     $content_tag = Record::findAllFrom('ContentTag');
     //var_dump($content_tag);
     //关系表中存在的文章ID以及tag集合到一个数组中tag_cache  避免在遍历生成文章静态页时重复读取数据库
     //遍历所有tag 组合出方便调用的形式
     if (is_array($tags) && count($tags) > 0) {
         $temp_tags = array();
         foreach ($tags as $k => $v) {
             $temp_tags[$v->id] = $v->name;
         }
     }
     //遍历关系表
     if (is_array($content_tag) && count($content_tag) > 0) {
         $this->cahce_tags = array();
         foreach ($content_tag as $k => $v) {
             if (isset($temp_tags[$v->tag_id])) {
                 $this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
             }
         }
     }
     //清空临时数据
     $tags = $content_tag = $temp_tags = array();
 }
/**
 *	Check if user is authorized
 *
 *	@return boolean true is access granted, false if no access
 */
function auth()
{
    // You can insert your own code over here to check if the user is authorized.
    // This calls credentials from Wolf CMS login
    AuthUser::load();
    if (AuthUser::isLoggedIn()) {
        return true;
    } else {
        return false;
    }
}
Example #26
0
function filemanager_lang()
{
    // filemanager available translations, fallback to 'english'
    $trans = array('ca', 'cs', 'da', 'de', 'en', 'es', 'fi', 'fr', 'he', 'hu', 'it', 'ja', 'nl', 'pl', 'pt', 'ru', 'sv', 'vn', 'cn');
    $user_lang = ($user = AuthUser::getRecord()) ? strtolower($user->language) : 'en';
    $lang = in_array($user_lang, $trans) ? $user_lang : 'en';
    if ($lang == 'cn') {
        $lang = 'zh-cn';
    }
    return $lang;
}
Example #27
0
 function getUsuariosArray()
 {
     global $uid;
     $auth = new AuthUser();
     $db = new DB();
     $u = array();
     if (!$auth->is_admin($uid)) {
         $sql = "SELECT name FROM jos_users ";
         $sql .= "WHERE id = {$uid} ";
         $u[$uid] = $db->queryUniqueValue($sql);
     } else {
         $sql = "SELECT id, name FROM jos_users ";
         $sql .= "WHERE block='0' ";
         $res = $db->query($sql);
         while ($line = $db->fetchNextObject($res)) {
             $u[$line->id] = $line->name;
         }
     }
     return $u;
 }
 function __construct()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     }
     if (!AuthUser::hasPermission('admin_view')) {
         redirect(URL_PUBLIC);
     }
     $this->setLayout('backend');
     $this->assignToLayout('sidebar', new View('../../plugins/funky_cache/views/sidebar'));
 }
 private static function _checkPermission()
 {
     AuthUser::load();
     if (!AuthUser::isLoggedIn()) {
         redirect(get_url('login'));
     } else {
         if (!AuthUser::hasPermission('administrator')) {
             Flash::set('error', __('You do not have permission to access the requested page!'));
             redirect(get_url());
         }
     }
 }
Example #30
0
 public function run()
 {
     DB::table('auth_role')->delete();
     $auth_id1 = AuthUser::find(1)->id;
     $auth_id2 = AuthUser::find(2)->id;
     $auth_id3 = AuthUser::find(3)->id;
     $auth_id4 = AuthUser::find(4)->id;
     $auth_id5 = AuthUser::find(5)->id;
     $auth_id6 = AuthUser::find(6)->id;
     $role_id1 = Role::where('name', '=', 'admin')->first()->id;
     $role_id2 = Role::where('name', '=', 'moderator')->first()->id;
     DB::table('auth_role')->insert(array(array('auth_id' => $auth_id1, 'role_id' => $role_id1), array('auth_id' => $auth_id2, 'role_id' => $role_id1), array('auth_id' => $auth_id3, 'role_id' => $role_id2), array('auth_id' => $auth_id4, 'role_id' => $role_id1), array('auth_id' => $auth_id5, 'role_id' => $role_id1), array('auth_id' => $auth_id6, 'role_id' => $role_id1)));
 }