コード例 #1
0
 function execute(&$request)
 {
     if ($request['user']->isMember() && $request['user']->get('perms') >= SUPERADMIN) {
         global $_DATASTORE;
         k4_bread_crumbs($request['template'], $request['dba'], 'L_EMAILUSERS');
         $request['template']->setVar('misc_on', '_on');
         $request['template']->setFile('sidebar_menu', 'menus/misc.html');
         if (isset($_DATASTORE['massmail'])) {
             $action = new K4InformationAction(new K4LanguageElement('L_EMAILINPROGRESS'), 'content', FALSE);
             return $action->execute($request);
         }
         global $_URL;
         $verify_url = new FAUrl($_URL->__toString());
         $verify_url->args = array();
         $verify_url->file = FALSE;
         $verify_url->anchor = FALSE;
         $verify_url->scheme = FALSE;
         $verify_url->path = FALSE;
         $verify_url->host = preg_replace('~www\\.~i', '', $verify_url->host);
         $request['template']->setFile('content', 'email_users.html');
         $request['template']->setVar('email_from', substr($verify_url->__toString(), 0, -1));
     } else {
         no_perms_error($request);
     }
     return TRUE;
 }
コード例 #2
0
ファイル: member.php プロジェクト: BackupTheBerlios/k4bb-svn
 function execute(&$request)
 {
     /* Create the ancestors bar */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_RESENDVALIDATIONEMAIL');
     /* Check if the user is logged in or not */
     if ($request['user']->isMember()) {
         no_perms_error($request);
         return TRUE;
     }
     if (!$this->runPostFilter('email', new FARequiredFilter())) {
         $action = new K4InformationAction(new K4LanguageElement('L_SUPPLYEMAIL'), 'content', TRUE);
         return $action->execute($request);
     }
     if (!$this->runPostFilter('email', new FARegexFilter('~^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$~'))) {
         $action = new K4InformationAction(new K4LanguageElement('L_NEEDVALIDEMAIL'), 'content', TRUE);
         return $action->execute($request);
     }
     $user = $request['dba']->getRow("SELECT * FROM " . K4USERS . " WHERE email = '" . $request['dba']->quote($_REQUEST['email']) . "'");
     if (!is_array($user) || empty($user)) {
         $action = new K4InformationAction(new K4LanguageElement('L_INVALIDEMAILRVE', $_REQUEST['email']), 'content', TRUE);
         return $action->execute($request);
     }
     if ($user['reg_key'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_USERREGGEDRVE'), 'content', TRUE);
         return $action->execute($request);
     }
     //  .'/member.php?act=activate_accnt&key='. $user['reg_key']
     $url = new FAUrl(K4_URL);
     $url->file = 'member.php';
     $url->args = array('act' => 'activate_accnt', 'key' => $user['reg_key']);
     $email = sprintf($request['template']->getVar('L_REGISTEREMAILRMSG'), $user['name'], $request['template']->getVar('bbtitle'), str_replace('&', '&', $url->__toString()), $request['template']->getVar('bbtitle'));
     email_user($user['email'], $request['template']->getVar('bbtitle') . ' - ' . $request['template']->getVar('L_RESENDVALIDATIONEMAIL'), $email);
     $action = new K4InformationAction(new K4LanguageElement('L_RESENTREGEMAIL', $_REQUEST['email']), 'content', TRUE);
     return $action->execute($request);
 }
コード例 #3
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;
 }
コード例 #4
0
ファイル: search.php プロジェクト: BackupTheBerlios/k4bb-svn
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_ALLFORUMS, $_URL;
     k4_bread_crumbs($request['template'], $request['dba'], 'L_SEARCHRESULTS');
     if (get_map('advsearch', 'can_add', array()) > $request['user']->get('perms')) {
         // something here?
     }
     /* Do we force it to rewrite the session? */
     if (isset($_REQUEST['rewrite_session']) && intval($_REQUEST['rewrite_session']) == 1 && isset($_SESSION['search']['search_queries'])) {
         unset($_SESSION['search']['search_queries']);
     }
     /**
      * Sort out author information
      */
     $user_ids = '';
     if (isset($_REQUEST['author']) && $_REQUEST['author'] != '') {
         $author = k4_htmlentities(trim($_REQUEST['author']), ENT_QUOTES);
         if (!isset($_REQUEST['exact']) || !$_REQUEST['exact']) {
             $author = str_replace('%', '*', $author);
             $author = intval($request['template']->getVar('allowwildcards')) == 1 ? str_replace('*', '%', $author) : str_replace('*', ' ', $author);
             // wildcard/partial match
             $user_search = "LOWER(name) LIKE LOWER('%" . $request['dba']->quote($author) . "%')";
         } else {
             // exact match
             $user_search = "name = '" . $request['dba']->quote($author) . "'";
         }
         if (strlen($author) < $request['template']->getVar('minsearchlength') || strlen($author) > $request['template']->getVar('maxsearchlength')) {
             $action = new K4InformationAction(new K4LanguageElement('L_INVALIDSEARCHKEYWORDS', $request['template']->getVar('minsearchlength'), $request['template']->getVar('maxsearchlength')), 'content', TRUE, 'search.php', 5);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(sprintf($request['template']->getVar('L_INVALIDSEARCHKEYWORDS'), $request['template']->getVar('minsearchlength'), $request['template']->getVar('maxsearchlength')));
         }
         $users = $request['dba']->executeQuery("SELECT * FROM " . K4USERS . " WHERE {$user_search}");
         if ($users->numrows() > 0) {
             $user_ids = ' AND (';
             while ($users->next()) {
                 $user = $users->current();
                 $user_ids .= $users->key() == 0 ? ' poster_id = ' . intval($user['id']) : ' OR poster_id = ' . intval($user['id']);
             }
             $user_ids .= ') ';
         } else {
             $action = new K4InformationAction(new K4LanguageElement('L_NOAUTHORSBYNAME'), 'content', FALSE, 'search.php', 5);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_NOAUTHORSBYNAME');
         }
     }
     /**
      * Sort out forum information
      */
     $forum_ids = '';
     $category_ids = '';
     $searchable_forums = '';
     /* This will handle different types of forum data */
     if (isset($_REQUEST['forums']) && is_array($_REQUEST['forums']) && !empty($_REQUEST['forums'])) {
         $forums = $_REQUEST['forums'];
     } elseif (isset($_REQUEST['forums']) && count(explode("|", $_REQUEST['forums'])) > 0) {
         $forums = explode("|", $_REQUEST['forums']);
     } else {
         $forums = array();
     }
     /* Now start looking thouroughly at the data */
     if (is_array($forums) && !empty($forums)) {
         $subforums = isset($_REQUEST['searchsubforums']) && intval($_REQUEST['searchsubforums']) == 1 ? TRUE : FALSE;
         $allforums = intval(@$forums[0]) == -1 ? TRUE : FALSE;
         $searchable_forums = $allforums ? '-1' : '';
         // do not include the first option
         for ($i = 1; $i < count($forums); $i++) {
             $id = intval($forums[$i]);
             // forums
             if (isset($_ALLFORUMS[$id])) {
                 if (get_map('', 'can_view', array('forum_id' => $id)) <= $request['user']->get('perms')) {
                     $forum_ids .= !$subforums && $_ALLFORUMS[$id]['row_level'] > 2 ? '' : ' OR forum_id = ' . intval($id);
                     $searchable_forums .= '|' . $id;
                 }
             }
         }
         $category_ids = $category_ids != '' ? ' AND (' . substr($category_ids, 4) . ') ' : '';
         $forum_ids = $forum_ids != '' ? ' AND (' . substr($forum_ids, 4) . ') ' : '';
         //			if(($allforums && !$subforums) || (!$allforums && !$subforums) ) {
         //				$forum_ids			= $forum_ids != '' ? ' AND ('. substr($forum_ids, 4) .') ' : '';
         //			} else {
         //				$category_ids		= '';
         //				$forum_ids			= '';
         //				$searchable_forums	= '-1';
         //			}
     }
     /* Set which forums we're looking through to the display options field */
     $request['template']->setVar('search_forums', trim($searchable_forums, '|'));
     /**
      * Sort out keywords
      */
     $keyword_query = '';
     if (isset($_REQUEST['keywords']) && $_REQUEST['keywords'] != '' && !isset($_REQUEST['newposts'])) {
         // deal with wildcrds
         $keywords = str_replace('%', '*', $_REQUEST['keywords']);
         $keywords = intval($request['template']->getVar('allowwildcards')) == 1 ? str_replace('*', '%', $keywords) : str_replace('*', ' ', $keywords);
         // are the keywords too short or too long?
         if (strlen($keywords) < $request['template']->getVar('minsearchlength') || strlen($keywords) > $request['template']->getVar('maxsearchlength')) {
             $action = new K4InformationAction(new K4LanguageElement('L_INVALIDSEARCHKEYWORDS', $request['template']->getVar('minsearchlength'), $request['template']->getVar('maxsearchlength')), 'content', TRUE, 'search.php', 5);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(sprintf($request['template']->getVar('L_INVALIDSEARCHKEYWORDS'), $request['template']->getVar('minsearchlength'), $request['template']->getVar('maxsearchlength')));
         }
         // has the person specified where to search?
         if (isset($_REQUEST['searchwhere']) && $_REQUEST['searchwhere'] != '' && $_REQUEST['searchwhere'] != 'subjectmessage') {
             if ($_REQUEST['searchwhere'] == 'subject') {
                 $keyword_query = " AND LOWER(name) LIKE LOWER('%" . $request['dba']->quote($keywords) . "%')";
             } else {
                 if ($_REQUEST['searchwhere'] == 'message') {
                     $keyword_query = " AND LOWER(body_text) LIKE LOWER('%" . $request['dba']->quote($keywords) . "%')";
                 }
             }
         } else {
             $keyword_query = "  AND (LOWER(name) LIKE LOWER('%" . $request['dba']->quote($keywords) . "%') OR LOWER(body_text) LIKE LOWER('%" . $request['dba']->quote($keywords) . "%')) ";
         }
     }
     // set where we are searching to the template
     $request['template']->setVar('search_where', !isset($_REQUEST['searchwhere']) ? 'subjectmessage' : $_REQUEST['searchwhere']);
     // are there no keywords, user ids, etc?
     if ($keyword_query == '' && $user_ids == '' && !isset($_SESSION['search']['search_queries']) && !isset($_REQUEST['newposts'])) {
         $action = new K4InformationAction(new K4LanguageElement('L_SEARCHINVALID'), 'content', TRUE, 'search.php', 3);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_SEARCHINVALID');
     }
     /**
      * Viewing preferences
      */
     $sort_orders = array('created', 'poster_name', 'name', 'forum_id');
     $viewas = isset($_SESSION['search']['search_queries']['viewas']) && $_SESSION['search']['search_queries']['viewas'] == 'topics' ? 'topics' : (isset($_REQUEST['viewas']) && $_REQUEST['viewas'] == 'topics' ? 'topics' : 'posts');
     $resultsperpage = $viewas == 'topics' ? intval($request['template']->getVar('searchtopicsperpage')) : intval($request['template']->getVar('searchpostsperpage'));
     $resultsperpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : $resultsperpage;
     $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;
     $daysprune = isset($_REQUEST['daysprune']) && ctype_digit($_REQUEST['daysprune']) ? $_REQUEST['daysprune'] == -1 ? 0 : intval($_REQUEST['daysprune']) : 0;
     $daysprune = $daysprune > 0 ? time() - @($daysprune * 86400) : 0;
     $sortorder = isset($_SESSION['search']['search_queries']['order']) && $_SESSION['search']['search_queries']['order'] == 'ASC' ? 'ASC' : (isset($_REQUEST['order']) && $_REQUEST['order'] == 'ASC' ? 'ASC' : 'DESC');
     $sortedby = isset($_SESSION['search']['search_queries']['sort']) && $_SESSION['search']['search_queries']['sort'] != 'DESC' ? $_SESSION['search']['search_queries']['sort'] : (isset($_REQUEST['sort']) && $_REQUEST['sort'] != '' ? $_REQUEST['sort'] : 'created');
     $start = ceil(@($page - 1) * $resultsperpage);
     /**
      * Execute the search
      */
     /* Create an array of the queries that we will use to weed out posts and pass through the session */
     $select = "num_replies, forum_id, post_id, post_id, body_text, name, posticon, is_poll, poster_name, poster_id, views, lastpost_uname, lastpost_uid, created, row_type";
     $general_condition = "is_draft=0 AND queue=0 AND display=1 AND moved_new_post_id=0 AND post_id>0";
     //$selectr			= "num_replies, forum_id, post_id, post_id, body_text, name, posticon, is_poll, poster_name, poster_id, poster_ip as views, poster_ip, category_id, created, row_type";
     $queries = array('posts' => "SELECT **SELECT** FROM " . K4POSTS . " WHERE {$general_condition} {$user_ids} {$forum_ids} {$category_ids} {$keyword_query} AND created >= {$daysprune} ORDER BY {$sortedby} {$sortorder}", 'topics_only' => "SELECT **SELECT** FROM " . K4POSTS . " WHERE row_type=" . TOPIC . " AND {$general_condition} {$user_ids} {$forum_ids} {$keyword_query} ORDER BY {$sortedby} {$sortorder}", 'viewas' => $viewas, 'limit' => $resultsperpage, 'sort' => $sortedby, 'order' => $sortorder, 'author' => @$_REQUEST['author'], 'keywords' => @$_REQUEST['keywords'], 'subforums' => intval(@$_REQUEST['searchsubforums']));
     //print_r($queries);
     // set these queries to the session
     if (isset($_SESSION['search']['search_queries']) && is_array($_SESSION['search']['search_queries']) && !empty($_SESSION['search']['search_queries'])) {
         $queries = $_SESSION['search']['search_queries'];
     } else {
         $_SESSION['search']['search_queries'] = $queries;
     }
     /* Get topics and replies */
     if ($queries['viewas'] == 'posts') {
         if (!isset($queries['num_results'])) {
             $num_results = $request['dba']->getValue(str_replace('**SELECT**', 'COUNT(post_id)', $queries['posts']));
             $_SESSION['search']['search_queries']['num_results'] = $num_results;
         } else {
             $num_results = $queries['num_results'];
         }
         /* Set the iterator */
         $result = $request['dba']->executeQuery(str_replace('**SELECT**', $select, $queries['posts']) . " LIMIT {$start}," . intval($queries['limit']));
         $it =& new SearchResultsIterator($request['dba'], $result);
         /* Get topics only */
     } else {
         if (!isset($queries['num_results'])) {
             $num_results = $request['dba']->getValue(str_replace('**SELECT**', 'COUNT(post_id)', $queries['topics_only']));
             $_SESSION['search']['search_queries']['num_results'] = $num_results;
         } else {
             $num_results = $queries['num_results'];
         }
         /* get the topics */
         $topics = $request['dba']->executeQuery(str_replace('**SELECT**', '*', $queries['topics_only']) . " LIMIT {$start}," . $queries['limit']);
         /* Apply the topics iterator */
         $it =& new TopicsIterator($request['dba'], $request['user'], $topics, $request['template']->getVar('IMG_DIR'), array('postsperpage' => $queries['limit']));
     }
     /**
      * Pagination
      */
     /* Create the Pagination */
     $url = new FAUrl($_URL->__toString());
     $url->args['limit'] = $queries['limit'];
     $url->args['viewas'] = $queries['viewas'];
     $url->args['sort'] = $queries['sort'];
     $url->args['order'] = $queries['order'];
     $url->args['page'] = FALSE;
     $url->anchor = FALSE;
     $num_pages = ceil(@($num_results / $queries['limit']));
     $pager =& new FAPaginator($url, $num_results, $page, $queries['limit']);
     $base_url = new FAUrl($_URL->__toString());
     if ($num_results > $resultsperpage) {
         $request['template']->setPager('searchresults_pager', $pager);
         /* Create a friendly url for our pager jump */
         $request['template']->setVar('pagejumper_url', preg_replace('~&amp;~i', '&', $base_url->__toString()));
     }
     /* Outside valid page range, redirect */
     if (!$pager->hasPage($page) && $num_pages > 0) {
         $base_url->args['page'] = $num_pages;
         $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, $base_url->__toString(), 3);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_PASTPAGELIMIT');
     }
     // finish stuff off
     $request['template']->setVar('mod_panel', 0);
     $request['template']->setVar('search_panel', 1);
     $request['template']->setList('search_results', $it);
     /* Search data gathered */
     $request['template']->setVar('search_viewas', $queries['viewas']);
     $request['template']->setVar('search_viewas_int', $queries['viewas'] == 'posts' ? 1 : 2);
     // for the if statements
     $request['template']->setVar('search_num_results', $num_results);
     $request['template']->setVar('search_author', $queries['author']);
     $request['template']->setVar('search_keywords', $queries['keywords']);
     $request['template']->setVar('search_sort', $queries['sort']);
     $request['template']->setVar('search_limit', $queries['limit']);
     $request['template']->setVar('search_order', $queries['order']);
     $request['template']->setVar('search_subforums', $queries['subforums']);
     $request['template']->setVar('search_daysprune', isset($_REQUEST['daysprune']) ? intval($_REQUEST['daysprune']) : 0);
     $request['template']->setVar('post_length', isset($_REQUEST['post_length']) && intval($_REQUEST['post_length']) > 0 ? intval($_REQUEST['post_length']) : intval($request['template']->getVar('searchpostlength')));
     $request['template']->setFile('content', 'search_results.html');
     //$request['template']->setFile('content_extra', 'search_sort_menu.html');
     $request['template']->setVisibility('forum_midsection', FALSE);
     /* Memory Saving */
     unset($result);
     if (USE_XMLHTTP) {
         $html = $request['template']->run(BB_BASE_DIR . '/templates/' . $request['user']->get('templateset') . '/search_results_simple.html');
         xmlhttp_header();
         echo $html;
         xmlhttp_footer();
     }
     return TRUE;
 }
コード例 #5
0
/**
 * Function to make pagination 
 */
function paginate($count, $first, $prev, $separator, $next, $last, $limit, $id)
{
    global $_URL, $_LANG;
    $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
    $limit = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) ? intval($_REQUEST['limit']) : $limit;
    $limit = $limit <= 0 ? 10 : $limit;
    $url = new FAUrl($_URL->__toString());
    $url->anchor = FALSE;
    $url->host = FALSE;
    $url->user = FALSE;
    $url->scheme = FALSE;
    $url->path = FALSE;
    $url->file = 'viewtopic.php';
    $url->args['id'] = intval($id);
    $before = 3;
    $after = 3;
    $num_pages = @ceil($count / $limit);
    $page_start = $page - $before < 1 ? 1 : $page - $before;
    $page_end = $page + $after > $num_pages ? $num_pages : $page + $after;
    $url->args['page'] = $page;
    $url->args['limit'] = $limit;
    if ($count > $limit) {
        $str = '<div style="float: right;"><table celpadding="0" cellspacing="' . K4_TABLE_CELLSPACING . '" border="0" class="pagination"><tr>';
        if ($page > 1) {
            $str .= '<td class="alt2" style="padding:2px;"><a href="' . $url->__toString() . '" class="minitext">' . $first . '</a></td>';
            $url->args['page'] = $page - 1 <= 0 ? 1 : $page - 1;
            $str .= '<td class="alt2" style="padding:2px;"><a href="' . $url->__toString() . '" class="minitext">' . $prev . '</a></td>';
        }
        //$str .= '(';
        for ($i = $page_start; $i <= $page_end; $i++) {
            $url->args['page'] = $i;
            $str .= '<td class="alt1" style="padding:2px;"><a href="' . $url->__toString() . '" class="minitext">' . $i . '</a></td>';
            if ($i != $page_end) {
                $str .= $separator;
            }
        }
        //$str .= ')';
        if ($page != $num_pages) {
            if ($page != $num_pages && $page > 1) {
                $url->args['page'] = $page + 1 < $num_pages ? $page + 1 : $num_pages;
                $str .= '<td class="alt2" style="padding:2px;"><a href="' . $url->__toString() . '" class="minitext">' . $next . '</a></td>';
            }
            $url->args['page'] = $num_pages;
            $str .= '<td class="alt2" style="padding:2px;"><a href="' . $url->__toString() . '" class="minitext">' . $last . '</a></td>';
        }
        $str .= '</tr></table></div>';
        return $str;
    }
}
コード例 #6
0
ファイル: user.php プロジェクト: BackupTheBerlios/k4bb-svn
/**
 * Email a user with the proper noreply email address
 */
function email_user($to, $subject, $message, $from = 'noreply', $headers = "")
{
    global $_URL, $_SETTINGS;
    $verify_url = new FAUrl($_URL->__toString());
    $verify_url->args = array();
    $verify_url->file = FALSE;
    $verify_url->anchor = FALSE;
    $verify_url->scheme = FALSE;
    $verify_url->path = FALSE;
    $verify_url->host = preg_replace('~www\\.~i', '', $verify_url->host);
    return @mail($to, $subject, $message, "From: \"" . $_SETTINGS['bbtitle'] . " Forums\" <" . $from . "@" . substr($verify_url->__toString(), 0, -1) . ">" . $headers);
}
コード例 #7
0
 function execute(&$request)
 {
     global $_URL;
     if ($request['user']->get('perms') < get_map('banuser', 'can_add', array()) && $request['user']->get('perms') < get_map('warnuser', 'can_add', array()) && $request['user']->get('perms') < get_map('flaguser', 'can_add', array())) {
         no_perms_error($request);
         return TRUE;
     }
     // include the wildcards in the valid username match
     if (!isset($_REQUEST['username']) || $_REQUEST['username'] == '' || !preg_match('~^[a-zA-Z]([a-zA-Z0-9]*[-_ \\*\\%]?)*[a-zA-Z0-9]*$~', $_REQUEST['username'])) {
         $action = new K4InformationAction(new K4LanguageElement('L_BADUSERS'), 'content', TRUE);
         return $action->execute($request);
     }
     $url = new FAUrl($_URL->__toString());
     $username = str_replace('*', '%', $request['dba']->quote($_REQUEST['username']));
     $num_users = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4USERS . " WHERE lower(name) LIKE lower('%{$username}%') ORDER BY name DESC");
     $request['template']->setVar('search_num_results', $num_users);
     $perpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : 25;
     $num_pages = @ceil($num_users / $perpage);
     $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;
     $url->args['username'] = $username;
     $pager =& new FAPaginator($url, $num_users, $page, $perpage);
     if ($num_users > $perpage) {
         $request['template']->setPager('users_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()));
     }
     k4_bread_crumbs($request['template'], $request['dba'], 'L_FINDUSERS');
     /* Outside valid page range, redirect */
     if (!$pager->hasPage($page) && $num_pages > 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'mod.php?act=findusers&username='******'&limit=' . $perpage . '&page=' . $num_pages, 3);
         return $action->execute($request);
     }
     $result = $request['dba']->executeQuery("SELECT * FROM " . K4USERS . " WHERE lower(name) LIKE lower('%{$username}%') ORDER BY name DESC");
     $it =& new UsersIterator($result);
     $request['template']->setList('users', $it);
     $request['template']->setFile('content', 'foundusers.html');
 }
コード例 #8
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_URL;
     /**
      * Error checking 
      */
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     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);
     }
     // set the topic id to the template
     $request['template']->setVar('topic_id', $topic['post_id']);
     // get the forum
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($topic['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Make sure the we are trying to post to a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         no_perms_error($request);
         return TRUE;
     }
     /* Do we have permission to post to this topic in this forum? */
     if ($request['user']->get('perms') < get_map('replies', 'can_add', array('forum_id' => $forum['forum_id']))) {
         no_perms_error($request);
         return TRUE;
     }
     if (isset($_REQUEST['r']) && intval($_REQUEST['r']) != 0) {
         $reply = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['r']));
         if (!$reply || !is_array($reply) || empty($reply)) {
             $action = new K4InformationAction(new K4LanguageElement('L_REPLYDOESNTEXIST'), 'content', FALSE);
             return $action->execute($request);
         } else {
             $request['template']->setVisibility('parent_id', TRUE);
             $request['template']->setVar('parent_id', $reply['post_id']);
         }
     }
     /* Prevent post flooding */
     $last_topic = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE poster_ip = '" . USER_IP . "' ORDER BY created DESC LIMIT 1");
     $last_reply = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE poster_ip = '" . USER_IP . "' ORDER BY created DESC LIMIT 1");
     if (is_array($last_topic) && !empty($last_topic)) {
         if (intval($last_topic['created']) + POST_IMPULSE_LIMIT > time() && $request['user']->get('perms') < MODERATOR) {
             $action = new K4InformationAction(new K4LanguageElement('L_MUSTWAITSECSTOPOST'), 'content', TRUE);
             return $action->execute($request);
         }
     }
     if (is_array($last_reply) && !empty($last_reply)) {
         if (intval($last_reply['created']) + POST_IMPULSE_LIMIT > time() && $request['user']->get('perms') < MODERATOR) {
             $action = new K4InformationAction(new K4LanguageElement('L_MUSTWAITSECSTOPOST'), 'content', TRUE);
             return $action->execute($request);
         }
     }
     $parent = isset($reply) && is_array($reply) ? $reply : $topic;
     /**
      * Start setting useful template information
      */
     /* 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);
     /* Set to the template what posting perms this user has */
     topic_post_options($request['template'], $request['user'], $forum);
     /**
      * Deal with reply attachments
      */
     $num_attachments = 0;
     /**
      * Deal with file attachments
      */
     if ($request['template']->getVar('attach_inputs') == '') {
         if ($request['user']->get('perms') >= get_map('attachments', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $num_attachments = $request['template']->getVar('nummaxattaches') - $num_attachments;
             $attach_inputs = '';
             for ($i = 1; $i <= $num_attachments; $i++) {
                 $attach_inputs .= '<br /><input type="file" class="inputbox" name="attach' . $i . '" id="attach' . $i . '" value="" size="55" />';
             }
             $request['template']->setVar('attach_inputs', $attach_inputs);
         }
     }
     /* Set the forum and topic info to the template */
     foreach ($forum as $key => $val) {
         $request['template']->setVar('forum_' . $key, $val);
     }
     /* We set topic information to be reply information */
     foreach ($topic as $key => $val) {
         /* Omit the body text variable */
         if ($key != 'body_text') {
             $request['template']->setVar('post_' . $key, $val);
         }
     }
     $body_text = '';
     /* If this is a quote, put quote tags around the message */
     if (isset($_REQUEST['quote']) && intval($_REQUEST['quote']) == 1) {
         // are we quoting a poll?
         if ($parent['is_poll'] == 1) {
             // does this reply have a/some poll(s) ?
             preg_match_all('~\\[poll=([0-9]+?)\\]~i', $parent['body_text'], $poll_matches, PREG_SET_ORDER);
             if (count($poll_matches) > 0) {
                 $url = new FAUrl($_URL->__toString());
                 $url->args = array();
                 $url->anchor = FALSE;
                 $url->file = 'viewpoll.php';
                 foreach ($poll_matches as $poll) {
                     $parent['body_text'] = str_replace('[poll=' . $poll[1] . ']', $request['template']->getVar('L_POLL') . ': [b][url=' . $url->__toString() . '?id=' . $poll[1] . ']' . $request['dba']->getValue("SELECT question FROM " . K4POLLQUESTIONS . " WHERE id = " . intval($poll[1])) . '[/url][/b]', $parent['body_text']);
                 }
             }
         }
         // revert the text with the bbcode parser
         $parser =& new BBParser();
         $body_text = '[quote=' . ($parent['poster_name'] == '' ? $request['template']->getVar('L_GUEST') : $parent['poster_name']) . ']' . $parser->revert($parent['body_text']) . '[/quote]';
     }
     /* Set the title variable */
     $request['template']->setVar('post_name', $request['template']->getVar('L_RE') . ': ' . (isset($reply) ? $reply['name'] : $topic['name']));
     $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTREPLY', $parent, $forum);
     foreach ($parent as $key => $val) {
         $request['template']->setVar('parent_' . $key, $val);
     }
     $query = "SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($topic['post_id']) . " ORDER BY created DESC LIMIT 10";
     $replies = $request['dba']->executeQuery($query);
     /* Set the form actiob */
     $request['template']->setVar('newreply_act', 'newreply.php?act=postreply');
     $it =& new TopicReviewIterator($request['dba'], $topic, $replies, $request['user']->getInfoArray());
     $request['template']->setList('topic_review', $it);
     /* Set the post topic form */
     $request['template']->setFile('content', 'newreply.html');
     /* Create our editor */
     create_editor($request, $body_text, 'post', $forum);
     /* Clear up some memory */
     unset($it, $body_text, $forum, $replies, $bbcode, $last_topic, $last_reply, $topic);
     return TRUE;
 }
コード例 #9
0
 function execute(&$request)
 {
     global $_USERGROUPS, $_QUERYPARAMS, $_URL;
     /**
      * Are we looking at the list of user groups?
      */
     if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) {
         $result = explode('|', $request['user']->get('usergroups'));
         $groups = $request['user']->get('usergroups') && $request['user']->get('usergroups') != '' ? iif(!$result, force_usergroups($request['user']->getInfoArray()), $result) : array();
         $query = "SELECT * FROM " . K4USERGROUPS . " WHERE display_legend = 1";
         if ($request['user']->get('perms') < ADMIN) {
             foreach ($groups as $id) {
                 if (isset($_USERGROUPS[$id])) {
                     $query .= ' OR id = ' . intval($id);
                 }
             }
         } else {
             $query = "SELECT * FROM " . K4USERGROUPS;
         }
         $groups = $request['dba']->executeQuery($query);
         $request['template']->setList('usergroups', $groups);
         k4_bread_crumbs($request['template'], $request['dba'], 'L_USERGROUPS');
         $request['template']->setFile('content', 'usergroups.html');
         /**
          * Are we looking at a specific user group?
          */
     } else {
         /* Is this user group set? */
         if (!isset($_USERGROUPS[intval($_REQUEST['id'])])) {
             k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
             $action = new K4InformationAction(new K4LanguageElement('L_GROUPDOESNTEXIST'), 'content', FALSE);
             return $action->execute($request);
         }
         $group = $_USERGROUPS[intval($_REQUEST['id'])];
         /**
          * If the group admin has yet to be set, set it to our administrator
          */
         if ($group['mod_name'] == '' || $group['mod_id'] == 0) {
             /* Get our administrator */
             $admin = $request['dba']->getRow("SELECT * FROM " . K4USERS . " WHERE perms >= " . intval(ADMIN) . " ORDER BY perms,id ASC LIMIT 1");
             $request['dba']->executeUpdate("UPDATE " . K4USERGROUPS . " SET mod_name = '" . $request['dba']->quote($admin['name']) . "', mod_id = " . intval($admin['id']) . " WHERE id = " . intval($group['id']));
             reset_cache('usergroups');
             /* Add this info to the group array so that we can access it later */
             $group['mod_name'] = $admin['name'];
             $group['mod_id'] = $admin['id'];
         }
         /* Get our admins max user group.. it _should_ be the administrators group */
         $g = get_user_max_group($request['dba']->getRow("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id = " . intval($group['mod_id'])), $_USERGROUPS);
         /* Set his group's color */
         $group['mod_color'] = !isset($g['color']) || $g['color'] == '' ? '000000' : $g['color'];
         /* Add this group's info to the database */
         foreach ($group as $key => $val) {
             $request['template']->setVar('group_' . $key, $val);
         }
         /* Create the Pagination */
         $resultsperpage = 10;
         $num_results = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4USERS . " WHERE usergroups LIKE '%|" . intval($group['id']) . "|%' AND id <> " . intval($group['mod_id']));
         $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 FAPaginator($_URL, $num_results, $page, $perpage);
         if ($num_results > $perpage) {
             $request['template']->setPager('users_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()));
         }
         /* Outside valid page range, redirect */
         if (!$pager->hasPage($page) && $num_pages > 0) {
             $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'usergroups.php?id=' . $group['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
             return $action->execute($request);
         }
         /* Get the members for this usergroup */
         $start = ($page - 1) * $perpage;
         /* Get the members of this usergroup */
         if ($num_results > 0) {
             $result = $request['dba']->executeQuery("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.usergroups LIKE '%|" . intval($group['id']) . "|%' AND u.id <> " . intval($group['mod_id']) . " LIMIT " . intval($start) . ", " . intval($perpage));
             $users =& new UsersIterator($result);
             $request['template']->setList('users_in_usergroup', $users);
         }
         $request['template']->setVar('num_group_members', $num_results);
         if ($request['user']->get('id') == $group['mod_id']) {
             $request['template']->setVisibility('add_user', TRUE);
             $request['template']->setVar('is_mod', 1);
         }
         k4_bread_crumbs($request['template'], $request['dba'], $group['name']);
         $request['template']->setFile('content', 'lookup_usergroup.html');
     }
     return TRUE;
 }
コード例 #10
0
 function execute(&$request)
 {
     global $_URL;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     if (!isset($_REQUEST['id']) || !$_REQUEST['id'] || intval($_REQUEST['id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($_REQUEST['id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Make sure the we are trying to post into a forum */
     if (!($forum['row_type'] & FORUM)) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTMODACATEGORY'), 'content', FALSE);
         return $action->execute($request);
     }
     foreach ($forum as $key => $val) {
         $request['template']->setVar('forum_' . $key, $val);
     }
     /**
      * Moderator Functions
      */
     $extra = 'AND queue = 0';
     $request['template']->setVar('modpanel', 0);
     /* is this user a moderator */
     if (is_moderator($request['user']->getInfoArray(), $forum)) {
         $mod_url = new FAUrl($_URL->__toString());
         $mod_url->file = 'viewforum.php';
         $mod_url->args = array('f' => $forum['forum_id']);
         $request['template']->setVar('mod_url', $mod_url->__toString());
         $request['template']->setVar('modpanel', 1);
     } else {
         no_perms_error($request);
         return TRUE;
     }
     k4_bread_crumbs($request['template'], $request['dba'], 'L_BADPOSTREPORTS', $forum);
     $num_results = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4BADPOSTREPORTS . " WHERE forum_id = " . intval($forum['forum_id']));
     /**
      * Pagination
      */
     /* Create the Pagination */
     $perpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : 10;
     $num_pages = 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()));
     }
     /* Outside valid page range, redirect */
     if (!$pager->hasPage($page) && $num_pages > 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'mod.php?id=' . $forum['forum_id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
         return $action->execute($request);
     }
     /* Get the bad post reports for this forum */
     $start = ($page - 1) * $perpage;
     $reports = $request['dba']->executeQuery("SELECT * FROM " . K4BADPOSTREPORTS . " WHERE forum_id = " . intval($forum['forum_id'] . " ORDER BY created ASC LIMIT {$start},{$perpage}"));
     $it = new BadPostReportIterator($request['dba'], $reports);
     $request['template']->setList('badpost_reports', $it);
     $request['template']->setFile('content', 'badpost_reports.html');
 }