Exemplo n.º 1
0
 public function query()
 {
     $this->notice = "用户查询";
     App::import('Sanitize');
     @($id = trim($this->params['pass'][0]));
     try {
         $u = User::getInstance($id);
     } catch (UserNullException $e) {
         $this->set("noid", true);
         return;
     }
     App::import("vendor", "inc/astro");
     $astro = Astro::getAstro($u->birthmonth, $u->birthday);
     $info = array("uid" => $u->userid, "name" => Sanitize::html($u->username), "gender" => $u->gender == 77 ? "男" : "女", "astro" => $astro['name'], "qq" => $u->OICQ == "" ? "未知" : $u->OICQ, "msn" => $u->MSN == "" ? "未知" : $u->MSN, "homepage" => $u->homepage == "" ? "未知" : $u->homepage, "level" => $u->getLevel(), "postNum" => $u->numposts, "loginNum" => $u->numlogins, "lastTime" => date("Y-m-d H:i:s", $u->lastlogin), "lastIP" => $u->lasthost, "life" => $u->getLife(), "first" => date("Y-m-d", $u->firstlogin), "status" => $u->getStatus());
     $this->set($info);
     $this->set("hide", $u->getCustom("userdefine0", 29) == 0);
     $this->set("me", $u->userid == User::getInstance()->userid);
 }
Exemplo n.º 2
0
 public function user($user)
 {
     $static = Configure::read('site.static');
     $base = Configure::read('site.prefix');
     $u = User::getInstance();
     $hide = $user->getCustom('userdefine0', 29) == 0;
     $super = $u->userid == $user->userid || $u->isAdmin();
     $ret = array();
     $ret['id'] = $user->userid;
     $ret['user_name'] = $user->username;
     $ret['face_url'] = $static . $base . $user->getFace();
     $ret['face_width'] = $user->userface_width;
     $ret['face_height'] = $user->userface_height;
     if ($hide && !$super) {
         $ret['gender'] = 'n';
         $ret['astro'] = '';
     } else {
         App::import("vendor", "inc/astro");
         $astro = Astro::getAstro($user->birthmonth, $user->birthday);
         $ret['gender'] = $user->gender == 77 ? 'm' : 'f';
         $ret['astro'] = $astro['name'] == '' ? '' : $astro['name'];
     }
     $ret['life'] = $user->getLife();
     $ret['qq'] = $user->OICQ;
     $ret['msn'] = $user->MSN;
     $ret['home_page'] = $user->homepage;
     $ret['level'] = $user->getLevel();
     //whether online or not for all user may be the user hide
     $ret['is_online'] = $user->isOnline();
     $ret['post_count'] = $user->numposts;
     $ret['last_login_time'] = $user->lastlogin;
     $ret['last_login_ip'] = $user->lasthost;
     $ret['is_hide'] = $hide;
     $ret['is_register'] = $user->isReg();
     if ($super) {
         $ret['is_admin'] = $user->isAdmin();
         $ret['first_login_time'] = $user->firstlogin;
         $ret['login_count'] = $user->numlogins;
         $ret['stay_count'] = $user->stay;
     }
     return $ret;
 }
Exemplo n.º 3
0
 public function index()
 {
     $this->cache(false);
     $this->css[] = "article.css";
     $this->js[] = "forum.share.js";
     $this->js[] = "forum.article.js";
     $this->_getNotice();
     $this->notice[] = array("url" => "", "text" => "阅读文章");
     App::import('Sanitize');
     App::import('vendor', array("inc/pagination", "inc/astro"));
     if (!isset($this->params['gid']) || $this->params['gid'] == '0') {
         $this->error(ECode::$ARTICLE_NONE);
     }
     try {
         $gid = $this->params['gid'];
         $this->_threads = Threads::getInstance($gid, $this->_board);
     } catch (ThreadsNullException $e) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     //article jump
     if (isset($this->params['url']['s'])) {
         $article = $this->_threads->getArticleById(intval($this->params['url']['s']));
         if (null !== $article) {
             $pos = $article->getPos();
             $page = ceil(($pos + 1) / Configure::read("pagination.article"));
             $this->redirect("/article/{$this->_board->NAME}/{$gid}?p={$page}#a{$pos}");
         }
         $this->redirect("/article/{$this->_board->NAME}/{$gid}");
     }
     //filter author
     $auF = $au = false;
     if (isset($this->params['url']['au'])) {
         $tmp = $this->_threads->getRecord(1, $this->_threads->getTotalNum());
         $auF = array();
         $au = trim($this->params['url']['au']);
         foreach ($tmp as $v) {
             if ($v->OWNER == $au) {
                 $auF[] = $v;
             }
         }
         $auF = new ArrayPageableAdapter($auF);
     }
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     $pagination = new Pagination(false !== $au ? $auF : $this->_threads, Configure::read("pagination.article"));
     $articles = $pagination->getPage($p);
     $u = User::getInstance();
     if ($bm = $u->isBM($this->_board) || $u->isAdmin()) {
         $this->js[] = "forum.manage.js";
     }
     $info = array();
     $curTime = strtotime(date("Y-m-d", time()));
     $isUbb = Configure::read("ubb.parse");
     $isSyn = Configure::read("ubb.syntax");
     $hasSyn = false;
     foreach ($articles as $v) {
         try {
             $own = User::getInstance($v->OWNER);
             $astro = Astro::getAstro($own->birthmonth, $own->birthday);
             if ($own->getCustom("userdefine0", 29) == 0) {
                 $hide = true;
                 $gender = -1;
             } else {
                 $hide = false;
                 $gender = $own->gender == "77" ? 0 : 1;
             }
             $user = array("id" => $own->userid, "name" => Sanitize::html($own->username), "gender" => $gender, "furl" => Sanitize::html($own->getFace()), "width" => $own->userface_width === 0 ? "" : $own->userface_width, "height" => $own->userface_height === 0 ? "" : $own->userface_height, "post" => $own->numposts, "astro" => $astro['name'], "online" => $own->isOnline(), "level" => $own->getLevel(), "time" => date($curTime > $own->lastlogin ? "Y-m-d" : "H:i:s", $own->lastlogin), "first" => date("Y-m-d", $own->firstlogin), "hide" => $hide);
         } catch (UserNullException $e) {
             $user = false;
         }
         $content = $v->getHtml(true);
         //hard to match all the format of ip
         //$pattern = '/<font class="f[0-9]+">※( |&nbsp;)来源:·.+?\[FROM:( |&nbsp;)[0-9a-zA-Z.:*]+\]<\/font><font class="f000">( +<br \/>)+ +<\/font>/';
         //preg_match($pattern, $content, $match);
         //$content = preg_replace($pattern, "", $content);
         if ($isUbb) {
             //remove ubb of nickname in first and title second line
             preg_match("'^(.*?<br \\/>.*?<br \\/>)'", $content, $res);
             $content = preg_replace("'(^.*?<br \\/>.*?<br \\/>)'", '', $content);
             $content = XUBB::remove($res[1]) . $content;
             $content = XUBB::parse($content);
             //check syntax
             if (!empty($isSyn) && preg_match("/<pre class=\"brush:/", $content)) {
                 $hasSyn = true;
             }
             //parse vote
             if ($v->OWNER === 'deliver' && in_array('vote', Configure::read('plugins.install'))) {
                 $vid = array();
                 if (preg_match("'\\[vote=(\\d+)\\]\\[/vote\\]'", $content, $vid)) {
                     $content = preg_replace("'\\[vote=\\d+\\]\\[/vote\\]'", '', $content);
                     App::import("vendor", array("inc/db", "vote.vote"));
                     $vid = $vid[1];
                     try {
                         $vote = new Vote($vid);
                         if (!$vote->isDeleted()) {
                             $this->css['plugin']['vote'][] = "vote.css";
                             $this->js['plugin']['vote'][] = "vote.js";
                             $myres = $vote->getResult($u->userid);
                             $voted = false;
                             if ($myres !== false) {
                                 $voted = true;
                                 $myres['time'] = date("Y-m-d H:i:s", $myres['time']);
                                 $this->set("myres", $myres);
                             }
                             $vinfo = array("vid" => $vote->vid, "title" => Sanitize::html($vote->subject), "desc" => nl2br(Sanitize::html($vote->desc)), "start" => date("Y-m-d H:i:s", $vote->start), "end" => date("Y-m-d", $vote->end), "num" => $vote->num, "type" => $vote->type, "limit" => $vote->limit, "aid" => $vote->aid, "isEnd" => $vote->isEnd(), "isDel" => $vote->isDeleted(), "voted" => $voted, "uid" => $vote->uid);
                             $item = $vote->items;
                             foreach ($item as $kk => $vv) {
                                 $item[$kk]["label"] = Sanitize::html($vv["label"]);
                                 $item[$kk]["percent"] = $vote->total === 0 ? 0 : round(intval($vv['num']) * 100 / $vote->total);
                                 $item[$kk]["on"] = $myres !== false && in_array($vv['viid'], $myres['items']);
                             }
                             $this->set("vinfo", $vinfo);
                             $this->set("vitems", $item);
                             $this->set("result_voted", $vote->result_voted);
                             $this->set("no_result", !($u->userid === $vote->uid || $u->isAdmin()) && $vote->result_voted && !$voted);
                         }
                     } catch (VoteNullException $e) {
                     }
                 }
             }
         }
         $info[] = array("id" => $v->ID, "owner" => $user, "op" => $v->OWNER == $u->userid || $bm ? 1 : 0, "pos" => $v->getPos(), "poster" => $v->OWNER, "content" => $content, "subject" => $v->isSubject(), 'g' => $v->isG(), 'm' => $v->isM(), 'l' => $v->isNoRe(), 'p' => $v->isPercent(), 's' => $v->isSharp(), 'x' => $v->isX());
     }
     $this->title = Sanitize::html($this->_threads->TITLE);
     $link = "{$this->base}/article/{$this->_board->NAME}/{$gid}?p=%page%";
     if (false !== $auF) {
         $link .= "&au={$au}";
     }
     $this->set("pageBar", $pagination->getPageBar($p, $link));
     $this->set("pagination", $pagination);
     $this->set("bName", $this->_board->NAME);
     $this->set("gid", $gid);
     $this->set("anony", $this->_board->isAnony());
     $this->set("tmpl", $this->_board->isTmplPost());
     $this->set("info", $info);
     $this->set("title", $this->title);
     $this->set('hasSyn', $hasSyn);
     $this->set("au", $au);
     $this->set("bm", $bm);
     //for the quick reply, raw encode the space
     $this->set("reid", $this->_threads->ID);
     if (!strncmp($this->_threads->TITLE, "Re: ", 4)) {
         $reTitle = $this->_threads->TITLE;
     } else {
         $reTitle = "Re: " . $this->_threads->TITLE;
     }
     //hack for post with ajax,need utf-8 encoding
     $reTitle = nforum_iconv($this->encoding, 'utf-8', $reTitle);
     $this->set("reTitle", rawurlencode($reTitle));
     //for default search day
     $this->set("searchDay", Configure::read("search.day"));
     $this->set("searchDay", Configure::read("search.day"));
     $this->jsr[] = "window.user_post=" . ($this->_board->hasPostPerm($u) && !$this->_board->isDeny($u) ? "true" : "false") . ";";
 }