Beispiel #1
0
 /**
  * Builds an array of forum data for use in the output template
  *
  * @return	array
  */
 public function renderForum()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['page'] = $this->request['changefilters'] ? 0 : (isset($this->request['page']) ? intval($this->request['page']) : 0);
     $announce_data = array();
     $topic_data = array();
     $other_data = array();
     $multi_mod_data = array();
     $footer_filter = array();
     $member_ids = array();
     //-----------------------------------------
     // Show?
     //-----------------------------------------
     if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') {
         $this->request['prune_day'] = 200;
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     $mod = $this->memberData['forumsModeratorData'];
     if (!$this->memberData['g_is_supmod']) {
         if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     //-----------------------------------------
     // Announcements
     //-----------------------------------------
     if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) {
         $announcements = array();
         foreach ($this->registry->cache()->getCache('announcements') as $announce) {
             $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id'];
             if ($announce['announce_forum'] == '*') {
                 $announcements[$order] = $announce;
             } else {
                 if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) {
                     $announcements[$order] = $announce;
                 }
             }
         }
         if (count($announcements)) {
             //-----------------------------------------
             // sort by start date
             //-----------------------------------------
             krsort($announcements);
             foreach ($announcements as $announce) {
                 if ($announce['announce_start']) {
                     $announce['announce_start'] = $this->lang->getDate($announce['announce_start'], 'date');
                 } else {
                     $announce['announce_start'] = '--';
                 }
                 $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']);
                 $announce['forum_id'] = $this->forum['id'];
                 $announce['announce_views'] = intval($announce['announce_views']);
                 $announce_data[] = $announce;
                 $member_ids[$announce['member_id']] = $announce['member_id'];
             }
             $this->forum['_showAnnouncementsBar'] = 1;
         }
     }
     //-----------------------------------------
     // Read topics
     //-----------------------------------------
     $First = $this->registry->class_forums->pageToSt(intval($this->request['page']));
     //-----------------------------------------
     // Sort options
     //-----------------------------------------
     $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day");
     $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key");
     $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by");
     $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter");
     $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100'));
     $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post'));
     $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A'));
     $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all'));
     if (!empty($this->request['remember'])) {
         if ($this->request['prune_day']) {
             IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']);
         }
         if ($this->request['sort_key']) {
             IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']);
         }
         if ($this->request['sort_by']) {
             IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']);
         }
         if ($this->request['topicfilter']) {
             IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']);
         }
     }
     //-----------------------------------------
     // Figure out sort order, day cut off, etc
     //-----------------------------------------
     $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0);
     $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views');
     $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit');
     $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order');
     $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved');
     if ($this->memberData['member_id']) {
         $filter_keys['istarted'] = 'topicfilter_istarted';
         $filter_keys['ireplied'] = 'topicfilter_ireplied';
     }
     //-----------------------------------------
     // check for any form funny business by wanna-be hackers
     //-----------------------------------------
     if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[strtoupper($sort_by)])) {
         $this->registry->getClass('output')->showError('forums_bad_filter', 10339);
     }
     $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
     //-----------------------------------------
     // If sorting by starter, add secondary..
     //-----------------------------------------
     $sort_key_chk = $sort_key;
     if ($sort_key == 'starter_name') {
         $sort_key = "starter_name {$r_sort_by}, t.last_post DESC";
         $r_sort_by = '';
     }
     //-----------------------------------------
     // Additional queries?
     //-----------------------------------------
     $add_query_array = array();
     $add_query = "";
     switch ($topicfilter) {
         case 'all':
             break;
         case 'open':
             $add_query_array[] = "t.state='open'";
             break;
         case 'hot':
             $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']);
             break;
         case 'locked':
             $add_query_array[] = "t.state='closed'";
             break;
         case 'moved':
             $add_query_array[] = "t.state='link'";
             break;
         case 'poll':
             $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)";
             break;
         default:
             break;
     }
     if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) {
         $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'";
     }
     /* Answered / unanswered */
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         if ($this->request['answered'] == 'true') {
             $add_query_array[] = 't.topic_answered_pid != 0';
         } else {
             if ($this->request['answered'] == 'false') {
                 $add_query_array[] = 't.topic_answered_pid = 0';
             }
         }
     }
     $_SQL_EXTRA = '';
     $_SQL_APPROVED = '';
     $_SQL_AGE_PRUNE = '';
     if (count($add_query_array)) {
         $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array);
     }
     //-----------------------------------------
     // Moderator?
     //-----------------------------------------
     $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : '';
     $modFilter = '';
     if ($this->memberData['is_mod']) {
         if ($this->request['modfilter'] == 'unapproved') {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('hidden'), 't.') . ' OR t.topic_queuedposts';
         } elseif ($this->permissions['TopicSoftDeleteSee']) {
             if ($this->request['modfilter'] == 'hidden') {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted'), 't.') . ' OR t.topic_deleted_posts';
             } else {
                 $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden', 'sdeleted'), 't.');
             }
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'hidden'), 't.');
         }
     } else {
         if ($this->permissions['TopicSoftDeleteSee']) {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible', 'sdeleted'), 't.');
         } else {
             $modFilter = $this->registry->class_forums->fetchTopicHiddenQuery(array('visible'), 't.');
         }
     }
     if ($modFilter) {
         $_SQL_APPROVED = ' AND (' . $modFilter . ')';
     }
     if ($Prune) {
         if ($prune_value == 200) {
             /* Just new content, don't show pinned, please */
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})";
             }
         } else {
             if ($modFilter) {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune} AND ( {$modFilter} ) )";
             } else {
                 $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})";
             }
         }
     }
     //-----------------------------------------
     // Query the database to see how many topics there are in the forum
     //-----------------------------------------
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         //-----------------------------------------
         $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => "t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid'))));
         $this->DB->execute();
         $total_possible = $this->DB->fetch();
     } else {
         if ($_SQL_EXTRA or $_SQL_AGE_PRUNE or $this->request['modfilter']) {
             $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA));
             $this->DB->execute();
             $total_possible = $this->DB->fetch();
         } else {
             $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics'];
             if ($this->permissions['TopicSoftDeleteSee'] and $this->forum['deleted_topics']) {
                 $total_possible['max'] += intval($this->forum['deleted_topics']);
             }
             $Prune = 0;
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $_extraStuff = '';
     if ($this->request['modfilter']) {
         $_extraStuff .= "&amp;modfilter=" . $this->request['modfilter'];
     }
     if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) {
         $_extraStuff .= "&amp;answered=" . $this->request['answered'];
     }
     $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => intval($this->request['page']), 'isPagesMode' => true, 'seoTitle' => $this->forum['name_seo'], 'disableSinglePage' => false, 'baseUrl' => "showforum=" . $this->forum['id'] . "&amp;prune_day={$prune_value}&amp;sort_by={$sort_by}&amp;sort_key={$sort_key_chk}&amp;topicfilter={$topicfilter}{$_extraStuff}"));
     //-----------------------------------------
     // Start printing the page
     //-----------------------------------------
     $other_data = array('forum_data' => $this->forum, 'hasMore' => $this->registry->class_forums->pageToSt($this->request['page']) + $this->settings['display_max_topics'] > $total_possible['max'] ? false : true, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics, 'can_move_topics' => $this->can_move_topics);
     $total_topics_printed = 0;
     //-----------------------------------------
     // Get main topics
     //-----------------------------------------
     $topic_array = array();
     $topic_ids = array();
     $topic_sort = "";
     //-----------------------------------------
     // Cut off?
     //-----------------------------------------
     $modAll = ($this->memberData['g_is_supmod'] or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($this->memberData['forumsModeratorData'][$this->forum['id']]['delete_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['move_topic'] or $this->memberData['forumsModeratorData'][$this->forum['id']]['split_merge']));
     $parse_dots = 1;
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         // No point in getting dots again...
         //-----------------------------------------
         $parse_dots = 0;
         $_joins = array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id']));
         if ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) {
             $_joins[] = $this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'));
         }
         // For some reason, mySQL doesn't like the distinct + t.* being in reverse order...
         $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => $_joins));
         $this->DB->execute();
     } else {
         $this->DB->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics']), 'add_join' => ($this->settings['tags_enabled'] and !$this->forum['bw_disable_tagging']) ? array($this->registry->tags->getCacheJoin(array('meta_id_field' => 't.tid'))) : array()));
         $this->DB->execute();
     }
     while ($t = $this->DB->fetch()) {
         /* Should we display the moderate checkbox for this post? */
         $t['moddable'] = FALSE;
         if ($modAll or isset($this->memberData['forumsModeratorData'][$this->forum['id']]) and ($t['pinned'] == 0 and $this->memberData['forumsModeratorData'][$this->forum['id']]['pin_topic'] or $t['pinned'] == 1 and $this->memberData['forumsModeratorData'][$this->forum['id']]['unpin_topic'] or $t['state'] == 'open' and $this->memberData['forumsModeratorData'][$this->forum['id']]['close_topic'] or $t['state'] == 'closed' and $this->memberData['forumsModeratorData'][$this->forum['id']]['open_topic'])) {
             $t['moddable'] = TRUE;
         }
         /* Add to array */
         $topic_array[$t['tid']] = $t;
         $topic_ids[$t['tid']] = $t['tid'];
         if ($t['last_poster_id']) {
             $member_ids[$t['last_poster_id']] = $t['last_poster_id'];
         }
         if ($t['starter_id']) {
             $member_ids[$t['starter_id']] = $t['starter_id'];
         }
     }
     ksort($topic_ids);
     //-----------------------------------------
     // Are we dotty?
     //-----------------------------------------
     if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $_queued = $this->registry->class_forums->fetchPostHiddenQuery(array('visible'), '');
         $this->DB->build(array('select' => $this->DB->buildDistinct('topic_id'), 'from' => 'posts', 'where' => $_queued . ' AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['author_id'] = $this->memberData['member_id'];
             }
         }
     }
     //-----------------------------------------
     // Get needed members
     //-----------------------------------------
     if (count($member_ids)) {
         $_members = IPSMember::load($member_ids);
         //-----------------------------------------
         // Add member data to announcements
         //-----------------------------------------
         $new_announces = array();
         foreach ($announce_data as $announce) {
             $announce = array_merge($announce, IPSMember::buildDisplayData($_members[$announce['member_id']]));
             $new_announces[] = $announce;
         }
         $announce_data = $new_announces;
     }
     //-----------------------------------------
     // Show meh the topics!
     //-----------------------------------------
     $adCodeSet = false;
     foreach ($topic_array as $topic) {
         /* Add member */
         if ($topic['last_poster_id']) {
             $topic = array_merge(IPSMember::buildDisplayData($_members[$topic['last_poster_id']]), $topic);
         } else {
             $topic = array_merge(IPSMember::buildProfilePhoto(array()), $topic);
         }
         if ($topic['starter_id']) {
             $topic['_starter'] = $_members[$topic['starter_id']];
         }
         /* AD Code */
         if ($this->registry->getClass('IPSAdCode')->userCanViewAds() && !$adCodeSet) {
             $topic['_adCode'] = $this->registry->getClass('IPSAdCode')->getAdCode('ad_code_forum_view_topic_code');
             if ($topic['_adCode']) {
                 $adCodeSet = true;
             }
         }
         if ($topic['pinned']) {
             $this->pinned_topic_count++;
         }
         $topic_data[$topic['tid']] = $this->renderEntry($topic);
         $total_topics_printed++;
     }
     //-----------------------------------------
     // Finish off the rest of the page  $filter_keys[$topicfilter]))
     //-----------------------------------------
     $sort_by_html = "";
     $sort_key_html = "";
     $prune_day_html = "";
     $filter_html = "";
     foreach ($sort_by_keys as $k => $v) {
         $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n";
     }
     foreach ($sort_keys as $k => $v) {
         $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n";
     }
     foreach ($prune_by_day as $k => $v) {
         $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n";
     }
     foreach ($filter_keys as $k => $v) {
         $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n";
     }
     $footer_filter['sort_by'] = $sort_key_html;
     $footer_filter['sort_order'] = $sort_by_html;
     $footer_filter['sort_prune'] = $prune_day_html;
     $footer_filter['topic_filter'] = $filter_html;
     if ($this->memberData['is_mod']) {
         $count = 0;
         $other_pages = 0;
         if ($this->request['selectedtids'] != "") {
             $tids = explode(",", $this->request['selectedtids']);
             if (is_array($tids) and count($tids)) {
                 foreach ($tids as $tid) {
                     if ($tid != '') {
                         if (!isset($topic_array[$tid])) {
                             $other_pages++;
                         }
                         $count++;
                     }
                 }
             }
         }
         $this->lang->words['f_go'] .= " ({$count})";
         if ($other_pages) {
             $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")";
         }
     }
     //-----------------------------------------
     // Multi-moderation?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']);
         if (is_array($mm_array) and count($mm_array)) {
             foreach ($mm_array as $m) {
                 $multi_mod_data[] = $m;
             }
         }
     }
     //-----------------------------------------
     // Need to update topics?
     //-----------------------------------------
     if (count($this->update_topics_open)) {
         $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')');
     }
     if (count($this->update_topics_close)) {
         $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')');
     }
     /* Got soft delete tids? */
     if (is_array($this->_sdTids) and count($this->_sdTids)) {
         $other_data['sdData'] = IPSDeleteLog::fetchEntries($this->_sdTids, 'topic', false);
     }
     /* Fetch follow data */
     $other_data['follow_data'] = $this->_like->render('summary', $this->forum['id']);
     return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->_generateActiveUserData());
 }
 /**
  * Show the mediatag add/edit form
  *
  * @access	private
  * @param	string	[$type='add']
  * @param	array 	[Optional] array of errors
  * @return	void
  */
 private function _mediaTagForm($type = 'add', $errors = array())
 {
     /* Check form type */
     if ($type == 'add') {
         /* Data */
         $data = array('mediatag_name' => $this->request['mediatag_name'], 'mediatag_match' => rtrim(str_replace('&#092;', '\\', str_replace('&#039', "'", trim(IPSText::stripslashes($_POST['mediatag_match'])))), ','), 'mediatag_replace' => rtrim(str_replace('&#092;', '\\', str_replace('&#039', "'", trim(IPSText::stripslashes($_POST['mediatag_replace'])))), ','));
     } else {
         /* Data */
         $id = intval($this->request['id']);
         $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bbcode_mediatag', 'where' => "mediatag_id={$id}"));
         /* Set Defaults */
         $data['mediatag_name'] = isset($this->request['mediatag_name']) && $this->request['mediatag_name'] ? $this->request['mediatag_name'] : $data['mediatag_name'];
         $data['mediatag_match'] = isset($this->request['mediatag_match']) && $this->request['mediatag_match'] ? $this->request['mediatag_match'] : $data['mediatag_match'];
         $data['mediatag_replace'] = isset($this->request['mediatag_replace']) && $this->request['mediatag_replace'] ? $this->request['mediatag_replace'] : $data['mediatag_replace'];
     }
     /* Setup Form */
     $this->registry->output->html .= $this->html->mediaTagForm($type, $data, $errors);
 }
Beispiel #3
0
 /**
  * Main function executed automatically by the controller
  *
  * @param	object		$registry		Registry object
  * @return	@e void
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Load skin
     //-----------------------------------------
     $this->html = $this->registry->output->loadTemplate('cp_skin_mycp');
     //-----------------------------------------
     // Load language
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('admin_mycp'));
     /* This is a little hacky, but we have to allow access to the whole module to get access to 
        'change my details'.  This check just makes sure that we don't also get access to the Dashboard
        if the permission system automatically added permission for 'change my details' */
     if ($this->registry->getClass('class_permissions')->editDetailsOnly) {
         /* If they just don't have access to the dashboard, let's show them something we do have access to */
         if (!$this->request['app']) {
             foreach (ipsRegistry::$applications as $k => $data) {
                 if ($this->registry->getClass('class_permissions')->checkForAppAccess($k) and ($k != 'core' or !$this->registry->getClass('class_permissions')->editDetailsOnly)) {
                     foreach (ipsRegistry::$modules[$k] as $module) {
                         if ($this->registry->getClass('class_permissions')->checkForModuleAccess($k, $module['sys_module_key'])) {
                             $filepath = IPSLib::getAppDir($k) . '/modules_admin/' . $module['sys_module_key'] . '/defaultSection.php';
                             if (is_file($filepath)) {
                                 $DEFAULT_SECTION = '';
                                 include $filepath;
                                 /*noLibHook*/
                                 if ($this->registry->getClass('class_permissions')->checkForSectionAccess($k, $module['sys_module_key'], $DEFAULT_SECTION)) {
                                     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "app={$k}&amp;module={$module['sys_module_key']}&amp;section={$DEFAULT_SECTION}");
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /* If all else fails, take them to the change details page */
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "core&amp;module=mycp&amp;section=details");
     } else {
         if (!$this->registry->getClass('class_permissions')->checkPermission('dashboard', 'core', 'mycp')) {
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . "core&amp;module=mycp&amp;section=details");
         }
     }
     //-----------------------------------------
     // Set up stuff
     //-----------------------------------------
     $this->form_code = $this->html->form_code = 'module=mycp&amp;section=dashboard';
     $this->form_code_js = $this->html->form_code_js = 'module=mycp&section=dashboard';
     //-----------------------------------------
     // Hang on, do we need the upgrader?
     // The only reason this is still here, since we check on the login form, is because Rhett Buck AKA BHP wants to
     // login to the ACP, then upload files, then click the System tab and be automatically redirected to the upgrader.
     // Seriously though?  Who does that?  The login form redirects you, so if you happen to upload files and click on
     // the ACP link you're already covered.  Only Mr. RB, that's who.
     //-----------------------------------------
     if (!IN_DEV and (!defined('SKIP_UPGRADE_CHECK') or !SKIP_UPGRADE_CHECK)) {
         require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
         /*noLibHook*/
         foreach (ipsRegistry::$applications as $app_dir => $app) {
             $_a = ($app_dir == 'forums' or $app_dir == 'members') ? 'core' : $app_dir;
             $numbers = IPSSetUp::fetchAppVersionNumbers($_a);
             if ($numbers['latest'][0] and $numbers['latest'][0] > $numbers['current'][0]) {
                 $this->registry->output->silentRedirect($this->settings['base_acp_url'] . '/upgrade/index.php?_acpRedirect=1');
                 return;
             }
         }
     }
     //-----------------------------------------
     // Get external data
     //-----------------------------------------
     $content = array();
     $thiscontent = "";
     $latest_version = array();
     $reg_end = "";
     $unfinished_upgrade = 0;
     $ipsNewsData = $this->cache->getCache('ipsNewsData');
     if (!isset($ipsNewsData['time']) or $ipsNewsData['time'] < time() - 43200) {
         $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement');
         $classFileManagement = new $classToLoad();
         if (strpos($this->settings['base_url'], 'https://') !== false) {
             $ipsNewsData['news'] = $classFileManagement->getFileContents('https://external.ipslink.com/ipboard33/dashboard/index.php?v=' . ipsRegistry::$vn_full);
             $ipsNewsData['vcheck'] = $classFileManagement->getFileContents('https://external.ipslink.com/latestversioncheck/ipb30x.php?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']));
         } else {
             $ipsNewsData['news'] = $classFileManagement->getFileContents('http://external.ipslink.com/ipboard33/dashboard/index.php?v=' . ipsRegistry::$vn_full);
             $ipsNewsData['vcheck'] = $classFileManagement->getFileContents('http://external.ipslink.com/latestversioncheck/ipb30x.php?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']));
         }
         $ipsNewsData['time'] = time();
         $this->cache->setCache('ipsNewsData', $ipsNewsData, array('array' => 1));
     }
     //-----------------------------------------
     // Get MySQL & PHP Version
     //-----------------------------------------
     $this->DB->getSqlVersion();
     //-----------------------------------------
     // Upgrade history?
     //-----------------------------------------
     $latest_version = array('upgrade_version_id' => NULL);
     $this->DB->build(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $latest_version = $r;
     }
     //-----------------------------------------
     // Resetting security image?
     //-----------------------------------------
     if ($this->request['reset_security_flag'] and $this->request['reset_security_flag'] == 1 and $this->request['new_build']) {
         $_latest = IPSLib::fetchVersionNumber('core');
         $new_build = intval($this->request['new_build']);
         $new_reason = trim(substr($this->request['new_reason'], 0, 1));
         $new_version = $_latest['long'] . '.' . $new_build . '.' . $new_reason;
         $this->DB->update('upgrade_history', array('upgrade_notes' => $new_version), 'upgrade_version_id=' . $latest_version['upgrade_version_id']);
         $latest_version['upgrade_notes'] = $new_version;
     }
     //-----------------------------------------
     // Got real version number?
     //-----------------------------------------
     ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
     ipsRegistry::$vn_full = !empty($latest_version['upgrade_notes']) ? $latest_version['upgrade_notes'] : ipsRegistry::$vn_full;
     //-----------------------------------------
     // Notepad
     //-----------------------------------------
     if ($this->request['save'] and $this->request['save'] == 1) {
         $_POST['notes'] = $_POST['notes'] ? $_POST['notes'] : $this->lang->words['cp_acpnotes'];
         $this->cache->setCache('adminnotes', IPSText::stripslashes($_POST['notes']), array('donow' => 1, 'array' => 0));
     }
     $text = $this->lang->words['cp_acpnotes'];
     if (!$this->cache->getCache('adminnotes')) {
         $this->cache->setCache('adminnotes', $text, array('donow' => 1, 'array' => 0));
     }
     $this->cache->updateCacheWithoutSaving('adminnotes', htmlspecialchars($this->cache->getCache('adminnotes'), ENT_QUOTES));
     $this->cache->updateCacheWithoutSaving('adminnotes', str_replace("&amp;#", "&#", $this->cache->getCache('adminnotes')));
     $content['ad_notes'] = $this->html->acp_notes($this->cache->getCache('adminnotes'));
     //-----------------------------------------
     // ADMINS USING CP
     //-----------------------------------------
     $t_time = time() - 60 * 10;
     $time_now = time();
     $seen_name = array();
     $acponline = "";
     $this->DB->build(array('select' => 's.session_member_name, s.session_member_id, s.session_location, s.session_log_in_time, s.session_running_time, s.session_ip_address, s.session_url', 'from' => array('core_sys_cp_sessions' => 's'), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => "m.member_id=s.session_member_id", 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $q = $this->DB->execute();
     while ($r = $this->DB->fetch($q)) {
         if (isset($seen_name[$r['session_member_name']]) and $seen_name[$r['session_member_name']] == 1) {
             continue;
         } else {
             $seen_name[$r['session_member_name']] = 1;
         }
         $r['_log_in'] = $time_now - $r['session_log_in_time'];
         $r['_click'] = $time_now - $r['session_running_time'];
         if ($r['_log_in'] / 60 < 1) {
             $r['_log_in'] = sprintf("%0d", $r['_log_in']) . ' ' . $this->lang->words['cp_secondsago'];
         } else {
             $r['_log_in'] = sprintf("%0d", $r['_log_in'] / 60) . ' ' . $this->lang->words['cp_minutesago'];
         }
         if ($r['_click'] / 60 < 1) {
             $r['_click'] = sprintf("%0d", $r['_click']) . ' ' . $this->lang->words['cp_secondsago'];
         } else {
             $r['_click'] = sprintf("%0d", $r['_click'] / 60) . ' ' . $this->lang->words['cp_minutesago'];
         }
         $r['session_location'] = $r['session_location'] ? $r['session_location'] : $this->lang->words['cp_index'];
         $r['seo_link'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?showuser='******'session_member_id'], 'none', $r['members_seo_name'], 'showuser');
         $admins_online[] = $r;
     }
     $content['acp_online'] = $this->html->acp_onlineadmin_wrapper($admins_online);
     //-----------------------------------------
     // Members awaiting admin validation?
     //-----------------------------------------
     if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'admin') {
         $where_extra = $this->settings['reg_auth_type'] == 'admin_user' ? ' AND user_verified=1' : '';
         $admin_reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => 'validating', 'where' => 'new_reg=1' . $where_extra));
         if ($admin_reg['reg'] > 0) {
             // We have some member's awaiting admin validation
             $data = null;
             $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => 'new_reg=1' . $where_extra, 'limit' => array(3), 'add_join' => array(array('type' => 'left', 'select' => 'm.members_display_name, m.email, m.ip_address', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id'))));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if ($r['coppa_user'] == 1) {
                     $r['_coppa'] = ' ( COPPA )';
                 } else {
                     $r['_coppa'] = "";
                 }
                 $r['_entry'] = $this->registry->getClass('class_localization')->getDate($r['entry_date'], 'TINY');
                 $data .= $this->html->acp_validating_block($r);
             }
             $content['validating'] = $this->html->acp_validating_wrapper($data);
         }
     }
     //-----------------------------------------
     // Info for the stats bar
     //-----------------------------------------
     $stats = array('performance' => false, 'active_users' => 0, 'server_load' => 0);
     $record = $this->cache->getCache('performanceCache');
     if (is_array($record) and count($record)) {
         $stats['performance'] = true;
     }
     list($load, $time) = explode('-', $this->caches['systemvars']['loadlimit']);
     $time = time() - $this->settings['au_cutoff'] * 60;
     $online = $this->DB->buildAndFetch(array('select' => 'count(*) as rows', 'from' => 'sessions', 'where' => "running_time > {$time}"));
     $stats['active_users'] = $online['rows'];
     $stats['server_load'] = $load;
     //-----------------------------------------
     // Piece it together
     //-----------------------------------------
     $this->registry->output->html .= $this->html->mainTemplate($content, $ipsNewsData, $this->getNotificationPanelEntries(), $stats);
     //-----------------------------------------
     // Left log all on?
     //-----------------------------------------
     if (IPS_LOG_ALL === TRUE) {
         $_html = $this->html->warning_box($this->lang->words['ds_log_all_title'], $this->lang->words['ds_log_all_desc']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     //-----------------------------------------
     // IN DEV stuff...
     //-----------------------------------------
     if (IN_DEV) {
         $lastUpdate = $this->caches['indev'];
         $lastUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('settings' => array()));
         $lastModUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('modules' => array()));
         $lastTaskUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('tasks' => array()));
         $lastHelpUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('help' => array()));
         $lastbbUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('bbcode' => array()));
         $content = array();
         $modContent = array();
         $tasksContent = array();
         $helpContent = array();
         $bbContent = array();
         $_html = '';
         foreach (ipsRegistry::$applications as $app_dir => $data) {
             /* Settings */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml'));
             $lastDBtime = intval($lastUpdate['import']['settings'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $content[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_settingsupdated']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Modules */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_modules.xml'));
             $lastDBtime = intval($lastUpdate['import']['modules'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $modContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_modulessneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Tasks */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_tasks.xml'));
             $lastDBtime = intval($lastUpdate['import']['tasks'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $tasksContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_taskssneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Help Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_help.xml'));
             $lastDBtime = intval($lastUpdate['import']['help'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $helpContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_helpneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* BBCode Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_bbcode.xml'));
             $lastDBtime = intval($lastUpdate['import']['bbcode'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $bbContent[] = "<strong>" . $data['app_title'] . " {$this->lang->words['cp_bbcodeneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
         }
         if (count($content)) {
             $_html = $this->html->warning_box($this->lang->words['cp_settingsneedup'], implode($content, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=settings&amp;section=settings&amp;do=settingsImportApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($modContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_modulessneedup'], implode($modContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=inDevRebuildAll'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($tasksContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($helpContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_helpneedup'], implode($helpContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=help&amp;do=importXml'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($bbContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_bbcodeneedup'], implode($bbContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=posts&amp;section=bbcode&amp;do=bbcode_import_all'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html, $this->registry->output->html);
         /* Got notes!? */
         if (is_file(DOC_IPS_ROOT_PATH . '_dev_notes.txt')) {
             /* file retains tabs, file_get_contents not! */
             $_notes = file(DOC_IPS_ROOT_PATH . '_dev_notes.txt');
             if ($_notes) {
                 /* sanitize data and convert tabs! */
                 //$_notes = array_map( 'htmlentities', $_notes );
                 $_notes = implode('', $_notes);
                 $_notes = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $_notes);
                 $_html = $this->registry->output->global_template->warning_box($this->lang->words['cp_devnotes'], nl2br($_notes)) . "<br />";
                 $this->registry->output->html = str_replace('<!--in_dev_notes-->', $_html, $this->registry->output->html);
             }
         }
     }
     //-----------------------------------------
     // Last 5 log in attempts
     //-----------------------------------------
     $this->registry->getClass('class_permissions')->return = true;
     if ($this->registry->getClass('class_permissions')->checkPermission('acplogin_log', 'core', 'logs')) {
         $this->DB->build(array('select' => '*', 'from' => 'admin_login_logs', 'where' => 'admin_success = 0 AND admin_time > 0', 'order' => 'admin_time DESC', 'limit' => array(0, 4)));
         $this->DB->execute();
         while ($rowb = $this->DB->fetch()) {
             $rowb['_admin_time'] = $this->registry->class_localization->getDate($rowb['admin_time'], 'long');
             $logins .= $this->html->acp_last_logins_row($rowb);
         }
         $this->registry->output->html = str_replace('<!--acplogins-->', $this->html->acp_last_logins_wrapper($logins), $this->registry->output->html);
     }
     //-----------------------------------------
     // Pass to CP output hander
     //-----------------------------------------
     $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
     $this->registry->getClass('output')->sendOutput();
 }
Beispiel #4
0
 /**
  * Validate an RSS Feed
  *
  * @param	bool	$standalone	If set to true, data will be queried from the db based on rss_id, otherwise data will be gathered from form fields
  * @return void
  */
 public function rssImportValidate($standalone = false)
 {
     /* INI */
     $return = 0;
     if (!$standalone) {
         /* Get data from the form */
         $rss_import_id = intval($this->request['rss_import_id']);
         $rss_import_title = trim($this->request['rss_import_title']);
         $rss_import_url = IPSText::stripslashes(trim($this->request['rss_import_url']));
         $rss_import_mid = trim($this->request['rss_import_mid']);
         $rss_import_showlink = IPSText::stripslashes(trim($this->request['rss_import_showlink']));
         $rss_import_enabled = intval($this->request['rss_import_enabled']);
         $rss_import_forum_id = intval($this->request['rss_import_forum_id']);
         $rss_import_pergo = intval($this->request['rss_import_pergo']);
         $rss_import_time = intval($this->request['rss_import_time']);
         $rss_import_topic_open = intval($this->request['rss_import_topic_open']);
         $rss_import_topic_hide = intval($this->request['rss_import_topic_hide']);
         $rss_import_topic_pre = $this->request['rss_import_topic_pre'];
         $rss_import_allow_html = intval($this->request['rss_import_allow_html']);
         $rss_import_auth = intval($this->request['rss_import_auth']);
         $rss_import_auth_user = trim($this->request['rss_import_auth_user']) ? trim($this->request['rss_import_auth_user']) : '';
         $rss_import_auth_pass = trim($this->request['rss_import_auth_pass']) ? trim($this->request['rss_import_auth_pass']) : '';
         $return = 1;
     } else {
         /* Get the RSS ID */
         $rss_input_id = $this->request['rss_id'] ? intval($this->request['rss_id']) : 0;
         /* Found an id */
         if ($rss_input_id > 0) {
             /* Query the data from the db */
             $rss_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rss_import', 'where' => 'rss_import_id=' . $rss_input_id));
             /* Format Data */
             if (!$rss_data['rss_import_url']) {
                 $rss_import_url = "";
                 $rss_import_auth = "";
                 $rss_import_auth_user = "";
                 $rss_import_auth_pass = "";
             } else {
                 $standalone = 0;
                 $rss_import_id = intval($rss_data['rss_import_id']);
                 $rss_import_url = $rss_data['rss_import_url'];
                 $member = $this->DB->buildAndFetch(array('select' => 'members_display_name', 'from' => 'members', 'where' => 'member_id=' . $rss_data['rss_import_mid']));
                 $rss_import_mid = $member['members_display_name'];
                 $rss_import_forum_id = intval($rss_data['rss_import_forum_id']);
                 $rss_import_auth = intval($rss_data['rss_import_auth']);
                 $rss_import_auth_user = trim($rss_data['rss_import_auth_user']);
                 $rss_import_auth_pass = trim($rss_data['rss_import_auth_pass']);
             }
         } else {
             $rss_import_url = IPSText::stripslashes(trim($this->request['rss_url']));
             $rss_import_auth = "";
             $rss_import_auth_user = "";
             $rss_import_auth_pass = "";
         }
     }
     /* Check for URL */
     if (!$rss_import_url) {
         $this->validate_errors[] = $this->lang->words['im_nourl'];
     } else {
         /* INIT */
         if (!$this->classes_loaded) {
             /* Load RSS Class */
             if (!is_object($this->class_rss)) {
                 $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classRss.php', 'classRss');
                 $this->class_rss = new $classToLoad();
                 $this->class_rss->rss_max_show = 100;
             }
             $this->classes_loaded = 1;
         }
         /* Set this imports doc type */
         $this->class_rss->doc_type = strtoupper(IPS_DOC_CHAR_SET);
         /* Set this import's authentication */
         $this->class_rss->auth_req = $rss_import_auth;
         $this->class_rss->auth_user = $rss_import_auth_user;
         $this->class_rss->auth_pass = $rss_import_auth_pass;
         $this->class_rss->userAgent = $_SERVER['HTTP_USER_AGENT'];
         /* Clear RSS object's error cache first */
         $this->class_rss->errors = array();
         $this->class_rss->rss_items = array();
         /* Reset the rss count as this is a new feed */
         $this->class_rss->rss_count = 0;
         /* Parse RSS */
         $this->class_rss->parseFeedFromUrl($rss_import_url);
         /* Validate Data - HTTP Status Code/Text */
         if ($this->class_rss->classFileManagement->http_status_code != "200") {
             if ($this->class_rss->classFileManagement->http_status_code) {
                 $this->validate_errors[] = "{$this->lang->words['im_http']} {$this->class_rss->classFileManagement->http_status_code} ({$this->class_rss->classFileManagement->http_status_text})";
             }
         } else {
             $this->validate_msg[] = "{$this->lang->words['im_http']} {$this->class_rss->classFileManagement->http_status_code} ({$this->class_rss->classFileManagement->http_status_text})";
         }
         /* Display any errors found */
         if (is_array($this->class_rss->errors) and count($this->class_rss->errors)) {
             foreach ($this->class_rss->errors as $error) {
                 $this->validate_errors[] = $error;
             }
         } else {
             /* Channels */
             if (!is_array($this->class_rss->rss_channels) or !count($this->class_rss->rss_channels)) {
                 $this->validate_errors[] = $this->lang->words['im_nochannels'];
             } else {
                 $this->validate_msg[] = sprintf($this->lang->words['im_channelcount'], count($this->class_rss->rss_channels));
                 /* Any Items */
                 if (!is_array($this->class_rss->rss_items) or !count($this->class_rss->rss_items)) {
                     $this->validate_errors[] = $this->lang->words['im_nocontent'];
                 } else {
                     foreach ($this->class_rss->rss_channels as $channel_id => $channel_data) {
                         if (is_array($this->class_rss->rss_items[$channel_id]) and count($this->class_rss->rss_items[$channel_id])) {
                             $this->validate_msg[] = sprintf($this->lang->words['im_topiccount'], count($this->class_rss->rss_items[$channel_id]));
                             foreach ($this->class_rss->rss_items[$channel_id] as $item_data) {
                                 if (!$item_data['unixdate']) {
                                     $this->validate_errors[] = $this->lang->words['im_nodate'];
                                 }
                                 if ($item_data['unixdate'] < 1) {
                                     $this->validate_errors[] = $this->lang->words['im_invdate'];
                                 } else {
                                     if ($item_data['unixdate'] > IPS_UNIX_TIME_NOW) {
                                         $this->validate_errors[] = $this->lang->words['im_invdate'];
                                     }
                                 }
                                 $item_data['content'] = $item_data['content'] ? $item_data['content'] : $item_data['description'];
                                 if (!$item_data['title'] or !$item_data['content']) {
                                     $this->validate_errors[] = $this->lang->words['im_nodesc'];
                                 }
                                 break 2;
                             }
                         }
                     }
                 }
             }
         }
         if (!$standalone) {
             if ($rss_import_mid) {
                 $member = $this->DB->buildAndFetch(array('select' => 'member_id, name', 'from' => 'members', 'where' => "members_l_display_name='{$rss_import_mid}'"));
                 if (!$member['member_id']) {
                     $this->validate_errors[] = sprintf($this->lang->words['im_nomember'] . $rss_import_mid);
                 }
             } else {
                 $this->validate_errors[] = $this->lang->words['im_memval'];
             }
         }
         /* Init forums if not already done so */
         if (!is_array($this->registry->class_forums->forum_by_id) or !count($this->registry->class_forums->forum_by_id)) {
             $this->registry->class_forums->forums_init();
         }
         if (!$standalone and $rss_import_forum_id) {
             if (!$this->registry->class_forums->forum_by_id[$rss_import_forum_id]) {
                 $this->validate_errors[] = $this->lang->words['im_noforum'];
             } else {
                 if ($this->registry->class_forums->forum_by_id[$rss_import_forum_id]['sub_can_post'] != 1 or $this->registry->class_forums->forum_by_id[$rss_import_forum_id]['redirect_on'] == 1) {
                     $this->validate_errors[] = $this->lang->words['im_redforum'];
                 }
             }
         }
         /* Display */
         if (!$return) {
             if (count($this->validate_msg)) {
                 $this->registry->output->setMessage(sprintf($this->lang->words['im_valresults'], IPSText::stripslashes(trim($rss_import_url)), implode("<br />&nbsp;&middot;", $this->validate_msg)), 1);
             }
             if (count($this->validate_errors)) {
                 $this->registry->output->global_error = sprintf($this->lang->words['im_valerrors'], IPSText::stripslashes(trim($rss_import_url)), implode("<br />&nbsp;&middot;", $this->validate_errors));
             }
             $this->rssImportOverview();
             return;
         } else {
             return TRUE;
         }
     }
 }
Beispiel #5
0
 /**
  * Class entry point
  *
  * @param	object		Registry reference
  * @return	@e void		[Outputs to screen/redirects]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Get HTML and skin
     //-----------------------------------------
     $this->registry->class_localization->loadLanguageFile(array('public_list'), 'members');
     //-----------------------------------------
     // Can we access?
     //-----------------------------------------
     if (!$this->memberData['g_mem_info']) {
         $this->registry->output->showError('cannot_view_memberlist', 10221, null, null, 403);
     }
     //-----------------------------------------
     // Init variables
     //-----------------------------------------
     $see_groups = array();
     $the_filter = array('ALL' => $this->lang->words['show_all']);
     $the_members = array();
     $query = array("m.members_l_display_name !='' AND m.members_l_display_name " . $this->DB->buildIsNull(false));
     $url = array();
     $pp_rating_real = isset($this->request['pp_rating_real']) ? intval($this->request['pp_rating_real']) : 0;
     $this->first = isset($this->request['st']) ? intval($this->request['st']) : 0;
     $this->max_results = !empty($this->request['max_results']) ? $this->request['max_results'] : $this->max_results;
     $this->sort_key = !empty($this->request['sort_key']) ? $this->request['sort_key'] : 'members_display_name';
     $this->sort_order = !empty($this->request['sort_order']) ? $this->request['sort_order'] : 'asc';
     $this->filter = !empty($this->request['filter']) ? $this->request['filter'] == 'ALL' ? 'ALL' : intval($this->request['filter']) : 'ALL';
     $this->request['showall'] = isset($this->request['showall']) ? intval($this->request['showall']) : 0;
     $this->request['name_box'] = isset($this->request['name_box']) ? $this->request['name_box'] : '';
     $this->request['quickjump'] = isset($this->request['quickjump']) ? $this->request['quickjump'] : 0;
     $_queryPP = false;
     //-----------------------------------------
     // Set some of the URL params
     //-----------------------------------------
     if ($this->request['quickjump']) {
         $this->request['name_box'] = 'begins';
         $this->request['name'] = $this->request['quickjump'];
     }
     $url['app'] = "app=members&amp;module=list";
     $url['showall'] = 'showall=' . $this->request['showall'];
     $url['sort_key'] = "sort_key={$this->sort_key}";
     $url['sort_order'] = "sort_order={$this->sort_order}";
     $url['max_results'] = "max_results={$this->max_results}";
     $url['quickjump'] = "quickjump={$this->request['quickjump']}";
     $url['name_box'] = 'name_box=' . $this->request['name_box'];
     $url['name'] = isset($this->request['name']) ? "name={$this->request['name']}" : "name=";
     //-----------------------------------------
     // Sort the member group info
     //-----------------------------------------
     foreach ($this->caches['group_cache'] as $row) {
         if ($row['g_hide_from_list']) {
             if (!($this->memberData['g_access_cp'] and $this->request['showall'])) {
                 $hide_ids[] = $row['g_id'];
                 continue;
             }
         }
         $see_groups[] = $row['g_id'];
         $this->mem_groups[$row['g_id']] = array('TITLE' => $row['g_title'], 'ICON' => $row['g_icon']);
         if ($row['g_id'] == $this->settings['guest_group']) {
             continue;
         }
         $the_filter[$row['g_id']] = $row['g_title'];
     }
     //-----------------------------------------
     // Init some arrays
     //-----------------------------------------
     $the_sort_key = array('members_l_display_name' => 'sort_by_name', 'posts' => 'pcount', 'joined' => 'sort_by_joined', 'members_profile_views' => 'm_dd_views');
     $the_max_results = array(10 => '10', 20 => '20', 40 => '40', 60 => '60');
     $the_sort_order = array('desc' => 'descending_order', 'asc' => 'ascending_order');
     $dropdowns = array('filter' => $the_filter, 'sort_key' => $the_sort_key, 'sort_order' => $the_sort_order, 'max_results' => $the_max_results);
     $defaults = array('filter' => $this->filter, 'sort_key' => $this->sort_key, 'sort_order' => $this->sort_order, 'max_results' => $this->max_results, 'photoonly' => !empty($this->request['photoonly']) ? 1 : 0);
     //-----------------------------------------
     // Final vars for query
     //-----------------------------------------
     $this->sort_key = isset($the_sort_key[$this->sort_key]) ? $this->sort_key : 'members_l_display_name';
     $this->sort_order = isset($the_sort_order[$this->sort_order]) ? $this->sort_order : 'asc';
     $this->filter = isset($the_filter[$this->filter]) ? $this->filter : 'ALL';
     $this->max_results = isset($the_max_results[$this->max_results]) ? $this->max_results : 20;
     //-----------------------------------------
     // Get custom profile information
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $this->custom_fields = new $classToLoad();
     $this->custom_fields->initData('edit', 1);
     $this->custom_fields->parseToEdit('mlist');
     //-----------------------------------------
     // Member Groups...
     //-----------------------------------------
     if ($this->filter != 'ALL') {
         if (!in_array($this->filter, $see_groups)) {
             $query[] = 'm.member_group_id IN(' . implode(',', $see_groups) . ')';
         } else {
             $query[] = 'm.member_group_id=' . $this->filter;
         }
         $url['filter'] = 'filter=' . $this->filter;
     }
     //-----------------------------------------
     // NOT IN Member Groups...
     //-----------------------------------------
     if (count($hide_ids)) {
         $query[] = "m.member_group_id NOT IN(" . implode(",", $hide_ids) . ")";
     }
     /* Not banned */
     $query[] = "m.member_banned=0";
     /* Not a spammer */
     $query[] = '( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')';
     //-----------------------------------------
     // Build query
     //-----------------------------------------
     $dates = array('lastpost', 'lastvisit', 'joined');
     $mapit = array('posts' => 'm.posts', 'joined' => 'm.joined', 'lastpost' => 'm.last_post', 'lastvisit' => 'm.last_visit', 'signature' => 'pp.signature', 'name' => 'm.members_display_name', 'photoonly' => 'pp.pp_main_photo');
     //-----------------------------------------
     // Do search
     //-----------------------------------------
     foreach ($mapit as $in => $tbl) {
         /**
          * Leave isset && != '', can't use empty or 0 values are skipped as well
          * @link	http://community.invisionpower.com/tracker/issue-37350-sorting-members-by-post-count/
          */
         $this->request[$in] = isset($this->request[$in]) && $this->request[$in] != '' ? $this->request[$in] : '';
         $inbit = $this->request[$in] = IPSText::parseCleanValue(trim(urldecode(IPSText::stripslashes($this->request[$in]))));
         $url[$in] = $in . '=' . urlencode($this->request[$in]);
         //-----------------------------------------
         // Name...
         //-----------------------------------------
         if ($in == 'name' and $inbit != "") {
             if ($this->request['name_box'] == 'begins') {
                 $query[] = "m.members_l_display_name LIKE '" . strtolower($inbit) . "%'";
             } else {
                 $query[] = "m.members_l_display_name LIKE '%" . strtolower($inbit) . "%'";
             }
         } else {
             if ($in == 'posts' and is_numeric($inbit) and intval($inbit) > -1) {
                 $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>';
                 $query[] = $tbl . ' ' . $ltmt . ' ' . intval($inbit);
                 $url[$in] = $in . '_ltmt=' . $this->request[$in . '_ltmt'] . '&posts=' . intval($inbit);
             } else {
                 if (in_array($in, $dates) and $inbit) {
                     if (preg_match('/\\d{2}-\\d{2}-\\d{4}/', $this->request[$in])) {
                         $_tmp = explode('-', $this->request[$in]);
                         $time_int = mktime(23, 59, 59, $_tmp[0], $_tmp[1], $_tmp[2]);
                     } else {
                         $time_int = strtotime($inbit);
                     }
                     if ($time_int) {
                         $ltmt = $this->request[$in . '_ltmt'] == 'lt' ? '<' : '>';
                         $query[] = $tbl . ' ' . $ltmt . ' ' . $time_int;
                         $url[$in . '_ltmt'] = $in . '_ltmt=' . $this->request[$in . '_ltmt'];
                     }
                 } else {
                     if ($in == 'photoonly') {
                         if ($this->request['photoonly'] == 1) {
                             $_queryPP = true;
                             $query[] = $tbl . "<> ''";
                             $url[] = 'photoonly=1';
                         }
                     } else {
                         if ($inbit != "" and $in != 'posts') {
                             $_queryPP = true;
                             $query[] = $tbl . " LIKE '%{$inbit}%'";
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Custom fields?
     //-----------------------------------------
     if (count($this->custom_fields->out_fields)) {
         foreach ($this->custom_fields->out_fields as $id => $data) {
             if (!empty($this->request['field_' . $id])) {
                 $_queryPP = true;
                 if (is_array($this->request['field_' . $id])) {
                     foreach ($this->request['field_' . $id] as $k => $v) {
                         $this->request['field_' . $id][$k] = urldecode($v);
                         $url['field_' . $id] = "field_{$id}[{$k}]=" . $v;
                     }
                 } else {
                     $url['field_' . $id] = "field_{$id}=" . $this->request['field_' . $id];
                     $this->request['field_' . $id] = urldecode($this->request['field_' . $id]);
                 }
                 if ($this->custom_fields->cache_data[$id]['pf_type'] == 'drop') {
                     $query[] = "p.field_{$id}='" . $this->request['field_' . $id] . "'";
                 } else {
                     if ($this->custom_fields->cache_data[$id]['pf_type'] == 'cbox') {
                         if (count($this->request['field_' . $id])) {
                             foreach ($this->request['field_' . $id] as $k => $v) {
                                 $query[] = "p.field_{$id} LIKE '%|{$k}|%'";
                             }
                         }
                     } else {
                         $query[] = $this->custom_fields->cache_data[$id]['pf_search_type'] == 'loose' ? "p.field_{$id} LIKE '%" . $this->request['field_' . $id] . "%'" : "p.field_{$id} = '" . $this->request['field_' . $id] . "'";
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Rating..
     //-----------------------------------------
     if ($pp_rating_real) {
         $_queryPP = true;
         $query[] = "pp.pp_rating_real > " . $pp_rating_real;
         $url['pp_rating_real'] = "pp_rating_real=" . $pp_rating_real;
     }
     //-----------------------------------------
     // Finish query
     //-----------------------------------------
     //$query[] = "m.members_l_display_name != ''";
     $joins = array();
     if ($_queryPP) {
         $joins[] = array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left');
         $joins[] = array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left');
     }
     //-----------------------------------------
     // Reputation
     //-----------------------------------------
     if (!ipsRegistry::isClassLoaded('repCache')) {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
         ipsRegistry::setClass('repCache', new $classToLoad());
     }
     //-----------------------------------------
     // START THE LISTING
     //-----------------------------------------
     $notInMembers = 0;
     foreach ($query as $q) {
         if (!strstr($q, 'm.')) {
             $notInMembers++;
         }
     }
     /* Get the count */
     if ($notInMembers > 0 or $this->sort_key != 'members_l_display_name' or $this->request['request_method'] == 'post') {
         $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'add_join' => $joins));
         $this->DB->build(array('select' => ' m.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results), 'add_join' => $joins));
     } else {
         $_max = $this->DB->buildAndFetch(array('select' => 'COUNT( * ) as cnt', 'from' => 'members m', 'where' => implode(" AND ", $query)));
         $this->DB->build(array('select' => 'm.member_id', 'from' => array('members' => 'm'), 'where' => implode(" AND ", $query), 'order' => 'm.' . $this->sort_key . ' ' . $this->sort_order, 'limit' => array($this->first, $this->max_results)));
     }
     /* Fetch IDs */
     $mids = array();
     $this->DB->execute();
     while ($m = $this->DB->fetch()) {
         if ($m['member_id']) {
             $mids[] = $m['member_id'];
         }
     }
     if (count($mids)) {
         $members = array();
         $_members = IPSMember::load($mids, 'all');
         /* Make sure that we keep the ordering from the query */
         foreach ($mids as $id) {
             $members[$id] = $_members[$id];
         }
     }
     $max = $_max['cnt'];
     if (is_array($members) and count($members)) {
         foreach ($members as $id => $member) {
             /* Damn SQL thing with member_id */
             if (!$member['member_id']) {
                 $member['member_id'] = $member['member_table_id'];
             }
             $member['members_display_name'] = $member['members_display_name'] ? $member['members_display_name'] : $member['name'];
             $member['members_seo_name'] = IPSMember::fetchSeoName($member);
             $member['group'] = $this->mem_groups[$member['member_group_id']]['TITLE'];
             $member = IPSMember::buildProfilePhoto($member);
             $member['pp_reputation_points'] = $member['pp_reputation_points'] ? $member['pp_reputation_points'] : 0;
             $member['author_reputation'] = ipsRegistry::getClass('repCache')->getReputation($member['pp_reputation_points']);
             /* Reputation */
             if ($this->settings['reputation_protected_groups']) {
                 if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) {
                     $member['pp_reputation_points'] = null;
                     $member['author_reputation'] = null;
                 }
             }
             $the_members[] = $member;
         }
     }
     /* make sure URL doesn't contain empty params */
     $_url = $url;
     $url = array();
     foreach ($_url as $key => $bit) {
         if (strrpos($bit, '=') + 1 == strlen($bit)) {
             continue;
         }
         $url[] = $bit;
     }
     $pages = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $this->max_results, 'currentStartValue' => $this->first, 'seoTitle' => "false", 'seoTemplate' => 'members_list', 'baseUrl' => implode('&amp;', $url)));
     //-----------------------------------------
     // Print...
     //-----------------------------------------
     $this->output .= $this->registry->getClass('output')->getTemplate('mlist')->member_list_show($the_members, $pages, $dropdowns, $defaults, $this->custom_fields, implode('&amp;', $url));
     //-----------------------------------------
     // Push to print handler
     //-----------------------------------------
     $this->registry->output->addContent($this->output);
     $this->registry->output->setTitle($this->lang->words['page_title'] . ' - ' . ipsRegistry::$settings['board_name']);
     $this->registry->output->addNavigation($this->lang->words['page_title'], 'app=members', "false", 'members_list');
     $this->registry->output->sendOutput();
 }
    /**
     * Bulk mail form
     *
     * @param	string		Type (add|edit)
     * @param	array 		Mail data
     * @param	string		Mail content
     * @param	array		Filter classes
     * @param	array		Error messages
     * @return	string		HTML
     */
    public function mailForm($type, $mail, $mail_content, $filters, $errors)
    {
        $dd_ltmt = array(0 => array('lt', $this->lang->words['b_lessthan']), 1 => array('mt', $this->lang->words['b_morethan']));
        if ($type == 'add') {
            $title = $this->lang->words['b_create'];
            $button = $this->lang->words['b_proceed'];
            $html_checked = 0;
        } else {
            $title = $this->lang->words['b_editstored'];
            $button = $this->lang->words['b_edit'];
            //-----------------------------------------
            // Unpack more..
            //-----------------------------------------
            $tmp = unserialize(stripslashes($mail['mail_opts']));
            if (is_array($tmp) and count($tmp)) {
                foreach ($tmp as $k => $v) {
                    if (!$mail[$k]) {
                        $mail[$k] = $v;
                    }
                }
            }
            $html_checked = $mail['mail_html_on'];
        }
        $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
        $editor = new $classToLoad();
        $editor->setContent($mail_content);
        $form = array();
        $form['groups'] = '';
        $form['mail_subject'] = $this->registry->output->formInput('mail_subject', htmlspecialchars(IPSText::stripslashes($_POST['mail_subject'] ? $_POST['mail_subject'] : $mail['mail_subject']), ENT_QUOTES));
        $form['mail_content'] = $editor->show('mail_content');
        $form['mail_content_plain'] = $this->registry->output->formTextarea('mail_content_plain', $mail_content, 60, 14, '', 'mail_content_plain', "' style='width: 100%'");
        // Hacky CSS thing, but eh
        $form['mail_post_ltmt'] = $this->registry->output->formDropdown('mail_post_ltmt', $dd_ltmt, $_POST['mail_post_ltml'] ? $_POST['mail_post_ltml'] : $mail['mail_post_ltmt']);
        $form['mail_filter_post'] = $this->registry->output->formSimpleInput("mail_filter_post", $_POST['mail_filter_post'] ? $_POST['mail_filter_post'] : $mail['mail_filter_post'], 7);
        $form['mail_visit_ltmt'] = $this->registry->output->formDropdown('mail_visit_ltmt', $dd_ltmt, $_POST['mail_visit_ltml'] ? $_POST['mail_visit_ltml'] : $mail['mail_visit_ltmt']);
        $form['mail_filter_visit'] = $this->registry->output->formSimpleInput("mail_filter_visit", $_POST['mail_filter_visit'] ? $_POST['mail_filter_visit'] : $mail['mail_filter_visit'], 7);
        $form['mail_joined_ltmt'] = $this->registry->output->formDropdown('mail_joined_ltmt', $dd_ltmt, $_POST['mail_joined_ltml'] ? $_POST['mail_joined_ltml'] : $mail['mail_joined_ltmt']);
        $form['mail_filter_joined'] = $this->registry->output->formSimpleInput("mail_filter_joined", $_POST['mail_filter_joined'] ? $_POST['mail_filter_joined'] : $mail['mail_filter_joined'], 7);
        $form['tags'] = $this->registry->output->formInput('mandrill_tags', $_POST['mandrill_tags'] ? $_POST['mandrill_tags'] : is_array($mail['mandrill_tags']) ? implode(',', $mail['mandrill_tags']) : '');
        foreach ($this->cache->getCache('group_cache') as $g) {
            if ($g['g_id'] == $this->settings['guest_group']) {
                continue;
            }
            $checked = 0;
            if ($mail['mail_groups']) {
                if (strstr(',' . $mail['mail_groups'] . ',', ',' . $g['g_id'] . ',')) {
                    $checked = 1;
                }
            }
            $form['groups'] .= $this->registry->output->formCheckbox('sg_' . $g['g_id'], $checked) . "&nbsp;&nbsp;<b>{$g['g_title']}</b><br />";
        }
        $standardStyle = '';
        $plainStyle = 'display:none';
        $htmlOn = 0;
        if ($mail['mail_html_on'] or $this->request['mail_html_on'] or !$this->settings['email_use_html']) {
            $standardStyle = 'display:none';
            $plainStyle = '';
            $htmlOn = 1;
        }
        $IPBHTML = "";
        //--starthtml--//
        $IPBHTML .= <<<HTML
<div class='section_title'>
\t<h2>{$title}</h2>
</div>

HTML;
        if (!empty($errors)) {
            $errors = implode('<br />', $errors);
            $IPBHTML .= <<<HTML
\t<div class='warning'>
\t\t{$errors}
\t</div>
\t<br />
HTML;
        }
        $IPBHTML .= <<<HTML
<form name='theAdminForm' id='adminform' action='{$this->settings['base_url']}{$this->form_code}&amp;do=mail_save' method='post'>
\t<input type='hidden' name='id' value='{$mail['mail_id']}' />
\t<input type='hidden' name='type' value='{$type}' />
\t<input type='hidden' name='_admin_auth_key' value='{$this->registry->getClass('adminFunctions')->_admin_auth_key}' />
\t<input type='hidden' name='mail_html_on' id='mail_html_on' value='{$htmlOn}' />
\t
\t<div class='acp-box'>
\t\t<h3>{$title}</h3>
\t\t
\t\t<table class='ipsTable double_pad' cellspacing='0' cellpadding='0'>
\t\t \t<tr>
\t\t \t\t<th colspan='2'>{$this->lang->words['b_step1_title']}</th>
\t\t \t</tr>
\t\t\t<tr>
\t\t \t\t<td class='field_title'>
\t\t\t\t\t<strong class='title'>{$this->lang->words['b_subject']}</strong>
\t\t\t\t</td>
\t\t \t\t<td class='field_field'>
\t\t \t\t\t{$form['mail_subject']}
\t\t \t\t</td>
\t\t \t</tr>
\t\t\t<tr>
\t\t \t\t<td class='field_title'>
\t\t\t\t\t<strong class='title'>{$this->lang->words['b_content']}</strong>
\t\t\t\t</td>
\t\t\t\t<td class='field_field'>
\t\t\t\t\t<div id='editor_standard' style='{$standardStyle}'>
\t\t\t\t\t\t{$form['mail_content']}<br />
\t\t\t\t\t\t<p style='margin-top: 5px' class='desctext'>
\t\t\t\t\t\t\t<span class='clickable mini_button' onclick='variablesPopup()'>{$this->lang->words['b_var_link']}</span> <span class='clickable mini_button' onclick="editorModeToggle('plain')">{$this->lang->words['b_html']}</span>
\t\t\t\t\t\t</p>
\t\t\t\t\t</div>
\t\t\t\t\t<div id='editor_plain' style='{$plainStyle}'>
\t\t\t\t\t\t{$form['mail_content_plain']}<br />
\t\t\t\t\t\t<p style='margin-top: 5px' class='desctext'>
\t\t\t\t\t\t\t<span class='clickable mini_button' onclick='variablesPopup()'>{$this->lang->words['b_var_link']}</span> 
HTML;
        if ($this->settings['email_use_html']) {
            $IPBHTML .= <<<HTML
\t\t\t\t\t\t\t\t<span class='clickable mini_button' onclick="editorModeToggle('standard')">{$this->lang->words['b_standard']}</span>
HTML;
        }
        $IPBHTML .= <<<HTML
\t\t\t\t\t\t</p>
\t\t\t\t\t</div>
\t\t\t\t</td>
\t\t \t</tr>
HTML;
        if ($this->settings['mandrill_api_key']) {
            $IPBHTML .= <<<HTML
\t\t\t<tr>
\t\t\t\t<td class='field_title'>
\t\t\t\t\t<strong class='title'>{$this->lang->words['mandrill_tags']}</strong>
\t\t\t\t</td>
\t\t \t\t<td class='field_field'>
\t\t \t\t\t{$form['tags']}<br />
\t\t \t\t\t<span class='desctext'>{$this->lang->words['mandrill_tags_desc']}</span>
\t\t \t\t</td>
\t\t \t</tr>
HTML;
        }
        $IPBHTML .= <<<HTML
\t\t \t<tr>
\t\t \t\t<th colspan='2'>{$this->lang->words['b_step2']}</th>
\t\t \t</tr>
\t\t</table>
\t\t<div class='information-box'>{$this->lang->words['bulkmail_notes_override']}</div>
\t\t<div class='ipsTabBar with_left with_right' id='tabstrip_mytabs'>
\t\t\t<span class='tab_left'>&laquo;</span>
\t\t\t<span class='tab_right'>&laquo;</span>
\t\t\t<ul>
HTML;
        foreach ($filters as $id => $data) {
            $appName = ipsRegistry::$applications[$app]['app_title'];
            $IPBHTML .= <<<HTML
\t\t\t\t<li id='tab_{$id}'>{$data['appName']}</li>
HTML;
        }
        $IPBHTML .= <<<HTML
\t\t\t</ul>
\t\t</div>
\t\t<div class='ipsTabBar_content' id='tabstrip_mytabs_content'>
HTML;
        foreach ($filters as $id => $data) {
            $IPBHTML .= <<<HTML
\t\t\t<div id='tab_{$id}_content'>
\t\t\t\t<table class='ipsTable double_pad'>
HTML;
            foreach ($data['filters'] as $f) {
                $IPBHTML .= <<<HTML
\t\t\t\t\t<tr>
\t\t\t\t\t\t<td class='field_title'><strong class='title'>{$f['title']}</strong></td>
\t\t\t\t\t\t<td class='field_field'>
\t\t\t\t\t\t\t{$f['field']}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
HTML;
            }
            $IPBHTML .= <<<HTML
\t\t\t\t</table>
\t\t\t</div>
HTML;
        }
        $IPBHTML .= <<<HTML
\t\t</div>
\t\t<div class='acp-actionbar'>
\t\t\t<input class='realbutton' type='submit' value='{$button}' />
\t\t</div>
\t</div>
</form>

<div id='quicktags-popup' style='display:none'>
\t<div class='acp-box'>
\t\t<h3>{$this->lang->words['b_qtag']}</h3>
\t\t<table class='ipsTable double_pad'>
\t\t\t<tr>
\t\t\t\t<td colspan='4'>{$this->lang->words['b_qtag_info']}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><strong>{member_id}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qid']}</td>
\t\t\t\t<td><strong>{member_name}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qmname']}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><strong>{member_joined}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qjoin']}</td>
\t\t\t\t<td><strong>{member_last_visit}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_lastactive']}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><strong>{member_posts}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qposts']}</td>
\t\t\t\t<td><strong>{reg_total}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qmtotal']}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><strong>{board_name}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qbname']}</td>
\t\t\t\t<td><strong>{board_url}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qboardurl']}</td>
\t\t\t</tr>

\t\t\t<tr>
\t\t\t\t<td><strong>{busy_count}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qonline']}</td>
\t\t\t\t<td><strong>{busy_time}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qonlinetime']}</td>
\t\t\t</tr>
\t\t\t<tr>
\t\t\t\t<td><strong>{total_posts}</strong></td>
\t\t\t\t<td>{$this->lang->words['b_qptotal']}</td>
\t\t\t</tr>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\t\t </table>
\t</div>
</div>

<script type='text/javascript'>
\tfunction variablesPopup()
\t{
\t\tnew ipb.Popup( 'variablespopup', { type: 'pane', stem: true, hideAtStart: false, w: '900px', h: '800px', initial: \$('quicktags-popup').innerHTML, modal: false } );
\t}
\t
\tfunction editorModeToggle( mode )
\t{
\t\tif ( mode == 'standard' )
\t\t{
\t\t\t\$('editor_standard').style.display = '';
\t\t\t\$('editor_plain').style.display = 'none';
\t\t\t
\t\t\tipb.textEditor.getEditor().insert( \$('mail_content_plain').value, false, true );
\t\t\t\$('mail_html_on').value = 0;
\t\t}
\t\telse
\t\t{
\t\t\t\$('editor_standard').style.display = 'none';
\t\t\t\$('editor_plain').style.display = '';
\t\t\t
\t\t\t\$('mail_content_plain').value = ipb.textEditor.getEditor().getText();
\t\t\t\$('mail_html_on').value = 1;
\t\t}
\t}
\t
     jQ("#tabstrip_mytabs").ipsTabBar({ tabWrap: "#tabstrip_mytabs_content" });
\t
</script>
HTML;
        //--endhtml--//
        return $IPBHTML;
    }
Beispiel #7
0
 /**
  * Save the form
  *
  * @param	string		Type of form
  * @return	string		HTML
  */
 protected function _remapSave($type = 'add')
 {
     //--------------------------------------------
     // INIT
     //--------------------------------------------
     $setID = intval($this->request['setID']);
     $map_id = intval($this->request['map_id']);
     $map_title = trim(IPSText::stripslashes(IPSText::htmlspecialchars($_POST['map_title'])));
     $map_url = trim(IPSText::stripslashes(IPSText::UNhtmlspecialchars($_POST['map_url'])));
     $map_match_type = trim($this->request['map_match_type']);
     //--------------------------------------------
     // Checks...
     //--------------------------------------------
     if ($type == 'edit') {
         if (!$map_id or !$map_title or !$map_url) {
             $this->registry->getClass('output')->global_message = $this->lang->words['um_entireform'];
             $this->_remapForm($type);
             return;
         }
     } else {
         if (!$map_title or !$map_url) {
             $this->registry->getClass('output')->global_message = $this->lang->words['um_entireform'];
             $this->_remapForm($type);
             return;
         }
     }
     //--------------------------------------------
     // Save...
     //--------------------------------------------
     $array = array('map_title' => $map_title, 'map_url' => $map_url, 'map_match_type' => $map_match_type, 'map_skin_set_id' => $setID);
     if ($type == 'add') {
         $array['map_date_added'] = time();
         $this->DB->insert('skin_url_mapping', $array);
         $this->registry->getClass('output')->global_message = $this->lang->words['um_added'];
     } else {
         $this->DB->update('skin_url_mapping', $array, 'map_id=' . $map_id);
         $this->registry->getClass('output')->global_message = $this->lang->words['um_edited'];
     }
     //-----------------------------------------
     // Rebuild skin cache...
     //-----------------------------------------
     $this->skinFunctions->rebuildURLMapCache();
     //-----------------------------------------
     // Done...
     //-----------------------------------------
     return $this->_showURLMappingList();
 }
 /**
  * Process the content before passing off to the bbcode library
  *
  * @access	public
  * @param	string		Form field name OR Raw text
  * @return	string		Text ready for editor
  */
 public function processAfterForm($form_field)
 {
     $t = isset($_POST[$form_field]) ? IPSText::stripslashes($_POST[$form_field]) : $form_field;
     $ot = $t;
     //-----------------------------------------
     // Fix up spaces
     //-----------------------------------------
     $t = str_replace('&nbsp;', ' ', $t);
     //-----------------------------------------
     // Gecko engine seems to put \r\n at edge
     // of iframe when wrapping? If so, add a
     // space or it'll get weird later
     //-----------------------------------------
     //		print $t;
     //		print "<br><br><br>---------------------<br><br><br>";
     //print nl2br(htmlspecialchars($t));
     //print "<br><br><br>---------------------<br><br><br>";
     if ($this->memberData['userAgentKey'] == 'firefox' or $this->memberData['userAgentKey'] == 'gecko') {
         $t = str_ireplace("<br>\r\n", "<br>", $t);
         $t = str_ireplace("<br>\n", "<br>", $t);
         $t = str_ireplace("<br>\r", "<br>", $t);
         $t = str_ireplace("<br />\r\n", "<br />", $t);
         $t = str_ireplace("<br />\n", "<br />", $t);
         $t = str_ireplace("<br />\r", "<br />", $t);
         $t = preg_replace("/((?:\r)?\n?(?:\\s)+)/", " ", $t);
     } else {
         $t = str_replace("\r\n", "", $t);
     }
     //print nl2br(htmlspecialchars($t));exit;
     //-----------------------------------------
     // RTE sends newlines as line break tags
     //-----------------------------------------
     $t = str_replace("\n", "", $t);
     //-----------------------------------------
     // Clean up already encoded HTML
     //-----------------------------------------
     $t = str_replace('&quot;', '"', $t);
     $t = str_replace('&apos;', "'", $t);
     //-----------------------------------------
     // Fix up incorrectly nested urls / BBcode
     //-----------------------------------------
     $t = preg_replace('#<a\\s+?href=[\'"]([^>]+?)\\[(.+?)[\'"](.+?)' . '>(.+?)\\[\\2</a>#is', '<a href="\\1"\\3>\\4</a>[\\2', $t);
     //-----------------------------------------
     // Make URLs safe (prevent tag stripping)
     //-----------------------------------------
     $t = preg_replace_callback('#<(a href|img src)=([\'"])([^>]+?)(\\2)#is', array($this, '_unhtmlUrl'), $t);
     //-----------------------------------------
     // WYSI-Weirdness #1: BR tags to \n
     //-----------------------------------------
     $t = str_ireplace(array("<br>", "<br />"), "\n", $t);
     $t = trim($t);
     //-----------------------------------------
     // Before we can use strip_tags, we should
     // clean out any javascript and CSS
     //-----------------------------------------
     $t = preg_replace("/\\<script(.*?)\\>(.*?)\\<\\/script\\>/", '', $t);
     $t = preg_replace("/\\<style(.*?)\\>(.*?)\\<\\/style\\>/", '', $t);
     //-----------------------------------------
     // Remove tags we're not bothering with
     // with PHPs wonderful strip tags func
     //-----------------------------------------
     if (!$this->allow_html) {
         $t = strip_tags($t, '<h1><h2><h3><h4><h5><h6><font><span><div><br><p><img><a><li><ol><ul><b><strong><em><i><u><s><strike><blockquote><sub><sup>');
     }
     //-----------------------------------------
     // WYSI-Weirdness #2: named anchors
     //-----------------------------------------
     $t = preg_replace("#<a\\s+?name=.+?" . ">(.+?)</a>#is", "\\1", $t);
     //-----------------------------------------
     // WYSI-Weirdness #2.1: Empty a hrefs
     //-----------------------------------------
     $t = preg_replace("#<a\\s+?href([^>]+)></a>#is", "", $t);
     $t = preg_replace("#<a\\s+?href=(['\"])>\\1(.+?)</a>#is", "\\1", $t);
     //-----------------------------------------
     // WYSI-Weirdness #2.2: Double linked links
     //-----------------------------------------
     $t = preg_replace("#href=[\"']\\w+://(%27|'|\"|&quot;)(.+?)\\1[\"']#is", "href=\"\\2\"", $t);
     //-----------------------------------------
     // WYSI-Weirdness #3: Headline tags
     //-----------------------------------------
     $t = preg_replace("#<(h[0-9])>(.+?)</\\1>#is", "\n[b]\\2[/b]\n", $t);
     //-----------------------------------------
     // WYSI-Weirdness #4: Font tags
     //-----------------------------------------
     $t = preg_replace("#<font (color|size|face)=\"([a-zA-Z0-9\\s\\#\\-]*?)\">(\\s*)</font>#is", " ", $t);
     //-----------------------------------------
     // WYSI-Weirdness #5: Fix up smilies
     //-----------------------------------------
     $current = $this->memberData['view_img'];
     $this->member->setProperty('view_img', 0);
     $t = IPSText::getTextClass('bbcode')->memberViewImages($t);
     $this->member->setProperty('view_img', $current);
     //-----------------------------------------
     // WYSI-Weirdness #6: Image tags
     //-----------------------------------------
     $t = preg_replace("#<img.+?src=[\"'](.+?)[\"']([^>]+?)?" . ">#is", "[img]\\1[/img]", $t);
     //-----------------------------------------
     // WYSI-Weirdness #7: Linked URL tags
     //-----------------------------------------
     $t = preg_replace("#\\[url=(\"|'|&quot;)<a\\s+?href=[\"'](.*)/??['\"]\\2/??</a>#is", "[url=\\1\\2", $t);
     //-----------------------------------------
     // WYSI-Weirdness #8: Make relative images full links
     //-----------------------------------------
     $t = preg_replace("#\\[img\\](/)?style_(emoticons|images)#i", '[img]' . $this->settings['board_url'] . '/style_' . '\\2', $t);
     //-----------------------------------------
     // Now, recursively parse the other tags
     // to make sure we get the nested ones
     //-----------------------------------------
     $t = $this->_recurseAndParse('b', $t, "_parseSimpleTag", 'b');
     $t = $this->_recurseAndParse('u', $t, "_parseSimpleTag", 'u');
     $t = $this->_recurseAndParse('strong', $t, "_parseSimpleTag", 'b');
     $t = $this->_recurseAndParse('i', $t, "_parseSimpleTag", 'i');
     $t = $this->_recurseAndParse('em', $t, "_parseSimpleTag", 'i');
     $t = $this->_recurseAndParse('strike', $t, "_parseSimpleTag", 's');
     $t = $this->_recurseAndParse('s', $t, "_parseSimpleTag", 's');
     $t = $this->_recurseAndParse('blockquote', $t, "_parseSimpleTag", 'indent');
     $t = $this->_recurseAndParse('sup', $t, "_parseSimpleTag", 'sup');
     $t = $this->_recurseAndParse('sub', $t, "_parseSimpleTag", 'sub');
     //-----------------------------------------
     // More complex tags
     //-----------------------------------------
     $t = $this->_recurseAndParse('a', $t, "_parseAnchorTag");
     $t = $this->_recurseAndParse('font', $t, "_parseFontTag");
     $t = $this->_recurseAndParse('div', $t, "_parseDivTag");
     $t = $this->_recurseAndParse('span', $t, "_parseSpanTag");
     $t = $this->_recurseAndParse('p', $t, "_parseParagraphTag");
     //-----------------------------------------
     // Lists
     //-----------------------------------------
     $t = $this->_recurseAndParse('ol', $t, "_parseListTag");
     $t = $this->_recurseAndParse('ul', $t, "_parseListTag");
     //-----------------------------------------
     // WYSI-Weirdness #9: Fix up para tags
     //-----------------------------------------
     $t = str_ireplace(array("<p>", "<p />"), "\n\n", $t);
     //-----------------------------------------
     // WYSI-Weirdness #10: Random junk
     //-----------------------------------------
     $t = str_ireplace(array("<a>", "</a>", "</li>"), "", $t);
     //-----------------------------------------
     // WYSI-Weirdness #11: Fix up list stuff
     //-----------------------------------------
     $t = preg_replace('#<li>(.*)((?=<li>)|</li>)#is', '\\1', $t);
     //-----------------------------------------
     // WYSI-Weirdness #12: Convert rest to HTML
     //-----------------------------------------
     $t = str_replace('&lt;', '<', $t);
     $t = str_replace('&gt;', '>', $t);
     $t = str_replace('&amp;', '&', $t);
     $t = preg_replace('#&amp;(quot|lt|gt);#', '&\\1;', $t);
     //-----------------------------------------
     // WYSI-Weirdness #13: Remove useless tags
     //-----------------------------------------
     while (preg_match("#\\[(url|img|b|u|i|s|email|list|indent|right|left|center)\\]\\[/\\1\\]#is", $t)) {
         $t = preg_replace("#\\[(url|img|b|u|i|s|email|list|indent|right|left|center)\\]\\[/\\1\\]#is", "", $t);
     }
     //-----------------------------------------
     // WYSI-Weirdness #14: Opera crap
     //-----------------------------------------
     $t = preg_replace("#\\[(font|size|color)\\]=[\"']([^\"']+?)[\"']\\]\\[/\\1\\]#is", "", $t);
     //-----------------------------------------
     // WYSI-Weirdness #15: No domain in FF?
     //-----------------------------------------
     $t = preg_replace("#(http|https):\\/\\/index.php(.*?)#is", $this->settings['board_url'] . '/index.php\\2', $t);
     $t = preg_replace("#\\[url=['\"]index.php(.*?)[\"']#is", "[url=\"" . $this->settings['board_url'] . '/index.php\\1"', $t);
     //-----------------------------------------
     // Now call the santize routine to make
     // html and nasties safe. VITAL!!
     //-----------------------------------------
     $t = $this->_cleanPost($t);
     //-----------------------------------------
     // Debug?
     //-----------------------------------------
     if ($this->debug) {
         print "<hr>";
         print nl2br(htmlspecialchars($ot));
         print "<hr>";
         print nl2br($t);
         print "<hr>";
         exit;
     }
     //-----------------------------------------
     // Done
     //-----------------------------------------
     return $t;
 }
 /**
  * Clean _GET _POST value
  *
  * @access	public
  * @param	string		Input
  * @param	bool		Also run postParseCleanValue
  * @return	string		Cleaned Input
  * @since	2.1
  */
 public static function parseCleanValue($val, $postParse = true)
 {
     if ($val == "") {
         return "";
     }
     $val = str_replace("&#032;", " ", IPSText::stripslashes($val));
     # Convert all carriage return combos
     $val = str_replace(array("\r\n", "\n\r", "\r"), "\n", $val);
     $val = str_replace("&", "&amp;", $val);
     $val = str_replace("<!--", "&#60;&#33;--", $val);
     $val = str_replace("-->", "--&#62;", $val);
     $val = str_ireplace("<script", "&#60;script", $val);
     $val = str_replace(">", "&gt;", $val);
     $val = str_replace("<", "&lt;", $val);
     $val = str_replace('"', "&quot;", $val);
     $val = str_replace("\n", "<br />", $val);
     // Convert literal newlines
     $val = str_replace("\$", "&#036;", $val);
     $val = str_replace("!", "&#33;", $val);
     $val = str_replace("'", "&#39;", $val);
     // IMPORTANT: It helps to increase sql query safety.
     if (IPS_ALLOW_UNICODE) {
         $val = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $val);
         //-----------------------------------------
         // Try and fix up HTML entities with missing ;
         //-----------------------------------------
         $val = preg_replace("/&#(\\d+?)([^\\d;])/i", "&#\\1;\\2", $val);
     }
     //-----------------------------------------
     // Shortcut to auto run other cleaning
     //-----------------------------------------
     if ($postParse) {
         $val = IPSText::postParseCleanValue($val);
     }
     return $val;
 }
Beispiel #10
0
 /**
  * Fetch a JSON list of template bits for the template group
  *
  * @return	@e void
  */
 protected function _replace()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $finalIDs = array();
     $templates = array();
     $sessionID = IPSText::md5Clean($this->request['sessionID']);
     $sessionData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'template_sandr', 'where' => "sandr_session_id='" . addslashes($sessionID) . "'"));
     $templateData = unserialize($sessionData['sandr_results']);
     if (is_array($templateData)) {
         foreach ($templateData as $_group => $_data) {
             if (!empty($_POST['groups'][$_group])) {
                 foreach ($_data as $_name => $_id) {
                     $finalIDs[] = $_id;
                 }
             } else {
                 foreach ($_data as $_name => $_id) {
                     if (!empty($_POST['templates'][$_id])) {
                         $finalIDs[] = $_id;
                     }
                 }
             }
         }
     }
     /* Check... */
     if (!count($finalIDs)) {
         $this->returnJsonError($this->lang->words['ajax_missing_data']);
     }
     /* Load templates */
     $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => 'template_id IN (' . implode(',', $finalIDs) . ')'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $templates[$row['template_id']] = $row;
     }
     /* Perform the replacement */
     foreach ($templates as $template_id => $template) {
         if ($sessionData['sandr_is_regex']) {
             $before = str_replace('#', '\\#', IPSText::stripslashes($sessionData['sandr_search_for']));
             $after = preg_replace('#\\\\\\\\(\\d+?)#i', '$\\1', $sessionData['sandr_replace_with']);
             $template['template_content'] = preg_replace("#{$before}#si", $after, $template['template_content']);
         } else {
             $template['template_content'] = str_ireplace($sessionData['sandr_search_for'], $sessionData['sandr_replace_with'], $template['template_content']);
         }
         /* Save it */
         $this->skinFunctions->saveTemplateBitFromEdit($template['template_id'], $sessionData['sandr_set_id'], $template['template_content'], $template['template_data']);
     }
     /* Done */
     $this->returnJsonArray(array('status' => 'ok'));
 }
 /**
  * Search template bits
  *
  * @access		public
  * @param		int			Template set id to search
  * @param		string		String to search
  * @param		boolean		Is regex
  * @param		boolean		Search all parents including master template set
  * @return		array 		array( 'searchCount' => int, 'matchCount' => int, 'matches' => array )
  * Exception Codes
  * REGEX_INCORRECT			Regex is not valid
  */
 public function searchTemplates($setID, $searchString, $isRegex = FALSE, $searchParents = FALSE)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $searchString = IPSText::stripslashes($searchString);
     $regexString = str_replace('#', '\\#', str_replace('"', '\\"', $searchString));
     $_templates = array();
     $_matches = array();
     $_matchCount = 0;
     $return = array('searchCount' => 0, 'matchCount' => 0, 'matches' => array());
     /* Test Regex */
     if ($isRegex) {
         ob_start();
         eval("preg_match( \"#{$regexString}#i\", 'sometexthere' );");
         $return = ob_get_contents();
         ob_end_clean();
         if ($return) {
             throw new Exception("REGEX_INCORRECT");
         }
     }
     /* Grab templates to search in */
     if ($searchParents) {
         $_templates = $this->fetchTemplates($setID);
     } else {
         $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => 'template_set_id=' . $setID));
         $this->DB->execute();
         while ($row = $this->DB->fetch()) {
             $_templates[$row['template_group']][strtolower($row['template_name'])] = $row;
         }
     }
     /* Got anything? */
     if (!count($_templates)) {
         return $return;
     }
     $_templateCount = 0;
     /* You may continue... */
     foreach ($_templates as $_group => $_gdata) {
         foreach ($_gdata as $_name => $_data) {
             if ($isRegex) {
                 if (preg_match("#{$regexString}#i", $_data['template_content'])) {
                     $_matches[$_group][$_name] = $_data;
                     $_matchCount++;
                 }
             } else {
                 if (stristr($_data['template_content'], $searchString)) {
                     $_matches[$_group][$_name] = $_data;
                     $_matchCount++;
                 }
             }
             $_templateCount++;
         }
     }
     /* Return to sender */
     return array('searchCount' => $_templateCount, 'matchCount' => $_matchCount, 'matches' => $_matches);
 }
 /**
  * Processes the template bits...
  *
  * @return	string	HTML
  */
 protected function _start()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $setID = intval($this->request['setID']);
     $searchParents = intval($this->request['searchParents']);
     $isRegex = intval($this->request['isRegex']);
     $searchFor_RAW = IPSText::stripslashes($_POST['searchFor']);
     $replaceWith_RAW = IPSText::stripslashes($_POST['replaceWith']);
     $_finalMatches = array();
     /* Checks */
     if (!$searchFor_RAW) {
         $this->registry->output->global_error = $this->lang->words['sr_sometext'];
         return $this->_showForm();
     }
     //-----------------------------------------
     // Get template set data
     //-----------------------------------------
     $setData = $this->skinFunctions->fetchSkinData($setID);
     try {
         $result = $this->skinFunctions->searchTemplates($setID, $_POST['searchFor'], $isRegex, $searchParents);
         if ($result['matchCount']) {
             /* Finalize */
             foreach ($result['matches'] as $_group => $_gdata) {
                 foreach ($_gdata as $_name => $_data) {
                     $_finalMatches[$_group][$_name] = $_data['template_id'];
                 }
             }
             /* Prep array */
             $sessionData = array('sandr_set_id' => $setID, 'sandr_search_only' => $replaceWith_RAW ? 0 : 1, 'sandr_search_all' => $searchParents, 'sandr_search_for' => $searchFor_RAW, 'sandr_replace_with' => $replaceWith_RAW, 'sandr_is_regex' => $isRegex, 'sandr_template_count' => $result['searchCount'], 'sandr_template_processed' => $result['searchCount'], 'sandr_updated' => time(), 'sandr_results' => serialize($_finalMatches));
             /* Insert into DB */
             $this->DB->insert('template_sandr', $sessionData);
             $sessionData['sandr_session_id'] = $this->DB->getInsertID();
         } else {
             $this->registry->output->global_error = $this->lang->words['sr_nomatches'];
             return $this->_showForm();
         }
         //-----------------------------------------
         // Print it...
         //-----------------------------------------
         $this->registry->output->html .= $this->html->searchandreplace_listTemplateGroups($_finalMatches, $setData, $sessionData);
     } catch (Exception $error) {
         $this->registry->output->global_error = $error->getMessage();
         return $this->_showForm();
     }
 }
Beispiel #13
0
 /**
  * Show PM form
  *
  * @param	string 		Error message
  * @return	string		returns HTML
  */
 protected function _showNewTopicForm($errors = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     /* Check max per day */
     if ($this->messengerFunctions->checkHasHitMax()) {
         $this->registry->getClass('output')->showError('maxperday_hit', 10271);
     }
     /* Check PM flood */
     if ($this->messengerFunctions->floodControlCheck() !== TRUE) {
         $this->registry->getClass('output')->showError(sprintf($this->lang->words['pm_flood_stop'], $this->messengerFunctions->exceptionData[0]), 010271);
     }
     /* Check limit*/
     if (!$this->messengerFunctions->withinPMQuota($this->memberData)) {
         $this->registry->getClass('output')->showError('cannot_send_new_limit', 10273, FALSE, '', 40);
     }
     $_msg_id = 0;
     $formMemberID = intval($this->request['fromMemberID']);
     # WAS MID
     $topicID = intval($this->request['topicID']);
     $preview = $this->request['preview'];
     $inviteUsers = array();
     $displayData = array('errors' => $errors ? array($errors) : array(), 'topicID' => $topicID, 'preview' => '', 'name' => '', 'title' => '', 'message' => '');
     $_POST['Post-NS'] = isset($_POST['Post']) ? $_POST['Post'] : '';
     $_POST['Post'] = IPSText::raw2form(isset($_POST['Post']) ? $_POST['Post'] : '');
     //-----------------------------------------
     // Load editor
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $_editor = new $classToLoad();
     $_editor->setAllowHtml(false);
     //-----------------------------------------
     // Preview post?
     //-----------------------------------------
     if ($preview) {
         /* Grab language for attachment previews */
         $this->registry->getClass('class_localization')->loadLanguageFile(array("public_topic"), 'forums');
         /* Load parser */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
         $parser = new $classToLoad();
         $parser->set(array('memberData' => $this->memberData, 'parseBBCode' => 1, 'parseArea' => 'pms', 'parseHtml' => 0, 'parseEmoticons' => 1));
         if ($this->request['_from'] == 'quickPM') {
             $old_msg = $_editor->process($_editor->fromPlainTextArea($_POST['Post']));
         } else {
             $old_msg = $_editor->process($_POST['Post']);
         }
         $old_msg = $parser->display($old_msg);
         if (!is_object($this->class_attach)) {
             //-----------------------------------------
             // Grab render attach class
             //-----------------------------------------
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
             $this->class_attach = new $classToLoad($this->registry);
         }
         //-----------------------------------------
         // Continue...
         //-----------------------------------------
         $this->class_attach->type = 'msg';
         $this->class_attach->attach_post_key = $this->_postKey;
         $this->class_attach->init();
         $attachData = $this->class_attach->renderAttachments(array(0 => $old_msg));
         $displayData['preview'] = $attachData[0]['html'] . $attachData[0]['attachmentHtml'];
     }
     //-----------------------------------------
     // Errors
     //-----------------------------------------
     if ($errors or IPSText::getTextClass('bbcode')->error != "") {
         if (IPSText::getTextClass('bbcode')->error) {
             $displayData['errors'][] = $this->lang->words[IPSText::getTextClass('bbcode')->error];
         }
         $preview = 1;
     }
     //-----------------------------------------
     // Did we come from a button with a user ID?
     //-----------------------------------------
     if ($formMemberID) {
         $name = IPSMember::load($formMemberID, 'core');
         if ($name['member_id']) {
             $displayData['name'] = $name['members_display_name'];
         }
     } else {
         $displayData['name'] = $this->request['entered_name'] ? $this->request['entered_name'] : '';
     }
     //-----------------------------------------
     // Are we quoting an old message?
     //-----------------------------------------
     if ($preview) {
         $displayData['message'] = $_POST['Post-NS'];
         if ($this->request['_from'] == 'quickPM') {
             $displayData['message'] = IPSText::parseCleanValue($displayData['message'], true);
         }
         $displayData['title'] = str_replace("'", "&#39;", str_replace('"', '&#34;', IPSText::stripslashes($_POST['msg_title'])));
     } else {
         if ($topicID) {
             $draftTopic = $this->messengerFunctions->fetchTopicDataWithMessage($topicID, TRUE);
             /* Permission to view this? */
             if ($draftTopic['mt_starter_id'] == $this->memberData['member_id']) {
                 if ($draftTopic['mt_to_member_id']) {
                     $displayData['name'] = $draftTopic['from_name'];
                 }
                 if ($draftTopic['mt_title']) {
                     $_member = IPSMember::load($draftTopic['mt_to_member_id'], 'core');
                     $displayData['name'] = $_member['members_display_name'];
                     $displayData['title'] = $draftTopic['mt_title'];
                     $_msg_id = $draftTopic['msg_id'];
                     $this->_postKey = $draftTopic['msg_post_key'];
                     /* Load parser */
                     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser');
                     $parser = new $classToLoad();
                     $parser->set(array('memberData' => $this->memberData, 'parseBBCode' => 1, 'parseArea' => 'pms', 'parseHtml' => 0, 'parseEmoticons' => 1));
                     $displayData['message'] = $draftTopic['msg_post'];
                 }
             }
         }
     }
     //-----------------------------------------
     // CC Boxes
     //-----------------------------------------
     if ($this->memberData['g_max_mass_pm'] > 0) {
         if ($_POST['inviteUsers']) {
             $displayData['inviteUsers'] = IPSText::parseCleanValue($_POST['inviteUsers']);
         } else {
             if ($draftTopic['mt_invited_members']) {
                 $_inviteUsers = $this->messengerFunctions->getInvitedUsers($draftTopic['mt_invited_members']);
                 $__inviteUsers = IPSMember::load($_inviteUsers, 'core');
                 if (is_array($__inviteUsers)) {
                     $_tmp = array();
                     foreach ($__inviteUsers as $id => $data) {
                         $_tmp[] = $data['members_display_name'];
                     }
                     if (is_array($_tmp)) {
                         $displayData['inviteUsers'] = implode(", ", $_tmp);
                     }
                 }
             }
         }
     }
     $_editor->setContent($displayData['message']);
     $displayData['editor'] = $_editor->show('Post', array('height' => 350));
     //-----------------------------------------
     // More Data...
     //-----------------------------------------
     $displayData['uploadData'] = $this->_canUpload ? array('canUpload' => 1) : array('canUpload' => 0);
     $displayData['postKey'] = $this->_postKey;
     //-----------------------------------------
     // Load attachments so we get some stats
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach');
     $class_attach = new $classToLoad($this->registry);
     $class_attach->type = 'msg';
     $class_attach->init();
     $class_attach->getUploadFormSettings();
     $displayData['uploadData']['attach_stats'] = $class_attach->attach_stats;
     //-----------------------------------------
     // Build up the HTML for the send form
     //-----------------------------------------
     $this->_title = $this->lang->words['sendMsgTitle'];
     $this->_navigation[] = array($this->lang->words['sendMsgTitle'], '');
     return $this->registry->getClass('output')->getTemplate('messaging')->sendNewPersonalTopicForm($displayData);
 }
Beispiel #14
0
 /**
  * Update a user's login or display name
  *
  * @param	string		Field to update
  * @return	@e void		[Outputs to screen]
  */
 protected function save_member_name($field = 'members_display_name')
 {
     $member_id = intval($this->request['member_id']);
     $member = IPSMember::load($member_id);
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin', 'members', 'members')) {
         $this->registry->output->showError($this->lang->words['m_editadmin']);
     }
     if ($field == 'members_display_name') {
         $display_name = $this->request['display_name'];
         $display_name = str_replace("&#43;", "+", $display_name);
     } else {
         $display_name = $this->request['name'];
         $display_name = str_replace("&#43;", "+", $display_name);
         $display_name = str_replace('|', '&#124;', $display_name);
         $display_name = trim(preg_replace("/\\s{2,}/", " ", $display_name));
     }
     if ($this->settings['strip_space_chr']) {
         // use hexdec to convert between '0xAD' and chr
         $display_name = IPSText::removeControlCharacters($display_name);
     }
     if ($field == 'members_display_name' and preg_match("#[\\[\\];,\\|]#", IPSText::UNhtmlspecialchars($display_name))) {
         $this->registry->output->showError($this->lang->words['m_displaynames']);
     }
     try {
         if (IPSMember::getFunction()->updateName($member_id, $display_name, $field, TRUE) === TRUE) {
             if ($field == 'members_display_name') {
                 ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_dnamelog'], $member['members_display_name'], $display_name));
             } else {
                 ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_namelog'], $member['name'], $display_name));
                 //-----------------------------------------
                 // If updating a name, and display names
                 //	disabled, update display name too
                 //-----------------------------------------
                 if (!ipsRegistry::$settings['auth_allow_dnames']) {
                     IPSMember::getFunction()->updateName($member_id, $display_name, 'members_display_name', TRUE);
                 }
                 //-----------------------------------------
                 // I say, did we choose to email 'dis member?
                 //-----------------------------------------
                 if ($this->request['send_email'] == 1) {
                     //-----------------------------------------
                     // By golly, we did!
                     //-----------------------------------------
                     $msg = trim(IPSText::stripslashes(nl2br($_POST['email_contents'])));
                     $msg = str_replace("{old_name}", $member['name'], $msg);
                     $msg = str_replace("{new_name}", $display_name, $msg);
                     $msg = str_replace("<#BOARD_NAME#>", $this->settings['board_name'], $msg);
                     $msg = str_replace("<#BOARD_ADDRESS#>", $this->settings['board_url'] . '/index.' . $this->settings['php_ext'], $msg);
                     IPSText::getTextClass('email')->message = stripslashes(IPSText::getTextClass('email')->cleanMessage($msg));
                     IPSText::getTextClass('email')->subject = $this->lang->words['m_changesubj'];
                     IPSText::getTextClass('email')->to = $member['email'];
                     IPSText::getTextClass('email')->sendMail();
                 }
             }
             $this->cache->rebuildCache('stats', 'global');
         } else {
             # We should absolutely never get here. So this is a fail-safe, really to
             # prevent a "false" positive outcome for the end-user
             $this->registry->output->showError($this->lang->words['m_namealready']);
         }
     } catch (Exception $error) {
         //	$this->returnJsonError( $error->getMessage() );
         switch ($error->getMessage()) {
             case 'NO_USER':
                 $this->registry->output->showError($this->lang->words['m_noid']);
                 break;
             case 'NO_PERMISSION':
             case 'NO_NAME':
                 $this->registry->output->showError(sprintf($this->lang->words['m_morethan3'], $this->settings['max_user_name_length']));
                 break;
             case 'ILLEGAL_CHARS':
                 $this->registry->output->showError($this->lang->words['m_illegal']);
                 break;
             case 'USER_NAME_EXISTS':
                 $this->registry->output->showError($this->lang->words['m_namealready']);
                 break;
             default:
                 $this->registry->output->showError($error->getMessage());
                 break;
         }
     }
     $this->registry->output->global_message = $this->lang->words[$field . '_updated_success'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=members&do=viewmember&member_id=' . $member_id);
 }
 /**
  * Saves a custom field form
  *
  * @param	string		Type (add|edit)
  * @return	@e void
  */
 public function mainSave($type = 'edit')
 {
     /* ID */
     $id = intval($this->request['id']);
     /* Custom Fields Class */
     $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classCustomFields.php', 'classCustomFields');
     $cfields_class = new $classToLoad(array());
     if (!$this->request['pf_title']) {
         $this->registry->output->showError($this->lang->words['cf_entertitle'], 11221);
     }
     if (!$this->request['pf_key']) {
         $this->registry->output->showError($this->lang->words['cf_enterkey'], 11221.5);
     } else {
         if ($type == 'edit') {
             $_exist = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => "pf_key='{$this->request['pf_key']}' AND pf_id <> {$id}"));
         } else {
             $_exist = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => "pf_key='{$this->request['pf_key']}'"));
         }
         if ($_exist['pf_id']) {
             $this->registry->output->showError($this->lang->words['cf_duplicatekey'], 11221.6);
         }
     }
     //-----------------------------------------
     // check-da-motcha
     //-----------------------------------------
     if ($type == 'edit') {
         if (!$id) {
             $this->registry->output->showError($this->lang->words['cf_norow'], 11222);
         }
     }
     $content = "";
     if ($_POST['pf_content'] != "") {
         $content = $cfields_class->formatContentForSave($_POST['pf_content']);
     }
     $db_string = array('pf_title' => $this->request['pf_title'], 'pf_desc' => $this->request['pf_desc'], 'pf_content' => IPSText::stripslashes($content), 'pf_type' => $this->request['pf_type'], 'pf_not_null' => intval($this->request['pf_not_null']), 'pf_member_hide' => intval($this->request['pf_member_hide']), 'pf_max_input' => intval($this->request['pf_max_input']), 'pf_member_edit' => intval($this->request['pf_member_edit']), 'pf_position' => intval($this->request['pf_position']), 'pf_show_on_reg' => intval($this->request['pf_show_on_reg']), 'pf_input_format' => $this->request['pf_input_format'], 'pf_admin_only' => intval($this->request['pf_admin_only']), 'pf_topic_format' => IPSText::stripslashes($_POST['pf_topic_format']), 'pf_group_id' => intval($this->request['pf_group_id']), 'pf_icon' => trim($this->request['pf_icon']), 'pf_key' => trim($this->request['pf_key']), 'pf_search_type' => trim($this->request['pf_search_type']), 'pf_filtering' => intval($this->request['pf_filtering']));
     if ($type == 'edit') {
         $this->DB->update('pfields_data', $db_string, 'pf_id=' . $id);
         $this->registry->output->global_message = $this->lang->words['cf_edited'];
     } else {
         $this->DB->insert('pfields_data', $db_string);
         $new_id = $this->DB->getInsertId();
         $this->DB->addField('pfields_content', "field_{$new_id}", 'text');
         $this->DB->optimize('pfields_content');
         $this->registry->output->global_message = $this->lang->words['cf_added'];
     }
     $this->rebuildCache();
     $this->mainScreen();
 }
 /**
  * Initiate the registry
  *
  * @return	mixed	false or void
  */
 public static function init()
 {
     $INFO = array();
     $_ipsPowerSettings = array();
     if (self::$initiated === TRUE) {
         return FALSE;
     }
     self::$initiated = TRUE;
     /* Load static classes */
     require IPS_ROOT_PATH . "sources/base/core.php";
     /*noLibHook*/
     require IPS_ROOT_PATH . "sources/base/ipsMember.php";
     /*noLibHook*/
     /* Debugging notices? */
     if (defined('IPS_ERROR_CAPTURE') and IPS_ERROR_CAPTURE !== FALSE) {
         @error_reporting(E_ALL | E_NOTICE);
         @set_error_handler("IPSDebug::errorHandler");
     }
     /* Load core variables */
     self::_loadCoreVariables();
     /* Load config file */
     if (is_file(DOC_IPS_ROOT_PATH . 'conf_global.php')) {
         require DOC_IPS_ROOT_PATH . 'conf_global.php';
         /*noLibHook*/
         if (is_array($INFO)) {
             foreach ($INFO as $key => $val) {
                 ipsRegistry::$settings[$key] = str_replace('&#092;', '\\', $val);
             }
         }
     }
     /* Load secret sauce */
     if (is_array($_ipsPowerSettings)) {
         ipsRegistry::$settings = array_merge($_ipsPowerSettings, ipsRegistry::$settings);
     }
     /* Make sure we're installed */
     if (empty($INFO['sql_database'])) {
         /* Quick PHP version check */
         if (!version_compare(MIN_PHP_VERS, PHP_VERSION, '<=')) {
             print "You must be using PHP " . MIN_PHP_VERS . " or better. You are currently using: " . PHP_VERSION;
             exit;
         }
         $host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : @getenv('HTTP_HOST');
         $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : @getenv('PHP_SELF');
         if (IPS_AREA == 'admin') {
             @header("Location: http://" . $host . rtrim(dirname($self), '/\\') . "/install/index.php");
         } else {
             if (!defined('CP_DIRECTORY')) {
                 define('CP_DIRECTORY', 'admin');
             }
             @header("Location: http://" . $host . rtrim(dirname($self), '/\\') . "/" . CP_DIRECTORY . "/install/index.php");
         }
     }
     /* Switch off dev mode you idjit */
     if (!defined('IN_DEV')) {
         define('IN_DEV', 0);
     }
     /* Shell defined? */
     if (!defined('IPS_IS_SHELL')) {
         define('IPS_IS_SHELL', FALSE);
     }
     /* If this wasn't defined in the gateway file... */
     if (!defined('ALLOW_FURLS')) {
         define('ALLOW_FURLS', ipsRegistry::$settings['use_friendly_urls'] ? TRUE : FALSE);
     }
     if (!defined('IPS_IS_MOBILE_APP')) {
         define('IPS_IS_MOBILE_APP', false);
     }
     /**
      * File and folder permissions
      */
     if (!defined('IPS_FILE_PERMISSION')) {
         define('IPS_FILE_PERMISSION', 0777);
     }
     if (!defined('IPS_FOLDER_PERMISSION')) {
         define('IPS_FOLDER_PERMISSION', 0777);
     }
     /* Set it again incase a gateway turned it off */
     ipsRegistry::$settings['use_friendly_urls'] = ALLOW_FURLS;
     /* Start timer */
     IPSDebug::startTimer();
     /* Cookies... */
     IPSCookie::$sensitive_cookies = array('session_id', 'admin_session_id', 'member_id', 'pass_hash');
     /* INIT DB */
     self::$handles['db'] = ips_DBRegistry::instance();
     /* Set DB */
     self::$handles['db']->setDB(ipsRegistry::$settings['sql_driver']);
     /* Input set up... */
     if (is_array($_POST) and count($_POST)) {
         foreach ($_POST as $key => $value) {
             # Skip post arrays
             if (!is_array($value)) {
                 $_POST[$key] = IPSText::stripslashes($value);
             }
         }
     }
     //-----------------------------------------
     // Clean globals, first.
     //-----------------------------------------
     IPSLib::cleanGlobals($_GET);
     IPSLib::cleanGlobals($_POST);
     IPSLib::cleanGlobals($_COOKIE);
     IPSLib::cleanGlobals($_REQUEST);
     # GET first
     $input = IPSLib::parseIncomingRecursively($_GET, array());
     # Then overwrite with POST
     self::$request = IPSLib::parseIncomingRecursively($_POST, $input);
     # Fix some notices
     if (!isset(self::$request['module'])) {
         self::$request['module'] = '';
     }
     if (!isset(self::$request['section'])) {
         self::$request['section'] = '';
     }
     # Assign request method
     self::$request['request_method'] = strtolower(my_getenv('REQUEST_METHOD'));
     /* Define some constants */
     define('IPS_IS_TASK', (isset(self::$request['module']) and self::$request['module'] == 'task' and self::$request['app'] == 'core') ? TRUE : FALSE);
     define('IPS_IS_AJAX', (isset(self::$request['module']) and self::$request['module'] == 'ajax') ? TRUE : FALSE);
     /* First pass of app set up. Needs to be BEFORE caches and member are set up */
     self::_fUrlInit();
     self::_manageIncomingURLs();
     /* _manageIncomingURLs MUST be called first!!! */
     self::_setUpAppData();
     /* Load app / coreVariables.. must be called after app Data */
     self::_loadAppCoreVariables(IPS_APP_COMPONENT);
     /* Must be called after _manageIncomingURLs */
     self::$handles['db']->getDB()->setDebugMode(IPS_SQL_DEBUG_MODE ? isset($_GET['debug']) ? intval($_GET['debug']) : 0 : 0);
     /* Get caches */
     self::$handles['caches'] = ips_CacheRegistry::instance();
     /* Make sure all is well before we proceed */
     try {
         self::instance()->setUpSettings();
     } catch (Exception $e) {
         print file_get_contents(IPS_CACHE_PATH . 'cache/skin_cache/settingsEmpty.html');
         exit;
     }
     /* Reset database log file paths to cache path */
     self::$handles['db']->resetLogPaths();
     /* Just in case they copy a space in the license... */
     ipsRegistry::$settings['ipb_reg_number'] = trim(ipsRegistry::$settings['ipb_reg_number']);
     /* Bah, now let's go over any input cleaning routines that have settings *sighs* */
     self::$request = IPSLib::postParseIncomingRecursively(self::$request);
     /* Set up dummy member class to prevent errors if cache rebuild required */
     self::$handles['member'] = ips_MemberRegistryDummy::instance();
     /* Build module and application caches */
     self::instance()->checkCaches();
     /* Set up app specific redirects. Must be called before member/sessions setup */
     self::_parseAppResets();
     /* Re-assign member */
     unset(self::$handles['member']);
     self::$handles['member'] = ips_MemberRegistry::instance();
     /* Load other classes */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_localization.php', 'class_localization');
     self::instance()->setClass('class_localization', new $classToLoad(self::instance()));
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions');
     self::instance()->setClass('permissions', new $classToLoad(self::instance()));
     /* Must be called before output initiated */
     self::getAppClass(IPS_APP_COMPONENT);
     if (IPS_AREA == 'admin') {
         require_once IPS_ROOT_PATH . 'sources/classes/output/publicOutput.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/output/adminOutput.php', 'adminOutput');
         self::instance()->setClass('output', new $classToLoad(self::instance()));
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . "sources/classes/class_admin_functions.php", 'adminFunctions');
         self::instance()->setClass('adminFunctions', new $classToLoad(self::instance()));
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_permissions.php', 'class_permissions');
         self::instance()->setClass('class_permissions', new $classToLoad(self::instance()));
         /* Do stuff that needs both adminFunctions and output initiated */
         self::instance()->getClass('adminFunctions')->postOutputInit();
     } else {
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/output/publicOutput.php', 'output');
         self::instance()->setClass('output', new $classToLoad(self::instance(), TRUE));
         register_shutdown_function(array('ipsRegistry', '__myDestruct'));
     }
     /* Post member processing */
     self::$handles['member']->postOutput();
     /* Add SEO templates to the output system */
     self::instance()->getClass('output')->seoTemplates = self::$_seoTemplates;
     //-----------------------------------------
     // Sort out report center early, so counts
     // and cache is right
     //-----------------------------------------
     $memberData =& self::$handles['member']->fetchMemberData();
     $memberData['showReportCenter'] = false;
     $member_group_ids = array($memberData['member_group_id']);
     $member_group_ids = array_diff(array_merge($member_group_ids, explode(',', $memberData['mgroup_others'])), array(''));
     $report_center = array_diff(explode(',', ipsRegistry::$settings['report_mod_group_access']), array(''));
     foreach ($report_center as $groupId) {
         if (in_array($groupId, $member_group_ids)) {
             $memberData['showReportCenter'] = true;
             break;
         }
     }
     if ($memberData['showReportCenter']) {
         $memberData['access_report_center'] = true;
         $memberCache = $memberData['_cache'];
         $reportsCache = self::$handles['caches']->getCache('report_cache');
         if (!$memberCache['report_last_updated'] || $memberCache['report_last_updated'] < $reportsCache['last_updated']) {
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary');
             $reports = new $classToLoad(ipsRegistry::instance());
             $totalReports = $reports->rebuildMemberCacheArray();
             $memberCache['report_num'] = $totalReports;
             $memberData['_cache'] = $memberCache;
         }
     }
     /* More set up */
     self::_finalizeAppData();
     /* Finish fURL stuffs */
     self::_fUrlComplete();
     self::instance()->getClass('class_localization')->loadLanguageFile(array('public_global'), 'core');
     if (IPS_AREA == 'admin') {
         $validationStatus = self::member()->sessionClass()->getStatus();
         $validationMessage = self::member()->sessionClass()->getMessage();
         if (ipsRegistry::$request['module'] != 'login' and !$validationStatus) {
             //-----------------------------------------
             // Force log in
             //-----------------------------------------
             if (ipsRegistry::$request['module'] == 'ajax') {
                 @header("Content-type: application/json;charset=" . IPS_DOC_CHAR_SET);
                 print json_encode(array('error' => self::instance()->getClass('class_localization')->words['acp_sessiontimeout'], '__session__expired__log__out__' => 1));
                 exit;
             } elseif (ipsRegistry::$settings['logins_over_https'] && (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on')) {
                 /* Bug 38301 */
                 ipsRegistry::getClass('output')->silentRedirect(str_replace('http://', 'https://', ipsRegistry::$settings['this_url']));
                 return;
             } else {
                 ipsRegistry::$request['module'] = 'login';
                 ipsRegistry::$request['core'] = 'login';
                 $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . "/modules_admin/login/manualResolver.php", 'admin_core_login_manualResolver');
                 $runme = new $classToLoad(self::instance());
                 $runme->doExecute(self::instance());
                 exit;
             }
         }
     } else {
         if (IPS_AREA == 'public') {
             /* Set up member */
             self::$handles['member']->finalizePublicMember();
             /* Proper no cache key <update:1> */
             ipsRegistry::$settings['noCacheKey'] = md5('$Rev: 12261 $');
             /* Are we banned: Via IP Address? */
             if (IPSMember::isBanned('ipAddress', self::$handles['member']->ip_address) === TRUE) {
                 self::instance()->getClass('output')->showError('you_are_banned', 2000, true, null, 403);
             }
             /* Are we banned: By DB */
             if (self::$handles['member']->getProperty('member_banned') == 1 or self::$handles['member']->getProperty('temp_ban')) {
                 /* Don't show this message if we're viewing the warn log */
                 if (ipsRegistry::$request['module'] != 'ajax' or ipsRegistry::$request['section'] != 'warnings') {
                     self::getClass('class_localization')->loadLanguageFile('public_error', 'core');
                     $message = '';
                     if (self::$handles['member']->getProperty('member_banned')) {
                         $message = self::getClass('class_localization')->words['no_view_board_b'];
                     } else {
                         $ban_arr = IPSMember::processBanEntry(self::$handles['member']->getProperty('temp_ban'));
                         /* No longer banned */
                         if (time() >= $ban_arr['date_end']) {
                             self::DB()->update('members', array('temp_ban' => ''), 'member_id=' . self::$handles['member']->getProperty('member_id'));
                         } else {
                             $message = sprintf(self::getClass('class_localization')->words['account_susp'], self::getClass('class_localization')->getDate($ban_arr['date_end'], 'LONG', 1));
                         }
                     }
                     /* Get anything? */
                     if ($message) {
                         $warn = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'members_warn_logs', 'where' => 'wl_member=' . self::$handles['member']->getProperty('member_id') . ' AND wl_suspend<>0 AND wl_suspend<>-2', 'order' => 'wl_date DESC', 'limit' => 1));
                         if ($warn['wl_id'] and ipsRegistry::$settings['warn_show_own']) {
                             $moredetails = "<a href='javascript:void(0);' onclick='warningPopup( this, {$warn['wl_id']} );'>" . self::getClass('class_localization')->words['warnings_moreinfo'] . "</a>";
                         }
                         self::instance()->getClass('output')->showError("{$message} {$moredetails}", 1001, true, null, 403);
                     }
                 }
             }
             /* Check server load */
             if (ipsRegistry::$settings['load_limit'] > 0) {
                 $server_load = IPSDebug::getServerLoad();
                 if ($server_load) {
                     $loadinfo = explode("-", $server_load);
                     if (count($loadinfo)) {
                         self::$server_load = $loadinfo[0];
                         if (self::$server_load > ipsRegistry::$settings['load_limit']) {
                             self::instance()->getClass('output')->showError('server_too_busy', 2001);
                         }
                     }
                 }
             }
             /* Specific Ajax Check */
             if (IPS_IS_AJAX and ipsRegistry::$request['section'] != 'warnings') {
                 if (self::$handles['member']->getProperty('g_view_board') != 1 || ipsRegistry::$settings['board_offline'] && !self::$handles['member']->getProperty('g_access_offline')) {
                     @header("Content-type: application/json;charset=" . IPS_DOC_CHAR_SET);
                     print json_encode(array('error' => 'no_permission', '__board_offline__' => 1));
                     exit;
                 }
             }
             /* Other public check */
             if (IPB_THIS_SCRIPT == 'public' and IPS_ENFORCE_ACCESS === FALSE and (ipsRegistry::$request['section'] != 'login' and ipsRegistry::$request['section'] != 'lostpass' and IPS_IS_AJAX === FALSE and ipsRegistry::$request['section'] != 'rss' and ipsRegistry::$request['section'] != 'attach' and ipsRegistry::$request['module'] != 'task' and ipsRegistry::$request['section'] != 'captcha')) {
                 //-----------------------------------------
                 // Permission to see the board?
                 //-----------------------------------------
                 if (self::$handles['member']->getProperty('g_view_board') != 1) {
                     self::getClass('output')->showError('no_view_board', 1000, null, null, 403);
                 }
                 //--------------------------------
                 //  Is the board offline?
                 //--------------------------------
                 if (ipsRegistry::$settings['board_offline'] == 1 and !IPS_IS_SHELL) {
                     if (self::$handles['member']->getProperty('g_access_offline') != 1) {
                         ipsRegistry::$settings['no_reg'] = 1;
                         self::getClass('output')->showBoardOffline();
                     }
                 }
                 //-----------------------------------------
                 // Do we have a display name?
                 //-----------------------------------------
                 if (!(ipsRegistry::$request['section'] == 'register' and (ipsRegistry::$request['do'] == 'complete_login' or ipsRegistry::$request['do'] == 'complete_login_do'))) {
                     if (!self::$handles['member']->getProperty('members_display_name')) {
                         $pmember = self::DB()->buildAndFetch(array('select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id=" . self::$handles['member']->getProperty('member_id')));
                         if (!$pmember['partial_member_id']) {
                             $pmember = array('partial_member_id' => self::$handles['member']->getProperty('member_id'), 'partial_date' => time(), 'partial_email_ok' => self::$handles['member']->getProperty('email') == self::$handles['member']->getProperty('name') . '@' . self::$handles['member']->getProperty('joined') ? 0 : 1);
                             self::DB()->insert('members_partial', $pmember);
                             $pmember['partial_id'] = self::DB()->getInsertId();
                         }
                         self::instance()->getClass('output')->silentRedirect(ipsRegistry::$settings['base_url'] . 'app=core&module=global&section=register&do=complete_login&mid=' . self::$handles['member']->getProperty('member_id') . '&key=' . $pmember['partial_date']);
                     }
                 }
                 //--------------------------------
                 //  Is log in enforced?
                 //--------------------------------
                 if (!(defined('IPS_IS_SHELL') && IPS_IS_SHELL === TRUE) && (!IPS_IS_MOBILE_APP && self::$handles['member']->getProperty('member_group_id') == ipsRegistry::$settings['guest_group'] and ipsRegistry::$settings['force_login'] == 1 && !in_array(ipsRegistry::$request['section'], array('register', 'privacy', 'unsubscribe')))) {
                     if (ipsRegistry::$settings['logins_over_https'] and (!$_SERVER['HTTPS'] or $_SERVER['HTTPS'] != 'on')) {
                         //-----------------------------------------
                         // Set referrer
                         //-----------------------------------------
                         if (!my_getenv('HTTP_REFERER') or stripos(my_getenv('HTTP_REFERER'), ipsRegistry::$settings['board_url']) === false) {
                             $http_referrer = (strtolower($_SERVER['HTTPS']) == 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                         } else {
                             $http_referrer = my_getenv('HTTP_REFERER');
                         }
                         self::instance()->getClass('output')->silentRedirect(str_replace('http://', 'https://', ipsRegistry::$settings['base_url']) . 'app=core&module=global&section=login&referer=' . urlencode($http_referrer));
                     }
                     ipsRegistry::$request['app'] = 'core';
                     ipsRegistry::$request['module'] = 'login';
                     ipsRegistry::$request['core'] = 'login';
                     ipsRegistry::$request['referer'] = ipsRegistry::$request['referer'] ? ipsRegistry::$request['referer'] : (strtolower($_SERVER['HTTPS']) == 'on' ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                     if (is_file(DOC_IPS_ROOT_PATH . '/' . PUBLIC_DIRECTORY . '/style_css/' . ipsRegistry::getClass('output')->skin['_csscacheid'] . '/ipb_login_register.css')) {
                         ipsRegistry::getClass('output')->addToDocumentHead('importcss', ipsRegistry::$settings['css_base_url'] . 'style_css/' . ipsRegistry::getClass('output')->skin['_csscacheid'] . '/ipb_login_register.css');
                     }
                     $classToLoad = IPSLib::loadActionOverloader(IPSLib::getAppDir('core') . "/modules_public/global/login.php", 'public_core_global_login');
                     $runme = new $classToLoad(self::instance());
                     $runme->doExecute(self::instance());
                     exit;
                 }
             }
             /* Have we entered an incorrect FURL that has no match? */
             if (ipsRegistry::$settings['use_friendly_urls'] and self::$_noFurlMatch === true) {
                 self::getClass('output')->showError('incorrect_furl', 404, null, null, 404);
             } else {
                 if (isset(ipsRegistry::$request['act']) and ipsRegistry::$request['act'] == 'rssout') {
                     self::getClass('output')->showError('incorrect_furl', 404, null, null, 404);
                 }
             }
             /* Track search engine visits */
             if (!IPS_IS_TASK and $_SERVER['HTTP_REFERER']) {
                 seoTracker::track($_SERVER['HTTP_REFERER'], self::$settings['query_string_real'], self::$handles['member']->getProperty('member_id'));
             }
         }
     }
     IPSDebug::setMemoryDebugFlag("Registry initialized");
 }
Beispiel #17
0
 /**
  * Save the forum
  *
  * @param	string		$type		[new|edit]
  * @return	@e void
  */
 public function forumSave($type = 'new')
 {
     /* If this is not a redirect forum anymore empty the redirect url - #35126 */
     if ($this->request['forum_type'] != 'redirect') {
         $this->request['redirect_url'] = '';
     }
     //-----------------------------------------
     // Converting the type?
     //-----------------------------------------
     if ($this->request['convert']) {
         $this->forumForm($type, 1);
         return;
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['name'] = trim($this->request['name']);
     $this->request['f'] = intval($this->request['f']);
     $this->request['parent_id'] = !empty($this->request['parent_id']) ? intval($this->request['parent_id']) : -1;
     $forum_cat_lang = intval($this->request['parent_id']) == -1 ? $this->lang->words['for_iscat_y'] : $this->lang->words['for_iscat_n'];
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     $this->registry->adminFunctions->checkSecurityKey();
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if ($this->request['name'] == "") {
         $this->registry->output->global_message = sprintf($this->lang->words['for_entertitle'], mb_strtolower($forum_cat_lang));
         $this->forumForm($type);
         return;
     }
     //-----------------------------------------
     // Are we trying to do something stupid
     // like running with scissors or moving
     // the parent of a forum into itself
     // spot?
     //-----------------------------------------
     if ($this->request['parent_id'] != $this->registry->getClass('class_forums')->forum_by_id[$this->request['f']]['parent_id']) {
         $ids = $this->registry->getClass('class_forums')->forumsGetChildren($this->request['f']);
         $ids[] = $this->request['f'];
         if (in_array($this->request['parent_id'], $ids)) {
             $this->registry->output->global_error = $this->lang->words['for_whymovethere'];
             $this->forumForm($type);
             return;
         }
     }
     //if( $this->request['parent_id'] < 1 )
     //{
     //	$this->request['sub_can_post'] = 1;
     //}
     //-----------------------------------------
     // Save array
     //-----------------------------------------
     $save = array('name' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['name']))), 'name_seo' => IPSText::makeSeoTitle(strip_tags(IPSText::UNhtmlspecialchars($this->request['name']))), 'description' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['description']))), 'use_ibc' => isset($this->request['use_ibc']) ? intval($this->request['use_ibc']) : 1, 'use_html' => intval($this->request['use_html']), 'password' => $this->request['password'], 'password_override' => is_array($this->request['password_override']) ? implode(",", $this->request['password_override']) : '', 'sort_key' => $this->request['sort_key'], 'sort_order' => $this->request['sort_order'], 'prune' => intval($this->request['prune']), 'topicfilter' => $this->request['topicfilter'], 'preview_posts' => intval($this->request['preview_posts']), 'allow_poll' => intval($this->request['allow_poll']), 'allow_pollbump' => intval($this->request['allow_pollbump']), 'forum_allow_rating' => intval($this->request['forum_allow_rating']), 'inc_postcount' => intval($this->request['inc_postcount']), 'parent_id' => intval($this->request['parent_id']), 'sub_can_post' => intval($this->request['sub_can_post']), 'redirect_on' => intval($this->request['redirect_on']), 'redirect_hits' => intval($this->request['redirect_hits']), 'redirect_url' => $this->request['redirect_url'], 'notify_modq_emails' => $this->request['notify_modq_emails'], 'permission_showtopic' => $this->request['parent_id'] == -1 ? 1 : intval($this->request['permission_showtopic']), 'min_posts_post' => intval($this->request['min_posts_post']), 'min_posts_view' => intval($this->request['min_posts_view']), 'can_view_others' => intval($this->request['can_view_others']), 'hide_last_info' => intval($this->request['hide_last_info']), 'disable_sharelinks' => intval($this->request['disable_sharelinks']), 'tag_predefined' => $this->request['tag_predefined'], 'forums_bitoptions' => IPSBWOPtions::freeze($this->request, 'forums', 'forums'), 'permission_custom_error' => nl2br(IPSText::stripslashes($_POST['permission_custom_error'])), 'ipseo_priority' => $this->request['ipseo_priority'], 'viglink' => intval($this->request['viglink']));
     /* Save data from application tabs */
     IPSLib::loadInterface('admin/forum_form.php');
     $_forumPlugins = array();
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php', 'admin_forum_form__' . $app_dir, $app_dir);
             $_forumPlugins[$_class] = new $_class($this->registry);
             $remote = $_forumPlugins[$_class]->getForSave();
             $save = array_merge($save, $remote);
         }
     }
     //-----------------------------------------
     // ADD
     //-----------------------------------------
     if ($type == 'new') {
         $this->DB->build(array('select' => 'MAX(id) as top_forum', 'from' => 'forums'));
         $this->DB->execute();
         $row = $this->DB->fetch();
         if ($row['top_forum'] < 1) {
             $row['top_forum'] = 0;
         }
         $row['top_forum']++;
         /* Forum Information */
         //$save['id']               = $row['top_forum'];
         $save['position'] = $row['top_forum'];
         $save['topics'] = 0;
         $save['posts'] = 0;
         $save['last_post'] = 0;
         $save['last_poster_id'] = 0;
         $save['last_poster_name'] = "";
         /* Insert the record */
         $this->DB->insert('forums', $save);
         $forum_id = $this->DB->getInsertId();
         /* Permissions */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions');
         $permissions = new $classToLoad(ipsRegistry::instance());
         $permissions->savePermMatrix($this->request['perms'], $forum_id, 'forum');
         if (!$save['can_view_others']) {
             $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$forum_id}");
         }
         /* Done */
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__created'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "'" . mb_strtolower($this->lang->words['for__created']));
     } else {
         $forumData = $this->registry->class_forums->getForumById($this->request['f']);
         if ($this->request['parent_id'] == -1) {
             $save['can_view_others'] = 1;
             /* Permissions */
             //$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions' );
             //$permissions = new $classToLoad( ipsRegistry::instance() );
             //$permissions->savePermMatrix( $this->request['perms'], $this->request['f'], 'forum' );
             if (!$save['can_view_others']) {
                 $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             } else {
                 $this->DB->update('permission_index', array('owner_only' => 0), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             }
         }
         $this->DB->update('forums', $save, "id=" . $this->request['f']);
         $forum_id = $this->request['f'];
         /* Tags */
         $this->registry->getClass('class_forums')->forumsInit();
         $this->registry->tags->updatePermssionsByParentId($this->request['f']);
         /* Did we enable/disable tagging? @todo find a better way to do this. Perhaps another field in tags? */
         if (isset($this->request['bw_disable_tagging'])) {
             if ($forumData['bw_disable_tagging'] != $this->request['bw_disable_tagging']) {
                 $toggle = $this->request['bw_disable_tagging'] ? 0 : 1;
                 $this->registry->tags->updateVisibilityByParentId($this->request['f'], $toggle);
                 if ($this->request['bw_disable_tagging'] == 0) {
                     /* We just restored all tags, so lets return hidden topics back to 0 */
                     $this->DB->build(array('select' => 'tid', 'from' => 'topics', 'where' => 'forum_id=' . $this->request['f'] . ' AND ' . $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted', 'hidden', 'pdelete', 'oktoremove')), 'order' => 'last_post DESC', 'limit' => array(0, 500)));
                     $this->DB->execute();
                     $topics = array();
                     while ($row = $this->DB->fetch()) {
                         $topics[] = $row['tid'];
                     }
                     if (count($topics)) {
                         $this->registry->tags->updateVisibilityByMetaId($topics, 0);
                     }
                 }
             }
         }
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__edited'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "' " . mb_strtolower($this->lang->words['for__edited']));
     }
     $this->request['f'] = '';
     if ($save['parent_id'] > 0) {
         $this->request['f'] = $save['parent_id'];
     }
     //-----------------------------------------
     // Post save callbacks
     //-----------------------------------------
     if (count($_forumPlugins)) {
         foreach ($_forumPlugins as $_className => $_object) {
             if (method_exists($_object, 'postSave')) {
                 $_object->postSave($forum_id);
             }
         }
     }
     $this->registry->getClass('class_forums')->forumsInit();
     $this->showForums();
 }
Beispiel #18
0
 /**
  * Sets the topic title.
  * You *must* pass a raw GET or POST value. ie, a value that has not been cleaned by parseCleanValue
  * as there are unicode checks to perform. This function will test those and clean the topic title for you
  *
  * @param	string		Topic Title
  */
 public function setTopicTitle($topicTitle)
 {
     if ($topicTitle) {
         $this->_topicTitle = $topicTitle;
         /* Clean */
         if ($this->settings['etfilter_shout']) {
             if (function_exists('mb_convert_case')) {
                 if (in_array(strtolower($this->settings['gb_char_set']), array_map('strtolower', mb_list_encodings()))) {
                     $this->_topicTitle = mb_convert_case($this->_topicTitle, MB_CASE_TITLE, $this->settings['gb_char_set']);
                 } else {
                     $this->_topicTitle = ucwords(strtolower($this->_topicTitle));
                 }
             } else {
                 $this->_topicTitle = ucwords(strtolower($this->_topicTitle));
             }
         }
         /* Encode curly braces @see http://community.invisionpower.com/tracker/issue-33987-replacements-parsed-in-titles/ */
         $this->_topicTitle = str_replace(array('{', '}'), array('&#123;', '&#125;'), $this->_topicTitle);
         $this->_topicTitle = IPSText::parseCleanValue($this->_topicTitle);
         $this->_topicTitle = $this->cleanTopicTitle($this->_topicTitle);
         $this->_topicTitle = IPSText::getTextClass('bbcode')->stripBadWords($this->_topicTitle);
         if ($this->getIsPreview() !== TRUE) {
             /* Unicode test */
             if (IPSText::mbstrlen($topicTitle) > $this->settings['topic_title_max_len']) {
                 $this->_postErrors = 'topic_title_long';
             }
             if (IPSText::mbstrlen(IPSText::stripslashes($topicTitle)) < 2 or !$this->_topicTitle) {
                 $this->_postErrors = 'no_topic_title';
             }
         }
     }
 }
 /**
  * Builds an array of forum data for use in the output template
  *
  * @access	public
  * @return	array
  **/
 public function renderForum()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['st'] = $this->request['changefilters'] ? 0 : (isset($this->request['st']) ? intval($this->request['st']) : 0);
     $announce_data = array();
     $topic_data = array();
     $other_data = array();
     $multi_mod_data = array();
     $footer_filter = array();
     //-----------------------------------------
     // Show?
     //-----------------------------------------
     if (isset($this->request['show']) and $this->request['show'] == 'sinceLastVisit') {
         $this->request['prune_day'] = 200;
     }
     //-----------------------------------------
     // Are we actually a moderator for this forum?
     //-----------------------------------------
     $mod = $this->memberData['forumsModeratorData'];
     if (!$this->memberData['g_is_supmod']) {
         if (!isset($mod[$this->forum['id']]) or !is_array($mod[$this->forum['id']])) {
             $this->memberData['is_mod'] = 0;
         }
     }
     //-----------------------------------------
     // Announcements
     //-----------------------------------------
     if (is_array($this->registry->cache()->getCache('announcements')) and count($this->registry->cache()->getCache('announcements'))) {
         $announcements = array();
         foreach ($this->registry->cache()->getCache('announcements') as $announce) {
             $order = $announce['announce_start'] ? $announce['announce_start'] . ',' . $announce['announce_id'] : $announce['announce_id'];
             if ($announce['announce_forum'] == '*') {
                 $announcements[$order] = $announce;
             } else {
                 if (strstr(',' . $announce['announce_forum'] . ',', ',' . $this->forum['id'] . ',')) {
                     $announcements[$order] = $announce;
                 }
             }
         }
         if (count($announcements)) {
             //-----------------------------------------
             // sort by start date
             //-----------------------------------------
             krsort($announcements);
             foreach ($announcements as $announce) {
                 if ($announce['announce_start']) {
                     $announce['announce_start'] = gmstrftime('%x', $announce['announce_start']);
                 } else {
                     $announce['announce_start'] = '--';
                 }
                 $announce['announce_title'] = IPSText::stripslashes($announce['announce_title']);
                 $announce['forum_id'] = $this->forum['id'];
                 $announce['announce_views'] = intval($announce['announce_views']);
                 $announce_data[] = $announce;
             }
             $this->forum['_showAnnouncementsBar'] = 1;
         }
     }
     //-----------------------------------------
     // Read topics
     //-----------------------------------------
     $First = intval($this->request['st']);
     //-----------------------------------------
     // Sort options
     //-----------------------------------------
     $cookie_prune = IPSCookie::get($this->forum['id'] . "_prune_day");
     $cookie_sort = IPSCookie::get($this->forum['id'] . "_sort_key");
     $cookie_sortb = IPSCookie::get($this->forum['id'] . "_sort_by");
     $cookie_fill = IPSCookie::get($this->forum['id'] . "_topicfilter");
     $prune_value = $this->selectVariable(array(1 => !empty($this->request['prune_day']) ? $this->request['prune_day'] : NULL, 2 => !empty($cookie_prune) ? $cookie_prune : NULL, 3 => $this->forum['prune'], 4 => '100'));
     $sort_key = $this->selectVariable(array(1 => !empty($this->request['sort_key']) ? $this->request['sort_key'] : NULL, 2 => !empty($cookie_sort) ? $cookie_sort : NULL, 3 => $this->forum['sort_key'], 4 => 'last_post'));
     $sort_by = $this->selectVariable(array(1 => !empty($this->request['sort_by']) ? $this->request['sort_by'] : NULL, 2 => !empty($cookie_sortb) ? $cookie_sortb : NULL, 3 => $this->forum['sort_order'], 4 => 'Z-A'));
     $topicfilter = $this->selectVariable(array(1 => !empty($this->request['topicfilter']) ? $this->request['topicfilter'] : NULL, 2 => !empty($cookie_fill) ? $cookie_fill : NULL, 3 => $this->forum['topicfilter'], 4 => 'all'));
     //print_r($this->request);exit;
     //print($cookie_sort);exit;
     if (!empty($this->request['remember'])) {
         if ($this->request['prune_day']) {
             IPSCookie::set($this->forum['id'] . "_prune_day", $this->request['prune_day']);
         }
         if ($this->request['sort_key']) {
             IPSCookie::set($this->forum['id'] . "_sort_key", $this->request['sort_key']);
         }
         if ($this->request['sort_by']) {
             IPSCookie::set($this->forum['id'] . "_sort_by", $this->request['sort_by']);
         }
         if ($this->request['topicfilter']) {
             IPSCookie::set($this->forum['id'] . "_topicfilter", $this->request['topicfilter']);
         }
     }
     //print $sort_key;exit;
     //-----------------------------------------
     // Figure out sort order, day cut off, etc
     //-----------------------------------------
     $Prune = $prune_value < 100 ? time() - $prune_value * 60 * 60 * 24 : (($prune_value == 200 and $this->memberData['member_id']) ? $this->memberData['last_visit'] : 0);
     $sort_keys = array('last_post' => 'sort_by_date', 'last_poster_name' => 'sort_by_last_poster', 'title' => 'sort_by_topic', 'starter_name' => 'sort_by_poster', 'start_date' => 'sort_by_start', 'topic_hasattach' => 'sort_by_attach', 'posts' => 'sort_by_replies', 'views' => 'sort_by_views');
     $prune_by_day = array('1' => 'show_today', '5' => 'show_5_days', '7' => 'show_7_days', '10' => 'show_10_days', '15' => 'show_15_days', '20' => 'show_20_days', '25' => 'show_25_days', '30' => 'show_30_days', '60' => 'show_60_days', '90' => 'show_90_days', '100' => 'show_all', '200' => 'show_last_visit');
     $sort_by_keys = array('Z-A' => 'descending_order', 'A-Z' => 'ascending_order');
     $filter_keys = array('all' => 'topicfilter_all', 'open' => 'topicfilter_open', 'hot' => 'topicfilter_hot', 'poll' => 'topicfilter_poll', 'locked' => 'topicfilter_locked', 'moved' => 'topicfilter_moved');
     if ($this->memberData['member_id']) {
         $filter_keys['istarted'] = 'topicfilter_istarted';
         $filter_keys['ireplied'] = 'topicfilter_ireplied';
     }
     //-----------------------------------------
     // check for any form funny business by wanna-be hackers
     //-----------------------------------------
     if (!isset($filter_keys[$topicfilter]) or !isset($sort_keys[$sort_key]) or !isset($prune_by_day[$prune_value]) or !isset($sort_by_keys[$sort_by])) {
         $this->registry->getClass('output')->showError('forums_bad_filter', 10339);
     }
     $r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
     //-----------------------------------------
     // If sorting by starter, add secondary..
     //-----------------------------------------
     $sort_key_chk = $sort_key;
     if ($sort_key == 'starter_name') {
         $sort_key = "starter_name {$r_sort_by}, t.last_post DESC";
         $r_sort_by = '';
     }
     //-----------------------------------------
     // Additional queries?
     //-----------------------------------------
     $add_query_array = array();
     $add_query = "";
     switch ($topicfilter) {
         case 'all':
             break;
         case 'open':
             $add_query_array[] = "t.state='open'";
             break;
         case 'hot':
             $add_query_array[] = "t.state='open' AND t.posts + 1 >= " . intval($this->settings['hot_topic']);
             break;
         case 'locked':
             $add_query_array[] = "t.state='closed'";
             break;
         case 'moved':
             $add_query_array[] = "t.state='link'";
             break;
         case 'poll':
             $add_query_array[] = "(t.poll_state='open' OR t.poll_state=1)";
             break;
         default:
             break;
     }
     if (!$this->memberData['g_other_topics'] or $topicfilter == 'istarted' or !$this->forum['can_view_others'] and !$this->memberData['is_mod']) {
         $add_query_array[] = "t.starter_id='" . $this->memberData['member_id'] . "'";
     }
     $_SQL_EXTRA = '';
     $_SQL_APPROVED = '';
     $_SQL_AGE_PRUNE = '';
     if (count($add_query_array)) {
         $_SQL_EXTRA = ' AND ' . implode(' AND ', $add_query_array);
     }
     //-----------------------------------------
     // Moderator?
     //-----------------------------------------
     if (!$this->memberData['is_mod']) {
         $_SQL_APPROVED = ' AND t.approved=1';
     } else {
         $_SQL_APPROVED = '';
         //' AND t.approved IN (0,1)';	If you are an admin, it's not needed and eliminates a filesort in some cases
     }
     if ($Prune) {
         if ($prune_value == 200) {
             /* Just new content, don't show pinned, please */
             $_SQL_AGE_PRUNE = " AND (t.last_post > {$Prune})";
         } else {
             $_SQL_AGE_PRUNE = " AND (t.pinned=1 or t.last_post > {$Prune})";
         }
     }
     //-----------------------------------------
     // Query the database to see how many topics there are in the forum
     //-----------------------------------------
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         //-----------------------------------------
         $this->DB->build(array('select' => 'COUNT(' . $this->DB->buildDistinct('p.topic_id') . ') as max', 'from' => array('topics' => 't'), 'where' => " t.forum_id={$this->forum['id']} AND p.author_id=" . $this->memberData['member_id'] . " AND p.new_topic=0" . $_SQL_APPROVED . $_SQL_AGE_PRUNE, 'add_join' => array(array('from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid'))));
         $this->DB->execute();
         $total_possible = $this->DB->fetch();
     } else {
         if (($_SQL_EXTRA or $_SQL_AGE_PRUNE) and !$this->request['modfilter']) {
             $this->DB->build(array('select' => 'COUNT(*) as max', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA));
             $this->DB->execute();
             $total_possible = $this->DB->fetch();
         } else {
             $total_possible['max'] = $this->memberData['is_mod'] ? $this->forum['topics'] + $this->forum['queued_topics'] : $this->forum['topics'];
             $Prune = 0;
         }
     }
     //-----------------------------------------
     // Generate the forum page span links
     //-----------------------------------------
     $this->forum['SHOW_PAGES'] = $this->registry->getClass('output')->generatePagination(array('totalItems' => $total_possible['max'], 'itemsPerPage' => $this->settings['display_max_topics'], 'currentStartValue' => $this->request['st'], 'seoTitle' => $this->forum['name_seo'], 'baseUrl' => "showforum=" . $this->forum['id'] . "&amp;prune_day={$prune_value}&amp;sort_by={$sort_by}&amp;sort_key={$sort_key_chk}&amp;topicfilter={$topicfilter}"));
     //-----------------------------------------
     // Start printing the page
     //-----------------------------------------
     $other_data = array('forum_data' => $this->forum, 'can_edit_topics' => $this->can_edit_topics, 'can_open_topics' => $this->can_open_topics, 'can_close_topics' => $this->can_close_topics);
     $total_topics_printed = 0;
     //-----------------------------------------
     // Get main topics
     //-----------------------------------------
     $topic_array = array();
     $topic_ids = array();
     $topic_sort = "";
     //-----------------------------------------
     // Mod filter?
     //-----------------------------------------
     $this->request['modfilter'] = isset($this->request['modfilter']) ? $this->request['modfilter'] : '';
     if ($this->request['modfilter'] == 'invisible_topics' and $this->memberData['is_mod']) {
         $topic_sort = 't.approved asc,';
     } else {
         if ($this->request['modfilter'] == 'invisible_posts' and $this->memberData['is_mod']) {
             $topic_sort = 't.topic_queuedposts desc,';
         } else {
             if ($this->request['modfilter'] == 'all' and $this->memberData['is_mod']) {
                 $topic_sort = 't.approved asc, t.topic_queuedposts desc,';
             }
         }
     }
     //-----------------------------------------
     // Cut off?
     //-----------------------------------------
     $parse_dots = 1;
     if ($topicfilter == 'ireplied') {
         //-----------------------------------------
         // Checking topics we've replied to?
         // No point in getting dots again...
         //-----------------------------------------
         $parse_dots = 0;
         // For some reason, mySQL doesn't like the distinct + t.* being in reverse order...
         $this->DB->build(array('select' => $this->DB->buildDistinct('p.author_id'), 'from' => array('topics' => 't'), 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . " AND p.new_topic=0", 'order' => "t.pinned desc,{$topic_sort} t.{$sort_key} {$r_sort_by}", 'limit' => array(intval($First), intval($this->settings['display_max_topics'])), 'add_join' => array(array('select' => 't.*', 'from' => array('posts' => 'p'), 'where' => 'p.topic_id=t.tid AND p.author_id=' . $this->memberData['member_id']))));
         $this->DB->execute();
     } else {
         $this->DB->build(array('select' => '*', 'from' => 'topics t', 'where' => "t.forum_id=" . $this->forum['id'] . " AND t.pinned IN (0,1)" . $_SQL_APPROVED . $_SQL_AGE_PRUNE . $_SQL_EXTRA, 'order' => 't.pinned DESC, ' . $topic_sort . ' t.' . $sort_key . ' ' . $r_sort_by, 'limit' => array(intval($First), $this->settings['display_max_topics'])));
         $this->DB->execute();
     }
     while ($t = $this->DB->fetch()) {
         $topic_array[$t['tid']] = $t;
         $topic_ids[$t['tid']] = $t['tid'];
     }
     ksort($topic_ids);
     //-----------------------------------------
     // Are we dotty?
     //-----------------------------------------
     if ($this->settings['show_user_posted'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $this->DB->build(array('select' => 'author_id, topic_id', 'from' => 'posts', 'where' => 'author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['author_id'] = $p['author_id'];
             }
         }
     }
     //-----------------------------------------
     // Are we tracking watched stuff
     //-----------------------------------------
     if ($this->settings['cpu_watch_update'] == 1 and $this->memberData['member_id'] and count($topic_ids) and $parse_dots) {
         $this->DB->build(array('select' => 'topic_id, trid as trackingTopic', 'from' => 'tracker', 'where' => 'member_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode(',', $topic_ids) . ')'));
         $this->DB->execute();
         while ($p = $this->DB->fetch()) {
             if (is_array($topic_array[$p['topic_id']])) {
                 $topic_array[$p['topic_id']]['trackingTopic'] = 1;
             }
         }
     }
     //-----------------------------------------
     // Show meh the topics!
     //-----------------------------------------
     foreach ($topic_array as $topic) {
         if ($topic['pinned']) {
             $this->pinned_topic_count++;
         }
         $topic_data[$topic['tid']] = $this->renderEntry($topic);
         $total_topics_printed++;
     }
     //-----------------------------------------
     // Finish off the rest of the page  $filter_keys[$topicfilter]))
     //-----------------------------------------
     $sort_by_html = "";
     $sort_key_html = "";
     $prune_day_html = "";
     $filter_html = "";
     foreach ($sort_by_keys as $k => $v) {
         $sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_by_keys[$k]]}</option>\n";
     }
     foreach ($sort_keys as $k => $v) {
         $sort_key_html .= $k == $sort_key_chk ? "<option value='{$k}' selected='selected'>{$this->lang->words[$sort_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$sort_keys[$k]]}</option>\n";
     }
     foreach ($prune_by_day as $k => $v) {
         $prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected='selected'>{$this->lang->words[$prune_by_day[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$prune_by_day[$k]]}</option>\n";
     }
     foreach ($filter_keys as $k => $v) {
         $filter_html .= $k == $topicfilter ? "<option value='{$k}' selected='selected'>{$this->lang->words[$filter_keys[$k]]}</option>\n" : "<option value='{$k}'>{$this->lang->words[$filter_keys[$k]]}</option>\n";
     }
     $footer_filter['sort_by'] = $sort_key_html;
     $footer_filter['sort_order'] = $sort_by_html;
     $footer_filter['sort_prune'] = $prune_day_html;
     $footer_filter['topic_filter'] = $filter_html;
     if ($this->memberData['is_mod']) {
         $count = 0;
         $other_pages = 0;
         if ($this->request['selectedtids'] != "") {
             $tids = explode(",", $this->request['selectedtids']);
             if (is_array($tids) and count($tids)) {
                 foreach ($tids as $tid) {
                     if ($tid != '') {
                         if (!isset($topic_array[$tid])) {
                             $other_pages++;
                         }
                         $count++;
                     }
                 }
             }
         }
         $this->lang->words['f_go'] .= " ({$count})";
         if ($other_pages) {
             $this->lang->words['f_go'] .= " ({$other_pages} " . $this->lang->words['jscript_otherpage'] . ")";
         }
     }
     //-----------------------------------------
     // Multi-moderation?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         $mm_array = $this->registry->getClass('class_forums')->getMultimod($this->forum['id']);
         if (is_array($mm_array) and count($mm_array)) {
             foreach ($mm_array as $m) {
                 $multi_mod_data[] = $m;
             }
         }
     }
     //-----------------------------------------
     // Need to update topics?
     //-----------------------------------------
     if (count($this->update_topics_open)) {
         $this->DB->update('topics', array('state' => 'open'), 'tid IN (' . implode(",", $this->update_topics_open) . ')');
     }
     if (count($this->update_topics_close)) {
         $this->DB->update('topics', array('state' => 'closed'), 'tid IN (' . implode(",", $this->update_topics_close) . ')');
     }
     return array('announce_data' => $announce_data, 'topic_data' => $topic_data, 'other_data' => $other_data, 'multi_mod_data' => $multi_mod_data, 'footer_filter' => $footer_filter, 'active_users' => $this->settings['no_au_forum'] ? array('_done' => 0) : $this->_generateActiveUserData());
 }
 /**
  * Display error
  *
  * @access	public
  * @param	string		Error message
  * @param	integer		Error code
  * @return	mixed		You can print a custom message here, or return formatted data to be sent do registry->output->sendOutput
  */
 public function displayError($message, $code = 0)
 {
     list($em_1, $em_2) = explode('@', $this->settings['email_in']);
     //-----------------------------------------
     // If we're a guest, show the log in box..
     //-----------------------------------------
     if (!$this->memberData['member_id']) {
         $safe_string = $this->settings['base_url'] . str_replace('&amp;', '&', IPSText::parseCleanValue(my_getenv('QUERY_STRING')));
         $has_openid = false;
         $uses_name = false;
         $uses_email = false;
         $this->registry->getClass('class_localization')->loadLanguageFile(array('public_login'), 'core');
         foreach ($this->cache->getCache('login_methods') as $method) {
             if ($method['login_folder_name'] == 'openid') {
                 $has_openid = true;
             }
             if ($method['login_user_id'] == 'username') {
                 $uses_name = true;
             }
             if ($method['login_user_id'] == 'email') {
                 $uses_email = true;
             }
         }
         if ($uses_name and $uses_email) {
             $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email'];
         } else {
             if ($uses_email) {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_useremail'];
             } else {
                 $this->lang->words['enter_name'] = $this->lang->words['enter_username'];
             }
         }
         $login_thing = $this->registry->getClass('output')->getTemplate('global_other')->error_log_in(str_replace('&', '&amp;', $safe_string));
     }
     //-----------------------------------------
     // Do we have any post data to keepy?
     //-----------------------------------------
     // Why even bother checking action?  If they posted something and we're here, let 'em save it!
     //if ( $this->request['act'] == 'post' OR $this->request['module'] == 'messenging' OR $this->request['act'] == 'calendar' )
     //{
     if ($_POST['Post']) {
         $post_thing = $this->registry->getClass('output')->getTemplate('global_other')->error_post_textarea(IPSText::htmlspecialchars(IPSText::stripslashes($_POST['Post'])));
     }
     //}
     //-----------------------------------------
     // Show error
     //-----------------------------------------
     $html = $this->registry->getClass('output')->getTemplate('global_other')->Error($message, $code, $em_1, $em_2, 1, $login_thing, $post_thing);
     return $html;
 }
Beispiel #21
0
 /**
  * Saves the login method to the database [add,edit]
  *
  * @param	string		Add or Edit flag
  * @return	@e void		[Outputs to screen]
  */
 protected function _loginSave($type = 'add')
 {
     //--------------------------------------------
     // INIT
     //--------------------------------------------
     $login_id = intval(ipsRegistry::$request['login_id']);
     $login_title = trim(ipsRegistry::$request['login_title']);
     $login_description = trim(IPSText::stripslashes(IPSText::UNhtmlspecialchars($_POST['login_description'])));
     $login_folder_name = trim(ipsRegistry::$request['login_folder_name']);
     $login_maintain_url = trim(ipsRegistry::$request['login_maintain_url']);
     $login_register_url = trim(ipsRegistry::$request['login_register_url']);
     $login_alt_login_html = trim(IPSText::stripslashes(IPSText::UNhtmlspecialchars($_POST['login_alt_login_html'])));
     $login_alt_acp_html = trim(IPSText::stripslashes(IPSText::UNhtmlspecialchars($_POST['login_alt_acp_html'])));
     $login_enabled = intval(ipsRegistry::$request['login_enabled']);
     $login_settings = intval(ipsRegistry::$request['login_settings']);
     $login_replace_form = intval(ipsRegistry::$request['login_replace_form']);
     $login_safemode = intval(ipsRegistry::$request['login_safemode']);
     $login_login_url = trim(ipsRegistry::$request['login_login_url']);
     $login_logout_url = trim(ipsRegistry::$request['login_logout_url']);
     $login_complete_page = trim(ipsRegistry::$request['login_complete_page']);
     $login_user_id = in_array(ipsRegistry::$request['login_user_id'], array('username', 'email', 'either')) ? ipsRegistry::$request['login_user_id'] : 'username';
     //--------------------------------------------
     // Checks...
     //--------------------------------------------
     if ($type == 'edit') {
         if (!$login_id) {
             ipsRegistry::getClass('output')->global_message = $this->lang->words['l_404'];
             $this->_loginList();
             return;
         }
     }
     if (!$login_title or !$login_folder_name) {
         ipsRegistry::getClass('output')->global_message = $this->lang->words['l_form'];
         $this->_loginForm($type);
         return;
     }
     //--------------------------------------------
     // Save...
     //--------------------------------------------
     $array = array('login_title' => $login_title, 'login_description' => $login_description, 'login_folder_name' => $login_folder_name, 'login_maintain_url' => $login_maintain_url, 'login_register_url' => $login_register_url, 'login_alt_login_html' => $login_alt_login_html, 'login_alt_acp_html' => $login_alt_acp_html, 'login_enabled' => $login_enabled, 'login_settings' => $login_settings, 'login_replace_form' => $login_replace_form, 'login_logout_url' => $login_logout_url, 'login_login_url' => $login_login_url, 'login_user_id' => $login_user_id);
     //--------------------------------------------
     // In DEV?
     //--------------------------------------------
     if (IN_DEV) {
         $array['login_safemode'] = $login_safemode;
     }
     //--------------------------------------------
     // Nike.. do it
     //--------------------------------------------
     if ($type == 'add') {
         $this->DB->insert('login_methods', $array);
     } else {
         $this->DB->update('login_methods', $array, 'login_id=' . $login_id);
     }
     //-----------------------------------------
     // Recache
     //-----------------------------------------
     $this->loginsRecache();
     ipsRegistry::getClass('output')->redirect($this->settings['base_url'] . $this->form_code . "", $type == 'add' ? $this->lang->words['l_added'] : $this->lang->words['l_edited']);
 }
 /**
  * Saves a custom field form
  *
  * @access	public
  * @param	string		Type (add|edit)
  * @return	void
  */
 public function mainSave($type = 'edit')
 {
     /* ID */
     $id = intval($this->request['id']);
     /* Custom Fields Class */
     require_once IPS_KERNEL_PATH . 'classCustomFields.php';
     $cfields_class = new classCustomFields(array());
     if (!$this->request['pf_title']) {
         $this->registry->output->showError($this->lang->words['cf_entertitle'], 11221);
     }
     //-----------------------------------------
     // check-da-motcha
     //-----------------------------------------
     if ($type == 'edit') {
         if (!$id) {
             $this->registry->output->showError($this->lang->words['cf_norow'], 11222);
         }
     }
     $content = "";
     if ($_POST['pf_content'] != "") {
         $content = $cfields_class->formatContentForSave($_POST['pf_content']);
     }
     $db_string = array('pf_title' => $this->request['pf_title'], 'pf_desc' => $this->request['pf_desc'], 'pf_content' => IPSText::stripslashes($content), 'pf_type' => $this->request['pf_type'], 'pf_not_null' => intval($this->request['pf_not_null']), 'pf_member_hide' => intval($this->request['pf_member_hide']), 'pf_max_input' => intval($this->request['pf_max_input']), 'pf_member_edit' => intval($this->request['pf_member_edit']), 'pf_position' => intval($this->request['pf_position']), 'pf_show_on_reg' => intval($this->request['pf_show_on_reg']), 'pf_input_format' => $this->request['pf_input_format'], 'pf_admin_only' => intval($this->request['pf_admin_only']), 'pf_topic_format' => IPSText::stripslashes($_POST['pf_topic_format']), 'pf_group_id' => intval($this->request['pf_group_id']), 'pf_icon' => trim($this->request['pf_icon']), 'pf_key' => trim($this->request['pf_key']));
     if ($type == 'edit') {
         $this->DB->update('pfields_data', $db_string, 'pf_id=' . $id);
         $this->registry->output->main_msg = $this->lang->words['cf_edited'];
     } else {
         $this->DB->insert('pfields_data', $db_string);
         $new_id = $this->DB->getInsertId();
         $this->DB->addField('pfields_content', "field_{$new_id}", 'text');
         $this->DB->optimize('pfields_content');
         $this->registry->output->main_msg = $this->lang->words['cf_added'];
     }
     $this->rebuildCache();
     $this->mainScreen();
 }
Beispiel #23
0
 /**
  * IP Address Tools index page
  *
  * @param 	string		Message to display
  * @param	string		Membername to default in the dropdown
  * @return	@e void		[Outputs to screen]
  */
 protected function _toolsIndex($msg = "", $membername = "")
 {
     if (!$membername) {
         $form = array('text' => $this->lang->words['t_entername'], 'form' => $this->registry->output->formInput("name", isset($_POST['name']) ? IPSText::stripslashes($_POST['name']) : ''));
     } else {
         $this->DB->build(array('select' => 'member_id, members_display_name', 'from' => 'members', 'where' => "members_l_username LIKE '{$membername}%' OR members_l_display_name LIKE '{$membername}%'"));
         $this->DB->execute();
         if (!$this->DB->getTotalRows()) {
             $msg = sprintf($this->lang->words['t_nomemberloc'], $membername);
             $form = array('text' => $this->lang->words['t_entername'], 'form' => $this->registry->output->formSimpleInput("name", isset($_POST['name']) ? IPSText::stripslashes($_POST['name']) : ''));
         } else {
             $mem_array = array();
             while ($m = $this->DB->fetch()) {
                 $mem_array[] = array($m['member_id'], $m['members_display_name']);
             }
             $form = array('text' => $this->lang->words['t_choosemem'], 'form' => $this->registry->output->formDropdown("member_id", $mem_array));
         }
     }
     $this->registry->output->html .= $this->html->toolsIndex($msg, $form);
 }
 /**
  * Suspend a member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberSuspendDo()
 {
     $this->request['member_id'] = intval($this->request['member_id']);
     if (!$this->request['member_id']) {
         $this->registry->output->showError($this->lang->words['m_specify'], 11232);
     }
     $member = IPSMember::load($this->request['member_id']);
     if (!$member['member_id']) {
         $this->registry->output->showError($this->lang->words['m_noid'], 11233);
     }
     //-----------------------------------------
     // Allowed to suspend administrators?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_suspend_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_suspadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Work out end date
     //-----------------------------------------
     $this->request['timespan'] = intval($this->request['timespan']);
     if ($this->request['timespan'] == "") {
         $new_ban = "";
     } else {
         $new_ban = IPSMember::processBanEntry(array('timespan' => intval($this->request['timespan']), 'unit' => $this->request['units']));
     }
     $show_ban = IPSMember::processBanEntry($new_ban);
     //-----------------------------------------
     // Update and show confirmation
     //-----------------------------------------
     IPSMember::save($member['member_id'], array('core' => array('temp_ban' => $new_ban)));
     // I say, did we choose to email 'dis member?
     if ($this->request['send_email']) {
         // By golly, we did!
         $msg = trim(IPSText::stripslashes($_POST['email_contents']));
         $msg = str_replace("{membername}", $member['members_display_name'], $msg);
         $msg = str_replace("{date_end}", ipsRegistry::getClass('class_localization')->getDate($show_ban['date_end'], 'LONG'), $msg);
         IPSText::getTextClass('email')->message = stripslashes(IPSText::getTextClass('email')->cleanMessage($msg));
         IPSText::getTextClass('email')->subject = $this->lang->words['m_acctsusp'];
         IPSText::getTextClass('email')->to = $member['email'];
         IPSText::getTextClass('email')->sendMail();
     }
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_susplog'], $member['members_display_name']));
     $this->registry->output->doneScreen($this->lang->words['m_suspended'], $this->lang->words['m_search'], "{$this->form_code}&amp;do=viewmember&amp;member_id={$member['member_id']}", "redirect");
 }
 /**
  * Show PM form
  *
  * @access	private
  * @param	array 		Array of errors
  * @return	string		returns HTML
  */
 private function _showNewTopicForm($errors = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     /* Check max per day */
     if ($this->messengerFunctions->checkHasHitMax()) {
         $this->registry->getClass('output')->showError('maxperday_hit', 10271);
     }
     /* Check PM flood */
     if ($this->messengerFunctions->floodControlCheck() !== TRUE) {
         $this->registry->getClass('output')->showError(sprintf($this->lang->words['pm_flood_stop'], $this->messengerFunctions->exceptionData[0]), 010271);
     }
     $_msg_id = 0;
     $formMemberID = intval($this->request['fromMemberID']);
     # WAS MID
     $topicID = intval($this->request['topicID']);
     $preview = $this->request['preview'];
     $inviteUsers = array();
     $displayData = array('errors' => $errors, 'topicID' => $topicID, 'preview' => '', 'name' => '', 'title' => '', 'message' => '');
     $_POST['Post-NS'] = isset($_POST['Post']) ? $_POST['Post'] : '';
     $_POST['Post'] = IPSText::removeMacrosFromInput(IPSText::raw2form(isset($_POST['Post']) ? $_POST['Post'] : ''));
     //-----------------------------------------
     // Preview post?
     //-----------------------------------------
     if ($preview) {
         /* Grab language for attachment previews */
         $this->registry->getClass('class_localization')->loadLanguageFile(array("public_topic"), 'forums');
         IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html'];
         IPSText::getTextClass('bbcode')->parse_nl2br = 1;
         IPSText::getTextClass('bbcode')->parse_smilies = 1;
         IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code'];
         IPSText::getTextClass('bbcode')->parsing_section = 'pms';
         IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id'];
         IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others'];
         $this->settings['max_emos'] = 0;
         $old_msg = IPSText::getTextClass('editor')->processRawPost('Post-NS');
         $old_msg = IPSText::getTextClass('bbcode')->preDisplayParse(IPSText::getTextClass('bbcode')->preDbParse($old_msg));
         if (!is_object($this->class_attach)) {
             //-----------------------------------------
             // Grab render attach class
             //-----------------------------------------
             require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
             $this->class_attach = new class_attach($this->registry);
         }
         //-----------------------------------------
         // Continue...
         //-----------------------------------------
         $this->class_attach->type = 'msg';
         $this->class_attach->attach_post_key = $this->_postKey;
         $this->class_attach->init();
         $attachData = $this->class_attach->renderAttachments(array(0 => $old_msg));
         $displayData['preview'] = $attachData[0]['html'] . $attachData[0]['attachmentHtml'];
     }
     //-----------------------------------------
     // Errors
     //-----------------------------------------
     if ($errors or IPSText::getTextClass('bbcode')->error != "") {
         if (IPSText::getTextClass('bbcode')->error) {
             $displayData['errors'][] = $this->lang->words[IPSText::getTextClass('bbcode')->error];
         }
         $preview = 1;
     }
     //-----------------------------------------
     // Did we come from a button with a user ID?
     //-----------------------------------------
     if ($formMemberID) {
         $name = IPSMember::load($formMemberID, 'core');
         if ($name['member_id']) {
             $displayData['name'] = $name['members_display_name'];
         }
     } else {
         $displayData['name'] = $this->request['entered_name'] ? $this->request['entered_name'] : '';
     }
     //-----------------------------------------
     // Are we quoting an old message?
     //-----------------------------------------
     if ($preview) {
         $displayData['message'] = $_POST['Post-NS'];
         $displayData['title'] = str_replace("'", "&#39;", str_replace('"', '&#34;', IPSText::stripslashes($_POST['msg_title'])));
     } else {
         if ($topicID) {
             $draftTopic = $this->messengerFunctions->fetchTopicDataWithMessage($topicID, TRUE);
             if ($draftTopic['mt_to_member_id']) {
                 $displayData['name'] = $draftTopic['from_name'];
             }
             if ($draftTopic['mt_title']) {
                 $_member = IPSMember::load($draftTopic['mt_to_member_id'], 'core');
                 $displayData['name'] = $_member['members_display_name'];
                 $displayData['title'] = $draftTopic['mt_title'];
                 $_msg_id = $draftTopic['msg_id'];
                 $this->_postKey = $draftTopic['msg_post_key'];
                 IPSText::getTextClass('bbcode')->parse_html = $this->settings['msg_allow_html'];
                 IPSText::getTextClass('bbcode')->parse_nl2br = 1;
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['msg_allow_code'];
                 IPSText::getTextClass('bbcode')->parsing_section = 'pms';
                 $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($draftTopic['msg_post']);
             }
         }
     }
     //-----------------------------------------
     // CC Boxes
     //-----------------------------------------
     if ($this->memberData['g_max_mass_pm'] > 0) {
         if ($_POST['inviteUsers']) {
             $displayData['inviteUsers'] = $_POST['inviteUsers'];
         } else {
             if ($draftTopic['mt_invited_members']) {
                 $_inviteUsers = $this->messengerFunctions->getInvitedUsers($draftTopic['mt_invited_members']);
                 $__inviteUsers = IPSMember::load($_inviteUsers, 'core');
                 if (is_array($__inviteUsers)) {
                     $_tmp = array();
                     foreach ($__inviteUsers as $id => $data) {
                         $_tmp[] = $data['members_display_name'];
                     }
                     if (is_array($_tmp)) {
                         $displayData['inviteUsers'] = implode(", ", $_tmp);
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Remove side panel
     //-----------------------------------------
     IPSText::getTextClass('editor')->remove_side_panel = 1;
     //-----------------------------------------
     // PM returns
     //-----------------------------------------
     if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message'] and $fromMsgID) {
         $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE(nl2br($displayData['message']));
     } else {
         if (IPSText::getTextClass('editor')->method == 'std' and $displayData['message'] and $fromMsgID) {
             $displayData['message'] = IPSText::getTextClass('bbcode')->preEditParse($displayData['message']);
         }
     }
     //-----------------------------------------
     // Is this RTE? If so, convert BBCode
     //-----------------------------------------
     if (IPSText::getTextClass('editor')->method == 'rte' and $displayData['message']) {
         if (count($errors) or $preview) {
             $displayData['message'] = stripslashes($displayData['message']);
         }
         $displayData['message'] = IPSText::getTextClass('bbcode')->convertForRTE($displayData['message']);
     } else {
         if ($displayData['message']) {
             $displayData['message'] = IPSText::stripslashes($displayData['message']);
         }
     }
     $displayData['editor'] = IPSText::getTextClass('editor')->showEditor($displayData['message'], 'Post');
     //-----------------------------------------
     // More Data...
     //-----------------------------------------
     $displayData['uploadData'] = $this->_canUpload ? array('canUpload' => 1) : array('canUpload' => 0);
     $displayData['postKey'] = $this->_postKey;
     //-----------------------------------------
     // Load attachments so we get some stats
     //-----------------------------------------
     require_once IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php';
     $class_attach = new class_attach($this->registry);
     $class_attach->type = 'msg';
     $class_attach->init();
     $class_attach->getUploadFormSettings();
     $displayData['uploadData']['attach_stats'] = $class_attach->attach_stats;
     //-----------------------------------------
     // Build up the HTML for the send form
     //-----------------------------------------
     $this->_title = $this->lang->words['sendMsgTitle'];
     $this->_navigation[] = array($this->lang->words['sendMsgTitle'], '');
     return $this->registry->getClass('output')->getTemplate('messaging')->sendNewPersonalTopicForm($displayData);
 }
 /**
  * Main class entry point
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @return	void		[Outputs to screen]
  */
 public function doExecute(ipsRegistry $registry)
 {
     //-----------------------------------------
     // Load skin
     //-----------------------------------------
     $this->html = $this->registry->output->loadTemplate('cp_skin_mycp');
     //-----------------------------------------
     // Load language
     //-----------------------------------------
     $this->registry->getClass('class_localization')->loadLanguageFile(array('admin_mycp'));
     //-----------------------------------------
     // Set up stuff
     //-----------------------------------------
     $this->form_code = $this->html->form_code = 'module=mycp&amp;section=dashboard';
     $this->form_code_js = $this->html->form_code_js = 'module=mycp&section=dashboard';
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     define('IPS_NEWS_URL', 'http://external./globalfeeds/news/');
     define('IPS_BULLETINS_URL', 'http://external./ipbfeeds/300/staffbulletin/');
     define('IPS_VERSION_CHECK_URL', 'http://www./latestversioncheck/ipb30x.php');
     $content = array();
     $thiscontent = "";
     $latest_version = array();
     $reg_end = "";
     $sm_install = 0;
     $lock_file = 0;
     $converter = 0;
     $fulltext_a = 0;
     $unfinished_upgrade = 0;
     $urls = array('news' => IPS_NEWS_URL, 'keiths_bits' => IPS_BULLETINS_URL, 'version_check' => IPS_VERSION_CHECK_URL, 'blogs' => 'http://external./globalfeeds/blog/');
     if (@file_exists(IPS_ROOT_PATH . 'install/index.php')) {
         $sm_install = 1;
     }
     if (@file_exists(DOC_IPS_ROOT_PATH . 'cache/installer_lock.php')) {
         $lock_file = 1;
     }
     if (@is_dir(IPS_ROOT_PATH . 'applications_addon/ips/convert/')) {
         $converter = 1;
         if (!@file_exists(DOC_IPS_ROOT_PATH . 'cache/converter_lock.php')) {
             $converter = 2;
         }
     }
     if ($this->DB->checkFulltextSupport()) {
         if (!$this->DB->getFulltextStatus('posts')) {
             $fulltext_a = 1;
         }
     }
     require_once IPS_ROOT_PATH . '/setup/sources/base/setup.php';
     $versions = IPSSetUp::fetchAppVersionNumbers('core');
     if ($versions['current'][0] != $versions['latest'][0]) {
         $unfinished_upgrade = 1;
     }
     //-----------------------------------------
     // Get MySQL & PHP Version
     //-----------------------------------------
     $this->DB->getSqlVersion();
     //-----------------------------------------
     // Upgrade history?
     //-----------------------------------------
     $latest_version = array('upgrade_version_id' => NULL);
     $this->DB->build(array('select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $latest_version = $r;
     }
     //-----------------------------------------
     // Resetting security image?
     //-----------------------------------------
     if ($this->request['reset_security_flag'] and $this->request['reset_security_flag'] == 1 and $this->request['new_build']) {
         $_latest = IPSLib::fetchVersionNumber('core');
         $new_build = intval($this->request['new_build']);
         $new_reason = trim(substr($this->request['new_reason'], 0, 1));
         $new_version = $_latest['long'] . '.' . $new_build . '.' . $new_reason;
         $this->DB->update('upgrade_history', array('upgrade_notes' => $new_version), 'upgrade_version_id=' . $latest_version['upgrade_version_id']);
         $latest_version['upgrade_notes'] = $new_version;
     }
     //-----------------------------------------
     // Got real version number?
     //-----------------------------------------
     ipsRegistry::$version = 'v' . $latest_version['upgrade_version_human'];
     ipsRegistry::$vn_full = (isset($latest_version['upgrade_notes']) and $latest_version['upgrade_notes']) ? $latest_version['upgrade_notes'] : ipsRegistry::$vn_full;
     //-----------------------------------------
     // Licensed?
     //-----------------------------------------
     $urls['keiths_bits'] = IPS_BULLETINS_URL . '?v=' . ipsRegistry::$vn_full;
     //-----------------------------------------
     // Notepad
     //-----------------------------------------
     if ($this->request['save'] and $this->request['save'] == 1) {
         $_POST['notes'] = $_POST['notes'] ? $_POST['notes'] : $this->lang->words['cp_acpnotes'];
         $this->cache->setCache('adminnotes', IPSText::stripslashes($_POST['notes']), array('donow' => 1, 'deletefirst' => 0, 'array' => 0));
     }
     $text = $this->lang->words['cp_acpnotes'];
     if (!$this->cache->getCache('adminnotes') or !$this->cache->getCache('adminnotes')) {
         $this->cache->setCache('adminnotes', $text, array('donow' => 1, 'deletefirst' => 0, 'array' => 0));
     }
     $this->cache->updateCacheWithoutSaving('adminnotes', htmlspecialchars($this->cache->getCache('adminnotes'), ENT_QUOTES));
     $this->cache->updateCacheWithoutSaving('adminnotes', str_replace("&amp;#", "&#", $this->cache->getCache('adminnotes')));
     $content['ad_notes'] = $this->html->acp_notes($this->cache->getCache('adminnotes'));
     //-----------------------------------------
     // ADMINS USING CP
     //-----------------------------------------
     $t_time = time() - 60 * 10;
     $time_now = time();
     $seen_name = array();
     $acponline = "";
     $this->DB->build(array('select' => 's.session_member_name, s.session_member_id, s.session_location, s.session_log_in_time, s.session_running_time, s.session_ip_address, s.session_url', 'from' => array('core_sys_cp_sessions' => 's'), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => "m.member_id=s.session_member_id", 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'))));
     $q = $this->DB->execute();
     while ($r = $this->DB->fetch($q)) {
         if (isset($seen_name[$r['session_member_name']]) and $seen_name[$r['session_member_name']] == 1) {
             continue;
         } else {
             $seen_name[$r['session_member_name']] = 1;
         }
         $r['_log_in'] = $time_now - $r['session_log_in_time'];
         $r['_click'] = $time_now - $r['session_running_time'];
         if ($r['_log_in'] / 60 < 1) {
             $r['_log_in'] = sprintf("%0d", $r['_log_in']) . $this->lang->words['cp_secondsago'];
         } else {
             $r['_log_in'] = sprintf("%0d", $r['_log_in'] / 60) . $this->lang->words['cp_minutesago'];
         }
         if ($r['_click'] / 60 < 1) {
             $r['_click'] = sprintf("%0d", $r['_click']) . $this->lang->words['cp_secondsago'];
         } else {
             $r['_click'] = sprintf("%0d", $r['_click'] / 60) . $this->lang->words['cp_minutesago'];
         }
         $r['session_location'] = $r['session_location'] ? "<a href='" . preg_replace('/&amp;app=([a-zA-Z0-9\\-_]+)/', '', $this->settings['base_url']) . $r['session_url'] . "'>{$r['session_location']}</a>" : $this->lang->words['cp_index'];
         $acponline .= $this->html->acp_onlineadmin_row(IPSMember::buildDisplayData($r));
     }
     $content['acp_online'] = $this->html->acp_onlineadmin_wrapper($acponline);
     //-----------------------------------------
     // Stats
     //-----------------------------------------
     $reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => array('validating' => 'v'), 'where' => 'v.lost_pass <> 1 AND m.member_group_id=' . $this->settings['auth_group'], 'add_join' => array(array('from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id', 'type' => 'left'))));
     if ($this->settings['ipb_bruteforce_attempts']) {
         $lock = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as mems', 'from' => 'members', 'where' => 'failed_login_count >= ' . $this->settings['ipb_bruteforce_attempts']));
     }
     $coppa = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as coppa', 'from' => 'validating', 'where' => 'coppa_user=1'));
     $my_timestamp = time() - $this->settings['au_cutoff'] * 60;
     $online = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as sessions', 'from' => 'sessions', 'where' => 'running_time>' . $my_timestamp));
     $pending = $this->DB->buildAndFetch(array('select' => 'SUM(queued_topics) as topics, SUM(queued_posts) as posts', 'from' => 'forums'));
     $spammers = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count, MAX(joined) as joined', 'from' => 'members', 'where' => "members_bitoptions = '1'"));
     $content['stats'] = $this->html->acp_stats_wrapper(array('topics' => intval($this->caches['stats']['total_topics']), 'replies' => intval($this->caches['stats']['total_replies']), 'topics_mod' => intval($pending['topics']), 'posts_mod' => intval($pending['posts']), 'members' => intval($this->caches['stats']['mem_count']), 'validate' => intval($reg['reg']), 'spammer' => array(intval($spammers['count']), intval($spammers['joined'])), 'locked' => intval($lock['mems']), 'coppa' => intval($coppa['coppa']), 'sql_driver' => strtoupper(SQL_DRIVER), 'sql_version' => $this->DB->true_version, 'php_version' => phpversion(), 'sessions' => intval($online['sessions']), 'php_sapi' => @php_sapi_name(), 'ipb_version' => ipsRegistry::$version, 'ipb_id' => ipsRegistry::$vn_full));
     //-----------------------------------------
     // Members awaiting admin validation?
     //-----------------------------------------
     if ($this->settings['reg_auth_type'] == 'admin_user' or $this->settings['reg_auth_type'] == 'admin') {
         $where_extra = $this->settings['reg_auth_type'] == 'admin_user' ? ' AND user_verified=1' : '';
         $admin_reg = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as reg', 'from' => 'validating', 'where' => 'new_reg=1' . $where_extra));
         if ($admin_reg['reg'] > 0) {
             // We have some member's awaiting admin validation
             $data = null;
             $this->DB->build(array('select' => 'v.*', 'from' => array('validating' => 'v'), 'where' => 'new_reg=1' . $where_extra, 'limit' => array(3), 'add_join' => array(array('type' => 'left', 'select' => 'm.members_display_name, m.email, m.ip_address', 'from' => array('members' => 'm'), 'where' => 'm.member_id=v.member_id'))));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 if ($r['coppa_user'] == 1) {
                     $r['_coppa'] = ' ( COPPA )';
                 } else {
                     $r['_coppa'] = "";
                 }
                 $r['_entry'] = $this->registry->getClass('class_localization')->getDate($r['entry_date'], 'TINY');
                 $data .= $this->html->acp_validating_block($r);
             }
             $content['validating'] = $this->html->acp_validating_wrapper($data);
         }
     }
     //-----------------------------------------
     // Forum and group dropdowns
     //-----------------------------------------
     require_once IPSLib::getAppDir('forums') . '/sources/classes/forums/class_forums.php';
     $this->registry->setClass('class_forums', new class_forums($this->registry));
     $this->registry->getClass('class_forums')->forumsInit();
     $forums = $this->registry->getClass('class_forums')->forumsForumJump(1);
     $groups = array();
     $groups_html = '';
     foreach ($this->cache->getCache('group_cache') as $k => $v) {
         $groups[$v['g_title']] = "<option value='{$k}'>{$v['g_title']}</option>";
     }
     ksort($groups);
     $groups_html = implode("\n", $groups);
     //-----------------------------------------
     // Piece it together
     //-----------------------------------------
     $urls['version_check'] = IPS_VERSION_CHECK_URL . '?' . base64_encode(ipsRegistry::$vn_full . '|^|' . $this->settings['board_url']);
     $this->registry->output->html .= $this->html->mainTemplate($content, $forums, $groups_html, $urls);
     //-----------------------------------------
     // FURL cache OOD?
     //-----------------------------------------
     if (file_exists(IPS_CACHE_PATH . 'cache/furlCache.php')) {
         $mtime = intval(@filemtime(IPS_CACHE_PATH . 'cache/furlCache.php'));
         /* Check mtimes on extensions.. */
         foreach (ipsRegistry::$applications as $app_dir => $application) {
             if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/furlTemplates.php')) {
                 $_mtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/extensions/furlTemplates.php'));
                 if ($_mtime > $mtime) {
                     $_html = $this->html->warning_box($this->lang->words['furlcache_outofdate'], "<a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=seoRebuild'>{$this->lang->words['rebuild_furl_cache']}</a>") . "<br />";
                     $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
                     break;
                 }
             }
         }
     }
     //-----------------------------------------
     // Minify on but /cache/tmp not writeable?
     //-----------------------------------------
     if (isset($this->settings['_use_minify']) and $this->settings['_use_minify']) {
         $_html = $this->html->warning_box($this->lang->words['minifywrite_head'], $this->lang->words['minifynot_writeable']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     //-----------------------------------------
     // Left log all on?
     //-----------------------------------------
     if (IPS_LOG_ALL === TRUE) {
         $_html = $this->html->warning_box($this->lang->words['ds_log_all_title'], $this->lang->words['ds_log_all_desc']) . "<br />";
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html . '<!--in_dev_check-->', $this->registry->output->html);
     }
     if (count($tasksContent)) {
         $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
     }
     //-----------------------------------------
     // IN DEV stuff...
     //-----------------------------------------
     if (IN_DEV) {
         $lastUpdate = $this->caches['indev'];
         $lastUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('settings' => array()));
         $lastModUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('modules' => array()));
         $lastTaskUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('tasks' => array()));
         $lastHelpUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('help' => array()));
         $lastbbUpdate = is_array($lastUpdate) ? $lastUpdate : array('import' => array('bbcode' => array()));
         $content = array();
         $modContent = array();
         $tasksContent = array();
         $helpContent = array();
         $bbContent = array();
         $apps = new IPSApplicationsIterator();
         $_html = '';
         foreach ($apps as $app) {
             $app_dir = $apps->fetchAppDir();
             /* Settings */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml'));
             $lastDBtime = intval($lastUpdate['import']['settings'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $content[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_settingsupdated']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Modules */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_modules.xml'));
             $lastDBtime = intval($lastUpdate['import']['modules'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $modContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_modulessneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Tasks */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_tasks.xml'));
             $lastDBtime = intval($lastUpdate['import']['tasks'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $tasksContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_taskssneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* Help Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_help.xml'));
             $lastDBtime = intval($lastUpdate['import']['help'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $helpContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_helpneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
             /* BBCode Files */
             $lastMtime = intval(@filemtime(IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_bbcode.xml'));
             $lastDBtime = intval($lastUpdate['import']['bbcode'][$app_dir]);
             if ($lastMtime > $lastDBtime) {
                 $_mtime = $this->registry->getClass('class_localization')->getDate($lastMtime, 'JOINED');
                 $_dbtime = $this->registry->getClass('class_localization')->getDate($lastDBtime, 'JOINED');
                 $bbContent[] = "<strong>" . $app['app_title'] . " {$this->lang->words['cp_bbcodeneedup']}.</strong><br />-- {$this->lang->words['cp_lastimportrun']}: {$_dbtime}<br />-- {$this->lang->words['cp_lastxmlexport']}: {$_mtime}";
             }
         }
         if (count($content)) {
             $_html = $this->html->warning_box($this->lang->words['cp_settingsneedup'], implode($content, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=settings&amp;do=settingsImportApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($modContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_modulessneedup'], implode($modContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=applications&amp;section=applications&amp;do=inDevRebuildAll'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($tasksContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_taskssneedup'], implode($tasksContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=system&amp;section=taskmanager&amp;do=tasksImportAllApps'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($helpContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_helpneedup'], implode($helpContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=tools&amp;section=help&amp;do=importXml'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         if (count($bbContent)) {
             $_html .= $this->html->warning_box($this->lang->words['cp_bbcodeneedup'], implode($bbContent, "<br />") . "<br /><a href='" . $this->settings['base_url'] . "app=core&amp;module=posts&amp;section=bbcode&amp;do=bbcode_import_all'>{$this->lang->words['cp_clickhere']}</a> {$this->lang->words['cp_clickhere_info']}.");
         }
         $this->registry->output->html = str_replace('<!--in_dev_check-->', $_html, $this->registry->output->html);
         if (@file_exists(DOC_IPS_ROOT_PATH . '_dev_notes.txt')) {
             $_notes = @file_get_contents(DOC_IPS_ROOT_PATH . '_dev_notes.txt');
             if ($_notes) {
                 $_html = $this->registry->output->global_template->information_box($this->lang->words['cp_devnotes'], nl2br($_notes)) . "<br />";
                 $this->registry->output->html = str_replace('<!--in_dev_notes-->', $_html, $this->registry->output->html);
             }
         }
     }
     //-----------------------------------------
     // INSTALLER PRESENT?
     //-----------------------------------------
     if ($sm_install == 1) {
         if ($lock_file != 1) {
             $installer = $this->html->warning_box($this->lang->words['cp_unlockedinstaller'], $this->html->warning_unlocked_installer()) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         } else {
             $installer = $this->html->warning_box($this->lang->words['cp_installerpresent'], $this->html->warning_installer()) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         }
     } else {
         if ($converter) {
             $text = $converter == 2 ? $this->lang->words['cp_unlocked_converter'] : $this->lang->words['cp_converterpresent'];
             $installer = $this->html->warning_box($text, $this->html->warning_converter($converter)) . "<br />";
             $this->registry->output->html = str_replace('<!--warninginstaller-->', $installer, $this->registry->output->html);
         }
     }
     //-----------------------------------------
     // UNFINISHED UPGRADE?
     //-----------------------------------------
     if ($unfinished_upgrade == 1) {
         $this->lang->words['cp_upgrade_warning'] = sprintf($this->lang->words['cp_upgrade_warning'], $versions['current'][1], $versions['latest'][1], $this->settings['base_acp_url']);
         $upgrade = $this->html->warning_box($this->lang->words['cp_unfinishedupgrade'], $this->html->warning_upgrade()) . "<br />";
         $this->registry->output->html = str_replace('<!--warningupgrade-->', $upgrade, $this->registry->output->html);
     }
     //-----------------------------------------
     // INSUFFICIENT PHP VERSION?
     //-----------------------------------------
     if (PHP_VERSION < '5.1.0') {
         $version = $this->html->warning_box(sprintf($this->lang->words['cp_yourphpversion'], PHP_VERSION), $this->html->acp_php_version_warning()) . "<br />";
         $this->registry->output->html = str_replace('<!--phpversioncheck-->', $version, $this->registry->output->html);
     }
     //-----------------------------------------
     // BOARD OFFLINE?
     //-----------------------------------------
     if ($this->settings['board_offline']) {
         $offline = $this->html->warning_box($this->lang->words['cp_boardoffline'], "{$this->lang->words['cp_boardoffline1']}<br /><br />&raquo; <a href='" . $this->settings['base_url'] . "&amp;module=tools&amp;section=settings&amp;do=findsetting&amp;key=boardoffline'>{$this->lang->words['cp_boardoffline2']}</a>") . "<br />";
         $this->registry->output->html = str_replace('<!--boardoffline-->', $offline, $this->registry->output->html);
     }
     //-----------------------------------------
     // No fulltext
     //-----------------------------------------
     if ($this->settings['search_method'] == 'traditional' and !$this->settings['use_fulltext'] and !$this->settings['hide_ftext_note']) {
         $ftext = $this->html->warning_box($this->lang->words['fulltext_off'], "{$this->lang->words['fulltext_turnon']}<br /><br />&raquo; <a href='" . $this->settings['base_url'] . "&amp;module=tools&amp;section=settings&amp;do=findsetting&amp;key=searchsetup'>{$this->lang->words['fulltext_find']}</a>") . "<br />";
         $this->registry->output->html = str_replace('<!--fulltext-->', $ftext, $this->registry->output->html);
     }
     //-----------------------------------------
     // Last 5 log in attempts
     //-----------------------------------------
     $this->registry->getClass('class_permissions')->return = true;
     if ($this->registry->getClass('class_permissions')->checkPermission('acplogin_log')) {
         $this->DB->build(array('select' => '*', 'from' => 'admin_login_logs', 'order' => 'admin_time DESC', 'limit' => array(0, 5)));
         $this->DB->execute();
         while ($rowb = $this->DB->fetch()) {
             $rowb['_admin_time'] = $this->registry->class_localization->getDate($rowb['admin_time'], 'long');
             $rowb['_admin_img'] = $rowb['admin_success'] ? 'aff_tick.png' : 'aff_cross.png';
             $logins .= $this->html->acp_last_logins_row($rowb);
         }
         $this->registry->output->html = str_replace('<!--acplogins-->', $this->html->acp_last_logins_wrapper($logins), $this->registry->output->html);
     }
     //-----------------------------------------
     // Pass to CP output hander
     //-----------------------------------------
     $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
     $this->registry->getClass('output')->sendOutput();
 }
 /**
  * Save a bbcode [add|edit]
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 protected function _bbcodeSave($type = 'add')
 {
     if ($type == 'edit') {
         if (!$this->request['id']) {
             $this->registry->output->global_message = $this->lang->words['no_bbcode_found_edit'];
             $this->_bbcodeForm($type);
             return;
         }
         $bbcode = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_id=' . intval($this->request['id'])));
         if (!$bbcode['bbcode_id']) {
             $this->registry->output->showError($this->lang->words['no_bbcode_found_edit'], 111162);
         }
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id'] && $duplicate['bbcode_id'] != $this->request['id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 if ($row['bbcode_id'] == $this->request['id']) {
                     continue;
                 }
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     } else {
         $bbcode = array();
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Fix BR tags
     //-----------------------------------------
     $this->request['bbcode_aliases'] = str_replace(array(' ', "\n"), '', IPSText::br2nl($this->request['bbcode_aliases']));
     //-----------------------------------------
     // check...
     //-----------------------------------------
     if (!$this->request['bbcode_title'] or !$this->request['bbcode_tag'] or !$this->request['bbcode_replace'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['complete_form'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!$this->request['bbcode_single_tag'] and !strstr($this->request['bbcode_replace'], '{content}') and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_content'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!strstr($this->request['bbcode_replace'], '{option}') and $this->request['bbcode_useoption'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_option'];
         $this->_bbcodeForm($type);
         return;
     }
     if (preg_match("/[^a-zA-Z0-9_]/", $this->request['bbcode_tag'])) {
         $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
         $this->_bbcodeForm($type);
         return;
     }
     $_aliases = explode(",", $this->request['bbcode_aliases']);
     foreach ($_aliases as $_alias) {
         if (preg_match("/[^a-zA-Z0-9_]/", $_alias)) {
             $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
             $this->_bbcodeForm($type);
             return;
         }
     }
     $array = array('bbcode_title' => $this->request['bbcode_title'], 'bbcode_desc' => IPSText::safeslashes($_POST['bbcode_desc']), 'bbcode_tag' => preg_replace("/[^a-zA-Z0-9_]/", "", $this->request['bbcode_tag']), 'bbcode_replace' => IPSText::safeslashes($_POST['bbcode_replace']), 'bbcode_example' => IPSText::safeslashes($_POST['bbcode_example']), 'bbcode_useoption' => $this->request['bbcode_useoption'], 'bbcode_switch_option' => intval($this->request['bbcode_switch_option']), 'bbcode_menu_option_text' => trim($this->request['bbcode_menu_option_text']), 'bbcode_menu_content_text' => trim($this->request['bbcode_menu_content_text']), 'bbcode_single_tag' => intval($this->request['bbcode_single_tag']), 'bbcode_groups' => is_array($this->request['bbcode_groups']) ? implode(',', $this->request['bbcode_groups']) : '', 'bbcode_sections' => is_array($this->request['bbcode_sections']) ? implode(',', $this->request['bbcode_sections']) : '', 'bbcode_php_plugin' => trim($this->request['bbcode_php_plugin']), 'bbcode_no_parsing' => intval($this->request['bbcode_no_parsing']), 'bbcode_optional_option' => intval($this->request['bbcode_optional_option']), 'bbcode_aliases' => $this->request['bbcode_aliases'], 'bbcode_image' => $this->request['bbcode_image'], 'bbcode_app' => $this->request['bbcode_app'], 'bbcode_protected' => intval($this->request['bbcode_protected']), 'bbcode_custom_regex' => str_replace("&#092;", '\\', IPSText::stripslashes($_POST['bbcode_custom_regex'])));
     if ($type == 'add') {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}'"));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         $this->DB->insert('custom_bbcode', $array);
         $this->registry->output->global_message = $this->lang->words['new_bbcode'];
     } else {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}' AND bbcode_id<>" . intval($this->request['id'])));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         if ($this->request['drop_cache']) {
             IPSContentCache::truncate();
         }
         $this->DB->update('custom_bbcode', $array, 'bbcode_id=' . intval($this->request['id']));
         $this->registry->output->global_message = $this->lang->words['edited_bbcode'];
     }
     $this->bbcodeRebuildCache();
     $this->_bbcodeStart();
 }
Beispiel #28
0
 /**
  * Lock/unlock a plugin
  *
  * @return	@e void
  */
 public function _changePlugin()
 {
     $this->registry->output->extra_nav[] = array("{$this->settings['base_url']}{$this->form_code}&do=plugin", $this->lang->words['r_plugmanager']);
     $plug_id = intval($this->request['com_id']);
     //-----------------------------------------
     // Make sure plugin ID is > than zero...
     //-----------------------------------------
     if ($plug_id < 1) {
         $this->registry->output->global_error = $this->lang->words['r_noid'];
         $this->_showPluginIndex();
         return;
     }
     //-----------------------------------------
     // Load basic, very basic, information...
     //-----------------------------------------
     $plug_data = $this->DB->buildAndFetch(array('select' => 'com_id, my_class, class_title, class_desc, author, author_url, pversion', 'from' => 'rc_classes', 'where' => "com_id='{$plug_id}'"));
     //-----------------------------------------
     // Does our plugin even exist...?
     //-----------------------------------------
     if (!$plug_data['com_id']) {
         $this->registry->output->global_error = $this->lang->words['r_plugnoexist'];
         $this->_showPluginIndex();
         return;
     }
     //-----------------------------------------
     // Can we even change this plugin?
     //-----------------------------------------
     if ($plug_data['lockd'] > 0 && !IN_DEV) {
         $this->registry->output->global_error = $this->lang->words['r_pluglocked'];
         $this->_showPluginIndex();
         return;
     }
     //-----------------------------------------
     // Let's start loading stuff...!
     //-----------------------------------------
     if ($plug_data['my_class'] == '') {
         $plug_data['my_class'] = 'default';
     }
     if ($_POST['finish'] == 1) {
         //-----------------------------------------
         // The form got sent, so lets go!
         //-----------------------------------------
         if (!$_POST['plugi_title'] || !$_POST['plugi_desc'] || !$_POST['plugi_file']) {
             $this->registry->output->global_error = $this->lang->words['r_missingfield'];
         } elseif (preg_match("/[^a-z0-9_\\-]/i", $_POST['plugi_file'])) {
             $this->registry->output->global_error = $this->lang->words['r_incchar'];
         }
         $build_plugin = array('class_title' => $this->request['plugi_title'], 'class_desc' => IPSText::stripslashes($_POST['plugi_desc']), 'author' => $this->request['plugi_author'], 'author_url' => $this->request['plugi_author_url'], 'my_class' => $this->request['plugi_file'], 'pversion' => 'v' . strval($this->request['plugi_version']), 'lockd' => intval($this->request['plugi_lockd']));
         //-----------------------------------------
         // If file was changed blank out extra...
         //-----------------------------------------
         if ($plug_data['my_class'] != $build_plugin['my_class']) {
             $build_plugin['extra_data'] = '';
             $do_edit = true;
         }
         if (!$this->registry->output->global_error) {
             $this->DB->update('rc_classes', $build_plugin, "com_id={$plug_id}");
             if ($do_edit == true) {
                 //-----------------------------------------
                 // Plugin was changed, need settings now
                 //-----------------------------------------
                 $this->registry->output->global_message = $this->lang->words['r_plugupdated'];
                 $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . "&amp;do=edit_plugin&amp;com_id=" . $plug_id);
             } else {
                 //-----------------------------------------
                 // File was not changed, no need to edit..
                 //-----------------------------------------
                 $this->registry->output->global_message = $this->lang->words['r_plugupdated'];
                 $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . "&amp;do=plugin");
             }
         } else {
             $plug_data = $build_plugin;
         }
     }
     //-----------------------------------------
     // Basic info for when I hit "Save"...
     //-----------------------------------------
     $this->registry->output->html .= $this->html->pluginForm($plug_data);
 }
Beispiel #29
0
 /**
  * Show the edit bulk mail form
  *
  * @param	string		[add|edit]
  * @param	array		Error messages
  * @return	@e void
  */
 protected function _mailForm($type = 'add', $errors = array())
 {
     //-----------------------------------------
     // Init some values
     //-----------------------------------------
     $id = intval($this->request['id']);
     if ($type == 'add') {
         $mail = array();
     } else {
         $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $this->request['id']));
     }
     if ($this->request['mail_groups']) {
         $mail['mail_groups'] = $this->request['mail_groups'];
     }
     //-----------------------------------------
     // Format mail content
     //-----------------------------------------
     $mail_content = $_POST['mail_content'] ? IPSText::stripslashes($_POST['mail_content']) : $mail['mail_content'];
     $mail_content = preg_replace("[^\r]\n", "\r\n", $mail_content);
     if (!$mail_content and $type == 'add') {
         $mail_content = $this->_getDefaultMailContents();
     }
     /* Bug report #39173 */
     $mail_content = IPSText::htmlspecialchars($mail_content);
     //-----------------------------------------
     // Get Filters
     //-----------------------------------------
     $opts = unserialize($mail['mail_opts']);
     $id = 1;
     $filters = array();
     foreach (IPSLib::getEnabledApplications() as $app) {
         $extensionFile = IPSLib::getAppDir($app['app_directory']) . '/extensions/bulkMailFilters.php';
         if (file_exists($extensionFile)) {
             $classToLoad = IPSLib::loadLibrary($extensionFile, 'bulkMailFilters_' . $app['app_directory']);
             $class = new $classToLoad($this->registry);
             $filters[$id] = array('appName' => $app['app_title'], 'appKey' => $app['app_directory'], 'filters' => array());
             foreach ($class->filters as $f) {
                 $classToLoad = IPSLib::loadLibrary($extensionFile, "bulkMailFilter_{$app['app_directory']}_{$f}");
                 $_class = new $classToLoad($this->registry);
                 $filters[$id]['filters'][] = array('title' => $this->lang->words["bulkMailFilter_{$app['app_directory']}_{$f}"], 'field' => $_class->getSettingField($opts['filters'][$app['app_directory']][$f]));
             }
             $id++;
         }
     }
     /* We want the members tab to be first so it shows groups, which will be the most common filter */
     uasort($filters, create_function('$a, $b', 'if ( $a[\'appKey\'] == "members" ) { return -1; } else { return 0; }'));
     //-----------------------------------------
     // Output
     //-----------------------------------------
     $this->registry->output->html .= $this->html->mailForm($type, $mail, $mail_content, $filters, $errors);
 }
 /**
  * Show the edit bulk mail form
  *
  * @access	private
  * @param	string		[add|edit]
  * @return	void
  */
 private function _mailForm($type = 'add')
 {
     //-----------------------------------------
     // Init some values
     //-----------------------------------------
     $id = intval($this->request['id']);
     if ($type == 'add') {
         $mail = array();
     } else {
         $mail = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'bulk_mail', 'where' => 'mail_id=' . $this->request['id']));
     }
     if ($this->request['mail_groups']) {
         $mail['mail_groups'] = $this->request['mail_groups'];
     }
     //-----------------------------------------
     // Format mail content
     //-----------------------------------------
     $mail_content = $_POST['mail_content'] ? IPSText::stripslashes($_POST['mail_content']) : $mail['mail_content'];
     $mail_content = preg_replace("[^\r]\n", "\r\n", $mail_content);
     if (!$mail_content and $type == 'add') {
         $mail_content = $this->_getDefaultMailContents();
     }
     $mail_content = htmlspecialchars($mail_content, ENT_QUOTES);
     $this->registry->output->html .= $this->html->mailForm($type, $mail, $mail_content);
 }