Beispiel #1
0
 public function ajax_session()
 {
     $this->cache(false);
     $static = Configure::read('site.static');
     $base = Configure::read('site.prefix');
     $user = User::getInstance();
     App::import('vendor', 'inc/wrapper');
     $wrapper = Wrapper::getInstance();
     $ret = $wrapper->user($user);
     $ret['is_login'] = $user->userid != 'guest';
     $ret['forum_totol_count'] = Forum::getOnlineNum();
     $ret['forum_user_count'] = Forum::getOnlineUserNum();
     $ret['forum_guest_count'] = Forum::getOnlineGuestNum();
     App::import("vendor", "model/mail");
     $info = MailBox::getInfo($user);
     $ret['new_mail'] = $info['newmail'];
     $ret['full_mail'] = $info['full'];
     if (Configure::read('refer.enable')) {
         App::import('vendor', 'model/refer');
         $ret['new_at'] = $ret['new_reply'] = false;
         try {
             if ($user->getCustom('userdefine1', 2)) {
                 $refer = new Refer($user, Refer::$AT);
                 $ret['new_at'] = $refer->getNewNum();
             }
             if ($user->getCustom('userdefine1', 3)) {
                 $refer = new Refer($user, Refer::$REPLY);
                 $ret['new_reply'] = $refer->getNewNum();
             }
         } catch (ReferNullException $e) {
         }
     }
     $this->set('no_html_data', $ret);
 }
Beispiel #2
0
    /**
     * @override method
     */
    public function beforeRender()
    {
        if (!$this->html) {
            //there is three ajax_st status
            //1:success
            //0:fail
            $data = $this->get('no_html_data');
            if (null === $data) {
                $data = array();
            }
            //use no_ajax_info param to ignore ajax info,
            //sometimes data may be a array
            if (!isset($data['ajax_st']) && null === $this->get('no_ajax_info')) {
                $data['ajax_st'] = 1;
                $data['ajax_code'] = isset($data['ajax_code']) ? $data['ajax_code'] : ECode::$SYS_AJAXOK;
                $data['ajax_msg'] = ECode::msg($data['ajax_code']);
                //code may be a string,check msg == code to set default code
                if ($data['ajax_msg'] == strval($data['ajax_code'])) {
                    $data['ajax_code'] = ECode::$SYS_AJAXOK;
                }
                $this->set('no_html_data', $data);
            }
            return;
        }
        $site = Configure::read("site");
        try {
            $u = User::getInstance();
            $uid = $u->userid;
            $admin = $u->isAdmin();
            $reg = $u->isReg();
        } catch (UserNullException $e) {
            $uid = 'guest';
            $admin = false;
            $reg = false;
        }
        //handle js & css
        $this->_initAsset();
        //add pack js&css
        $asset_pack = nforum_cache_read('asset_pack');
        if (is_array($asset_pack) && ($this->front || $this->spider)) {
            $this->set('js', array_merge(array('js/' . $asset_pack['js']), $this->get('js')));
            $this->set('css', array_merge(array('css/' . $asset_pack['css']), $this->get('css')));
        }
        //handle title
        $title = $site['name'];
        if (!empty($this->title)) {
            $title = $this->title;
        } else {
            if (isset($this->notice[0]) && $this->path != $site['home']) {
                $title .= "-" . $this->notice[0]["text"];
            } else {
                $title .= "-" . $site['desc'];
            }
        }
        //handle notice
        if ($this->path != $site['home']) {
            $this->notice = array_merge(array(array("url" => $site['home'], "text" => $site['name'])), $this->notice);
        }
        /* handle jsr start*/
        if (!$this->spider) {
            if ($this->front) {
                $site = Configure::read("site");
                $cookie = Configure::read("cookie");
                $jsr = Configure::read("jsr");
                $jsr['iframe'] = $jsr['iframe'] ? 'true' : 'false';
                $jsr['domain'] = preg_replace('/^https?:\\/\\//', '', $site['domain']);
                $jsr['cookie_domain'] = $cookie['domain'];
                $jsr['base'] = $this->base;
                $jsr['prefix'] = $cookie['prefix'];
                $jsr['home'] = $site['home'];
                $jsr['static'] = $site['static'];
                $jsr['protocol'] = $site['ssl'] ? 'https://' : 'http://';
                App::import("vendor", "inc/json");
                $jsr = 'var sys_merge=' . BYRJSON::encode($jsr);
                $this->jsr = array_merge(array($jsr), $this->jsr);
                $syn = Configure::read('ubb.syntax');
                if (Configure::read('ubb.parse') && !empty($syn)) {
                    $this->set('js', array_merge($this->get('js'), array($syn . '/scripts/shCore.js', $syn . '/scripts/shAutoloader.js')));
                }
            } else {
                $tmp = array();
                foreach ($this->notice as $v) {
                    $tmp[] = '<a href="' . (empty($v['url']) ? 'javascript:void(0)' : $this->base . $v['url']) . '">' . $v['text'] . '</a>';
                }
                $tmp = join('&ensp;>>&ensp;', $tmp);
                $this->jsr[] = <<<EOT
\$('#notice_nav').html('{$tmp}');\$.setTitle('{$title}');
EOT;
                $syn = Configure::read('ubb.syntax');
                if (Configure::read('ubb.parse') && !empty($syn) && $this->get('hasSyn') !== false) {
                    $this->set('syntax', $syn);
                }
            }
        }
        /* handle jsr end*/
        //basic variables
        $arr = array('base' => $this->base, 'islogin' => $this->ByrSession->isLogin, 'id' => $uid, 'isAdmin' => $admin, 'isReg' => $reg, 'notice' => $this->notice, 'webTitle' => $title, 'webTotal' => Forum::getOnlineNum(), 'webUser' => Forum::getOnlineUserNum(), 'webGuest' => Forum::getOnlineGuestNum(), 'encoding' => $this->encoding, 'domain' => $site['domain'], 'static' => $site['static'], 'siteName' => $site['name'], 'keywords' => $site['keywords'], 'description' => $site['description'], 'home' => $site['home'], 'preindex' => $site['preIndex'], 'front' => $this->front, 'spider' => $this->spider, 'jsr' => $this->jsr);
        $this->set($arr);
    }
Beispiel #3
0
 public function __construct()
 {
     $this->_num = Forum::getOnlineUserNum();
 }