Ejemplo n.º 1
0
 public function ICDCodeSearch($params)
 {
     ini_set('memory_limit', '256M');
     $type = Globals::getGlobal('dx_code_type');
     $query = is_object($params) ? $params->query : $params;
     /**
      * get last icd9 code revision
      */
     $revision = $this->getLastRevisionByCodeType('ICD9');
     $records = array();
     $whereQuery = '';
     $queries = explode(' ', $query);
     $wheres = array();
     $wheresIndex = 0;
     foreach ($queries as $q) {
         $q = trim($q);
         $w0 = ':W0' . $wheresIndex;
         $wheres[$w0] = '%' . $q . '%';
         $w1 = ':W1' . $wheresIndex;
         $wheres[$w1] = $q . '%';
         $w2 = ':W2' . $wheresIndex;
         $wheres[$w2] = $q . '%';
         $w3 = ':W3' . $wheresIndex++;
         $wheres[$w3] = $q . '%';
         $whereQuery .= " AND (short_desc \tLIKE {$w0}\n                         OR long_desc \t\t    LIKE {$w1}\n                         OR dx_code\t\t\t    LIKE {$w2}\n                         OR formatted_dx_code\tLIKE {$w3}) ";
     }
     if ($type == 'ICD9' || $type == 'BOTH') {
         /**
          * ICD9
          */
         $sql = "SELECT dx_id AS id,\n\t\t\t\t\t\t  formatted_dx_code,\n\t\t\t\t\t\t  formatted_dx_code AS code,\n\t\t\t\t\t\t  dx_code,\n\t\t\t\t\t\t  dx_code \t\t\tAS xcode,\n\t\t\t\t\t\t  long_desc,\n\t\t\t\t\t\t  long_desc \t\tAS code_text,\n\t\t\t\t\t\t  short_desc,\n\t\t\t\t\t\t  'ICD9-DX'\t\t\tAS code_type\n\t\t\t\t     FROM icd9_dx_code\n\t                WHERE active = '1'\n\t                  AND revision = '{$revision}'\n\t                  {$whereQuery}\n\t             ORDER BY formatted_dx_code ASC";
         $recordSet = $this->conn->prepare($sql);
         $recordSet->execute($wheres);
         $records = array_merge($records, $recordSet->fetchAll(PDO::FETCH_ASSOC));
     } elseif ($type == 'ICD10' || $type == 'BOTH') {
         /**
          *  get last icd10 code revision
          */
         $revision = $this->getLastRevisionByCodeType('ICD10');
         /**
          * ICD10 DX
          */
         $sql = "SELECT dx_id AS id,\n\t\t\t\t\t\t  formatted_dx_code,\n\t\t\t\t\t\t  formatted_dx_code AS code,\n\t\t\t\t\t\t  dx_code,\n\t\t\t\t\t\t  dx_code \t\t\tAS xcode,\n\t\t\t\t\t\t  long_desc,\n\t\t\t\t\t\t  TRIM(long_desc) \t\tAS code_text,\n\t\t\t\t\t\t  short_desc,\n\t\t\t\t\t\t  'ICD10-CM'\t\tAS code_type\n\t\t\t\t\t FROM icd10_dx_order_code\n                    WHERE active = '1'\n                      AND revision = '{$revision}'\n                     {$whereQuery}\n                 ORDER BY formatted_dx_code ASC";
         $recordSet = $this->conn->prepare($sql);
         $recordSet->execute($wheres);
         $records = array_merge($records, $recordSet->fetchAll(PDO::FETCH_ASSOC));
     }
     if (is_object($params)) {
         $total = count($records);
         if (isset($params->start) && isset($params->limit)) {
             $records = array_slice($records, $params->start, $params->limit, true);
         }
         return array('totals' => $total, 'rows' => $records);
     } else {
         return $records;
     }
 }
Ejemplo n.º 2
0
 function &current()
 {
     $temp = parent::current();
     if ($temp['invisible'] == 1) {
         Globals::setGlobal('num_online_invisible', Globals::getGlobal('num_online_invisible') + 1);
     }
     if ($temp['user_id'] != 0) {
         $group = get_user_max_group($temp, $this->groups);
         $temp['color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $temp['font_weight'] = @$group['min_perm'] > MEMBER ? 'bold' : 'normal';
     }
     /* Should we free the result? */
     if ($this->row == $this->size - 1) {
         $this->result->freeResult();
     }
     if ($temp['name'] != '' && (isset($temp['invisible']) && $temp['invisible'] == 0 || !isset($temp['invisible']))) {
         return $temp;
     }
 }
 function current()
 {
     $temp = parent::current();
     if ($temp['invisible'] == 1) {
         Globals::setGlobal('num_online_invisible', Globals::getGlobal('num_online_invisible') + 1);
     }
     if ($temp['user_id'] >= 0) {
         $group = get_user_max_group($temp, $this->groups);
         $temp['color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $temp['font_weight'] = @$group['min_perm'] > MEMBER ? 'bold' : 'normal';
     }
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['user_id']);
     //if($temp['name'] != '') {
     //	if(((isset($temp['invisible']) && $temp['invisible'] == 0) || !isset($temp['invisible']))) {
     return $temp;
     //	}
     //}
 }
Ejemplo n.º 4
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     global $_URL, $_QUERYPARAMS, $_USERGROUPS, $_SESS;
     /**
      * Error Checking
      */
     if (!isset($request['id']) || !$request['id'] || intval($request['id']) == 0) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDTOPIC'));
         $template->setInfo('content', $template->getVar('L_TOPICDOESNTEXIST'), FALSE);
         return TRUE;
     }
     /* Get our topic */
     $topic = $dba->getRow("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['topic'] . " FROM " . TOPICS . " t LEFT JOIN " . INFO . " i ON t.topic_id = i.id WHERE i.id = " . intval($request['id']));
     if (!$topic || !is_array($topic) || empty($topic)) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDTOPIC'));
         $template->setInfo('content', $template->getVar('L_TOPICDOESNTEXIST'), FALSE);
         return TRUE;
     }
     if ($topic['is_draft'] == 1) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDTOPICVIEW'));
         $template->setInfo('content', $template->getVar('L_CANTVIEWDRAFT'), FALSE);
         return TRUE;
     }
     if ($topic['queue'] == 1) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDTOPICVIEW'));
         $template->setInfo('content', $template->getVar('L_TOPICPENDINGMOD'), FALSE);
         return TRUE;
     }
     if ($topic['display'] == 0) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDTOPICVIEW'));
         $template->setInfo('content', $template->getVar('L_TOPICISHIDDEN'), FALSE);
         return TRUE;
     }
     /* Get the current forum */
     $forum = $dba->getRow("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['forum'] . " FROM " . FORUMS . " f LEFT JOIN " . INFO . " i ON f.forum_id = i.id WHERE i.id = " . intval($topic['forum_id']));
     if (!$forum || !is_array($forum) || empty($forum)) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDFORUM'));
         $template->setInfo('content', $template->getVar('L_FORUMDOESNTEXIST'), FALSE);
         return TRUE;
     }
     if (get_map($user, 'forums', 'can_view', array()) > $user['perms'] || get_map($user, 'topics', 'can_view', array('forum_id' => $forum['id'])) > $user['perms']) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'), $forum['row_left'], $forum['row_right']);
         $template->setInfo('content', $template->getVar('L_PERMCANTVIEWTOPIC'), FALSE);
         return TRUE;
     }
     /**
      * Set the new breadcrumbs bit
      */
     $template = BreadCrumbs($template, $topic['name'], iif($topic['topic_type'] == TOPIC_GLOBAL, FALSE, $forum['row_left']), iif($topic['topic_type'] == TOPIC_GLOBAL, FALSE, $forum['row_right']));
     /** 
      * Get the users Browsing this topic 
      */
     /* Set the extra SQL query fields to check */
     $extra = " AND s.location_file = '" . $dba->Quote($_URL->file) . "' AND s.location_id = " . intval($topic['id']);
     $expired = time() - ini_get('session.gc_maxlifetime');
     $num_online_total = $dba->getValue("SELECT COUNT(s.id) FROM " . SESSIONS . " s WHERE s.seen >= {$expired} {$extra}");
     if ($num_online_total > 0) {
         $users_browsing =& new OnlineUsersIterator($extra);
         /* Set the users browsing list */
         $template->setList('users_browsing', $users_browsing);
         $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_online_total' => $num_online_total);
         $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
         $template->setVar('num_online_members', $stats['num_online_members']);
         $template->setVar('users_browsing', $template->getVar('L_USERSBROWSINGTOPIC'));
         $template->setVar('online_stats', sprintf($template->getVar('L_USERSBROWSINGSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
         /* Set the User's Browsing file */
         $template->setFile('users_browsing', 'users_browsing.html');
         $groups = array();
         /* Set the usergroups legend list */
         foreach ($_USERGROUPS as $group) {
             if ($group['display_legend'] == 1) {
                 $groups[] = $group;
             }
         }
         $groups =& new FAArrayIterator($groups);
         $template->setList('usergroups_legend', $groups);
     }
     /**
      * Is this topic expired?
      */
     $extra = '';
     if ($topic['topic_type'] > TOPIC_NORMAL && $topic['topic_expire'] > 0) {
         if ($topic['created'] + 3600 * 24 * $topic['topic_expire'] > time()) {
             $extra = ",topic_expire=0,topic_type=" . TOPIC_NORMAL;
         }
     }
     /**
      * Is this user subscribed to this topic?
      */
     $subscription = $dba->getRow("SELECT * FROM " . SUBSCRIPTIONS . " WHERE topic_id = " . intval($topic['id']) . " AND user_id = " . intval($user['id']));
     if (is_array($subscription) && !empty($subscription)) {
         if ($subscription['last_visit'] < $topic['reply_time']) {
             /* Set the user to keep subscribing to this topic */
             $dba->executeUpdate("UPDATE " . SUBSCRIPTIONS . " SET requires_revisit = 0, last_visit = " . time() . " WHERE topic_id = " . intval($topic['id']) . " AND user_id = " . intval($user['id']));
         }
     }
     /* Add the topic info to the template */
     foreach ($topic as $key => $val) {
         $template->setVar('topic_' . $key, $val);
     }
     /* Update the number of views for this topic */
     $dba->executeUpdate("UPDATE " . TOPICS . " SET views=views+1 {$extra} WHERE topic_id=" . intval($topic['id']));
     $resultsperpage = $forum['postsperpage'];
     $num_results = @(($topic['row_right'] - $topic['row_left'] - 1) / 2);
     $perpage = isset($request['limit']) && ctype_digit($request['limit']) && intval($request['limit']) > 0 ? intval($request['limit']) : $resultsperpage;
     $num_pages = ceil($num_results / $perpage);
     $page = isset($request['page']) && ctype_digit($request['page']) && intval($request['page']) > 0 ? intval($request['page']) : 1;
     $pager =& new TPL_Paginator($_URL, $num_results, $page, $perpage);
     if ($num_results > $perpage) {
         $template->setPager('replies_pager', $pager);
     }
     /* Outside valid page range, redirect */
     if (!$pager->hasPage($page) && $num_results > $resultsperpage) {
         $template->setInfo('content', $template->getVar('L_PASTPAGELIMIT'));
         $template->setRedirect('viewtopic.php?id=' . $topic['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
     }
     $sort_orders = array('name', 'created', 'id', 'poster_name');
     /* Get the replies for this topic */
     $topic['daysprune'] = isset($request['daysprune']) && ctype_digit($request['daysprune']) ? iif($request['daysprune'] == -1, 0, intval($request['daysprune'])) : 0;
     $topic['sortorder'] = isset($request['order']) && ($request['order'] == 'ASC' || $request['order'] == 'DESC') ? $request['order'] : 'ASC';
     $topic['sortedby'] = isset($request['sort']) && in_array($request['sort'], $sort_orders) ? $request['sort'] : 'created';
     $topic['start'] = ($page - 1) * $perpage;
     $topic['postsperpage'] = $perpage;
     /* Do we set the similar topics? */
     $result =& $dba->executeQuery("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['topic'] . " FROM " . TOPICS . " t LEFT JOIN " . INFO . " i ON t.topic_id = i.id WHERE ((lower(i.name) LIKE lower('%" . $dba->quote($topic['name']) . "%') OR lower(i.name) LIKE lower('%" . $dba->quote($topic['body_text']) . "%')) OR (lower(t.body_text) LIKE lower('%" . $dba->quote($topic['name']) . "%') OR lower(t.body_text) LIKE lower('%" . $dba->quote($topic['body_text']) . "%'))) AND t.is_draft = 0 AND i.id <> " . intval($topic['id']));
     if ($result->numrows() > 0) {
         $it =& new TopicsIterator($result, &$session, $template->getVar('IMG_DIR'), $forum);
         $template->setList('similar_topics', $it);
         $template->setFile('similar_topics', 'similar_topics.html');
     }
     /* set the topic iterator */
     $topic_list =& new TopicIterator($topic, TRUE);
     $template->setList('topic', $topic_list);
     $template->setVar('next_oldest', intval($dba->getValue("SELECT id FROM " . INFO . " WHERE id < " . $topic['id'] . " AND row_type = " . TOPIC . " LIMIT 1")));
     $template->setVar('next_newest', intval($dba->getValue("SELECT id FROM " . INFO . " WHERE id > " . $topic['id'] . " AND row_type = " . TOPIC . " LIMIT 1")));
     /* Set the file we need */
     $template->setFile('content', 'viewtopic.html');
     return TRUE;
 }
Ejemplo n.º 5
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_DATASTORE, $_SETTINGS;
     $this->dba = $request['dba'];
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($_REQUEST['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Make sure the we are trying to post into a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTPOSTTONONFORUM'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_CANTPOSTTONONFORUM');
     }
     /* Do we have permission to post to this forum? */
     if ($request['user']->get('perms') < get_map('topics', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $action = new K4InformationAction(new K4LanguageElement('L_PERMCANTPOST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_PERMCANTPOST');
     }
     /* General error checking */
     if (!isset($_REQUEST['name']) || $_REQUEST['name'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICNAME'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICNAME');
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars']), intval($_SETTINGS['topicminchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICMESSAGE'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICMESSAGE');
     }
     /* Get our topic */
     $draft = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']) . " AND is_draft = 1 AND poster_id = " . intval($request['user']->get('id')));
     if (!$draft || !is_array($draft) || empty($draft)) {
         $action = new K4InformationAction(new K4LanguageElement('L_DRAFTDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_DRAFTDOESNTEXIST');
     }
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTTOPIC', $forum);
     $created = time();
     /* Initialize the bbcode parser with the topic message */
     $_REQUEST['message'] = substr($_REQUEST['message'], 0, $_SETTINGS['postmaxchars']);
     /* Parse the bbcode */
     $body_text = $_REQUEST['message'];
     $submit_type = isset($_REQUEST['submit_type']) ? $_REQUEST['submit_type'] : 'post';
     if (!isset($_REQUEST['disable_bbcode']) || !$_REQUEST['disable_bbcode']) {
         $parser =& new BBParser();
         Globals::setGlobal('forum_id', $forum['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $forum['maxpolloptions'] ? $forum['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $forum['maxpollquestions'] ? $forum['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         if ($submit_type == 'post' || $submit_type == 'draft' || isset($_REQUEST['post'])) {
             $parser->register('BBPollNode');
         }
         $body_text = $parser->parse($body_text);
         $is_poll = Globals::getGlobal('is_poll');
     }
     // permissions are taken into account inside the poller
     //$poller		= &new K4BBPolls($body_text, $draft['body_text'], $forum, $draft['post_id']);
     /**
      * Figure out what type of topic type this is
      */
     $post_type = isset($_REQUEST['post_type']) && intval($_REQUEST['post_type']) != 0 ? $_REQUEST['post_type'] : TOPIC_NORMAL;
     if ($post_type == TOPIC_STICKY && $request['user']->get('perms') < get_map('sticky', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $post_type = TOPIC_NORMAL;
     } else {
         if ($post_type == TOPIC_ANNOUNCE && $request['user']->get('perms') < get_map('announce', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $post_type = TOPIC_NORMAL;
         }
     }
     $is_feature = isset($_REQUEST['is_feature']) && $_REQUEST['is_feature'] == 'yes' ? 1 : 0;
     if ($is_feature == 1 && $request['user']->get('perms') < get_map('feature', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $is_feature = 0;
     }
     /* If we are submitting or saving a draft */
     if ($submit_type == 'post' || $submit_type == 'draft' || (isset($_REQUEST['post']) || isset($_REQUEST['draft']))) {
         /**
          * Build the queries to add the draft
          */
         $poster_name = $request['user']->get('id') <= 0 ? k4_htmlentities(isset($_REQUEST['poster_name']) ? $_REQUEST['poster_name'] : '', ENT_QUOTES) : $request['user']->get('name');
         $update_a = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET name=?,body_text=?,posticon=?,disable_html=?,disable_bbcode=?,disable_emoticons=?,disable_sig=?,disable_areply=?,disable_aurls=?,is_draft=?,post_type=?,is_feature=?,is_poll=?,created=? WHERE post_id=?");
         /* Set the informtion */
         $update_a->setInt(1, $created);
         $update_a->setInt(2, $draft['post_id']);
         /* Set the topic information */
         $update_a->setString(1, k4_htmlentities(html_entity_decode($_REQUEST['name']), ENT_QUOTES));
         $update_a->setString(2, $body_text);
         $update_a->setString(3, $request['user']->get('perms') >= get_map('posticons', 'can_add', array('forum_id' => $forum['forum_id'])) ? isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif' : 'clear.gif');
         $update_a->setInt(4, isset($_REQUEST['disable_html']) && $_REQUEST['disable_html'] ? 1 : 0);
         $update_a->setInt(5, isset($_REQUEST['disable_bbcode']) && $_REQUEST['disable_bbcode'] ? 1 : 0);
         $update_a->setInt(6, isset($_REQUEST['disable_emoticons']) && $_REQUEST['disable_emoticons'] ? 1 : 0);
         $update_a->setInt(7, isset($_REQUEST['enable_sig']) && $_REQUEST['enable_sig'] ? 0 : 1);
         $update_a->setInt(8, isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply'] ? 1 : 0);
         $update_a->setInt(9, isset($_REQUEST['disable_aurls']) && $_REQUEST['disable_aurls'] ? 1 : 0);
         $update_a->setInt(10, 0);
         $update_a->setInt(11, $post_type);
         $update_a->setInt(12, $is_feature);
         $update_a->setInt(13, $is_poll);
         $update_a->setInt(14, $created);
         $update_a->setInt(15, $draft['post_id']);
         /**
          * Do the queries
          */
         $update_a->executeUpdate();
         $forum_update = $request['dba']->prepareStatement("UPDATE " . K4FORUMS . " SET topics=topics+1,posts=posts+1,post_created=?,post_name=?,post_uname=?,post_id=?,post_uid=?,post_posticon=? WHERE forum_id=?");
         $datastore_update = $request['dba']->prepareStatement("UPDATE " . K4DATASTORE . " SET data=? WHERE varname=?");
         if (isset($_REQUEST['submit_type']) && $_REQUEST['submit_type'] == 'post' || isset($_REQUEST['post'])) {
             $request['dba']->executeUpdate("UPDATE " . K4USERINFO . " SET num_posts=num_posts+1,total_posts=total_posts+1 WHERE user_id=" . intval($request['user']->get('id')));
         }
         /* Set the forum values */
         $forum_update->setInt(1, $created);
         $forum_update->setString(2, k4_htmlentities(html_entity_decode($_REQUEST['name']), ENT_QUOTES));
         $forum_update->setString(3, $poster_name);
         $forum_update->setInt(4, $draft['post_id']);
         $forum_update->setInt(5, $request['user']->get('id'));
         $forum_update->setString(6, iif($request['user']->get('perms') >= get_map('posticons', 'can_add', array('forum_id' => $forum['forum_id'])), isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif', 'clear.gif'));
         $forum_update->setInt(7, $forum['forum_id']);
         /* Set the datastore values */
         $datastore = $_DATASTORE['forumstats'];
         $datastore['num_topics'] = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4POSTS . " WHERE is_draft=0");
         $datastore_update->setString(1, serialize($datastore));
         $datastore_update->setString(2, 'forumstats');
         /**
          * Update the forums table and datastore table
          */
         $forum_update->executeUpdate();
         $datastore_update->executeUpdate();
         reset_cache('datastore');
         /**
          * Subscribe this user to the topic
          */
         if (isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply']) {
             $subscribe = $request['dba']->prepareStatement("INSERT INTO " . K4SUBSCRIPTIONS . " (user_id,post_id,forum_id,email) VALUES (?,?,?,?)");
             $subscribe->setInt(1, $request['user']->get('id'));
             $subscribe->setInt(2, $draft['id']);
             $subscribe->setInt(3, $forum['forum_id']);
             $subscribe->setString(4, $request['user']->get('email'));
             $subscribe->executeUpdate();
         }
         // deal with attachments
         if ($request['template']->getVar('nojs') == 0) {
             attach_files($request, $forum, $draft['post_id']);
         }
         // set up the topic queue
         set_send_topic_mail($forum['forum_id'], $poster_name == '' ? $request['template']->getVar('L_GUEST') : $poster_name);
         /* Redirect the user */
         $action = new K4InformationAction(new K4LanguageElement('L_ADDEDTOPIC', k4_htmlentities(html_entity_decode($_REQUEST['name']), ENT_QUOTES), $forum['name']), 'content', FALSE, 'viewtopic.php?id=' . $draft['post_id'], 3);
         return $action->execute($request);
         /* If we are previewing */
     } else {
         /**
          * Post Previewing
          */
         if (!USE_XMLHTTP) {
             $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
             /* Get and set the emoticons and post icons to the template */
             $emoticons = $request['dba']->executeQuery("SELECT * FROM " . K4EMOTICONS . " WHERE clickable=1");
             $posticons = $request['dba']->executeQuery("SELECT * FROM " . K4POSTICONS);
             /* Add the emoticons and posticons */
             $request['template']->setList('emoticons', $emoticons);
             $request['template']->setList('posticons', $posticons);
             /* Set some emoticon information */
             $request['template']->setVar('emoticons_per_row', $request['template']->getVar('smcolumns'));
             $request['template']->setVar('emoticons_per_row_remainder', $request['template']->getVar('smcolumns') - 1);
             $request['template']->setVar('newtopic_action', 'newtopic.php?act=postdraft');
             $request['template']->setVisibility('post_topic', TRUE);
             post_attachment_options($request, $forum, $draft);
             topic_post_options($request['template'], $request['user'], $forum);
             /* Create our editor */
             create_editor($request, $_REQUEST['message'], 'post', $forum);
         }
         /* Set topic iterator array elements to be passed to the template */
         $topic_preview = array('post_id' => @$draft['post_id'], 'name' => k4_htmlentities(html_entity_decode($_REQUEST['name']), ENT_QUOTES), 'posticon' => isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif', 'body_text' => $body_text, 'poster_name' => html_entity_decode($draft['poster_name'], ENT_QUOTES), 'poster_id' => $request['user']->get('id'), 'is_poll' => $draft['is_poll'], 'row_left' => 0, 'row_right' => 0, 'post_type' => $post_type, 'is_feature' => $is_feature, 'posticon' => $request['user']->get('perms') >= get_map('posticons', 'can_add', array('forum_id' => $forum['forum_id'])) ? isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif' : 'clear.gif', 'disable_html' => isset($_REQUEST['disable_html']) && $_REQUEST['disable_html'] ? 1 : 0, 'disable_sig' => isset($_REQUEST['enable_sig']) && $_REQUEST['enable_sig'] ? 0 : 1, 'disable_bbcode' => isset($_REQUEST['disable_bbcode']) && $_REQUEST['disable_bbcode'] ? 1 : 0, 'disable_emoticons' => isset($_REQUEST['disable_emoticons']) && $_REQUEST['disable_emoticons'] ? 1 : 0, 'disable_areply' => isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply'] ? 1 : 0, 'disable_aurls' => isset($_REQUEST['disable_aurls']) && $_REQUEST['disable_aurls'] ? 1 : 0);
         /* Add the topic information to the template */
         $topic_iterator = new TopicIterator($request['dba'], $request['user'], $topic_preview, FALSE);
         $request['template']->setList('topic', $topic_iterator);
         /* Assign the topic preview values to the template */
         $topic_preview['body_text'] = $_REQUEST['message'];
         foreach ($topic_preview as $key => $val) {
             $request['template']->setVar('topic_' . $key, $val);
         }
         /* Assign the forum information to the template */
         foreach ($forum as $key => $val) {
             $request['template']->setVar('forum_' . $key, $val);
         }
         $request['template']->setVar('is_topic', 1);
         if (!USE_XMLHTTP) {
             /* Set the the button display options */
             $request['template']->setVisibility('save_draft', FALSE);
             $request['template']->setVisibility('load_button', FALSE);
             $request['template']->setVisibility('edit_topic', TRUE);
             $request['template']->setVisibility('post_id', TRUE);
             /* set the breadcrumbs bit */
             k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTTOPIC', $forum);
             /* Set the post topic form */
             $request['template']->setVar('forum_forum_id', $forum['forum_id']);
             $request['template']->setFile('preview', 'post_preview.html');
             $request['template']->setFile('content', 'newtopic.html');
         } else {
             $templateset = $request['user']->isMember() ? $request['user']->get('templateset') : $forum['defaultstyle'];
             $html = $request['template']->run(BB_BASE_DIR . '/templates/' . $templateset . '/post_preview.html');
             xmlhttp_header();
             echo $html;
             xmlhttp_footer();
         }
     }
     return TRUE;
 }
Ejemplo n.º 6
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     global $_URL, $_QUERYPARAMS, $_USERGROUPS, $_SESS, $_ALLFORUMS;
     if (!isset($request['id']) || !$request['id'] || intval($request['id']) == 0) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDFORUM'));
         $template->setInfo('content', $template->getVar('L_FORUMDOESNTEXIST'), FALSE);
         return TRUE;
     }
     /* Get the current forum/category */
     $forum = $_ALLFORUMS[$request['id']];
     $query = $forum['row_type'] & FORUM ? "SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['forum'] . " FROM " . FORUMS . " f LEFT JOIN " . INFO . " i ON f.forum_id = i.id WHERE i.id = " . intval($request['id']) : "SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['category'] . " FROM " . CATEGORIES . " c LEFT JOIN " . INFO . " i ON c.category_id = i.id WHERE i.id = " . intval($request['id']);
     $forum = $dba->getRow($query);
     if (!$forum || !is_array($forum) || empty($forum)) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INVALIDFORUM'));
         $template->setInfo('content', $template->getVar('L_FORUMDOESNTEXIST'), FALSE);
         return TRUE;
     }
     if ($forum['row_type'] == FORUM && @$forum['is_link'] == 1) {
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'), $forum['row_left'], $forum['row_right']);
         $template->setInfo('content', $template->getVar('L_REDIRECTING'));
         if ($forum['link_show_redirects'] == 1) {
             $template->setRedirect('redirect.php?id=' . $forum['id'], 3);
         } else {
             $template->setRedirect($forum['link_href'], 3);
         }
         return TRUE;
     }
     /* Set the extra SQL query fields to check */
     $extra = " AND s.location_file = '" . $dba->Quote($_URL->file) . "' AND s.location_id = " . intval($forum['id']);
     $forum_can_view = $forum['row_type'] & CATEGORY ? get_map($user, 'categories', 'can_view', array()) : get_map($user, 'forums', 'can_view', array());
     $expired = time() - ini_get('session.gc_maxlifetime');
     $num_online_total = $dba->getValue("SELECT COUNT(s.id) as num_online_total FROM " . SESSIONS . " s WHERE s.seen >= {$expired} {$extra}");
     /* If there are more than 0 people browsing the forum, display the stats */
     if ($num_online_total > 0 && $forum_can_view <= $user['perms'] && ($forum['row_type'] & CATEGORY || $forum['row_type'] & FORUM)) {
         $users_browsing =& new OnlineUsersIterator($extra);
         /* Set the users browsing list */
         $template->setList('users_browsing', $users_browsing);
         $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_online_total' => $num_online_total);
         $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
         $element = $forum['row_type'] & CATEGORY ? 'L_USERSBROWSINGCAT' : 'L_USERSBROWSINGFORUM';
         $template->setVar('num_online_members', $stats['num_online_members']);
         $template->setVar('users_browsing', $template->getVar($element));
         $template->setVar('online_stats', sprintf($template->getVar('L_USERSBROWSINGSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
         /* Set the User's Browsing file */
         $template->setFile('users_browsing', 'users_browsing.html');
         $groups = array();
         /* Set the usergroups legend list */
         foreach ($_USERGROUPS as $group) {
             if ($group['display_legend'] == 1) {
                 $groups[] = $group;
             }
         }
         $groups =& new FAArrayIterator($groups);
         $template->setList('usergroups_legend', $groups);
     }
     if ($forum_can_view > $user['perms']) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'), $forum['row_left'], $forum['row_right']);
         $template->setInfo('content', $template->getVar('L_PERMCANTVIEW'), FALSE);
         return TRUE;
     }
     /* Set the breadcrumbs bit */
     $template = BreadCrumbs($template, NULL, $forum['row_left'], $forum['row_right']);
     /* Set all of the category/forum info to the template */
     $template->setVarArray($forum);
     /* If we are looking at a category */
     if ($forum['row_type'] & CATEGORY) {
         if (get_map($user, 'categories', 'can_view', array()) > $user['perms']) {
             /* set the breadcrumbs bit */
             $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'), $forum['row_left'], $forum['row_right']);
             $template->setInfo('content', $template->getVar('L_PERMCANTVIEW'));
             return TRUE;
         }
         /* Set the proper query params */
         $query_params = $_QUERYPARAMS['info'] . $_QUERYPARAMS['category'];
         /* Set the Categories list */
         $categories =& new CategoriesIterator("SELECT {$query_params} FROM " . INFO . " i LEFT JOIN " . CATEGORIES . " c ON c.category_id = i.id WHERE i.row_type = " . CATEGORY . " AND i.row_left = " . $forum['row_left'] . " AND i.row_right = " . $forum['row_right'] . " AND i.id = " . $forum['id'] . " ORDER BY i.row_order ASC");
         $template->setList('categories', $categories);
         /* Hide the welcome message at the top of the forums.html template */
         $template->hide('welcome_msg');
         /* Show the forum status icons */
         $template->show('forum_status_icons');
         /* Show the 'Mark these forums Read' link */
         $template->show('mark_these_forums');
         /* Set the forums template to content variable */
         $template->setFile('content', 'forums.html');
         /* If we are looking at a forum */
     } else {
         if ($forum['row_type'] & FORUM) {
             /* Add the forum info to the template */
             foreach ($forum as $key => $val) {
                 $template->setVar('forum_' . $key, $val);
             }
             /* If this forum has sub-forums */
             if (isset_forum_cache_item('subforums', $forum['id']) && $forum['subforums'] == 1) {
                 /* Cache this forum as having subforums */
                 set_forum_cache_item('subforums', 1, $forum['id']);
                 /* Show the table that holds the subforums */
                 $template->show('subforums');
                 /* Set the proper query params */
                 $query_params = $_QUERYPARAMS['info'] . $_QUERYPARAMS['forum'];
                 /* Set the sub-forums list */
                 $template->setList('subforums', new ForumsIterator("SELECT {$query_params} FROM " . INFO . " i LEFT JOIN " . FORUMS . " f ON f.forum_id = i.id WHERE i.row_left > " . $forum['row_left'] . " AND i.row_right < " . $forum['row_right'] . " AND i.row_type = " . FORUM . " AND i.parent_id = " . $forum['id'] . " ORDER BY i.row_order ASC"));
                 $template->setFile('content', 'subforums.html');
             }
             if (get_map($user, 'topics', 'can_view', array('forum_id' => $forum['id'])) > $user['perms']) {
                 /* set the breadcrumbs bit */
                 $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'), $forum['row_left'], $forum['row_right']);
                 $template->setInfo('content_extra', $template->getVar('L_CANTVIEWFORUMTOPICS'), FALSE);
                 return TRUE;
             }
             /**
              * Forum settings
              */
             /* Set the topics template to the content variable */
             $template->setFile('content_extra', 'topics.html');
             /* Set what this user can/cannot do in this forum */
             $template->setVar('forum_user_topic_options', sprintf($template->getVar('L_FORUMUSERTOPICPERMS'), iif(get_map($user, 'topics', 'can_add', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN')), iif(get_map($user, 'topics', 'can_edit', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN')), iif(get_map($user, 'topics', 'can_del', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN')), iif(get_map($user, 'attachments', 'can_add', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN'))));
             $template->setVar('forum_user_reply_options', sprintf($template->getVar('L_FORUMUSERREPLYPERMS'), iif(get_map($user, 'replies', 'can_add', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN')), iif(get_map($user, 'replies', 'can_edit', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN')), iif(get_map($user, 'replies', 'can_del', array('forum_id' => $forum['id'])) > $user['perms'], $template->getVar('L_CANNOT'), $template->getVar('L_CAN'))));
             /* Create an array with all of the possible sort orders we can have */
             $sort_orders = array('name', 'reply_time', 'num_replies', 'views', 'reply_uname', 'rating');
             /**
              * Pagination
              */
             /* Create the Pagination */
             $resultsperpage = $forum['topicsperpage'];
             $num_results = $forum['topics'];
             $perpage = isset($request['limit']) && ctype_digit($request['limit']) && intval($request['limit']) > 0 ? intval($request['limit']) : $resultsperpage;
             $num_pages = ceil($num_results / $perpage);
             $page = isset($request['page']) && ctype_digit($request['page']) && intval($request['page']) > 0 ? intval($request['page']) : 1;
             $pager =& new TPL_Paginator($_URL, $num_results, $page, $perpage);
             if ($num_results > $perpage) {
                 $template->setPager('topics_pager', $pager);
             }
             /* Get the topics for this forum */
             $daysprune = isset($request['daysprune']) && ctype_digit($request['daysprune']) ? iif($request['daysprune'] == -1, 0, intval($request['daysprune'])) : 30;
             $sortorder = isset($request['order']) && ($request['order'] == 'ASC' || $request['order'] == 'DESC') ? $request['order'] : 'DESC';
             $sortedby = isset($request['sort']) && in_array($request['sort'], $sort_orders) ? $request['sort'] : 'created';
             $start = ($page - 1) * $perpage;
             if ($forum['topics'] > 0) {
                 /**
                  * Topic Setting
                  */
                 /* get the topics */
                 $topics =& $dba->prepareStatement("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['topic'] . " FROM " . TOPICS . " t LEFT JOIN " . INFO . " i ON t.topic_id = i.id WHERE i.created>=? AND t.is_draft=0 AND t.queue = 0 AND t.display = 1 AND i.row_type=" . TOPIC . " AND t.forum_id = " . intval($forum['id']) . " AND (t.topic_type <> " . TOPIC_GLOBAL . " AND t.topic_type <> " . TOPIC_ANNOUNCE . " AND t.topic_type <> " . TOPIC_STICKY . " AND t.is_feature = 0) ORDER BY {$sortedby} {$sortorder} LIMIT ?,?");
                 /* Set the query values */
                 $topics->setInt(1, $daysprune * (3600 * 24));
                 $topics->setInt(2, $start);
                 $topics->setInt(3, $perpage);
                 /* Execute the query */
                 $result =& $topics->executeQuery();
                 /* Apply the topics iterator */
                 $it =& new TopicsIterator($result, &$session, $template->getVar('IMG_DIR'), $forum);
                 $template->setList('topics', $it);
                 /**
                  * Get announcement/global topics
                  */
                 if ($page == 1) {
                     $announcements =& $dba->executeQuery("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['topic'] . " FROM " . TOPICS . " t LEFT JOIN " . INFO . " i ON t.topic_id = i.id WHERE t.is_draft=0 AND t.queue = 0 AND t.display = 1 AND i.row_type=" . TOPIC . " AND t.forum_id = " . intval($forum['id']) . " AND (t.topic_type = " . TOPIC_GLOBAL . " OR t.topic_type = " . TOPIC_ANNOUNCE . ") ORDER BY i.created DESC");
                     if ($announcements->numrows() > 0) {
                         $a_it =& new TopicsIterator($announcements, &$session, $template->getVar('IMG_DIR'), $forum);
                         $template->setList('announcements', $a_it);
                     }
                 }
                 /**
                  * Get sticky/feature topics
                  */
                 $importants =& $dba->executeQuery("SELECT " . $_QUERYPARAMS['info'] . $_QUERYPARAMS['topic'] . " FROM " . TOPICS . " t LEFT JOIN " . INFO . " i ON t.topic_id = i.id WHERE t.is_draft=0 AND t.queue = 0 AND t.display = 1 AND i.row_type=" . TOPIC . " AND t.forum_id = " . intval($forum['id']) . " AND (t.topic_type <> " . TOPIC_GLOBAL . " AND t.topic_type <> " . TOPIC_ANNOUNCE . ") AND (t.topic_type = " . TOPIC_STICKY . " OR t.is_feature = 1) ORDER BY i.created DESC");
                 if ($importants->numrows() > 0) {
                     $i_it =& new TopicsIterator($importants, &$session, $template->getVar('IMG_DIR'), $forum);
                     $template->setList('importants', $i_it);
                 }
                 /* Outside valid page range, redirect */
                 if (!$pager->hasPage($page) && $num_results > $resultsperpage) {
                     $template->setVar('topics_message', $template->getVar('L_PASTPAGELIMIT'));
                     $template->setRedirect('viewforum.php?id=' . $forum['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
                     return TRUE;
                 }
             }
             /* If there are no topics, set the right messageto display */
             if ($forum['topics'] <= 0) {
                 $template->show('no_topics');
                 $template->setVar('topics_message', iif($daysprune == 0, $template->getVar('L_NOPOSTSINFORUM'), sprintf($template->getVar('L_FORUMNOPOSTSSINCE'), $daysprune)));
                 return TRUE;
             }
             /**
              * Moderator functions
              */
             $template->setVar('modpanel', 0);
             if (is_moderator($user, $forum)) {
                 $template->setVar('modpanel', 1);
             }
         } else {
             /* set the breadcrumbs bit */
             $template = BreadCrumbs($template, $template->getVar('L_INVALIDFORUM'));
             $template->setInfo('content', $template->getVar('L_FORUMDOESNTEXIST'), FALSE);
             return TRUE;
         }
     }
     /* Add the cookies for this forum's topics */
     bb_execute_topiccache();
     return TRUE;
 }
Ejemplo n.º 7
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_USERGROUPS, $_URL;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     if (isset($_REQUEST['f']) && intval($_REQUEST['f']) != 0 || isset($_REQUEST['c']) && intval($_REQUEST['c']) != 0) {
         $thing = isset($_REQUEST['f']) ? 'f' : 'c';
         $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($_REQUEST[$thing]));
     } else {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', TRUE);
         return $action->execute($request);
     }
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     if ($forum['row_type'] & FORUM && $forum['is_link'] == 1) {
         if ($forum['link_show_redirects'] == 1) {
             $action = new K4InformationAction(new K4LanguageElement('L_REDIRECTING'), 'content', FALSE, 'redirect.php?id=' . $forum['forum_id'], 3);
         } else {
             $action = new K4InformationAction(new K4LanguageElement('L_REDIRECTING'), 'content', FALSE, $forum['link_href'], 3);
         }
         return $action->execute($request);
     }
     /* Set the extra SQL query fields to check */
     $extra = " AND location_file = '" . $request['dba']->Quote($_URL->file) . "' AND location_id = " . ($forum['row_type'] & CATEGORY ? intval($forum['category_id']) : intval($forum['forum_id']));
     $user_extra = $request['user']->isMember() ? ' OR (seen > 0 AND user_id = ' . intval($request['user']->get('id')) . ')' : '';
     $forum_can_view = $forum['row_type'] & CATEGORY ? get_map('', 'can_view', array('category_id' => $forum['category_id'])) : get_map('', 'can_view', array('forum_id' => $forum['forum_id']));
     $expired = time() - ini_get('session.gc_maxlifetime');
     $num_online_total = $request['dba']->getValue("SELECT COUNT(id) FROM " . K4SESSIONS . " WHERE ((seen >= {$expired} {$extra}) {$user_extra})");
     $num_online_total = !$request['user']->isMember() ? $num_online_total + 1 : $num_online_total;
     /* If there are more than 0 people browsing the forum, display the stats */
     if ($num_online_total > 0 && $forum_can_view <= $request['user']->get('perms')) {
         $query = "SELECT * FROM " . K4SESSIONS . " WHERE ((seen >= {$expired} {$extra}) {$user_extra}) AND ((user_id > 0) OR (user_id = 0 AND name <> '')) GROUP BY name ORDER BY seen DESC";
         $users_browsing =& new K4OnlineUsersIterator($request['dba'], '', $request['dba']->executeQuery($query));
         /* Set the users browsing list */
         $request['template']->setList('users_browsing', $users_browsing);
         $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_online_total' => $num_online_total);
         $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
         $element = $forum['row_type'] & CATEGORY ? 'L_USERSBROWSINGCAT' : 'L_USERSBROWSINGFORUM';
         $request['template']->setVar('num_online_members', $stats['num_online_members']);
         $request['template']->setVar('users_browsing', $request['template']->getVar($element));
         $request['template']->setVar('online_stats', sprintf($request['template']->getVar('L_USERSBROWSINGSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
         /* Set the User's Browsing file */
         $request['template']->setFile('users_browsing', 'users_browsing.html');
         $groups = array();
         /* Set the usergroups legend list */
         foreach ($_USERGROUPS as $group) {
             if ($group['display_legend'] == 1) {
                 $groups[] = $group;
             }
         }
         $groups =& new FAArrayIterator($groups);
         $request['template']->setList('usergroups_legend', $groups);
     }
     if ($forum_can_view > $request['user']->get('perms')) {
         $action = new K4InformationAction(new K4LanguageElement('L_PERMCANTVIEW'), 'content', FALSE);
         return $action->execute($request);
     }
     /**
      * Breadcrumbs 
      */
     /* Set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], NULL, $forum);
     /* Set if this breadcrumb should be 'new' or not */
     $icon = NULL;
     $new = $forum['row_type'] & FORUM ? forum_icon($forum, $icon) : FALSE;
     $request['template']->setVar('breadcrumb_new', $new == TRUE ? 'new' : '');
     /**
      * Forum/cateogry checking
      */
     /* Set all of the category/forum info to the template */
     $request['template']->setVarArray($forum);
     /**
      *
      * CATEGORY
      *
      */
     if ($forum['row_type'] & CATEGORY) {
         if (get_map('categories', 'can_view', array()) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_PERMCANTVIEW'), 'content', FALSE);
             return $action->execute($request);
         }
         /* Set the Categories list */
         $categories =& new K4ForumsIterator($request['dba'], "SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . $forum['forum_id'] . " ORDER BY row_order ASC");
         $request['template']->setList('tlforums', $categories);
         /* Hide the welcome message at the top of the forums.html template */
         $request['template']->setVisibility('welcome_msg', FALSE);
         /* Show the forum status icons */
         $request['template']->setVisibility('forum_status_icons', TRUE);
         /* Show the 'Mark these forums Read' link */
         $request['template']->setVisibility('mark_these_forums', TRUE);
         /* Set the forums template to content variable */
         $request['template']->setFile('content', 'forums.html');
         /**
          *
          * FORUM / META FORUM
          *
          */
     } else {
         if ($forum['row_type'] & FORUM || $forum['row_type'] & METAFORUM || $forum['row_type'] & ARCHIVEFORUM) {
             /* Add the forum info to the template */
             foreach ($forum as $key => $val) {
                 $request['template']->setVar('forum_' . $key, $val);
             }
             /* If this forum has sub-forums */
             if (isset_forum_cache_item('subforums', $forum['forum_id']) && $forum['subforums'] >= 1) {
                 /* Cache this forum as having subforums */
                 set_forum_cache_item('subforums', 1, $forum['forum_id']);
                 /* Show the table that holds the subforums */
                 $request['template']->setVisibility('subforums', TRUE);
                 /* Set the sub-forums list */
                 $it =& new K4ForumsIterator($request['dba'], "SELECT * FROM " . K4FORUMS . " WHERE parent_id = " . $forum['forum_id'] . " ORDER BY row_order ASC");
                 $request['template']->setList('forums', $it);
             }
             if (get_map('topics', 'can_view', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
                 $action = new K4InformationAction(new K4LanguageElement('L_CANTVIEWFORUMTOPICS'), 'content_extra', FALSE);
                 return $action->execute($request);
             }
             /**
              * Forum settings
              */
             /* Set the topics template to the content variable */
             $request['template']->setFile('content', 'viewforum.html');
             /* Set what this user can/cannot do in this forum */
             $request['template']->setVar('forum_user_topic_options', sprintf($request['template']->getVar('L_FORUMUSERTOPICPERMS'), get_map('topics', 'can_add', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN'), get_map('topics', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN'), get_map('topics', 'can_del', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN'), get_map('attachments', 'can_add', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN')));
             $request['template']->setVar('forum_user_reply_options', sprintf($request['template']->getVar('L_FORUMUSERREPLYPERMS'), get_map('replies', 'can_add', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN'), get_map('replies', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN'), get_map('replies', 'can_del', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms') ? $request['template']->getVar('L_CANNOT') : $request['template']->getVar('L_CAN')));
             /* Create an array with all of the possible sort orders we can have */
             $sort_orders = array('name', 'lastpost_created', 'num_replies', 'views', 'lastpost_uname', 'rating', 'poster_name');
             //$extra_topics		= intval(@$_ALLFORUMS[GLBL_ANNOUNCEMENTS]['topics']);
             $extra_topics = 0;
             // TODO: need only Announcements from global announcements
             /**
              * Pagination
              */
             /* Create the Pagination */
             $resultsperpage = $request['user']->get('topicsperpage') <= 0 ? $forum['topicsperpage'] : $request['user']->get('topicsperpage');
             $num_results = $forum['topics'] + $extra_topics;
             $perpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : $resultsperpage;
             $perpage = $perpage > 100 ? 100 : $perpage;
             $num_pages = intval(@ceil($num_results / $perpage));
             $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;
             $pager =& new FAPaginator($_URL, $num_results, $page, $perpage);
             if ($num_results > $perpage) {
                 $request['template']->setPager('topics_pager', $pager);
                 /* Create a friendly url for our pager jump */
                 $page_jumper = new FAUrl($_URL->__toString());
                 $page_jumper->args['limit'] = $perpage;
                 $page_jumper->args['page'] = FALSE;
                 $page_jumper->anchor = FALSE;
                 $request['template']->setVar('pagejumper_url', preg_replace('~&amp;~i', '&', $page_jumper->__toString()));
             }
             /* Get the topics for this forum */
             $daysprune = $_daysprune = isset($_REQUEST['daysprune']) && ctype_digit($_REQUEST['daysprune']) ? $_REQUEST['daysprune'] == 0 ? 0 : intval($_REQUEST['daysprune']) : 365;
             $daysprune = $daysprune > 0 ? time() - @($daysprune * 86400) : 0;
             $sortorder = isset($_REQUEST['order']) && ($_REQUEST['order'] == 'ASC' || $_REQUEST['order'] == 'DESC') ? $_REQUEST['order'] : 'DESC';
             $sortedby = isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sort_orders) ? $_REQUEST['sort'] : 'lastpost_created';
             $start = ($page - 1) * $perpage;
             /* Apply the directional arrow to the sorting of topics */
             $request['template']->setVar('order', $sortorder == 'DESC' ? 'ASC' : 'DESC');
             $image = '<img src="Images/' . $request['template']->getVar('IMG_DIR') . '/Icons/arrow_' . ($sortorder == 'DESC' ? 'down' : 'up') . '.gif" alt="" border="0" />';
             $request['template']->setVar($sortedby . '_sort', $image);
             /* If there are no topics, set the right message to display */
             if ($forum['topics'] <= 0) {
                 $request['template']->setVisibility('no_topics', TRUE);
                 $request['template']->setVar('topics_message', $daysprune == 0 ? $request['template']->getVar('L_NOPOSTSINFORUM') : sprintf($request['template']->getVar('L_FORUMNOPOSTSSINCE'), $_daysprune));
             }
             if ($forum['topics'] + $extra_topics > 0 || $forum['row_type'] > GALLERY) {
                 /**
                  * Moderator Functions
                  */
                 $extra = 'AND queue = 0';
                 $request['template']->setVar('modpanel', 0);
                 /* is this user a moderator */
                 if (is_moderator($request['user']->getInfoArray(), $forum) && $forum['row_type'] <= GALLERY) {
                     $request['template']->setVar('modpanel', 1);
                     if (isset($_REQUEST['queued']) || isset($_REQUEST['locked'])) {
                         if (isset($_REQUEST['queued'])) {
                             $extra = 'AND queue = 1';
                         } elseif (isset($_REQUEST['locked'])) {
                             $extra = ' AND queue = 0 AND post_locked = 1';
                         }
                     }
                 }
                 /**
                  * Topic Setting
                  */
                 /* Make our query */
                 $query = "SELECT * FROM " . K4POSTS . " WHERE created>={$daysprune} AND is_draft=0 AND display=1 AND row_type=" . TOPIC . " AND forum_id=" . intval($forum['forum_id']) . " AND (post_type <> " . TOPIC_ANNOUNCE . " AND post_type <> " . TOPIC_STICKY . " AND is_feature = 0) {$extra} ORDER BY {$sortedby} {$sortorder} LIMIT {$start},{$perpage}";
                 if ($forum['row_type'] & METAFORUM) {
                     global $_FILTERS, $_FORUMFILTERS;
                     $query = "SELECT * FROM " . K4POSTS . " WHERE row_type=" . TOPIC . " AND forum_id<>" . GARBAGE_BIN . " ";
                     // loop through the filters being applied to this forum
                     $forum_filters = array();
                     if (isset($_FORUMFILTERS[$forum['forum_id']])) {
                         foreach ($_FORUMFILTERS[$forum['forum_id']] as $forum_filter) {
                             if (isset($_FILTERS[$forum_filter['filter_id']])) {
                                 $forum_filters[] = array('name' => $_FILTERS[$forum_filter['filter_id']]['filter_name']);
                                 $query .= " AND " . sprintf($_FILTERS[$forum_filter['filter_id']]['filter_query'], $request['dba']->quote($forum_filter['insert1']), $request['dba']->quote($forum_filter['insert2']), $request['dba']->quote($forum_filter['insert3'])) . " ";
                             }
                         }
                     }
                     $request['template']->setList('forum_filters', new FAArrayIterator($forum_filters));
                     $query .= " {$extra} ORDER BY {$sortedby} {$sortorder} LIMIT {$start},{$perpage}";
                     $query = str_replace('**', '%', $query);
                 }
                 /* get the topics */
                 $result = $request['dba']->executeQuery($query);
                 /* Apply the topics iterator */
                 $it =& new TopicsIterator($request['dba'], $request['user'], $result, $request['template']->getVar('IMG_DIR'), $forum);
                 $request['template']->setList('topics', $it);
                 // let's just make sure..
                 if ($result->hasNext()) {
                     $request['template']->setVisibility('no_topics', FALSE);
                 }
                 if ($forum['row_type'] <= GALLERY) {
                     /**
                      * Get announcement/global topics
                      */
                     if ($page == 1) {
                         $announcements = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE (is_draft=0 AND display=1) AND row_type=" . TOPIC . " AND post_type = " . TOPIC_ANNOUNCE . " AND (forum_id = " . intval($forum['forum_id']) . " OR forum_id = " . GLBL_ANNOUNCEMENTS . ") {$extra} ORDER BY lastpost_created DESC");
                         if ($announcements->hasNext()) {
                             $a_it =& new TopicsIterator($request['dba'], $request['user'], $announcements, $request['template']->getVar('IMG_DIR'), $forum);
                             $request['template']->setList('announcements', $a_it);
                         }
                     }
                     /**
                      * Get sticky/feature topics
                      */
                     $importants = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE is_draft=0 AND row_type=" . TOPIC . " AND display = 1 AND forum_id = " . intval($forum['forum_id']) . " AND (post_type <> " . TOPIC_ANNOUNCE . ") AND (post_type = " . TOPIC_STICKY . " OR is_feature = 1) {$extra} ORDER BY lastpost_created DESC");
                     if ($importants->hasNext()) {
                         $i_it =& new TopicsIterator($request['dba'], $request['user'], $importants, $request['template']->getVar('IMG_DIR'), $forum);
                         $request['template']->setList('importants', $i_it);
                     }
                 }
                 /* Outside valid page range, redirect */
                 if (!$pager->hasPage($page) && $num_pages > 0) {
                     $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'viewforum.php?f=' . $forum['forum_id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
                     return $action->execute($request);
                 }
             }
             /**
              * Forum Subscriptions
              */
             if ($request['user']->isMember() && $forum['topics'] > 0) {
                 $subscribed = $request['dba']->executeQuery("SELECT * FROM " . K4SUBSCRIPTIONS . " WHERE forum_id = " . intval($forum['forum_id']) . " AND post_id = 0 AND user_id = " . $request['user']->get('id'));
                 $request['template']->setVar('is_subscribed', $subscribed->numRows() > 0 ? 1 : 0);
             }
             /**
              *
              * GALLERY
              *
              */
         } else {
             if ($forum['row_type'] & GALLERY) {
                 $request['template']->setFile('content', 'viewgallery.html');
                 /**
                  *
                  * ERROR
                  *
                  */
             } else {
                 $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
                 return $action->execute($request);
             }
         }
     }
     /**
      * Can we post in here?
      */
     $can_post_in_forum = 1;
     if ($forum['forum_id'] == GARBAGE_BIN || $forum['row_type'] > GALLERY) {
         $can_post_in_forum = 0;
     }
     $request['template']->setVar('can_post_in_forum', $can_post_in_forum);
     // urls
     $request['template']->setVar('U_FORUMRSSURL', K4Url::getGenUrl('rss', 'f=' . $forum['forum_id']));
     /* Add the cookies for this forum's topics */
     bb_execute_topiccache();
     // show the midsection of the forum
     $request['template']->setVisibility('forum_midsection', TRUE);
     return TRUE;
 }
Ejemplo n.º 8
0
 /**
  * @brief       Get Form Fields by Form ID or Form Title
  * @details     We can get the form fields by form name or form if
  *              example: getFields('Demographics') or getFields('1')
  *              The logic of the function is to get the form parent field
  *              and its options, then get the child items if any with it options.
  *              Then.. use reg Expression to remove the double quotes from all
  *              the options and leave the double quotes to all options values,
  *              unless the value is a int or bool.
  *
  * @author      Ernesto J. Rodriguez (Certun) <*****@*****.**>
  * @version     Vega 1.0
  *
  * @param       stdClass $params With the form Title or Form ID
  * @internal    $params->formToRender Holds the Title or ID of the form to render
  * @return      string String of javascript array
  */
 function getFields(stdClass $params)
 {
     $this->setModels();
     /**
      * define $items as an array to push all the $item into.
      */
     $items = [];
     /**
      * get the form parent fields
      */
     $records = $this->ff->sql("Select ff.*\n                         FROM `forms_fields` AS ff\n                    LEFT JOIN `forms_layout` AS fl\n                           ON ff.`form_id` = fl.`id`\n                        WHERE (fl.`name` = '{$params->formToRender}' OR fl.`id` = '{$params->formToRender}')\n                          AND ff.`parentId` = 'root'\n                     ORDER BY ff.`x_index` ASC, ff.`id` ASC")->all();
     /**
      * for each parent item lets get all the options and children items
      */
     foreach ($records as $item) {
         /**
          * get parent field options using the parent item "id" as parameter and
          * store the return array in $opts.
          */
         $opts = $this->getItemsOptions($item['id']);
         /**
          * now take each option and add it to this $item array
          */
         foreach ($opts as $opt => $val) {
             if ($opt != 'pos') {
                 $item[$opt] = $val;
             }
         }
         if ($item['xtype'] == 'combobox') {
             $item = $this->getComboDefaults($item);
             $item['store'] = $this->getStore($item['list_id']);
         }
         if ($item['xtype'] == 'datefield') {
             $item['format'] = 'Y-m-d';
         }
         /**
          * now lets get the the child items using the parent item ID parameter
          */
         $item['items'] = $this->getChildItems($item['id']);
         if ($item['xtype'] == 'fieldset' && $item['title'] == 'Assessment') {
             $item['items'][] = ['xtype' => 'icdsfieldset', 'emptyText' => 'Search For Diagnosis Codes', 'name' => 'dxCodes'];
         }
         /**
          * lets check if this item has a child items. If not, the unset the $item['Items']
          * this way we make sure the we done return a items property
          */
         if ($item['items'] == null) {
             unset($item['items']);
         }
         /**
          * unset the stuff that are not properties
          */
         unset($item['id'], $item['form_id'], $item['parentId'], $item['x_index']);
         /**
          * push this item into the $items Array
          */
         if (Globals::getGlobal('compact_demographics') && $item['xtype'] == 'fieldset' && $params->formToRender == 1) {
             $item['xtype'] = 'panel';
             $item['border'] = false;
             $item['bodyBorder'] = false;
             $item['bodyPadding'] = 10;
             //				if($item['title'] == 'Primary Insurance' || $item['title'] == 'Secondary Insurance' || $item['title'] == 'Tertiary Insurance' ){
             //					array_push($items2, $item);
             //				}else{
             array_push($items, $item);
             //				}
         } else {
             array_push($items, $item);
         }
     }
     /**
      * <p>In this next block of code we are going to clean the json output using a reg expression
      * to remove the unnecessary double quotes from the properties, bools, and ints values.
      * basically we start we this input..</p>
      * <code>
      * [{
      *      "xtype":"fieldset",
      *      "title":"Who",
      *      "collapsible":"true",
      *      "items":[{
      *          "xtype":"fieldcontainer",
      *          "fieldLabel":"Name",
      *          "layout":"hbox",
      *          "anchor":"100%",
      *       }]
      * }]
      * </code>
      * <p>and finish with this output...</p>
      * <code>
      * [{
      *      xtype:'fieldset',
      *      title:'Who',
      *      collapsible:true,
      *      items:[{
      *          xtype:'fieldcontainer',
      *          fieldLabel:'Name',
      *          layout:'hbox',
      *          anchor:'100%',
      *       }]
      * }]
      * </code>
      * <p>The regular expression will select any string that...</p>
      *
      * <p>is surrounded by double quotes and follow by : for example "xtype": </p>
      *
      * <p>or "Ext.create</p>
      *
      * <p>or }]})"</p>
      *
      * <p>Then remove the double quotes form that selection.</p>
      *
      * <p>Then replace remaining double quotes for single quotes <-- not required but...
      * we do it because GaiaEHR user single quotes to define strings.</p>
      */
     $rawStr = json_encode($items);
     if (Globals::getGlobal('compact_demographics') && $params->formToRender == 1) {
         $rawStr = "Ext.widget('tabpanel',{border:false,height:240,defaults:{autoScroll:true},items:{$rawStr}})";
     }
     $regex = '("\\w*?":|"Ext\\.create|\\)"\\})';
     $cleanItems = [];
     preg_match_all($regex, $rawStr, $rawItems);
     foreach ($rawItems[0] as $item) {
         array_push($cleanItems, str_replace('"', '', $item));
     }
     $itemsJsArray = str_replace('"', '\'', str_replace($rawItems[0], $cleanItems, $rawStr));
     return preg_replace("/(\\w)(')(\\w)/i", "\$1\\'\$3", $itemsJsArray);
     //return $items;
 }
Ejemplo n.º 9
0
 function execute(&$request)
 {
     if (USE_XMLHTTP) {
         if (!isset($_REQUEST['post_id']) || intval($_REQUEST['post_id']) == 0) {
             return xmlhttp_message('L_YOUNEEDPERMS');
         }
         // get the post
         $post = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']));
         if (!is_array($post) || empty($post)) {
             return xmlhttp_message('L_POSTDOESNTEXIST');
         }
         if ($post['row_type'] & TOPIC) {
             if ($request['user']->get('id') == $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'topics', 'can_edit', array('forum_id' => $post['forum_id']))) {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
             if ($request['user']->get('id') != $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'other_topics', 'can_edit', array('forum_id' => $post['forum_id']))) {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
         } else {
             if ($post['row_type'] & REPLY) {
                 if ($request['user']->get('id') == $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'replies', 'can_edit', array('forum_id' => $post['forum_id']))) {
                     return xmlhttp_message('L_YOUNEEDPERMS');
                 }
                 if ($request['user']->get('id') != $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'other_replies', 'can_edit', array('forum_id' => $post['forum_id']))) {
                     return xmlhttp_message('L_YOUNEEDPERMS');
                 }
             } else {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
         }
         if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
             return xmlhttp_message('L_INSERTPOSTMESSAGE');
         }
         global $_ALLFORUMS;
         Globals::setGlobal('forum_id', $post['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $_ALLFORUMS[$post['forum_id']]['maxpolloptions'] ? $_ALLFORUMS[$post['forum_id']]['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $_ALLFORUMS[$post['forum_id']]['maxpollquestions'] ? $_ALLFORUMS[$post['forum_id']]['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         $parser =& new BBParser();
         $parser->register('BBPollNode');
         $body_text = $parser->parse($_REQUEST['message']);
         $body_text = $parser->comparePolls($post['post_id'], $body_text, $post['body_text'], $request['dba']);
         $is_poll = Globals::getGlobal('is_poll');
         /* If this topic is a redirect/ connects to one, update the original */
         if ($post['row_type'] & TOPIC && ($post['moved_new_post_id'] > 0 || $post['moved_old_post_id'] > 0)) {
             $update = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET body_text=?,edited_time=?,edited_username=?,edited_userid=?,is_poll=? WHERE post_id=?");
             $update->setString(1, $body_text);
             $update->setInt(2, time());
             $update->setString(3, $request['user']->get('name'));
             $update->setInt(4, $request['user']->get('id'));
             $update->setInt(5, $is_poll);
             $update->setInt(6, $post['moved_new_post_id'] > 0 ? $post['moved_new_post_id'] : $post['moved_old_post_id']);
             $update->executeUpdate();
         }
         /* Update the original */
         $update = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET body_text=?,edited_time=?,edited_username=?,edited_userid=?,is_poll=? WHERE post_id=?");
         $update->setString(1, $body_text);
         $update->setInt(2, time());
         $update->setString(3, $request['user']->get('name'));
         $update->setInt(4, $request['user']->get('id'));
         $update->setInt(5, $is_poll);
         $update->setInt(6, $post['post_id']);
         $update->executeUpdate();
         xmlhttp_header();
         echo $body_text;
         xmlhttp_footer();
     }
     return TRUE;
 }
Ejemplo n.º 10
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_DATASTORE, $_SETTINGS;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id=" . intval($_REQUEST['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Make sure the we are trying to edit in a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTEDITTONONFORUM'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_CANTEDITTONONFORUM');
     }
     /* General error checking */
     if ($this->row_type & TOPIC) {
         if (!isset($_REQUEST['name']) || $_REQUEST['name'] == '') {
             $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICNAME'), 'content', TRUE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICNAME');
         }
         $len = strlen($_REQUEST['name']);
         if ($len < intval($_SETTINGS['topicminchars']) || $len > intval($_SETTINGS['topicmaxchars'])) {
             $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
         }
     }
     if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICMESSAGE'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICMESSAGE');
     }
     /* Get our post */
     $post = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']));
     if (!is_array($post) || empty($post)) {
         $action = new K4InformationAction(new K4LanguageElement('L_POSTDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_POSTDOESNTEXIST');
     }
     $type = $this->row_type & TOPIC ? 'topics' : 'replies';
     /* Does this person have permission to edit this topic? */
     if ($post['poster_id'] == $request['user']->get('id')) {
         if (get_map($type, 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
         }
     } else {
         if (get_map('other_' . $type, 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
         }
     }
     if ($post['is_poll'] == 1) {
         // TODO: something here.
     }
     /* Does this user have permission to edit this topic if it is locked? */
     if ($post['post_locked'] == 1 && get_map('closed', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
         $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
     }
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], $this->row_type & TOPIC ? 'L_EDITTOPIC' : 'L_EDITREPLY', $post, $forum);
     /* Initialize the bbcode parser with the topic message */
     $_REQUEST['message'] = substr($_REQUEST['message'], 0, $_SETTINGS['postmaxchars']);
     /* Parse the bbcode */
     $body_text = $_REQUEST['message'];
     $submit_type = isset($_REQUEST['submit_type']) ? $_REQUEST['submit_type'] : 'post';
     if (!isset($_REQUEST['disable_bbcode']) || !$_REQUEST['disable_bbcode']) {
         $parser =& new BBParser();
         Globals::setGlobal('forum_id', $forum['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $forum['maxpolloptions'] ? $forum['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $forum['maxpollquestions'] ? $forum['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         if ($submit_type == 'post' || isset($_REQUEST['post'])) {
             $parser->register('BBPollNode');
         }
         $body_text = $parser->parse($body_text);
         if ($submit_type == 'post' || isset($_REQUEST['post'])) {
             $body_text = $parser->comparePolls($post['post_id'], $body_text, $post['body_text'], $request['dba']);
         }
         $is_poll = Globals::getGlobal('is_poll');
     }
     // permissions are taken into account inside the poller
     //$poller		= &new K4BBPolls($body_text, $topic['body_text'], $forum, $topic['post_id']);
     $request['template']->setVar('newtopic_action', 'newtopic.php?act=updatetopic');
     if ($this->row_type & TOPIC) {
         /* Get the topic type */
         $post_type = isset($_REQUEST['post_type']) && intval($_REQUEST['post_type']) != 0 ? $_REQUEST['post_type'] : TOPIC_NORMAL;
         /* Check the topic type and check if this user has permission to post that type of topic */
         if ($post_type == TOPIC_STICKY && $request['user']->get('perms') < get_map('sticky', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $post_type = TOPIC_NORMAL;
         } else {
             if ($post_type == TOPIC_ANNOUNCE && $request['user']->get('perms') < get_map('announce', 'can_add', array('forum_id' => $forum['forum_id']))) {
                 $post_type = TOPIC_NORMAL;
             }
         }
         /* Is this a featured topic? */
         $is_feature = isset($_REQUEST['is_feature']) && $_REQUEST['is_feature'] == 'yes' ? 1 : 0;
         if ($is_feature == 1 && $request['user']->get('perms') < get_map('feature', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $is_feature = 0;
         }
     } else {
         $post_type = TOPIC_NORMAL;
         $is_feature = 0;
     }
     /* If we are saving this topic */
     if ($submit_type == 'post' || isset($_REQUEST['post'])) {
         $posticon = iif($request['user']->get('perms') >= get_map('posticons', 'can_add', array('forum_id' => $forum['forum_id'])), isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif', 'clear.gif');
         $time = time();
         $name = k4_htmlentities($_REQUEST['name'], ENT_QUOTES);
         /**
          * Build the queries to update the topic
          */
         $update_a = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET name=?,body_text=?,posticon=?,disable_html=?,disable_bbcode=?,disable_emoticons=?,disable_sig=?,disable_areply=?,disable_aurls=?,is_draft=?,edited_time=?,edited_username=?,edited_userid=?,is_feature=?,post_type=?,post_expire=?,is_poll=? WHERE post_id=?");
         $update_a->setString(1, $name);
         $update_a->setString(2, $body_text);
         $update_a->setString(3, $posticon);
         $update_a->setInt(4, isset($_REQUEST['disable_html']) && $_REQUEST['disable_html'] ? 1 : 0);
         $update_a->setInt(5, isset($_REQUEST['disable_bbcode']) && $_REQUEST['disable_bbcode'] ? 1 : 0);
         $update_a->setInt(6, isset($_REQUEST['disable_emoticons']) && $_REQUEST['disable_emoticons'] ? 1 : 0);
         $update_a->setInt(7, isset($_REQUEST['enable_sig']) && $_REQUEST['enable_sig'] ? 0 : 1);
         $update_a->setInt(8, isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply'] ? 1 : 0);
         $update_a->setInt(9, isset($_REQUEST['disable_aurls']) && $_REQUEST['disable_aurls'] ? 1 : 0);
         $update_a->setInt(10, 0);
         $update_a->setInt(11, $time);
         $update_a->setString(12, $request['user']->get('id') <= 0 ? k4_htmlentities(isset($_REQUEST['poster_name']) ? $_REQUEST['poster_name'] : '', ENT_QUOTES) : $request['user']->get('name'));
         $update_a->setInt(13, $request['user']->get('id'));
         $update_a->setInt(14, $is_feature);
         $update_a->setInt(15, $post_type);
         $update_a->setInt(16, $post_type > TOPIC_NORMAL ? intval(isset($_REQUEST['post_expire']) ? $_REQUEST['post_expire'] : 0) : 0);
         $update_a->setInt(17, $is_poll);
         $update_a->setInt(18, $post['post_id']);
         $update_a->executeUpdate();
         /* If this topic is a redirect/ connects to one, update the original */
         if ($this->row_type & TOPIC && ($post['moved_new_post_id'] > 0 || $post['moved_old_post_id'] > 0)) {
             $redirect = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET name=?,edited_time=?,edited_username=?,edited_userid=? WHERE post_id=?");
             $redirect->setString(1, $name);
             $redirect->setInt(2, time());
             $redirect->setString(3, $request['user']->get('name'));
             $redirect->setInt(4, $request['user']->get('id'));
             $redirect->setInt(5, $post['moved_new_post_id'] > 0 ? $post['moved_new_post_id'] : $post['moved_old_post_id']);
             $redirect->executeUpdate();
             /**
              * Subscribe/Unsubscribe this user to the topic
              */
             $is_subscribed = $request['dba']->getRow("SELECT * FROM " . K4SUBSCRIPTIONS . " WHERE user_id = " . intval($request['user']->get('id')) . " AND post_id = " . intval($post['post_id']));
             if (isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply']) {
                 if (!is_array($is_subscribed) || empty($is_subscribed)) {
                     $subscribe = $request['dba']->prepareStatement("INSERT INTO " . K4SUBSCRIPTIONS . " (user_id,post_id,forum_id,email) VALUES (?,?,?,?)");
                     $subscribe->setInt(1, $request['user']->get('id'));
                     $subscribe->setInt(2, $topic['post_id']);
                     $subscribe->setInt(3, $forum['forum_id']);
                     $subscribe->setString(4, $request['user']->get('email'));
                     $subscribe->executeUpdate();
                 }
             } else {
                 if (!isset($_REQUEST['disable_areply']) || !$_REQUEST['disable_areply']) {
                     if (is_array($is_subscribed) && !empty($is_subscribed)) {
                         $subscribe = $request['dba']->prepareStatement("DELETE FROM " . K4SUBSCRIPTIONS . " WHERE user_id=? AND post_id=?");
                         $subscribe->setInt(1, $request['user']->get('id'));
                         $subscribe->setInt(2, $topic['post_id']);
                         $subscribe->executeUpdate();
                     }
                 }
             }
         }
         // deal with attachments
         if ($request['template']->getVar('nojs') == 0) {
             attach_files($request, $forum, $post);
         }
         /* Should we update the forum's last post info? */
         if ($forum['lastpost_id'] == $post['post_id']) {
             // if this topic is the forums last post
             if ($forum['lastpost_id'] == $post['post_id'] && $forum['lastpost_created'] == $post['created']) {
                 $forum_topic_update = $request['dba']->prepareStatement("UPDATE " . K4FORUMS . " SET lastpost_name=?,lastpost_posticon=? WHERE forum_id=?");
                 $forum_topic_update->setString(1, $name);
                 $forum_topic_update->setString(2, $posticon);
                 $forum_topic_update->setInt(3, $forum['forum_id']);
                 $forum_topic_update->executeUpdate();
             }
         }
         /* Redirect the user */
         $action = new K4InformationAction(new K4LanguageElement($this->row_type & TOPIC ? 'L_UPDATEDTOPIC' : 'L_UPDATEDREPLY', $name), 'content', FALSE, 'findpost.php?id=' . $post['post_id'], 3);
         return $action->execute($request);
     } else {
         /**
          * Post Previewing
          */
         if (!USE_XMLHTTP) {
             $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
             /* Get and set the emoticons and post icons to the template */
             $emoticons = $request['dba']->executeQuery("SELECT * FROM " . K4EMOTICONS . " WHERE clickable = 1");
             $posticons = $request['dba']->executeQuery("SELECT * FROM " . K4POSTICONS);
             $request['template']->setList('emoticons', $emoticons);
             $request['template']->setList('posticons', $posticons);
             $request['template']->setVar('emoticons_per_row', $request['template']->getVar('smcolumns'));
             $request['template']->setVar('emoticons_per_row_remainder', $request['template']->getVar('smcolumns') - 1);
             post_attachment_options($request, $forum, $post);
             topic_post_options($request['template'], $request['user'], $forum);
             /* Create our editor */
             create_editor($request, $_REQUEST['message'], 'post', $forum);
         }
         $topic_preview = array('post_id' => @$post['post_id'], 'name' => $name, 'posticon' => isset($_REQUEST['posticon']) ? $_REQUEST['posticon'] : 'clear.gif', 'body_text' => $body_text, 'poster_name' => html_entity_decode($topic['poster_name'], ENT_QUOTES), 'poster_id' => $request['user']->get('id'), 'is_poll' => $topic['is_poll'], 'row_left' => 0, 'row_right' => 0, 'post_type' => $post_type, 'is_feature' => $is_feature, 'disable_html' => isset($_REQUEST['disable_html']) && $_REQUEST['disable_html'] ? 1 : 0, 'disable_sig' => isset($_REQUEST['enable_sig']) && $_REQUEST['enable_sig'] ? 1 : 0, 'disable_bbcode' => isset($_REQUEST['disable_bbcode']) && $_REQUEST['disable_bbcode'] ? 1 : 0, 'disable_emoticons' => isset($_REQUEST['disable_emoticons']) && $_REQUEST['disable_emoticons'] ? 1 : 0, 'disable_areply' => isset($_REQUEST['disable_areply']) && $_REQUEST['disable_areply'] ? 1 : 0, 'disable_aurls' => isset($_REQUEST['disable_aurls']) && $_REQUEST['disable_aurls'] ? 1 : 0);
         /* Add the topic information to the template */
         $topic_iterator =& new TopicIterator($request['dba'], $request['user'], $topic_preview, FALSE);
         $request['template']->setList('topic', $topic_iterator);
         /* Assign the topic preview values to the template */
         $topic_preview['body_text'] = $_REQUEST['message'];
         foreach ($topic_preview as $key => $val) {
             $request['template']->setVar('topic_' . $key, $val);
         }
         /* Assign the forum information to the template */
         foreach ($forum as $key => $val) {
             $request['template']->setVar('forum_' . $key, $val);
         }
         if (!USE_XMLHTTP) {
             /* Set the the button display options */
             $request['template']->setVisibility('save_draft', FALSE);
             $request['template']->setVisibility('load_button', FALSE);
             $request['template']->setVisibility('edit_topic', TRUE);
             $request['template']->setVisibility('post_id', TRUE);
             $request['template']->setVisibility('post_topic', FALSE);
             $request['template']->setVisibility('edit_post', TRUE);
             /* set the breadcrumbs bit */
             k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTTOPIC', $forum);
             /* Set the post topic form */
             $request['template']->setVar('forum_forum_id', $forum['forum_id']);
             $request['template']->setFile('preview', 'post_preview.html');
             $request['template']->setFile('content', 'newtopic.html');
         } else {
             $templateset = $request['user']->isMember() ? $request['user']->get('templateset') : $forum['defaultstyle'];
             xmlhttp_header();
             echo $request['template']->run(BB_BASE_DIR . '/templates/' . $templateset . '/post_preview.html');
             xmlhttp_footer();
         }
     }
     return TRUE;
 }
Ejemplo n.º 11
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     //$dba->executeUpdate("UPDATE ". USERINFO ." SET msn = '*****@*****.**' WHERE user_id = 1");
     global $_DATASTORE, $_USERGROUPS, $_SESS;
     //$str = "[poll][question=hello?][answer]maybe[/answer][answer]good[/answer][/question][question=yes][answer]maybe[/answer][answer]good[/answer][/question][/poll]";
     //$dba->executeUpdate("UPDATE k4_topics set display=1");
     /*
     
     //echo str_replace('"','\"', serialize(array('spiderstrings'=>'googlebot|lycos|ask jeeves|scooter|fast-webcrawler|slurp@inktomi|turnitinbot','spidernames'=>array('googlebot' => 'Google','lycos' => 'Lycos','ask jeeves' => 'Ask Jeeves','scooter' => 'Altavista','fast-webcrawler' => 'AllTheWeb','slurp@inktomi' => 'Inktomi','turnitinbot' => 'Turnitin.com'))));
     
     
     $bbcode	= &new BBCodex(&$user, $text, 2, TRUE, TRUE, TRUE, TRUE);
     
     $text = $bbcode->parse();
     
     echo $text;
     echo '<br />';
     $bbcode	= &new BBCodex(&$user, $text, 2, TRUE, TRUE, TRUE, TRUE);
     
     $text = $bbcode->revert();
     
     echo '<textarea rows="5" cols="100">'. $text .'</textarea>';
     */
     /* Set the breadcrumbs bit */
     $template = BreadCrumbs($template, $template->getVar('L_HOME'));
     //$dba->executeUpdate("update k4_information set row_level = 3 where row_type = 2 and parent_id = 2");
     /*$dba->executeQuery("delete from k4_information");
     		$dba->executeQuery("delete from k4_categories");
     		$dba->executeQuery("delete from k4_forums");
     		$dba->executeQuery("delete from k4_topics");
     		$dba->executeQuery("delete from k4_replies");
     		$dba->executeQuery("delete from k4_maps");
     		$dba->executeQuery("delete from k4_topicqueue");
     		$dba->executeQuery("delete from k4_mailqueue");
     		$dba->executeUpdate("UPDATE ". USERINFO ." SET num_posts = 0");*/
     //print_r($dba->getRow("SELECT sql, name, type FROM sqlite_master WHERE tbl_name = '". USERINFO ."' ORDER BY type DESC"));
     //$dba->executeQuery("delete from ". PROFILEFIELDS ." where name = 'field6'");
     /* Set the Categories list */
     $categories =& new CategoriesIterator(NULL);
     $template->setList('categories', $categories);
     if (!is_a($session['user'], 'Member')) {
         $template->setVar('welcome_title', sprintf($template->getVar('L_WELCOMETITLE'), $template->getVar('bbtitle')));
         $template->show('welcome_msg');
         $template->setFile('quick_login', 'login_form_quick.html');
     }
     /* Set the online users list */
     $online_users =& new OnlineUsersIterator(NULL);
     $template->setList('online_users', $online_users);
     $newest_user = $dba->getRow("SELECT name, id FROM " . USERS . " ORDER BY id DESC LIMIT 1");
     $expired = time() - ini_get('session.gc_maxlifetime');
     $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_topics' => intval($_DATASTORE['forumstats']['num_topics']), 'num_replies' => intval($_DATASTORE['forumstats']['num_replies']), 'num_members' => intval($_DATASTORE['forumstats']['num_members']), 'num_online_total' => $dba->getValue("SELECT COUNT(*) FROM " . SESSIONS . " WHERE seen >= {$expired}") + iif(is_a($session['user'], 'Guest') && $_SESS->is_new, 1, 0), 'newest_uid' => $newest_user['id'], 'newest_user' => $newest_user['name']);
     $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
     $template->setVar('num_online_members', $stats['num_online_members']);
     $template->setVar('newest_member', sprintf($template->getVar('L_NEWESTMEMBER'), $stats['newest_uid'], $stats['newest_user']));
     $template->setVar('total_users', sprintf($template->getVar('L_TOTALUSERS'), $stats['num_members']));
     $template->setVar('total_posts', sprintf($template->getVar('L_TOTALPOSTS'), $stats['num_topics'] + $stats['num_replies'], $stats['num_topics'], $stats['num_replies']));
     $template->setVar('online_stats', sprintf($template->getVar('L_ONLINEUSERSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
     $template->setVar('most_users_ever', sprintf($template->getVar('L_MOSTUSERSEVERONLINE'), $_DATASTORE['maxloggedin']['maxonline'], date("n/j/Y", bbtime($_DATASTORE['maxloggedin']['maxonlinedate'])), date("g:ia", bbtime($_DATASTORE['maxloggedin']['maxonlinedate']))));
     if ($stats['num_online_total'] >= $_DATASTORE['maxloggedin']['maxonline']) {
         $maxloggedin = array('maxonline' => $stats['num_online_total'], 'maxonlinedate' => time());
         $query = $dba->prepareStatement("UPDATE " . DATASTORE . " SET data = ? WHERE varname = ?");
         $query->setString(1, serialize($maxloggedin));
         $query->setString(2, 'maxloggedin');
         $query->executeUpdate();
         if (!@touch(CACHE_FILE, time() - 86460)) {
             @unlink(CACHE_FILE);
         }
     }
     /* Show the forum status icons */
     $template->show('forum_status_icons');
     $groups = array();
     /* Set the usergroups legend list */
     foreach ($_USERGROUPS as $group) {
         if ($group['display_legend'] == 1) {
             $groups[] = $group;
         }
     }
     $groups =& new FAArrayIterator($groups);
     $template->setList('usergroups_legend', $groups);
     /* Set the forums template to content variable */
     $template->setFile('content', 'forums.html');
     $template->setFile('forum_info', 'forum_info.html');
     return TRUE;
 }
Ejemplo n.º 12
0
 function flatten($noparse = FALSE)
 {
     if ($noparse) {
         return $this->getUnparsed($noparse);
     }
     $body = parent::flatten($noparse);
     $question = trim($this->_attrib);
     $items = explode('[*]', $body);
     $param = $this->_attrib;
     $maxpolloptions = intval(Globals::getGlobal('maxpolloptions'));
     $forum_id = intval(Globals::getGlobal('forum_id'));
     if (!Globals::getGlobal('num_polls')) {
         Globals::setGlobal('num_polls', 0);
     }
     $can_poll = $forum_id > 0 && $_SESSION['user']->get('perms') >= get_map('bbcode', 'can_add', array('forum_id' => $forum_id));
     $ret = '';
     if (count($items) > 0 && $maxpolloptions > 0 && $can_poll && $question != '' && Globals::getGlobal('num_polls') <= Globals::getGlobal('maxpollquestions')) {
         global $_DBA;
         $question = $_DBA->quote(k4_htmlentities($question, ENT_QUOTES));
         $insert_question = $_DBA->executeUpdate("INSERT INTO " . K4POLLQUESTIONS . " (question, created, user_id, user_name) VALUES ('{$question}', " . time() . ", " . intval($_SESSION['user']->get('id')) . ", '" . $_DBA->quote($_SESSION['user']->get('name')) . "')");
         $question_id = $_DBA->getInsertId(K4POLLQUESTIONS, 'id');
         $buffer = '';
         $i = 0;
         foreach ($items as $item) {
             if ($i >= $maxpolloptions) {
                 break;
             }
             $item = trim(strip_tags(preg_replace("~(\r\n|\r|\n|\t|<br>|<br\\/>|<br \\/>)~i", "", $item)));
             if ($item != '') {
                 $_DBA->executeUpdate("INSERT INTO " . K4POLLANSWERS . " (question_id,answer) VALUES (" . intval($question_id) . ", '" . $_DBA->quote(k4_htmlentities($item, ENT_QUOTES)) . "')");
                 $i++;
             }
         }
         Globals::setGlobal('is_poll', TRUE);
         Globals::setGlobal('num_polls', Globals::getGlobal('num_polls') + 1);
         $ret = "[poll={$question_id}]";
     }
     return $ret;
 }
Ejemplo n.º 13
0
 function ForumsIterator($query = NULL, $do_recurse = TRUE)
 {
     global $_SETTINGS, $_DBA, $_QUERYPARAMS, $_USERGROUPS;
     $query = $query == NULL ? "" : $query;
     $this->usergroups = $_USERGROUPS;
     $this->user =& Globals::getGlobal('user');
     $this->dba = $_DBA;
     $this->settings = $_SETTINGS;
     $this->query_params = $_QUERYPARAMS;
     $this->do_recurse = $do_recurse;
     $this->result =& $this->dba->executeQuery($query);
     //$this->forums		= isset($_COOKIE['forums']) && $_COOKIE['forums'] != NULL && $_COOKIE['forums'] != '' ? iif(!unserialize($_COOKIE['forums']), array(), unserialize($_COOKIE['forums'])) : array();
     parent::FAProxyIterator($this->result);
 }
Ejemplo n.º 14
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_USERGROUPS, $_URL;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /**
      * Error Checking
      */
     if (!isset($_REQUEST['id']) || !$_REQUEST['id'] || intval($_REQUEST['id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOPICDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Get our topic */
     $topic = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['id']));
     if (!$topic || !is_array($topic) || empty($topic)) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOPICDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Should we redirect this user? */
     if ($topic['moved_new_post_id'] > 0) {
         header("Location: viewtopic.php?id=" . intval($topic['moved_new_post_id']));
     }
     /* Get the current forum */
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($topic['forum_id']));
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     if ($topic['is_draft'] == 1) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTVIEWDRAFT'), 'content', FALSE);
         return $action->execute($request);
     }
     if (get_map('forums', 'can_view', array()) > $request['user']->get('perms') || get_map('topics', 'can_view', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
         $action = new K4InformationAction(new K4LanguageElement('L_PERMCANTVIEWTOPIC'), 'content', FALSE);
         return $action->execute($request);
     }
     // get the page number up here, the header call needs it!
     // this is also used down below for pagination
     $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;
     /**
      * Are we in an archive??
      */
     if ($forum['row_type'] & ARCHIVEFORUM) {
         if (!file_exists(BB_BASE_DIR . '/archive/' . intval($forum['forum_id']) . '/' . intval($topic['post_id']) . '-' . $page . '.xml')) {
             $archiver = new k4Archiver();
             $archiver->archiveTopicXML($request, $forum, $topic);
         }
         // redirect us!
         header("Location: archive.php?forum=" . intval($forum['forum_id']) . "&topic=" . intval($topic['post_id']) . "&page=" . $page);
         exit;
     }
     /**
      * Moderator functions
      */
     $request['template']->setVar('modpanel', 0);
     $moderator = FALSE;
     if (is_moderator($request['user']->getInfoArray(), $forum)) {
         $request['template']->setVar('modpanel', 1);
         $moderator = TRUE;
     }
     /**
      * More error checking
      */
     if ($topic['queue'] == 1 && !$moderator) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOPICPENDINGMOD'), 'content', FALSE);
         return $action->execute($request);
     }
     if ($topic['display'] == 0 && !$moderator) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOPICISHIDDEN'), 'content', FALSE);
         return $action->execute($request);
     }
     /**
      * This sets the last time that we've seen this forum
      */
     $cookieinfo = get_forum_cookies();
     $cookieinfo[$forum['forum_id']] = time();
     $cookiestr = '';
     foreach ($cookieinfo as $key => $val) {
         $cookiestr .= ',' . $key . ',' . intval($val);
     }
     $domain = get_domain();
     setcookie(K4FORUMINFO, trim($cookiestr, ','), time() + 2592000, $domain);
     unset($cookieinfo, $cookiestr);
     $cookieinfo = get_topic_cookies();
     /**
      * Set the new breadcrumbs bit
      */
     k4_bread_crumbs($request['template'], $request['dba'], $topic['name'], $forum);
     /* Set if this breadcrumb should be 'new' or not */
     $new = topic_icon($cookieinfo, $topic, '');
     $request['template']->setVar('breadcrumb_new', $new == TRUE ? 'new' : '');
     /**
      * Now tell the cookies that we've read this topic
      */
     $cookieinfo[$topic['post_id']] = time();
     $cookiestr = '';
     foreach ($cookieinfo as $key => $val) {
         // make sure to weed out 30-day old topic views
         if ((time() - intval($val)) / 30 <= 2592000) {
             $cookiestr .= ',' . $key . ',' . intval($val);
         }
     }
     setcookie(K4TOPICINFO, trim($cookiestr, ','), time() + 2592000, $domain);
     unset($cookieinfo, $cookiestr);
     /** 
      * Get the users Browsing this topic 
      */
     /* Set the extra SQL query fields to check */
     $extra = " AND location_file = '" . $request['dba']->quote($_URL->file) . "' AND location_id = " . intval($topic['post_id']);
     $expired = time() - ini_get('session.gc_maxlifetime');
     $user_extra = $request['user']->isMember() ? ' OR (seen > 0 AND user_id = ' . intval($request['user']->get('id')) . ')' : '';
     $num_online_total = $request['dba']->getValue("SELECT COUNT(id) FROM " . K4SESSIONS . " WHERE ((seen >= {$expired} {$extra}) {$user_extra})");
     $num_online_total = !$request['user']->isMember() ? $num_online_total + 1 : $num_online_total;
     if ($num_online_total > 0) {
         $query = "SELECT * FROM " . K4SESSIONS . " WHERE ((seen >= {$expired} {$extra}) {$user_extra}) AND ((user_id > 0) OR (user_id = 0 AND name <> '')) GROUP BY name ORDER BY seen DESC";
         $users_browsing =& new K4OnlineUsersIterator($request['dba'], '', $request['dba']->executeQuery($query));
         /* Set the users browsing list */
         $request['template']->setList('users_browsing', $users_browsing);
         $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_online_total' => $num_online_total);
         $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
         $request['template']->setVar('num_online_members', $stats['num_online_members']);
         $request['template']->setVar('users_browsing', $request['template']->getVar('L_USERSBROWSINGTOPIC'));
         $request['template']->setVar('online_stats', sprintf($request['template']->getVar('L_USERSBROWSINGSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
         /* Set the User's Browsing file */
         $request['template']->setFile('users_browsing', 'users_browsing.html');
         $groups = array();
         /* Set the usergroups legend list */
         foreach ($_USERGROUPS as $group) {
             if ($group['display_legend'] == 1) {
                 $groups[] = $group;
             }
         }
         $groups =& new FAArrayIterator($groups);
         $request['template']->setList('usergroups_legend', $groups);
     }
     /**
      * Is this topic expired?
      */
     $extra = '';
     if ($topic['post_type'] > TOPIC_NORMAL && $topic['post_expire'] > 0) {
         if ($topic['created'] + 3600 * 24 * $topic['post_expire'] > time()) {
             $extra = ",post_expire=0,post_type=" . TOPIC_NORMAL;
         }
     }
     /* Add the topic info to the template */
     foreach ($topic as $key => $val) {
         $request['template']->setVar('topic_' . $key, $val);
     }
     /* Add the forum info to the template */
     foreach ($forum as $key => $val) {
         $request['template']->setVar('forum_' . $key, $val);
     }
     /* Update the number of views for this topic */
     $request['dba']->executeUpdate("UPDATE " . K4POSTS . " SET views=views+1 {$extra} WHERE post_id=" . intval($topic['post_id']));
     $resultsperpage = $request['user']->get('postsperpage') <= 0 ? $forum['postsperpage'] : $request['user']->get('postsperpage');
     $num_results = $topic['num_replies'];
     $perpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : $resultsperpage;
     $perpage = $perpage > 50 ? 50 : $perpage;
     $num_pages = @ceil($num_results / $perpage);
     // the $page is set above so that the archive options can use it ;)
     $request['template']->setVar('page', $page);
     $url =& new FAUrl($_URL->__toString());
     $pager =& new FAPaginator($url, $num_results, $page, $perpage);
     if ($num_results > $perpage) {
         $request['template']->setPager('replies_pager', $pager);
         /* Create a friendly url for our pager jump */
         $page_jumper = $url;
         $page_jumper->args['limit'] = $perpage;
         $page_jumper->args['page'] = FALSE;
         $page_jumper->anchor = FALSE;
         $request['template']->setVar('pagejumper_url', preg_replace('~&amp;~i', '&', $page_jumper->__toString()));
     }
     /* Outside valid page range, redirect */
     if (!$pager->hasPage($page) && $num_pages > 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'viewtopic.php?id=' . $topic['post_id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
         return $action->execute($request);
     }
     $sort_orders = array('name', 'created', 'id', 'poster_name');
     /* Get the replies for this topic */
     $topic['daysprune'] = isset($_REQUEST['daysprune']) && ctype_digit($_REQUEST['daysprune']) ? iif($_REQUEST['daysprune'] == -1, 0, intval($_REQUEST['daysprune'])) : 0;
     $topic['sortorder'] = isset($_REQUEST['order']) && ($_REQUEST['order'] == 'ASC' || $_REQUEST['order'] == 'DESC') ? $_REQUEST['order'] : 'ASC';
     $topic['sortedby'] = isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sort_orders) ? $_REQUEST['sort'] : 'created';
     $topic['start'] = ($page - 1) * $perpage;
     $topic['postsperpage'] = $perpage;
     /* Do we set the similar topics? */
     $similar_topics = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE ((lower(name) LIKE lower('%" . $request['dba']->quote($topic['name']) . "%') OR lower(name) LIKE lower('%" . $request['dba']->quote($topic['body_text']) . "%')) OR (lower(body_text) LIKE lower('%" . $request['dba']->quote($topic['name']) . "%') OR lower(body_text) LIKE lower('%" . $request['dba']->quote($topic['body_text']) . "%'))) AND row_type=" . TOPIC . " AND is_draft = 0 AND post_id <> " . intval($topic['post_id']) . " ORDER BY lastpost_created DESC LIMIT 10");
     if ($similar_topics->hasNext()) {
         //$it = new PostsIterator($request, $similar_topics);
         $it =& new TopicsIterator($request['dba'], $request['user'], $similar_topics, $request['template']->getVar('IMG_DIR'), $forum);
         $request['template']->setList('similar_topics', $it);
         $request['template']->setFile('similar_topics', 'similar_topics.html');
     }
     /* Do we show the replies or show the threaded view? */
     $show_replies = $request['user']->get('topic_threaded') == 1 ? FALSE : TRUE;
     $show_replies = $request['user']->get('topic_threaded') == 1 && isset($_REQUEST['p']) && intval($_REQUEST['p']) > 0 ? TRUE : $show_replies;
     $single_reply = $request['user']->get('topic_threaded') == 1 && isset($_REQUEST['p']) && intval($_REQUEST['p']) > 0 ? intval($_REQUEST['p']) : FALSE;
     /* set the topic iterator */
     //$topic_list			= new TopicIterator($request['dba'], $request['user'], $topic, $show_replies, $single_reply);
     $result = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE (" . ($page <= 1 ? "post_id=" . $topic['post_id'] . " OR" : '') . " (parent_id=" . intval($topic['post_id']) . " AND row_level>1)) AND created >= " . 3600 * 24 * intval($topic['daysprune']) . " ORDER BY " . $topic['sortedby'] . " " . $topic['sortorder'] . " LIMIT " . intval($topic['start']) . "," . intval($topic['postsperpage']));
     $posts = new PostsIterator($request, $result);
     $request['template']->setList('posts', $posts);
     $request['template']->setVar('next_oldest', intval($request['dba']->getValue("SELECT post_id FROM " . K4POSTS . " WHERE post_id < " . $topic['post_id'] . " LIMIT 1")));
     $request['template']->setVar('next_newest', intval($request['dba']->getValue("SELECT post_id FROM " . K4POSTS . " WHERE post_id > " . $topic['post_id'] . " LIMIT 1")));
     /* Show the threaded view if necessary */
     if ($request['user']->get('topic_threaded') == 1) {
         if ($topic['num_replies'] > 0) {
             $request['template']->setFile('topic_threaded', 'topic_threaded.html');
             $replies = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE parent_id=" . intval($topic['post_id']) . " AND row_level>1 ORDER BY row_order ASC");
             $it =& new ThreadedRepliesIterator($replies, $topic['row_level']);
             $request['template']->setList('threaded_replies', $it);
         }
     }
     /**
      * Topic subscription stuff
      */
     if ($request['user']->isMember()) {
         $subscribed = $request['dba']->executeQuery("SELECT * FROM " . K4SUBSCRIPTIONS . " WHERE post_id = " . intval($topic['post_id']) . " AND user_id = " . $request['user']->get('id'));
         $request['template']->setVar('is_subscribed', iif($subscribed->numRows() > 0, 1, 0));
     }
     /**
      * HTML toggling stuff
      */
     $topic_row = 0;
     $reply_row = 0;
     $perms = $request['user']->get('perms');
     if ($perms >= get_map('replies', 'can_add', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('topics', 'can_edit', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('topics', 'can_del', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('other_topics', 'can_edit', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('other_topics', 'can_del', array('forum_id' => $topic['forum_id']))) {
         $topic_row = 1;
     }
     if ($perms >= get_map('replies', 'can_add', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('replies', 'can_edit', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('replies', 'can_del', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('other_replies', 'can_edit', array('forum_id' => $topic['forum_id'])) || $perms >= get_map('other_replies', 'can_del', array('forum_id' => $topic['forum_id']))) {
         $reply_row = 1;
     }
     $request['template']->setVar('topic_row', $topic_row);
     $request['template']->setVar('reply_row', $reply_row);
     $request['template']->setVar('newreply_act', K4Url::getGenUrl('newreply', 'act=postreply'));
     $request['template']->setVar('U_TOPICRSSURL', K4Url::getGenUrl('rss', 't=' . $topic['post_id']));
     /**
      * Topic display
      */
     $request['template']->setFile('topic_file', 'topic' . ($request['user']->get('topic_display') == 0 ? '' : '_linear') . '.html');
     $request['template']->setFile('reply_file', 'reply' . ($request['user']->get('topic_display') == 0 ? '' : '_linear') . '.html');
     /* Set the file we need */
     $request['template']->setVar('forum_forum_id', $forum['forum_id']);
     $request['template']->setFile('content', 'viewtopic.html');
     if (USE_WYSIWYG) {
         $request['template']->setList('emoticons', $request['dba']->executeQuery("SELECT * FROM " . K4EMOTICONS . " WHERE clickable = 1"));
         $request['template']->setVar('emoticons_per_row', $request['template']->getVar('smcolumns'));
         $request['template']->setVar('emoticons_per_row_remainder', $request['template']->getVar('smcolumns') - 1);
     }
     /* Create our editor for the quick reply */
     create_editor($request, '', 'quickreply', $forum);
     // show the midsection of the forum
     $request['template']->setVisibility('forum_midsection', TRUE);
     return TRUE;
 }
Ejemplo n.º 15
0
 function execute(&$request)
 {
     //$action = new AdminCSSRequestAction();
     //return $action->execute($request);
     global $_DATASTORE, $_USERGROUPS, $_QUERYPARAMS;
     // Member/Guest specifics
     if (!$request['user']->isMember()) {
         $request['template']->setVar('welcome_title', sprintf($request['template']->getVar('L_WELCOMETITLE'), $request['template']->getVar('bbtitle')));
         $request['template']->setFile('quick_login', 'login_form_quick.html');
         $request['template']->setVisibility('welcome_msg', TRUE);
     }
     // The content panel
     $request['template']->setFile('content', 'forums.html');
     $forums =& new K4ForumsIterator($request['dba'], "SELECT * FROM " . K4FORUMS . " WHERE parent_id=0 ORDER BY row_order ASC");
     //$categories	= &new K4ForumsIterator($request['dba'], "SELECT * FROM ". K4FORUMS ." WHERE row_type=". CATEGORY ." AND parent_id = 0 ORDER BY row_order ASC");
     $request['template']->setVisibility('no_forums', !$forums->hasNext() ? TRUE : FALSE);
     $request['template']->setList('tlforums', $forums);
     //$request['template']->setList('categories', $categories);
     // Set the online users list
     $user_extra = $request['user']->isMember() ? ' OR (seen > 0 AND user_id = ' . intval($request['user']->get('id')) . ')' : '';
     $expired = time() - ini_get('session.gc_maxlifetime');
     $online_users = $request['dba']->executeQuery("SELECT * FROM " . K4SESSIONS . " WHERE ((seen >= {$expired}) {$user_extra}) AND ((user_id > 0) OR (user_id = 0 AND name <> '')) GROUP BY name ORDER BY seen DESC");
     $online_users =& new K4OnlineUsersIterator($request['dba'], '', $online_users);
     $request['template']->setList('online_users', $online_users);
     //$newest_user						= $request['dba']->getRow("SELECT name, id FROM ". K4USERS ." ORDER BY id DESC LIMIT 1");
     $expired = time() - ini_get('session.gc_maxlifetime');
     //print_r($_DATASTORE); exit;
     $stats = array('num_online_members' => intval(Globals::getGlobal('num_online_members')), 'num_invisible' => intval(Globals::getGlobal('num_online_invisible')), 'num_topics' => intval($_DATASTORE['forumstats']['num_topics']), 'num_replies' => intval($_DATASTORE['forumstats']['num_replies']), 'num_members' => intval($_DATASTORE['forumstats']['num_members']), 'num_guests' => $request['dba']->getValue("SELECT COUNT(*) FROM " . K4SESSIONS . " WHERE seen >= {$expired} AND user_id=0"), 'newest_uid' => $_DATASTORE['forumstats']['newest_user_id'], 'newest_user' => $_DATASTORE['forumstats']['newest_user_name']);
     $stats['num_online_total'] = $stats['num_online_members'] + $stats['num_invisible'] + $stats['num_guests'];
     $request['template']->setVar('num_online_members', $stats['num_online_members']);
     $request['template']->setVar('newest_member', sprintf($request['template']->getVar('L_NEWESTMEMBER'), $stats['newest_uid'], $stats['newest_user']));
     $request['template']->setVar('total_users', sprintf($request['template']->getVar('L_TOTALUSERS'), $stats['num_members']));
     $request['template']->setVar('total_posts', sprintf($request['template']->getVar('L_TOTALPOSTS'), $stats['num_topics'] + $stats['num_replies'], $stats['num_topics'], $stats['num_replies']));
     $request['template']->setVar('online_stats', sprintf($request['template']->getVar('L_ONLINEUSERSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
     $request['template']->setVar('most_users_ever', sprintf($request['template']->getVar('L_MOSTUSERSEVERONLINE'), $_DATASTORE['maxloggedin']['maxonline'], date("n/j/Y", bbtime($_DATASTORE['maxloggedin']['maxonlinedate'])), date("g:ia", bbtime($_DATASTORE['maxloggedin']['maxonlinedate']))));
     if ($stats['num_online_total'] >= $_DATASTORE['maxloggedin']['maxonline']) {
         $maxloggedin = array('maxonline' => $stats['num_online_total'], 'maxonlinedate' => time());
         $query = $request['dba']->prepareStatement("UPDATE " . K4DATASTORE . " SET data = ? WHERE varname = ?");
         $query->setString(1, serialize($maxloggedin));
         $query->setString(2, 'maxloggedin');
         $query->executeUpdate();
         reset_cache('datastore');
     }
     // Show the forum status icons
     $request['template']->setVisibility('forum_status_icons', TRUE);
     $request['template']->setFile('content_extra', 'forum_status_icons.html');
     if ($request['user']->get('perms') >= get_map('can_see_board', 'can_add', array())) {
         $request['template']->setVisibility('forum_midsection', TRUE);
         $groups = array();
         // Set the usergroups legend list
         if (is_array($_USERGROUPS) && !empty($_USERGROUPS)) {
             foreach ($_USERGROUPS as $group) {
                 if ($group['display_legend'] == 1) {
                     $group['U_USERGROUPURL'] = K4Url::getUserGroupUrl($group['id']);
                     $groups[] = $group;
                 }
             }
         }
     }
     $groups =& new FAArrayIterator($groups);
     $request['template']->setList('usergroups_legend', $groups);
     /* Set the forum stats */
     $request['template']->setFile('forum_info', 'forum_info.html');
     $request['template']->setVar('can_see_board', get_map('can_see_board', 'can_view', array()));
     k4_bread_crumbs($request['template'], $request['dba'], 'L_HOME');
 }