Ejemplo n.º 1
0
 function __construct()
 {
     if ($_GET['act'] == 'del') {
         Forum::del();
         $this->redirect('/' . implode('/', Funcs::$uri) . '/');
     }
     if (Funcs::$uri[2] == '') {
         $tree = Tree::getTreeByUrl('wide', array('help', 'forum'));
         Funcs::setMeta($tree);
         $tree['list'] = Forum::getForum();
         View::render('forum/forum', $tree);
     } elseif (Funcs::$uri[3] == '') {
         if ($_POST) {
             $error = Forum::add();
             if ($error) {
                 $tree = Forum::getItems();
                 Funcs::setMeta($tree);
                 View::render('forum/items', $tree);
             } else {
                 $this->redirect('/' . Funcs::$uri[0] . '/' . Funcs::$uri[1] . '/' . Funcs::$uri[2] . '/');
             }
         } else {
             $tree = Forum::getItems();
             Funcs::setMeta($tree);
             View::render('forum/items', $tree);
         }
     } else {
         if ($_POST) {
             $error = Forum::add();
             if ($error) {
                 $tree = Forum::getList();
                 Funcs::setMeta($tree);
                 View::render('forum/list', $tree);
             } else {
                 $this->redirect('/' . Funcs::$uri[0] . '/' . Funcs::$uri[1] . '/' . Funcs::$uri[2] . '/' . Funcs::$uri[3] . '/');
             }
         } else {
             $tree = Forum::getList();
             Funcs::setMeta($tree);
             View::render('forum/list', $tree);
         }
     }
 }
Ejemplo n.º 2
0
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($array);
     }
     break;
     /* Forum */
 /* Forum */
 case validateRoute('GET', 'forums'):
     $forum = new Forum($db, $user);
     $user->updateLastForumAccess();
     httpResponse($forum->getForums());
     break;
 case validateRoute('GET', 'forums/\\d+'):
     $forum = new Forum($db, $user);
     $user->updateLastForumAccess();
     httpResponse($forum->getForum($params[1]));
     break;
 case validateRoute('GET', 'forums/\\d+/topics'):
     $forum = new Forum($db, $user);
     $user->updateLastForumAccess();
     list($result, $totalCount) = $forum->getTopics($params[1], (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'forums/\\d+/topics/\\d+'):
     $forum = new Forum($db, $user);
     $user->updateLastForumAccess();
     httpResponse($forum->getTopic($params[3]));
     break;
 case validateRoute('DELETE', 'forums/\\d+/topics/\\d+'):
     $forum = new Forum($db, $user);
     $user->updateLastForumAccess();
Ejemplo n.º 3
0
 public function Execute(Template $template, Session $session, $request)
 {
     $dba = DBA::Open();
     /* Create the ancestors bar (if we run into any trouble */
     $template = CreateAncestors($template, $template['L_EDITPOST']);
     /* Set the user's permissions */
     $user_perms = isset($session['user']['perms']) ? $session['user']['perms'] : ALL;
     if ($session['user'] instanceof Member) {
         $id = intval(@$request['id']);
         if (isset($request['id']) && $id != 0) {
             try {
                 @($post = $dba->GetRow("SELECT * FROM " . POSTS . " WHERE id = {$id}"));
             } catch (DBA_Exception $e) {
                 return new TplException($e, $template);
             }
             if (is_array($post) && !empty($post)) {
                 /* Try and get the forum */
                 try {
                     @($f = new Forum());
                     @($forum = $f->getForum($post['forum_id']));
                 } catch (DBA_Exception $e) {
                     return new TplException($e, $template);
                 }
                 if ($user_perms >= $forum['can_edit'] && ($session['user']['id'] == $post['poster_id'] || $user_perms & ADMIN)) {
                     /* Set the post icons and the emoticons */
                     $template->posticons = DBA::Open()->Query("SELECT * FROM " . POSTICONS);
                     $template->emoticons = DBA::Open()->Query("SELECT * FROM " . EMOTICONS);
                     /* Hide the part of this template that has to do with replying */
                     $template->post_thread = array('hide' => TRUE);
                     /* Set the template */
                     $template->content = array('file' => 'newthread.html');
                     $parser = new BBParser($post['body_text']);
                     $template['message'] = $parser->Revert($post['body_text']);
                     $template['posttitle'] = $post['name'];
                     /* Remove all of the extra features */
                     $template->poll_options = array('hide' => TRUE);
                     $template->post_options = array('hide' => TRUE);
                     $template->can_attach = array('hide' => TRUE);
                     /* Set the thread action */
                     $template['a_add_thread'] = new Action('posting.php', 'update_post');
                     /* Set the post id */
                     $template['post_id'] = $post['id'];
                 } else {
                     return new Error($template['L_PERMSEDITPOST'], $template);
                 }
             } else {
                 return new Error($template['L_INVALIDPOSTID'], $template);
             }
         } else {
             return new Error($template['L_INVALIDPOSTID'], $template);
         }
     } else {
         return new Error($template['L_NEEDLOGGEDIN'], $template);
     }
     /* Set the number of queries */
     $template['num_queries'] = $session->dba->num_queries;
     return TRUE;
 }
Ejemplo n.º 4
0
 public function Execute(Template $template, Session $session, $request)
 {
     if (isset($request['id'])) {
         /* Instanciate the forum class */
         $forum = new Forum();
         $id = intval($request['id']);
         $suspend = $session['user']['perms'] & ADMIN ? 1 : 0;
         $row = $forum->getForum($id);
         /* Simple redirect to index.php */
         if ($row['row_left'] == 1) {
             exit(header("Location: index.php"));
         }
         /* Check if the Category or forum exists */
         if (!$row) {
             return new Error($template['L_FORUMDOESNTEXIST'], $template);
         }
         /* Create the ancestors list with the results from the get category query */
         $template = CreateAncestors($template, $row, $suspend);
         /* Are we looking at forums within a category? */
         if ($row['row_level'] == 1) {
             $template->welcome_msg = array('hide' => TRUE);
             $template->content = array('file' => 'forums.html');
             $template->categories = new ForumList($id, $suspend);
         } else {
             if ($row['row_level'] >= 2) {
                 /* Make sure that the forum isn't a link */
                 if ($row['is_link'] == 0) {
                     /* Is this forum password-protected? */
                     if ($row['private'] == 1 && @$_SESSION['forum_logged'] != $row['id']) {
                         $template['forum_id'] = $row['id'];
                         $template->content = array('file' => 'forum_login.html');
                     } else {
                         /* Get the user permissions */
                         $user_perms = isset($session['user']['perms']) ? $session['user']['perms'] : ALL;
                         /* If the current user is allowed to read the forums */
                         if ($user_perms >= $row['can_view']) {
                             if ($row['subforums'] > 0) {
                                 $template->subforums = new SubForumList($row, FALSE, $suspend);
                             } else {
                                 $template->sub_forums = array('hide' => TRUE);
                             }
                             /* Set the template */
                             $template->content = array('file' => 'forum.html');
                             if (isset($request['sort']) && isset($request['order'])) {
                                 $template[$request['sort'] . '_sort'] = $request['order'] == 'ASC' ? '&nbsp;<img src="Images/' . $template['imageset'] . '/Icons/arrow_up.gif" alt="" border="0" />' : '&nbsp;<img src="Images/' . $template['imageset'] . '/Icons/arrow_down.gif" alt="" border="0" />';
                             }
                             if (!isset($request['order'])) {
                                 $template['order'] = 'DESC';
                             } else {
                                 $template['order'] = $request['order'] == 'DESC' ? 'ASC' : 'DESC';
                             }
                             /* This could return an instance of the SetError class, so we'll check that */
                             $threads = new ThreadIterator($session);
                             /* Check if there was an error */
                             if ($threads instanceof SetError) {
                                 return new Error($threads->message, $template);
                             } else {
                                 $template->threads = $threads;
                             }
                             $template['total_posts'] = $row['threads'];
                             $template['forum_id'] = $row['id'];
                             $template['postlimit'] = $row['threadsperpage'];
                             $template['pag_start'] = isset($request['start']) ? intval(@$request['start']) : 0;
                         } else {
                             return new Error($template['L_PERMCANTVIEW'], $template);
                         }
                     }
                 } else {
                     DBA::Open()->Execute("UPDATE " . FORUMS . " SET referals = referals+1 WHERE id = " . $row['id']);
                     header("Location: " . $row['link_href']);
                 }
             } else {
                 return new Error($template['L_ERRORVIEWFORUM'], $template);
             }
         }
     } else {
         return new Error($template['L_INVALIDFORUM'], $template);
     }
     /* Set the number of queries */
     $template['num_queries'] = $session->dba->num_queries;
     return TRUE;
 }
Ejemplo n.º 5
0
 public function Execute(Template $template, Session $session, $request)
 {
     /* Create the ancestors bar (if we run into any trouble */
     $template = CreateAncestors($template, $template['L_POSTREPLY']);
     /* Open a connection to the database */
     $this->dba = DBA::Open();
     /* Set the a variable to this user's permissions and id */
     $user_perms = isset($session['user']['perms']) ? $session['user']['perms'] : ALL;
     $user_id = $session['user']['id'];
     /* Get our parent forum */
     try {
         @($post = $this->dba->GetRow("SELECT * FROM " . POSTS . " WHERE id = " . intval($request['post_id'])));
         @($thread = $this->dba->GetRow("SELECT * FROM " . POSTS . " WHERE row_left <= " . $post['row_left'] . " AND row_right >= " . $post['row_right']));
     } catch (DBA_Exception $e) {
         return new TplException($e, $template);
     }
     /* Parse the Message */
     $request['message'] = BB::Open($request['message'])->Execute();
     /* Quote all of the REQUEST variables */
     foreach ($request as $key => $val) {
         $request[$key] = $this->dba->Quote($val);
     }
     /* Set the post icon */
     if (isset($request['posticon']) && intval($request['posticon']) != 0 && $request['posticon'] != '-1') {
         try {
             $posticon = $this->dba->GetValue("SELECT image FROM " . POSTICONS . " WHERE id = " . intval($request['posticon']));
         } catch (DBA_Exception $e) {
             return new TplException($e, $template);
         }
     } else {
         $posticon = 'clear.gif';
     }
     if (is_array($post) && !empty($post)) {
         /* Try and get the forum */
         try {
             @($f = new Forum());
             @($forum = $f->getForum($post['forum_id']));
         } catch (DBA_Exception $e) {
             return new TplException($e, $template);
         }
         if ($user_perms >= $forum['can_edit'] && ($session['user']['id'] == $post['poster_id'] || $user_perms & ADMIN)) {
             try {
                 @$this->dba->Query("UPDATE " . POSTS . " SET name = '" . $request['title'] . "', body_text = '" . $request['message'] . "', icon = '" . $posticon . "', edited = " . time() . " WHERE id = " . $post['id']);
             } catch (DBA_Exception $e) {
                 return new TplException($e, $template);
             }
             /* If we've gotten to this point, reload the page to our recently added thread :) */
             return new Error($template['L_UPDATEDPOST'] . '<meta http-equiv="refresh" content="1; url=viewthread.php?id=' . $thread['id'] . '">', $template);
         } else {
             return new Error($template['L_PERMSEDITPOST'], $template);
         }
     } else {
         return new Error($template['L_INVALIDPOSTID'], $template);
     }
 }