Пример #1
0
 /**
  * Get Blog Category Hierarchy Index
  * @return array
  */
 public static function get_blogCatsIndex()
 {
     return dbquery_tree(DB_BLOG_CATS, 'blog_cat_id', 'blog_cat_parent');
 }
Пример #2
0
 /**
  * Get Download Category Hierarchy Index
  * @return array
  */
 public static function get_downloadCatsIndex()
 {
     return dbquery_tree(DB_DOWNLOAD_CATS, 'download_cat_id', 'download_cat_parent', "" . (multilang_table("BL") ? "WHERE download_cat_language='" . LANGUAGE . "'" : '') . "");
 }
Пример #3
0
 /**
  * Executes forum
  */
 public function set_ForumInfo()
 {
     $forum_settings = $this->get_forum_settings();
     $userdata = fusion_get_userdata();
     $locale = fusion_get_locale("", FORUM_LOCALE);
     $_GET['forum_id'] = isset($_GET['forum_id']) && verify_forum($_GET['forum_id']) ? intval($_GET['forum_id']) : 0;
     // security boot due to insufficient access level
     if (isset($_GET['viewforum']) && empty($_GET['forum_id'])) {
         redirect(INFUSIONS . 'forum/index.php');
     }
     if (stristr($_SERVER['PHP_SELF'], 'forum_id')) {
         if ($_GET['section'] == 'latest') {
             redirect(INFUSIONS . 'forum/index.php?section=latest');
         }
         if ($_GET['section'] == 'mypost') {
             redirect(INFUSIONS . 'forum/index.php?section=mypost');
         }
         if ($_GET['section'] == 'tracked') {
             redirect(INFUSIONS . 'forum/index.php?section=tracked');
         }
     }
     // Xss sanitization
     $this->forum_info = array('forum_id' => isset($_GET['forum_id']) ? $_GET['forum_id'] : 0, 'parent_id' => isset($_GET['parent_id']) && verify_forum($_GET['parent_id']) ? $_GET['parent_id'] : 0, 'forum_branch' => isset($_GET['forum_branch']) && verify_forum($_GET['forum_branch']) ? $_GET['forum_branch'] : 0, 'new_thread_link' => '', 'lastvisited' => isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time(), 'posts_per_page' => $forum_settings['posts_per_page'], 'threads_per_page' => $forum_settings['threads_per_page'], 'forum_index' => dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), 'threads' => array(), 'section' => isset($_GET['section']) ? $_GET['section'] : 'thread');
     // Set Max Rows -- XSS
     $this->forum_info['forum_max_rows'] = dbcount("('forum_id')", DB_FORUMS, (multilang_table("FO") ? "forum_language='" . LANGUAGE . "' AND" : '') . "\n\t\tforum_cat='" . $this->forum_info['parent_id'] . "' AND " . groupaccess('forum_access') . "");
     // Sanitize Globals
     $_GET['rowstart'] = isset($_GET['rowstart']) && $_GET['rowstart'] <= $this->forum_info['forum_max_rows'] ? $_GET['rowstart'] : 0;
     $this->ext = isset($this->forum_info['parent_id']) && isnum($this->forum_info['parent_id']) ? "&amp;parent_id=" . $this->forum_info['parent_id'] : '';
     add_to_title($locale['global_200'] . $locale['forum_0000']);
     add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php', 'title' => $locale['forum_0000']));
     $this->forum_breadcrumbs($this->forum_info['forum_index']);
     // Set Meta data
     if ($this->forum_info['forum_id'] > 0) {
         $meta_sql = "SELECT forum_meta, forum_description FROM " . DB_FORUMS . "\n            WHERE forum_id='" . intval($this->forum_info['forum_id']) . "'";
         $meta_result = dbquery($meta_sql);
         if (dbrows($meta_result) > 0) {
             $meta_data = dbarray($meta_result);
             if (!empty($meta_data['forum_description'])) {
                 set_meta('description', $meta_data['forum_description']);
             }
             if (!empty($meta_data['forum_meta'])) {
                 set_meta('keywords', $meta_data['forum_meta']);
             }
         }
     }
     // Additional Sections in Index View
     if (isset($_GET['section'])) {
         switch ($_GET['section']) {
             case 'participated':
                 include FORUM_SECTIONS . "participated.php";
                 add_to_title($locale['global_201'] . $locale['global_024']);
                 add_breadcrumb(array('link' => FORUM . "index.php?section=participated", 'title' => $locale['global_024']));
                 set_meta("description", $locale['global_024']);
                 break;
             case 'latest':
                 include FORUM_SECTIONS . "latest.php";
                 add_to_title($locale['global_201'] . $locale['global_021']);
                 add_breadcrumb(array('link' => FORUM . "index.php?section=latest", 'title' => $locale['global_021']));
                 set_meta("description", $locale['global_021']);
                 break;
             case 'tracked':
                 include FORUM_SECTIONS . "tracked.php";
                 add_to_title($locale['global_201'] . $locale['global_056']);
                 add_breadcrumb(array('link' => FORUM . "index.php?section=tracked", 'title' => $locale['global_056']));
                 set_meta("description", $locale['global_056']);
                 break;
             case "unanswered":
                 include FORUM_SECTIONS . "unanswered.php";
                 add_to_title($locale['global_201'] . $locale['global_027']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=unanswered", 'title' => $locale['global_027']));
                 set_meta("description", $locale['global_027']);
                 break;
             case "unsolved":
                 include FORUM_SECTIONS . "unsolved.php";
                 add_to_title($locale['global_201'] . $locale['global_028']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=unsolved", 'title' => $locale['global_028']));
                 set_meta("description", $locale['global_028']);
                 break;
             default:
                 redirect(FORUM);
         }
     } else {
         // Viewforum view
         if (!empty($this->forum_info['forum_id']) && isset($this->forum_info['parent_id']) && isset($_GET['viewforum'])) {
             // @todo: turn this into ajax filtration to cut down SEO design pattern
             $this->forum_info['filter'] = $this->filter()->get_FilterInfo();
             // Forum SQL
             $forum_sql = "\n                SELECT f.*,\n                f2.forum_name 'forum_cat_name',\n\t\t\t\tt.thread_id, t.thread_lastpost, t.thread_lastpostid, t.thread_subject,\n\t\t\t\tp.post_message,\n\t\t\t\tu.user_id, u.user_name, u.user_status, u.user_avatar,\n\t\t\t\tmin(p2.post_datestamp) 'first_post_datestamp'\n\t\t\t\tFROM " . DB_FORUMS . " f\n\t\t\t\t# subforums\n\t\t\t\tLEFT JOIN " . DB_FORUMS . " f2 ON f.forum_cat = f2.forum_id\n\t\t\t\t# thread info\n\t\t\t\tLEFT JOIN " . DB_FORUM_THREADS . " t ON t.forum_id = f.forum_id AND " . groupaccess('f.forum_access') . "\n\t\t\t\t# just last post\n\t\t\t\tLEFT JOIN " . DB_FORUM_POSTS . " p on p.thread_id = t.thread_id and p.post_id = t.thread_lastpostid\n\t\t\t\t# post info\n\t\t\t\tLEFT JOIN " . DB_FORUM_POSTS . " p2 ON p2.thread_id = t.thread_id\n\t\t\t\t# just last post user\n\t\t\t\tLEFT JOIN " . DB_USERS . " u ON f.forum_lastuser=u.user_id\n\t\t\t\t" . (multilang_table("FO") ? "WHERE f.forum_language='" . LANGUAGE . "' AND" : "WHERE") . " " . groupaccess('f.forum_access') . "\n\t\t\t\tAND f.forum_id='" . intval($this->forum_info['forum_id']) . "' OR f.forum_cat='" . intval($this->forum_info['forum_id']) . "'\n\t\t\t\tOR f.forum_branch='" . intval($this->forum_info['forum_branch']) . "'\n\t\t\t\tGROUP BY f.forum_id ORDER BY forum_cat ASC\n                ";
             $result = dbquery($forum_sql);
             $refs = array();
             // define what a row is
             $row_array = array('forum_new_status' => '', 'last_post' => '', 'forum_icon' => '', 'forum_icon_lg' => '', 'forum_moderators' => '', 'forum_link' => array('link' => '', 'title' => ''), 'forum_description' => '', 'forum_postcount_word' => '', 'forum_threadcount_word' => '');
             if (dbrows($result) > 0) {
                 while ($row = dbarray($result) and checkgroup($row['forum_access'])) {
                     // Calculate Forum New Status
                     $newStatus = "";
                     $forum_match = "\\|" . $row['forum_lastpost'] . "\\|" . $row['forum_id'];
                     $last_visited = isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time();
                     if ($row['forum_lastpost'] > $last_visited) {
                         if (iMEMBER && ($row['forum_lastuser'] !== $userdata['user_id'] || !preg_match("({$forum_match}\\.|{$forum_match}\$)", $userdata['user_threads']))) {
                             $newStatus = "<span class='forum-new-icon'><i title='" . $locale['forum_0260'] . "' class='" . self::get_forumIcons('new') . "'></i></span>";
                         }
                     }
                     // Calculate lastpost information
                     $lastPostInfo = array();
                     if (!empty($row['forum_lastpostid'])) {
                         $last_post = array('avatar' => '', 'avatar_src' => $row['user_avatar'] && file_exists(IMAGES . 'avatars/' . $row['user_avatar']) && !is_dir(IMAGES . 'avatars/' . $row['user_avatar']) ? IMAGES . 'avatars/' . $row['user_avatar'] : '', 'message' => fusion_first_words(parseubb(parsesmileys($row['post_message'])), 10), 'profile_link' => profile_link($row['forum_lastuser'], $row['user_name'], $row['user_status']), 'time' => timer($row['forum_lastpost']), 'date' => showdate("forumdate", $row['forum_lastpost']), 'thread_link' => INFUSIONS . "forum/viewthread.php?forum_id=" . $row['forum_id'] . "&amp;thread_id=" . $row['thread_id'], 'post_link' => INFUSIONS . "forum/viewthread.php?forum_id=" . $row['forum_id'] . "&amp;thread_id=" . $row['thread_id'] . "&amp;pid=" . $row['thread_lastpostid'] . "#post_" . $row['thread_lastpostid']);
                         if ($forum_settings['forum_last_post_avatar']) {
                             $last_post['avatar'] = display_avatar($row, '30px', '', '', 'img-rounded');
                         }
                         $lastPostInfo = $last_post;
                     }
                     /**
                      * Default system icons - why do i need this? Why not let themers decide?
                      */
                     switch ($row['forum_type']) {
                         case '1':
                             $forum_icon = "<i class='" . self::get_forumIcons('forum') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . self::get_forumIcons('forum') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '2':
                             $forum_icon = "<i class='" . self::get_forumIcons('thread') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . self::get_forumIcons('thread') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '3':
                             $forum_icon = "<i class='" . self::get_forumIcons('link') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . self::get_forumIcons('link') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '4':
                             $forum_icon = "<i class='" . self::get_forumIcons('question') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . self::get_forumIcons('question') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         default:
                             $forum_icon = "";
                             $forum_icon_lg = "";
                     }
                     $mods = new Moderator();
                     $_row = array_merge($row_array, $row, array("forum_type" => $row['forum_type'], "forum_moderators" => $mods::parse_forum_mods($row['forum_mods']), "forum_new_status" => $newStatus, "forum_link" => array("link" => FORUM . "index.php?viewforum&amp;forum_id=" . $row['forum_id'] . "&amp;parent_id=" . $row['forum_cat'], "title" => $row['forum_name']), "forum_description" => nl2br(parseubb($row['forum_description'])), "forum_postcount_word" => format_word($row['forum_postcount'], $locale['fmt_post']), "forum_threadcount_word" => format_word($row['forum_threadcount'], $locale['fmt_thread']), "last_post" => $lastPostInfo, "forum_icon" => $forum_icon, "forum_icon_lg" => $forum_icon_lg, "forum_image" => $row['forum_image'] && file_exists(FORUM . "images/" . $row['forum_image']) ? $row['forum_image'] : ""));
                     $this->forum_info['forum_moderators'] = $_row['forum_moderators'];
                     // child hierarchy data.
                     $thisref =& $refs[$_row['forum_id']];
                     $thisref = $_row;
                     if ($_row['forum_cat'] == $this->forum_info['parent_id']) {
                         $this->forum_info['item'][$_row['forum_id']] =& $thisref;
                         // will push main item out.
                     } else {
                         $refs[$_row['forum_cat']]['child'][$_row['forum_id']] =& $thisref;
                     }
                     /**
                      * The current forum
                      */
                     if ($row['forum_id'] == $this->forum_info['forum_id']) {
                         require_once INCLUDES . "mimetypes_include.php";
                         $this->forum_info['forum_type'] = $row['forum_type'];
                         $mods::define_forum_mods($row);
                         // do the full string of checks for forums access
                         $this->setForumPermission($row);
                         // Generate New thread link
                         if ($this->getForumPermission("can_post") && $row['forum_type'] > 1) {
                             $this->forum_info['new_thread_link'] = FORUM . "newthread.php?forum_id=" . $row['forum_id'];
                         }
                         // Not a category
                         if ($row['forum_type'] !== '1') {
                             $filter_sql = $this->filter()->get_filterSQL();
                             $thread_info = $this->thread(FALSE)->get_forum_thread($this->forum_info['forum_id'], array('condition' => $filter_sql['condition'], 'order' => $filter_sql['order']));
                             $this->forum_info = array_merge_recursive($this->forum_info, $thread_info);
                         }
                     }
                 }
             } else {
                 redirect(INFUSIONS . 'forum/index.php');
             }
         } else {
             $this->forum_info['forums'] = self::get_forum();
             //Index view
         }
     }
 }
Пример #4
0
 public function set_ForumInfo()
 {
     global $forum_settings, $userdata, $locale;
     if (stristr($_SERVER['PHP_SELF'], 'forum_id')) {
         if ($_GET['section'] == 'latest') {
             redirect(INFUSIONS . 'forum/index.php?section=latest');
         }
         if ($_GET['section'] == 'mypost') {
             redirect(INFUSIONS . 'forum/index.php?section=mypost');
         }
         if ($_GET['section'] == 'tracked') {
             redirect(INFUSIONS . 'forum/index.php?section=tracked');
         }
     }
     // security boot due to insufficient access level
     if (isset($_GET['viewforum']) && !verify_forum($_GET['forum_id'])) {
         redirect(INFUSIONS . 'forum/index.php');
     }
     // Xss sanitization
     $this->forum_info = array('forum_id' => isset($_GET['forum_id']) ? $_GET['forum_id'] : 0, 'parent_id' => isset($_GET['parent_id']) && verify_forum($_GET['parent_id']) ? $_GET['parent_id'] : 0, 'forum_branch' => isset($_GET['forum_branch']) && verify_forum($_GET['forum_branch']) ? $_GET['forum_branch'] : 0, 'new_thread_link' => '', 'lastvisited' => isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time(), 'posts_per_page' => $forum_settings['posts_per_page'], 'threads_per_page' => $forum_settings['threads_per_page'], 'forum_index' => dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), 'threads' => array(), 'section' => isset($_GET['section']) ? $_GET['section'] : 'thread');
     // Set Max Rows -- XSS
     $this->forum_info['forum_max_rows'] = dbcount("('forum_id')", DB_FORUMS, (multilang_table("FO") ? "forum_language='" . LANGUAGE . "' AND" : '') . "\n\t\tforum_cat='" . $this->forum_info['parent_id'] . "' AND " . groupaccess('forum_access') . "");
     // Sanitize Globals
     $_GET['forum_id'] = $this->forum_info['forum_id'];
     $_GET['rowstart'] = isset($_GET['rowstart']) && $_GET['rowstart'] <= $this->forum_info['forum_max_rows'] ? $_GET['rowstart'] : 0;
     $this->ext = isset($this->forum_info['parent_id']) && isnum($this->forum_info['parent_id']) ? "&amp;parent_id=" . $this->forum_info['parent_id'] : '';
     add_to_title($locale['global_200'] . $locale['forum_0000']);
     add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php', 'title' => $locale['forum_0000']));
     forum_breadcrumbs($this->forum_info['forum_index']);
     // Set Meta data
     if ($this->forum_info['forum_id'] > 0) {
         $meta_result = dbquery("SELECT forum_meta, forum_description FROM " . DB_FORUMS . " WHERE forum_id='" . intval($this->forum_info['forum_id']) . "'");
         if (dbrows($meta_result) > 0) {
             $meta_data = dbarray($meta_result);
             if ($meta_data['forum_description'] !== '') {
                 set_meta('description', $meta_data['forum_description']);
             }
             if ($meta_data['forum_meta'] !== '') {
                 set_meta('keywords', $meta_data['forum_meta']);
             }
         }
     }
     // Additional Sections in Index View
     if (isset($_GET['section'])) {
         switch ($_GET['section']) {
             case 'participated':
                 include INFUSIONS . "forum/sections/participated.php";
                 add_to_title($locale['global_201'] . $locale['global_024']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=participated", 'title' => $locale['global_024']));
                 set_meta("description", $locale['global_024']);
                 break;
             case 'latest':
                 include INFUSIONS . "forum/sections/latest.php";
                 add_to_title($locale['global_201'] . $locale['global_021']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=latest", 'title' => $locale['global_021']));
                 set_meta("description", $locale['global_021']);
                 break;
             case 'tracked':
                 include INFUSIONS . "forum/sections/tracked.php";
                 add_to_title($locale['global_201'] . $locale['global_056']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=tracked", 'title' => $locale['global_056']));
                 set_meta("description", $locale['global_056']);
                 break;
             case "unanswered":
                 include INFUSIONS . "forum/sections/unanswered.php";
                 add_to_title($locale['global_201'] . $locale['global_027']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=unanswered", 'title' => $locale['global_027']));
                 set_meta("description", $locale['global_027']);
                 break;
             case "unsolved":
                 include INFUSIONS . "forum/sections/unsolved.php";
                 add_to_title($locale['global_201'] . $locale['global_028']);
                 add_breadcrumb(array('link' => INFUSIONS . "forum/index.php?section=unsolved", 'title' => $locale['global_028']));
                 set_meta("description", $locale['global_028']);
                 break;
             default:
                 redirect(FUSION_SELF);
         }
     } else {
         // Switch between view forum or forum index -- required: $_GET['viewforum']
         if ($this->forum_info['forum_id'] && isset($this->forum_info['parent_id']) && isset($_GET['viewforum'])) {
             /**
              * View Forum Additional Views - add Filter Initialization
              */
             $time = isset($_GET['time']) ? $_GET['time'] : '';
             $type = isset($_GET['type']) ? $_GET['type'] : '';
             $sort = isset($_GET['sort']) ? $_GET['sort'] : '';
             $order = isset($_GET['order']) ? $_GET['order'] : '';
             $timeCol = '';
             $typeCol = '';
             if ($time) {
                 $time_array = array('today' => strtotime('today'), '2days' => strtotime('-2 day'), '1week' => strtotime('-1 week'), '2week' => strtotime('-2 week'), '1month' => strtotime('-2 month'), '2month' => strtotime('-2 month'), '3month' => strtotime('-2 month'), '6month' => strtotime('-6 month'), '1year' => strtotime('-1 year'));
                 $time_stop = '';
                 foreach ($time_array as $key => $value) {
                     if ($time == $key) {
                         $time_stop = prev($time_array);
                         break;
                     }
                 }
                 if ($time !== 'today') {
                     $timeCol = "AND ((post_datestamp >= '" . $time_array[$time] . "' OR t.thread_lastpost >= '" . $time_array[$time] . "') AND (post_datestamp <= '" . $time_stop . "' OR t.thread_lastpost <= '" . $time_stop . "')) ";
                 } else {
                     $timeCol = "AND (post_datestamp >= '" . $time_array[$time] . "' OR t.thread_lastpost >= '" . $time_array[$time] . "') ";
                 }
             }
             if ($type) {
                 $type_array = array('all' => '', 'discussions' => "AND (a1.attach_name IS NULL or a1.attach_name='') AND (a2.attach_name IS NULL or a2.attach_name='') AND (forum_poll_title IS NULL or forum_poll_title='')", 'attachments' => "AND a1.attach_name !='' OR a2.attach_name !='' AND (forum_poll_title IS NULL or forum_poll_title='')", 'poll' => "AND (a1.attach_name IS NULL or a1.attach_name='') AND (a2.attach_name IS NULL or a2.attach_name='') AND forum_poll_title !=''", 'solved' => "AND t.thread_answered = '1'", 'unsolved' => "AND t.thread_answered = '0'");
                 $typeCol = $type_array[$type];
             }
             $sortCol = "ORDER BY t.thread_lastpost ";
             $orderCol = 'ASC';
             if ($sort) {
                 $sort_array = array('author' => 't.thread_author', 'time' => 't.thread_lastpost', 'subject' => 't.thread_subject', 'reply' => 't.thread_postcount', 'view' => 't.thread_views');
                 $sortCol = "ORDER BY " . $sort_array[$sort] . " ";
             }
             if ($order) {
                 $order_array = array('ascending' => 'ASC', 'descending' => 'DESC');
                 $orderCol = $order_array[$order];
             }
             $sql_condition = $timeCol . $typeCol;
             $sql_order = $sortCol . $orderCol;
             // Filter Links
             $timeExt = isset($_GET['time']) ? "&amp;time=" . $_GET['time'] : '';
             $typeExt = isset($_GET['type']) ? "&amp;type=" . $_GET['type'] : '';
             $sortExt = isset($_GET['sort']) ? "&amp;sort=" . $_GET['sort'] : '';
             $orderExt = isset($_GET['order']) ? "&amp;order=" . $_GET['order'] : '';
             $baseLink = INFUSIONS . 'forum/index.php?viewforum&amp;forum_id=' . $_GET['forum_id'] . '' . (isset($_GET['parent_id']) ? '&amp;parent_id=' . $_GET['parent_id'] . '' : '');
             $timeLink = $baseLink . $typeExt . $sortExt . $orderExt;
             $this->forum_info['filter']['time'] = array($locale['forum_3006'] => INFUSIONS . 'forum/index.php?viewforum&amp;forum_id=' . $_GET['forum_id'] . '' . (isset($_GET['parent_id']) ? '&amp;parent_id=' . $_GET['parent_id'] . '' : ''), $locale['forum_3007'] => $timeLink . '&amp;time=today', $locale['forum_3008'] => $timeLink . '&amp;time=2days', $locale['forum_3009'] => $timeLink . '&amp;time=1week', $locale['forum_3010'] => $timeLink . '&amp;time=2week', $locale['forum_3011'] => $timeLink . '&amp;time=1month', $locale['forum_3012'] => $timeLink . '&amp;time=2month', $locale['forum_3013'] => $timeLink . '&amp;time=3month', $locale['forum_3014'] => $timeLink . '&amp;time=6month', $locale['forum_3015'] => $timeLink . '&amp;time=1year');
             $typeLink = $baseLink . $timeExt . $sortExt . $orderExt;
             $this->forum_info['filter']['type'] = array($locale['forum_3000'] => $typeLink . '&amp;type=all', $locale['forum_3001'] => $typeLink . '&amp;type=discussions', $locale['forum_3002'] => $typeLink . '&amp;type=attachments', $locale['forum_3003'] => $typeLink . '&amp;type=poll', $locale['forum_3004'] => $typeLink . '&amp;type=solved', $locale['forum_3005'] => $typeLink . '&amp;type=unsolved');
             $sortLink = $baseLink . $timeExt . $typeExt . $orderExt;
             $this->forum_info['filter']['sort'] = array($locale['forum_3016'] => $sortLink . '&amp;sort=author', $locale['forum_3017'] => $sortLink . '&amp;sort=time', $locale['forum_3018'] => $sortLink . '&amp;sort=subject', $locale['forum_3019'] => $sortLink . '&amp;sort=reply', $locale['forum_3020'] => $sortLink . '&amp;sort=view');
             $orderLink = $baseLink . $timeExt . $typeExt . $sortExt;
             $this->forum_info['filter']['order'] = array($locale['forum_3021'] => $orderLink . '&amp;order=descending', $locale['forum_3022'] => $orderLink . '&amp;order=ascending');
             // Forum SQL
             $result = dbquery("SELECT f.*, f2.forum_name AS forum_cat_name,\n\t\t\t\tt.thread_id, t.thread_lastpost, t.thread_lastpostid, t.thread_subject,\n\t\t\t\tcount(t.thread_id) as forum_threadcount, p.post_message,\n\t\t\t\tu.user_id, u.user_name, u.user_status, u.user_avatar\n\t\t\t\tFROM " . DB_FORUMS . " f\n\t\t\t\tLEFT JOIN " . DB_FORUMS . " f2 ON f.forum_cat = f2.forum_id\n\t\t\t\tLEFT JOIN " . DB_FORUM_THREADS . " t ON t.forum_id = f.forum_id\n\t\t\t\tLEFT JOIN " . DB_FORUM_POSTS . " p on p.thread_id = t.thread_id and p.post_id = t.thread_lastpostid\n\t\t\t\tLEFT JOIN " . DB_USERS . " u ON f.forum_lastuser=u.user_id  ## -- redo this part -- ##\n\t\t\t\t" . (multilang_table("FO") ? "WHERE f.forum_language='" . LANGUAGE . "' AND" : "WHERE") . " " . groupaccess('f.forum_access') . "\n\t\t\t\tAND f.forum_id='" . intval($this->forum_info['forum_id']) . "' OR f.forum_cat='" . intval($this->forum_info['forum_id']) . "' OR f.forum_branch='" . intval($this->forum_info['forum_branch']) . "'\n\t\t\t\tgroup by f.forum_id ORDER BY forum_cat ASC\n\t\t\t\t");
             $refs = array();
             if (dbrows($result) > 0) {
                 while ($row = dbarray($result) and checkgroup($row['forum_access'])) {
                     // Calculate Forum New Status
                     $newStatus = "";
                     $forum_match = "\\|" . $row['forum_lastpost'] . "\\|" . $row['forum_id'];
                     $last_visited = isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time();
                     if ($row['forum_lastpost'] > $last_visited) {
                         if (iMEMBER && ($row['forum_lastuser'] !== $userdata['user_id'] || !preg_match("({$forum_match}\\.|{$forum_match}\$)", $userdata['user_threads']))) {
                             $newStatus = "<span class='forum-new-icon'><i title='" . $locale['forum_0260'] . "' class='" . Functions::get_forumIcons('new') . "'></i></span>";
                         }
                     }
                     // Calculate lastpost information
                     $lastPostInfo = array();
                     if ($row['forum_lastpostid']) {
                         $last_post = array('avatar' => '', 'avatar_src' => $row['user_avatar'] && file_exists(IMAGES . 'avatars/' . $row['user_avatar']) && !is_dir(IMAGES . 'avatars/' . $row['user_avatar']) ? IMAGES . 'avatars/' . $row['user_avatar'] : '', 'message' => fusion_first_words(parseubb(parsesmileys($row['post_message'])), 10), 'profile_link' => profile_link($row['forum_lastuser'], $row['user_name'], $row['user_status']), 'time' => timer($row['forum_lastpost']), 'date' => showdate("forumdate", $row['forum_lastpost']), 'thread_link' => INFUSIONS . "forum/viewthread.php?forum_id=" . $row['forum_id'] . "&amp;thread_id=" . $row['thread_id'], 'post_link' => INFUSIONS . "forum/viewthread.php?forum_id=" . $row['forum_id'] . "&amp;thread_id=" . $row['thread_id'] . "&amp;pid=" . $row['thread_lastpostid'] . "#post_" . $row['thread_lastpostid']);
                         if ($forum_settings['forum_last_post_avatar']) {
                             $last_post['avatar'] = display_avatar($row, '30px', '', '', 'img-rounded');
                         }
                         $lastPostInfo = $last_post;
                     }
                     /**
                      * Default system icons - why do i need this? Why not let themers decide?
                      */
                     switch ($row['forum_type']) {
                         case '1':
                             $forum_icon = "<i class='" . Functions::get_forumIcons('forum') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . Functions::get_forumIcons('forum') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '2':
                             $forum_icon = "<i class='" . Functions::get_forumIcons('thread') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . Functions::get_forumIcons('thread') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '3':
                             $forum_icon = "<i class='" . Functions::get_forumIcons('link') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . Functions::get_forumIcons('link') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         case '4':
                             $forum_icon = "<i class='" . Functions::get_forumIcons('question') . " fa-fw m-r-10'></i>";
                             $forum_icon_lg = "<i class='" . Functions::get_forumIcons('question') . " fa-3x fa-fw m-r-10'></i>";
                             break;
                         default:
                             $forum_icon = "";
                             $forum_icon_lg = "";
                     }
                     $row += array("forum_moderators" => Functions::parse_forumMods($row['forum_mods']), "forum_new_status" => $newStatus, "forum_link" => array("link" => INFUSIONS . "forum/index.php?viewforum&amp;forum_id=" . $row['forum_id'] . "&amp;parent_id=" . $row['forum_cat'], "title" => $row['forum_name']), "forum_description" => nl2br(parseubb($row['forum_description'])), "forum_postcount_word" => format_word($row['forum_postcount'], $locale['fmt_post']), "forum_threadcount_word" => format_word($row['forum_threadcount'], $locale['fmt_thread']), "last_post" => $lastPostInfo, "forum_icon" => $forum_icon, "forum_icon_lg" => $forum_icon_lg, "forum_image" => $row['forum_image'] && file_exists(FORUM . "images/" . $row['forum_image']) ? $row['forum_image'] : "");
                     $this->forum_info['forum_moderators'] = $row['forum_moderators'];
                     // child hierarchy data.
                     $thisref =& $refs[$row['forum_id']];
                     $thisref = $row;
                     if ($row['forum_cat'] == $this->forum_info['parent_id']) {
                         $this->forum_info['item'][$row['forum_id']] =& $thisref;
                         // will push main item out.
                     } else {
                         $refs[$row['forum_cat']]['child'][$row['forum_id']] =& $thisref;
                     }
                     /**
                      * The current forum
                      */
                     if ($row['forum_id'] == $this->forum_info['forum_id']) {
                         require_once INCLUDES . "mimetypes_include.php";
                         define_forum_mods($row);
                         // do the full string of checks for forums access
                         $this->setForumPermission($row);
                         // Generate Links
                         if ($this->getForumPermission("can_post")) {
                             $this->forum_info['new_thread_link'] = INFUSIONS . "forum/newthread.php?forum_id=" . $row['forum_id'];
                         }
                         /**
                          * Get threads with filter conditions
                          */
                         //xss
                         $count = dbarray(dbquery("SELECT\n\t\t\t\t\t\t\t\tcount(t.thread_id) 'thread_max_rows',\n\t\t\t\t\t\t\t\tcount(a1.attach_id) 'attach_image',\n\t\t\t\t\t\t\t\tcount(a2.attach_id) 'attach_files'\n\n\t\t\t\t\t\t\t\tFROM " . DB_FORUM_THREADS . " t\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUMS . " tf ON tf.forum_id = t.forum_id\n\t\t\t\t\t\t\t\tINNER JOIN " . DB_USERS . " tu1 ON t.thread_author = tu1.user_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu2 ON t.thread_lastuser = tu2.user_id #issue 323\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_POSTS . " p1 ON p1.thread_id = t.thread_id and p1.post_id = t.thread_lastpostid\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_POLLS . " p ON p.thread_id = t.thread_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_VOTES . " v ON v.thread_id = t.thread_id AND p1.post_id = v.post_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_ATTACHMENTS . " a1 on a1.thread_id = t.thread_id AND a1.attach_mime IN ('" . implode(",", img_mimeTypes()) . "')\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_ATTACHMENTS . " a2 on a2.thread_id = t.thread_id AND a2.attach_mime NOT IN ('" . implode(",", img_mimeTypes()) . "')\n\t\t\t\t\t\t\t\tWHERE t.forum_id='" . $this->forum_info['forum_id'] . "' AND t.thread_hidden='0' AND " . groupaccess('tf.forum_access') . " {$sql_condition}\n\t\t\t\t\t\t\t\t##GROUP BY t.thread_id {$sql_order}\n\t\t\t\t\t\t"));
                         $this->forum_info['thread_max_rows'] = $count['thread_max_rows'];
                         if ($this->forum_info['thread_max_rows'] > 0) {
                             $this->forum_info['threads']['pagenav'] = "";
                             $this->forum_info['threads']['pagenav2'] = "";
                             // anti-XSS filtered rowstart
                             $_GET['thread_rowstart'] = isset($_GET['thread_rowstart']) && isnum($_GET['thread_rowstart']) && $_GET['thread_rowstart'] <= $this->forum_info['thread_max_rows'] ? $_GET['thread_rowstart'] : 0;
                             $t_result = dbquery("\n                                SELECT t.*, tu1.user_name AS author_name, tu1.user_status AS author_status, tu1.user_avatar as author_avatar,\n\t\t\t\t\t\t\t\ttu2.user_name AS last_user_name, tu2.user_status AS last_user_status, tu2.user_avatar AS last_user_avatar,\n\t\t\t\t\t\t\t\tp1.post_datestamp, p1.post_message,\n\t\t\t\t\t\t\t\tp.forum_poll_title,\n\t\t\t\t\t\t\t\tcount(v.post_id) AS vote_count,\n\t\t\t\t\t\t\t\ta1.attach_name, a1.attach_id,\n\t\t\t\t\t\t\t\ta2.attach_name, a2.attach_id,\n\t\t\t\t\t\t\t\tcount(a1.attach_mime) 'attach_image',\n\t\t\t\t\t\t\t\tcount(a2.attach_mime) 'attach_files'\n\t\t\t\t\t\t\t\tFROM " . DB_FORUM_THREADS . " t\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUMS . " tf ON tf.forum_id = t.forum_id\n\t\t\t\t\t\t\t\tINNER JOIN " . DB_USERS . " tu1 ON t.thread_author = tu1.user_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu2 ON t.thread_lastuser = tu2.user_id #issue 323\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_POSTS . " p1 ON p1.thread_id = t.thread_id and p1.post_id = t.thread_lastpostid\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_POLLS . " p ON p.thread_id = t.thread_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_VOTES . " v ON v.thread_id = t.thread_id AND p1.post_id = v.post_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_ATTACHMENTS . " a1 on a1.thread_id = t.thread_id AND a1.attach_mime IN ('" . implode(",", img_mimeTypes()) . "')\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB_FORUM_ATTACHMENTS . " a2 on a2.thread_id = t.thread_id AND a2.attach_mime NOT IN ('" . implode(",", img_mimeTypes()) . "')\n\t\t\t\t\t\t\t\tWHERE t.forum_id='" . $this->forum_info['forum_id'] . "' AND t.thread_hidden='0' AND " . groupaccess('tf.forum_access') . " {$sql_condition}\n\t\t\t\t\t\t\t\tGROUP BY t.thread_id {$sql_order} LIMIT " . intval($_GET['thread_rowstart']) . ", " . $this->forum_info['threads_per_page']);
                             $thread_rows = dbrows($t_result);
                             if ($thread_rows > 0) {
                                 while ($threads = dbarray($t_result)) {
                                     $icon = "";
                                     $match_regex = $threads['thread_id'] . "\\|" . $threads['thread_lastpost'] . "\\|" . $threads['forum_id'];
                                     if ($threads['thread_lastpost'] > $this->forum_info['lastvisited']) {
                                         if (iMEMBER && ($threads['thread_lastuser'] == $userdata['user_id'] || preg_match("(^\\.{$match_regex}\$|\\.{$match_regex}\\.|\\.{$match_regex}\$)", $userdata['user_threads']))) {
                                             $icon = "<i class='" . get_forumIcons('thread') . "' title='" . $locale['forum_0261'] . "'></i>";
                                         } else {
                                             $icon = "<i class='" . get_forumIcons('new') . "' title='" . $locale['forum_0260'] . "'></i>";
                                         }
                                     }
                                     $author = array('user_id' => $threads['thread_author'], 'user_name' => $threads['author_name'], 'user_status' => $threads['author_status'], 'user_avatar' => $threads['author_avatar']);
                                     $lastuser = array('user_id' => $threads['thread_lastuser'], 'user_name' => $threads['last_user_name'], 'user_status' => $threads['last_user_status'], 'user_avatar' => $threads['last_user_avatar']);
                                     $threads += array("thread_link" => array("link" => INFUSIONS . "forum/viewthread.php?thread_id=" . $threads['thread_id'], "title" => $threads['thread_subject']), "forum_type" => $row['forum_type'], "thread_pages" => makepagenav(0, $forum_settings['posts_per_page'], $threads['thread_postcount'], 3, FORUM . "viewthread.php?thread_id=" . $threads['thread_id'] . "&amp;"), "thread_icons" => array('lock' => $threads['thread_locked'] ? "<i class='" . get_forumIcons('lock') . "' title='" . $locale['forum_0263'] . "'></i>" : '', 'sticky' => $threads['thread_sticky'] ? "<i class='" . get_forumIcons('sticky') . "' title='" . $locale['forum_0103'] . "'></i>" : '', 'poll' => $threads['thread_poll'] ? "<i class='" . get_forumIcons('poll') . "' title='" . $locale['forum_0314'] . "'></i>" : '', 'hot' => $threads['thread_postcount'] >= 20 ? "<i class='" . get_forumIcons('hot') . "' title='" . $locale['forum_0311'] . "'></i>" : '', 'reads' => $threads['thread_views'] >= 20 ? "<i class='" . get_forumIcons('reads') . "' title='" . $locale['forum_0311'] . "'></i>" : '', 'image' => $threads['attach_image'] > 0 ? "<i class='" . get_forumIcons('image') . "' title='" . $locale['forum_0313'] . "'></i>" : '', 'file' => $threads['attach_files'] > 0 ? "<i class='" . get_forumIcons('file') . "' title='" . $locale['forum_0312'] . "'></i>" : '', 'icon' => $icon), "thread_starter" => $locale['forum_0006'] . timer($threads['post_datestamp']) . " " . $locale['by'] . " " . profile_link($author['user_id'], $author['user_name'], $author['user_status']) . "</span>", "thread_author" => $author, "thread_last" => array('avatar' => display_avatar($lastuser, '30px', '', '', ''), 'profile_link' => profile_link($lastuser['user_id'], $lastuser['user_name'], $lastuser['user_status']), 'time' => $threads['post_datestamp'], 'post_message' => parseubb(parsesmileys($threads['post_message'])), "formatted" => "<div class='pull-left'>" . display_avatar($lastuser, '30px', '', '', '') . "</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class='overflow-hide'>" . $locale['forum_0373'] . " <span class='forum_profile_link'>" . profile_link($lastuser['user_id'], $lastuser['user_name'], $lastuser['user_status']) . "</span><br/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . timer($threads['post_datestamp']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>"));
                                     //if ($threads['thread_status']['reads']) $threads['thread_status']['icon'] = $threads['thread_status']['reads'];
                                     //if ($threads['thread_status']['hot']) $threads['thread_status']['icon'] = $threads['thread_status']['hot'];
                                     //if ($threads['thread_status']['sticky']) $threads['thread_status']['icon'] = $threads['thread_status']['sticky'];
                                     //if ($threads['thread_status']['lock']) $threads['thread_status']['icon'] = $threads['thread_status']['lock'];
                                     // Threads Customized Output
                                     /*
                                     										$attach_image = 0;
                                     										$attach_file = 0;
                                     										$a_result = dbquery("SELECT attach_id, attach_mime FROM ".DB_FORUM_ATTACHMENTS." WHERE thread_id ='".$threads['thread_id']."'");
                                     										if (dbrows($a_result) > 0) {
                                     											require_once INCLUDES."mimetypes_include.php";
                                     											while ($adata = dbarray($a_result)) {
                                     												if (in_array($adata['attach_mime'], img_mimeTypes())) {
                                     													$attach_image = $attach_image+1;
                                     												} else {
                                     													$attach_file = $attach_file+1;
                                     												}
                                     											}
                                     										}*/
                                     if ($threads['thread_sticky']) {
                                         $this->forum_info['threads']['sticky'][$threads['thread_id']] = $threads;
                                     } else {
                                         $this->forum_info['threads']['item'][$threads['thread_id']] = $threads;
                                     }
                                 }
                             }
                             if ($this->forum_info['thread_max_rows'] > $this->forum_info['threads_per_page']) {
                                 $this->forum_info['threads']['pagenav'] = makepagenav($_GET['thread_rowstart'], $this->forum_info['threads_per_page'], $this->forum_info['thread_max_rows'], 3, clean_request("", array("thread_rowstart"), FALSE) . "&amp;", "thread_rowstart");
                                 $this->forum_info['threads']['pagenav2'] = makepagenav($_GET['thread_rowstart'], $this->forum_info['threads_per_page'], $this->forum_info['thread_max_rows'], 3, clean_request("", array("thread_rowstart"), FALSE) . "&amp;", "thread_rowstart", TRUE);
                             }
                         }
                     }
                 }
             } else {
                 redirect(INFUSIONS . 'forum/index.php');
             }
         } else {
             $this->forum_info['forums'] = Functions::get_forum();
         }
     }
 }
Пример #5
0
 public function __construct()
 {
     $this->language_opts = fusion_get_enabled_languages();
     $this->link_index = dbquery_tree(DB_SITE_LINKS, 'link_id', 'link_cat');
 }
Пример #6
0
function form_select_tree($title, $input_name, $input_id, $input_value = FALSE, $array = FALSE, $db, $name_col, $id_col, $cat_col, $self_id = FALSE, $id = FALSE, $level = FALSE, $index = FALSE, $data = FALSE)
{
    global $_POST, $locale;
    if (!defined("SELECT2")) {
        define("SELECT2", TRUE);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js' /></script>\n");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />\n");
    }
    $title2 = isset($title) && !empty($title) ? stripinput($title) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $input_value = isset($input_value) ? stripinput($input_value) : '';
    if (isset($name) && $name != "") {
        $name = stripinput($name);
    } else {
        $name = "";
    }
    if (isset($id_col) && $id_col != "") {
        $id_col = stripinput($id_col);
    } else {
        $id_col = "";
    }
    if (isset($cat_col) && $cat_col != "") {
        $cat_col = stripinput($cat_col);
    } else {
        $cat_col = "";
    }
    if (!is_array($array)) {
        $array = array();
        $state_validation = "";
        $required = 0;
        $safemode = 0;
        $allowclear = "";
        $placeholder = $locale['choose'];
        $deactivate = "";
        $labeloff = "";
        $multiple = "";
        $stacking = 0;
        $width = "style='width:90%;'";
        $add_parent_opts = 0;
        $no_root = 0;
        $inline = '';
        $include_opts = '';
        // for selective input. will not show items if value not in array.
    } else {
        $multiple = array_key_exists('is_multiple', $array) ? $array['is_multiple'] : "";
        $placeholder = array_key_exists('placeholder', $array) ? $array['placeholder'] : $locale['choose'];
        $allowclear = !empty($placeholder) && $multiple !== 1 ? "allowClear:true" : "";
        $deactivate = array_key_exists('deactivate', $array) ? $array['deactivate'] : "";
        $labeloff = array_key_exists('labeloff', $array) ? $array['labeloff'] : "";
        $helper_text = array_key_exists("helper", $array) ? $array['helper'] : "";
        $required = array_key_exists('required', $array) && $array['required'] == 1 ? 1 : 0;
        $safemode = array_key_exists('safemode', $array) && $array['safemode'] == 1 ? 1 : 0;
        $stacking = array_key_exists('stacking', $array) && $array['stacking'] == 1 ? 1 : 0;
        $add_parent_opts = array_key_exists('add_parent_opts', $array) && $array['add_parent_opts'] == 1 ? 1 : 0;
        $no_root = array_key_exists('no_root', $array) && $array['no_root'] == 1 ? 1 : 0;
        $width = array_key_exists('width', $array) ? $array['width'] : '';
        $multiple = $multiple == 1 ? "multiple" : "";
        $inline = array_key_exists("rowstart", $array) ? 1 : 0;
        $include_opts = array_key_exists("include_opts", $array) ? $array['include_opts'] : '';
    }
    // Patterns
    if (!$level) {
        $level = 0;
        $html = "";
        $html .= "<div id='{$input_id}-field' class='form-group m-b-0'>\n";
        $html .= "<label class='control-label " . ($inline ? "col-sm-3 col-md-3 col-lg-3" : '') . "' for='{$input_id}'>{$title} " . ($required == 1 ? "<span class='required'>*</span>" : '') . "</label>\n";
        $html .= $inline ? "<div class='col-sm-9 col-md-9 col-lg-9'>\n" : "";
    }
    $opt_pattern = str_repeat("&#8212;", $level);
    // no need to count here, it's cosmetics.
    if ($level == "0") {
        add_to_jquery("\n            \$('#" . $input_id . "').select2({\n            placeholder: '" . $placeholder . "',\n            {$allowclear}\n            });\n            ");
        $html .= "<select name='{$input_name}' id='{$input_id}' " . ($width ? "style='width: {$width}'" : "style='min-width: 250px'") . " " . ($deactivate == "1" && isnum($deactivate) ? "readonly" : "") . " {$multiple}>";
        if ($allowclear) {
            $html .= "<option value=''></option>";
        }
        if ($no_root !== 1) {
            // api options to remove root from selector. used in items creation.
            $this_select = '';
            if ($input_value !== NULL) {
                if ($input_value == '0') {
                    $this_select = "selected";
                }
            }
            $html .= $add_parent_opts == '1' ? "<option value='0' " . $this_select . ">{$opt_pattern} " . $locale['parent'] . "</option>\n" : "<option value='0' {$this_select}>{$opt_pattern} Root</option>\n";
        }
        $index = dbquery_tree($db, $id_col, $cat_col);
        $data = dbquery_tree_data($db, $id_col, $cat_col);
    }
    if (!$id) {
        $id = 0;
    }
    if (isset($index[$id])) {
        foreach ($index[$id] as $key => $value) {
            $html =& $html;
            $name = $data[$value][$name_col];
            $select = $input_value !== "" && $input_value == $value ? 'selected' : '';
            if (isset($include_opts) && is_array($include_opts)) {
                $html .= in_array($value, $include_opts) ? "<option value='{$value}' " . $select . " " . ($self_id == $value ? 'disabled' : '') . ">{$opt_pattern} {$name} " . ($self_id == $value ? '(Current Item)' : '') . "</option>\n" : '';
            } else {
                $html .= "<option value='{$value}' " . $select . " " . ($self_id == $value ? 'disabled' : '') . ">{$opt_pattern} {$name} " . ($self_id == $value ? '(Current Item)' : '') . "</option>\n";
            }
            if (isset($index[$value])) {
                $html .= form_select_tree($title, $input_name, $input_id, $input_value, $array, $db, $name_col, $id_col, $cat_col, $self_id, $value, $level + 1, $index, $data);
            }
        }
    }
    if (!$level) {
        $html .= "</select>";
        $html .= "<br/><div id='{$input_id}-help' style='display:inline-block !important;'></div>";
        $html .= "<input type='hidden' name='def[{$input_name}]' value='[type=dropdown],[title={$title2}],[id={$input_id}],[required={$required}],[safemode={$safemode}]' readonly>";
        $html .= "</div>\n";
    }
    return $html;
}
Пример #7
0
 public function display_administration_form()
 {
     global $aidlink;
     pageAccess("SL");
     $locale = fusion_get_locale("", LOCALE . LOCALESET . "admin/sitelinks.php");
     if (isset($_POST['cancel'])) {
         redirect(FUSION_SELF . $aidlink);
     }
     $title = $locale['SL_0001'];
     if (isset($_GET['ref']) && $_GET['ref'] == "link_form") {
         $title = isset($_GET['link_id']) && $this->verify_sitelinks($_GET['link_id']) ? $locale['SL_0011'] : $locale['SL_0010'];
     }
     $master_title['title'][] = $title;
     $master_title['id'][] = "links";
     $master_title['icon'][] = '';
     $master_title['title'][] = $locale['SL_0041'];
     $master_title['id'][] = "settings";
     $master_title['icon'][] = '';
     $link_index = dbquery_tree(DB_SITE_LINKS, "link_id", "link_cat");
     $link_data = dbquery_tree_full(DB_SITE_LINKS, "link_id", "link_cat");
     make_page_breadcrumbs($link_index, $link_data, "link_id", "link_name", "link_cat");
     opentable($locale['SL_0012']);
     echo opentab($master_title, isset($_GET['section']) ? $_GET['section'] : "links", 'link', TRUE);
     if (isset($_GET['section']) && $_GET['section'] == "settings") {
         $this->display_sitelinks_settings();
     } else {
         if (isset($_GET['ref'])) {
             switch ($_GET['ref']) {
                 case "link_form":
                     $this->display_sitelinks_form();
                     break;
                 default:
                     $this->display_sitelinks_list();
             }
         } else {
             $this->display_sitelinks_list();
         }
     }
     echo closetab();
     closetable();
 }
Пример #8
0
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once file_exists('maincore.php') ? 'maincore.php' : __DIR__ . "/../../maincore.php";
if (!db_exists(DB_WEBLINKS)) {
    redirect(BASEDIR . "error.php?code=404");
}
require_once THEMES . "templates/header.php";
require_once INCLUDES . "infusions_include.php";
if (file_exists(INFUSIONS . "weblinks/locale/" . LOCALESET . "weblinks.php")) {
    include INFUSIONS . "weblinks/locale/" . LOCALESET . "weblinks.php";
} else {
    include INFUSIONS . "weblinks/locale/English/weblinks.php";
}
include INFUSIONS . "weblinks/templates/weblinks.php";
$wl_settings = get_settings("weblinks");
$weblink_cat_index = dbquery_tree(DB_WEBLINK_CATS, 'weblink_cat_id', 'weblink_cat_parent');
add_breadcrumb(array('link' => INFUSIONS . 'weblinks/weblinks.php', 'title' => $locale['400']));
if (!isset($_GET['weblink_id']) || !isset($_GET['weblink_cat_id'])) {
    set_title($locale['400']);
}
if (isset($_GET['weblink_id']) && isnum($_GET['weblink_id'])) {
    $res = 0;
    $data = dbarray(dbquery("SELECT weblink_url,weblink_cat, weblink_visibility FROM " . DB_WEBLINKS . " WHERE weblink_id='" . intval($_GET['weblink_id']) . "'"));
    if (checkgroup($data['weblink_visibility'])) {
        $res = 1;
        dbquery("UPDATE " . DB_WEBLINKS . " SET weblink_count=weblink_count+1 WHERE weblink_id='" . intval($_GET['weblink_id']) . "'");
        redirect($data['weblink_url']);
    } else {
        redirect(FUSION_SELF);
    }
} elseif (isset($_GET['cat_id']) && isnum($_GET['cat_id'])) {
Пример #9
0
 define_forum_mods($forum_data);
 // Use the new permission settings
 $forum->setForumPermission($forum_data);
 $permission = $forum->getForumPermission();
 $forum_data['lock_edit'] = $forum_settings['forum_edit_lock'] == 1 ? TRUE : FALSE;
 if ($permission['can_post'] && $permission['can_access']) {
     $post_data['forum_cat'] = $forum_data['forum_cat'];
     // create a new thread.
     dbquery_insert(DB_FORUM_THREADS, $thread_data, 'save', array('primary_key' => 'thread_id', 'keep_session' => TRUE));
     $post_data['thread_id'] = dblastid();
     dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id', 'keep_session' => TRUE));
     $post_data['post_id'] = dblastid();
     dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . $post_data['post_author'] . "'");
     // Update stats in forum and threads
     // find all parents and update them
     $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $post_data['forum_id']);
     foreach ($list_of_forums as $fid) {
         dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $fid . "'");
     }
     // update current forum
     dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $post_data['forum_id'] . "'");
     // update current thread
     dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_lastpost='" . time() . "', thread_lastpostid='" . $post_data['post_id'] . "', thread_lastuser='******'post_author'] . "' WHERE thread_id='" . $post_data['thread_id'] . "'");
     // set notify
     if ($forum_settings['thread_notify'] && isset($_POST['notify_me']) && $post_data['thread_id']) {
         if (!dbcount("(thread_id)", DB_FORUM_THREAD_NOTIFY, "thread_id='" . $post_data['thread_id'] . "' AND notify_user='******'post_author'] . "'")) {
             dbquery("INSERT INTO " . DB_FORUM_THREAD_NOTIFY . " (thread_id, notify_datestamp, notify_user, notify_status) VALUES('" . $post_data['thread_id'] . "', '" . time() . "', '" . $post_data['post_author'] . "', '1')");
         }
     }
     if ($defender->safe()) {
         redirect(INFUSIONS . "forum/postify.php?post=new&error=0&amp;forum_id=" . intval($post_data['forum_id']) . "&amp;parent_id=" . intval($post_data['forum_cat']) . "&amp;thread_id=" . intval($post_data['thread_id'] . ""));
Пример #10
0
 /**
  * Handle post of Quick Reply Form
  */
 private function handle_quick_reply()
 {
     $forum_settings = $this->get_forum_settings();
     $locale = fusion_get_locale();
     $userdata = fusion_get_userdata();
     if (isset($_POST['post_quick_reply'])) {
         if ($this->getThreadPermission("can_reply") && \defender::safe()) {
             $this->thread_data = $this->thread_info['thread'];
             require_once INCLUDES . "flood_include.php";
             if (!flood_control("post_datestamp", DB_FORUM_POSTS, "post_author='" . $userdata['user_id'] . "'")) {
                 // have notice
                 $post_data = array('post_id' => 0, 'forum_id' => $this->thread_data['forum_id'], 'thread_id' => $this->thread_data['thread_id'], 'post_message' => form_sanitizer($_POST['post_message'], '', 'post_message'), 'post_showsig' => isset($_POST['post_showsig']) ? 1 : 0, 'post_smileys' => isset($_POST['post_smileys']) || preg_match("#(\\[code\\](.*?)\\[/code\\]|\\[geshi=(.*?)\\](.*?)\\[/geshi\\]|\\[php\\](.*?)\\[/php\\])#si", $_POST['post_message']) ? 1 : 0, 'post_author' => $userdata['user_id'], 'post_datestamp' => time(), 'post_ip' => USER_IP, 'post_ip_type' => USER_IP_TYPE, 'post_edituser' => 0, 'post_edittime' => 0, 'post_editreason' => '', 'post_hidden' => 0, 'post_locked' => $forum_settings['forum_edit_lock'] || isset($_POST['post_locked']) ? 1 : 0);
                 if (\defender::safe()) {
                     // post message is invalid or whatever is invalid
                     $update_forum_lastpost = FALSE;
                     // Prepare forum merging action
                     $last_post_author = dbarray(dbquery("SELECT post_author FROM " . DB_FORUM_POSTS . " WHERE thread_id='" . $this->thread_data['thread_id'] . "' ORDER BY post_id DESC LIMIT 1"));
                     if ($last_post_author['post_author'] == $post_data['post_author'] && $this->thread_data['forum_merge']) {
                         $last_message = dbarray(dbquery("SELECT post_id, post_message FROM " . DB_FORUM_POSTS . " WHERE thread_id='" . $this->thread_data['thread_id'] . "' ORDER BY post_id DESC"));
                         $post_data['post_id'] = $last_message['post_id'];
                         $post_data['post_message'] = $last_message['post_message'] . "\n\n" . $locale['forum_0640'] . " " . showdate("longdate", time()) . ":\n" . $post_data['post_message'];
                         dbquery_insert(DB_FORUM_POSTS, $post_data, 'update', array('primary_key' => 'post_id'));
                     } else {
                         $update_forum_lastpost = TRUE;
                         dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id'));
                         $post_data['post_id'] = dblastid();
                         dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . $post_data['post_author'] . "'");
                     }
                     // Update stats in forum and threads
                     if ($update_forum_lastpost) {
                         // find all parents and update them
                         $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $this->thread_data['forum_id']);
                         if (!empty($list_of_forums)) {
                             foreach ($list_of_forums as $fid) {
                                 dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $fid . "'");
                             }
                         }
                         // update current forum
                         dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $this->thread_data['forum_id'] . "'");
                         // update current thread
                         dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_lastpost='" . time() . "', thread_lastpostid='" . $post_data['post_id'] . "', thread_postcount=thread_postcount+1, thread_lastuser='******'post_author'] . "' WHERE thread_id='" . $this->thread_data['thread_id'] . "'");
                     }
                     // set notify
                     if ($forum_settings['thread_notify'] == TRUE && isset($_POST['notify_me']) && $this->thread_data['thread_id']) {
                         if (!dbcount("(thread_id)", DB_FORUM_THREAD_NOTIFY, "thread_id='" . $this->thread_data['thread_id'] . "' AND notify_user='******'post_author'] . "'")) {
                             dbquery("INSERT INTO " . DB_FORUM_THREAD_NOTIFY . " (thread_id, notify_datestamp, notify_user, notify_status) VALUES('" . $this->thread_data['thread_id'] . "', '" . time() . "', '" . $post_data['post_author'] . "', '1')");
                         }
                     }
                 }
                 redirect(INFUSIONS . "forum/postify.php?post=reply&error=0&amp;forum_id=" . intval($post_data['forum_id']) . "&amp;thread_id=" . intval($post_data['thread_id']) . "&amp;post_id=" . intval($post_data['post_id']));
             }
         }
     }
 }
Пример #11
0
/**
 * Select2 hierarchy
 * Returns a full hierarchy nested dropdown.
 * @param        $input_name
 * @param string $label
 * @param bool   $input_value
 * @param array  $options
 * @param        $db - your db
 * @param        $name_col - the option text to show
 * @param        $id_col - unique id
 * @param        $cat_col - parent id
 *                         ## The rest of the Params are used by the function itself -- no need to handle ##
 * @param bool   $self_id - not required
 * @param bool   $id - not required
 * @param bool   $level - not required
 * @param bool   $index - not required
 * @param bool   $data - not required
 * @return string
 */
function form_select_tree($input_name, $label = "", $input_value = FALSE, array $options = array(), $db, $name_col, $id_col, $cat_col, $self_id = FALSE, $id = FALSE, $level = FALSE, $index = FALSE, $data = FALSE)
{
    global $defender, $locale;
    if (!defined("SELECT2")) {
        define("SELECT2", TRUE);
        add_to_footer("<script src='" . DYNAMICS . "assets/select2/select2.min.js' /></script>\n");
        add_to_head("<link href='" . DYNAMICS . "assets/select2/select2.css' rel='stylesheet' />\n");
    }
    $title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name)));
    $default_options = array('required' => FALSE, 'regex' => '', 'input_id' => $input_name, 'placeholder' => $locale['choose'], 'deactivate' => FALSE, 'safemode' => FALSE, 'allowclear' => FALSE, 'multiple' => FALSE, 'width' => '250px', 'keyflip' => FALSE, 'tags' => FALSE, 'jsonmode' => FALSE, 'chainable' => FALSE, 'maxselect' => FALSE, 'error_text' => $locale['error_input_default'], 'class' => '', 'inline' => FALSE, 'tip' => '', 'delimiter' => ',', 'callback_check' => '', 'file' => '', 'parent_value' => $locale['root'], 'add_parent_opts' => FALSE, 'disable_opts' => '', 'hide_disabled' => FALSE, 'no_root' => FALSE, 'show_current' => FALSE, 'query' => '');
    $options += $default_options;
    $options['input_id'] = trim($options['input_id'], "[]");
    if ($options['multiple']) {
        if ($input_value) {
            $input_value = construct_array($input_value, 0, $options['delimiter']);
        } else {
            $input_value = array();
        }
    }
    if (!$options['width']) {
        $options['width'] = $default_options['width'];
    }
    $allowclear = $options['placeholder'] && $options['multiple'] || $options['allowclear'] ? "allowClear:true" : '';
    $disable_opts = '';
    if ($options['disable_opts']) {
        $disable_opts = is_array($options['disable_opts']) ? $options['disable_opts'] : explode(',', $options['disable_opts']);
    }
    /* Child patern */
    $opt_pattern = str_repeat("&#8212;", $level);
    if (!$level) {
        $level = 0;
        if (!isset($index[$id])) {
            $index[$id] = array('0' => $locale['no_opts']);
        }
        $error_class = "";
        if ($defender->inputHasError($input_name)) {
            $error_class = "has-error ";
            if (!empty($options['error_text'])) {
                $new_error_text = $defender->getErrorText($input_name);
                if (!empty($new_error_text)) {
                    $options['error_text'] = $new_error_text;
                }
                addNotice("danger", "<strong>{$title}</strong> - " . $options['error_text']);
            }
        }
        $html = "<div id='" . $options['input_id'] . "-field' class='form-group " . $error_class . $options['class'] . "' " . ($options['inline'] && $options['width'] && !$label ? "style='width: " . $options['width'] . "'" : '') . ">\n";
        $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 p-l-0" : 'col-xs-12 p-l-0') . "' for='" . $options['input_id'] . "'>{$label} " . ($options['required'] == TRUE ? "<span class='required'>*</span>" : '') . " " . ($options['tip'] ? "<i class='pointer fa fa-question-circle' label=\"" . $options['tip'] . "\"></i>" : '') . "</label>\n" : '';
        $html .= $options['inline'] ? "<div class='col-xs-12 " . ($label ? "col-sm-9 col-md-9 col-lg-9" : "col-sm-12") . "'>\n" : "";
    }
    if ($level == 0) {
        $html =& $html;
        add_to_jquery("\n\t\t\$('#" . $options['input_id'] . "').select2({\n\t\tplaceholder: '" . $options['placeholder'] . "',\n\t\t{$allowclear}\n\t\t});\n\t\t");
        if (is_array($input_value) && $options['multiple']) {
            // stores as value;
            $vals = '';
            foreach ($input_value as $arr => $val) {
                $vals .= $arr == count($input_value) - 1 ? "'{$val}'" : "'{$val}',";
            }
            add_to_jquery("\$('#" . $options['input_id'] . "').select2('val', [{$vals}]);");
        }
        $html .= "<select name='{$input_name}' id='" . $options['input_id'] . "' style='width: " . ($options['width'] ? $options['width'] : $default_options['width']) . "' " . ($options['deactivate'] ? " disabled" : "") . ($options['multiple'] ? " multiple" : "") . ">";
        $html .= $options['allowclear'] ? "<option value=''></option>" : '';
        if ($options['no_root'] == FALSE) {
            // api options to remove root from selector. used in items creation.
            $this_select = '';
            if ($input_value !== NULL) {
                if ($input_value !== '') {
                    $this_select = 'selected';
                }
            }
            $html .= $options['add_parent_opts'] == TRUE ? "<option value='0' " . $this_select . ">{$opt_pattern} " . $locale['parent'] . "</option>\n" : "<option value='0' " . $this_select . " >{$opt_pattern} " . $options['parent_value'] . "</option>\n";
        }
        $index = dbquery_tree($db, $id_col, $cat_col, $options['query']);
        $data = dbquery_tree_data($db, $id_col, $cat_col, $options['query']);
    }
    if (!$id) {
        $id = 0;
    }
    if (isset($index[$id])) {
        foreach ($index[$id] as $key => $value) {
            //$hide = $disable_branch && $value == $self_id ? 1 : 0;
            $html =& $html;
            $name = $data[$value][$name_col];
            $name = PHPFusion\QuantumFields::parse_label($name);
            $select = $input_value !== "" && $input_value == $value ? 'selected' : '';
            $disabled = $disable_opts && in_array($value, $disable_opts) ? TRUE : FALSE;
            $hide = $disabled && $options['hide_disabled'] ? TRUE : FALSE;
            // do a disable for filter_opts item.
            $html .= !$hide ? "<option value='{$value}' " . $select . " " . ($disable_opts && in_array($value, $disable_opts) ? 'disabled' : '') . " >{$opt_pattern} {$name} " . ($options['show_current'] && $self_id == $value ? '(Current Item)' : '') . "</option>\n" : '';
            if (isset($index[$value]) && !$hide) {
                $html .= form_select_tree($input_name, $label, $input_value, $options, $db, $name_col, $id_col, $cat_col, $self_id, $value, $level + TRUE, $index, $data);
            }
        }
    }
    if (!$level) {
        $html =& $html;
        $html .= "</select>";
        $html .= $options['required'] == 1 && $defender->inputHasError($input_name) || $defender->inputHasError($input_name) ? "<div id='" . $options['input_id'] . "-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : "";
        $html .= $options['inline'] ? "</div>\n" : '';
        $html .= "</div>\n";
        if ($options['required']) {
            $html .= "<input class='req' id='dummy-" . $options['input_id'] . "' type='hidden'>\n";
            // for jscheck
        }
        $input_name = $options['multiple'] ? str_replace("[]", "", $input_name) : $input_name;
        $defender->add_field_session(array('input_name' => $input_name, 'title' => trim($title, '[]'), 'id' => $options['input_id'], 'type' => 'dropdown', 'regex' => $options['regex'], 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'], 'callback_check' => $options['callback_check'], 'delimiter' => $options['delimiter']));
    }
    return $html;
}
Пример #12
0
 /**
  * Get forum index for hierarchy traversal
  * @return array
  */
 private function get_forum_index()
 {
     return dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
 }
Пример #13
0
 /**
  * Executes single news item information - $_GET['readmore']
  * @param $news_id
  */
 public function set_NewsItemInfo($news_id)
 {
     global $aidlink;
     $locale = fusion_get_locale('', NEWS_LOCALE);
     $settings = fusion_get_settings();
     set_title(SiteLinks::get_current_SiteLinks("", "link_name"));
     add_breadcrumb(array('link' => INFUSIONS . 'news/news.php', 'title' => SiteLinks::get_current_SiteLinks("", "link_name")));
     $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) ? $_GET['rowstart'] : 0;
     $result = dbquery(self::get_NewsQuery(array('condition' => 'news_id=' . intval($news_id))));
     if (dbrows($result) > 0) {
         include INCLUDES . "comments_include.php";
         include INCLUDES . "ratings_include.php";
         $data = dbarray($result);
         if ($data['news_keywords'] !== "") {
             set_meta("keywords", $data['news_keywords']);
         }
         if (!isset($_POST['post_comment']) && !isset($_POST['post_rating'])) {
             $result2 = dbquery("UPDATE " . DB_NEWS . " SET news_reads=news_reads+1 WHERE news_id='" . $_GET['readmore'] . "'");
             $data['news_reads']++;
         }
         $news_subject = $data['news_subject'];
         $news_news = preg_split("/<!?--\\s*pagebreak\\s*-->/i", $data['news_breaks'] == "y" ? nl2br(parse_textarea($data['news_extended'] ? $data['news_extended'] : $data['news_news'])) : parse_textarea($data['news_extended'] ? $data['news_extended'] : $data['news_news']));
         $pagecount = count($news_news);
         $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $pagecount ? $_GET['rowstart'] : 0;
         $admin_actions = array();
         if (iADMIN && checkrights("N")) {
             $admin_actions = array("edit" => INFUSIONS . "news/news_admin.php" . $aidlink . "&amp;action=edit&amp;section=nform&amp;news_id=" . $data['news_id'], "delete" => INFUSIONS . "news/news_admin.php" . $aidlink . "&amp;action=delete&amp;section=nform&amp;news_id=" . $data['news_id']);
         }
         $news_info = $this->get_NewsData($data);
         /*
                         array(
                         "news_id" => $data['news_id'],
                         "user_id" => $data['user_id'],
                         "user_name" => $data['user_name'],
                         "user_status" => $data['user_status'],
                         "user_joined" => $data['user_joined'],
                         "user_level" => $data['user_level'],
                         "user_avatar" => $data['user_avatar'],
                         "news_datestamp" => $data['news_datestamp'],
                         "news_ialign" => $data['news_ialign'],
                         "cat_id" => $data['news_cat'],
                         "news_cat_name" => $data['news_cat_name'],
                         "news_cat_image_src" => !empty($data['news_cat_image']) && file_exists(IMAGES_NC.$data['news_cat_image']) ? IMAGES_NC.$data['news_cat_image'] : "",
                         "news_image_src" => !empty($data['news_image']) && file_exists(IMAGES_N.$data['news_image']) ? IMAGES_N.$data['news_image'] : "",
                         "cat_image" => $data['news_cat_image'],
                         "news_subject" => $data['news_subject'],
                         "news_descr" => $data['news_news'],
                         "news_cat_url" => INFUSIONS.'news/news.php?cat_id='.$data['news_cat'],
                         'news_url' => INFUSIONS.'news/news.php?readmore='.$data['news_id'],
                         'news_news' => $news_news[$_GET['rowstart']],
                         "news_ext" => "n",
                         "news_keywords" => $data['news_keywords'],
                         "news_reads" => $data['news_reads'],
                         "news_comments" => $data['count_comment'],
                         'news_sum_rating' => $data['sum_rating'] ? $data['sum_rating'] : 0,
                         'news_count_votes' => $data['count_votes'],
                         "news_allow_comments" => $data['news_allow_comments'],
                         'news_allow_ratings' => $data['news_allow_ratings'],
                         "news_sticky" => $data['news_sticky'],
                         "print_link" => BASEDIR."print.php?type=N&amp;item_id=".$data['news_id'],
                         'admin_actions' => $admin_actions,
                     ); */
         if (fusion_get_settings("create_og_tags")) {
             add_to_head("<meta property='og:title' content='" . $data['news_subject'] . "' />");
             add_to_head("<meta property='og:description' content='" . strip_tags($data['news_news']) . "' />");
             add_to_head("<meta property='og:site_name' content='" . fusion_get_settings('sitename') . "' />");
             add_to_head("<meta property='og:type' content='article' />");
             add_to_head("<meta property='og:url' content='" . $settings['siteurl'] . "infusions/news.php?readmore=" . $_GET['readmore'] . "' />");
             if ($data['news_image']) {
                 $og_image = IMAGES_N . $data['news_image'];
             } else {
                 $og_image = IMAGES_NC . $data['news_cat_image'];
             }
             $og_image = str_replace(BASEDIR, $settings['siteurl'], $og_image);
             add_to_head("<meta property='og:image' content='" . $og_image . "' />");
         }
         $_GET['cat_id'] = $data['news_cat_id'];
         set_title($news_subject . $locale['global_200'] . $locale['news_0004']);
         $news_cat_index = dbquery_tree(DB_NEWS_CATS, 'news_cat_id', 'news_cat_parent');
         $this->news_cat_breadcrumbs($news_cat_index);
         add_breadcrumb(array('link' => INFUSIONS . "news/news.php?readmore=" . $data['news_id'], 'title' => $data['news_subject']));
         $info['news_item'] = $news_info;
         $info['news_item']['page_count'] = $pagecount;
     } else {
         redirect(INFUSIONS . "news/news.php");
     }
     return $info;
 }
Пример #14
0
    redirect(BASEDIR . "error.php?code=404");
}
require_once THEMES . "templates/header.php";
require_once INCLUDES . "infusions_include.php";
if (file_exists(INFUSIONS . "articles/locale/" . LOCALESET . "articles.php")) {
    include INFUSIONS . "articles/locale/" . LOCALESET . "articles.php";
} else {
    include INFUSIONS . "articles/locale/English/articles.php";
}
include INFUSIONS . "articles/templates/articles.php";
$info = array();
$locale = fusion_get_locale();
add_to_title($locale['global_200'] . \PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name"));
add_breadcrumb(array('link' => INFUSIONS . 'articles/articles.php', 'title' => \PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name")));
$article_settings = get_settings("article");
$article_cat_index = dbquery_tree(DB_ARTICLE_CATS, 'article_cat_id', 'article_cat_parent', "" . (multilang_table("AR") ? "WHERE article_cat_language='" . LANGUAGE . "'" : '') . "");
/* Render Articles */
if (isset($_GET['article_id']) && isnum($_GET['article_id'])) {
    $result = dbquery("SELECT ta.article_subject, ta.article_snippet, ta.article_article, ta.article_keywords, ta.article_breaks,\n\t\tta.article_datestamp, ta.article_reads, ta.article_allow_comments, ta.article_allow_ratings,\n\t\ttac.article_cat_id, tac.article_cat_name,\n\t\ttu.user_id, tu.user_name, tu.user_status, tu.user_avatar, tu.user_joined, tu.user_level\n\t\tFROM " . DB_ARTICLES . " ta\n\t\tINNER JOIN " . DB_ARTICLE_CATS . " tac ON ta.article_cat=tac.article_cat_id\n\t\tLEFT JOIN " . DB_USERS . " tu ON ta.article_name=tu.user_id\n\t\t" . (multilang_table("AR") ? "WHERE tac.article_cat_language='" . LANGUAGE . "' AND" : "WHERE") . " " . groupaccess('article_visibility') . " AND article_id='" . $_GET['article_id'] . "' AND article_draft='0'");
    if (dbrows($result) > 0) {
        $data = dbarray($result);
        require_once INCLUDES . "comments_include.php";
        require_once INCLUDES . "ratings_include.php";
        $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) ? $_GET['rowstart'] : 0;
        if ($_GET['rowstart'] == 0 && empty($_POST)) {
            dbquery("UPDATE " . DB_ARTICLES . " SET article_reads=article_reads+1 WHERE article_id='" . $_GET['article_id'] . "'");
        }
        $article = preg_split("/<!?--\\s*pagebreak\\s*-->/i", parse_textarea($data['article_article']));
        $pagecount = count($article);
        $article_subject = stripslashes($data['article_subject']);
        add_breadcrumb(array('link' => INFUSIONS . 'articles/articles.php?cat_id=' . $data['article_cat_id'], 'title' => $data['article_cat_name']));
Пример #15
0
}
require_once THEMES . "templates/header.php";
require_once INCLUDES . "infusions_include.php";
if (file_exists(INFUSIONS . "news/locale/" . LOCALESET . "news.php")) {
    include INFUSIONS . "news/locale/" . LOCALESET . "news.php";
} else {
    include INFUSIONS . "news/locale/English/news.php";
}
$news_settings = get_settings("news");
require_once INFUSIONS . "news/templates/news.php";
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) {
    $_GET['rowstart'] = 0;
    $rows = 0;
}
// Predefined variables, do not edit these values
$news_cat_index = dbquery_tree(DB_NEWS_CATS, 'news_cat_id', 'news_cat_parent');
$info = array();
$i = 0;
add_to_title($locale['global_200'] . \PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name"));
add_breadcrumb(array('link' => INFUSIONS . 'news/news.php', 'title' => \PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name")));
if (isset($_GET['readmore']) && isnum($_GET['readmore'])) {
    $result = dbquery("SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status, tu.user_avatar , tu.user_level, tu.user_joined,\n\t \t\t\t\tSUM(tr.rating_vote) AS sum_rating,\n\t\t\t\t\tCOUNT(tr.rating_item_id) AS count_votes,\n\t\t\t\t\tCOUNT(td.comment_item_id) AS count_comment\n\t\t\t\t\tFROM " . DB_NEWS . " tn\n\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu ON tn.news_name=tu.user_id\n\t\t\t\t\tLEFT JOIN " . DB_NEWS_CATS . " tc ON tn.news_cat=tc.news_cat_id\n\t\t\t\t\tLEFT JOIN " . DB_RATINGS . " tr ON tr.rating_item_id = tn.news_id AND tr.rating_type='N'\n\t\t\t\t\tLEFT JOIN " . DB_COMMENTS . " td ON td.comment_item_id = tn.news_id AND td.comment_type='N' AND td.comment_hidden='0'\n\t\t\t\t\t" . (multilang_table("NS") ? "WHERE news_language='" . LANGUAGE . "' AND" : "WHERE") . " " . groupaccess('news_visibility') . "\n\t\t\t\t\tAND news_id='" . $_GET['readmore'] . "' AND news_draft='0'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
    if (dbrows($result) > 0) {
        include INCLUDES . "comments_include.php";
        include INCLUDES . "ratings_include.php";
        $data = dbarray($result);
        if ($data['news_keywords'] !== "") {
            set_meta("keywords", $data['news_keywords']);
        }
        if (!isset($_POST['post_comment']) && !isset($_POST['post_rating'])) {
            $result2 = dbquery("UPDATE " . DB_NEWS . " SET news_reads=news_reads+1 WHERE news_id='" . $_GET['readmore'] . "'");
Пример #16
0
 function forum_newtopic()
 {
     global $settings, $locale;
     if (isset($_POST['select_forum'])) {
         $_POST['forum_sel'] = isset($_POST['forum_sel']) && isnum($_POST['forum_sel']) ? $_POST['forum_sel'] : 0;
         redirect(FORUM . 'post.php?action=newthread&forum_id=' . $_POST['forum_sel']);
     }
     echo openmodal('newtopic', $locale['forum_0057'], array('button_id' => 'newtopic', 'class' => 'modal-md'));
     $index = dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
     $result = dbquery("SELECT a.forum_id, a.forum_name, b.forum_name as forum_cat_name, a.forum_post\n\t\t FROM " . DB_FORUMS . " a\n\t\t LEFT JOIN " . DB_FORUMS . " b ON a.forum_cat=b.forum_id\n\t\t WHERE " . groupaccess('a.forum_access') . " " . (multilang_table("FO") ? "AND a.forum_language='" . LANGUAGE . "' AND" : "AND") . "\n\t\t (a.forum_type ='2' or a.forum_type='4') AND a.forum_post < " . USER_LEVEL_PUBLIC . " AND a.forum_lock !='1' ORDER BY a.forum_cat ASC, a.forum_branch ASC, a.forum_name ASC");
     $options = array();
     if (dbrows($result) > 0) {
         while ($data = dbarray($result)) {
             $depth = get_depth($index, $data['forum_id']);
             if (checkgroup($data['forum_post'])) {
                 $options[$data['forum_id']] = str_repeat("&#8212;", $depth) . $data['forum_name'] . " " . ($data['forum_cat_name'] ? "(" . $data['forum_cat_name'] . ")" : '');
             }
         }
         echo "<div class='well clearfix m-t-10'>\n";
         echo form_select('forum_sel', $locale['forum_0395'], '', array('options' => $options, 'inline' => 1, 'width' => '100%'));
         echo "<div class='display-inline-block col-xs-12 col-sm-offset-3'>\n";
         echo form_button('select_forum', $locale['forum_0396'], 'select_forum', array('class' => 'btn-primary btn-sm'));
         echo "</div>\n";
         echo "</div>\n";
         echo closeform();
     } else {
         echo "<div class='well text-center'>\n";
         echo $locale['forum_0328'];
         echo "</div>\n";
     }
     echo closemodal();
 }
Пример #17
0
 /**
  * New thread
  */
 public function set_newThreadInfo()
 {
     $userdata = fusion_get_userdata();
     $locale = fusion_get_locale("", FORUM_LOCALE);
     $locale += fusion_get_locale("", FORUM_TAGS_LOCALE);
     $forum_settings = ForumServer::get_forum_settings();
     // @todo: Reduce lines and optimize further
     if (iMEMBER) {
         // New thread directly to a specified forum
         if (!empty($_GET['forum_id']) && ForumServer::verify_forum($_GET['forum_id'])) {
             add_to_title($locale['forum_0000']);
             add_to_meta("description", $locale['forum_0000']);
             add_breadcrumb(array("link" => FORUM . "index.php", "title" => $locale['forum_0000']));
             add_to_title($locale['global_201'] . $locale['forum_0057']);
             $forum_data = dbarray(dbquery("SELECT f.*, f2.forum_name AS forum_cat_name\n\t\t\t\tFROM " . DB_FORUMS . " f\n\t\t\t\tLEFT JOIN " . DB_FORUMS . " f2 ON f.forum_cat=f2.forum_id\n\t\t\t\tWHERE f.forum_id='" . intval($_GET['forum_id']) . "'\n\t\t\t\tAND " . groupaccess('f.forum_access') . "\n\t\t\t\t"));
             if ($forum_data['forum_type'] == 1) {
                 redirect(INFUSIONS . "forum/index.php");
             }
             // Use the new permission settings
             self::setPermission($forum_data);
             $forum_data['lock_edit'] = $forum_settings['forum_edit_lock'];
             if (self::getPermission("can_post") && self::getPermission("can_access")) {
                 add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php?viewforum&amp;forum_id=' . $forum_data['forum_id'] . '&amp;parent_id=' . $forum_data['forum_cat'], 'title' => $forum_data['forum_name']));
                 add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php?viewforum&amp;forum_id=' . $forum_data['forum_id'] . '&amp;parent_id=' . $forum_data['forum_cat'], 'title' => $locale['forum_0057']));
                 /**
                  * Generate a poll form
                  */
                 $poll_form = "";
                 if (self::getPermission("can_create_poll")) {
                     // initial data to push downwards
                     $pollData = array('thread_id' => 0, 'forum_poll_title' => !empty($_POST['forum_poll_title']) ? form_sanitizer($_POST['forum_poll_title'], '', 'forum_poll_title') : '', 'forum_poll_start' => time(), 'forum_poll_length' => 2, 'forum_poll_votes' => 0);
                     // counter of lengths
                     $option_data[1] = "";
                     $option_data[2] = "";
                     // Do a validation if checked add_poll
                     if (isset($_POST['add_poll'])) {
                         $pollData = array('thread_id' => 0, 'forum_poll_title' => isset($_POST['forum_poll_title']) ? form_sanitizer($_POST['forum_poll_title'], '', 'forum_poll_title') : '', 'forum_poll_start' => time(), 'forum_poll_length' => count($option_data), 'forum_poll_votes' => 0);
                         // calculate poll lengths
                         if (!empty($_POST['poll_options']) && is_array($_POST['poll_options'])) {
                             foreach ($_POST['poll_options'] as $i => $value) {
                                 $option_data[$i] = form_sanitizer($value, '', "poll_options[{$i}]");
                             }
                         }
                     }
                     if (isset($_POST['add_poll_option']) && isset($_POST['poll_options'])) {
                         // reindex the whole array with blank values.
                         foreach ($_POST['poll_options'] as $i => $value) {
                             $option_data[$i] = form_sanitizer($value, '', "poll_options[{$i}]");
                         }
                         if (\defender::safe()) {
                             $option_data = array_values(array_filter($option_data));
                             array_unshift($option_data, NULL);
                             unset($option_data[0]);
                             $pollData['forum_poll_length'] = count($option_data);
                         }
                         array_push($option_data, '');
                     }
                     $poll_field = '';
                     $poll_field['poll_field'] = form_text('forum_poll_title', $locale['forum_0604'], $pollData['forum_poll_title'], array('max_length' => 255, 'placeholder' => $locale['forum_0604a'], 'inline' => TRUE, 'required' => TRUE));
                     for ($i = 1; $i <= count($option_data); $i++) {
                         $poll_field['poll_field'] .= form_text("poll_options[{$i}]", sprintf($locale['forum_0606'], $i), $option_data[$i], array('max_length' => 255, 'placeholder' => $locale['forum_0605'], 'inline' => TRUE, 'required' => $i <= 2 ? TRUE : FALSE));
                     }
                     $poll_field['poll_field'] .= "<div class='col-xs-12 col-sm-offset-3'>\n";
                     $poll_field['poll_field'] .= form_button('add_poll_option', $locale['forum_0608'], $locale['forum_0608'], array('class' => 'btn-primary btn-sm'));
                     $poll_field['poll_field'] .= "</div>\n";
                     $info = array('title' => $locale['forum_0366'], 'description' => $locale['forum_0630'], 'field' => $poll_field);
                     ob_start();
                     echo form_checkbox("add_poll", $locale['forum_0366'], isset($_POST['add_poll']) ? TRUE : FALSE, array('reverse_label' => TRUE));
                     echo "<div id='poll_form' class='poll-form' style='display:none;'>\n";
                     echo "<div class='well clearfix'>\n";
                     echo "<!--pre_form-->\n";
                     echo $info['field']['poll_field'];
                     echo "</div>\n";
                     echo "</div>\n";
                     $poll_form = ob_get_contents();
                     ob_end_clean();
                 }
                 $thread_data = array('forum_id' => $forum_data['forum_id'], 'thread_id' => 0, 'thread_subject' => isset($_POST['thread_subject']) ? form_sanitizer($_POST['thread_subject'], '', 'thread_subject') : '', 'thread_tags' => isset($_POST['thread_tags']) ? form_sanitizer($_POST['thread_tags'], '', 'thread_tags') : '', 'thread_author' => $userdata['user_id'], 'thread_views' => 0, 'thread_lastpost' => time(), 'thread_lastpostid' => 0, 'thread_lastuser' => $userdata['user_id'], 'thread_postcount' => 1, 'thread_poll' => 0, 'thread_sticky' => isset($_POST['thread_sticky']) ? 1 : 0, 'thread_locked' => isset($_POST['thread_sticky']) ? 1 : 0, 'thread_hidden' => 0);
                 $post_data = array('forum_id' => $forum_data['forum_id'], 'forum_cat' => $forum_data['forum_cat'], 'thread_id' => 0, 'post_id' => 0, 'post_message' => isset($_POST['post_message']) ? form_sanitizer($_POST['post_message'], '', 'post_message') : '', 'post_showsig' => isset($_POST['post_showsig']) ? 1 : 0, 'post_smileys' => !isset($_POST['post_smileys']) || isset($_POST['post_message']) && preg_match("#(\\[code\\](.*?)\\[/code\\]|\\[geshi=(.*?)\\](.*?)\\[/geshi\\]|\\[php\\](.*?)\\[/php\\])#si", $_POST['post_message']) ? 0 : 1, 'post_author' => $userdata['user_id'], 'post_datestamp' => time(), 'post_ip' => USER_IP, 'post_ip_type' => USER_IP_TYPE, 'post_edituser' => 0, 'post_edittime' => 0, 'post_editreason' => '', 'post_hidden' => 0, 'notify_me' => isset($_POST['notify_me']) ? 1 : 0, 'post_locked' => 0);
                 // Execute post new thread
                 if (isset($_POST['post_newthread']) && \defender::safe()) {
                     require_once INCLUDES . "flood_include.php";
                     // all data is sanitized here.
                     if (!flood_control("post_datestamp", DB_FORUM_POSTS, "post_author='" . $userdata['user_id'] . "'")) {
                         // have notice
                         if (\defender::safe()) {
                             // create a new thread.
                             dbquery_insert(DB_FORUM_THREADS, $thread_data, 'save', array('primary_key' => 'thread_id', 'keep_session' => TRUE));
                             $post_data['thread_id'] = dblastid();
                             $pollData['thread_id'] = dblastid();
                             dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id', 'keep_session' => TRUE));
                             $post_data['post_id'] = dblastid();
                             // Attach files if permitted
                             if (!empty($_FILES) && is_uploaded_file($_FILES['file_attachments']['tmp_name'][0]) && self::getPermission("can_upload_attach")) {
                                 $upload = form_sanitizer($_FILES['file_attachments'], '', 'file_attachments');
                                 if ($upload['error'] == 0) {
                                     foreach ($upload['target_file'] as $arr => $file_name) {
                                         $attach_data = array('thread_id' => $post_data['thread_id'], 'post_id' => $post_data['post_id'], 'attach_name' => $file_name, 'attach_mime' => $upload['type'][$arr], 'attach_size' => $upload['source_size'][$arr], 'attach_count' => '0');
                                         dbquery_insert(DB_FORUM_ATTACHMENTS, $attach_data, "save", array('keep_session' => TRUE));
                                     }
                                 }
                             }
                             dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . intval($post_data['post_author']) . "'");
                             // Update stats in forum and threads
                             // find all parents and update them
                             $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $post_data['forum_id']);
                             if (is_array($list_of_forums)) {
                                 foreach ($list_of_forums as $forum_id) {
                                     $forum_update_sql = "\n                                        UPDATE " . DB_FORUMS . " SET forum_lastpost='" . intval($post_data['post_datestamp']) . "',\n                                        forum_postcount=forum_postcount+1,\n                                        forum_threadcount=forum_threadcount+1,\n                                        forum_lastpostid='" . intval($post_data['post_id']) . "',\n                                        forum_lastuser='******'post_author']) . "' WHERE forum_id='" . intval($forum_id) . "'\n                                        ";
                                     dbquery($forum_update_sql);
                                 }
                             }
                             // update current forum
                             dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . $post_data['post_datestamp'] . "', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $post_data['forum_id'] . "'");
                             // update current thread
                             dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_lastpost='" . $post_data['post_datestamp'] . "', thread_lastpostid='" . $post_data['post_id'] . "', thread_lastuser='******'post_author'] . "' WHERE thread_id='" . $post_data['thread_id'] . "'");
                             // set notify
                             if ($forum_settings['thread_notify'] && isset($_POST['notify_me']) && $post_data['thread_id']) {
                                 if (!dbcount("(thread_id)", DB_FORUM_THREAD_NOTIFY, "thread_id='" . $post_data['thread_id'] . "' AND notify_user='******'post_author'] . "'")) {
                                     dbquery("INSERT INTO " . DB_FORUM_THREAD_NOTIFY . " (thread_id, notify_datestamp, notify_user, notify_status) VALUES('" . $post_data['thread_id'] . "', '" . $post_data['post_datestamp'] . "', '" . $post_data['post_author'] . "', '1')");
                                 }
                             }
                             // Add poll if exist
                             if (!empty($option_data) && isset($_POST['add_poll'])) {
                                 dbquery_insert(DB_FORUM_POLLS, $pollData, 'save');
                                 $poll_option_data['thread_id'] = $pollData['thread_id'];
                                 $i = 1;
                                 foreach ($option_data as $option_text) {
                                     if ($option_text) {
                                         $poll_option_data['forum_poll_option_id'] = $i;
                                         $poll_option_data['forum_poll_option_text'] = $option_text;
                                         $poll_option_data['forum_poll_option_votes'] = 0;
                                         dbquery_insert(DB_FORUM_POLL_OPTIONS, $poll_option_data, 'save');
                                         $i++;
                                     }
                                 }
                                 dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_poll='1' WHERE thread_id='" . $pollData['thread_id'] . "'");
                             }
                         }
                         if (\defender::safe()) {
                             redirect(INFUSIONS . "forum/postify.php?post=new&error=0&amp;forum_id=" . intval($post_data['forum_id']) . "&amp;parent_id=" . intval($post_data['forum_cat']) . "&amp;thread_id=" . intval($post_data['thread_id'] . ""));
                         }
                     }
                 }
                 $this->info = array('title' => $locale['forum_0057'], 'description' => '', 'openform' => openform('input_form', 'post', FORUM . "newthread.php?forum_id=" . $post_data['forum_id'], array('enctype' => self::getPermission("can_upload_attach"))), 'closeform' => closeform(), 'forum_id_field' => '', 'thread_id_field' => '', "forum_field" => "", 'subject_field' => form_text('thread_subject', $locale['forum_0600'], $thread_data['thread_subject'], array('required' => 1, 'placeholder' => $locale['forum_2001'], 'error_text' => '', 'class' => 'm-t-20 m-b-20')), 'tags_field' => form_select('thread_tags[]', $locale['forum_tag_0100'], $thread_data['thread_tags'], array('options' => $this->tag()->get_TagOpts(TRUE), 'width' => '100%', 'multiple' => TRUE, 'delimiter' => '.', 'max_select' => 3)), 'message_field' => form_textarea('post_message', $locale['forum_0601'], $post_data['post_message'], array('required' => 1, 'error_text' => '', 'autosize' => 1, 'no_resize' => 1, 'preview' => 1, 'form_name' => 'input_form', 'bbcode' => 1)), 'attachment_field' => self::getPermission("can_upload_attach") ? form_fileinput('file_attachments[]', $locale['forum_0557'], "", array('input_id' => 'file_attachments', 'upload_path' => INFUSIONS . 'forum/attachments/', 'type' => 'object', 'preview_off' => TRUE, "multiple" => TRUE, "inline" => FALSE, 'max_count' => $forum_settings['forum_attachmax_count'], 'valid_ext' => $forum_settings['forum_attachtypes'], "class" => "m-b-0")) . " <div class='m-b-20'>\n<small>\n                            " . sprintf($locale['forum_0559'], parsebytesize($forum_settings['forum_attachmax']), str_replace('|', ', ', $forum_settings['forum_attachtypes']), $forum_settings['forum_attachmax_count']) . "</small>\n</div>\n" : "", 'poll_form' => $poll_form, 'smileys_field' => form_checkbox('post_smileys', $locale['forum_0622'], $post_data['post_smileys'], array('class' => 'm-b-0', 'reverse_label' => TRUE)), 'signature_field' => array_key_exists("user_sig", $userdata) && $userdata['user_sig'] ? form_checkbox('post_showsig', $locale['forum_0623'], $post_data['post_showsig'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'sticky_field' => iMOD || iSUPERADMIN ? form_checkbox('thread_sticky', $locale['forum_0620'], $thread_data['thread_sticky'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'lock_field' => iMOD || iSUPERADMIN ? form_checkbox('thread_locked', $locale['forum_0621'], $thread_data['thread_locked'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'edit_reason_field' => '', 'delete_field' => '', 'hide_edit_field' => '', 'post_locked_field' => '', 'notify_field' => $forum_settings['thread_notify'] ? form_checkbox('notify_me', $locale['forum_0626'], $post_data['notify_me'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'post_buttons' => form_button('post_newthread', $locale['forum_0057'], $locale['forum_0057'], array('class' => 'btn-primary btn-sm')) . form_button('cancel', $locale['cancel'], $locale['cancel'], array('class' => 'btn-default btn-sm m-l-10')), 'last_posts_reply' => '');
                 // add a jquery to toggle the poll form
                 add_to_jquery("\n                        if (\$('#add_poll').is(':checked')) {\n                            \$('#poll_form').show();\n                        } else {\n                            \$('#poll_form').hide();\n                        }\n                        \$('#add_poll').bind('click', function() {\n                            if (\$(this).is(':checked')) {\n                                \$('#poll_form').slideDown();\n                            } else {\n                                \$('#poll_form').slideUp();\n                            }\n                        });\n                    ");
             } else {
                 redirect(FORUM . "index.php");
             }
         } else {
             /*
              * Quick New Forum Posting.
              * Does not require to run permissions.
              * Does not contain forum poll.
              * Does not contain attachment
              */
             if (!dbcount("(forum_id)", DB_FORUMS, "forum_type !='1'")) {
                 redirect(INFUSIONS . "forum/index.php");
             }
             if (!dbcount("(forum_id)", DB_FORUMS, "forum_language ='" . LANGUAGE . "'")) {
                 redirect(INFUSIONS . "forum/index.php");
             }
             add_breadcrumb(array("link" => FORUM . "newthread.php?forum_id=0", "title" => $locale['forum_0057']));
             $thread_data = array('forum_id' => isset($_POST['forum_id']) ? form_sanitizer($_POST['forum_id'], 0, "forum_id") : 0, 'thread_id' => 0, 'thread_subject' => isset($_POST['thread_subject']) ? form_sanitizer($_POST['thread_subject'], '', 'thread_subject') : '', 'thread_tags' => isset($_POST['thread_tags']) ? form_sanitizer($_POST['thread_tags'], '', 'thread_tags') : '', 'thread_author' => $userdata['user_id'], 'thread_views' => 0, 'thread_lastpost' => time(), 'thread_lastpostid' => 0, 'thread_lastuser' => $userdata['user_id'], 'thread_postcount' => 1, 'thread_poll' => 0, 'thread_sticky' => isset($_POST['thread_sticky']) ? TRUE : FALSE, 'thread_locked' => isset($_POST['thread_sticky']) ? TRUE : FALSE, 'thread_hidden' => 0);
             $post_data = array('forum_id' => isset($_POST['forum_id']) ? form_sanitizer($_POST['forum_id'], 0, "forum_id") : 0, "forum_cat" => 0, 'thread_id' => 0, 'post_id' => 0, 'post_message' => isset($_POST['post_message']) ? form_sanitizer($_POST['post_message'], '', 'post_message') : '', 'post_showsig' => isset($_POST['post_showsig']) ? TRUE : FALSE, 'post_smileys' => !isset($_POST['post_smileys']) || isset($_POST['post_message']) && preg_match("#(\\[code\\](.*?)\\[/code\\]|\\[geshi=(.*?)\\](.*?)\\[/geshi\\]|\\[php\\](.*?)\\[/php\\])#si", $_POST['post_message']) ? FALSE : TRUE, 'post_author' => $userdata['user_id'], 'post_datestamp' => time(), 'post_ip' => USER_IP, 'post_ip_type' => USER_IP_TYPE, 'post_edituser' => 0, 'post_edittime' => 0, 'post_editreason' => '', 'post_hidden' => 0, 'notify_me' => isset($_POST['notify_me']) ? TRUE : FALSE, 'post_locked' => 0);
             // go for a new thread posting.
             // check data
             // and validate
             // do not run attach, and do not run poll.
             if (isset($_POST['post_newthread']) && \defender::safe()) {
                 require_once INCLUDES . "flood_include.php";
                 // all data is sanitized here.
                 if (!flood_control("post_datestamp", DB_FORUM_POSTS, "post_author='" . $userdata['user_id'] . "'")) {
                     // have notice
                     if (ForumServer::verify_forum($thread_data['forum_id'])) {
                         $forum_data = dbarray(dbquery("SELECT f.*, f2.forum_name AS forum_cat_name\n                            FROM " . DB_FORUMS . " f\n                            LEFT JOIN " . DB_FORUMS . " f2 ON f.forum_cat=f2.forum_id\n                            WHERE f.forum_id='" . intval($thread_data['forum_id']) . "'\n                            AND " . groupaccess('f.forum_access') . "\n                            "));
                         if ($forum_data['forum_type'] == 1) {
                             redirect(INFUSIONS . "forum/index.php");
                         }
                         // Use the new permission settings
                         self::setPermission($forum_data);
                         $forum_data['lock_edit'] = $forum_settings['forum_edit_lock'];
                         if (self::getPermission("can_post") && self::getPermission("can_access")) {
                             $post_data['forum_cat'] = $forum_data['forum_cat'];
                             // create a new thread.
                             dbquery_insert(DB_FORUM_THREADS, $thread_data, 'save', array('primary_key' => 'thread_id', 'keep_session' => TRUE));
                             $post_data['thread_id'] = dblastid();
                             dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id', 'keep_session' => TRUE));
                             $post_data['post_id'] = dblastid();
                             dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . $post_data['post_author'] . "'");
                             // Update stats in forum and threads
                             // find all parents and update them
                             $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $post_data['forum_id']);
                             foreach ($list_of_forums as $fid) {
                                 dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $fid . "'");
                             }
                             // update current forum
                             dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost=''" . time() . "'', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $post_data['forum_id'] . "'");
                             // update current thread
                             dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_lastpost=''" . time() . "'', thread_lastpostid='" . $post_data['post_id'] . "', thread_lastuser='******'post_author'] . "' WHERE thread_id='" . $post_data['thread_id'] . "'");
                             // set notify
                             if ($forum_settings['thread_notify'] && isset($_POST['notify_me']) && $post_data['thread_id']) {
                                 if (!dbcount("(thread_id)", DB_FORUM_THREAD_NOTIFY, "thread_id='" . $post_data['thread_id'] . "' AND notify_user='******'post_author'] . "'")) {
                                     dbquery("INSERT INTO " . DB_FORUM_THREAD_NOTIFY . " (thread_id, notify_datestamp, notify_user, notify_status) VALUES('" . $post_data['thread_id'] . "', '" . time() . "', '" . $post_data['post_author'] . "', 1)");
                                 }
                             }
                             if (\defender::safe()) {
                                 redirect(INFUSIONS . "forum/postify.php?post=new&error=0&amp;forum_id=" . intval($post_data['forum_id']) . "&amp;parent_id=" . intval($post_data['forum_cat']) . "&amp;thread_id=" . intval($post_data['thread_id'] . ""));
                             }
                         } else {
                             addNotice("danger", $locale['forum_0186']);
                         }
                     } else {
                         addNotice("danger", $locale['forum_0187']);
                         redirect(INFUSIONS . "forum/index.php");
                     }
                 }
             }
             //Disable all parents
             $disabled_opts = array();
             $disable_query = "\n                SELECT forum_id FROM " . DB_FORUMS . " WHERE forum_type='1'\n                " . (multilang_table("FO") ? "AND forum_language='" . LANGUAGE . "'" : "") . "\n                ";
             $disable_query = dbquery(" {$disable_query} ");
             if (dbrows($disable_query) > 0) {
                 while ($d_forum = dbarray($disable_query)) {
                     $disabled_opts = $d_forum['forum_id'];
                 }
             }
             $this->info = array('title' => $locale['forum_0057'], 'description' => '', 'openform' => openform('input_form', 'post', FORUM . "newthread.php", array('enctype' => FALSE)), 'closeform' => closeform(), 'forum_id_field' => '', 'thread_id_field' => '', 'forum_field' => form_select_tree("forum_id", $locale['forum_0395'], $thread_data['forum_id'], array("required" => TRUE, "width" => "320px", "no_root" => TRUE, "disable_opts" => $disabled_opts, "query" => multilang_table("FO") ? "WHERE forum_language='" . LANGUAGE . "'" : ""), DB_FORUMS, "forum_name", "forum_id", "forum_cat"), 'subject_field' => form_text('thread_subject', $locale['forum_0600'], $thread_data['thread_subject'], array('required' => 1, 'placeholder' => $locale['forum_2001'], 'error_text' => '', 'class' => 'm-t-20 m-b-20')), 'tags_field' => form_select('thread_tags[]', $locale['forum_tag_0100'], $thread_data['thread_tags'], array('options' => $this->tag()->get_TagOpts(), 'width' => '100%', 'multiple' => TRUE, 'delimiter' => '.', 'max_select' => 3)), 'message_field' => form_textarea('post_message', $locale['forum_0601'], $post_data['post_message'], array('required' => 1, 'error_text' => '', 'autosize' => 1, 'no_resize' => 1, 'preview' => 1, 'form_name' => 'input_form', 'bbcode' => 1)), 'attachment_field' => "", 'poll_form' => "", 'smileys_field' => form_checkbox('post_smileys', $locale['forum_0622'], $post_data['post_smileys'], array('class' => 'm-b-0', 'reverse_label' => TRUE)), 'signature_field' => array_key_exists("user_sig", $userdata) && $userdata['user_sig'] ? form_checkbox('post_showsig', $locale['forum_0623'], $post_data['post_showsig'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'sticky_field' => iSUPERADMIN ? form_checkbox('thread_sticky', $locale['forum_0620'], $thread_data['thread_sticky'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'lock_field' => iSUPERADMIN ? form_checkbox('thread_locked', $locale['forum_0621'], $thread_data['thread_locked'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'edit_reason_field' => '', 'delete_field' => '', 'hide_edit_field' => '', 'post_locked_field' => '', 'notify_field' => $forum_settings['thread_notify'] ? form_checkbox('notify_me', $locale['forum_0626'], $post_data['notify_me'], array('class' => 'm-b-0', 'reverse_label' => TRUE)) : '', 'post_buttons' => form_button('post_newthread', $locale['forum_0057'], $locale['forum_0057'], array('class' => 'btn-primary btn-sm')) . form_button('cancel', $locale['cancel'], $locale['cancel'], array('class' => 'btn-default btn-sm m-l-10')), 'last_posts_reply' => '');
         }
     } else {
         redirect(INFUSIONS . 'forum/index.php');
     }
 }
Пример #18
0
 public function render_reply_form()
 {
     global $locale, $userdata, $forum_settings, $defender;
     $thread_data = $this->thread_info['thread'];
     if ((!iMOD or !iSUPERADMIN) && $thread_data['thread_locked']) {
         redirect(INFUSIONS . 'forum/index.php');
     }
     if ($this->getThreadPermission("can_reply")) {
         add_to_title($locale['global_201'] . $locale['forum_0503']);
         add_breadcrumb(array('link' => '', 'title' => $locale['forum_0503']));
         // field data
         $post_data = array('post_id' => 0, 'forum_id' => $this->thread_info['thread']['forum_id'], 'thread_id' => $this->thread_info['thread']['thread_id'], 'post_message' => isset($_POST['post_message']) ? form_sanitizer($_POST['post_message'], '', 'post_message') : '', 'post_showsig' => isset($_POST['post_showsig']) ? 1 : 0, 'post_smileys' => isset($_POST['post_smileys']) || isset($_POST['post_message']) && preg_match("#(\\[code\\](.*?)\\[/code\\]|\\[geshi=(.*?)\\](.*?)\\[/geshi\\]|\\[php\\](.*?)\\[/php\\])#si", $_POST['post_message']) ? 1 : 0, 'post_author' => $userdata['user_id'], 'post_datestamp' => time(), 'post_ip' => USER_IP, 'post_ip_type' => USER_IP_TYPE, 'post_edituser' => 0, 'post_edittime' => 0, 'post_editreason' => '', 'post_hidden' => 0, 'notify_me' => 0, 'post_locked' => $forum_settings['forum_edit_lock'] || isset($_POST['post_locked']) ? 1 : 0);
         // execute form post actions
         if (isset($_POST['post_reply'])) {
             require_once INCLUDES . "flood_include.php";
             // all data is sanitized here.
             if (!flood_control("post_datestamp", DB_FORUM_POSTS, "post_author='" . $userdata['user_id'] . "'")) {
                 // have notice
                 $update_forum_lastpost = FALSE;
                 if ($defender->safe()) {
                     // Prepare forum merging action
                     $last_post_author = dbarray(dbquery("SELECT post_author FROM " . DB_FORUM_POSTS . " WHERE thread_id='" . $thread_data['thread_id'] . "' ORDER BY post_id DESC LIMIT 1"));
                     if ($last_post_author['post_author'] == $post_data['post_author'] && $thread_data['forum_merge']) {
                         $last_message = dbarray(dbquery("SELECT post_id, post_message FROM " . DB_FORUM_POSTS . " WHERE thread_id='" . $thread_data['thread_id'] . "' ORDER BY post_id DESC"));
                         $post_data['post_id'] = $last_message['post_id'];
                         $post_data['post_message'] = $last_message['post_message'] . "\n\n" . $locale['forum_0640'] . " " . showdate("longdate", time()) . ":\n" . $post_data['post_message'];
                         dbquery_insert(DB_FORUM_POSTS, $post_data, 'update', array('primary_key' => 'post_id', 'keep_session' => TRUE));
                     } else {
                         $update_forum_lastpost = TRUE;
                         dbquery_insert(DB_FORUM_POSTS, $post_data, 'save', array('primary_key' => 'post_id', 'keep_session' => TRUE));
                         $post_data['post_id'] = dblastid();
                         if (!defined("FUSION_NULL")) {
                             dbquery("UPDATE " . DB_USERS . " SET user_posts=user_posts+1 WHERE user_id='" . $post_data['post_author'] . "'");
                         }
                     }
                     // Attach files if permitted
                     if (!empty($_FILES) && is_uploaded_file($_FILES['file_attachments']['tmp_name'][0]) && $this->getThreadPermission("can_upload_attach")) {
                         $upload = form_sanitizer($_FILES['file_attachments'], '', 'file_attachments');
                         if ($upload['error'] == 0) {
                             foreach ($upload['target_file'] as $arr => $file_name) {
                                 $adata = array('thread_id' => $thread_data['thread_id'], 'post_id' => $post_data['post_id'], 'attach_name' => $file_name, 'attach_mime' => $upload['type'][$arr], 'attach_size' => $upload['source_size'][$arr], 'attach_count' => 0);
                                 dbquery_insert(DB_FORUM_ATTACHMENTS, $adata, "save", array('keep_session' => TRUE));
                             }
                         }
                     }
                     // Update stats in forum and threads
                     if ($update_forum_lastpost == TRUE) {
                         // find all parents and update them
                         $list_of_forums = get_all_parent(dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat'), $thread_data['forum_id']);
                         foreach ($list_of_forums as $fid) {
                             dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $fid . "'");
                         }
                         // update current forum
                         dbquery("UPDATE " . DB_FORUMS . " SET forum_lastpost='" . time() . "', forum_postcount=forum_postcount+1, forum_lastpostid='" . $post_data['post_id'] . "', forum_lastuser='******'post_author'] . "' WHERE forum_id='" . $thread_data['forum_id'] . "'");
                         // update current thread
                         dbquery("UPDATE " . DB_FORUM_THREADS . " SET thread_lastpost='" . time() . "', thread_lastpostid='" . $post_data['post_id'] . "', thread_postcount=thread_postcount+1, thread_lastuser='******'post_author'] . "' WHERE thread_id='" . $thread_data['thread_id'] . "'");
                     }
                     if ($forum_settings['thread_notify'] && isset($_POST['notify_me'])) {
                         if (!dbcount("(thread_id)", DB_FORUM_THREAD_NOTIFY, "thread_id='" . $thread_data['thread_id'] . "' AND notify_user='******'post_author'] . "'")) {
                             dbquery("INSERT INTO " . DB_FORUM_THREAD_NOTIFY . " (thread_id, notify_datestamp, notify_user, notify_status) VALUES('" . $thread_data['thread_id'] . "', '" . time() . "', '" . $post_data['post_author'] . "', '1')");
                         }
                     }
                     if ($defender->safe()) {
                         redirect(INFUSIONS . "forum/postify.php?post=reply&error=0&amp;forum_id=" . intval($post_data['forum_id']) . "&amp;thread_id=" . intval($post_data['thread_id']) . "&amp;post_id=" . intval($post_data['post_id']));
                     }
                 }
             }
         }
         // template data
         $form_action = INFUSIONS . "forum/viewthread.php?action=reply&amp;forum_id=" . $thread_data['forum_id'] . "&amp;thread_id=" . $thread_data['thread_id'];
         // Quote Get
         if (isset($_GET['quote']) && isnum($_GET['quote'])) {
             $quote_result = dbquery("SELECT a.post_message, b.user_name\n\t\t\t\t\t\t\t\t\t\tFROM " . DB_FORUM_POSTS . " a\n\t\t\t\t\t\t\t\t\t\tINNER JOIN " . DB_USERS . " b ON a.post_author=b.user_id\n\t\t\t\t\t\t\t\t\t\tWHERE thread_id='" . $thread_data['thread_id'] . "' and post_id='" . $_GET['quote'] . "'");
             if (dbrows($quote_result) > 0) {
                 $quote_data = dbarray($quote_result);
                 // do not do this. to silently inject.
                 $post_data['post_message'] = "[quote name=" . $quote_data['user_name'] . " post=" . $_GET['quote'] . "]@" . $quote_data['user_name'] . " - " . strip_bbcodes($quote_data['post_message']) . "[/quote]" . $post_data['post_message'];
                 $form_action .= "&amp;post_id=" . $_GET['post_id'] . "&amp;quote=" . $_GET['quote'];
             } else {
                 redirect(INFUSIONS . "forum/index.php");
             }
         }
         $info = array('title' => $locale['forum_0503'], 'description' => $locale['forum_2000'] . $thread_data['thread_subject'], 'openform' => openform('input_form', 'post', $form_action, array('enctype' => $this->getThreadPermission("can_upload_attach") ? TRUE : FALSE, 'max_tokens' => 1)), 'closeform' => closeform(), 'forum_id_field' => form_hidden('forum_id', "", $post_data['forum_id']), 'thread_id_field' => form_hidden('thread_id', "", $post_data['thread_id']), "forum_field" => "", 'subject_field' => form_hidden('thread_subject', "", $thread_data['thread_subject']), 'message_field' => form_textarea('post_message', $locale['forum_0601'], $post_data['post_message'], array('required' => TRUE, 'error_text' => '', 'autosize' => TRUE, 'no_resize' => TRUE, 'preview' => TRUE, 'form_name' => 'input_form', 'bbcode' => TRUE)), 'delete_field' => '', 'edit_reason_field' => '', 'attachment_field' => $this->getThreadPermission("can_upload_attach") ? form_fileinput('file_attachments[]', $locale['forum_0557'], "", array('input_id' => 'file_attachments', 'upload_path' => INFUSIONS . 'forum/attachments/', 'type' => 'object', 'preview_off' => TRUE, "multiple" => TRUE, "inline" => false, 'max_count' => $forum_settings['forum_attachmax_count'], 'valid_ext' => $forum_settings['forum_attachtypes'], "class" => "m-b-0")) . "\n\t\t\t\t\t\t\t\t <div class='m-b-20'>\n<small>" . sprintf($locale['forum_0559'], parsebytesize($forum_settings['forum_attachmax']), str_replace('|', ', ', $forum_settings['forum_attachtypes']), $forum_settings['forum_attachmax_count']) . "</small>\n</div>\n" : "", "poll_form" => "", 'smileys_field' => form_checkbox('post_smileys', $locale['forum_0622'], $post_data['post_smileys'], array('class' => 'm-b-0')), 'signature_field' => array_key_exists("user_sig", $userdata) && $userdata['user_sig'] ? form_checkbox('post_showsig', $locale['forum_0623'], $post_data['post_showsig'], array('class' => 'm-b-0')) : '', 'sticky_field' => '', 'lock_field' => '', 'hide_edit_field' => '', 'post_locked_field' => '', 'notify_field' => $forum_settings['thread_notify'] ? form_checkbox('notify_me', $locale['forum_0626'], $post_data['notify_me'], array('class' => 'm-b-0')) : '', 'post_buttons' => form_button('post_reply', $locale['forum_0504'], $locale['forum_0504'], array('class' => 'btn-primary')) . form_button('cancel', $locale['cancel'], $locale['cancel'], array('class' => 'btn-default m-l-10')), 'last_posts_reply' => '');
         // only in reply
         if ($forum_settings['forum_last_posts_reply']) {
             $result = dbquery("\n\t\t\t\tSELECT\n\t\t\t\tp.thread_id, p.post_message, p.post_smileys, p.post_author, p.post_datestamp, p.post_hidden,\n\t\t\t\t\t\t\tu.user_id, u.user_name, u.user_status, u.user_avatar\n\t\t\t\t\t\t\tFROM " . DB_FORUM_POSTS . " p\n\t\t\t\t\t\t\tLEFT JOIN " . DB_USERS . " u ON p.post_author = u.user_id\n\t\t\t\t\t\t\tWHERE p.thread_id='" . $thread_data['thread_id'] . "' AND p.post_hidden='0'\n\t\t\t\t\t\t\tGROUP BY p.post_id\n\t\t\t\t\t\t\tORDER BY p.post_datestamp DESC LIMIT 0," . $forum_settings['posts_per_page']);
             if (dbrows($result)) {
                 $title = sprintf($locale['forum_0526'], $forum_settings['forum_last_posts_reply']);
                 if ($forum_settings['forum_last_posts_reply'] == "1") {
                     $title = $locale['forum_0525'];
                 }
                 ob_start();
                 echo "<p><strong>" . $title . "</strong>\n</p>\n";
                 echo "<table class='table table-responsive'>\n";
                 $i = $forum_settings['posts_per_page'];
                 while ($data = dbarray($result)) {
                     $message = $data['post_message'];
                     if ($data['post_smileys']) {
                         $message = parsesmileys($message);
                     }
                     $message = parseubb($message);
                     echo "<tr>\n<td class='tbl2 forum_thread_user_name' style='width:10%'><!--forum_thread_user_name-->" . profile_link($data['user_id'], $data['user_name'], $data['user_status']) . "</td>\n";
                     echo "<td class='tbl2 forum_thread_post_date'>\n";
                     echo "<div style='float:right' class='small'>\n";
                     echo $i . ($i == $forum_settings['forum_last_posts_reply'] ? " (" . $locale['forum_0525'] . ")" : "");
                     echo "</div>\n";
                     echo "<div class='small'>" . $locale['forum_0524'] . showdate("forumdate", $data['post_datestamp']) . "</div>\n";
                     echo "</td>\n";
                     echo "</tr>\n<tr>\n<td valign='top' class='tbl2 forum_thread_user_info' style='width:10%'>\n";
                     echo display_avatar($data, '50px');
                     echo "</td>\n<td valign='top' class='tbl1 forum_thread_user_post'>\n";
                     echo nl2br($message);
                     echo "</td>\n</tr>\n";
                     $i--;
                 }
                 echo "</table>\n";
                 $info['last_posts_reply'] = ob_get_contents();
                 ob_end_clean();
             }
         }
         postform($info);
     } else {
         redirect(INFUSIONS . 'forum/index.php');
     }
 }
Пример #19
0
 /**
  * Get forum index for hierarchy traversal
  * @return array
  */
 protected static function get_forum_index()
 {
     return dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
 }