/** * Class entry point * * @access public * @param object Registry reference * @return void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { $this->registry->class_localization->loadLanguageFile(array('public_profile')); /* INIT */ $member_id = intval($this->request['mid']); //----------------------------------------- // Can we access? //----------------------------------------- if (!$this->memberData['g_mem_info']) { $this->returnString('error'); } if (!$member_id) { $this->returnString('error'); } $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups,basic', 'id'); if (!$member['member_id']) { $this->returnString('error'); } $this->registry->class_localization->loadLanguageFile(array('public_online'), 'members'); $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile')); $member = IPSMember::getLocation($member); $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies']; if ($member['posts'] and $board_posts) { $member['_posts_day'] = round($member['posts'] / ((time() - $member['joined']) / 86400), 2); # Fix the issue when there is less than one day $member['_posts_day'] = $member['_posts_day'] > $member['posts'] ? $member['posts'] : $member['_posts_day']; $member['_total_pct'] = sprintf('%.2f', $member['posts'] / $board_posts * 100); } $member['_posts_day'] = floatval($member['_posts_day']); $this->returnHtml($this->registry->getClass('output')->getTemplate('profile')->showCard($member)); }
/** * Process Results * * @param array Row from database using query specified in fetch() * @return array Same data with any additional processing necessary */ public function process($row) { /* Build poster's display data */ $member = $row['author_id'] ? IPSMember::load($row['author_id'], 'profile_portal,pfields_content,sessions,groups', 'id') : IPSMember::setUpGuest(); $row = array_merge($row, IPSMember::buildDisplayData($member, array('reputation' => 0, 'warn' => 0))); /* Get forum data (damn HTML >.<) */ $forumData = ipsRegistry::getClass('class_forums')->getForumById($row['forum_id']); /* Parse BBCode */ IPSText::getTextClass('bbcode')->parse_smilies = $row['use_emo']; IPSText::getTextClass('bbcode')->parse_html = ($forumData['use_html'] and $member['g_dohtml'] and $row['post_htmlstate']) ? 1 : 0; IPSText::getTextClass('bbcode')->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'topics'; IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others']; $row['post'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['post']); /* Parse attachments */ $messageHTML = array($row['pid'] => $row['post']); $attachHTML = $this->class_attach->renderAttachments($messageHTML, array($row['pid'])); if (is_array($attachHTML) and count($attachHTML)) { /* Get rid of any lingering attachment tags */ if (stristr($attachHTML[$row['pid']]['html'], "[attachment=")) { $attachHTML[$row['pid']]['html'] = IPSText::stripAttachTag($attachHTML[$row['pid']]['html']); } $row['post'] = $attachHTML[$row['pid']]['html'] . $attachHTML[$row['pid']]['attachmentHtml']; } /* Get rep buttons */ if ($row['repUserGiving'] == ipsRegistry::member()->getProperty('member_id')) { $row['has_given_rep'] = $row['rep_rating']; } $row['rep_points'] = ipsRegistry::getClass('repCache')->getRepPoints(array('app' => 'forums', 'type' => 'pid', 'type_id' => $row['pid'], 'rep_points' => $row['rep_points'])); $row['repButtons'] = ipsRegistry::getClass('repCache')->getLikeFormatted(array('app' => 'forums', 'type' => 'pid', 'id' => $row['pid'], 'rep_like_cache' => $row['rep_like_cache'])); /* Return */ return $row; }
/** * Class entry point * * @access public * @param object Registry reference * @return void [Outputs to screen/redirects] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // INIT //----------------------------------------- $info = array(); $id = intval($this->request['id']); //----------------------------------------- // Get HTML and skin //----------------------------------------- $this->registry->class_localization->loadLanguageFile(array('public_profile'), 'members'); //----------------------------------------- // Can we access? //----------------------------------------- if (!$this->memberData['g_mem_info']) { $this->registry->output->showError('photos_profiles_off', 10242); } if (!$id) { $this->registry->output->showError('photos_no_id', 10243); } $member = IPSMember::load($id); $member = IPSMember::buildDisplayData($member); $html = $this->registry->getClass('output')->getTemplate('profile')->showPhoto($member); //----------------------------------------- // Push to print handler //----------------------------------------- $this->registry->getClass('output')->setTitle($this->lang->words['photo_title']); $this->registry->getClass('output')->popUpWindow($html); }
/** * Remove user's photo * * @return @e void [Outputs to screen] */ protected function remove_photo() { //----------------------------------------- // INIT //----------------------------------------- $member_id = intval($this->request['member_id']); //----------------------------------------- // Get member //----------------------------------------- $member = IPSMember::load($member_id); if (!$member['member_id']) { $this->returnJsonError($this->lang->words['m_noid']); exit; } //----------------------------------------- // Allowed to upload pics for administrators? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_photo_admin', 'members', 'members')) { $this->returnJsonError($this->lang->words['m_editadmin']); exit; } $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo'); $photos = new $classToLoad($this->registry); $photos->remove($member_id); ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_imgremlog'], $member_id)); $member = IPSMember::load($member_id); $member = IPSMember::buildDisplayData($member, 0); //----------------------------------------- // Return //----------------------------------------- $this->returnJsonArray(array('success' => 1, 'pp_main_photo' => $member['pp_main_photo'], 'pp_main_width' => $member['pp_main_width'], 'pp_main_height' => $member['pp_main_height'])); }
public function getOutput() { /* INIT */ $time_high = time(); $ids = array(); $rows = array(); $time_low = $time_high - 60 * 60 * 24; $todays_posts = 0; $store = array(); /* List of forum ids */ foreach (ipsRegistry::getClass('class_forums')->forum_by_id as $id => $data) { if (!isset($data['inc_postcount']) || !$data['inc_postcount']) { continue; } $ids[] = $id; } /* Found some forums? */ if (count($ids)) { /* Total Posts Today */ /*$total_today = $this->DB->buildAndFetch( array( 'select' => 'count(*) as cnt', 'from' => array( 'posts' => 'p' ), 'where' => "p.post_date > {$time_low} AND t.forum_id IN(" . implode( ",", $ids ) . ")", 'add_join' => array( array( 'from' => array( 'topics' => 't' ), 'where' => 't.tid=p.topic_id', 'type' => 'left' ) ) ) );*/ /* Query the top posters */ $this->DB->build(array('select' => 'COUNT(*) as tpost', 'from' => array('posts' => 'p'), 'where' => "p.post_date > {$time_low} AND t.forum_id IN(" . implode(",", $ids) . ")", 'group' => 'p.author_id', 'order' => 'tpost DESC', 'limit' => array(0, 9), 'add_join' => array(array('from' => array('topics' => 't'), 'where' => 't.tid=p.topic_id', 'type' => 'left'), array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=p.author_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $this->DB->execute(); /* Loop through and save the members */ while ($r = $this->DB->fetch()) { $todays_posts += $r['tpost']; $store[] = $r; } /* Format the results for output */ if ($todays_posts) { foreach ($store as $info) { $info['total_today_posts'] = $todays_posts; if ($todays_posts > 0 and $info['tpost'] > 0) { //$info['today_pct'] = sprintf( '%.2f', ( $info['tpost'] / $total_today['cnt'] ) * 100 ); } $rows[] = IPSMember::buildDisplayData($info); } } } return $this->registry->getClass('output')->getTemplate('boards')->hookTopPosters($rows); }
/** * Main class entry point * * @param object ipsRegistry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Get member data and format //----------------------------------------- $user = intval($this->request['user']); $id = intval($this->request['id']); if (!$user) { $this->returnString("no"); } if ($id) { $member = IPSMember::buildDisplayData(IPSMember::load($id)); } else { $member = IPSMember::buildDisplayData(IPSMember::setUpGuest($this->lang->words['global_guestname'] . "_" . $user)); } //----------------------------------------- // Mod permissions //----------------------------------------- $my_groups = array($this->memberData['member_group_id']); if ($this->memberData['mgroup_others']) { $my_groups = array_merge($my_groups, explode(",", IPSText::cleanPermString($this->memberData['mgroup_others']))); } $permissions = 0; $private = 0; if ($this->settings['ipschat_mods']) { $mod_groups = explode(",", $this->settings['ipschat_mods']); foreach ($my_groups as $group_id) { if (in_array($group_id, $mod_groups)) { $permissions = 1; break; } } } if ($this->settings['ipschat_private']) { $mod_groups = explode(",", $this->settings['ipschat_private']); foreach ($my_groups as $group_id) { if (in_array($group_id, $mod_groups)) { $private = 1; break; } } } //----------------------------------------- // Return output //----------------------------------------- $this->returnJsonArray(array('html' => ipsRegistry::getClass('output')->replaceMacros($this->registry->getClass('output')->getTemplate('ipchat')->ajaxNewUser(array('user_id' => $user, 'moderator' => $permissions, 'private' => $private, 'member' => $member))), 'prefix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['prefix']) : '', 'suffix' => $this->settings['ipschat_format_names'] ? str_replace('"', '__DBQ__', $member['suffix']) : '', 'pp_small_photo' => $member['pp_small_photo'], 'name' => $member['members_display_name'], '_canBeIgnored' => $member['member_id'] ? $member['_canBeIgnored'] : 1, 'g_id' => $member['g_id'])); }
/** * Feturn HTML block * * @param array Member information * @return string HTML block */ public function return_html_block($member = array()) { //----------------------------------------- // Got a member? //----------------------------------------- if (!is_array($member) or !count($member)) { return $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show'); } $friends = array(); //----------------------------------------- // Grab the friends //----------------------------------------- /* How many friends do we have? */ $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => 'profile_friends', 'where' => 'friends_member_id=' . $member['member_id'] . ' AND friends_approved=1')); /* Sort out pagination */ $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0; $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => self::FRIENDS_PER_PAGE, 'currentStartValue' => $st, 'baseUrl' => "showuser={$member['member_id']}&tab=friends", 'seoTemplate' => 'showuser', 'seoTitle' => $member['members_seo_name'])); /* Get em! */ $queryData = array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => 'f.friends_member_id=' . $member['member_id'] . ' AND f.friends_approved=1 AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')', 'add_join' => array(1 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=f.friends_friend_id', 'type' => 'left'), 2 => array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id', 'type' => 'left'))); // Ordering is bad because it causes a filesort, but if they have more than 100 members, we're going to have // to order so we can paginate if ($count['dracula'] > self::FRIENDS_PER_PAGE) { $queryData['order'] = 'm.members_display_name'; $queryData['limit'] = array($st, self::FRIENDS_PER_PAGE); } $this->DB->build($queryData); $outer = $this->DB->execute(); //----------------------------------------- // Get and store... //----------------------------------------- while ($row = $this->DB->fetch($outer)) { if ($row['member_id']) { $friends[IPSText::mbstrtolower($row['members_display_name'])] = IPSMember::buildDisplayData($row, 0); } } ksort($friends); $content = $this->registry->getClass('output')->getTemplate('profile')->tabFriends($friends, $member, $pagination); //----------------------------------------- // Macros... //----------------------------------------- $content = $this->registry->output->replaceMacros($content); //----------------------------------------- // Return content.. //----------------------------------------- return $content ? $content : $this->registry->getClass('output')->getTemplate('profile')->tabNoContent('err_no_aboutme_to_show'); }
/** * Class entry point * * @param object Registry reference * @return @e void [Outputs to screen] */ public function doExecute(ipsRegistry $registry) { //----------------------------------------- // Can we access? //----------------------------------------- if (!$this->memberData['g_mem_info']) { $this->returnString('error'); } $this->registry->class_localization->loadLanguageFile(array('public_profile', 'public_online'), 'members'); /* Got a valid member? */ $member_id = intval($this->request['mid']); if (empty($member_id)) { $this->returnString('error'); } $member = IPSMember::load($member_id, 'profile_portal,pfields_content,sessions,groups,basic', 'id'); if (empty($member['member_id'])) { $this->returnString('error'); } $member = IPSMember::buildDisplayData($member, array('customFields' => 1, 'cfSkinGroup' => 'profile', 'spamStatus' => 1)); $member = IPSMember::getLocation($member); $board_posts = $this->caches['stats']['total_topics'] + $this->caches['stats']['total_replies']; if ($member['posts'] and $board_posts) { $member['_posts_day'] = round($member['posts'] / ((time() - $member['joined']) / 86400), 2); # Fix the issue when there is less than one day $member['_posts_day'] = $member['_posts_day'] > $member['posts'] ? $member['posts'] : $member['_posts_day']; $member['_total_pct'] = sprintf('%.2f', $member['posts'] / $board_posts * 100); } $member['_posts_day'] = floatval($member['_posts_day']); /* Load status class */ if (!$this->registry->isClassLoaded('memberStatus')) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus'); $this->registry->setClass('memberStatus', new $classToLoad(ipsRegistry::instance())); } /* Fetch */ $member['_status'] = $this->registry->getClass('memberStatus')->fetch($this->memberData, array('member_id' => $member['member_id'], 'limit' => 1)); if (is_array($member['_status']) and count($member['_status'])) { $member['_status'] = array_pop($member['_status']); } /* Reputation */ if ($this->settings['reputation_protected_groups']) { if (in_array($member['member_group_id'], explode(",", $this->settings['reputation_protected_groups']))) { $this->settings['reputation_show_profile'] = false; } } $this->returnHtml($this->registry->getClass('output')->getTemplate('profile')->showCard($member)); }
/** * Execute the feed and return the HTML to show on the page. * Can be called from ACP or front end, so the plugin needs to setup any appropriate lang files, skin files, etc. * * @access public * @param array Block data * @return string Block HTML to display or cache */ public function executeFeed($block) { $this->lang->loadLanguageFile(array('public_ccs'), 'ccs'); $config = unserialize($block['block_config']); $where = array(); //----------------------------------------- // Set up filtering clauses //----------------------------------------- if ($config['filters']['filter_groups']) { $where[] = "m.member_group_id IN(" . $config['filters']['filter_groups'] . ")"; } if ($config['filters']['filter_posts']) { $where[] = "m.posts > " . $config['filters']['filter_posts']; } if ($config['filters']['filter_bday_day']) { $where[] = "m.bday_day=" . date('j') . " AND m.bday_month=" . date('n'); } if ($config['filters']['filter_bday_mon']) { $where[] = "m.bday_month=" . date('n'); } if ($config['filters']['filter_has_blog']) { $where[] = "m.has_blog=1"; } if ($config['filters']['filter_has_gallery']) { $where[] = "m.has_gallery=1"; } if ($config['filters']['filter_min_rating']) { $where[] = "p.pp_rating_value >= " . $config['filters']['filter_min_rating']; } if ($config['filters']['filter_min_rep']) { $where[] = "p.pp_reputation_points >= " . $config['filters']['filter_min_rep']; } $order = ''; switch ($config['sortby']) { case 'name': $order .= "m.members_display_name "; break; default: case 'posts': $order .= "m.posts "; break; case 'joined': $order .= "m.joined "; break; case 'last_active': $order .= "m.last_active "; break; case 'last_post': $order .= "m.last_post "; break; case 'age': $where[] = "bday_year IS NOT NULL AND bday_year > 0"; $order .= "m.bday_year " . $config['sortorder'] . ",m.bday_mon " . $config['sortorder'] . ",m.bday_day "; break; case 'profile_views': $order .= "m.members_profile_views "; break; case 'status_update': $order .= "p.pp_status_update "; break; case 'rating': $order .= "p.pp_rating_value "; break; case 'rep': $order .= "p.pp_reputation_points "; break; case 'rand': $order .= "RAND() "; break; } $order .= $config['sortorder']; //----------------------------------------- // Run the query and get the results //----------------------------------------- $members = array(); $this->DB->build(array('select' => 'm.*, m.member_id as mid', 'from' => array('members' => 'm'), 'where' => implode(' AND ', $where), 'order' => $order, 'limit' => array($config['offset_a'], $config['offset_b']), 'add_join' => array(array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'p.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left')))); $this->DB->execute(); while ($r = $this->DB->fetch()) { //----------------------------------------- // Normalization //----------------------------------------- $r['member_id'] = $r['mid']; $r['url'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?showuser='******'member_id'], 'none', $r['members_seo_name'], 'showuser'); $r['title'] = $r['members_display_name']; $r['date'] = $r['joined']; $r['content'] = $r['pp_about_me']; IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons']; IPSText::getTextClass('bbcode')->parse_html = intval($this->settings['aboutme_html']); IPSText::getTextClass('bbcode')->parse_nl2br = 1; IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['aboutme_bbcode']; IPSText::getTextClass('bbcode')->parsing_section = 'aboutme'; IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others']; $r['content'] = IPSText::getTextClass('bbcode')->preDisplayParse($r['content']); $r['content'] = IPSText::getTextClass('bbcode')->memberViewImages($r['content']); $r = IPSMember::buildDisplayData($r); $members[] = $r; } //----------------------------------------- // Return formatted content //----------------------------------------- $feedConfig = $this->returnFeedInfo(); $templateBit = $feedConfig['templateBit'] . '_' . $block['block_id']; if ($config['hide_empty'] and !count($members)) { return ''; } return $this->registry->output->getTemplate('ccs')->{$templateBit}($block['block_name'], $members); }
/** * Execute plugin * * @param array $permissions Moderator permissions * @return @e string */ public function executePlugin($permissions) { //----------------------------------------- // Check permissions //----------------------------------------- if (!$this->canView($permissions)) { return ''; } /* Add some CSS.. */ $this->registry->output->addToDocumentHead('importcss', "{$this->settings['css_base_url']}style_css/{$this->registry->output->skin['_csscacheid']}/ipb_mlist.css"); //----------------------------------------- // Get 10 members on suspension //----------------------------------------- $st = intval($this->request['st']); $total = $this->DB->buildAndFetch(array('select' => 'count(*) as members', 'from' => 'members', 'where' => "temp_ban!=0 AND temp_ban!='' AND temp_ban " . $this->DB->buildIsNull(false))); $members = array(); $this->DB->build(array('select' => 'm.*', 'from' => array('members' => 'm'), 'order' => 'm.joined DESC', 'limit' => array($st, 10), 'where' => "m.temp_ban!=0 AND m.temp_ban!='' AND m.temp_ban " . $this->DB->buildIsNull(false), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $mod_arr = IPSMember::processBanEntry($r['temp_ban']); if ($mod_arr['date_end'] and $mod_arr['date_end'] < time()) { IPSMember::save($r['member_id'], array('core' => array('temp_ban' => 0))); continue; } if ($mod_arr['date_start'] == 1) { $r['_language'] = $this->lang->words['modcp_modq_indef']; } else { $r['_language'] = $this->registry->getClass('class_localization')->getDate($mod_arr['date_end'], 'SHORT'); } $members[] = IPSMember::buildDisplayData($r); } //----------------------------------------- // Page links //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => $total['members'], 'itemsPerPage' => 10, 'currentStartValue' => $st, 'baseUrl' => "app=core&module=modcp&fromapp=members&tab=suspended")); return $this->registry->output->getTemplate('modcp')->membersList('suspended', $members, $pages); }
/** * Handles ajax/non-ajax window for reports and comments linked from reports * * @access private * @return boolean */ private function _displayReport() { //----------------------------------------- // Lets make sure this report exists... //----------------------------------------- $rid = intval($this->request['rid']); $options = array('rid' => $rid); $reports = array(); $comments = array(); if (!$rid) { $this->registry->output->showError('reports_no_rid', 10137); } $this->registry->class_localization->loadLanguageFile(array('public_editors')); $report_index = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . $rid)); //----------------------------------------- // Basic title and nav routine.. //----------------------------------------- $this->registry->output->addNavigation($this->lang->words['main_title'], 'app=core&module=reports&do=index'); $this->registry->output->addNavigation($report_index['title'], ''); if ($this->DB->getTotalRows() == 0) { $this->registry->output->showError('reports_no_rid', 10138); } $COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions(); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_emoticons = 1; IPSText::getTextClass('bbcode')->parse_nl2br = 0; IPSText::getTextClass('bbcode')->parsing_section = 'global'; //----------------------------------------- // Get reports //----------------------------------------- $this->DB->buildFromCache('grab_report', array('COM' => $COM_PERM, 'rid' => $rid), 'report_sql_queries'); $outer = $this->DB->execute(); while ($row = $this->DB->fetch($outer)) { IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others']; $row['points'] = isset($row['points']) ? $row['points'] : $this->settings['_tmpPoints'][$row['id']]; if (!$options['url'] && $row['url']) { $options['url'] = $this->registry->getClass('reportLibrary')->processUrl($row['url'], $row['seoname'], $row['seotemplate']); } if (!$options['class'] && $row['my_class']) { $options['class'] = $row['my_class']; } if ($row['my_class'] == 'messages' && !$options['topicID'] && $row['exdat1']) { $options['topicID'] = intval($row['exdat1']); } $options['title'] = $row['title']; $options['status_id'] = $row['status']; if (!$options['image'] && $row['img_preview']) { $options['image'] = $this->registry->getClass('reportLibrary')->processUrl($row['img_preview'], $row['seoname'], $row['seotemplate']); } if (!$options['status_icon']) { $options['status_icon'] = $this->_buildStatusIcon($row); $options['status_text'] = $this->registry->getClass('reportLibrary')->flag_cache[$row['status']][$row['points']]['title']; } $row['report'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['report']); $row['report'] = IPSText::getTextClass('bbcode')->memberViewImages($row['report']); $reports[$row['id']] = $row; } if (!$options['class']) { $this->registry->output->showError('reports_no_rid', 10138); } $_tmp = $this->registry->getClass('reportLibrary')->flag_cache; // Manually build array get just the statuses, not severities foreach ($_tmp as $sid => $sta) { if (is_array($sta) && count($sta)) { foreach ($sta as $points => $info) { if ($options['statuses'][$sid]) { break; } $options['statuses'][$sid] = $info; } } } //----------------------------------------- // Get comments //----------------------------------------- $ids = array(0 => 0); $this->DB->build(array('select' => 'id', 'from' => 'rc_comments', 'where' => 'rid=' . $rid, 'group' => 'id')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $ids[$row['id']] = $row['id']; } $this->DB->build(array('select' => 'comm.*', 'from' => array('rc_comments' => 'comm'), 'where' => 'comm.id IN (' . implode(',', $ids) . ')', 'order' => 'comm.comment_date ASC', 'add_join' => array(array('select' => 'mem.*', 'from' => array('members' => 'mem'), 'where' => 'mem.member_id=comm.comment_by'), array('select' => 'grop.*,grop.g_is_supmod as iscop', 'from' => array('groups' => 'grop'), 'where' => 'grop.g_id=mem.member_group_id'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=mem.member_id')))); $outer = $this->DB->execute(); while ($row = $this->DB->fetch($outer)) { IPSText::getTextClass('bbcode')->parsing_mgroup = $row['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $row['mgroup_others']; $row['author'] = IPSMember::buildDisplayData($row['member_id']); $row['comment'] = IPSText::getTextClass('bbcode')->preDisplayParse($row['comment']); $row['comment'] = IPSText::getTextClass('bbcode')->memberViewImages($row['comment']); $comments[$row['id']] = $row; } //----------------------------------------- // And output //----------------------------------------- $this->output .= $this->registry->getClass('output')->getTemplate('reports')->viewReport($options, $reports, $comments); }
/** * Builds comments * * @access public * @param array Member information * @param boolean Use a new id * @param string Message to display * @return string Comment HTML * @since IPB 2.2.0.2006-08-02 */ public function buildComments($member, $new_id = 0, $return_msg = '') { //----------------------------------------- // INIT //----------------------------------------- $comments = array(); $member_id = intval($member['member_id']); $comment_perpage = 15; //intval( $member['pp_setting_count_comments'] ); $comment_html = 0; $comment_start = intval($this->request['st']); $comment_approved = ($this->memberData['member_id'] == $member['member_id'] or $this->memberData['g_is_supmod']) ? '' : ' AND ( pc.comment_approved=1 OR ( pc.comment_approved=0 AND pc.comment_by_member_id=' . $member_id . ') )'; //----------------------------------------- // Not showing comments? //----------------------------------------- if ($comment_perpage < 1) { return ''; } //----------------------------------------- // Regenerate comments... //----------------------------------------- $this->DB->build(array('select' => 'pc.*', 'from' => array('profile_comments' => 'pc'), 'where' => 'pc.comment_for_member_id=' . $member_id . $comment_approved, 'order' => 'pc.comment_date DESC', 'limit' => array($comment_start, $comment_perpage), 'calcRows' => TRUE, 'add_join' => array(array('select' => 'm.members_display_name, m.members_seo_name, m.posts, m.last_activity, m.member_group_id, m.member_id, m.last_visit, m.warn_level', 'from' => array('members' => 'm'), 'where' => 'm.member_id=pc.comment_by_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $o = $this->DB->execute(); $max = $this->DB->fetchCalculatedRows(); while ($row = $this->DB->fetch($o)) { $row['_comment_date'] = ipsRegistry::getClass('class_localization')->getDate($row['comment_date'], 'TINY'); $row = IPSMember::buildDisplayData($row); if (!$row['members_display_name_short']) { $row = array_merge($row, IPSMember::setUpGuest()); } $comments[] = $row; } //----------------------------------------- // Pagination //----------------------------------------- $links = $this->registry->output->generatePagination(array('totalItems' => $max, 'itemsPerPage' => $comment_perpage, 'currentStartValue' => $comment_start, 'baseUrl' => "showuser={$member_id}", 'seoTitle' => $member['members_seo_name'])); $comment_html = $this->registry->getClass('output')->getTemplate('profile')->showComments($member, $comments, $new_id, $return_msg, $links); //----------------------------------------- // Return it... //----------------------------------------- return $comment_html; }
/** * Get search results * * @param int $st Start offset * @param int $limit Results limit * @param string [$extraQuery] Extra query where clause * @param bool [$minimalInfo] Only return ids, names and groups * @return array Array of search results, or an array with keys 'ids' and 'names' if $minimalInfo is true */ public function getSearchResults($st, $limit, $extraQuery = '', $minimalInfo = false) { $extra = $extraQuery ? " AND " . $extraQuery : ''; $members = array(); $ids = array(); $names = array(); $groups = array(); //----------------------------------------- // Build query //----------------------------------------- $query = array('select' => 'm.*, m.member_id as mem_id, m.ip_address as mem_ip', 'from' => array('members' => 'm'), 'where' => $this->getWhereClause() . $extra, 'order' => $this->getOrderByClause(), 'add_join' => array(array('select' => 'p.*', 'from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'par.*', 'from' => array('members_partial' => 'par'), 'where' => 'par.partial_member_id=m.member_id', 'type' => 'left'), array('select' => 'val.*', 'from' => array('validating' => 'val'), 'where' => 'val.member_id=m.member_id', 'type' => 'left'))); if ($st or $limit) { $query['limit'] = array($st, $limit); } //----------------------------------------- // Execute query and return results //----------------------------------------- $this->DB->build($query); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { if ($minimalInfo) { $ids[$r['mem_id']] = $r['mem_id']; $names[$r['mem_id']] = $r['members_display_name']; $groups[$r['mem_id']] = $r['member_group_id']; } else { $r['member_id'] = $r['mem_id']; $r['ip_address'] = $r['mem_ip']; $r['_joined'] = $this->registry->class_localization->getDate($r['joined'], 'JOINED'); $r['group_title'] = $this->caches['group_cache'][$r['member_group_id']]['g_title']; $members[$r['member_id']] = IPSMember::buildDisplayData($r); } } return $minimalInfo ? array('ids' => $ids, 'names' => $names, 'groups' => $groups) : $members; }
/** * 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&section=dashboard'; $this->form_code_js = $this->html->form_code_js = 'module=mycp§ion=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("&#", "&#", $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('/&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&module=applications&section=applications&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&module=system&section=taskmanager&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&module=tools&section=settings&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&module=applications&section=applications&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&module=system&section=taskmanager&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&module=tools&section=help&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&module=posts&section=bbcode&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 />» <a href='" . $this->settings['base_url'] . "&module=tools&section=settings&do=findsetting&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 />» <a href='" . $this->settings['base_url'] . "&module=tools&section=settings&do=findsetting&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(); }
/** * Fetch all replies to a status * Default filters are sorted on reply_date ASC * * @param mixed [Array of member data OR member ID INT for member updating their status - will use ->getAuthor() if null] * @param array Array of sort/filter data ( member_id [int], latest_only [0,1], offset [int], limit [int], unix_cutoff [int], sort_dir [asc,desc], sort_field [string] ) */ public function fetchAllReplies($status = null, $filters = array()) { $status = $status === null ? $this->_internalData['StatusData'] : (is_array($status) ? $status : $this->_loadStatus($status)); $where = array(); $replies = array(); $sort_dir = $filters['sort_dir'] == 'desc' ? 'desc' : 'asc'; $sort_field = isset($filters['sort_field']) ? $filters['sort_field'] : 'reply_date'; $offset = isset($filters['offset']) ? intval($filters['offset']) : 0; $limit = isset($filters['limit']) ? intval($filters['limit']) : 100; /* Grab them */ $this->DB->build(array('select' => 's.*', 'from' => array('member_status_replies' => 's'), 'where' => 's.reply_status_id=' . intval($status['status_id']), 'order' => 's.' . $sort_field . ' ' . $sort_dir, 'limit' => array($offset, $limit), 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=s.reply_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $o = $this->DB->execute(); while ($row = $this->DB->fetch($o)) { /* Format some data */ $row['reply_date_formatted'] = $this->registry->getClass('class_localization')->getDate($row['reply_date'], 'SHORT'); $row['_canDelete'] = $this->canDeleteReply($this->getAuthor(), $row, $status); /* Format member */ $row = IPSMember::buildDisplayData($row, array('reputation' => 0, 'warn' => 0)); $replies[$row['reply_id']] = $row; } /* Phew */ return $replies; }
/** * Fetch entries from the delete log * * @param array Object IDs * @param string Object Type * @param boolean Parse Member Data */ public static function fetchEntries($ids, $type, $parseMember = true) { $return = array(); if (is_array($ids) and count($ids) and $type) { $ids = IPSLib::cleanIntArray($ids); ipsRegistry::DB()->build(array('select' => 'l.*', 'from' => array('core_soft_delete_log' => 'l'), 'where' => 'sdl_obj_id IN (' . implode(',', $ids) . ') AND sdl_obj_key=\'' . $type . '\'', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'l.sdl_obj_member_id=m.member_id'), array('select' => 'p.*', 'from' => array('profile_portal' => 'p'), 'where' => 'l.sdl_obj_member_id=p.pp_member_id')))); $i = ipsRegistry::DB()->execute(); while ($row = ipsRegistry::DB()->fetch($i)) { if ($parseMember) { $row['member'] = IPSMember::buildDisplayData($row); } $return[$row['sdl_obj_id']] = $row; } return $return; } return array(); }
/** * List members * * @access private * @return void [Outputs to screen] */ private function _memberList() { //----------------------------------------- // INIT //----------------------------------------- $data = $this->_generateFilterBoxes(); $_sql = array(); $st = intval($this->request['st']); $members = array(); $perpage = 20; //----------------------------------------- // FILTERS //----------------------------------------- if ($data['member_contains_text']) { $_field = ''; $_text = $this->DB->addSlashes($data['member_contains_text']); switch ($data['member_contains']) { default: case 'member_id': $_field = 'm.member_id'; break; case 'name': $_field = 'm.name'; break; case 'members_display_name': $_field = 'm.members_display_name'; break; case 'email': $_field = 'm.email'; break; case 'ip_address': $_field = 'm.ip_address'; break; case 'signature': $_field = 'pp.signature'; break; } switch ($data['member_contains_type']) { default: case 'contains': $_sql[] = $_field . " LIKE '%" . $_text . "%'"; break; case 'begins': $_sql[] = $_field . " LIKE '" . $_text . "%'"; break; case 'ends': $_sql[] = $_field . " LIKE '%" . $_text . "'"; break; case 'equals': $_sql[] = $_field . " = '" . $_text . "'"; break; } } if ($data['member_type']) { switch ($data['member_type']) { case 'suspended': $_sql[] = "m.temp_ban > 0"; break; case 'notsuspended': $_sql[] = "( m.temp_ban < 1 or m.temp_ban='' or m.temp_ban " . $this->DB->buildIsNull(true) . " )"; break; } } /* Banned status */ if ($data['banned_type']) { switch ($data['banned_type']) { case 'banned': $_sql[] = "m.member_banned=1"; break; case 'notbanned': $_sql[] = "m.member_banned=0"; break; } } /* Spam status */ if ($data['spam_type']) { switch ($data['spam_type']) { case 'spam': $_sql[] = IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has'); break; case 'notspam': $_sql[] = "NOT (" . IPSBWOptions::sql('bw_is_spammer', 'm.members_bitoptions', 'members', 'global', 'has') . ")"; break; } } if ($data['primary_group']) { $_sql[] = "m.member_group_id=" . intval($data['primary_group']); } if ($data['post_count'] and $data['post_count_type']) { $_type = ''; if ($data['post_count_type'] == 'gt') { $_type = '>'; } else { if ($data['post_count_type'] == 'lt') { $_type = '<'; } else { if ($data['post_count_type'] == 'eq') { $_type = '='; } } } if ($_type) { $_sql[] = "m.posts" . $_type . intval($data['post_count']); } } if ($data['secondary_group']) { $_sql[] = "( m.mgroup_others LIKE '%," . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '" . $data['secondary_group'] . ",%' OR " . "m.mgroup_others LIKE '%," . $data['secondary_group'] . "' OR " . "m.mgroup_others='" . $data['secondary_group'] . "' )"; } foreach (array('reg', 'post', 'active') as $_bit) { foreach (array('from', 'to') as $_when) { $bit = 'date_' . $_bit . '_' . $_when; if ($data[$bit]) { //----------------------------------------- // mm/dd/yyyy instead of mm-dd-yyyy //----------------------------------------- $data[$bit] = str_replace('/', '-', $data[$bit]); list($month, $day, $year) = explode('-', $data[$bit]); if (!checkdate($month, $day, $year)) { $this->registry->output->global_message = sprintf($this->lang->words['m_daterange'], $month, $day, $year); } else { $time_int = mktime(0, 0, 0, $month, $day, $year); switch ($_bit) { case 'reg': $field = 'joined'; break; case 'post': $field = 'last_post'; break; case 'active': $field = 'last_activity'; break; } if ($_when == 'from') { $_sql[] = 'm.' . $field . ' > ' . $time_int; } else { $_sql[] = 'm.' . $field . ' < ' . $time_int; } } } } } //----------------------------------------- // Check we have correct fields //----------------------------------------- switch ($data['order_direction']) { case 'asc': $order_direction = 'asc'; break; default: case 'desc': $order_direction = 'desc'; break; } switch ($data['order_by']) { default: case 'joined': $order_by = 'm.joined'; break; case 'members_l_username': $order_by = 'm.members_l_username'; break; case 'members_l_display_name': $order_by = 'm.members_l_display_name'; break; case 'email': $order_by = 'm.email'; break; } //----------------------------------------- // Custom fields... //----------------------------------------- if (is_array($data['custom_fields']) and count($data['custom_fields'])) { foreach ($data['custom_fields'] as $id => $value) { if ($value) { $_sql[] = 'p.field_' . $id . " LIKE '%" . $value . "%'"; } } } //----------------------------------------- // get 'owt? //----------------------------------------- $real_query = count($_sql) ? implode(" AND ", $_sql) : ''; //----------------------------------------- // Get the number of results //----------------------------------------- $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('members' => 'm'), 'where' => $real_query, 'add_join' => array(0 => array('from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), 1 => array('from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left')))); if ($count['count'] < 1) { $this->registry->output->global_message = $this->lang->words['m_nomembers']; // Reset the filter $real_query = ''; // And reset the cookie so we don't get the message on every page view ipsRegistry::getClass('adminFunctions')->staffSaveCookie('memberFilter', array()); $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'members')); } $pages = $this->registry->output->generatePagination(array('totalItems' => $count['count'], 'itemsPerPage' => $perpage, 'currentStartValue' => $st, 'baseUrl' => $this->settings['base_url'] . "&{$this->form_code}&do=" . $this->request['do'])); //----------------------------------------- // Run the query //----------------------------------------- $this->DB->build(array('select' => 'm.*, m.member_id as mem_id', 'from' => array('members' => 'm'), 'where' => $real_query, 'order' => $order_by . ' ' . $order_direction, 'limit' => array($st, $perpage), 'add_join' => array(1 => array('select' => 'p.*', 'from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left'), 2 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { $r['member_id'] = $r['mem_id']; $r['_joined'] = $this->registry->class_localization->getDate($r['joined'], 'JOINED'); $r['group_title'] = $this->caches['group_cache'][$r['member_group_id']]['g_title']; $members[] = IPSMember::buildDisplayData($r); } //----------------------------------------- // Prune you fookers? //----------------------------------------- if ($data['search_type'] == 'delete') { $this->_memberPruneForm($count['count']); return; } else { if ($data['search_type'] == 'move') { $this->_memberMoveForm($count['count']); return; } } $this->registry->output->extra_nav[] = array('', $this->lang->words['m_viewlist']); $this->registry->output->html .= $this->html->members_list($members, $pages); }
/** * Builds the html for an event * * @param array Array of event data * @param bool Parse the data and return the parsed array, instead of the formatted HTML * @return string Parsed event HTML */ public function calendarMakeEventHTML($event, $returnAsArray = false) { //----------------------------------------- // Caching //----------------------------------------- static $cachedEvents = array(); if (isset($cachedEvents[$event['event_id']])) { if ($returnAsArray) { return $cachedEvents[$event['event_id']]; } else { return $this->registry->output->getTemplate('calendar')->showEvent($cachedEvents[$event['event_id']]['event'], $cachedEvents[$event['event_id']]['member'], array('type' => $cachedEvents[$event['event_id']]['info']['type'], 'ends' => $cachedEvents[$event['event_id']]['info']['ends'], 'calendars' => $this->functions->getCalendars(), 'calendar' => $this->calendar, 'chosen_date' => $this->chosen_date)); } } if ($this->canReport === 'notinit') { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/reportLibrary.php', 'reportLibrary'); $reports = new $classToLoad($this->registry); $this->canReport = $reports->canReport('calendar'); } $event['_canReport'] = $this->canReport; //----------------------------------------- // Get member details //----------------------------------------- $member = IPSMember::buildDisplayData($event); //----------------------------------------- // Like strip //----------------------------------------- if (!$this->_like) { require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php'; /*noLibHook*/ $this->_like = classes_like::bootstrap('calendar', 'events'); } $event['_like_strip'] = $this->_like->render('summary', $event['event_id']); $event['_like_count'] = $this->_like->getCount($event['event_id']); //----------------------------------------- // Reputation //----------------------------------------- if (is_null($event['has_given_rep'])) { $event['has_given_rep'] = 0; } if (is_null($event['rep_points'])) { $event['rep_points'] = 0; } if ($this->settings['reputation_enabled']) { $event['like'] = $this->registry->repCache->getLikeFormatted(array('app' => 'calendar', 'type' => 'event_id', 'id' => $event['event_id'], 'rep_like_cache' => $event['rep_like_cache'])); } //----------------------------------------- // Times and dates //----------------------------------------- $event['_start_time'] = strtotime($event['event_start_date']); $event['_end_time'] = ($event['event_end_date'] and $event['event_end_date'] != '0000-00-00 00:00:00') ? strtotime($event['event_end_date']) : 0; if (!$event['event_all_day']) { if ($this->memberData['member_id'] and $this->memberData['time_offset']) { $event['_start_time'] = $event['_start_time'] + $this->memberData['time_offset'] * 3600; } else { if (!$this->memberData['member_id'] and $this->settings['time_offset']) { $event['_start_time'] = $event['_start_time'] + $this->settings['time_offset'] * 3600; } } if ($this->memberData['member_id'] and $this->memberData['time_offset']) { $event['_end_time'] = $event['_end_time'] ? $event['_end_time'] + $this->memberData['time_offset'] * 3600 : 0; } else { if (!$this->memberData['member_id'] and $this->settings['time_offset']) { $event['_end_time'] = $event['_end_time'] ? $event['_end_time'] + $this->settings['time_offset'] * 3600 : 0; } } } $event['_start_date'] = gmstrftime($this->settings['clock_date'], $event['_start_time']); $event['_event_time'] = ''; $event['_event_etime'] = ''; if (!$event['event_all_day']) { if ($this->settings['cal_time_format'] == 'standard') { $event['_event_time'] = gmstrftime('%I:%M %p', $event['_start_time']); $event['_event_etime'] = $event['_end_time'] ? gmstrftime('%I:%M %p', $event['_end_time']) : ''; } else { $event['_event_time'] = gmstrftime('%H:%M', $event['_start_time']); $event['_event_etime'] = $event['_end_time'] ? gmstrftime('%H:%M', $event['_end_time']) : ''; } } //----------------------------------------- // Event type //----------------------------------------- $type = $this->lang->words['se_normal']; $ends = ''; if (!$event['event_recurring'] and $event['_end_time'] and gmstrftime($this->settings['clock_date'], $event['_end_time']) != $event['_start_date']) { $type = $this->lang->words['se_range']; $ends = sprintf($this->lang->words['se_ends'], gmstrftime($this->settings['clock_date'], $event['_end_time'])); } else { if ($event['event_recurring']) { $type = $this->lang->words['se_recur']; $ends = sprintf($this->lang->words['se_ends'], gmstrftime($this->settings['clock_date'], $event['_end_time'])); } } //----------------------------------------- // Event content //----------------------------------------- IPSText::getTextClass('bbcode')->parse_html = 0; IPSText::getTextClass('bbcode')->parse_smilies = intval($event['event_smilies']); IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'calendar'; IPSText::getTextClass('bbcode')->parsing_mgroup = $member['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $member['mgroup_others']; $event['event_content'] = IPSText::getTextClass('bbcode')->preDisplayParse($event['event_content']); $event['event_attach_content'] = ''; //----------------------------------------- // Parse attachments //----------------------------------------- static $attachments = null; if ($event['event_attachments']) { //----------------------------------------- // Get attachments class //----------------------------------------- if (!$attachments) { $this->lang->loadLanguageFile(array('public_topic'), 'forums'); $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('core') . '/sources/classes/attach/class_attach.php', 'class_attach'); $attachments = new $classToLoad($this->registry); $attachments->type = 'event'; $attachments->init(); } $attachHTML = $attachments->renderAttachments(array($event['event_id'] => $event['event_content']), array($event['event_id'])); if (is_array($attachHTML)) { $event['event_content'] = $attachHTML[$event['event_id']]['html']; $event['event_attach_content'] = $attachHTML[$event['event_id']]['attachmentHtml']; } } //----------------------------------------- // Rating //----------------------------------------- $event['_can_rate'] = ($this->memberData['member_id'] and $this->registry->permissions->check('rate', $this->calendar)) ? 1 : 0; $event['_rating_value'] = -1; if ($event['_can_rate']) { $rating = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'cal_event_ratings', 'where' => "rating_eid={$event['event_id']} and rating_member_id=" . $this->memberData['member_id'])); $event['_rating_value'] = $rating['rating_value'] ? $rating['rating_value'] : -1; } //----------------------------------------- // RSVP attendees //----------------------------------------- $event['_rsvp_attendees'] = array(); $event['_rsvp_attendees_short'] = array(); $event['_rsvp_count'] = 0; $event['_can_rsvp'] = false; $event['_can_delete_rsvp'] = false; if ($event['event_rsvp']) { $this->DB->build(array('select' => 'a.*', 'from' => array('cal_event_rsvp' => 'a'), 'where' => 'a.rsvp_event_id=' . $event['event_id'], 'order' => 'm.members_display_name ASC', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=a.rsvp_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left')))); $this->DB->execute(); while ($r = $this->DB->fetch()) { $event['_rsvp_attendees'][$r['member_id']] = IPSMember::buildDisplayData(array_merge($r, $this->caches['group_cache'][$r['member_group_id']])); $event['_rsvp_attendees'][$r['member_id']]['_can_delete_rsvp'] = false; if ($this->calendar['cal_rsvp_owner'] and $this->memberData['member_id'] and $this->memberData['member_id'] == $r['member_id']) { $event['_rsvp_attendees'][$r['member_id']]['_can_delete_rsvp'] = true; } if ($event['_rsvp_count'] < 5) { $event['_rsvp_attendees_short'][$r['member_id']] = $event['_rsvp_attendees'][$r['member_id']]; } $event['_rsvp_count']++; } if ($this->memberData['member_id'] and $this->registry->permissions->check('rsvp', $this->calendar)) { if (!isset($event['_rsvp_attendees'][$this->memberData['member_id']])) { $event['_can_rsvp'] = true; } else { $event['_have_rsvp'] = true; } } if ($this->calendar['cal_rsvp_owner'] and $this->memberData['member_id'] and $this->memberData['member_id'] == $event['event_member_id']) { $event['_can_delete_rsvp'] = true; } } //----------------------------------------- // Return formatted HTML //----------------------------------------- $cachedEvents[$event['event_id']] = array('member' => $member, 'event' => $event, 'info' => array('type' => $type, 'ends' => $ends)); if ($returnAsArray) { return $cachedEvents[$event['event_id']]; } else { return $this->registry->output->getTemplate('calendar')->showEvent($event, $member, array('type' => $type, 'ends' => $ends, 'calendars' => $this->functions->getCalendars(), 'calendar' => $this->calendar, 'chosen_date' => $this->chosen_date)); } }
/** * Builds an array of category data for output * * @return array */ public function processAllCategories() { //----------------------------------------- // Init //----------------------------------------- $return_cat_data = array(); $root = array(); $parent = array(); $member_ids = array(); //----------------------------------------- // Want to view categories? //----------------------------------------- if (!empty($this->request['c'])) { foreach (explode(",", $this->request['c']) as $c) { $c = intval($c); $i = $this->registry->getClass('class_forums')->forum_by_id[$c]['parent_id']; $root[$i] = $i; $parent[$c] = $c; } } if (!count($root)) { $root[] = 'root'; } foreach ($root as $root_id) { if (is_array($this->registry->class_forums->forum_cache[$root_id]) and count($this->registry->class_forums->forum_cache[$root_id])) { foreach ($this->registry->class_forums->forum_cache[$root_id] as $id => $forum_data) { $temp_cat_data = array(); //----------------------------------------- // Only showing certain root forums? //----------------------------------------- if (count($parent)) { if (!in_array($id, $parent)) { continue; } } $cat_data = $forum_data; if (isset($this->registry->class_forums->forum_cache[$forum_data['id']]) and is_array($this->registry->class_forums->forum_cache[$forum_data['id']])) { foreach ($this->registry->class_forums->forum_cache[$forum_data['id']] as $forum_data) { $forum_data['show_subforums'] = isset($forum_data['show_subforums']) ? $forum_data['show_subforums'] : ''; $forum_data['last_unread'] = isset($forum_data['last_unread']) ? $forum_data['last_unread'] : ''; //----------------------------------------- // Get all subforum stats // and calculate //----------------------------------------- if ($forum_data['redirect_on']) { $forum_data['redirect_target'] = isset($forum_data['redirect_target']) ? $forum_data['redirect_target'] : '_parent'; $temp_cat_data[$forum_data['id']] = $forum_data; } else { $temp_cat_data[$forum_data['id']] = $this->registry->class_forums->forumsFormatLastinfo($this->registry->class_forums->forumsCalcChildren($forum_data['id'], $forum_data)); } if ($temp_cat_data[$forum_data['id']]['last_poster_id']) { $member_ids[$forum_data['id']] = $temp_cat_data[$forum_data['id']]['last_poster_id']; } } } if (count($temp_cat_data)) { $return_cat_data[] = array('cat_data' => $cat_data, 'forum_data' => $temp_cat_data); } $temp_cat_data = array(); } } } if (count($member_ids)) { $_members = IPSMember::load(array_unique($member_ids), 'members,profile_portal'); foreach ($member_ids as $forumId => $memberId) { $_member = $_members[$memberId]; if ($_member['member_id']) { $_member = IPSMember::buildDisplayData($_member); foreach ($return_cat_data as $k => $_type) { foreach ($_type as $__type => $obj) { if ($__type == 'forum_data') { foreach ($obj as $fid => $fdata) { if ($fid != $forumId) { continue; } $return_cat_data[$k][$__type][$fid] = array_merge($_member, $fdata); break 3; } } } } } } } return $return_cat_data; }
/** * Retrieve upcoming birthdays * * @return @e string * @note The recache function will recache up to 6 each day. That fulfills the 5 that are displayed + 1 more to know if we should show a link to view all. */ public function getUpcomingBirthdays() { if (!$this->settings['show_birthdays'] or !IPSLib::appIsInstalled('calendar')) { return ''; } $a = explode(',', gmdate('Y,n,j,G,i,s', time() + $this->registry->getClass('class_localization')->getTimeOffset())); $day = $a[2]; $month = $a[1]; $year = $a[0]; $birthstring = ""; $count = 0; $lang = ''; $users = array(); $fetch = 5; if (is_array($this->caches['birthdays']) and count($this->caches['birthdays'])) { $_users = IPSMember::load(array_keys($this->caches['birthdays'])); foreach ($this->caches['birthdays'] as $u) { /* Age */ $pyear = 0; $u = array_merge($_users[$u['member_id']], $u); $u = IPSMember::buildDisplayData($u); if ($u['bday_year'] && $u['bday_year'] > 0) { $pyear = $year - $u['bday_year']; } $u['_pyear'] = $pyear; if ($u['bday_day'] == $day and $u['bday_month'] == $month) { if ($count < $fetch) { $users[] = $u; } $count++; } else { if ($day == 28 && $month == 2 && !date("L")) { if ($u['bday_day'] == "29" and $u['bday_month'] == $month) { if ($count < $fetch) { $users[] = $u; } $count++; } } } } } //----------------------------------------- // Get calendar info, but only if we need it //----------------------------------------- $data = array(); if ($count >= count($users)) { $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('calendar') . "/sources/functions.php", 'app_calendar_classes_functions', 'calendar'); $functions = new $classToLoad($this->registry); $calendars = $functions->getCalendars(); foreach ($calendars as $calendar) { /* We need to grab first calendar that allows birthdays */ if (!$calendar['cal_bday_limit']) { continue; } $data = array('id' => $calendar['cal_id'], 'title' => $calendar['cal_title_seo'], 'year' => $year, 'month' => $month, 'day' => $day, 'count' => $count); break; } } if ($count >= count($users) and !count($data)) { return ''; } //----------------------------------------- // Spin and print... //----------------------------------------- return $this->registry->output->getTemplate('calendar')->boardIndexBirthdays($users, $data); }
/** * Displays a report * * @return @e void */ public function _displayReport() { //----------------------------------------- // Lets make sure this report exists... //----------------------------------------- $rid = intval($this->request['rid']); $options = array('rid' => $rid); $reports = array(); $comments = array(); if (!$rid) { $this->registry->output->showError('reports_no_rid', 10137); } $this->registry->class_localization->loadLanguageFile(array('public_editors')); $report_index = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_reports_index', 'where' => "id=" . $rid)); //----------------------------------------- // Basic title and nav routine.. //----------------------------------------- $this->registry->output->addNavigation($this->lang->words['main_title'], 'app=core&module=reports&do=index'); $this->registry->output->addNavigation($report_index['title'], ''); if (!$report_index['id']) { $this->registry->output->showError('reports_no_rid', 10138); } $COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions(); /* Load parser */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser'); $parser = new $classToLoad(); //----------------------------------------- // Get reports //----------------------------------------- $this->DB->buildFromCache('grab_report', array('COM' => $COM_PERM, 'rid' => $rid), 'report_sql_queries'); $outer = $this->DB->execute(); while ($row = $this->DB->fetch($outer)) { $row['points'] = isset($row['points']) ? $row['points'] : $this->settings['_tmpPoints'][$row['id']]; if (!$options['url'] && $row['url']) { $options['url'] = $this->registry->getClass('reportLibrary')->processUrl($row['url'], $row['seoname'], $row['seotemplate']); } if (!$options['class'] && $row['my_class']) { $options['class'] = $row['my_class']; } if ($row['my_class'] == 'messages' && !$options['topicID'] && $row['exdat1']) { $options['topicID'] = intval($row['exdat1']); } $options['title'] = $row['title']; $options['status_id'] = $row['status']; if (!$options['status_icon']) { $options['status_icon'] = $this->registry->getClass('reportLibrary')->buildStatusIcon($row); $options['status_text'] = $this->registry->getClass('reportLibrary')->flag_cache[$row['status']][$row['points']]['title']; } /* Stupid stupid stupidness */ $row['_title'] = $row['title']; $row['title'] = $row['member_title']; if ($row['member_id']) { $row['author'] = IPSMember::buildDisplayData($row); } else { $row['author'] = IPSMember::buildDisplayData(IPSMember::setUpGuest('')); } $row['title'] = $row['_title']; /* Set up some settings */ $parser->set(array('parseArea' => 'reports', 'memberData' => $row['author'], 'parseBBCode' => true, 'parseHtml' => false, 'parseEmoticons' => true)); $row['report'] = $parser->display($row['report']); $reports[] = $row; } if (!$options['class']) { $this->registry->output->showError('reports_no_rid', 10138); } $_tmp = $this->registry->getClass('reportLibrary')->flag_cache; // Manually build array get just the statuses, not severities foreach ($_tmp as $sid => $sta) { if (is_array($sta) && count($sta)) { foreach ($sta as $points => $info) { if ($options['statuses'][$sid]) { break; } $options['statuses'][$sid] = $info; } } } //----------------------------------------- // Get comments //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php'; /*noLibHook*/ $this->_comments = classes_comments_bootstrap::controller('core-reports'); $comments = array('html' => $this->_comments->fetchFormatted($report_index, array('offset' => intval($this->request['st']))), 'count' => $this->_comments->count($report_index)); //----------------------------------------- // Mark as read //----------------------------------------- $this->registry->classItemMarking->markRead(array('forumID' => 0, 'itemID' => $rid), 'core'); //----------------------------------------- // And output //----------------------------------------- $this->output .= $this->registry->getClass('output')->getTemplate('reports')->viewReport($options, $reports, $comments); }
/** * Class entry point * * @access public * @param object Registry reference * @return void [Outputs to screen/redirects] */ public function doExecute(ipsRegistry $registry) { $announceID = intval($this->request['announce_id']); if (!$announceID) { $this->registry->getClass('output')->showError('announcement_id_missing', 10327); } $this->registry->getClass('class_localization')->loadLanguageFile(array('public_topic')); //----------------------------------------- // Get the announcement //----------------------------------------- $announce = $this->DB->buildAndFetch(array('select' => 'a.*', 'from' => array('announcements' => 'a'), 'where' => 'a.announce_id=' . $announceID, 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=a.announce_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'), array('select' => 'pc.*', 'from' => array('pfields_content' => 'pc'), 'where' => 'pc.member_id=m.member_id', 'type' => 'left')))); if (!$announce['announce_id'] or !$announce['announce_forum']) { $this->registry->getClass('output')->showError('announcement_id_missing', 10328); } //----------------------------------------- // Permission to see it? //----------------------------------------- $pass = 0; if ($announce['announce_forum'] == '*') { $pass = 1; } else { $tmp = explode(",", $announce['announce_forum']); if (!is_array($tmp) and !count($tmp)) { $pass = 0; } else { foreach ($tmp as $id) { if ($this->registry->getClass('class_forums')->forum_by_id[$id]['id']) { if (IPSMember::checkPermissions('read', $id)) { $pass = 1; break; } } } } } if ($pass != 1) { $this->registry->getClass('output')->showError('announcement_no_perms', 2035, true); } if (!$announce['announce_active'] and !$this->memberData['g_is_supmod']) { $this->registry->getClass('output')->showError('announcement_no_perms', 2036, true); } //----------------------------------------- // Parsey parsey! //----------------------------------------- IPSText::getTextClass('bbcode')->parse_smilies = 1; IPSText::getTextClass('bbcode')->parse_html = $announce['announce_html_enabled'] ? 1 : 0; IPSText::getTextClass('bbcode')->parse_nl2br = $announce['announce_nlbr_enabled']; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parsing_section = 'announcements'; IPSText::getTextClass('bbcode')->parsing_mgroup = $announce['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $announce['mgroup_others']; $announce['announce_post'] = IPSText::getTextClass('bbcode')->preDisplayParse($announce['announce_post']); $member = IPSMember::buildDisplayData($announce, array('signature' => 1, 'customFields' => 1, 'checkFormat' => 1, 'cfLocation' => 'topic')); if ($member['member_id']) { $member['_members_display_name'] = "<a href='{$this->settings['_base_url']}showuser={$member['member_id']}'>{$member['members_display_name_short']}</a>"; } if ($announce['announce_start'] and $announce['announce_end']) { $announce['running_date'] = sprintf($this->lang->words['announce_both'], gmstrftime('%x', $announce['announce_start']), gmstrftime('%x', $announce['announce_end'])); } else { if ($announce['announce_start'] and !$announce['announce_end']) { $announce['running_date'] = sprintf($this->lang->words['announce_start'], gmstrftime('%x', $announce['announce_start'])); } else { if (!$announce['announce_start'] and $announce['announce_end']) { $announce['running_date'] = sprintf($this->lang->words['announce_end'], gmstrftime('%x', $announce['announce_end'])); } else { $announce['running_date'] = ''; } } } $template = $this->registry->getClass('output')->getTemplate('topic')->announcement_show($announce, $member); //----------------------------------------- // Update hits //----------------------------------------- $this->DB->build(array('update' => 'announcements', 'set' => 'announce_views=announce_views+1', 'where' => "announce_id=" . $announceID)); $this->DB->execute(); if ($this->request['f']) { $nav = $this->registry->getClass('class_forums')->forumsBreadcrumbNav($this->request['f']); } $nav[] = array($announce['announce_title'], ""); foreach ($nav as $_id => $_nav) { $this->registry->getClass('output')->addNavigation($_nav[0], $_nav[1], $_nav[2], $_nav[3]); } $this->registry->getClass('output')->setTitle($this->settings['board_name'] . " -> " . $announce['announce_title']); $this->registry->getClass('output')->addContent($template); $this->registry->getClass('output')->sendOutput(); }
/** * 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 .= "&modfilter=" . $this->request['modfilter']; } if (isset($this->request['answered']) && $this->registry->class_forums->answerTopicsEnabled($this->forum['id'])) { $_extraStuff .= "&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'] . "&prune_day={$prune_value}&sort_by={$sort_by}&sort_key={$sort_key_chk}&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 ignored users * * @author Matt Mecham * @return string Processed HTML */ public function formIgnoredUsers() { //----------------------------------------- // INIT //----------------------------------------- $final_users = array(); $temp_users = array(); $uid = intval($this->request['uid']); $ignoredUsers = array(); //----------------------------------------- // Do we have incoming? //----------------------------------------- if ($uid) { $newmem = IPSMember::load($uid); $this->request['newbox_1'] = $newmem['members_display_name']; } //----------------------------------------- // Get ignored users //----------------------------------------- $perPage = 25; /* Count */ $count = $this->DB->buildAndFetch(array('select' => 'count(*) as dracula', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'])); /* Sort out pagination */ $st = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0; $pagination = $this->registry->output->generatePagination(array('totalItems' => $count['dracula'], 'itemsPerPage' => $perPage, 'currentStartValue' => $st, 'baseUrl' => 'app=core&module=usercp&tab=core&area=ignoredusers')); /* Get em */ $this->DB->build(array('select' => '*', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'], 'limit' => array($st, $perPage))); $this->DB->execute(); while ($row = $this->DB->fetch()) { $ignoredUsers[$row['ignore_ignore_id']] = $row; } //----------------------------------------- // Get members and check to see if they've // since been moved into a group that cannot // be ignored //----------------------------------------- foreach ($ignoredUsers as $_id => $data) { if (intval($_id)) { $temp_users[] = $_id; } } if (count($temp_users)) { $members = IPSMember::load($temp_users, 'all'); foreach ($members as $m) { $m['g_title'] = IPSMember::makeNameFormatted($this->caches['group_cache'][$m['member_group_id']]['g_title'], $m['member_group_id']); $final_users[$m['member_id']] = IPSMember::buildDisplayData($m); $final_users[$m['member_id']]['ignoreData'] = $ignoredUsers[$m['member_id']]; } } $this->request['newbox_1'] = $this->request['newbox_1'] ? $this->request['newbox_1'] : ''; return $this->registry->getClass('output')->getTemplate('ucp')->membersIgnoredUsersForm($final_users, $pagination); }
/** * List all current friends. * * @return @e void [Prints to screen] * @since IPB 2.2.0.2006-08-08 */ protected function _viewList() { //----------------------------------------- // INIT //----------------------------------------- $friends = array(); $tab = substr(IPSText::alphanumericalClean($this->request['tab']), 0, 20); $per_page = 25; $start = intval($this->request['st']); //----------------------------------------- // Check we're a member //----------------------------------------- if (!$this->memberData['member_id']) { $this->registry->output->showError('no_friend_mid', 10267, null, null, 404); } //----------------------------------------- // To what are we doing to whom? //----------------------------------------- if ($tab == 'pending') { $query = 'f.friends_approved=0 AND f.friends_friend_id=' . $this->memberData['member_id']; $joinKey = 'f.friends_member_id'; } else { $query = 'f.friends_approved=1 AND f.friends_member_id=' . $this->memberData['member_id']; $joinKey = 'f.friends_friend_id'; } /* Not banned or spammed */ $query .= ' AND m.member_banned=0 AND ( ! ' . IPSBWOptions::sql('bw_is_spammer', 'members_bitoptions', 'members', 'global', 'has') . ')'; //----------------------------------------- // Get count... //----------------------------------------- $count = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'add_join' => array(array('select' => '', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'inner')))); //----------------------------------------- // Pages... //----------------------------------------- $pages = $this->registry->output->generatePagination(array('totalItems' => intval($count['count']), 'noDropdown' => 1, 'itemsPerPage' => $per_page, 'currentStartValue' => $start, 'baseUrl' => 'app=members&module=profile&section=friends&do=list&tab=' . $tab)); //----------------------------------------- // Get current friends... //----------------------------------------- $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => $query, 'order' => 'm.members_l_display_name ASC', 'limit' => array($start, $per_page), 'add_join' => array(array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=' . $joinKey, 'type' => 'left'), array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=' . $joinKey, 'type' => 'left')))); $q = $this->DB->execute(); //----------------------------------------- // Get and store... //----------------------------------------- while ($row = $this->DB->fetch($q)) { $row = IPSMember::buildDisplayData($row, array('warn' => 0)); $friends[] = $row; } //----------------------------------------- // Show... //----------------------------------------- $content = $this->registry->getClass('output')->getTemplate('profile')->friendsList($friends, $pages); $this->registry->output->setTitle($this->lang->words['m_title_friends'] . ' - ' . ipsRegistry::$settings['board_name']); $this->registry->output->addNavigation($this->lang->words['m_title_friends'], ''); $this->registry->getClass('output')->addContent($content); $this->registry->getClass('output')->sendOutput(); }
/** * Execute the feed and return the HTML to show on the page. * Can be called from ACP or front end, so the plugin needs to setup any appropriate lang files, skin files, etc. * * @access public * @param array Block data * @return string Block HTML to display or cache */ public function executeFeed($block) { $this->lang->loadLanguageFile(array('public_ccs'), 'ccs'); $config = unserialize($block['block_config']); $where = array(); //----------------------------------------- // Set up filtering clauses //----------------------------------------- switch ($config['content']) { case 'entries': if ($config['filters']['filter_blogid']) { $where[] = "e.blog_id=" . $config['filters']['filter_blogid']; } if ($config['filters']['filter_visibility'] != 'either') { $where[] = "e.entry_status='" . ($config['filters']['filter_visibility'] == 'open' ? 'published' : 'draft') . "'"; } if ($config['filters']['filter_featured']) { $where[] = "e.entry_featured=1"; } if ($config['filters']['filter_submitted']) { $timestamp = @strtotime($config['filters']['filter_submitted']); if ($timestamp) { $where[] = "e.entry_date > " . $timestamp; } } if ($config['filters']['filter_submitter'] == 'myself') { $where[] = "e.entry_author_id = " . $this->memberData['member_id']; } else { if ($config['filters']['filter_submitter'] == 'friends') { //----------------------------------------- // Get page builder for friends //----------------------------------------- require_once IPSLib::getAppDir('ccs') . '/sources/pages.php'; $pageBuilder = new pageBuilder($this->registry); $friends = $pageBuilder->getFriends(); if (count($friends)) { $where[] = "e.entry_author_id IN( " . implode(',', $friends) . ")"; } else { return ''; } } else { if ($config['filters']['filter_submitter'] != '') { $member = IPSMember::load($config['filters']['filter_submitter'], 'basic'); if ($member['member_id']) { $where[] = "e.entry_author_id = " . $member['member_id']; } else { return ''; } } } } break; case 'comments': if ($config['filters']['filter_visibility'] != 'either') { $where[] = "c.comment_queued=" . ($config['filters']['filter_visibility'] == 'open' ? 0 : 1); } if ($config['filters']['filter_submitted']) { $timestamp = @strtotime($config['filters']['filter_submitted']); if ($timestamp) { $where[] = "c.comment_date > " . $timestamp; } } if ($config['filters']['filter_submitter'] == 'myself') { $where[] = "c.member_id = " . $this->memberData['member_id']; } else { if ($config['filters']['filter_submitter'] == 'friends') { //----------------------------------------- // Get page builder for friends //----------------------------------------- require_once IPSLib::getAppDir('ccs') . '/sources/pages.php'; $pageBuilder = new pageBuilder($this->registry); $friends = $pageBuilder->getFriends(); if (count($friends)) { $where[] = "c.member_id IN( " . implode(',', $friends) . ")"; } else { return ''; } } else { if ($config['filters']['filter_submitter'] != '') { $member = IPSMember::load($config['filters']['filter_submitter'], 'basic'); if ($member['member_id']) { $where[] = "c.member_id = " . $member['member_id']; } else { return ''; } } } } break; case 'blogs': if ($config['filters']['filter_owner'] == 'myself') { $where[] = "b.member_id = " . $this->memberData['member_id']; } else { if ($config['filters']['filter_owner'] == 'friends') { //----------------------------------------- // Get page builder for friends //----------------------------------------- require_once IPSLib::getAppDir('ccs') . '/sources/pages.php'; $pageBuilder = new pageBuilder($this->registry); $friends = $pageBuilder->getFriends(); if (count($friends)) { $where[] = "b.member_id IN( " . implode(',', $friends) . ")"; } else { return ''; } } else { if ($config['filters']['filter_owner'] != '') { $member = IPSMember::load($config['filters']['filter_owner'], 'basic'); if ($member['member_id']) { $where[] = "b.member_id = " . $member['member_id']; } else { return ''; } } } } if ($config['filters']['filter_type'] != 'either') { $where[] = "b.blog_type='" . $config['filters']['filter_type'] . "'"; } if (!$config['filters']['filter_private']) { $where[] = "b.blog_private=0"; } if ($config['filters']['filter_guests']) { $where[] = "b.blog_allowguests=1"; } break; } $order = ''; switch ($config['content']) { case 'entries': switch ($config['sortby']) { case 'name': $order .= "e.entry_name "; break; case 'trackbacks': $order .= "e.entry_trackbacks "; break; default: case 'submitted': $order .= "e.entry_date "; break; case 'comments': $order .= "e.entry_num_comments "; break; case 'lastcomment': $order .= "e.entry_last_comment_date "; break; case 'rand': $order .= "RAND() "; break; } break; case 'comments': switch ($config['sortby']) { default: case 'post_date': $order .= "c.comment_date "; break; } break; case 'blogs': switch ($config['sortby']) { case 'name': $order .= "b.blog_name "; break; case 'entries': $order .= "entry_count "; break; default: case 'last_entry': $order .= "e.entry_date "; break; case 'views': $order .= "b.blog_num_views "; break; case 'pinned': $order .= "b.blog_pinned "; break; case 'rate': $order .= "(b.blog_rating_total/b.blog_rating_count) "; break; case 'rand': $order .= "RAND() "; break; } break; } $order .= $config['sortorder']; //----------------------------------------- // Run the query and get the results //----------------------------------------- $content = array(); switch ($config['content']) { case 'entries': $this->DB->build(array('select' => 'e.*', 'from' => array('blog_entries' => 'e'), 'where' => implode(' AND ', $where), 'order' => $order, 'limit' => array($config['offset_a'], $config['offset_b']), 'add_join' => array(array('select' => 'b.*', 'from' => array('blog_blogs' => 'b'), 'where' => 'e.blog_id=b.blog_id', 'type' => 'left'), array('select' => 'm.*, m.member_id as mid', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.entry_author_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { //----------------------------------------- // Normalization //----------------------------------------- $r['member_id'] = $r['mid']; $r['url'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?app=blog&module=display&section=blog&blogid=' . $r['blog_id'] . '&showentry=' . $r['entry_id'], 'none'); $r['date'] = $r['entry_date']; $r['content'] = $r['entry']; $r['title'] = $r['entry_name']; IPSText::getTextClass('bbcode')->parse_html = $r['entry_html_state'] ? 1 : 0; IPSText::getTextClass('bbcode')->parse_nl2br = $r['entry_html_state'] == 2 ? 1 : 0; IPSText::getTextClass('bbcode')->parse_smilies = $r['entry_use_emo'] ? 1 : 0; IPSText::getTextClass('bbcode')->parsing_section = 'blog_entry'; IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others']; $r['content'] = IPSText::getTextClass('bbcode')->memberViewImages($r['content']); $r['content'] = IPSText::getTextClass('bbcode')->preDisplayParse($r['content']); $r = IPSMember::buildDisplayData($r); $content[] = $r; } break; case 'comments': $this->DB->build(array('select' => 'c.*', 'from' => array('blog_comments' => 'c'), 'where' => implode(' AND ', $where), 'order' => $order, 'limit' => array($config['offset_a'], $config['offset_b']), 'add_join' => array(array('select' => 'e.*', 'from' => array('blog_entries' => 'e'), 'where' => 'c.entry_id=e.entry_id', 'type' => 'left'), array('select' => 'b.*', 'from' => array('blog_blogs' => 'b'), 'where' => 'b.blog_id=e.blog_id', 'type' => 'left'), array('select' => 'm.*, m.member_id as mid', 'from' => array('members' => 'm'), 'where' => 'm.member_id=c.member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { //----------------------------------------- // Normalization //----------------------------------------- $r['member_id'] = $r['mid']; $r['url'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?app=blog&module=display&section=blog&blogid=' . $r['blog_id'] . '&showentry=' . $r['entry_id'], 'none'); $r['date'] = $r['comment_date']; $r['content'] = $r['comment_text']; $r['title'] = $r['entry_name']; IPSText::getTextClass('bbcode')->parse_html = $r['comment_html_state'] ? 1 : 0; IPSText::getTextClass('bbcode')->parse_bbcode = 1; IPSText::getTextClass('bbcode')->parse_nl2br = $r['comment_html_state'] == 2 ? 1 : 0; IPSText::getTextClass('bbcode')->parse_smilies = $r['comment_use_emo'] ? 1 : 0; IPSText::getTextClass('bbcode')->parsing_section = 'blog_comment'; IPSText::getTextClass('bbcode')->parsing_mgroup = $r['member_group_id']; IPSText::getTextClass('bbcode')->parsing_mgroup_others = $r['mgroup_others']; $r['content'] = IPSText::getTextClass('bbcode')->memberViewImages($r['content']); $r['content'] = IPSText::getTextClass('bbcode')->preDisplayParse($r['content']); $r = IPSMember::buildDisplayData($r); $content[] = $r; } break; case 'blogs': $this->DB->build(array('select' => 'b.*', 'from' => array('blog_blogs' => 'b'), 'where' => implode(' AND ', $where), 'order' => $order, 'limit' => array($config['offset_a'], $config['offset_b']), 'group' => 'b.blog_id', 'add_join' => array(array('select' => 'COUNT(e.entry_id) as entry_count, MAX(e.entry_id) as max_entry_id', 'from' => array('blog_entries' => 'e'), 'where' => 'e.blog_id=b.blog_id', 'type' => 'left'), array('select' => 'et.*', 'from' => array('blog_entries' => 'et'), 'where' => 'et.entry_id=max_entry_id', 'type' => 'left'), array('select' => 'm.*, m.member_id as mid', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left'), array('select' => 'pf.*', 'from' => array('pfields_content' => 'pf'), 'where' => 'pf.member_id=m.member_id', 'type' => 'left'), array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left')))); $outer = $this->DB->execute(); while ($r = $this->DB->fetch($outer)) { //----------------------------------------- // Normalization //----------------------------------------- $r['member_id'] = $r['mid']; $r['url'] = $this->registry->output->buildSEOUrl($this->settings['board_url'] . '/index.php?app=blog&module=display&section=blog&blogid=' . $r['blog_id'], 'none'); $r['title'] = $r['blog_name']; $r['date'] = $r['entry_date']; $r['content'] = $r['blog_desc']; $r = IPSMember::buildDisplayData($r); $content[] = $r; } break; } //----------------------------------------- // Return formatted content //----------------------------------------- $feedConfig = $this->returnFeedInfo(); $templateBit = $feedConfig['templateBit'] . '_' . $block['block_id']; if ($config['hide_empty'] and !count($content)) { return ''; } return $this->registry->output->getTemplate('ccs')->{$templateBit}($block['block_name'], $content); }
/** * Loads the content for the friends tab * * @access private * @return void [Prints to screen] * @since IPB 2.2.0.2006-08-15 */ private function _iframeList() { //----------------------------------------- // INIT //----------------------------------------- $member_id = intval($this->request['member_id']); $content = ''; $friends = array(); //----------------------------------------- // Load member //----------------------------------------- $member = IPSMember::load($member_id); //----------------------------------------- // Check //----------------------------------------- if (!$member['member_id']) { $this->returnString($this->lang->words['nofriendid']); } //----------------------------------------- // Grab the friends //----------------------------------------- $this->DB->build(array('select' => 'f.*', 'from' => array('profile_friends' => 'f'), 'where' => 'f.friends_member_id=' . $member_id . ' AND f.friends_approved=1', 'order' => 'm.members_display_name ASC', 'add_join' => array(1 => array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=f.friends_friend_id', 'type' => 'left'), 2 => array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=f.friends_friend_id', 'type' => 'left')))); $outer = $this->DB->execute(); //----------------------------------------- // Get and store... //----------------------------------------- while ($row = $this->DB->fetch($outer)) { $row['members_display_name_short'] = IPSText::truncate($row['members_display_name'], 13); $friends[] = IPSMember::buildDisplayData($row, 0); } //----------------------------------------- // Ok.. show the friends //----------------------------------------- $content = $this->registry->getClass('output')->getTemplate('profile')->friendsIframe($member, $friends); $this->returnHtml($content); }
/** * Hook: Recent topics * Moved here so we can update with out requiring global hook changes * * @param int Number of topics * @param bool Whether to output directly (true) or return array of topics (false) * @return mixed String if $output is true, array if $output is false */ public function hooks_recentTopics($topicCount = 5, $output = true) { /* INIT */ $topicIDs = array(); $topic_rows = array(); $timesUsed = array(); $bvnp = explode(',', $this->settings['vnp_block_forums']); $this->registry->class_localization->loadLanguageFile(array('public_topic', 'public_forums'), 'forums'); /* Grab last X data */ foreach ($this->forum_by_id as $forumID => $forumData) { if (!$forumData['can_view_others'] and !$this->_memberData['is_mod']) { continue; } if ($forumData['password'] != '') { continue; } if (!$this->registry->permissions->check('read', $forumData)) { continue; } if (is_array($bvnp) and count($bvnp)) { if (in_array($forumID, $bvnp)) { continue; } } /* Still here? */ $_topics = $this->lastXThaw($forumData['last_x_topic_ids']); if (is_array($_topics)) { foreach ($_topics as $id => $time) { if (in_array($time, $timesUsed)) { while (in_array($time, $timesUsed)) { $time += 1; } } $timesUsed[] = $time; $topicIDs[$time] = $id; } } } $timesUsed = array(); if (is_array($topicIDs) && count($topicIDs)) { krsort($topicIDs); /* We get up to double in case some of the latest are moved_to links - we do another array_slice afterwards to limit to right limit */ $_topics = array_slice($topicIDs, 0, $topicCount * 2); if (is_array($_topics) && count($_topics)) { /* Query Topics */ $this->registry->DB()->build(array('select' => 't.tid, t.title as topic_title, t.title_seo, t.start_date, t.starter_id, t.starter_name, t.moved_to, t.views, t.posts, t.topic_answered_pid', 'from' => array('topics' => 't'), 'where' => 't.tid IN (' . implode(',', array_values($_topics)) . ')', 'add_join' => array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=t.starter_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left')))); $outer = $this->registry->DB()->execute(); while ($r = $this->registry->DB()->fetch($outer)) { if (!empty($r['moved_to'])) { continue; } $time = $r['start_date']; if (in_array($time, $timesUsed)) { while (in_array($time, $timesUsed)) { $time += 1; } } $timesUsed[] = $time; $topics_rows[$time] = IPSMember::buildDisplayData($r); } /* Got any results? */ if (count($topics_rows)) { krsort($topics_rows); $topics_rows = array_slice($topics_rows, 0, $topicCount); } } } if ($output) { return $this->registry->output->getTemplate('boards')->hookRecentTopics($topics_rows); } else { return $topics_rows; } }
/** * Returns the editor for viewing ... * @param unknown_type $member */ public function getEditorHtml(array $member) { /* Fetch member data */ $member = IPSMember::buildDisplayData(IPSMember::load($member['member_id'], 'all')); $p_w = ""; $p_h = ""; $cur_photo = ""; $rand = urlencode(microtime()); $data = array('currentPhoto' => array('tag' => ''), 'custom' => array('tag' => ''), 'gravatar' => array('tag' => ''), 'twitter' => array('tag' => '')); /* Photo type */ $data['type'] = $member['pp_photo_type'] = $this->getPhotoType($member); /* Got gravatar? */ $member['pp_gravatar'] = $member['pp_gravatar'] ? $member['pp_gravatar'] : $member['email']; /* Quick permission check */ if (!IPSMember::canUploadPhoto($member, TRUE)) { return false; } /* Set the current photo */ $data['currentPhoto']['tag'] = IPSMember::buildProfilePhoto($member, 'full', IPS_MEMBER_PHOTO_NO_CACHE); /* Set up custom */ $data['custom']['tag'] = $member['pp_photo_type'] != 'custom' ? IPSMember::buildNoPhoto($member, 'thumb', false, true) : "<img src='" . $member['pp_thumb_photo'] . '?__rand=' . $rand . "' width='" . $member['pp_thumb_width'] . "' height='" . $member['pp_thumb_height'] . "' />"; /* Set up Gravatar */ $data['gravatar']['tag'] = "<img src='http://www.gravatar.com/avatar/" . md5($member['pp_gravatar']) . "?s=100' alt='' />"; /* Twitter linked? */ if (IPSLib::twitter_enabled() && $member['twitter_token'] && $member['twitter_secret']) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect'); $twitter = new $classToLoad($this->registry, $member['twitter_token'], $member['twitter_secret']); $userData = $twitter->fetchUserData(); if ($userData['profile_image_url']) { $data['twitter']['tag'] = "<img src='" . str_replace('_normal.', '.', $userData['profile_image_url']) . "' />"; } } /* Facebook linked? */ if (IPSLib::fbc_enabled() && $member['fb_uid']) { $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect'); $facebook = new $classToLoad($this->registry); /* Now get the linked user */ $linkedMemberData = IPSMember::load(intval($member['fb_uid']), 'all', 'fb_uid'); $userData = $facebook->fetchUserData(); if ($userData['pic_big']) { $data['facebook']['tag'] = "<img src='" . $userData['pic_big'] . "' />"; } else { if ($userData['pic']) { $data['facebook']['tag'] = "<img src='" . $userData['pic'] . "' />"; } } } $this->uploadFormMax = 5000 * 1024; return $this->registry->getClass('output')->getTemplate('profile')->photoEditor($data, $member); }
/** * Formats / grabs extra data for results * Takes an array of IDS (can be IDs from anything) and returns an array of expanded data. * * @param array $ids Ids * @return array */ public function processResultsComments($ids) { /* INIT */ $sort_order = IPSSearchRegistry::get('in.search_sort_order'); $search_term = IPSSearchRegistry::get('in.clean_search_term'); $content_title_only = IPSSearchRegistry::get('opt.searchType') == 'content' ? false : true; $members = array(); $results = array(); $statusIds = array(); $replyIds = IPSSearchRegistry::get('_internal.replyIds'); $replyData = IPSSearchRegistry::get('_internal.replyData'); $replies = array(); $sortKey = ''; /* Got some? */ if (count($ids)) { /* Set vars */ IPSSearch::$ask = 'status_date'; IPSSearch::$aso = strtolower($sort_order); IPSSearch::$ast = 'numerical'; /* Get the status updates */ $this->DB->build(array('select' => "s.*", 'from' => array('member_status_updates' => 's'), 'where' => 's.status_id IN( ' . implode(',', $ids) . ')', 'add_join' => array_merge(array(array('select' => 'm.member_id as owner_id, m.members_display_name as owner_display_name, m.members_seo_name as owner_seo_name', 'from' => array('members' => 'm'), 'where' => 'm.member_id=s.status_member_id', 'type' => 'left'), array('select' => 'mem.member_id as author_id, mem.members_display_name as author_display_name, mem.members_seo_name as author_seo_name', 'from' => array('members' => 'mem'), 'where' => 'mem.member_id=s.status_author_id', 'type' => 'left'))))); /* Grab data */ $this->DB->execute(); /* Grab the results */ while ($row = $this->DB->fetch()) { $statusIds[$row['status_id']] = $row; } /* Sort */ if (count($statusIds)) { usort($statusIds, array("IPSSearch", "usort")); foreach ($statusIds as $id => $row) { /* Do we have any reply data? */ if (!empty($replyData[$id])) { $row = array_merge($row, $replyData[$id]); } /* Get author data? */ if (!empty($row['status_author_id'])) { $members[$row['status_author_id']] = $row['status_author_id']; } if (!empty($row['status_member_id'])) { $members[$row['status_member_id']] = $row['status_member_id']; } if (!empty($row['reply_member_id'])) { $members[$row['reply_member_id']] = $row['reply_member_id']; } $results[$row['status_id']] = $row; } } /* Need to load members? */ if (count($members)) { $mems = IPSMember::load($members, 'all'); foreach ($results as $id => $r) { $_status_member = IPSMember::buildDisplayData($mems[$r['status_member_id']], array('reputation' => 0, 'warn' => 0)); $_status_author = IPSMember::buildDisplayData($mems[$r['status_author_id']], array('reputation' => 0, 'warn' => 0)); $results[$id]['status_member'] = $_status_member; $results[$id]['status_author'] = $_status_author; if (!empty($r['reply_member_id'])) { $results[$id]['reply_author'] = IPSMember::buildDisplayData($mems[$r['reply_member_id']], array('reputation' => 0, 'warn' => 0)); } } } } return $results; }