예제 #1
0
 public function __construct()
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (!$oUser->isLogged()) {
         $this->_sLayout = 'login.php';
     }
 }
예제 #2
0
파일: home.class.php 프로젝트: s1im05/vvv
 public function indexAction()
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (!$oUser->isLogged()) {
         $this->request->go('/');
     }
     if (isset($_POST['save'])) {
         $this->_save();
         $this->view->assign('aUser', $oUser->data);
     }
     $this->view->assign('sMenuActive', 'home');
 }
예제 #3
0
 public function getLikeAction($iPage)
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (!$oUser->isLogged()) {
         return;
     }
     $iLimit = (int) $this->config->project->postsppage;
     $aLikes = $this->db->selectPage($iCnt, "SELECT\n                                                    p.*,\n                                                    c.title AS chapter_title,\n                                                    c.class AS chapter_name,\n                                                    pl.cdate AS like_date,\n                                                    true AS like_state\n                                                FROM\n                                                    ?_posts p,\n                                                    ?_chapters c,\n                                                    ?_posts__likes pl\n                                                WHERE\n                                                    p.id        = pl.post_id AND\n                                                    c.id        = p.chapter_id AND\n                                                    pl.user_id  = ?d AND\n                                                    pl.state    = 1\n                                                ORDER BY\n                                                    pl.cdate DESC\n                                                LIMIT ?d, ?d", $oUser->id, $iPage * $iLimit, $iLimit);
     $this->setLayout('ajax_template.php');
     $this->setTemplate('home_list_likes.php');
     $this->view->assign('aPostList', $aLikes);
     $this->view->assign('iPage', $iPage);
     $this->view->assign('bAllLoaded', ($iPage + 1) * $iLimit >= $iCnt);
     $this->view->assign('sViewType', isset($_COOKIE['vt']) ? $_COOKIE['vt'] == 'list' ? 'list' : 'thumb' : 'thumb');
 }
예제 #4
0
 private function _statusChange($iPostId, $bLike)
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (!$oUser->isLogged()) {
         $this->request->go404();
     }
     if (!($aPost = $this->db->selectRow("SELECT * FROM ?_posts WHERE id = ?d LIMIT 1;", $iPostId))) {
         $this->request->go404();
     }
     if ($aRow = $this->db->selectRow("SELECT * FROM ?_posts__likes WHERE post_id = ?d AND user_id = ?d AND state != ?d LIMIT 1;", $iPostId, $oUser->id, $bLike ? 1 : 0)) {
         $this->db->query("UPDATE LOW_PRIORITY ?_posts__likes SET state = ?d, cdate = NOW() WHERE post_id = ?d AND user_id = ?d LIMIT 1;", $bLike ? 1 : 0, $iPostId, $oUser->id);
     } elseif ($bLike) {
         $this->db->query("INSERT INTO ?_posts__likes SET state = 1, cdate = NOW(), post_id = ?d, user_id = ?d;", $iPostId, $oUser->id);
     }
     $iLikes = (int) $this->db->selectCell("SELECT SUM(state) FROM ?_posts__likes WHERE post_id = ?d GROUP BY post_id", $iPostId);
     $this->db->query("UPDATE LOW_PRIORITY \n                                ?_posts \n                            SET \n                                likes = ?d\n                            WHERE \n                                id = ?d \n                            LIMIT 1;", $iLikes, $iPostId);
     $this->setLayout('ajax.php');
     $this->view->assign('sRequest', $iLikes);
 }
예제 #5
0
 private function doLogin()
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (isset($_POST['token'])) {
         $oUser->loginLoginza($_POST['token']);
     } elseif (!$oUser->isLogged()) {
         $oUser->loginCookie();
     }
     if ($this->request->getPath() === '/logout') {
         $oUser->logout();
     }
     return $oUser;
 }
예제 #6
0
 public function run()
 {
     $oUser = new \SSCE\Models\User($this->options);
     if (isset($_POST['token'])) {
         $oUser->loginLoginza($_POST['token']);
     } elseif (!$oUser->isLogged()) {
         $oUser->loginCookie();
     }
     if ($this->request->getPath() === '/logout') {
         $oUser->logout();
     }
     $this->view->assign('bIsLogged', $oUser->isLogged());
 }