Example #1
0
        $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'])) {
    $info = array();
    $info['item'] = array();
    $result = dbquery("SELECT weblink_cat_name, weblink_cat_sorting FROM\n\t" . DB_WEBLINK_CATS . " " . (multilang_table("WL") ? "WHERE weblink_cat_language='" . LANGUAGE . "' AND" : "WHERE") . " weblink_cat_id='" . intval($_GET['cat_id']) . "'");
    if (dbrows($result) != 0) {
        $cdata = dbarray($result);
        $info = $cdata;
        add_to_title($locale['global_201'] . $cdata['weblink_cat_name']);
        weblink_cat_breadcrumbs($weblink_cat_index);
        add_to_meta("description", $cdata['weblink_cat_name']);
        $max_rows = dbcount("(weblink_id)", DB_WEBLINKS, "weblink_cat='" . $_GET['cat_id'] . "' AND " . groupaccess('weblink_visibility'));
        $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $max_rows ? $_GET['rowstart'] : 0;
        if ($max_rows != 0) {
            $result = dbquery("SELECT weblink_id, weblink_name, weblink_description, weblink_datestamp, weblink_count\n            FROM " . DB_WEBLINKS . " WHERE " . groupaccess('weblink_visibility') . " AND weblink_cat='" . intval($_GET['cat_id']) . "' ORDER BY " . $cdata['weblink_cat_sorting'] . " LIMIT " . $_GET['rowstart'] . "," . $wl_settings['links_per_page']);
            $numrows = dbrows($result);
            $info['weblink_rows'] = $numrows;
            $info['page_nav'] = $max_rows > $wl_settings['links_per_page'] ? makepagenav($_GET['rowstart'], $wl_settings['links_per_page'], $max_rows, 3, INFUSIONS . "weblinks/weblinks.php?cat_id=" . $_GET['cat_id'] . "&amp;") : 0;
            if (dbrows($result) > 0) {
                while ($data = dbarray($result)) {
                    $data['new'] = $data['weblink_datestamp'] + 604800 > time() + $settings['timeoffset'] * 3600 ? 1 : 0;
                    $data['weblink'] = array('link' => INFUSIONS . "weblinks/weblinks.php?cat_id=" . $_GET['cat_id'] . "&amp;weblink_id=" . $data['weblink_id'], 'name' => $data['weblink_name']);
                    $info['item'][$data['weblink_id']] = $data;
                }
            }
        }
Example #2
0
 /**
  * Thread Class constructor - This builds all essential data on load.
  */
 public function __construct()
 {
     global $locale, $userdata, $settings, $forum_settings;
     // exit no.1
     if (!isset($_GET['thread_id']) && !isnum($_GET['thread_id'])) {
         redirect(INFUSIONS . 'forum/index.php');
     }
     $thread_data = \PHPFusion\Forums\Functions::get_thread($_GET['thread_id']);
     // fetch query and define iMOD
     if (!empty($thread_data)) {
         $thread_stat = self::get_thread_stats($_GET['thread_id']);
         // get post_count, lastpost_id, first_post_id.
         if ($thread_data['forum_type'] == 1) {
             redirect(INFUSIONS . 'forum/index.php');
         }
         if ($thread_stat['post_count'] < 1) {
             redirect(INFUSIONS . 'forum/index.php');
         }
         // Set meta
         add_to_meta($locale['forum_0000']);
         if ($thread_data['forum_description'] !== '') {
             add_to_meta('description', $thread_data['forum_description']);
         }
         if ($thread_data['forum_meta'] !== '') {
             add_to_meta('keywords', $thread_data['forum_meta']);
         }
         add_to_title($thread_data['thread_subject']);
         // Set Forum Breadcrumbs
         $this->forum_index = dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
         add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php', 'title' => $locale['forum_0000']));
         forum_breadcrumbs($this->forum_index, $thread_data['forum_id']);
         add_breadcrumb(array('link' => INFUSIONS . 'forum/viewthread.php?forum_id=' . $thread_data['forum_id'] . '&amp;thread_id=' . $thread_data['thread_id'], 'title' => $thread_data['thread_subject']));
         $this->setThreadPermission($thread_data);
         // Sanitizes $_GETs
         $_GET['forum_id'] = $thread_data['forum_id'];
         /**
          * Generate User Tracked Buttons
          */
         $this->thread_info['buttons']['notify'] = array();
         if ($this->getThreadPermission("can_access")) {
             // only member can track the thread
             if ($thread_data['user_tracked']) {
                 $this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=off&amp;forum_id=" . $thread_data['forum_id'] . "&amp;thread_id=" . $thread_data['thread_id'], 'title' => $locale['forum_0174']);
             } else {
                 $this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=on&amp;forum_id=" . $thread_data['forum_id'] . "&amp;thread_id=" . $thread_data['thread_id'], 'title' => $locale['forum_0175']);
             }
         }
         /**
          * Generate Quick Reply Form
          */
         $qr_form = "";
         if ($this->getThreadPermission("can_reply") == TRUE && $thread_data['forum_quick_edit'] == TRUE) {
             $qr_form = "<!--sub_forum_thread-->\n";
             $form_url = INFUSIONS . "forum/viewthread.php?thread_id=" . $thread_data['thread_id'];
             $qr_form .= openform('quick_reply_form', 'post', $form_url, array('class' => 'm-b-20 m-t-20'));
             $qr_form .= "<h4 class='m-t-20 pull-left'>" . $locale['forum_0168'] . "</h4>\n";
             $qr_form .= form_textarea('post_message', $locale['forum_0601'], '', array('bbcode' => true, 'required' => true, 'autosize' => true, 'preview' => true, 'form_name' => 'quick_reply_form'));
             $qr_form .= "<div class='m-t-10 pull-right'>\n";
             $qr_form .= form_button('post_quick_reply', $locale['forum_0172'], $locale['forum_0172'], array('class' => 'btn-primary btn-sm m-r-10'));
             $qr_form .= "</div>\n";
             $qr_form .= "<div class='overflow-hide'>\n";
             $qr_form .= form_checkbox('post_smileys', $locale['forum_0169'], '', array('class' => 'm-b-0'));
             if (array_key_exists("user_sig", $userdata) && $userdata['user_sig']) {
                 $qr_form .= form_checkbox('post_showsig', $locale['forum_0170'], '1', array('class' => 'm-b-0'));
             }
             if ($forum_settings['thread_notify']) {
                 $qr_form .= form_checkbox('notify_me', $locale['forum_0171'], $thread_data['user_tracked'], array('class' => 'm-b-0'));
             }
             $qr_form .= "</div>\n";
             $qr_form .= closeform();
         }
         /**
          * Generate Poll Form
          */
         $poll = array();
         $poll_form = "";
         if ($this->getThreadPermission("can_access") && $thread_data['thread_poll'] == TRUE) {
             $poll_result = dbquery("SELECT\n\t\t\t\tpoll_opts.*, poll.forum_poll_title, poll.forum_poll_votes\n\t\t\t\tFROM " . DB_FORUM_POLL_OPTIONS . " poll_opts\n\t\t\t\tINNER JOIN " . DB_FORUM_POLLS . " poll using (thread_id)\n\t\t\t\tWHERE poll.thread_id='" . intval($thread_data['thread_id']) . "'\n\t\t\t\t");
             if (dbrows($poll_result) > 0) {
                 $i = 0;
                 // Construct poll data - model
                 while ($pdata = dbarray($poll_result)) {
                     if ($i == 0) {
                         $poll['forum_poll_title'] = $pdata['forum_poll_title'];
                         $poll['forum_poll_votes'] = $pdata['forum_poll_votes'];
                         $poll['forum_poll_max_options'] = dbrows($poll_result);
                     }
                     $poll['forum_poll_options'][$pdata['forum_poll_option_id']] = $pdata;
                     $i++;
                 }
                 // SQL cast poll vote
                 if (isset($_POST['poll_option']) && isnum($_POST['poll_option']) && $_POST['poll_option'] <= $poll['forum_poll_max_options']) {
                     if ($this->getThreadPermission("can_vote_poll") == TRUE) {
                         $pollInput['poll_option_id'] = stripinput($_POST['poll_option']);
                         global $defender;
                         if ($defender->safe()) {
                             dbquery("UPDATE " . DB_FORUM_POLL_OPTIONS . " SET forum_poll_option_votes=forum_poll_option_votes+1 WHERE thread_id='" . intval($thread_data['thread_id']) . "' AND forum_poll_option_id='" . intval($pollInput['poll_option_id']) . "'");
                             dbquery("UPDATE " . DB_FORUM_POLLS . " SET forum_poll_votes=forum_poll_votes+1 WHERE thread_id='" . intval($thread_data['thread_id']) . "'");
                             dbquery("INSERT INTO " . DB_FORUM_POLL_VOTERS . " (thread_id, forum_vote_user_id, forum_vote_user_ip, forum_vote_user_ip_type) VALUES ('" . $thread_data['thread_id'] . "', '" . $userdata['user_id'] . "', '" . USER_IP . "', '" . USER_IP_TYPE . "')");
                             addNotice('success', $locale['forum_0614']);
                             redirect(INFUSIONS . "forum/viewthread.php?forum_id=" . $thread_data['forum_id'] . "&thread_id=" . $thread_data['thread_id']);
                         } else {
                             addNotice("danger", "You are not eligible to cast a vote in the poll.");
                         }
                     }
                 }
                 $poll_form_start = "";
                 $poll_form_end = "";
                 if ($this->getThreadPermission("can_vote_poll")) {
                     $poll_form_start = openform("poll_vote_form", "post", INFUSIONS . "forum/viewthread.php?thread_id=" . $thread_data['thread_id']);
                     $poll_form_end = form_button('vote', $locale['forum_2010'], 'vote', array('class' => 'btn btn-sm btn-primary m-l-20 '));
                     $poll_form_end .= closeform();
                 }
                 // need to fix security.
                 if ($this->getThreadPermission("can_edit_poll")) {
                     $poll_form .= "<div class='pull-right btn-group'>\n";
                     $poll_form .= "<a class='btn btn-sm btn-default' href='" . INFUSIONS . "forum/viewthread.php?action=editpoll&forum_id=" . $thread_data['forum_id'] . "&thread_id=" . $thread_data['thread_id'] . "'>" . $locale['forum_0603'] . "</a>\n";
                     $poll_form .= "<a class='btn btn-sm btn-default' href='" . INFUSIONS . "forum/viewthread.php?action=deletepoll&forum_id=" . $thread_data['forum_id'] . "&thread_id=" . $thread_data['thread_id'] . "' onclick='confirm('" . $locale['forum_0616'] . "');'>" . $locale['delete'] . "</a>\n";
                     $poll_form .= "</div>\n";
                 }
                 $poll_form .= $poll_form_start;
                 $poll_form .= "<h3 class='strong m-b-10'><i class='fa fa-fw fa-pie-chart fa-lg'></i>" . $locale['forum_0377'] . " : " . $poll['forum_poll_title'] . "</h3>\n";
                 $poll_form .= "<ul class='p-l-20 p-t-0'>\n";
                 if (!empty($poll['forum_poll_options'])) {
                     $i = 1;
                     $vote_options = $poll['forum_poll_options'];
                     foreach ($vote_options as $poll_option) {
                         if ($this->getThreadPermission("can_vote_poll") == TRUE) {
                             $poll_form .= "<li><label for='opt-" . $i . "'><input id='opt-" . $i . "' type='radio' name='poll_option' value='" . $i . "' class='m-r-20'> <span class='m-l-10'>" . $poll_option['forum_poll_option_text'] . "</span>\n</label></li>\n";
                         } else {
                             $option_votes = $poll['forum_poll_votes'] ? number_format(100 / $poll['forum_poll_votes'] * $poll_option['forum_poll_option_votes']) : 0;
                             $poll_form .= progress_bar($option_votes, $poll_option['forum_poll_option_text'], '', '10px');
                         }
                         $i++;
                     }
                 }
                 $poll_form .= "</ul>\n";
                 $poll_form .= $poll_form_end;
             }
         }
         /**
          * Generate Attachment
          */
         $attachments = array();
         if ($this->getThreadPermission("can_download_attach") == TRUE) {
             $a_result = dbquery("SELECT * FROM " . DB_FORUM_ATTACHMENTS . " WHERE thread_id='" . intval($thread_data['thread_id']) . "' ORDER BY post_id ASC");
             if (dbrows($a_result) > 0) {
                 while ($a_data = dbarray($a_result)) {
                     if (file_exists(INFUSIONS . "forum/attachments/" . $a_data['attach_name'])) {
                         //$this->thread_info['attachments'][$a_data['post_id']][] = $a_data;
                         $attachments[$a_data['post_id']][] = $a_data;
                     }
                 }
             }
         }
         /**
          * Generate Mod Form
          */
         if (iMOD) {
             // need to wrap with issets?
             $mod = new Moderator();
             $mod->setForumId($thread_data['forum_id']);
             $mod->setThreadId($thread_data['thread_id']);
             $mod->set_modActions();
             /**
              * Thread moderation form template
              */
             $this->thread_info['mod_options'] = array('renew' => $locale['forum_0207'], 'delete' => $locale['forum_0201'], $thread_data['thread_locked'] ? "unlock" : "lock" => $thread_data['thread_locked'] ? $locale['forum_0203'] : $locale['forum_0202'], $thread_data['thread_sticky'] ? "nonsticky" : "sticky" => $thread_data['thread_sticky'] ? $locale['forum_0205'] : $locale['forum_0204'], 'move' => $locale['forum_0206']);
             $addition = isset($_GET['rowstart']) ? "&amp;rowstart=" . intval($_GET['rowstart']) : "";
             $this->thread_info['form_action'] = INFUSIONS . "forum/viewthread.php?thread_id=" . intval($thread_data['thread_id']) . $addition;
             $this->thread_info['open_post_form'] = openform('moderator_menu', 'post', $this->thread_info['form_action']);
             $this->thread_info['close_post_form'] = closeform();
             /*
             * <a id='check' class='btn button btn-sm btn-default text-dark' href='#' onclick=\"javascript:setChecked('mod_form','delete_post[]',1);return false;\">".$locale['forum_0080']."</a>\n
             						<a id='uncheck' class='btn button btn-sm btn-default text-dark' href='#' onclick=\"javascript:setChecked('mod_form','delete_post[]',0);return false;\">".$locale['forum_0081']."</a>\n
             */
             $this->thread_info['mod_form'] = "\n\t\t\t\t<div class='list-group-item'>\n\n\t\t\t\t\t<div class='btn-group m-r-10'>\n\n\t\t\t\t\t\t" . form_button("check_all", $locale['forum_0080'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t\t" . form_button("check_none", $locale['forum_0081'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t\t" . form_button('move_posts', $locale['forum_0176'], $locale['forum_0176'], array('class' => 'btn-default btn-sm m-r-10')) . "\n\t\t\t\t\t" . form_button('delete_posts', $locale['forum_0177'], $locale['forum_0177'], array('class' => 'btn-default btn-sm')) . "\n\t\t\t\t\t<div class='pull-right'>\n\t\t\t\t\t\t" . form_button('go', $locale['forum_0208'], $locale['forum_0208'], array('class' => 'btn-default pull-right btn-sm m-t-0 m-l-10')) . "\n\t\t\t\t\t\t" . form_select('step', '', '', array('options' => $this->thread_info['mod_options'], 'placeholder' => $locale['forum_0200'], 'width' => '250px', 'allowclear' => 1, 'class' => 'm-b-0 m-t-5', 'inline' => 1)) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t</div>\n";
             add_to_jquery("\n\t\t\t\t\$('#check_all').bind('click', function() {\n\t\t\t\t    var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', true);\n\t\t\t\t});\n\t\t\t\t\$('#check_none').bind('click', function() {\n\t\t\t\t    var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', false); });\n\t\t\t\t");
         }
         $this->thread_info += array("thread" => $thread_data, "thread_id" => $thread_data['thread_id'], "forum_id" => $thread_data['forum_id'], "forum_cat" => isset($_GET['forum_cat']) && verify_forum($_GET['forum_cat']) ? $_GET['forum_cat'] : 0, "forum_branch" => isset($_GET['forum_branch']) && verify_forum($_GET['forum_branch']) ? $_GET['forum_branch'] : 0, "forum_link" => array("link" => INFUSIONS . "forum/index.php?viewforum&amp;forum_id=" . $thread_data['forum_id'] . "&amp;forum_cat=" . $thread_data['forum_cat'] . "&amp;forum_branch=" . $thread_data['forum_branch'], "title" => $thread_data['forum_name']), "post_id" => isset($_GET['post_id']) && verify_post($_GET['post_id']) ? $_GET['post_id'] : 0, "pid" => isset($_GET['pid']) && isnum($_GET['pid']) ? $_GET['pid'] : 0, "section" => isset($_GET['section']) ? $_GET['section'] : '', "forum_moderators" => Functions::parse_forumMods($thread_data['forum_mods']), "max_post_items" => $thread_stat['post_count'], "post_firstpost" => $thread_stat['first_post_id'], "post_lastpost" => $thread_stat['last_post_id'], "posts_per_page" => $forum_settings['posts_per_page'], "threads_per_page" => $forum_settings['threads_per_page'], "lastvisited" => isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time(), "allowed_post_filters" => array('oldest', 'latest', 'high'), "attachtypes" => explode(",", $forum_settings['forum_attachtypes']), "quick_reply_form" => $qr_form, "poll_form" => $poll_form, "post-filters" => "", 'mod_options' => array(), 'form_action' => '', 'open_post_form' => '', 'close_post_form' => '', 'mod_form' => '');
         /**
          * Generate All Thread Buttons
          */
         $this->thread_info['buttons'] += array("print" => array("link" => BASEDIR . "print.php?type=F&amp;item_id=" . $thread_data['thread_id'] . "&amp;rowstart=" . $_GET['rowstart'], "title" => $locale['forum_0178']), "newthread" => $this->getThreadPermission("can_post") == TRUE ? array("link" => INFUSIONS . "forum/newthread.php?forum_id=" . $thread_data['forum_id'], "title" => $locale['forum_0264']) : array(), "reply" => $this->getThreadPermission("can_reply") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=reply&amp;forum_id=" . $thread_data['forum_id'] . "&amp;thread_id=" . $thread_data['thread_id'], "title" => $locale['forum_0360']) : array(), "poll" => $this->getThreadPermission("can_create_poll") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=newpoll&amp;forum_id=" . $thread_data['forum_id'] . "&amp;thread_id=" . $thread_data['thread_id'], "title" => $locale['forum_0366']) : array());
         /**
          * Generate Post Filters
          */
         $this->thread_info['post-filters'][0] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $thread_data['thread_id'] . '&amp;section=oldest', 'locale' => $locale['forum_0180']);
         $this->thread_info['post-filters'][1] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $thread_data['thread_id'] . '&amp;section=latest', 'locale' => $locale['forum_0181']);
         if ($this->getThreadPermission("can_rate") == TRUE) {
             $this->thread_info['allowed-post-filters'][2] = 'high';
             $this->thread_info['post-filters'][2] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_info['thread_id'] . '&amp;section=high', 'locale' => $locale['forum_0182']);
         }
         $this->handle_quick_reply();
         $this->get_thread_post();
         //self::set_ThreadJs();
         // execute in the end.
         //self::set_ForumPostDB();
     } else {
         redirect(FORUM . 'index.php');
     }
 }
Example #3
0
/**
 * Article Category Breadcrumbs Generator
 * @param $forum_index
 */
function articleCats_breadcrumbs($index)
{
    global $locale;
    function breadcrumb_arrays($index, $id)
    {
        $crumb =& $crumb;
        if (isset($index[get_parent($index, $id)])) {
            $_name = dbarray(dbquery("SELECT article_cat_id, article_cat_name, article_cat_parent FROM " . DB_ARTICLE_CATS . " " . (multilang_table("AR") ? "WHERE article_cat_language='" . LANGUAGE . "' and " : "where ") . "\n\t\t\t\tarticle_cat_id='" . intval($id) . "'"));
            $crumb = array('link' => INFUSIONS . "articles/articles.php?cat_id=" . $_name['article_cat_id'], 'title' => $_name['article_cat_name']);
            if (isset($index[get_parent($index, $id)])) {
                if (get_parent($index, $id) == 0) {
                    return $crumb;
                }
                $crumb_1 = breadcrumb_arrays($index, get_parent($index, $id));
                $crumb = array_merge_recursive($crumb, $crumb_1);
                // convert so can comply to Fusion Tab API.
            }
        }
        return $crumb;
    }
    // then we make a infinity recursive function to loop/break it out.
    $crumb = breadcrumb_arrays($index, $_GET['cat_id']);
    // then we sort in reverse.
    if (count($crumb['title']) > 1) {
        krsort($crumb['title']);
        krsort($crumb['link']);
    }
    if (count($crumb['title']) > 1) {
        foreach ($crumb['title'] as $i => $value) {
            add_breadcrumb(array('link' => $crumb['link'][$i], 'title' => $value));
            if ($i == count($crumb['title']) - 1) {
                add_to_title($locale['global_201'] . $value);
                add_to_meta($value);
            }
        }
    } elseif (isset($crumb['title'])) {
        add_to_title($locale['global_201'] . $crumb['title']);
        add_to_meta($crumb['title']);
        add_breadcrumb(array('link' => $crumb['link'], 'title' => $crumb['title']));
    }
}
Example #4
0
            if ($data['download_homepage']) {
                $urlprefix = !strstr($data['download_homepage'], "http://") && !strstr($data['download_homepage'], "https://") ? 'http://' : '';
                $data['download_homepage'] = "<a href='" . $urlprefix . $data['download_homepage'] . "' title='" . $urlprefix . $data['download_homepage'] . "' target='_blank'>" . $locale['download_1018'] . "</a>\n";
            } else {
                $data['download_homepage'] = $locale['na'];
            }
            /* Admin link */
            $data['admin_link'] = '';
            if (iADMIN && checkrights('D')) {
                $data['admin_link'] = array('edit' => INFUSIONS . "downloads/downloads_admin.php" . $aidlink . "&amp;action=edit&amp;section=nform&amp;download_id=" . $data['download_id'], 'delete' => INFUSIONS . "downloads/downloads_admin.php" . $aidlink . "&amp;action=delete&amp;section=nform&amp;download_id=" . $data['download_id']);
            }
            $info['download_title'] = $data['download_title'];
            $info['download_updated'] = $locale['global_049'] . " " . timer($data['download_datestamp']);
            add_breadcrumb(array('link' => INFUSIONS . "downloads/downloads.php?download_id=" . $_GET['download_id'], 'title' => $data['download_title']));
            add_to_title($data['download_title']);
            add_to_meta($data['download_title'] . ($data['download_keywords'] ? "," . $data['download_keywords'] : ''));
            if ($data['download_keywords'] !== "") {
                set_meta("keywords", $data['download_keywords']);
            }
            $data['download_title'] = "<a class='text-dark' href='" . INFUSIONS . "downloads/downloads.php?readmore=" . $data['download_id'] . "'>" . $data['download_title'] . "</a>";
            $info['download_item'] = $data;
        } else {
            redirect(INFUSIONS . "downloads/downloads.php");
        }
    } else {
        redirect(INFUSIONS . "downloads/downloads.php");
    }
} else {
    $condition = '';
    if (isset($_GET['author']) && isnum($_GET['author'])) {
        $condition = "AND download_user = '******'author']) . "'";
Example #5
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');
     }
 }
Example #6
0
        render_photo($info);
    } else {
        redirect(INFUSIONS . 'gallery/gallery.php');
    }
} else {
    if (isset($_GET['album_id']) && isnum($_GET['album_id'])) {
        /* View Album */
        $result = dbquery("SELECT album_title, album_description, album_keywords, album_image, album_thumb1, album_thumb2, album_access\n\tFROM " . DB_PHOTO_ALBUMS . " WHERE " . groupaccess('album_access') . " AND album_id='" . intval($_GET['album_id']) . "'\n\t");
        if (dbrows($result) > 0) {
            $info = dbarray($result);
            set_title($info['album_title'] . $locale['global_200']);
            add_to_title(\PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name"));
            add_breadcrumb(array('link' => INFUSIONS . 'gallery/gallery.php', 'title' => \PHPFusion\SiteLinks::get_current_SiteLinks("", "link_name")));
            add_breadcrumb(array('link' => INFUSIONS . 'gallery/gallery.php?album_id=' . $_GET['album_id'], 'title' => $info['album_title']));
            if ($info['album_keywords'] !== "") {
                add_to_meta("keywords", $info['album_keywords']);
            }
            /* Category Info */
            $info['album_thumb'] = displayAlbumImage($info['album_image'], $info['album_thumb2'], $info['album_thumb1'], "");
            $info['album_link'] = array('link' => INFUSIONS . 'gallery/gallery.php?album_id=' . $_GET['album_id'], 'name' => $info['album_title']);
            $info['max_rows'] = dbcount("(photo_id)", DB_PHOTOS, "album_id='" . $_GET['album_id'] . "'");
            $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $info['max_rows'] ? $_GET['rowstart'] : 0;
            if ($info['max_rows'] > 0) {
                // Album stats
                $latest_update = dbarray(dbquery("\n\t\t\t\t\tSELECT tp.photo_datestamp, tu.user_id, tu.user_name, tu.user_status\n\t\t\t\t\tFROM " . DB_PHOTOS . " tp\n\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu ON tp.photo_user=tu.user_id\n\t\t\t\t\tWHERE album_id='" . intval($_GET['album_id']) . "'\n\t\t\t\t\tORDER BY photo_datestamp DESC LIMIT 1"));
                $info['album_stats'] = $locale['422'] . $info['max_rows'] . "<br />\n";
                $info['album_stats'] .= $locale['423'] . profile_link($latest_update['user_id'], $latest_update['user_name'], $latest_update['user_status']) . "" . $locale['424'] . showdate("longdate", $latest_update['photo_datestamp']) . "\n";
                $result = dbquery("SELECT tp.*,\n\t\t\t\t\ttu.user_id, tu.user_name, tu.user_status, tu.user_avatar,\n\t\t\t\t\tSUM(tr.rating_vote) 'sum_rating',\n\t\t\t\t\tCOUNT(tr.rating_vote) 'count_rating',\n\t\t\t\t\tCOUNT(tr.rating_item_id) 'count_votes'\n\t\t\t\t\tFROM " . DB_PHOTOS . " tp\n\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu ON tp.photo_user=tu.user_id\n\t\t\t\t\tLEFT JOIN " . DB_RATINGS . " tr ON tr.rating_item_id = tp.photo_id AND tr.rating_type='P'\n\t\t\t\t\tWHERE album_id='" . intval($_GET['album_id']) . "'\n\t\t\t\t\tGROUP BY photo_id ORDER BY photo_order\n\t\t\t\t\tlimit " . intval($_GET['rowstart']) . "," . intval($gallery_settings['gallery_pagination']));
                $info['photo_rows'] = dbrows($result);
                $info['page_nav'] = $info['max_rows'] > $gallery_settings['gallery_pagination'] ? makepagenav($_GET['rowstart'], $gallery_settings['gallery_pagination'], $info['max_rows'], 3, INFUSIONS . "gallery/gallery.php?album_id=" . $_GET['album_id'] . "&amp;") : '';
                if ($info['photo_rows'] > 0) {
Example #7
0
 private function setInbox()
 {
     global $locale, $userdata;
     /**
      * Sanitize environment
      */
     $myStatus = self::get_pm_settings($userdata['user_id']);
     //print_p($myStatus);
     if (!isset($_GET['folder']) || !preg_check("/^(inbox|outbox|archive|options)\$/", $_GET['folder'])) {
         $_GET['folder'] = "inbox";
     }
     function validate_user($user_id)
     {
         if (isnum($user_id) && dbcount("(user_id)", DB_USERS, "user_id='" . intval($user_id) . "' AND user_status ='0'")) {
             return TRUE;
         }
         return FALSE;
     }
     if (isset($_POST['msg_send']) && isnum($_POST['msg_send']) && validate_user($_POST['msg_send'])) {
         $_GET['msg_send'] = $_POST['msg_send'];
     }
     // prohibits send message to non-existing group
     $user_group = fusion_get_groups();
     unset($user_group[0]);
     if (isset($_POST['msg_to_group']) && isnum($_POST['msg_to_group']) && isset($user_group[$_POST['msg_to_group']])) {
         $_GET['msg_to_group'] = $_POST['msg_to_group'];
     }
     $this->info = array("folders" => array("inbox" => array("link" => BASEDIR . "messages.php?folder=inbox", "title" => $locale['402']), "outbox" => array("link" => BASEDIR . "messages.php?folder=outbox", "title" => $locale['403']), "archive" => array("link" => BASEDIR . "messages.php?folder=archive", "title" => $locale['404']), "options" => array("link" => BASEDIR . "messages.php?folder=options", "title" => $locale['425'])), "inbox_total" => dbrows(dbquery("SELECT message_id FROM " . DB_MESSAGES . " WHERE message_user='******'user_id'] . "' and message_to='" . $userdata['user_id'] . "' AND message_folder='0'")), "outbox_total" => dbrows(dbquery("SELECT message_id FROM " . DB_MESSAGES . " WHERE message_user='******'user_id'] . "' and message_to='" . $userdata['user_id'] . "' AND message_folder='1'")), "archive_total" => dbrows(dbquery("SELECT message_id FROM " . DB_MESSAGES . " WHERE message_user='******'user_id'] . "' and message_to='" . $userdata['user_id'] . "' AND message_folder='2'")), "button" => array("new" => array('link' => BASEDIR . "messages.php?msg_send=new", 'name' => $locale['401']), "options" => array('link' => BASEDIR . "messages.php?folder=options", 'name' => $locale['425'])), "actions_form" => "");
     add_to_title($locale['global_200'] . $locale['400']);
     add_to_meta("description", $locale['400']);
 }
Example #8
0
 /**
  * Thread Class constructor - This builds all essential data on load.
  */
 public function set_threadInfo()
 {
     if (!isset($_GET['thread_id']) && !isnum($_GET['thread_id'])) {
         redirect(INFUSIONS . 'forum/index.php');
     }
     $forum_settings = $this->get_forum_settings();
     $locale = fusion_get_locale("", FORUM_LOCALE);
     $userdata = fusion_get_userdata();
     // Download acceptable types for Forum
     $this->thread_data = self::get_thread($_GET['thread_id']);
     // fetch query and define iMOD
     if (!empty($this->thread_data)) {
         $thread_stat = self::get_thread_stats($_GET['thread_id']);
         // get post_count, lastpost_id, first_post_id.
         if ($this->thread_data['forum_type'] == 1) {
             if (fusion_get_settings("site_seo")) {
                 redirect(fusion_get_settings("siteurl") . "infusions/forum/index.php");
             }
             redirect(INFUSIONS . 'forum/index.php');
         }
         if ($thread_stat['post_count'] < 1) {
             if (fusion_get_settings("site_seo")) {
                 redirect(fusion_get_settings("siteurl") . "infusions/forum/index.php");
             }
             redirect(INFUSIONS . 'forum/index.php');
         }
         // Set meta
         add_to_title($this->thread_data['thread_subject']);
         add_to_meta($locale['forum_0000']);
         if ($this->thread_data['forum_description'] !== '') {
             add_to_meta('description', $this->thread_data['forum_description']);
         }
         if ($this->thread_data['forum_meta'] !== '') {
             add_to_meta('keywords', $this->thread_data['forum_meta']);
         }
         // Set Forum Breadcrumbs
         $forum_index = dbquery_tree(DB_FORUMS, 'forum_id', 'forum_cat');
         add_breadcrumb(array('link' => INFUSIONS . 'forum/index.php', 'title' => $locale['forum_0000']));
         $this->forum_breadcrumbs($forum_index, $this->thread_data['forum_id']);
         add_breadcrumb(array('link' => INFUSIONS . 'forum/viewthread.php?forum_id=' . $this->thread_data['forum_id'] . '&amp;thread_id=' . $this->thread_data['thread_id'], 'title' => $this->thread_data['thread_subject']));
         $this->setThreadPermission();
         // Sanitizes $_GETs
         $_GET['forum_id'] = intval($this->thread_data['forum_id']);
         /**
          * Generate User Tracked Buttons
          */
         $this->thread_info['buttons']['notify'] = array();
         if ($this->getThreadPermission("can_access")) {
             // only member can track the thread
             if ($this->thread_data['user_tracked']) {
                 $this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=off&amp;forum_id=" . $this->thread_data['forum_id'] . "&amp;thread_id=" . $this->thread_data['thread_id'], 'title' => $locale['forum_0174']);
             } else {
                 $this->thread_info['buttons']['notify'] = array('link' => INFUSIONS . "forum/postify.php?post=on&amp;forum_id=" . $this->thread_data['forum_id'] . "&amp;thread_id=" . $this->thread_data['thread_id'], 'title' => $locale['forum_0175']);
             }
         }
         $this->thread_info['thread'] = $this->thread_data;
         /**
          * Generate Quick Reply Form
          */
         $qr_form = "";
         if ($this->getThreadPermission("can_reply") == TRUE && $this->thread_data['forum_quick_edit'] == TRUE) {
             $qr_form = QuickReply::display_quickReply($this->thread_data);
         }
         /**
          * Generate Poll Form
          */
         $poll = new Poll($this->thread_info);
         $poll_form = $poll->generate_poll($this->thread_data);
         /**
          * Generate Attachment
          */
         $attach = new Attachment($this->thread_info);
         $attachments = $attach::get_attachments($this->thread_data);
         /**
          * Generate Mod Form
          */
         if (iMOD) {
             $this->moderator()->setForumId($this->thread_data['forum_id']);
             $this->moderator()->setThreadId($this->thread_data['thread_id']);
             $this->moderator()->set_modActions();
             /**
              * Thread moderation form template
              */
             $addition = isset($_GET['rowstart']) ? "&amp;rowstart=" . intval($_GET['rowstart']) : "";
             $this->thread_info['form_action'] = INFUSIONS . "forum/viewthread.php?thread_id=" . intval($this->thread_data['thread_id']) . $addition;
             $this->thread_info['open_post_form'] = openform('moderator_menu', 'post', $this->thread_info['form_action']);
             $this->thread_info['mod_options'] = array('renew' => $locale['forum_0207'], 'delete' => $locale['forum_0201'], $this->thread_data['thread_locked'] ? "unlock" : "lock" => $this->thread_data['thread_locked'] ? $locale['forum_0203'] : $locale['forum_0202'], $this->thread_data['thread_sticky'] ? "nonsticky" : "sticky" => $this->thread_data['thread_sticky'] ? $locale['forum_0205'] : $locale['forum_0204'], 'move' => $locale['forum_0206']);
             $this->thread_info['close_post_form'] = closeform();
             $this->thread_info['mod_form'] = "\n\t\t\t\t<div class='list-group-item'>\n\n\t\t\t\t\t<div class='btn-group m-r-10'>\n\n\t\t\t\t\t\t" . form_button("check_all", $locale['forum_0080'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t\t" . form_button("check_none", $locale['forum_0081'], $locale['forum_0080'], array('class' => 'btn-default btn-sm', "type" => "button")) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t\t" . form_button('move_posts', $locale['forum_0176'], $locale['forum_0176'], array('class' => 'btn-default btn-sm m-r-10')) . "\n\t\t\t\t\t" . form_button('delete_posts', $locale['forum_0177'], $locale['forum_0177'], array('class' => 'btn-default btn-sm')) . "\n\t\t\t\t\t<div class='pull-right'>\n\t\t\t\t\t\t" . form_button('go', $locale['forum_0208'], $locale['forum_0208'], array('class' => 'btn-default pull-right btn-sm m-t-0 m-l-10')) . "\n\t\t\t\t\t\t" . form_select('step', '', '', array('options' => $this->thread_info['mod_options'], 'placeholder' => $locale['forum_0200'], 'width' => '250px', 'allowclear' => TRUE, 'class' => 'm-b-0 m-t-5', 'inline' => TRUE)) . "\n\t\t\t\t\t</div>\n\n\t\t\t\t</div>\n";
             add_to_jquery("\n\t\t\t\t\$('#check_all').bind('click', function() {\n\t\t\t\t    var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', true);\n\t\t\t\t});\n\t\t\t\t\$('#check_none').bind('click', function() {\n\t\t\t\t    var thread_posts = \$('#moderator_menu input:checkbox').prop('checked', false); });\n\t\t\t\t");
         }
         $this->thread_info += array("thread" => $this->thread_data, "thread_id" => $this->thread_data['thread_id'], "forum_id" => $this->thread_data['forum_id'], 'thread_tags' => $this->thread_data['thread_tags'], 'thread_tags_display' => '', "forum_cat" => isset($_GET['forum_cat']) && verify_forum($_GET['forum_cat']) ? $_GET['forum_cat'] : 0, "forum_branch" => isset($_GET['forum_branch']) && verify_forum($_GET['forum_branch']) ? $_GET['forum_branch'] : 0, "forum_link" => array("link" => INFUSIONS . "forum/index.php?viewforum&amp;forum_id=" . $this->thread_data['forum_id'] . "&amp;forum_cat=" . $this->thread_data['forum_cat'] . "&amp;forum_branch=" . $this->thread_data['forum_branch'], "title" => $this->thread_data['forum_name']), "thread_attachments" => $attachments, "post_id" => isset($_GET['post_id']) && verify_post($_GET['post_id']) ? $_GET['post_id'] : 0, "pid" => isset($_GET['pid']) && isnum($_GET['pid']) ? $_GET['pid'] : 0, "section" => isset($_GET['section']) ? $_GET['section'] : '', "forum_moderators" => $this->moderator()->parse_forum_mods($this->thread_data['forum_mods']), "max_post_items" => $thread_stat['post_count'], "post_firstpost" => $thread_stat['first_post_id'], "post_lastpost" => $thread_stat['last_post_id'], "posts_per_page" => $forum_settings['posts_per_page'], "threads_per_page" => $forum_settings['threads_per_page'], "lastvisited" => isset($userdata['user_lastvisit']) && isnum($userdata['user_lastvisit']) ? $userdata['user_lastvisit'] : time(), "allowed_post_filters" => array('oldest', 'latest', 'high'), "attachtypes" => explode(",", $forum_settings['forum_attachtypes']), "quick_reply_form" => $qr_form, "poll_form" => $poll_form, "post-filters" => "", 'mod_options' => array(), 'form_action' => '', 'open_post_form' => '', 'close_post_form' => '', 'mod_form' => '');
         //print_p($this->thread_info);
         if (!empty($this->thread_info['thread_tags'])) {
             $this->thread_info['thread_tags_display'] = $this->tag(FALSE)->display_thread_tags($this->thread_info['thread_tags']);
         }
         /**
          * Generate All Thread Buttons
          */
         $this->thread_info['buttons'] += array("print" => array("link" => BASEDIR . "print.php?type=F&amp;item_id=" . $this->thread_data['thread_id'] . "&amp;rowstart=" . $_GET['rowstart'], "title" => $locale['forum_0178']), "newthread" => $this->getThreadPermission("can_post") == TRUE ? array("link" => INFUSIONS . "forum/newthread.php?forum_id=" . $this->thread_data['forum_id'], "title" => $locale['forum_0264']) : array(), "reply" => $this->getThreadPermission("can_reply") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=reply&amp;forum_id=" . $this->thread_data['forum_id'] . "&amp;thread_id=" . $this->thread_data['thread_id'], "title" => $locale['forum_0360']) : array(), "poll" => $this->getThreadPermission("can_create_poll") == TRUE ? array("link" => INFUSIONS . "forum/viewthread.php?action=newpoll&amp;forum_id=" . $this->thread_data['forum_id'] . "&amp;thread_id=" . $this->thread_data['thread_id'], "title" => $locale['forum_0366']) : array());
         /**
          * Generate Post Filters
          */
         $this->thread_info['post-filters'][0] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_data['thread_id'] . '&amp;section=oldest', 'locale' => $locale['forum_0180']);
         $this->thread_info['post-filters'][1] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_data['thread_id'] . '&amp;section=latest', 'locale' => $locale['forum_0181']);
         if ($this->getThreadPermission("can_rate") == TRUE) {
             $this->thread_info['allowed-post-filters'][2] = 'high';
             $this->thread_info['post-filters'][2] = array('value' => INFUSIONS . 'forum/viewthread.php?thread_id=' . $this->thread_info['thread_id'] . '&amp;section=high', 'locale' => $locale['forum_0182']);
         }
         $this->handle_quick_reply();
         $this->get_thread_post();
         //self::set_ThreadJs();
         // execute in the end.
     } else {
         redirect(FORUM . 'index.php');
     }
 }
Example #9
0
}
require_once THEMES . "templates/header.php";
if (file_exists(INFUSIONS . "forum/locale/" . LOCALESET . "forum.php")) {
    include INFUSIONS . "forum/locale/" . LOCALESET . "forum.php";
} else {
    include INFUSIONS . "forum/locale/English/forum.php";
}
add_to_title($locale['forum_0000']);
require_once INCLUDES . "infusions_include.php";
require_once INFUSIONS . "forum/classes/Forum.php";
require_once INFUSIONS . "forum/classes/Functions.php";
require_once INFUSIONS . "forum/forum_include.php";
require_once INFUSIONS . "forum/templates/forum_input.php";
if (iMEMBER) {
    $forum_settings = get_settings('forum');
    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']);
    if (!empty($_GET['forum_id']) && PHPFusion\Forums\Functions::verify_forum($_GET['forum_id'])) {
        $forum = new PHPFusion\Forums\Forum();
        $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");
        }
        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']) {
            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']));
Example #10
0
| Author: PHP-Fusion Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES . "templates/header.php";
require_once THEMES . "templates/global/login.php";
$locale = fusion_get_locale();
add_to_title($locale['global_200'] . $locale['global_100']);
add_to_meta("keywords", $locale['global_100']);
$info = array();
if (!iMEMBER) {
    if (isset($_GET['error']) && isnum($_GET['error'])) {
        if (isset($_GET['redirect']) && strpos(urldecode($_GET['redirect']), "/") === 0) {
            $action_url = cleanurl(urldecode($_GET['redirect']));
        }
        switch ($_GET['error']) {
            case 1:
                addNotice("warning", $locale['global_196']);
                break;
            case 2:
                addNotice("warning", $locale['global_192']);
                break;
            case 3:
                if (isset($_COOKIE[COOKIE_PREFIX . "user"])) {
/**
 * Hierarchy Page Breadcrumbs
 * This function generates breadcrumbs on all your category needs on $_GET['rownav'] as your cat_id
 * @param $tree_index - dbquery_tree(DB_NEWS_CATS, "news_cat_id", "news_cat_parent")
 *                    / tree_index(dbquery_tree_full(DB_NEWS_CATS, "news_cat_id", "news_cat_parent"))
 * @param $tree_full - dbquery_tree_full(DB_NEWS_CATS, "news_cat_id", "news_cat_parent");
 * @param $id_col - "news_cat_id",
 * @param $title_col - "news_cat_name",
 * @param $getname - cat_id, download_cat_id, news_cat_id, i.e. $_GET['cat_id']
 */
function make_page_breadcrumbs($tree_index, $tree_full, $id_col, $title_col, $getname = "rownav")
{
    global $locale;
    $_GET[$getname] = !empty($_GET[$getname]) && isnum($_GET[$getname]) ? $_GET[$getname] : 0;
    function breadcrumb_arrays($tree_index, $tree_full, $id_col, $title_col, $getname, $id)
    {
        $crumb =& $crumb;
        if (isset($tree_index[get_parent($tree_index, $id)])) {
            $_name = get_parent_array($tree_full, $id);
            $crumb = array('link' => isset($_name[$id_col]) ? clean_request($getname . "=" . $_name[$id_col], array("aid"), TRUE) : "", 'title' => isset($_name[$title_col]) ? \PHPFusion\QuantumFields::parse_label($_name[$title_col]) : "");
            if (get_parent($tree_index, $id) == 0) {
                return $crumb;
            }
            $crumb_1 = breadcrumb_arrays($tree_index, $tree_full, $id_col, $title_col, $getname, get_parent($tree_index, $id));
            $crumb = array_merge_recursive($crumb, $crumb_1);
        }
        return $crumb;
    }
    // then we make a infinity recursive function to loop/break it out.
    $crumb = breadcrumb_arrays($tree_index, $tree_full, $id_col, $title_col, $getname, $_GET[$getname]);
    // then we sort in reverse.
    if (count($crumb['title']) > 1) {
        krsort($crumb['title']);
        krsort($crumb['link']);
    }
    if (count($crumb['title']) > 1) {
        foreach ($crumb['title'] as $i => $value) {
            add_breadcrumb(array('link' => $crumb['link'][$i], 'title' => $value));
            if ($i == count($crumb['title']) - 1) {
                add_to_title($locale['global_201'] . $value);
                add_to_meta($value);
            }
        }
    } elseif (isset($crumb['title'])) {
        add_to_title($locale['global_201'] . $crumb['title']);
        add_to_meta($crumb['title']);
        add_breadcrumb(array('link' => $crumb['link'], 'title' => $crumb['title']));
    }
}