Пример #1
0
 /**
  * Create admin account
  *
  * @access	public
  * @return	@e void
  */
 public static function createAdminAccount()
 {
     /* Build Entry */
     $_mke_time = ipsRegistry::$settings['login_key_expire'] ? time() + intval(ipsRegistry::$settings['login_key_expire']) * 86400 : 0;
     $salt = IPSMember::generatePasswordSalt(5);
     $passhash = IPSMember::generateCompiledPasshash($salt, md5(IPSSetUp::getSavedData('admin_pass')));
     $_dname = IPSSetUp::getSavedData('admin_user');
     $member = array('name' => $_dname, 'members_l_username' => strtolower($_dname), 'members_display_name' => $_dname, 'members_l_display_name' => strtolower($_dname), 'members_seo_name' => IPSText::makeSeoTitle($_dname), 'member_login_key' => IPSMember::generateAutoLoginKey(), 'member_login_key_expire' => $_mke_time, 'title' => 'Administrator', 'email' => IPSSetUp::getSavedData('admin_email'), 'member_group_id' => 4, 'posts' => 1, 'joined' => time(), 'last_visit' => time(), 'last_activity' => time(), 'ip_address' => my_getenv('REMOTE_ADDR'), 'view_sigs' => 1, 'restrict_post' => 0, 'msg_show_notification' => 1, 'msg_count_total' => 0, 'msg_count_new' => 0, 'coppa_user' => 0, 'language' => IPSLib::getDefaultLanguage(), 'members_auto_dst' => 1, 'member_uploader' => 'flash', 'allow_admin_mails' => 0, 'members_pass_hash' => $passhash, 'members_pass_salt' => $salt, 'has_blog' => '', 'fb_token' => '', 'ignored_users' => '', 'members_cache' => '', 'failed_logins' => '', 'bday_day' => 0, 'bday_month' => 0, 'bday_year' => 0);
     /* Insert: MEMBERS */
     ipsRegistry::DB()->setDataType(array('name', 'members_display_name', 'members_l_username', 'members_l_display_name'), 'string');
     ipsRegistry::DB()->insert('members', $member);
     $member_id = ipsRegistry::DB()->getInsertId();
     $member['member_id'] = $member_id;
     /* Insert into the custom profile fields DB */
     ipsRegistry::DB()->insert('pfields_content', array('member_id' => $member_id));
     /* Insert into pp */
     ipsRegistry::DB()->insert('profile_portal', array('pp_member_id' => $member_id, 'pp_setting_count_friends' => 1, 'signature' => '', 'pconversation_filters' => '', 'pp_setting_count_comments' => 1, 'pp_setting_count_visitors' => 1));
 }
Пример #2
0
 /**
  * Get Content URL
  *
  * @param	array		$warning		Row from members_warn_logs
  * @return	@e array	array( url => URL to the content the warning came from, title => Title )
  */
 public function getContentUrl($warning)
 {
     if (is_numeric($warning['wl_content_id1'])) {
         $post = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'posts', 'where' => "pid={$warning['wl_content_id1']}"));
         if (!empty($post['topic_id'])) {
             $topic = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'topics', 'where' => "tid={$post['topic_id']}"));
             if (!empty($topic['tid'])) {
                 return array('url' => ipsRegistry::getClass('output')->buildSEOUrl("showtopic={$topic['tid']}&findpost={$post['pid']}", 'public', $topic['title_seo'], 'showtopic'), 'title' => $topic['title']);
             }
         }
     } elseif ($warning['wl_content_id1'] == 'announcement') {
         $announcement = ipsRegistry::DB()->buildAndFetch(array('select' => '*', 'from' => 'announcements', 'where' => "announce_id=" . intval($warning['wl_content_id2'])));
         if (!empty($announcement['announce_id'])) {
             return array('url' => ipsRegistry::getClass('output')->buildSEOUrl("showannouncement={$announcement['announce_id']}", 'public', IPSText::makeSeoTitle($announcement['announce_title']), 'showannouncement'), 'title' => $announcement['announce_title']);
         }
     }
     return NULL;
 }
Пример #3
0
 /**
  * Sort out profile fields
  * 
  * @return	@e void
  */
 public function addProfile()
 {
     /* INIT */
     $fields = array();
     $prefix = $this->registry->dbFunctions()->getPrefix();
     $sourceFile = '';
     /* Get DB driver file */
     require_once IPSLib::getAppDir('core') . '/setup/versions/upg_30001/' . strtolower($this->registry->dbFunctions()->getDriverType()) . '_version_upgrade.php';
     /*noLibHook*/
     /* First off, move all current profile fields to group ID 3 */
     $this->DB->update('pfields_data', array('pf_group_id' => 3), 'pf_group_id=0');
     /* Grab all custom fields */
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $fields[$row['pf_id']] = $row;
     }
     foreach ($fields as $id => $data) {
         /* Now add any missing content fields */
         if (!$this->DB->checkForField("field_{$id}", 'pfields_content')) {
             $this->DB->addField('pfields_content', "field_{$id}", 'text');
         }
     }
     $this->DB->optimize('pfields_content');
     /* Now make add a key */
     $this->DB->build(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_group_id=3'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         /* Attempt basic conversion of data */
         if ($row['pf_topic_format']) {
             if ($row['pf_topic_format'] == '{title}: {content}<br />') {
                 $row['pf_topic_format'] = '<span class="ft">{title}:</span><span class="fc">{content}</span>';
             } else {
                 if ($row['pf_topic_format'] == '{title}: {key}<br />') {
                     $row['pf_topic_format'] = '<span class="ft">{title}:</span><span class="fc">{key}</span>';
                 }
             }
         }
         /* 2.3.x used 'text', 3.0.0 uses 'input'... */
         $row['pf_type'] = $row['pf_type'] == 'text' ? 'input' : $row['pf_type'];
         $this->DB->update('pfields_data', array('pf_type' => $row['pf_type'], 'pf_topic_format' => $row['pf_topic_format'], 'pf_key' => IPSText::makeSeoTitle($row['pf_title'])), 'pf_id=' . $row['pf_id']);
     }
     /* Now, move profile data into the correct fields */
     foreach (array('aim_name' => 'aim', 'icq_number' => 'icq', 'website' => 'website', 'yahoo' => 'yahoo', 'interests' => 'interests', 'msnname' => 'msn', 'location' => 'location') as $old => $new) {
         $field = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_key=\'' . $new . '\''));
         $query = SQLVC::UpdateOne($old, $field);
         if (is_null($query)) {
             continue;
         }
         if (IPSSetUp::getSavedData('man')) {
             $query = trim($query);
             /* Ensure the last character is a semi-colon */
             if (substr($query, -1) != ';') {
                 $query .= ';';
             }
             $output .= $query . "\n\n";
         } else {
             $this->DB->query($query);
             if ($this->DB->error) {
                 $this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
             } else {
                 $this->registry->output->addMessage("Конвертирование поля: {$old}....");
             }
         }
     }
     /* Update gender */
     $gender = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'pfields_data', 'where' => 'pf_key=\'gender\''));
     if ($gender['pf_id']) {
         $queries = array(SQLVC::UpdateTwo($gender), SQLVC::UpdateThree($gender));
         foreach ($queries as $query) {
             if (IPSSetUp::getSavedData('man')) {
                 $query = trim($query);
                 /* Ensure the last character is a semi-colon */
                 if (substr($query, -1) != ';') {
                     $query .= ';';
                 }
                 $output .= $query . "\n\n";
             } else {
                 $this->DB->query($query);
                 if ($this->DB->error) {
                     $this->registry->output->addError($query . "<br /><br />" . $this->DB->error);
                 } else {
                     $this->registry->output->addMessage("Конвертирование поля «Пол»....");
                 }
             }
         }
     }
     if (IPSSetUp::getSavedData('man') and $output) {
         /* Create source file */
         if ($this->registry->dbFunctions()->getDriverType() == 'mysql') {
             $sourceFile = IPSSetUp::createSqlSourceFile($output, '30001', 'pf');
         }
         $this->_output = $this->registry->output->template()->upgrade_manual_queries($output, $sourceFile);
     }
     /* Next Page */
     $this->request['workact'] = 'permsAndBbcode';
 }
Пример #4
0
 /**
  * Generates the sql to query events
  *
  * @param	integer	$month		Month to get events from
  * @param	integer	$year		Year to get events from
  * @param	array	[$presets]	Load based on specific timestamps
  * @return	@e void
  */
 public function calendarGetEventsSQL($month = 0, $year = 0, $presets = array())
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $minimal = (isset($presets['minimal']) and $presets['minimal']) ? true : false;
     if (isset($presets['timenow'])) {
         $prev_month = $this->calendarGetPreviousMonth(gmstrftime("%m", $presets['timenow']), gmstrftime("%Y", $presets['timenow']));
     } else {
         $prev_month = $this->calendarGetPreviousMonth($month, $year);
     }
     if (isset($presets['timethen'])) {
         $next_month = $this->calendarGetNextMonth(gmstrftime("%m", $presets['timethen']), gmstrftime("%Y", $presets['timethen']));
     } else {
         $next_month = $this->calendarGetNextMonth($month, $year);
     }
     $start_date = gmstrftime("%Y-%m-%d", isset($presets['timenow']) ? $presets['timenow'] : gmmktime(0, 0, 1, $prev_month['month_id'], 1, $prev_month['year_id']));
     $end_date = gmstrftime("%Y-%m-%d", isset($presets['timethen']) ? $presets['timethen'] : gmmktime(0, 0, 1, $next_month['month_id'], date('t', mktime(0, 0, 0, $next_month['month_id'], 1, $next_month['year_id'])), $next_month['year_id']));
     $getcached = (count($presets) and (!isset($presets['honor_permissions']) or !$presets['honor_permissions'])) ? 1 : 0;
     list($_endYear, $_endMonth, $_endDay) = explode('-', $end_date);
     //-----------------------------------------
     // Get the events (if we haven't already)
     //-----------------------------------------
     if (!array_key_exists($month, $this->events)) {
         $this->events[$month] = array();
         if ($getcached) {
             $where = (!empty($presets['cal_id']) ? "e.event_calendar_id=" . intval($presets['cal_id']) . " AND " : '') . "e.event_approved=1";
         } else {
             $where = "e.event_calendar_id={$this->calendar['cal_id']} AND " . ($this->memberData['g_is_supmod'] ? "e.event_approved IN (0,1)" : "e.event_approved=1");
         }
         //-----------------------------------------
         // Query DB for events and loop
         //-----------------------------------------
         if (!$minimal) {
             $_joins = array(array('select' => 'm.*', 'from' => array('members' => 'm'), 'where' => 'm.member_id=e.event_member_id', 'type' => 'left'), array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'm.member_id=pp.pp_member_id', 'type' => 'left'));
             if ($this->settings['reputation_enabled']) {
                 $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_reputation_cache.php', 'classReputationCache');
                 $this->registry->setClass('repCache', new $classToLoad());
                 $_joins[] = $this->registry->getClass('repCache')->getTotalRatingJoin('event_id', 'e.event_id', 'calendar');
                 $_joins[] = $this->registry->getClass('repCache')->getUserHasRatedJoin('event_id', 'e.event_id', 'calendar');
             }
         }
         $this->DB->build(array('select' => 'e.*', 'from' => $minimal ? 'cal_events e' : array('cal_events' => 'e'), 'add_join' => $_joins, 'where' => $where . " AND ( \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t( e.event_start_date <= '{$end_date}' AND e.event_end_date >= '{$start_date}' ) OR\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t( ( e.event_end_date " . $this->DB->buildIsNull(true) . " OR e.event_end_date='0000-00-00 00:00:00' ) AND e.event_start_date >= '{$start_date}' AND e.event_start_date <= '{$end_date}' ) OR \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t( e.event_recurring=3 AND " . $this->DB->buildDateFormat('event_start_date', '%c') . "={$month} AND e.event_end_date <= '{$end_date}' ) )"));
         $outer = $this->DB->execute();
         while ($r = $this->DB->fetch($outer)) {
             //-----------------------------------------
             // Exclude private events
             //-----------------------------------------
             if ($r['event_private'] and !$getcached) {
                 if (!$this->memberData['member_id'] or $this->memberData['member_id'] != $r['event_member_id']) {
                     continue;
                 }
             }
             //-----------------------------------------
             // Check event permissions
             //-----------------------------------------
             if ($r['event_perms'] != '*' and !$getcached) {
                 $permissionGroups = explode(',', IPSText::cleanPermString($r['event_perms']));
                 if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
                     continue;
                 }
             }
             //-----------------------------------------
             // Dynamically fix missing SEO titles
             //-----------------------------------------
             if (!$r['event_title_seo']) {
                 $r['event_title_seo'] = IPSText::makeSeoTitle($r['event_title']);
                 $this->DB->update('cal_events', array('event_title_seo' => $r['event_title_seo']), 'event_id=' . $r['event_id']);
             }
             //-----------------------------------------
             // Create time info for PHP date functions
             //-----------------------------------------
             $_startTime = strtotime($r['event_start_date']);
             $_endTime = ($r['event_end_date'] and $r['event_end_date'] != '0000-00-00 00:00:00') ? strtotime($r['event_end_date']) : 0;
             if (!$r['event_all_day'] and !$presets['no_date_convert']) {
                 if ($this->memberData['member_id'] and $this->memberData['time_offset']) {
                     $_startTime = $_startTime + $this->memberData['time_offset'] * 3600;
                 } else {
                     if (!$this->memberData['member_id'] and $this->settings['time_offset']) {
                         $_startTime = $_startTime + $this->settings['time_offset'] * 3600;
                     }
                 }
                 if ($this->memberData['member_id'] and $this->memberData['time_offset']) {
                     $_endTime = $_endTime ? $_endTime + $this->memberData['time_offset'] * 3600 : 0;
                 } else {
                     if (!$this->memberData['member_id'] and $this->settings['time_offset']) {
                         $_endTime = $_endTime ? $_endTime + $this->settings['time_offset'] * 3600 : 0;
                     }
                 }
             }
             $r['event_start_date'] = gmstrftime("%Y-%m-%d %H:%M:%S", $_startTime);
             $r['event_end_date'] = gmstrftime("%Y-%m-%d %H:%M:%S", $_endTime);
             list($_year, $_month, $_day) = explode('-', gmdate('Y-m-d', $_startTime));
             //-----------------------------------------
             // Recurring events
             //-----------------------------------------
             if ($r['event_recurring'] > 0) {
                 $r['recurring'] = 1;
                 if (($_month == $month or $_month == $_endMonth) and ($_year == $year or $r['event_recurring'] == 3)) {
                     $this->events[$_month]['recurring'][$r['event_id']] = $r;
                 }
                 //-----------------------------------------
                 // Loop to add to other months as needed
                 // Don't need to add yearly as we only check month
                 //-----------------------------------------
                 if ($r['event_recurring'] < 3) {
                     while ($_startTime < $_endTime) {
                         //-----------------------------------------
                         // Only add if not already present
                         //-----------------------------------------
                         if (!isset($this->events[$_month]['recurring'][$r['event_id']])) {
                             if (($_month == $month or $_month == $next_month['month_id'] or $_month == $prev_month['month_id']) and $_year == $year or $getcached) {
                                 $this->events[$_month]['recurring'][$r['event_id']] = $r;
                             }
                         }
                         //-----------------------------------------
                         // Increment timestamps and reset month/year
                         //-----------------------------------------
                         if ($r['event_recurring'] == 1) {
                             $_startTime = strtotime(gmstrftime("%Y-%m-%d", $_startTime) . " +1 week");
                         } elseif ($r['event_recurring'] == 2) {
                             $_startTime = strtotime(gmstrftime("%Y-%m-%d", $_startTime) . " +1 month");
                         }
                         $_month = gmstrftime('%m', $_startTime);
                         $_year = gmstrftime('%Y', $_startTime);
                     }
                 }
             } else {
                 if (!$r['event_recurring'] and $_endTime) {
                     $r['ranged'] = 1;
                     //-----------------------------------------
                     // Daily loop
                     //-----------------------------------------
                     while ($_startTime <= $_endTime) {
                         if ($_startTime < gmmktime(0, 0, 1, $prev_month['month_id'], 1, $prev_month['year_id']) or $_startTime > gmmktime(0, 0, 1, $next_month['month_id'], 31, $next_month['year_id'])) {
                             $_startTime += 3600;
                             continue;
                         }
                         $_dayOfMonth = gmstrftime("%d", $_startTime);
                         $_month = gmstrftime("%m", $_startTime);
                         $this->events[$_month]['ranged'][$_dayOfMonth][$r['event_id']] = $r;
                         $_startTime += 3600;
                     }
                 } else {
                     $r['single'] = 1;
                     $this->events[$_month]['single'][$_day][$r['event_id']] = $r;
                 }
             }
         }
     }
 }
Пример #5
0
 /**
  * Convert Posts
  *
  * @access	private
  * @return void
  **/
 private function convert_posts()
 {
     //---------------------------
     // Primary Key
     //---------------------------
     $this->lib->useKey('postID');
     //---------------------------
     // Set up
     //---------------------------
     $main = array('select' => '*', 'from' => $this->pb . 'post', 'order' => 'postID ASC');
     $loop = $this->lib->load('posts', $main);
     //-----------------------------------------
     // Prepare for reports conversion
     //-----------------------------------------
     $this->lib->prepareReports('post');
     $new = $this->DB->buildAndFetch(array('select' => 'status', 'from' => 'rc_status', 'where' => 'is_new=1'));
     //---------------------------
     // Loop
     //---------------------------
     while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
         $save = array('topic_id' => $row['threadID'], 'author_id' => $row['userID'], 'author_name' => $row['username'], 'post' => $this->fixPostData($row['message']), 'post_date' => $row['time'], 'use_emo' => $row['enableSmilies'], 'post_htmlstate' => $row['enableHtml'], 'use_sig' => $row['showSignature'], 'ip_address' => $row['ipAddress']);
         $this->lib->convertPost($row['postID'], $save);
         $this->lib->setLastKeyValue($row['postID']);
         //-----------------------------------------
         // Report Center
         //-----------------------------------------
         $link = $this->lib->getLink($row['threadID'], 'topics');
         if (!$link) {
             continue;
         }
         $rc = $this->DB->buildAndFetch(array('select' => 'com_id', 'from' => 'rc_classes', 'where' => "my_class='post'"));
         $forum = $this->DB->buildAndFetch(array('select' => 'forum_id, title', 'from' => 'topics', 'where' => 'tid=' . $link));
         $rs = array('select' => '*', 'from' => $this->pb . 'post_report', 'order' => 'reportID ASC', 'where' => 'postID=' . $row['postID']);
         ipsRegistry::DB('hb')->build($rs);
         $res = ipsRegistry::DB('hb')->execute();
         $reports = array();
         while ($rget = ipsRegistry::DB('hb')->fetch($res)) {
             $report = array('id' => $rget['reportID'], 'title' => "Reported post #{$row['postID']}", 'status' => $new['status'], 'rc_class' => $rc['com_id'], 'updated_by' => $rget['userID'], 'date_updated' => $rget['reportTime'], 'date_created' => $rget['reportTime'], 'exdat1' => $forum['forum_id'], 'exdat2' => $row['threadID'], 'exdat3' => $row['postID'], 'num_reports' => '1', 'num_comments' => '0', 'seoname' => IPSText::makeSeoTitle($forum['title']));
             $reports = array(array('id' => $rget['reportID'], 'report' => $rget['report'], 'report_by' => $rget['userID'], 'date_reported' => $rget['reportTime']));
             $this->lib->convertReport('post', $report, $reports, false);
         }
     }
     $this->lib->next();
 }
 /**
  * Parase Topic Data
  *
  * @access	public
  * @param	array	$topic				Topic data
  * @param	bool	$last_time_default	Use default "last read time"
  * @return	array
  **/
 public function parseTopicData($topic, $last_time_default = true)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $topic['real_tid'] = $topic['tid'];
     $topic['_last_post'] = $topic['last_post'];
     //-----------------------------------------
     // Do we have an SEO title?
     //-----------------------------------------
     $_hasSEOTitle = false;
     if ($topic['title_seo']) {
         $_hasSEOTitle = true;
     }
     $topic['title_seo'] = $topic['title_seo'] ? $topic['title_seo'] : IPSText::makeSeoTitle($topic['title']);
     /**
      * Here we'll take the one query hit to update in order to speed it up in the future
      */
     if (!$_hasSEOTitle and $this->settings['use_friendly_urls']) {
         $this->DB->update('topics', array('title_seo' => $topic['title_seo'] ? $topic['title_seo'] : '-'), 'tid=' . $topic['tid']);
     }
     //-----------------------------------------
     // Need to update this topic?
     //-----------------------------------------
     if ($topic['state'] == 'open') {
         if (!$topic['topic_open_time'] or $topic['topic_open_time'] < $topic['topic_close_time']) {
             if ($topic['topic_close_time'] and ($topic['topic_close_time'] <= time() and (time() >= $topic['topic_open_time'] or !$topic['topic_open_time']))) {
                 $topic['state'] = 'closed';
                 $this->update_topics_close[] = $topic['real_tid'];
             }
         } else {
             if ($topic['topic_open_time'] or $topic['topic_open_time'] > $topic['topic_close_time']) {
                 if ($topic['topic_close_time'] and ($topic['topic_close_time'] <= time() and time() <= $topic['topic_open_time'])) {
                     $topic['state'] = 'closed';
                     $this->update_topics_close[] = $topic['real_tid'];
                 }
             }
         }
     } else {
         if ($topic['state'] == 'closed') {
             if (!$topic['topic_close_time'] or $topic['topic_close_time'] < $topic['topic_open_time']) {
                 if ($topic['topic_open_time'] and ($topic['topic_open_time'] <= time() and (time() >= $topic['topic_close_time'] or !$topic['topic_close_time']))) {
                     $topic['state'] = 'open';
                     $this->update_topics_open[] = $topic['real_tid'];
                 }
             } else {
                 if ($topic['topic_close_time'] or $topic['topic_close_time'] > $topic['topic_open_time']) {
                     if ($topic['topic_open_time'] and ($topic['topic_open_time'] <= time() and time() <= $topic['topic_close_time'])) {
                         $topic['state'] = 'open';
                         $this->update_topics_open[] = $topic['real_tid'];
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // For polls we check last vote instead
     // @todo [Future] Show a diff icon for new vote + new reply, new vote + no new reply, etc.
     // Bug 16598: Need separate checks for icon vs getnewpost link
     //-----------------------------------------
     if ($topic['poll_state'] and $topic['last_vote'] > $topic['last_post']) {
         $is_read = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_vote']), 'forums');
         $gotonewpost = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_post']), 'forums');
     } else {
         $is_read = $this->registry->classItemMarking->isRead(array('forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_post']), 'forums');
         $gotonewpost = $is_read;
     }
     //-----------------------------------------
     // Yawn
     //-----------------------------------------
     $topic['last_poster'] = $topic['last_poster_id'] ? IPSLib::makeProfileLink($topic['last_poster_name'], $topic['last_poster_id'], $topic['seo_last_name']) : $this->settings['guest_name_pre'] . $topic['last_poster_name'] . $this->settings['guest_name_suf'];
     $topic['starter'] = $topic['starter_id'] ? IPSLib::makeProfileLink($topic['starter_name'], $topic['starter_id'], $topic['seo_first_name']) : $this->settings['guest_name_pre'] . $topic['starter_name'] . $this->settings['guest_name_suf'];
     $topic['prefix'] = $topic['poll_state'] ? $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap($this->settings['pre_polls']) : '';
     $show_dots = "";
     if ($this->memberData['member_id'] and (isset($topic['author_id']) and $topic['author_id'])) {
         $show_dots = 1;
     }
     $topic['folder_img'] = $this->registry->getClass('class_forums')->fetchTopicFolderIcon($topic, $show_dots, $is_read);
     /* SKINNOTE: Change these so that the link is built in the skin, not here */
     $topic['topic_icon'] = $topic['icon_id'] ? '<img src="' . $this->settings['mime_img'] . '/style_extra/post_icons/icon' . $topic['icon_id'] . '.gif" border="0" alt="" />' : '&nbsp;';
     $topic['topic_icon'] = $topic['pinned'] ? '<{B_PIN}>' : $topic['topic_icon'];
     $topic['start_date'] = $this->registry->getClass('class_localization')->getDate($topic['start_date'], 'LONG');
     //-----------------------------------------
     // Pages 'n' posts
     //-----------------------------------------
     $pages = 1;
     $topic['PAGES'] = "";
     if ($this->memberData['is_mod']) {
         $topic['posts'] += intval($topic['topic_queuedposts']);
     }
     if ($topic['posts']) {
         $mode = IPSCookie::get('topicmode');
         if ($mode == 'threaded') {
             $this->settings['display_max_posts'] = $this->settings['threaded_per_page'];
         }
         if (($topic['posts'] + 1) % $this->settings['display_max_posts'] == 0) {
             $pages = ($topic['posts'] + 1) / $this->settings['display_max_posts'];
         } else {
             $number = ($topic['posts'] + 1) / $this->settings['display_max_posts'];
             $pages = ceil($number);
         }
     }
     if ($pages > 1) {
         for ($i = 0; $i < $pages; ++$i) {
             $real_no = $i * $this->settings['display_max_posts'];
             $page_no = $i + 1;
             if ($page_no == 4 and $pages > 4) {
                 $topic['pages'][] = array('last' => 1, 'st' => ($pages - 1) * $this->settings['display_max_posts'], 'page' => $pages);
                 break;
             } else {
                 $topic['pages'][] = array('last' => 0, 'st' => $real_no, 'page' => $page_no);
             }
         }
     }
     //-----------------------------------------
     // Format some numbers
     //-----------------------------------------
     $topic['posts'] = $this->registry->getClass('class_localization')->formatNumber(intval($topic['posts']));
     $topic['views'] = $this->registry->getClass('class_localization')->formatNumber(intval($topic['views']));
     //-----------------------------------------
     // Jump to latest post / last time stuff...
     //-----------------------------------------
     if (!$gotonewpost) {
         $topic['go_new_post'] = true;
     } else {
         $topic['go_new_post'] = false;
     }
     $topic['last_post'] = $this->registry->getClass('class_localization')->getDate($topic['last_post'], 'SHORT');
     //-----------------------------------------
     // Linky pinky!
     //-----------------------------------------
     if ($topic['state'] == 'link') {
         $t_array = explode("&", $topic['moved_to']);
         $topic['tid'] = $t_array[0];
         $topic['forum_id'] = $t_array[1];
         $topic['title'] = $topic['title'];
         $topic['views'] = '--';
         $topic['posts'] = '--';
         $topic['prefix'] = $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap($this->settings['pre_moved']);
         $topic['go_new_post'] = false;
     } else {
         $topic['_posts'] = $topic['posts'];
         $topic['posts'] = $this->registry->getClass('output')->getTemplate('forum')->who_link($topic['tid'], $topic['posts']);
     }
     $topic['_hasqueued'] = 0;
     $mod = $this->memberData['forumsModeratorData'];
     $mod = $mod ? $mod : array();
     if (($this->memberData['g_is_supmod'] or $mod[$topic['forum_id']]['post_q'] and $mod[$topic['forum_id']]['post_q'] == 1) and $topic['topic_queuedposts']) {
         $topic['_hasqueued'] = 1;
     }
     //-----------------------------------------
     // Topic rating
     //-----------------------------------------
     $topic['_rate_img'] = '';
     if (isset($this->forum['forum_allow_rating']) and $this->forum['forum_allow_rating']) {
         if ($topic['topic_rating_total']) {
             $topic['_rate_int'] = round($topic['topic_rating_total'] / $topic['topic_rating_hits']);
         }
         //-----------------------------------------
         // Show image?
         //-----------------------------------------
         if ($topic['topic_rating_hits'] >= $this->settings['topic_rating_needed'] and $topic['_rate_int']) {
             $topic['_rate_img'] = $this->registry->getClass('output')->getTemplate('forum')->topic_rating_image($topic['_rate_int']);
         }
     }
     //-----------------------------------------
     // Already switched on?
     //-----------------------------------------
     if ($this->memberData['is_mod']) {
         if ($this->request['selectedtids']) {
             if (strstr(',' . $this->request['selectedtids'] . ',', ',' . $topic['tid'] . ',')) {
                 $topic['tidon'] = 1;
             } else {
                 $topic['tidon'] = 0;
             }
         }
     }
     return $topic;
 }
 /**
  * Updates member's DB row name or members_display_name
  *
  * @todo 	[Future] Separate out forum specific stuff (moderators, etc) and move into hooks 
  * @access	public
  * @param	string		Member id
  * @param	string		New name
  * @param	string		Field to update (name or display name)
  * @return	mixed		True if update successful, otherwise exception or false
  * Error Codes:
  * NO_USER				Could not load the user
  * NO_PERMISSION		This user cannot change their display name at all
  * NO_MORE_CHANGES		The user cannot change their display name again in this time period
  * NO_NAME				No display name (or shorter than 3 chars was given)
  * ILLEGAL_CHARS		The display name contains illegal characters
  * USER_NAME_EXISTS		The username already exists
  */
 public function updateName($member_id, $name, $field = 'members_display_name')
 {
     //-----------------------------------------
     // Load the member
     //-----------------------------------------
     $member = IPSMember::load($member_id);
     $_seoName = IPSText::makeSeoTitle($name);
     if (!$member['member_id']) {
         throw new Exception("NO_USER");
     }
     //-----------------------------------------
     // Make sure name does not exist
     //-----------------------------------------
     try {
         if ($this->checkNameExists($name, $member, $field) === TRUE) {
             throw new Exception("USER_NAME_EXISTS");
         } else {
             if ($field == 'members_display_name') {
                 $this->DB->force_data_type = array('dname_previous' => 'string', 'dname_current' => 'string');
                 $this->DB->insert('dnames_change', array('dname_member_id' => $member_id, 'dname_date' => time(), 'dname_ip_address' => $member['ip_address'], 'dname_previous' => $member['members_display_name'], 'dname_current' => $name));
                 //-----------------------------------------
                 // Still here? Change it then
                 //-----------------------------------------
                 IPSMember::save($member['member_id'], array('core' => array('members_display_name' => $name, 'members_l_display_name' => strtolower($name), 'members_seo_name' => $_seoName)));
                 $this->DB->force_data_type = array('last_poster_name' => 'string', 'seo_last_name' => 'string');
                 $this->DB->update('forums', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                 $this->DB->force_data_type = array('member_name' => 'string', 'seo_name' => 'string');
                 $this->DB->update('sessions', array('member_name' => $name, 'seo_name' => $_seoName), "member_id=" . $member['member_id']);
                 $this->DB->force_data_type = array('starter_name' => 'string', 'seo_first_name' => 'string');
                 $this->DB->update('topics', array('starter_name' => $name, 'seo_first_name' => $_seoName), "starter_id=" . $member['member_id']);
                 $this->DB->force_data_type = array('last_poster_name' => 'string', 'seo_last_name' => 'string');
                 $this->DB->update('topics', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
             } else {
                 //-----------------------------------------
                 // If one gets here, one can assume that the new name is correct for one, er...one.
                 // So, lets do the converteroo
                 //-----------------------------------------
                 IPSMember::save($member['member_id'], array('core' => array('name' => $name, 'members_l_username' => strtolower($name), 'members_seo_name' => $_seoName)));
                 $this->DB->force_data_type = array('member_name' => 'string');
                 $this->DB->update('moderators', array('member_name' => $name), "member_id=" . $member['member_id']);
                 if (!$this->settings['auth_allow_dnames']) {
                     //-----------------------------------------
                     // Not using sep. display names?
                     //-----------------------------------------
                     IPSMember::save($member['member_id'], array('core' => array('members_display_name' => $name, 'members_l_display_name' => strtolower($name), 'members_seo_name' => $_seoName)));
                     $this->DB->force_data_type = array('last_poster_name' => 'string', 'seo_last_name' => 'string');
                     $this->DB->update('forums', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                     $this->DB->force_data_type = array('member_name' => 'string', 'seo_name' => 'string');
                     $this->DB->update('sessions', array('member_name' => $name, 'seo_name' => $_seoName), "member_id=" . $member['member_id']);
                     $this->DB->force_data_type = array('starter_name' => 'string', 'seo_first_name' => 'string');
                     $this->DB->update('topics', array('starter_name' => $name, 'seo_first_name' => $_seoName), "starter_id=" . $member['member_id']);
                     $this->DB->force_data_type = array('last_poster_name' => 'string', 'seo_last_name' => 'string');
                     $this->DB->update('topics', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                 }
             }
             //-----------------------------------------
             // Recache moderators
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('moderators', 'forums');
             //-----------------------------------------
             // Recache announcements
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('announcements', 'forums');
             //-----------------------------------------
             // Stats to Update?
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('stats', 'core');
             IPSLib::runMemberSync('onNameChange', $member['member_id'], $name);
             return TRUE;
         }
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
 }
Пример #8
0
 /**
  * Processes the registration form
  *
  * @return	@e void
  */
 public function registerProcessForm()
 {
     $this->_resetMember();
     $form_errors = array();
     $coppa = $this->request['coppa_user'] == 1 ? 1 : 0;
     $in_password = trim($this->request['PassWord']);
     $in_email = strtolower(trim($this->request['EmailAddress']));
     /* Did we agree to the t&c? */
     if (!$this->request['agree_tos']) {
         $form_errors['tos'] = array($this->lang->words['must_agree_to_terms']);
     }
     /* Custom profile field stuff */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields');
     $custom_fields = new $classToLoad();
     $custom_fields->initData('edit');
     $custom_fields->parseToSave($_POST, 'register');
     /* Check */
     if ($custom_fields->error_messages) {
         $form_errors['general'] = $custom_fields->error_messages;
     }
     /* Check the email address */
     if (!$in_email or strlen($in_email) < 6 or !IPSText::checkEmailAddress($in_email)) {
         $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email'];
     }
     if (trim($this->request['PassWord_Check']) != $in_password or !$in_password) {
         $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match'];
     }
     /*
     There's no reason for this - http://community.invisionpower.com/resources/bugs.html/_/ip-board/registrations-limit-passwords-to-32-characters-for-no-apparent-reason-r37770
     elseif ( strlen( $in_password ) < 3 )
     {
     	$form_errors['password'][$this->lang->words['pass_too_short']] = $this->lang->words['pass_too_short'];
     }
     elseif ( strlen( $in_password ) > 32 )
     {
     	$form_errors['password'][$this->lang->words['pass_too_long']] = $this->lang->words['pass_too_long'];
     }
     */
     /* Check the username */
     $user_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'name');
     $disp_check = IPSMember::getFunction()->cleanAndCheckName($this->request['members_display_name'], array(), 'members_display_name');
     if (is_array($user_check['errors']) && count($user_check['errors'])) {
         foreach ($user_check['errors'] as $key => $error) {
             $form_errors['dname'][$error] = isset($this->lang->words[$error]) ? $this->lang->words[$error] : $error;
         }
     }
     /* this duplicates username error above */
     /*if( is_array( $disp_check['errors'] ) && count( $disp_check['errors'] ) )
     		{
     			foreach( $disp_check['errors'] as $key => $error )
     			{
     				$form_errors['dname'][ $error ]	= isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
     			}
     		}*/
     /* Is this email addy taken? */
     if (IPSMember::checkByEmail($in_email) == TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* Load handler... */
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
     $this->han_login = new $classToLoad($this->registry);
     $this->han_login->init();
     $this->han_login->emailExistsCheck($in_email);
     if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'EMAIL_NOT_IN_USE') {
         $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
     }
     /* Are they banned [EMAIL]? */
     if (IPSMember::isBanned('email', $in_email) === TRUE) {
         $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban'];
     }
     /* Check the CAPTCHA */
     if ($this->settings['bot_antispam_type'] != 'none') {
         if ($this->registry->getClass('class_captcha')->validate() !== TRUE) {
             $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code'];
         }
     }
     /* Check the Q and A */
     $qanda = intval($this->request['qanda_id']);
     $pass = true;
     if ($qanda) {
         $pass = false;
         $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda));
         if ($data['qa_id']) {
             $answers = explode("\n", str_replace("\r", "", $data['qa_answers']));
             if (count($answers)) {
                 foreach ($answers as $answer) {
                     $answer = trim($answer);
                     if (IPSText::mbstrlen($answer) and mb_strtolower($answer) == mb_strtolower($this->request['qa_answer'])) {
                         $pass = true;
                         break;
                     }
                 }
             }
         }
     } else {
         //-----------------------------------------
         // Do we have any questions?
         //-----------------------------------------
         $data = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as questions', 'from' => 'question_and_answer'));
         if ($data['questions']) {
             $pass = false;
         }
     }
     if (!$pass) {
         $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a'];
     }
     /* CHECK 2: Any errors ? */
     if (count($form_errors)) {
         $this->registerForm($form_errors);
         return;
     }
     /* Build up the hashes */
     $mem_group = $this->settings['member_group'];
     /* Are we asking the member or admin to preview? */
     if ($this->settings['reg_auth_type']) {
         $mem_group = $this->settings['auth_group'];
     } else {
         if ($coppa == 1) {
             $mem_group = $this->settings['auth_group'];
         }
     }
     /* Create member */
     $member = array('name' => $this->request['members_display_name'], 'password' => $in_password, 'members_display_name' => $this->request['members_display_name'], 'email' => $in_email, 'member_group_id' => $mem_group, 'joined' => time(), 'ip_address' => $this->member->ip_address, 'time_offset' => $this->request['time_offset'], 'coppa_user' => $coppa, 'members_auto_dst' => intval($this->settings['time_dst_auto_correction']), 'allow_admin_mails' => intval($this->request['allow_admin_mail']), 'language' => $this->member->language_id);
     /* Spam Service */
     $spamCode = 0;
     $_spamFlag = 0;
     if ($this->settings['spam_service_enabled']) {
         /* Query the service */
         $spamCode = IPSMember::querySpamService($in_email);
         /* Action to perform */
         $action = $this->settings['spam_service_action_' . $spamCode];
         /* Perform Action */
         switch ($action) {
             /* Proceed with registration */
             case 1:
                 break;
                 /* Flag for admin approval */
             /* Flag for admin approval */
             case 2:
                 $member['member_group_id'] = $this->settings['auth_group'];
                 $this->settings['reg_auth_type'] = 'admin';
                 $_spamFlag = 1;
                 break;
                 /* Approve the account, but ban it */
             /* Approve the account, but ban it */
             case 3:
                 $member['member_banned'] = 1;
                 $member['bw_is_spammer'] = 1;
                 $this->settings['reg_auth_type'] = '';
                 break;
                 /* Deny registration */
             /* Deny registration */
             case 4:
                 $this->registry->output->showError('spam_denied_account', '100x001', FALSE, '', 200);
                 break;
         }
     }
     //-----------------------------------------
     // Create the account
     //-----------------------------------------
     $member = IPSMember::create(array('members' => $member, 'pfields_content' => $custom_fields->out_fields), FALSE, FALSE, FALSE);
     //-----------------------------------------
     // Login handler create account callback
     //-----------------------------------------
     $this->han_login->createAccount(array('member_id' => $member['member_id'], 'email' => $member['email'], 'joined' => $member['joined'], 'password' => $in_password, 'ip_address' => $this->member->ip_address, 'username' => $member['members_display_name'], 'name' => $member['name'], 'members_display_name' => $member['members_display_name']));
     //-----------------------------------------
     // We'll just ignore if this fails - it shouldn't hold up IPB anyways
     //-----------------------------------------
     /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
     		{
     			$this->registry->output->showError( 'han_login_create_failed', 2017, true );
     		}*/
     //-----------------------------------------
     // Validation
     //-----------------------------------------
     $validate_key = md5(IPSMember::makePassword() . time());
     $time = time();
     if ($coppa != 1) {
         if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin' or $this->settings['reg_auth_type'] == 'admin_user') {
             //-----------------------------------------
             // We want to validate all reg's via email,
             // after email verificiation has taken place,
             // we restore their previous group and remove the validate_key
             //-----------------------------------------
             $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address'], 'spam_flag' => $_spamFlag));
             if ($this->settings['reg_auth_type'] == 'user' or $this->settings['reg_auth_type'] == 'admin_user') {
                 /* Send out the email. */
                 $message = array('THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=auto_validate&uid=" . urlencode($member['member_id']) . "&aid=" . urlencode($validate_key), 'publicNoSession', 'false'), 'NAME' => $member['members_display_name'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=05", 'publicNoSession', 'false'), 'EMAIL' => $member['email'], 'ID' => $member['member_id'], 'CODE' => $validate_key);
                 IPSText::getTextClass('email')->setPlainTextTemplate(IPSText::getTextClass('email')->getTemplate("reg_validate", $this->member->language_id));
                 IPSText::getTextClass('email')->buildPlainTextContent($message);
                 IPSText::getTextClass('email')->buildHtmlContent($message);
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $member['email'];
                 IPSText::getTextClass('email')->sendMail();
                 $this->output = $this->registry->output->getTemplate('register')->showAuthorize($member);
             } else {
                 if ($this->settings['reg_auth_type'] == 'admin') {
                     $this->output = $this->registry->output->getTemplate('register')->showPreview($member);
                 }
             }
             /* Only send new registration email if the member wasn't banned */
             if ($this->settings['new_reg_notify'] and !$member['member_banned']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             $this->registry->output->setTitle($this->lang->words['reg_success'] . ' - ' . ipsRegistry::$settings['board_name']);
             $this->registry->output->addNavigation($this->lang->words['nav_reg'], '');
         } else {
             /* We don't want to preview, or get them to validate via email. */
             $stat_cache = $this->cache->getCache('stats');
             if ($member['members_display_name'] and $member['member_id'] and !$this->caches['group_cache'][$member['member_group_id']]['g_hide_online_list']) {
                 $stat_cache['last_mem_name'] = $member['members_display_name'];
                 $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle($member['members_display_name']);
                 $stat_cache['last_mem_id'] = $member['member_id'];
             }
             $stat_cache['mem_count'] += 1;
             $this->cache->setCache('stats', $stat_cache, array('array' => 1));
             /* Only send new registration email if the member wasn't banned */
             if ($this->settings['new_reg_notify'] and !$member['member_banned']) {
                 $date = $this->registry->class_localization->getDate(time(), 'LONG', 1);
                 IPSText::getTextClass('email')->getTemplate('admin_newuser');
                 IPSText::getTextClass('email')->buildMessage(array('DATE' => $date, 'LOG_IN_NAME' => $member['name'], 'EMAIL' => $member['email'], 'IP' => $member['ip_address'], 'DISPLAY_NAME' => $member['members_display_name']));
                 IPSText::getTextClass('email')->subject = sprintf($this->lang->words['new_registration_email1'], $this->settings['board_name']);
                 IPSText::getTextClass('email')->to = $this->settings['email_in'];
                 IPSText::getTextClass('email')->sendMail();
             }
             IPSCookie::set('pass_hash', $member['member_login_key'], 1);
             IPSCookie::set('member_id', $member['member_id'], 1);
             //-----------------------------------------
             // Fix up session
             //-----------------------------------------
             $privacy = $member['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['Privacy']) ? 1 : 0;
             # Update value for onCompleteAccount call
             $member['login_anonymous'] = $privacy . '&1';
             $this->member->sessionClass()->convertGuestToMember(array('member_name' => $member['members_display_name'], 'member_id' => $member['member_id'], 'member_group' => $member['member_group_id'], 'login_type' => $privacy));
             IPSLib::runMemberSync('onCompleteAccount', $member);
             $this->registry->output->silentRedirect($this->settings['base_url'] . '&app=core&module=global&section=login&do=autologin&fromreg=1');
         }
     } else {
         /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */
         $this->DB->insert('validating', array('vid' => $validate_key, 'member_id' => $member['member_id'], 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => $time, 'coppa_user' => $coppa, 'new_reg' => 1, 'ip_address' => $member['ip_address']));
         $this->registry->output->redirectScreen($this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=12');
     }
 }
Пример #9
0
 /**
  * Set the SEO titles
  * 
  * @param	int
  * @return	@e void
  */
 public function fixSeoTitles()
 {
     /* Init */
     $st = intval($this->request['st']);
     $did = 0;
     $each = 200;
     /* If this is the first pass, do the cal_calendars table too */
     if (!$st) {
         $this->DB->build(array('select' => 'cal_id, cal_title', 'from' => 'cal_calendars'));
         $outer = $this->DB->execute();
         while ($r = $this->DB->fetch($outer)) {
             $this->DB->update('cal_calendars', array('cal_title_seo' => IPSText::makeSeoTitle($r['cal_title'])), 'cal_id=' . $r['cal_id']);
         }
         $this->registry->output->addMessage('Calendar FURL titles rebuilt');
     }
     /* Build event FURL titles */
     $this->DB->build(array('select' => 'event_id, event_title', 'from' => 'cal_events', 'order' => 'event_id ASC', 'limit' => array($st, $each)));
     $outer = $this->DB->execute();
     while ($r = $this->DB->fetch($outer)) {
         $did++;
         $this->DB->update('cal_events', array('event_title_seo' => IPSText::makeSeoTitle($r['event_title'])), 'event_id=' . $r['event_id']);
     }
     /* Show message and redirect */
     if ($did > 0) {
         $this->request['st'] = $st + $did;
         $this->request['workact'] = 'fixtitles';
         $this->registry->output->addMessage("Up to {$this->request['st']} event FURL titles rebuilt so far...");
     } else {
         $this->request['st'] = 0;
         $this->request['workact'] = '';
         $this->registry->output->addMessage("All event FURL titles rebuilt...");
     }
     /* Next Page */
     return;
 }
Пример #10
0
 /**
  * Updates member's DB row name or members_display_name
  *
  * @todo 	[Future] Separate out forum specific stuff (moderators, etc) and move into hooks 
  * 
  * @param	string		Member id
  * @param	string		New name
  * @param	string		Field to update (name or display name)
  * @return	mixed		True if update successful, otherwise exception or false
  * 
  * Error Codes:
  * NO_USER				Could not load the user
  * NO_PERMISSION		This user cannot change their display name at all
  * NO_MORE_CHANGES		The user cannot change their display name again in this time period
  * NO_NAME				No display name (or shorter than 3 chars was given)
  * ILLEGAL_CHARS		The display name contains illegal characters
  * USER_NAME_EXISTS		The username already exists
  */
 public function updateName($member_id, $name, $field = 'members_display_name', $discount = FALSE)
 {
     //-----------------------------------------
     // Load the member
     //-----------------------------------------
     $member = IPSMember::load($member_id);
     $_seoName = IPSText::makeSeoTitle($name);
     if (!$member['member_id']) {
         throw new Exception("NO_USER");
     }
     //-----------------------------------------
     // Make sure name does not exist
     //-----------------------------------------
     try {
         if ($this->checkNameExists($name, $member, $field) === TRUE) {
             throw new Exception("USER_NAME_EXISTS");
         } else {
             if ($field == 'members_display_name') {
                 $this->DB->setDataType(array('dname_previous', 'dname_current'), 'string');
                 if ($member['members_display_name'] != $name) {
                     $this->DB->insert('dnames_change', array('dname_member_id' => $member_id, 'dname_date' => time(), 'dname_ip_address' => $member['ip_address'], 'dname_previous' => $member['members_display_name'], 'dname_current' => $name, 'dname_discount' => $discount ? 1 : 0));
                 }
                 //-----------------------------------------
                 // Still here? Change it then
                 //-----------------------------------------
                 IPSMember::save($member['member_id'], array('core' => array('members_display_name' => $name, 'members_l_display_name' => mb_strtolower($name), 'members_seo_name' => $_seoName)));
                 $this->DB->setDataType(array('last_poster_name', 'seo_last_name'), 'string');
                 $this->DB->update('forums', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                 $this->DB->setDataType(array('member_name', 'seo_name'), 'string');
                 $this->DB->update('sessions', array('member_name' => $name, 'seo_name' => $_seoName), "member_id=" . $member['member_id']);
                 $this->DB->setDataType(array('starter_name', 'seo_first_name'), 'string');
                 $this->DB->update('topics', array('starter_name' => $name, 'seo_first_name' => $_seoName), "starter_id=" . $member['member_id']);
                 $this->DB->setDataType(array('last_poster_name', 'seo_last_name'), 'string');
                 $this->DB->update('topics', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                 $this->DB->update('posts', array('author_name' => $name), "author_id=" . $member['member_id']);
                 /* Update archived posts */
                 $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/archive/writer.php', 'classes_archive_writer');
                 $archiveWriter = new $classToLoad();
                 $archiveWriter->setApp('forums');
                 $archiveWriter->update(array('archive_author_name' => $name), 'archive_author_id=' . $member['member_id']);
             } else {
                 //-----------------------------------------
                 // If one gets here, one can assume that the new name is correct for one, er...one.
                 // So, lets do the converteroo
                 //-----------------------------------------
                 IPSMember::save($member['member_id'], array('core' => array('name' => $name, 'members_l_username' => mb_strtolower($name))));
                 $this->DB->setDataType('member_name', 'string');
                 $this->DB->update('moderators', array('member_name' => $name), "member_id=" . $member['member_id']);
                 if (!$this->settings['auth_allow_dnames']) {
                     //-----------------------------------------
                     // Not using sep. display names?
                     //-----------------------------------------
                     IPSMember::save($member['member_id'], array('core' => array('members_display_name' => $name, 'members_l_display_name' => mb_strtolower($name), 'members_seo_name' => $_seoName)));
                     $this->DB->setDataType(array('last_poster_name', 'seo_last_name'), 'string');
                     $this->DB->update('forums', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                     $this->DB->setDataType(array('member_name', 'seo_name'), 'string');
                     $this->DB->update('sessions', array('member_name' => $name, 'seo_name' => $_seoName), "member_id=" . $member['member_id']);
                     $this->DB->setDataType(array('starter_name', 'seo_first_name'), 'string');
                     $this->DB->update('topics', array('starter_name' => $name, 'seo_first_name' => $_seoName), "starter_id=" . $member['member_id']);
                     $this->DB->setDataType(array('last_poster_name', 'seo_last_name'), 'string');
                     $this->DB->update('topics', array('last_poster_name' => $name, 'seo_last_name' => $_seoName), "last_poster_id=" . $member['member_id']);
                     $this->DB->update('posts', array('author_name' => $name), "author_id=" . $member['member_id']);
                     /* Update archived posts */
                     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/archive/writer.php', 'classes_archive_writer');
                     $archiveWriter = new $classToLoad();
                     $archiveWriter->setApp('forums');
                     $archiveWriter->update(array('archive_author_name' => $name), 'archive_author_id=' . $member['member_id']);
                 }
             }
             //-----------------------------------------
             // Recache moderators
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('moderators', 'forums');
             //-----------------------------------------
             // Recache announcements
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('announcements', 'forums');
             //-----------------------------------------
             // Stats to Update?
             //-----------------------------------------
             $this->registry->cache()->rebuildCache('stats', 'core');
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $han_login = new $classToLoad($this->registry);
             $han_login->init();
             $han_login->changeName($member[$field], $name, $member['email'], $member, $field);
             IPSLib::runMemberSync('onNameChange', $member['member_id'], $name);
             return TRUE;
         }
     } catch (Exception $error) {
         throw new Exception($error->getMessage());
     }
 }
Пример #11
0
 /**
  * Convert an image
  *
  * @access	public
  * @param 	integer		Foreign ID number
  * @param 	array 		Data to insert to table
  * @param 	string 		Path to where images are stores
  * @param 	array 		Custom field data to insert to table
  * @param	boolean		If true, loads file data from database, rather than move file
  * @return 	boolean		Success or fail
  **/
 public function convertImage($id, $info, $path, $custom_fields, $db = false)
 {
     // Check we have a path
     if (!$this->settings['gallery_images_path']) {
         $this->logError($id, 'Your IP.Gallery uploads path has not been configured');
         return false;
     }
     //-----------------------------------------
     // Make sure we have everything we need
     //-----------------------------------------
     if (!$id) {
         $this->logError($id, 'No ID number provided');
         return false;
     }
     // Need image path if was not stored in database
     if (!$path and !$db) {
         $this->logError($id, 'No path provided');
         return false;
     }
     // Be sure to have member id
     if (!$info['member_id']) {
         $this->logError($id, 'No member ID provided');
         return false;
     }
     // Need to store in either category or album
     if (!$info['category_id'] and !$info['album_id']) {
         $this->logError($id, 'No category or album ID provided');
         return false;
     }
     // Check if a masked name was provided. If not, just use the filename.
     $info['masked_file_name'] = $info['masked_file_name'] ? $info['masked_file_name'] : $info['file_name'];
     if (!$db and !$info['masked_file_name']) {
         $this->logError($id, 'No filename provided');
         return false;
     }
     // Make sure image data was provided if stored in database.
     if ($db && !$info['data']) {
         $this->logError($id, 'No file data provided');
         return false;
     }
     if (isset($info['directory']) && $info['directory'] != '') {
         $path = $path . '/' . trim($info['directory'], '/');
     }
     // Check the file actually exists
     if (!$db && !file_exists($path . '/' . $info['masked_file_name'])) {
         $this->logError($id, 'Could not locate file ' . $path . '/' . $info['masked_file_name']);
         return false;
     }
     //-----------------------------------------
     // Set up array
     //-----------------------------------------
     $imageArray = array('member_id' => $this->getLink($info['member_id'], 'members', false, $this->useLocalLink), 'category_id' => $info['category_id'] ? $this->getLink($info['category_id'], 'gallery_categories') : 0, 'album_id' => $info['album_id'] ? $this->getLink($info['album_id'], 'gallery_albums') : 0, 'caption' => $info['caption'] ? $info['caption'] : 'No caption', 'file_size' => $info['file_size'] ? $info['file_size'] : 2, 'description' => $info['description'], 'directory' => '', 'file_name' => $info['file_name'], 'approved' => $info['approved'], 'thumbnail' => $info['thumbnail'], 'views' => intval($info['views']), 'comments' => intval($info['comments']), 'idate' => intval($info['idate']), 'ratings_total' => intval($info['ratings_total']), 'ratings_count' => intval($info['ratings_count']), 'caption_seo' => IPSText::makeSeoTitle($info['caption']), 'image_notes' => $info['image_notes'], 'rating' => intval($info['ratings_total']) > 0 ? intval($info['ratings_total']) / intval($info['ratings_count']) : 0);
     // Fields still required = array( 'file_name', 'file_type', 'masked_file_name', 'medium_file_name');
     // Fields optional = array( 'file_size', 'pinned', 'media', 'credit_info', 'metadata', 'media_thumb');
     $_file = IPSLib::getAppDir('gallery') . '/app_class_gallery.php';
     $_name = 'app_class_gallery';
     $galleryLibObject;
     if (file_exists($_file)) {
         $classToLoad = IPSLib::loadLibrary($_file, $_name);
         $galleryLibObject = new $classToLoad($this->registry);
     }
     $this->_loadMediaCache();
     require_once IPS_KERNEL_PATH . 'classUpload.php';
     $upload = new classUpload();
     $allowed_ext = array();
     foreach ($this->media_thumb_cache as $k => $v) {
         if (!$v['allowed']) {
             continue;
         }
         if ($v['default_type'] == 0 and !$allow_media) {
             continue;
         }
         $allowed_ext[] = str_replace(".", "", $k);
     }
     $dir = "";
     if ($this->settings['gallery_dir_images']) {
         $dir = $this->DB->buildAndFetch(array('select' => 'directory', 'from' => 'gallery_images', 'order' => "id DESC", 'limit' => array(0, 1)));
         $dir = $dir['directory'];
         if (!is_dir($this->settings['gallery_images_path'] . '/' . $dir)) {
             $dir = '';
         }
         $total = $this->DB->buildAndFetch(array('select' => 'COUNT(directory) AS files', 'from' => 'gallery_images', 'where' => "directory='{$dir}'"));
         if ($total['files'] >= $this->settings['gallery_dir_images'] || !$total['files']) {
             $dir = time();
             @mkdir($this->settings['gallery_images_path'] . '/' . $dir, 0777);
             @chmod($this->settings['gallery_images_path'] . '/' . $dir, 0777);
             @touch($this->settings['gallery_images_path'] . '/' . $dir . '/index.html');
         }
         $dir = $dir ? "{$dir}/" : "";
         $imageArray['directory'] = str_replace("/", "", $dir);
     }
     $ext = $upload->_getFileExtension($info['file_name']);
     if (!in_array($ext, $allowed_ext)) {
         $this->logError($id, "Invalid_mime_type for file name: {$info['file_name']}");
         return false;
     }
     $new_name = "gallery_{$info['member_id']}_" . ($info['album_id'] > 0 ? $info['album_id'] : $info['category_id']) . "_" . time() % $imageArray['file_size'] . '.' . $ext;
     $imageArray['masked_file_name'] = $new_name;
     $new_file = $this->settings['gallery_images_path'] . '/' . $dir . $new_name;
     // Create the file from the db if that's the case
     if ($db) {
         $this->createFile($new_name, $info['data'], $info['file_size'], $this->settings['gallery_images_path'] . '/' . substr($dir, 0, -1));
     } else {
         // Copy the file to its end IP.Gallery location
         if (!@copy($path . '/' . $info['masked_file_name'], $new_file)) {
             $e = error_get_last();
             $this->logError($id, 'Could not move file - attempted to move ' . $path . '/' . $info['masked_file_name'] . ' to ' . $new_file . '<br />' . $e['message'] . '<br /><br />');
             return false;
         }
     }
     @chmod($new_file, 0777);
     if (method_exists($upload, 'check_xss_infile')) {
         $upload->saved_upload_name = $new_file;
         $upload->check_xss_infile();
         if ($upload->error_no == 5) {
             $this->logError($id, 'Invalid XSS file: ' . $info['file_name'] . '<br /><br />');
             return false;
         }
     }
     //-------------------------------------------------------------
     // Exif/IPTC support?
     //-------------------------------------------------------------
     $meta_data = array();
     if ($this->settings['gallery_exif']) {
         $meta_data = array_merge($meta_data, $this->registry->glib->extractExif($new_file));
     }
     if ($this->settings['gallery_iptc']) {
         $meta_data = array_merge($meta_data, $this->registry->glib->extractIptc($new_file));
     }
     $imageArray['metadata'] = serialize($meta_data);
     //-------------------------------------------------------------
     // Pass to library
     //-------------------------------------------------------------
     $media = 0;
     $ext = '.' . $ext;
     $imageArray['media'] = $this->media_thumb_cache[$ext]['default_type'] ? 0 : 1;
     $image = array('media' => $imageArray['media'], 'directory' => $dir, 'masked_file_name' => $new_name);
     if (!$imageArray['media']) {
         $this->registry->glib->rebuildImage($image, FALSE, TRUE);
     }
     $imageArray['medium_file_name'] = $this->registry->glib->did_medium ? 'med_' . $new_name : '';
     $imageArray['file_type'] = $this->registry->glib->getImageType($new_file);
     $imageArray['thumbnail'] = $this->registry->glib->did_thumb ? $this->registry->glib->did_thumb : 0;
     //-----------------------------------------
     // Insert
     //-----------------------------------------
     foreach ($custom_fields as $key => $value) {
         if (preg_match('/field_(.+)/', $key, $matches)) {
             $newKey = $this->getLink($matches[1], 'gallery_form_fields');
             if ($newKey) {
                 $imageArray['field_' . $newKey] = $value;
             }
         }
     }
     // Go
     $this->DB->insert('gallery_images', $imageArray);
     $inserted_id = $this->DB->getInsertId();
     //-----------------------------------------
     // Add link
     //-----------------------------------------
     $this->addLink($inserted_id, $id, 'gallery_images');
     return true;
 }
 /**
  * Converts a guest session to a member session
  *
  * @access	public
  * @param	array 		Array of incoming data (member_id, member_name, member_group, login_type)
  * @return	string 		Current session ID
  */
 public function convertGuestToMember($data)
 {
     /* Delete old sessions */
     $this->_destroySessions("ip_address='" . $this->_member->ip_address . "' AND id != '{$this->session_id}'");
     /* Fetch member */
     $member = IPSMember::load($data['member_id'], 'core');
     /* Update this session directly */
     $this->DB->update('sessions', array('member_name' => $data['member_name'], 'seo_name' => IPSText::makeSeoTitle($data['member_name']), 'member_id' => $data['member_id'], 'running_time' => time(), 'member_group' => $data['member_group'], 'login_type' => $data['login_type']), "id='" . $this->session_id . "'", TRUE);
     /* Remove from update and delete array */
     unset($this->_sessionsToSave[$this->session_id]);
     unset($this->_sessionsToKill[$this->session_id]);
     $update = array('last_activity' => time());
     if ($member['last_activity']) {
         $update['last_visit'] = $member['last_activity'];
     } else {
         $update['last_visit'] = time();
     }
     /* Make sure last activity and last visit are up to date */
     IPSMember::save($data['member_id'], array('core' => $update));
     /* Set cookie */
     IPSCookie::set("session_id", $this->session_id, -1);
     IPSDebug::addLogMessage("convertGuestToMember: {$data['member_id']}, {$this->session_id} " . serialize($data), 'sessions-' . $this->_memberData['member_id']);
     /* Set type */
     self::$data_store['_sessionType'] = 'update';
     return $this->session_id;
 }
 /**
  * Return the SEO title for a topic
  *
  * @access	public
  * @return	string		The SEO friendly name
  */
 public function _fetchSeoTitle_forum()
 {
     $forum = $this->DB->buildAndFetch(array('select' => 'id, name_seo, name', 'from' => 'forums', 'where' => 'id=' . intval($this->_id)));
     if ($forum['id']) {
         /* Check permission */
         if (!$this->registry->getClass('class_forums')->forumsCheckAccess($forum['id'], 0, 'forum', array(), TRUE)) {
             return FALSE;
         }
         return $forum['name_seo'] ? $forum['name_seo'] : IPSText::makeSeoTitle($forum['name']);
     }
     return FALSE;
 }
Пример #14
0
 /**
  * Parse/format the online list data for the records
  *
  * @author	Brandon Farber
  * @param	array 			Online list rows to check against
  * @return	array 			Online list rows parsed
  */
 public function parseOnlineEntries($rows)
 {
     if (!is_array($rows) or !count($rows)) {
         return $rows;
     }
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $forums_raw = array();
     $forums = array();
     $topics_raw = array();
     $topics = array();
     $posts_raw = array();
     $posts = array();
     $final = array();
     //-----------------------------------------
     // Extract the topic/forum data
     //-----------------------------------------
     foreach ($rows as $row) {
         if ($row['current_appcomponent'] != 'forums' or !$row['current_module']) {
             continue;
         }
         if ($row['current_section'] == 'forums') {
             $forums_raw[$row['location_2_id']] = '';
         } else {
             if ($row['current_section'] == 'topics') {
                 $topics_raw[$row['location_1_id']] = $row['location_1_id'];
             } else {
                 if ($row['current_section'] == 'post') {
                     $forums_raw[$row['location_2_id']] = '';
                     $topics_raw[$row['location_1_id']] = $row['location_1_id'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Get the forums, if you dare
     //-----------------------------------------
     ipsRegistry::getAppClass('forums');
     if (count($forums_raw)) {
         foreach (ipsRegistry::getClass('class_forums')->forum_by_id as $fid => $forum) {
             if (isset($forums_raw[$fid])) {
                 if (ipsRegistry::getClass('permissions')->check('view', $forum) !== false) {
                     $forums[$fid] = $forum['name'];
                 }
             }
         }
     }
     //-----------------------------------------
     // Get the topics, if you care
     //-----------------------------------------
     if (count($topics_raw)) {
         $_approved = ipsRegistry::getClass('class_forums')->fetchTopicHiddenQuery(array('visible'), 't.');
         ipsRegistry::DB()->build(array('select' => 't.*', 'from' => array('topics' => 't'), 'where' => $_approved . ' AND t.tid IN(' . implode(',', $topics_raw) . ') AND ' . ipsRegistry::getClass('permissions')->buildPermQuery('p'), 'add_join' => array(array('from' => array('permission_index' => 'p'), 'where' => "p.perm_type_id=t.forum_id AND p.app='forums' AND p.perm_type='forum'", 'type' => 'left'))));
         $tr = ipsRegistry::DB()->execute();
         while ($r = ipsRegistry::DB()->fetch($tr)) {
             $_forum = ipsRegistry::getClass('class_forums')->getForumByid($r['forum_id']);
             if (count($_forum) and ipsRegistry::getClass('class_forums')->forumsCheckAccess($_forum['id'], false, 'topic', $r, true)) {
                 if (ipsRegistry::getClass('permissions')->check('read', $_forum) !== false) {
                     if ($_forum['password'] == '' or IPSMember::isInGroup(ipsRegistry::member()->fetchMemberData(), explode(',', $_forum['password_override'])) or IPSCookie::get("ipbforumpass_{$_forum['id']}") == md5($_forum['password'])) {
                         $topics[$r['tid']] = $r['title'];
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Put humpty dumpty together again
     //-----------------------------------------
     foreach ($rows as $row) {
         if ($row['current_appcomponent'] != 'forums') {
             $final[$row['id']] = $row;
             continue;
         }
         if (!$row['current_module']) {
             $row['where_line'] = ipsRegistry::getClass('class_localization')->words['board_index'];
             $final[$row['id']] = $row;
             continue;
         }
         if ($row['current_section'] == 'forums') {
             if (isset($forums[$row['location_2_id']])) {
                 $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_sf'];
                 $row['where_line_more'] = $forums[$row['location_2_id']];
                 $row['where_link'] = 'showforum=' . $row['location_2_id'];
                 $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showforum=" . $row['location_2_id'], 'public'), IPSText::makeSeoTitle($forums[$row['location_2_id']]), 'showforum');
             }
         } else {
             if ($row['current_section'] == 'topics') {
                 if (isset($topics[$row['location_1_id']])) {
                     $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_st'];
                     $row['where_line_more'] = $topics[$row['location_1_id']];
                     $row['where_link'] = 'showtopic=' . $row['location_1_id'];
                     $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showtopic=" . $row['location_1_id'], 'public'), IPSText::makeSeoTitle($topics[$row['location_1_id']]), 'showtopic');
                 }
             } else {
                 if ($row['current_section'] == 'post') {
                     if ($row['location_1_id']) {
                         if (isset($topics[$row['location_1_id']])) {
                             $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_postrep'];
                             $row['where_line_more'] = $topics[$row['location_1_id']];
                             $row['where_link'] = 'showtopic=' . $row['location_1_id'];
                             $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showtopic=" . $row['location_1_id'], 'public'), IPSText::makeSeoTitle($topics[$row['location_1_id']]), 'showtopic');
                         }
                     } else {
                         if ($row['location_2_id']) {
                             if (isset($forums[$row['location_2_id']])) {
                                 $row['where_line'] = ipsRegistry::getClass('class_localization')->words['WHERE_postnew'];
                                 $row['where_line_more'] = $forums[$row['location_2_id']];
                                 $row['where_link'] = 'showforum=' . $row['location_2_id'];
                                 $row['_whereLinkSeo'] = ipsRegistry::getClass('output')->formatUrl(ipsRegistry::getClass('output')->buildUrl("showforum=" . $row['location_2_id'], 'public'), IPSText::makeSeoTitle($forums[$row['location_2_id']]), 'showforum');
                             }
                         }
                     }
                 }
             }
         }
         $final[$row['id']] = $row;
     }
     return $final;
 }
Пример #15
0
 /**
  * Rebuild Post Names
  *
  * @return	@e void
  */
 public function rebuildPostNames()
 {
     //-----------------------------------------
     // Set up
     //-----------------------------------------
     $done = 0;
     $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
     $end = intval($this->request['pergo']) ? intval($this->request['pergo']) : 100;
     $dis = $end + $start;
     $output = array();
     //-----------------------------------------
     // Got any more?
     //-----------------------------------------
     $tmp = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'limit' => array($dis, 1)));
     $max = intval($tmp['member_id']);
     //-----------------------------------------
     // Avoid limit...
     //-----------------------------------------
     $this->DB->build(array('select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start, $end)));
     $outer = $this->DB->execute();
     //-----------------------------------------
     // Process...
     //-----------------------------------------
     while ($r = $this->DB->fetch($outer)) {
         $seoName = IPSText::makeSeoTitle($r['members_display_name']);
         $this->DB->update('topics', array('starter_name' => $r['members_display_name'], 'seo_first_name' => $seoName), "starter_id=" . $r['member_id']);
         $this->DB->update('topics', array('last_poster_name' => $r['members_display_name'], 'seo_last_name' => $seoName), "last_poster_id=" . $r['member_id']);
         $done++;
     }
     //-----------------------------------------
     // Finish - or more?...
     //-----------------------------------------
     if (!$done and !$max) {
         //-----------------------------------------
         // Done..
         //-----------------------------------------
         $text = $this->lang->words['re_rebuildcomp'] . '<br />' . implode("<br />", $output);
         $url = "{$this->settings['base_url']}{$this->form_code}";
     } else {
         //-----------------------------------------
         // More..
         //-----------------------------------------
         $thisgoeshere = sprintf($this->lang->words['re_thisgoeshere'], $dis);
         $text = $thisgoeshere . '<br />' . implode("<br />", $output);
         $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
     }
     //-----------------------------------------
     // Bye....
     //-----------------------------------------
     $this->_specialRedirect($url, $text);
 }
 /**
  * Add or update an announcement
  *
  * @param	string	$type	add|edit
  * @return	@e void
  */
 protected function _save($type = 'add')
 {
     if ($this->request['secure_key'] != $this->member->form_hash) {
         $this->registry->output->showError('no_permission', 10311903, null, null, 403);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $forums_to_save = "";
     $start_date = 0;
     $end_date = 0;
     $announce_id = intval($this->request['announce_id']);
     //-----------------------------------------
     // check...
     //-----------------------------------------
     if (!$this->request['announce_title'] or !$this->request['announce_post']) {
         return $this->_form($type, $this->lang->words['announce_error_title']);
     }
     //-----------------------------------------
     // Get forums to add announce in
     //-----------------------------------------
     if (is_array($this->request['announce_forum']) and count($this->request['announce_forum'])) {
         if (in_array('*', $this->request['announce_forum'])) {
             $forums_to_save = '*';
         } else {
             $forums_to_save = implode(",", $this->request['announce_forum']);
         }
     }
     if (!$forums_to_save) {
         return $this->_form($type, $this->lang->words['announce_error_forums']);
     }
     //-----------------------------------------
     // Check Dates
     //-----------------------------------------
     if (strstr($this->request['announce_start'], '-')) {
         $start_array = explode('-', $this->request['announce_start']);
         if ($start_array[0] and $start_array[1] and $start_array[2]) {
             if (!checkdate($start_array[0], $start_array[1], $start_array[2])) {
                 return $this->_form($type, $this->lang->words['announce_error_date']);
             }
         }
         $start_date = mktime(12, 0, 0, $start_array[0], $start_array[1], $start_array[2]);
     }
     if (strstr($this->request['announce_end'], '-')) {
         $end_array = explode('-', $this->request['announce_end']);
         if ($end_array[0] and $end_array[1] and $end_array[2]) {
             if (!checkdate($end_array[0], $end_array[1], $end_array[2])) {
                 return $this->_form($type, $this->lang->words['announce_error_date']);
             }
         }
         $end_date = mktime(12, 0, 0, $end_array[0], $end_array[1], $end_array[2]);
     }
     //-----------------------------------------
     // Sort out the content
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
     $editor = new $classToLoad();
     $editor->setAllowBbcode(true);
     $editor->setAllowHtml(intval($this->request['announce_html_enabled']));
     if (intval($this->request['announce_html_enabled'])) {
         $editor->setBypassHtmlPurify(true);
     }
     $announceContent = $editor->process($_POST['announce_post']);
     IPSText::getTextClass('bbcode')->bypass_badwords = 1;
     IPSText::getTextClass('bbcode')->parse_smilies = 1;
     IPSText::getTextClass('bbcode')->parse_html = intval($this->request['announce_html_enabled']);
     IPSText::getTextClass('bbcode')->parse_nl2br = $this->request['announce_html_enabled'] ? $this->request['announce_nlbr_enabled'] : 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'announcement';
     $announceContent = IPSText::getTextClass('bbcode')->preDbParse($announceContent);
     //-----------------------------------------
     // Build save array
     //-----------------------------------------
     $save_array = array('announce_title' => $this->request['announce_title'], 'announce_post' => $announceContent, 'announce_active' => $this->request['announce_active'] ? $this->request['announce_active'] : 0, 'announce_forum' => $forums_to_save, 'announce_html_enabled' => $this->request['announce_html_enabled'] ? $this->request['announce_html_enabled'] : 0, 'announce_nlbr_enabled' => $this->request['announce_nlbr_enabled'] ? $this->request['announce_nlbr_enabled'] : 0, 'announce_start' => $start_date, 'announce_end' => $end_date, 'announce_seo_title' => IPSText::makeSeoTitle($this->request['announce_title']));
     //-----------------------------------------
     // Save..
     //-----------------------------------------
     if ($type == 'add') {
         $save_array['announce_member_id'] = $this->memberData['member_id'];
         $this->DB->insert('announcements', $save_array);
     } else {
         if ($announce_id) {
             $this->DB->update('announcements', $save_array, 'announce_id=' . $announce_id);
         }
     }
     //-----------------------------------------
     // Update cache
     //-----------------------------------------
     $this->registry->cache()->rebuildCache('announcements', 'forums');
     $this->registry->getClass('output')->redirectScreen($this->lang->words['announcement_saved'], $this->settings['base_url'] . "app=core&amp;module=modcp&amp;tab=announcements&amp;fromapp=forums");
 }
Пример #17
0
 /**
  * Save the forum
  *
  * @param	string		$type		[new|edit]
  * @return	@e void
  */
 public function forumSave($type = 'new')
 {
     /* If this is not a redirect forum anymore empty the redirect url - #35126 */
     if ($this->request['forum_type'] != 'redirect') {
         $this->request['redirect_url'] = '';
     }
     //-----------------------------------------
     // Converting the type?
     //-----------------------------------------
     if ($this->request['convert']) {
         $this->forumForm($type, 1);
         return;
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['name'] = trim($this->request['name']);
     $this->request['f'] = intval($this->request['f']);
     $this->request['parent_id'] = !empty($this->request['parent_id']) ? intval($this->request['parent_id']) : -1;
     $forum_cat_lang = intval($this->request['parent_id']) == -1 ? $this->lang->words['for_iscat_y'] : $this->lang->words['for_iscat_n'];
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     $this->registry->adminFunctions->checkSecurityKey();
     //-----------------------------------------
     // Check
     //-----------------------------------------
     if ($this->request['name'] == "") {
         $this->registry->output->global_message = sprintf($this->lang->words['for_entertitle'], mb_strtolower($forum_cat_lang));
         $this->forumForm($type);
         return;
     }
     //-----------------------------------------
     // Are we trying to do something stupid
     // like running with scissors or moving
     // the parent of a forum into itself
     // spot?
     //-----------------------------------------
     if ($this->request['parent_id'] != $this->registry->getClass('class_forums')->forum_by_id[$this->request['f']]['parent_id']) {
         $ids = $this->registry->getClass('class_forums')->forumsGetChildren($this->request['f']);
         $ids[] = $this->request['f'];
         if (in_array($this->request['parent_id'], $ids)) {
             $this->registry->output->global_error = $this->lang->words['for_whymovethere'];
             $this->forumForm($type);
             return;
         }
     }
     //if( $this->request['parent_id'] < 1 )
     //{
     //	$this->request['sub_can_post'] = 1;
     //}
     //-----------------------------------------
     // Save array
     //-----------------------------------------
     $save = array('name' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['name']))), 'name_seo' => IPSText::makeSeoTitle(strip_tags(IPSText::UNhtmlspecialchars($this->request['name']))), 'description' => IPSText::getTextClass('bbcode')->xssHtmlClean(nl2br(IPSText::stripslashes($_POST['description']))), 'use_ibc' => isset($this->request['use_ibc']) ? intval($this->request['use_ibc']) : 1, 'use_html' => intval($this->request['use_html']), 'password' => $this->request['password'], 'password_override' => is_array($this->request['password_override']) ? implode(",", $this->request['password_override']) : '', 'sort_key' => $this->request['sort_key'], 'sort_order' => $this->request['sort_order'], 'prune' => intval($this->request['prune']), 'topicfilter' => $this->request['topicfilter'], 'preview_posts' => intval($this->request['preview_posts']), 'allow_poll' => intval($this->request['allow_poll']), 'allow_pollbump' => intval($this->request['allow_pollbump']), 'forum_allow_rating' => intval($this->request['forum_allow_rating']), 'inc_postcount' => intval($this->request['inc_postcount']), 'parent_id' => intval($this->request['parent_id']), 'sub_can_post' => intval($this->request['sub_can_post']), 'redirect_on' => intval($this->request['redirect_on']), 'redirect_hits' => intval($this->request['redirect_hits']), 'redirect_url' => $this->request['redirect_url'], 'notify_modq_emails' => $this->request['notify_modq_emails'], 'permission_showtopic' => $this->request['parent_id'] == -1 ? 1 : intval($this->request['permission_showtopic']), 'min_posts_post' => intval($this->request['min_posts_post']), 'min_posts_view' => intval($this->request['min_posts_view']), 'can_view_others' => intval($this->request['can_view_others']), 'hide_last_info' => intval($this->request['hide_last_info']), 'disable_sharelinks' => intval($this->request['disable_sharelinks']), 'tag_predefined' => $this->request['tag_predefined'], 'forums_bitoptions' => IPSBWOPtions::freeze($this->request, 'forums', 'forums'), 'permission_custom_error' => nl2br(IPSText::stripslashes($_POST['permission_custom_error'])), 'ipseo_priority' => $this->request['ipseo_priority'], 'viglink' => intval($this->request['viglink']));
     /* Save data from application tabs */
     IPSLib::loadInterface('admin/forum_form.php');
     $_forumPlugins = array();
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/forum_form.php', 'admin_forum_form__' . $app_dir, $app_dir);
             $_forumPlugins[$_class] = new $_class($this->registry);
             $remote = $_forumPlugins[$_class]->getForSave();
             $save = array_merge($save, $remote);
         }
     }
     //-----------------------------------------
     // ADD
     //-----------------------------------------
     if ($type == 'new') {
         $this->DB->build(array('select' => 'MAX(id) as top_forum', 'from' => 'forums'));
         $this->DB->execute();
         $row = $this->DB->fetch();
         if ($row['top_forum'] < 1) {
             $row['top_forum'] = 0;
         }
         $row['top_forum']++;
         /* Forum Information */
         //$save['id']               = $row['top_forum'];
         $save['position'] = $row['top_forum'];
         $save['topics'] = 0;
         $save['posts'] = 0;
         $save['last_post'] = 0;
         $save['last_poster_id'] = 0;
         $save['last_poster_name'] = "";
         /* Insert the record */
         $this->DB->insert('forums', $save);
         $forum_id = $this->DB->getInsertId();
         /* Permissions */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions');
         $permissions = new $classToLoad(ipsRegistry::instance());
         $permissions->savePermMatrix($this->request['perms'], $forum_id, 'forum');
         if (!$save['can_view_others']) {
             $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$forum_id}");
         }
         /* Done */
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__created'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "'" . mb_strtolower($this->lang->words['for__created']));
     } else {
         $forumData = $this->registry->class_forums->getForumById($this->request['f']);
         if ($this->request['parent_id'] == -1) {
             $save['can_view_others'] = 1;
             /* Permissions */
             //$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/class_public_permissions.php', 'classPublicPermissions' );
             //$permissions = new $classToLoad( ipsRegistry::instance() );
             //$permissions->savePermMatrix( $this->request['perms'], $this->request['f'], 'forum' );
             if (!$save['can_view_others']) {
                 $this->DB->update('permission_index', array('owner_only' => 1), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             } else {
                 $this->DB->update('permission_index', array('owner_only' => 0), "app='forums' AND perm_type='forum' AND perm_type_id={$this->request['f']}");
             }
         }
         $this->DB->update('forums', $save, "id=" . $this->request['f']);
         $forum_id = $this->request['f'];
         /* Tags */
         $this->registry->getClass('class_forums')->forumsInit();
         $this->registry->tags->updatePermssionsByParentId($this->request['f']);
         /* Did we enable/disable tagging? @todo find a better way to do this. Perhaps another field in tags? */
         if (isset($this->request['bw_disable_tagging'])) {
             if ($forumData['bw_disable_tagging'] != $this->request['bw_disable_tagging']) {
                 $toggle = $this->request['bw_disable_tagging'] ? 0 : 1;
                 $this->registry->tags->updateVisibilityByParentId($this->request['f'], $toggle);
                 if ($this->request['bw_disable_tagging'] == 0) {
                     /* We just restored all tags, so lets return hidden topics back to 0 */
                     $this->DB->build(array('select' => 'tid', 'from' => 'topics', 'where' => 'forum_id=' . $this->request['f'] . ' AND ' . $this->registry->class_forums->fetchTopicHiddenQuery(array('sdeleted', 'hidden', 'pdelete', 'oktoremove')), 'order' => 'last_post DESC', 'limit' => array(0, 500)));
                     $this->DB->execute();
                     $topics = array();
                     while ($row = $this->DB->fetch()) {
                         $topics[] = $row['tid'];
                     }
                     if (count($topics)) {
                         $this->registry->tags->updateVisibilityByMetaId($topics, 0);
                     }
                 }
             }
         }
         $this->registry->output->global_message = $forum_cat_lang . $this->lang->words['for__edited'];
         $this->registry->adminFunctions->saveAdminLog($forum_cat_lang . " '" . $this->request['name'] . "' " . mb_strtolower($this->lang->words['for__edited']));
     }
     $this->request['f'] = '';
     if ($save['parent_id'] > 0) {
         $this->request['f'] = $save['parent_id'];
     }
     //-----------------------------------------
     // Post save callbacks
     //-----------------------------------------
     if (count($_forumPlugins)) {
         foreach ($_forumPlugins as $_className => $_object) {
             if (method_exists($_object, 'postSave')) {
                 $_object->postSave($forum_id);
             }
         }
     }
     $this->registry->getClass('class_forums')->forumsInit();
     $this->showForums();
 }
Пример #18
0
 /**
  * Rebuild a forum's count
  *
  * @return	boolean
  */
 public function forumRebuild($fid)
 {
     $fid = intval($fid);
     if (!$fid) {
         return false;
     }
     /* Topics */
     $topics = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . $this->fetchTopicHiddenQuery(array('visible'), '') . " and forum_id={$fid}"));
     /* Queued topics */
     $queued_topics = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . $this->fetchTopicHiddenQuery(array('hidden'), '') . " and forum_id={$fid}"));
     /* Deleted topics */
     $deleted_topics = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . $this->fetchTopicHiddenQuery(array('sdeleted'), '') . " and forum_id={$fid}"));
     /* Archived topics */
     $archived_topics = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('archived', 'working')) . " and forum_id={$fid}"));
     /* Posts */
     $posts = $this->DB->buildAndFetch(array('select' => 'SUM(posts) as replies', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . $this->fetchTopicHiddenQuery(array('visible'), '') . " and forum_id={$fid}"));
     /* Queued posts */
     $queued_posts = $this->DB->buildAndFetch(array('select' => 'SUM(topic_queuedposts) as replies', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . $this->fetchTopicHiddenQuery(array('visible', 'hidden'), '') . " and forum_id={$fid}"));
     /* Deleted posts */
     $deleted_posts = $this->DB->buildAndFetch(array('select' => 'SUM(topic_deleted_posts) as replies', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('not', 'exclude')) . ' AND ' . "forum_id={$fid}"));
     /* Archived posts */
     $archived_posts = $this->DB->buildAndFetch(array('select' => 'SUM(posts) as replies', 'from' => 'topics', 'where' => $this->fetchTopicArchiveQuery(array('archived', 'working')) . " and forum_id={$fid}"));
     /* Last poster */
     $last_post = $this->DB->buildAndFetch(array('select' => 'tid, title, last_poster_id, last_poster_name, seo_last_name, last_post', 'from' => 'topics', 'where' => $this->fetchTopicHiddenQuery(array('visible'), '') . " and forum_id={$fid}" . " AND state != 'link'", 'order' => 'last_post DESC', 'limit' => array(1)));
     /* Newest topic */
     $newest_topic = $this->DB->buildAndFetch(array('select' => 'title, tid, seo_first_name', 'from' => 'topics', 'where' => 'forum_id=' . $fid . ' and ' . $this->fetchTopicHiddenQuery(array('visible'), '') . " AND state != 'link'", 'order' => 'start_date desc', 'limit' => array(1)));
     /* Rebuild last topics */
     $lastXTopics = $this->lastXFreeze($this->buildLastXTopicIds($fid, FALSE));
     /* Save */
     $dbs = array('name_seo' => IPSText::makeSeoTitle($this->allForums[$fid]['name']), 'last_poster_id' => intval($last_post['last_poster_id']), 'last_poster_name' => $last_post['last_poster_name'], 'seo_last_name' => IPSText::makeSeoTitle($last_post['last_poster_name']), 'last_post' => intval($last_post['last_post']), 'last_title' => $last_post['title'], 'seo_last_title' => IPSText::makeSeoTitle($last_post['title']), 'last_id' => intval($last_post['tid']), 'topics' => intval($topics['count']) + intval($archived_topics['count']), 'posts' => intval($posts['replies']) + intval($archived_posts['replies']), 'queued_topics' => intval($queued_topics['count']), 'queued_posts' => intval($queued_posts['replies']), 'deleted_posts' => intval($deleted_posts['replies']), 'archived_topics' => intval($archived_topics['count']), 'archived_posts' => intval($archived_posts['replies']), 'deleted_topics' => intval($deleted_topics['count']), 'newest_id' => intval($newest_topic['tid']), 'newest_title' => $newest_topic['title'], 'last_x_topic_ids' => $lastXTopics);
     if ($this->allForums[$fid]['_update_deletion']) {
         $dbs['forum_last_deletion'] = time();
     }
     $this->DB->setDataType(array('last_poster_name', 'last_title', 'newest_title', 'seo_last_title', 'seo_last_name'), 'string');
     $this->DB->update('forums', $dbs, "id=" . $fid);
     return true;
 }
Пример #19
0
 /**
  * Formats the URL (.htaccess SEO, etc)
  *
  * @access	public
  * @param	string	Raw URL
  * @param	string	Any special SEO title passed
  * @param	string	Any special SEO template to use. If none is passed but SEO is enabled, IPB will search all templates for a match
  * @return	string	Formatted  URL
  */
 public function formatUrl($url, $seoTitle = '', $seoTemplate = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if (!ipsRegistry::$settings['use_friendly_urls']) {
         return $url;
     }
     $_template = FALSE;
     $seoTitle = !empty($seoTitle) && !is_array($seoTitle) ? array($seoTitle) : $seoTitle;
     $_seoTitleForCache = is_array($seoTitle) ? implode(';', $seoTitle) : '';
     $_md5 = md5($url . $_seoTitleForCache . $seoTemplate);
     $_s = '';
     $cached = $this->getCachedFurl($_md5);
     if (!is_null($cached)) {
         return $cached;
     }
     //-----------------------------------------
     // If using URL sessions, fix the URL...
     //-----------------------------------------
     if (!IN_ACP and strstr($url, 's=')) {
         preg_match("/s=([a-zA-Z0-9]{32})(.*?)\$/", $url, $matches);
         if (!empty($matches[2])) {
             $url = preg_replace("/s=([a-zA-Z0-9]{32})(&amp;|&)/", '', $url);
             $_s = $matches[1];
         }
         if (strstr($url, 's=0')) {
             $url = preg_replace("/(\\?|&|;)s=0(&amp;|&)/", '', $url);
             $_s = '';
         }
     }
     if ($this->settings['use_friendly_urls'] and is_array($seoTitle) && count($seoTitle)) {
         /* SEO Tweak - if default app is forums then don't bother with act=idx nonsense */
         if (IPS_DEFAULT_APP == 'forums' and !$this->settings['actidx_override']) {
             if (stristr($url, 'act=idx')) {
                 $url = str_ireplace(array(IPS_PUBLIC_SCRIPT . '?act=idx', '?act=idx', 'act=idx'), '', $url);
             }
         }
         if ($seoTemplate and isset($this->seoTemplates[$seoTemplate])) {
             $_template = $seoTemplate;
         }
         /* Need to search for one - fast? */
         if ($_template === FALSE) {
             /* Search for one, then. Possibly a bit slower than we'd like! */
             foreach ($this->seoTemplates as $key => $data) {
                 if (stristr(str_replace($this->settings['board_url'], '', $url), $key)) {
                     $_template = $key;
                     break;
                 }
             }
         }
         /* Got one to work with? */
         if ($_template !== FALSE) {
             if (count($seoTitle) == 1 && (substr($seoTitle[0], 0, 2) == '%%' and substr($seoTitle[0], -2) == '%%')) {
                 $seoTitle[0] = IPSText::makeSeoTitle(substr($seoTitle[0], 2, -2));
             }
             /* Do we need to encode? */
             if (IPS_DOC_CHAR_SET != 'UTF-8') {
                 foreach ($seoTitle as $id => $item) {
                     $seoTitle[$id] = urlencode($item);
                 }
             }
             if (count($seoTitle) == 1) {
                 $replace = str_replace('#{__title__}', IPSText::convertUnicode($seoTitle[0]), $this->seoTemplates[$_template]['out'][1]);
                 // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
             } else {
                 $replace = $this->seoTemplates[$_template]['out'][1];
                 foreach ($seoTitle as $id => $item) {
                     $replace = str_replace('#{__title-' . $id . '__}', IPSText::convertUnicode($item), $replace);
                     // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
                 }
             }
             $url = preg_replace($this->seoTemplates[$_template]['out'][0], $replace, $url);
             $_anchor = '';
             $__url = $url;
             /* Protect html entities */
             $url = preg_replace('/&#(\\d)/', "~|~\\1", $url);
             if (strstr($url, '&')) {
                 $restUrl = substr($url, strpos($url, '&'));
                 $url = substr($url, 0, strpos($url, '&'));
             } else {
                 $restUrl = '';
             }
             /* Anchor */
             if (strstr($restUrl, '#')) {
                 $_anchor = substr($restUrl, strpos($restUrl, '#'));
                 $restUrl = substr($restUrl, 0, strpos($restUrl, '#'));
             }
             switch ($this->settings['url_type']) {
                 case 'path_info':
                     if ($this->settings['htaccess_mod_rewrite']) {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', '', $url);
                     } else {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '/', $url);
                     }
                     break;
                 default:
                 case 'query_string':
                     $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '?/', $url);
                     break;
             }
             /* Ensure that if the seoTitle is missing there is no double slash */
             # http://localhost/invisionboard3/user/1//
             # http://localhost/invisionboard3/user/1/mattm/
             if (substr($url, -2) == '//') {
                 $url = substr($url, 0, -1);
             }
             /* Others... */
             if ($restUrl) {
                 $_url = str_replace('&amp;', '&', str_replace('?', '', $restUrl));
                 $_data = explode("&", $_url);
                 $_add = array();
                 $_page = '';
                 foreach ($_data as $k) {
                     if (strstr($k, '=')) {
                         list($kk, $vv) = explode('=', $k);
                         /* Catch page */
                         if ($this->seoTemplates[$_template]['isPagesMode'] && $kk == 'page') {
                             $_page .= $this->seoTemplates['__data__']['varPage'] . $vv;
                         } else {
                             if ($kk and $vv) {
                                 $_add[] = $kk . $this->seoTemplates['__data__']['varJoin'] . $vv;
                             }
                         }
                     }
                 }
                 /* Got anything to add?... */
                 if (count($_add) or $_page) {
                     if ($_page) {
                         if (strrpos($url, $this->seoTemplates['__data__']['end']) + strlen($this->seoTemplates['__data__']['end']) == strlen($url)) {
                             $url = substr($url, 0, -1);
                         }
                         $url .= $this->seoTemplates['__data__']['end'] . $_page;
                     }
                     if (count($_add)) {
                         $url .= $this->seoTemplates['__data__']['varBlock'] . implode($this->seoTemplates['__data__']['varSep'], $_add);
                     }
                 }
             }
             /* Session ID? */
             $this->_appendSession($url, $_s);
             /* anchor? */
             if ($_anchor) {
                 $url .= $_anchor;
             }
             /* Protect html entities */
             $url = str_replace('~|~', '&#', $url);
             $this->setCachedFurl($_md5, $url);
             return $url;
         } else {
             /* Session ID? */
             $this->_appendSession($url, $_s);
             $this->setCachedFurl($_md5, $url);
             return $url;
         }
     } else {
         /* Session ID? */
         $this->_appendSession($url, $_s);
         $this->setCachedFurl($_md5, $url);
         return $url;
     }
 }
Пример #20
0
 /**
  * Convert a member
  *
  * @access	public
  * @param 	array		Basic data (id number, username, email, group, joined date, password)
  * @param 	array 		Data to insert to members table
  * @param 	array 		Data to insert to profile table
  * @param 	array 		Data to insert to custom profile fields table
  * @param 	string 		Path to avatars folder
  * @param 	string 		Path to profile pictures folder
  * @return 	boolean		Success or fail
  **/
 public function convertMember($info, $members, $profile, $custom, $pic_path = '', $groupLink = TRUE)
 {
     //-----------------------------------------
     // Make sure we have everything we need
     //-----------------------------------------
     if (!$info['id']) {
         $this->logError($info['id'], 'No ID number provided');
         return false;
     }
     if (!$info['username']) {
         $this->logError($info['id'], 'No username provided');
         return false;
     }
     if (!$info['email']) {
         // See Tracker Report #28874 for reasons why this got changed.
         $info['email'] = $info['id'] . '@' . time() . '.com';
         //$info['email'] = rand(1, 100).'@'.time().'.com';
         $this->logError($info['id'], 'No email address provided - member converted with ' . $info['email']);
     }
     // Check profile photo
     if (!is_writeable($this->settings['upload_dir'] . '/profile')) {
         $this->error($this->settings['upload_dir'] . '/profile is not writeable, cannot continue');
         return false;
     }
     //-----------------------------------------
     // Set some needed variables
     //-----------------------------------------
     $now = time();
     $joined = $info['joined'] ? $info['joined'] : $now;
     if ($info['md5pass']) {
         $salt = IPSMember::generatePasswordSalt(5);
         $hash = IPSMember::generateCompiledPasshash($salt, $info['md5pass']);
     } elseif ($info['plainpass']) {
         $salt = IPSMember::generatePasswordSalt(5);
         $hash = IPSMember::generateCompiledPasshash($salt, md5($info['plainpass']));
     } elseif ($info['pass_hash']) {
         $salt = $info['pass_salt'];
         $hash = $info['pass_hash'];
     } elseif ($info['password'] !== NULL) {
         $members['conv_password'] = $info['password'];
     } else {
         // give em a random pass, let's stop those posts by these users being lost and assigned to guests.
         $randPass = IPSMember::makePassword();
         $salt = IPSMember::generatePasswordSalt(5);
         $hash = IPSMember::generateCompiledPasshash($salt, $randPass);
         $this->logError($info['id'], 'No password provided. Member has still been converted with password: '******'email'], 'all');
     if ($duplicateMember['member_id']) {
         $this->logError($info['id'], "Duplicate member found. {$info['username']} has been merged with the account email {$duplicateMember['username']}");
         $this->addLink($duplicateMember['member_id'], $info['id'], 'members');
         $this->DB->update('conv_link', array('duplicate' => '1'), "type = 'members' AND app={$this->app['app_id']} AND foreign_id='{$info['id']}'");
         if ($info['posts'] > 0) {
             $this->DB->update('members', array('posts' => "posts+'{$info['posts']}'"), "member_id='{$duplicateMember['member_id']}'");
         }
         // we have a customavatar and the one we have on file does not match what we've been given, time to update it.
         if ($profile['photo_type'] == 'custom' and $duplicateMember['pp_main_photo'] != $profile['pp_main_photo']) {
             if ($profile['photo_data']) {
                 // open file for writing
                 if (!($handle = fopen($this->settings['upload_dir'] . '/profile/photo-' . $profile['pp_member_id'] . '.png', 'w'))) {
                     $this->logError($info['id'], 'Could not write to file.');
                 }
                 // Write image to our opened file.
                 if (fwrite($handle, $profile['photo_data']) === FALSE) {
                     $this->logError($info['id'], 'Could not write to file.');
                 }
                 // log it all into DB
                 $profile['pp_main_photo'] = 'profile/photo-' . $profile['pp_member_id'] . '.png';
             }
         }
         return TRUE;
     }
     //-----------------------------------------
     // Handle Names
     //-----------------------------------------
     // Apostrophe is an allowed character but needs converting
     $info['username'] = str_replace("'", '&#39;', $info['username']);
     $info['username'] = str_replace("!", '&#33;', $info['username']);
     // as is an excalamation point.
     $nameCheck = IPSMember::getFunction()->cleanAndCheckName($info['username'], array(), 'name');
     // Check for illegal characters
     if ($nameCheck['errors']['username'] == ipsRegistry::getClass('class_localization')->words['reg_error_chars']) {
         // Illegal characters exist, clean them out with dashes
         $nameCheckMap['disallowed'] = array("'", "\"", "&#34;", "<", ">", "\\", "&#92;", "\$", "&#036;", "]", "[", ",", "|");
         $nameCheckMap['replace'] = array('&#39;', '&#quot;', '&#quot;', '&#lt;', '&#gt;', '-', '-', '-', '-', '-', '-', '-', '-');
         $nameCheck['members_display_name'] = str_replace($nameCheckMap['disallowed'], $nameCheckMap['replace'], $nameCheck['username']);
         $this->logError($info['id'], "{$nameCheck['errors']['username']} with name {$info['username']}. Member has still been created but with username as {$nameCheck['username']}");
         // Now check for duplicate username.
         try {
             if (IPSMember::getFunction()->checkNameExists($nameCheck['username'], array(), 'name', true, true)) {
                 $t = time();
                 $this->logError($info['id'], ipsRegistry::getClass('class_localization')->words['reg_error_username_taken'] . " with name {$nameCheck['username']}. Member has still been created but with username as {$nameCheck['username']}{$t}");
                 $nameCheck['username'] = $nameCheck['username'] . $t;
             }
         } catch (Exception $e) {
             //-----------------------------------------
             // Name exists, let's return appropriately
             //-----------------------------------------
             switch ($e->getMessage()) {
                 default:
                     $this->logError($info['id'], "Unexpected error with name: {$info['username']}. Member was skipped.");
                     return false;
             }
         }
     } elseif ($nameCheck['errors']['username'] == 'reg_error_username_taken') {
         $nameCheck['username'] = $nameCheck['username'] . time();
         $this->logError($info['id'], "{$nameCheck['errors']['username']} with name: {$info['username']}. Member has still been created but with username as {$nameCheck['username']}");
     }
     $username = $displayname = $nameCheck['username'];
     // Begin check and clean for display name if provided.
     if (isset($info['displayname'])) {
         // Apostrophe is an allowed character but needs converting
         $info['displayname'] = str_replace("'", '&#39;', $info['displayname']);
         $displayname = NULL;
         $nameCheck = IPSMember::getFunction()->cleanAndCheckName($info['displayname'], array(), 'members_display_name');
         if ($nameCheck['errors']['dname'] == str_replace('{chars}', ipsRegistry::$settings['username_characters'], ipsRegistry::$settings['username_errormsg'])) {
             $nameCheckMap['disallowed'] = array("'", "\"", "&#34;", "<", ">", "\\", "&#92;", "\$", "&#036;", "]", "[", ",", "|");
             $nameCheckMap['replace'] = array('&#39;', '&#quot;', '&#quot;', '&#lt;', '&#gt;', '-', '-', '-', '-', '-', '-', '-', '-');
             $nameCheck['members_display_name'] = str_replace($nameCheckMap['disallowed'], $nameCheckMap['replace'], $nameCheck['members_display_name']);
             $this->logError($info['id'], "{$nameCheck['errors']['dname']} with name: {$info['displayname']}. Member has still been created but with display name as {$nameCheck['members_display_name']}");
             // Now check for duplicate display name.
             try {
                 if (IPSMember::getFunction()->checkNameExists($nameCheck['members_display_name'], array(), 'members_display_name', true, true)) {
                     $t = time();
                     $this->logError($info['id'], ipsRegistry::getClass('class_localization')->words['reg_error_username_taken'] . " with name {$nameCheck['members_display_name']}. Member has still been created but with display name as {$nameCheck['members_display_name']}{$t}");
                     $nameCheck['members_display_name'] = $nameCheck['members_display_name'] . $t;
                 }
             } catch (Exception $e) {
                 //-----------------------------------------
                 // Name exists, let's return appropriately
                 //-----------------------------------------
                 switch ($e->getMessage()) {
                     default:
                         $this->logError($info['id'], "Unexpected error with display name: {$info['displayname']}. Member was skipped.");
                         return false;
                 }
             }
         } elseif ($nameCheck['errors']['dname'] == 'reg_error_username_taken') {
             $nameCheck['members_display_name'] = $nameCheck['members_display_name'] . time();
             $this->logError($info['id'], "{$nameCheck['errors']['dname']} with name: {$info['displayname']}. Member has still been created but with display name as {$nameCheck['members_display_name']}");
         }
         $displayname = $nameCheck['members_display_name'];
     }
     // Check we have a path
     if (!$this->settings['upload_dir']) {
         $this->logError($info['id'], 'Your IP.Board uploads path has not been configured');
         return false;
     }
     //-----------------------------------------
     // Insert
     //-----------------------------------------
     $members['title'] = str_replace("'", '&#39;', $members['title']);
     //$members['member_id']				= $info['id'];
     $members['name'] = $username;
     $members['last_post'] = intval($members['last_post']);
     if (empty($info['member_group_id'])) {
         $members['member_group_id'] = $info['group'] ? $groupLink === TRUE ? $this->getLink($info['group'], 'groups') : $info['group'] : $this->settings['member_group'];
     } else {
         $members['member_group_id'] = $info['member_group_id'];
     }
     $members['email'] = $info['email'];
     $members['joined'] = $joined;
     $members['member_login_key'] = IPSMember::generateAutoLoginKey();
     $members['member_login_key_expire'] = ipsRegistry::$settings['login_key_expire'] ? time() + intval(ipsRegistry::$settings['login_key_expire']) * 86400 : 0;
     $members['members_display_name'] = $displayname;
     $members['members_seo_name'] = IPSText::makeSeoTitle($displayname);
     $members['members_l_display_name'] = IPSText::mbstrtolower($displayname);
     $members['members_l_username'] = IPSText::mbstrtolower($username);
     $members['members_pass_hash'] = $hash;
     $members['members_pass_salt'] = $salt;
     $members['posts'] = $members['posts'] ? $members['posts'] : 0;
     $members['warn_level'] = (int) $members['warn_level'];
     // Sort out secondary groups
     if (!empty($info['secondary_groups'])) {
         // explode so we can loop through for the getLink
         $secondary_groups = explode(",", $info['secondary_groups']);
         $_secondary = array();
         if (!empty($secondary_groups)) {
             foreach ($secondary_groups as $group) {
                 if (!empty($group)) {
                     $newGroup = $this->getLink($group, 'groups', true);
                     if ($newGroup) {
                         $_secondary[] = $newGroup;
                     }
                 }
                 /**else
                 			{
                 				$this->logError($info['id'] .' - '. $group, 'empty secondary group id');
                 			}**/
             }
         }
         $members['mgroup_others'] = implode(",", $_secondary);
     }
     // Sneaky hack with the comments and friends
     if (!in_array('pp_setting_count_comments', $profile)) {
         $profile['pp_setting_count_comments'] = 1;
     }
     if (!in_array('pp_setting_count_friends', $profile)) {
         $profile['pp_setting_count_friends'] = 1;
     }
     // We better turn on allow_admin_mails if it isn't set
     $members['allow_admin_mails'] = isset($members['allow_admin_mails']) ? $members['allow_admin_mails'] : 1;
     // Fix up the birthday since STRICT complains..
     $members['bday_day'] = intval($members['bday_day']);
     $members['bday_month'] = intval($members['bday_month']);
     $members['bday_year'] = intval($members['bday_year']);
     // No idea why birthdays are messing up.., so I'll just hack this bit. - Alex
     // #020372 tracker
     if ($members['bday_year'] < 1900) {
         // Don't think we can really be this old ya know.
         $members['bday_day'] = 0;
         $members['bday_month'] = 0;
         $members['bday_year'] = 0;
     }
     // 3.1.3 dropped columns
     unset($members['email_pm']);
     // 3.2.0 Dropped columns
     unset($members['hide_email']);
     unset($members['view_avs']);
     // 3.3.0 Dropped columns
     unset($members['members_editor_choice']);
     // First member?
     if ($info['id'] != $this->memberData['member_id']) {
         if ($this->usingExtendedInserts) {
             // Add it to the extended insert array which runs on next()
             $this->extendedInserts['members'][] = $this->DB->compileInsertString($members);
             //$memberId = $members['member_id'];
             $memberId = $info['id'];
         } else {
             //unset( $members['member_id'] );
             $this->DB->insert('members', $members);
             $memberId = $this->DB->getInsertId();
             // Add a link
             $this->addLink($memberId, $info['id'], 'members');
         }
     } else {
         if ($this->usingExtendedInserts) {
             // Unset important information to stop locking us out
             $unset = array('member_id', 'members_pass_salt', 'members_pass_hash', 'name', 'members_l_username', 'members_display_name', 'members_l_display_name', 'members_seo_name', 'member_banned', 'conv_password', 'email', 'member_group_id');
             foreach ($unset as $k) {
                 unset($members[$k]);
             }
             $this->DB->update('members', $members, "member_id=" . $this->memberData['member_id']);
             $memberId = $this->memberData['member_id'];
             $this->logError($memberId, "<strong><span style='size: 1.15em;'>{$username} has been merged with {$this->memberData['members_display_name']}. This is because you are logged in as {$this->memberData['members_display_name']} and due to both members sharing the same ID. You are not running the conversion in 'merge' mode and therefore you WILL have to manually update this members name, email address, AND member group.</span></strong><br /><ul><li>Username: {$username}</li><li>Email Address: {$info['email']}</li></ul>");
         } else {
             //unset( $members['member_id'] );
             $this->DB->insert('members', $members);
             $memberId = $this->DB->getInsertId();
             // Add a link
             $this->addLink($memberId, $info['id'], 'members');
         }
     }
     // If user group is the auth group, add them to validating table.
     if ($members['member_group_id'] == $this->settings['auth_group'] && ($this->settings['reg_auth_type'] == 'user' || $this->settings['reg_auth_type'] == 'admin' || $this->settings['reg_auth_type'] == 'admin_user')) {
         //-----------------------------------------
         // We want to validate all reg's via email,
         // after email verificiation has taken place,
         // we restore their previous group and remove the validate_key
         //-----------------------------------------
         $validating = array('vid' => md5(uniqid()), 'member_id' => $memberId, 'real_group' => $this->settings['member_group'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => time(), 'coppa_user' => 0, 'new_reg' => 1, 'ip_address' => $members['ip_address'], 'spam_flag' => 0);
         if ($this->usingExtendedInserts) {
             $this->extendedInserts['validating'][] = $this->DB->compileInsertString($validating);
         } else {
             $this->DB->insert('validating', $validating);
         }
     }
     $profile['pp_member_id'] = $memberId;
     // Defaults if not specified (prevents "Column Count Mismatches" in MySQL)
     $profile['pp_thumb_photo'] = $profile['pp_thumb_photo'] ? $profile['pp_thumb_photo'] : '';
     $profile['pp_main_photo'] = $profile['pp_main_photo'] ? $profile['pp_main_photo'] : '';
     $profile['pp_main_width'] = $profile['pp_main_width'] ? $profile['pp_main_width'] : 0;
     $profile['pp_main_height'] = $profile['pp_main_height'] ? $profile['pp_main_height'] : 0;
     $profile['pp_thumb_width'] = $profile['pp_thumb_width'] ? $profile['pp_thumb_width'] : 0;
     $profile['pp_thumb_height'] = $profile['pp_thumb_height'] ? $profile['pp_thumb_height'] : 0;
     //-----------------------------------------
     // Sort out uploaded avatars / photos
     //-----------------------------------------
     // we send profile_type of custom if we have a photo at all
     if ($profile['photo_type'] == 'custom') {
         if ($profile['photo_data']) {
             // open file for writing
             if (!($handle = fopen($this->settings['upload_dir'] . '/profile/photo-' . $profile['pp_member_id'] . '.png', 'w'))) {
                 $this->logError($info['id'], 'Could not write to file.');
             }
             // Write image to our opened file.
             if (fwrite($handle, $profile['photo_data']) === FALSE) {
                 $this->logError($info['id'], 'Could not write to file.');
             }
             // log it all into DB
             $profile['pp_main_photo'] = 'profile/photo-' . $profile['pp_member_id'] . '.png';
         }
     }
     if ($profile['photo_type'] == 'url') {
         // Make an attempt at fetching the remote pic. If not, log an error.
         $profile['pp_main_photo'] = '';
         if ($remote = @file_get_contents($profile['photo_location'])) {
             $image_dims = @getimagesize($profile['photo_location']);
             if ($image_dims[0]) {
                 $profile['photo_data'] = $remote;
                 $profile['photo_type'] = 'custom';
                 $profile['pp_main_photo'] = $profile['photo_location'];
                 if (!isset($profile['photo_filesize'])) {
                     $profile['photo_filesize'] = strlen($remote);
                 }
             } else {
                 $this->logError($info['id'], 'Remote picture file does not appear to be an image.');
             }
         } else {
             $this->logError($info['id'], 'Could not fetch remote picture file.');
         }
     }
     // Oops... I screwed up... workaround for now... will fix properly soon.
     if ($profile['photo_type'] != 'url' and $profile['photo_location'] and !$profile['pp_main_photo']) {
         $profile['pp_main_photo'] = $profile['photo_location'];
     }
     if (!is_dir($pic_path) and $profile['pp_main_photo'] and !$profile['photo_data']) {
         $this->logError($info['id'], 'Incorrect profile pictures path');
         //return false;
     }
     // Move em or create em
     if ($profile['pp_main_photo']) {
         //-----------------------------------------
         // Already a dir?
         //-----------------------------------------
         $upload_path = $this->settings['upload_dir'];
         $upload_dir;
         if (!file_exists($upload_path . "/profile")) {
             if (@mkdir($upload_path . "/profile", 0777)) {
                 @file_put_contents($upload_path . '/profile/index.html', '');
                 @chmod($upload_path . "/profile", 0777);
                 # Set path and dir correct
                 $upload_path .= "/profile";
                 $upload_dir = "profile/";
             } else {
                 # Set path and dir correct
                 $upload_dir = "";
             }
         } else {
             # Set path and dir correct
             $upload_path .= "/profile";
             $upload_dir = "profile/";
         }
         // What's the extension?
         $e = explode('.', $profile['pp_main_photo']);
         $extension = array_pop($e);
         // There's an issue with profile photo thumbnail rebuilds. Waiting on the deal with that issue before adjusting this.
         // For now, we'll just set the thumbnail the same as the main photo.
         $profile['pp_thumb_photo'] = "{$upload_dir}photo-{$memberId}.{$extension}";
         if ($profile['photo_data']) {
             //$this->createFile($profile['pp_main_photo'], $profile['photo_data'], $profile['photo_filesize'], $this->settings['upload_dir']);
             $this->createFile("photo-{$memberId}.{$extension}", $profile['photo_data'], $profile['photo_filesize'], $upload_path);
             $profile['pp_main_photo'] = "{$upload_dir}photo-{$memberId}.{$extension}";
         } else {
             //$this->moveFiles(array($profile['pp_main_photo']), $profile_path, $this->settings['upload_dir']);
             $this->moveFiles(array($profile['pp_main_photo']), $pic_path, $upload_path);
             if ($upload_dir != '' && @rename($upload_path . "/{$profile['pp_main_photo']}", $upload_path . "/photo-{$memberId}.{$extension}")) {
                 $profile['pp_main_photo'] = "{$upload_dir}photo-{$memberId}.{$extension}";
             }
         }
         // Try and get width and height.
         $dimensions = @getimagesize($upload_dir . 'photo-' . $memberId . '.' . $extension);
         // Add some triple checks.
         $profile['pp_main_width'] = $dimensions[0] ? $dimensions[0] : 1;
         $profile['pp_main_height'] = $dimensions[1] ? $dimensions[1] : 1;
         $profile['pp_thumb_width'] = $dimensions[0] ? $dimensions[0] : 1;
         $profile['pp_thumb_height'] = $dimensions[1] ? $dimensions[1] : 1;
     }
     $profile['pp_photo_type'] = $profile['photo_type'];
     unset($profile['avatar_data']);
     unset($profile['photo_data']);
     unset($profile['photo_filesize']);
     unset($profile['avatar_filesize']);
     unset($profile['photo_type']);
     unset($profile['photo_location']);
     unset($profile['notes']);
     // need to stop fields which have been added by hooks getting through. See ticket 854980 as to why this is needed.
     if (is_array($profile)) {
         // set the fields we're allowed (I can't think of a better way of populating this array unfortunately)
         $allowedFields = array('pp_member_id', 'pp_last_visitors', 'pp_rating_hits', 'pp_rating_value', 'pp_rating_real', 'pp_main_photo', 'pp_main_width', 'pp_main_height', 'pp_thumb_photo', 'pp_thumb_width', 'pp_thumb_height', 'pp_setting_moderate_comments', 'pp_setting_moderate_friends', 'pp_setting_count_friends', 'pp_setting_count_comments', 'pp_setting_count_visitors', 'pp_about_me', 'pp_reputation_points', 'pp_gravatar', 'pp_photo_type', 'signature', 'avatar_location', 'avatar_size', 'avatar_type', 'pconversation_filters', 'fb_photo', 'fb_photo_thumb', 'fb_bwoptions', 'tc_last_sid_import', 'tc_photo', 'tc_bwoptions', 'pp_customization', 'pp_profile_update');
         foreach ($profile as $k => $v) {
             // not in allowed array? unset. (this stops fields from hooks making it through)
             if (!in_array($k, $allowedFields)) {
                 unset($profile[$k]);
             }
         }
     }
     // check if we passed in custom..
     $profileFields = array();
     $profileFields['member_id'] = $memberId;
     if (!empty($custom)) {
         $profileFields = array_merge($profileFields, $custom);
     }
     // First member?
     if ($info['id'] != $this->memberData['member_id']) {
         if ($this->usingExtendedInserts) {
             // Add it to the extended insert array which runs on next()
             $this->extendedInserts['profile_portal'][] = $this->DB->compileInsertString($profile);
             // Custom profile fields
             $this->extendedInserts['pfields_content'][] = $this->DB->compileInsertString($profileFields);
         } else {
             $this->DB->insert('profile_portal', $profile);
             $this->DB->insert('pfields_content', $profileFields);
         }
     } else {
         if ($this->usingExtendedInserts) {
             unset($profileFields['member_id']);
             unset($profile['pp_member_id']);
             $this->DB->update('profile_portal', $profile, "pp_member_id=" . $this->memberData['member_id']);
             $this->DB->update('pfields_content', $profileFields, "member_id=" . $this->memberData['member_id']);
         } else {
             $this->DB->insert('profile_portal', $profile);
             $this->DB->insert('pfields_content', $profileFields);
         }
     }
     // Conversion cycle complete
     return true;
 }
Пример #21
0
 /**
  * Move a topic
  *
  * @param	mixed 		Topic id | Array of topic ids
  * @param	integer		Source forum
  * @param	integer		Move to forum
  * @param	boolean		Leave the 'link'
  * @return	boolean
  */
 public function topicMove($topics, $source = 0, $moveto = 0, $leavelink = 0)
 {
     $this->error = "";
     $source = intval($source);
     $moveto = intval($moveto);
     $forumIDSQL = $source ? " forum_id={$source} AND " : '';
     $ids = array();
     if (is_array($topics)) {
         $topics = IPSLib::cleanIntArray($topics);
         if (count($topics) > 0) {
             $tid = " IN(" . implode(",", $topics) . ")";
             $ids = $topics;
         } else {
             return false;
         }
         //-----------------------------------------
         // Mark as read in new forum
         //-----------------------------------------
         foreach ($topics as $_tid) {
             $this->registry->classItemMarking->markRead(array('forumID' => $moveto, 'itemID' => $_tid), 'forums');
         }
     } else {
         if (intval($topics)) {
             $tid = "={$topics}";
             $ids = array($topics);
         } else {
             return false;
         }
         //-----------------------------------------
         // Mark as read in new forum
         //-----------------------------------------
         $this->registry->classItemMarking->markRead(array('forumID' => $moveto, 'itemID' => $topics), 'forums');
     }
     /* GET AND EXAMINE */
     $_topics = $this->registry->topics->getTopics(array('topicId' => $ids, 'archiveState' => array('not', 'exclude'), 'topicType' => array('all')));
     if (!count($_topics)) {
         return false;
     } else {
         $ids = array_keys($_topics);
         $tid = " IN(" . implode(",", $ids) . ")";
     }
     /* Update recent posts */
     $this->registry->topics->updateRecentPost(array('post_forum_id' => $moveto), array('post_topic_id' => $ids));
     //-----------------------------------------
     // Update the topic
     //-----------------------------------------
     $this->DB->update('topics', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Update the polls
     //-----------------------------------------
     $this->DB->update('polls', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Update the voters
     //-----------------------------------------
     $this->DB->update('voters', array('forum_id' => $moveto), $forumIDSQL . "tid" . $tid);
     //-----------------------------------------
     // Are we leaving a stink er link?
     //-----------------------------------------
     if ($leavelink and $source) {
         $this->DB->build(array('select' => '*', 'from' => 'topics', 'where' => "tid" . $tid));
         $oq = $this->DB->execute();
         while ($row = $this->DB->fetch($oq)) {
             $this->DB->setDataType(array('title', 'starter_name', 'last_poster_name', 'seo_last_name'), 'string');
             $this->DB->insert('topics', array('title' => $row['title'], 'state' => 'link', 'posts' => 0, 'views' => 0, 'starter_id' => $row['starter_id'], 'start_date' => $row['start_date'], 'starter_name' => $row['starter_name'], 'seo_first_name' => IPSText::makeSeoTitle($row['starter_name']), 'last_post' => $row['last_post'], 'forum_id' => $source, 'approved' => 1, 'pinned' => 0, 'moved_to' => $row['tid'] . '&' . $moveto, 'moved_on' => time(), 'last_poster_id' => $row['last_poster_id'], 'last_poster_name' => $row['last_poster_name'], 'seo_last_name' => IPSText::makeSeoTitle($row['starter_name'])));
         }
     }
     /* Tagging */
     $this->registry->tags->moveTagsToParentId($ids, $moveto);
     //-----------------------------------------
     // Sort out subscriptions
     //-----------------------------------------
     $trid_to_delete = array();
     //-----------------------------------------
     // Like class - remove if you don't have access
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
     /*noLibHook*/
     $_like = classes_like::bootstrap('forums', 'topics');
     $topics = $_like->getDataByRelationshipId($tid);
     if (count($topics)) {
         foreach ($topics as $r) {
             $perm_id = $r['org_perm_id'] ? $r['org_perm_id'] : $r['g_perm_id'];
             if ($this->registry->permissions->check('read', $this->registry->class_forums->allForums[$moveto], explode(',', IPSText::cleanPermString($perm_id))) !== TRUE) {
                 $trid_to_delete[] = $r['like_id'];
             }
         }
     }
     if (count($trid_to_delete) > 0) {
         $this->DB->delete('core_like', "like_id IN('" . implode("','", $trid_to_delete) . "')");
     }
     return true;
 }
 /**
  * Set up defaults for a guest user
  *
  * @access	public
  * @param	string	Guest name
  * @return	array 	Guest record
  * @since	2.0
  * @todo		[Future] We may want to move this into the session class at some point
  */
 public static function setUpGuest($name = 'Guest')
 {
     $cache = ipsRegistry::cache()->getCache('group_cache');
     $array = array('name' => $name, 'members_display_name' => $name, '_members_display_name' => $name, 'members_seo_name' => IPSText::makeSeoTitle($name), 'member_id' => 0, 'password' => '', 'email' => '', 'title' => '', 'posts' => 0, 'member_group_id' => ipsRegistry::$settings['guest_group'], 'view_sigs' => ipsRegistry::$settings['guests_sig'], 'view_img' => ipsRegistry::$settings['guests_img'], 'view_avs' => ipsRegistry::$settings['guests_ava'], 'member_forum_markers' => array(), 'avatar' => '', 'member_posts' => '', 'g_title' => $cache[ipsRegistry::$settings['guest_group']]['g_title'], 'member_rank_img' => '', 'member_joined' => '', 'member_location' => '', 'member_number' => '', 'members_auto_dst' => 0, 'has_blog' => 0, 'has_gallery' => 0, 'is_mod' => 0, 'last_visit' => time(), 'login_anonymous' => '', 'mgroup_others' => '', 'org_perm_id' => '', '_cache' => array('qr_open' => 0), 'auto_track' => 0, 'ignored_users' => NULL, 'members_editor_choice' => 'std', '_cache' => array('friends' => array()), '_group_formatted' => IPSLib::makeNameFormatted($cache[ipsRegistry::$settings['guest_group']]['g_title'], ipsRegistry::$settings['guest_group']));
     return is_array($cache[ipsRegistry::$settings['guest_group']]) ? array_merge($array, $cache[ipsRegistry::$settings['guest_group']]) : $array;
 }
Пример #23
0
 /**
  * Import and parse an iCalendar feed
  *
  * @param	string		$content	Feed content
  * @param	int			$member_id	Member to save events under
  * @param	int			$feed_id	Feed id
  * @return	mixed		False on failure, otherwise an array with keys 'skipped' and 'imported'
  */
 public function import($content, $member_id = 0, $feed_id = 0)
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $this->lang->loadLanguageFile(array('admin_calendar'), 'calendar');
     //-----------------------------------------
     // Error checking
     //-----------------------------------------
     if (!$content) {
         $this->_error = $this->lang->words['icali_nocontent'];
         return;
     }
     $_raw = preg_replace("#(\n\r|\r|\n){1,}#", "\n", $content);
     $_raw = explode("\n", $_raw);
     if (!count($_raw)) {
         $this->_error = $this->lang->words['icali_nocontent'];
         return;
     }
     if ($_raw[0] != 'BEGIN:VCALENDAR') {
         $this->_error = $this->lang->words['icali_badcontent'];
         return;
     }
     $this->_rawIcsData = $_raw;
     //-----------------------------------------
     // Loop and start parsing
     //-----------------------------------------
     foreach ($this->_rawIcsData as $k => $v) {
         $line = explode(':', $v);
         switch ($line[0]) {
             case 'BEGIN':
                 $this->_parseBeginBlock($line[1], $k);
                 break;
                 /* Unsupported at this time */
             /* Unsupported at this time */
             case 'CALSCALE':
             case 'METHOD':
             case 'X-WR-TIMEZONE':
             case 'X-WR-RELCALID':
             default:
                 break;
         }
     }
     //-----------------------------------------
     // Process raw ICS data now
     //-----------------------------------------
     if (count($this->_parsedIcsData)) {
         $this->_parsedIcsData = $this->_convertToGmt($this->_parsedIcsData);
     }
     //-----------------------------------------
     // And loop over results to insert
     //-----------------------------------------
     $_imported = 0;
     $_skipped = 0;
     // Leave this here - useful for debugging
     //print_r($this->_parsedIcsData);exit;
     if (count($this->_parsedIcsData)) {
         //-----------------------------------------
         // Get member data
         //-----------------------------------------
         $_member = IPSMember::load($member_id);
         if (!$_member) {
             $this->_error = $this->lang->words['icali_nomember'];
             return false;
         }
         //-----------------------------------------
         // Get like class for notifications
         //-----------------------------------------
         require_once IPS_ROOT_PATH . 'sources/classes/like/composite.php';
         /*noLibHook*/
         $_like = classes_like::bootstrap('calendar', 'calendars');
         //-----------------------------------------
         // Loop over the events
         //-----------------------------------------
         foreach ($this->_parsedIcsData['events'] as $event) {
             $event['uid'] = $event['uid'] ? $event['uid'] : md5(implode(',', $event));
             $event_unix_from = $event['start']['gmt_ts'];
             $event_unix_to = $event['end']['gmt_ts'];
             $event_all_day = $event['start']['type'] == 'DATE' ? 1 : 0;
             //-----------------------------------------
             // End dates are "exclusive" in iCalendar format, meaning
             // they are actually the day ahead.
             // @link	http://microformats.org/wiki/dtend-issue
             //-----------------------------------------
             if ($event_unix_to and $event['end']['type'] == 'DATE') {
                 $event_unix_to -= 86400;
             }
             //-----------------------------------------
             // If end date is same as start date, it's a single day event
             //-----------------------------------------
             if ($event_unix_from == $event_unix_to) {
                 $event_unix_to = 0;
             }
             //-----------------------------------------
             // If no end date, but we have a duration, calculate end date
             //-----------------------------------------
             if (!$event_unix_to and $event['duration']) {
                 preg_match("#(\\d+?)H#is", $event['duration'], $match);
                 $hour = $match[1] ? $match[1] : 0;
                 preg_match("#(\\d+?)M#is", $event['duration'], $match);
                 $minute = $match[1] ? $match[1] : 0;
                 preg_match("#(\\d+?)S#is", $event['duration'], $match);
                 $second = $match[1] ? $match[1] : 0;
                 $event_unix_to = $event_unix_from + $hour * 3600 + $minute * 60 + $second;
             }
             //-----------------------------------------
             // Recurring...
             //-----------------------------------------
             $recurring = 0;
             if (isset($event['recurr']['FREQ'])) {
                 if ($event['recurr']['FREQ'] == 'MONTHLY' and $event['recurr']['INTERVAL'] == 12) {
                     $event['recurr']['FREQ'] = 'YEARLY';
                 }
                 switch ($event['recurr']['FREQ']) {
                     case 'WEEKLY':
                         $recurring = 1;
                         break;
                     case 'MONTHLY':
                         $recurring = 2;
                         break;
                     case 'YEARLY':
                         $recurring = 3;
                         break;
                 }
                 $event_unix_to = $event['recurr']['until_ts'] ? $event['recurr']['until_ts'] : time() + 86400 * 365 * 10;
             }
             //-----------------------------------------
             // Adjust timestamps if all day event
             //-----------------------------------------
             if ($event_all_day) {
                 $event_unix_from = gmmktime(0, 0, 0, gmstrftime('%m', $event_unix_from), gmstrftime('%d', $event_unix_from), gmstrftime('%Y', $event_unix_from));
                 $event_unix_to = $event_unix_to ? gmmktime(0, 0, 0, gmstrftime('%m', $event_unix_to), gmstrftime('%d', $event_unix_to), gmstrftime('%Y', $event_unix_to)) : 0;
             }
             //-----------------------------------------
             // If we are missing crucial data, skip
             //-----------------------------------------
             if (!($event['description'] or $event['summary']) or !$event_unix_from) {
                 $_skipped++;
                 continue;
             }
             //-----------------------------------------
             // Skip previously imported events
             //-----------------------------------------
             if ($event['uid']) {
                 $_check = $this->DB->buildAndFetch(array('select' => 'import_id', 'from' => 'cal_import_map', 'where' => "import_guid='" . $this->DB->addSlashes($event['uid']) . "'"));
                 if ($_check['import_id']) {
                     $_skipped++;
                     continue;
                 }
             }
             //-----------------------------------------
             // Format array for storage
             //-----------------------------------------
             $_eventData = array('event_calendar_id' => $this->calendar['cal_id'], 'event_member_id' => $_member['member_id'], 'event_content' => $event['description'] ? nl2br($event['description']) : $event['summary'], 'event_title' => $event['summary'] ? $event['summary'] : IPSText::truncate($event['description'], 100), 'event_title_seo' => IPSText::makeSeoTitle($event['summary']), 'event_smilies' => 1, 'event_comments' => 0, 'event_rsvp' => count($event['attendee']) ? 1 : 0, 'event_perms' => '*', 'event_private' => 0, 'event_approved' => 1, 'event_saved' => $event['created'] ? $event['created'] : time(), 'event_lastupdated' => $event['last_modified'] ? $event['last_modified'] : ($event['created'] ? $event['created'] : time()), 'event_recurring' => $recurring, 'event_start_date' => strftime("%Y-%m-%d %H:%M:00", $event_unix_from), 'event_end_date' => $event_unix_to ? strftime("%Y-%m-%d %H:%M:00", $event_unix_to) : 0, 'event_post_key' => md5(uniqid(microtime(), true)), 'event_sequence' => intval($event['sequence']), 'event_all_day' => $event_all_day);
             //-----------------------------------------
             // Data hooks
             //-----------------------------------------
             IPSLib::doDataHooks($_eventData, 'calendarAddEvent');
             //-----------------------------------------
             // Insert
             //-----------------------------------------
             $this->DB->insert('cal_events', $_eventData);
             $event_id = $this->DB->getInsertId();
             $_imported++;
             //-----------------------------------------
             // Insert mapping
             //-----------------------------------------
             $this->DB->insert('cal_import_map', array('import_feed_id' => $feed_id, 'import_event_id' => $event_id, 'import_guid' => $event['uid']));
             //-----------------------------------------
             // If we have attendees that are members, insert them
             //-----------------------------------------
             if (isset($event['attendee']) and count($event['attendee'])) {
                 foreach ($event['attendee'] as $attendee) {
                     if ($attendee['email']) {
                         $_loadedMember = IPSMember::load($attendee['email']);
                         if ($_loadedMember['member_id']) {
                             $this->DB->insert('cal_event_rsvp', array('rsvp_member_id' => $_loadedMember['member_id'], 'rsvp_event_id' => $event_id, 'rsvp_date' => time()));
                         }
                     }
                 }
             }
             //-----------------------------------------
             // Send notifications
             //-----------------------------------------
             $_url = $this->registry->output->buildSEOUrl('app=calendar&amp;module=calendar&amp;section=view&amp;do=showevent&amp;event_id=' . $event_id, 'public', $_eventData['event_title_seo'], 'cal_event');
             $_like->sendNotifications($_eventData['event_calendar_id'], array('immediate', 'offline'), array('notification_key' => 'new_event', 'notification_url' => $_url, 'email_template' => 'add_event_follow', 'email_subject' => sprintf($this->lang->words['add_event_follow_subject'], $_url, $_eventData['event_title']), 'build_message_array' => array('NAME' => '-member:members_display_name-', 'AUTHOR' => $_member['members_display_name'], 'TITLE' => $_eventData['event_title'], 'URL' => $_url)));
         }
     }
     //-----------------------------------------
     // Rebuild cache
     //-----------------------------------------
     $this->cache->rebuildCache('calendar_events', 'calendar');
     //-----------------------------------------
     // Return
     //-----------------------------------------
     return array('skipped' => $_skipped, 'imported' => $_imported);
 }
Пример #24
0
 /**
  * Do some set up after ipsRegistry::init()
  * 
  * @return	@e void
  */
 public function afterOutputInit()
 {
     /* Register a call back for an incorrect page */
     $this->registry->getClass('output')->registerIncorrectPageCallback(array($this, 'incorrectPageCallback'));
     if (!empty($_GET['showtopic']) and is_array($this->registry->getClass('class_forums')->topic_cache)) {
         $topic = $this->registry->getClass('class_forums')->topic_cache;
         $topic['title_seo'] = $topic['title_seo'] ? $topic['title_seo'] : IPSText::makeSeoTitle($topic['title']);
         /* Check to see if we're using old ST params */
         $this->registry->getClass('output')->checkStParamsAndRedirect($this->settings['display_max_posts']);
         /* Check TOPIC permalink... */
         $this->registry->getClass('output')->checkPermalink($topic['title_seo']);
         /* Add canonical tag */
         $this->registry->getClass('output')->addCanonicalTag($this->request['page'] ? 'showtopic=' . $topic['tid'] . '&page=' . $this->request['page'] : 'showtopic=' . $topic['tid'], $topic['title_seo'], 'showtopic');
         /* Store root doc URL */
         $this->registry->getClass('output')->storeRootDocUrl($this->registry->getClass('output')->buildSEOUrl('showtopic=' . $topic['tid'], 'publicNoSession', $topic['title_seo'], 'showtopic'));
     } else {
         if (!empty($_GET['showforum'])) {
             $_GET['showforum'] = intval($_GET['showforum']);
             ipsRegistry::$request['showforum'] = intval(ipsRegistry::$request['showforum']);
             $data = $this->registry->getClass('class_forums')->forumsFetchData($_GET['showforum']);
             $data['name_seo'] = $data['name_seo'] ? $data['name_seo'] : IPSText::makeSeoTitle($data['name']);
             /* Check to see if we're using old ST params */
             $this->registry->getClass('output')->checkStParamsAndRedirect($this->settings['display_max_topics']);
             /* Check FORUM permalink... */
             $this->registry->getClass('output')->checkPermalink($data['name_seo']);
             /* Add canonical tag */
             if ($data['id']) {
                 $this->registry->getClass('output')->addCanonicalTag($this->request['page'] ? 'showforum=' . $data['id'] . '&page=' . $this->request['page'] : 'showforum=' . $data['id'], $data['name_seo'], 'showforum');
                 /* Store root doc URL */
                 $this->registry->getClass('output')->storeRootDocUrl($this->registry->getClass('output')->buildSEOUrl('showforum=' . $data['id'], 'publicNoSession', $data['name_seo'], 'showforum'));
             }
         } else {
             if (!empty($_GET['showannouncement'])) {
                 $announce = $this->caches['announcements'][intval($_GET['showannouncement'])];
                 if ($announce['announce_id']) {
                     $_seoTitle = $announce['announce_seo_title'] ? $announce['announce_seo_title'] : IPSText::makeSeoTitle($announce['announce_title']);
                     $this->registry->getClass('output')->checkPermalink($_seoTitle);
                     /* Add canonical tag */
                     if ($announce['announce_id']) {
                         $this->registry->getClass('output')->addCanonicalTag('showannouncement=' . $announce['announce_id'] . ($_GET['f'] ? '&amp;f=' . intval($_GET['f']) : '&amp;f=0'), $_seoTitle, 'showannouncement');
                         /* Store root doc URL */
                         $this->registry->getClass('output')->storeRootDocUrl($this->registry->getClass('output')->buildSEOUrl('showannouncement=' . $announce['announce_id'] . ($_GET['f'] ? '&amp;f=' . intval($_GET['f']) : '&amp;f=0'), 'publicNoSession', $_seoTitle, 'showannouncement'));
                     }
                 }
             }
         }
     }
 }
Пример #25
0
 /**
  * Converge_Server::onUsernameChange()
  *
  * Updates the local app's DB
  *
  * This will return a param "response" with either
  * - FAILED    		 (Unknown failure)
  * - SUCCESS    	 (Added OK)
  *
  * @access	public
  * @param	int		$product_id			Product ID
  * @param	string	$auth_key 			Authentication Key
  * @param	string	$old_username		Existing username
  * @param	string	$new_username		NEW username to change
  * @param	string	$auth				Email address
  * @return	mixed	xml / boolean
  */
 public function onUsernameChange($auth_key, $product_id, $old_username, $new_username, $auth)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $auth_key = IPSText::md5Clean($auth_key);
     $product_id = intval($product_id);
     $email_address = IPStext::parseCleanValue($auth);
     $new_username = IPStext::parseCleanValue($new_username);
     $return = 'FAILED';
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($auth);
     //-----------------------------------------
     // Authenticate
     //-----------------------------------------
     if ($this->__authenticate($auth_key, $product_id) !== FALSE) {
         if ($member['member_id']) {
             if ($old_username and $new_username and $member['member_id']) {
                 $check = IPSMember::load($new_username, 'core', 'username');
                 if (!$check['member_id']) {
                     $lower = strtolower($new_username);
                     IPSMember::save($member['email'], array('core' => array('name' => $new_username, 'members_display_name' => $new_username, 'members_seo_name' => IPSText::makeSeoTitle($new_username), 'members_l_display_name' => $lower, 'members_l_username' => $lower)));
                     $return = 'SUCCESS';
                 } else {
                     $return = 'FAIL';
                 }
             }
         }
     }
     $this->classApiServer->apiSendReply(array('complete' => 1, 'response' => $return));
     exit;
 }
Пример #26
0
             $dupe = get_result("SELECT " . ($FORUMLINK == "smf" ? "`ID_MEMBER`" : "`id_member`") . " FROM `{$db_prefix}members` WHERE `member" . ($FORUMLINK == "smf" ? "N" : "_n") . "ame`=" . $username . " LIMIT 1", true, $CACHE_DURATION);
             if (!isset($dupe[0])) {
                 $smfset[] = 'member' . ($FORUMLINK == "smf" ? "N" : "_n") . 'ame=' . $username;
             } else {
                 $newname .= ', dupe name in smf memberName';
             }
             $dupe = get_result("SELECT " . ($FORUMLINK == "smf" ? "`ID_MEMBER`" : "`id_member`") . " FROM {$db_prefix}members WHERE `real" . ($FORUMLINK == "smf" ? "N" : "_n") . "ame`=" . $username . " LIMIT 1", true, $CACHE_DURATION);
             if (!isset($dupe[0])) {
                 $smfset[] = 'real' . ($FORUMLINK == "smf" ? "N" : "_n") . 'ame=' . $username;
             } else {
                 $newname .= ', dupe name in smf realName';
             }
         } elseif ($FORUMLINK == 'ipb') {
             $new_username = trim($username, "'");
             $new_l_username = strtolower($new_username);
             $new_seoname = IPSText::makeSeoTitle($new_username);
             IPSMember::save($ipb_fid, array("members" => array("name" => "{$new_username}", "members_display_name" => "{$new_username}", "members_l_display_name" => "{$new_l_username}", "members_l_username" => "{$new_l_username}", "members_seo_name" => "{$new_seoname}")));
         }
         $newname .= ' )';
     } else {
         $note .= ' Dupe name in XBTIT.';
     }
 }
 if ($topicsperpage != $curu['topicsperpage']) {
     $set[] = 'topicsperpage=' . $topicsperpage;
 }
 if ($postsperpage != $curu['postsperpage']) {
     $set[] = 'postsperpage=' . $postsperpage;
 }
 if ($torrentsperpage != $curu['torrentsperpage']) {
     $set[] = 'torrentsperpage=' . $torrentsperpage;
Пример #27
0
 /**
  * Save the topic title edits
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _doEdit()
 {
     $this->_resetModerator($this->topic['forum_id']);
     $this->_genericPermissionCheck('edit_topic');
     if (trim($this->request['TopicTitle']) == "") {
         $this->_showError('mod_no_topic_title', 10399);
     }
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
     /*noLibHook*/
     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
     $_postClass = new $classToLoad($this->registry);
     $this->request['TopicTitle'] = $_postClass->cleanTopicTitle($this->request['TopicTitle']);
     $this->request['TopicTitle'] = trim(IPSText::getTextClass('bbcode')->stripBadWords($this->request['TopicTitle']));
     if ($this->settings['etfilter_shout']) {
         if (function_exists('mb_convert_case')) {
             if (in_array(strtolower($this->settings['gb_char_set']), array_map('strtolower', mb_list_encodings()))) {
                 $this->request['TopicTitle'] = mb_convert_case($this->request['TopicTitle'], MB_CASE_TITLE, $this->settings['gb_char_set']);
             } else {
                 $this->request['TopicTitle'] = ucwords(strtolower($this->request['TopicTitle']));
             }
         } else {
             $this->request['TopicTitle'] = ucwords(strtolower($this->request['TopicTitle']));
         }
     }
     $this->request['TopicDesc'] = trim(IPSText::getTextClass('bbcode')->stripBadWords($this->request['TopicDesc']));
     $this->request['TopicDesc'] = IPSText::mbsubstr($this->request['TopicDesc'], 0, 70);
     $title_seo = IPSText::makeSeoTitle($this->request['TopicTitle']);
     $this->DB->update('topics', array('title' => $this->request['TopicTitle'], 'title_seo' => $title_seo), 'tid=' . $this->topic['tid']);
     $this->modLibrary->forumRecount($this->forum['id']);
     $this->_addModeratorLog(sprintf($this->lang->words['acp_edit_title'], $this->topic['tid'], $this->topic['title'], $this->request['TopicTitle']));
     $this->registry->output->redirectScreen($this->lang->words['p_edited'], $this->settings['base_url'] . "showtopic=" . $this->topic['tid'], $title_seo, 'showtopic');
 }
Пример #28
0
 /**
  * Update forum's last post information
  *
  * @param	array 	$topic
  * @param	string	$type
  * @return	@e void
  */
 protected function updateForumAndStats($topic, $type = 'new')
 {
     $moderated = 0;
     $stat_cache = $this->registry->cache()->getCache('stats');
     $forum_data = $this->getForumData();
     //-----------------------------------------
     // Moderated?
     //-----------------------------------------
     $moderate = 0;
     if ($this->getPublished() === false) {
         $moderate = 1;
     }
     //-----------------------------------------
     // Add to forum's last post?
     //-----------------------------------------
     if (!$moderate) {
         if ($topic['approved']) {
             $dbs = array('last_title' => $topic['title'], 'seo_last_title' => IPSText::makeSeoTitle($topic['title']), 'last_id' => $topic['tid'], 'last_post' => IPS_UNIX_TIME_NOW, 'last_poster_name' => $this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName'], 'seo_last_name' => IPSText::makeSeoTitle($this->getAuthor('member_id') ? $this->getAuthor('members_display_name') : $this->request['UserName']), 'last_poster_id' => $this->getAuthor('member_id'), 'last_x_topic_ids' => $this->registry->class_forums->lastXFreeze($this->registry->class_forums->buildLastXTopicIds($forum_data['id'], FALSE)));
             if ($type == 'new') {
                 $stat_cache['total_topics']++;
                 $forum_data['topics'] = intval($forum_data['topics']);
                 $dbs['topics'] = ++$forum_data['topics'];
                 $dbs['newest_id'] = $topic['tid'];
                 $dbs['newest_title'] = $topic['title'];
             } else {
                 $stat_cache['total_replies']++;
                 $forum_data['posts'] = intval($forum_data['posts']);
                 $dbs['posts'] = ++$forum_data['posts'];
             }
         }
     } else {
         if ($type == 'new') {
             $forum_data['queued_topics'] = intval($forum_data['queued_topics']);
             $dbs['queued_topics'] = ++$forum_data['queued_topics'];
         } else {
             $forum_data['queued_posts'] = intval($forum_data['queued_posts']);
             $dbs['queued_posts'] = ++$forum_data['queued_posts'];
         }
     }
     //-----------------------------------------
     // Merging posts?
     // Don't update counter
     //-----------------------------------------
     if ($this->_isMergingPosts) {
         unset($dbs['posts']);
         unset($dbs['queued_posts']);
         $stat_cache['total_replies'] -= 1;
     }
     //-----------------------------------------
     // Update
     //-----------------------------------------
     if (is_array($dbs) and count($dbs)) {
         $this->DB->setDataType(array('last_poster_name', 'seo_last_name', 'seo_last_title', 'last_title'), 'string');
         /* Data Hook Location */
         IPSLib::doDataHooks($dbs, 'updateForumLastPostData');
         $this->DB->update('forums', $dbs, "id=" . intval($forum_data['id']));
     }
     //-----------------------------------------
     // Update forum cache
     //-----------------------------------------
     //$this->registry->getClass('class_forums')->updateForumCache();
     $this->registry->cache()->setCache('stats', $stat_cache, array('array' => 1, 'donow' => 0));
 }
 /**
  * Formats the URL (.htaccess SEO, etc)
  *
  * @access	public
  * @param	string	Raw URL
  * @param	string	Any special SEO title passed
  * @param	string	Any special SEO template to use. If none is passed but SEO is enabled, IPB will search all templates for a match
  * @return	string	Formatted  URL
  */
 public function formatUrl($url, $seoTitle = '', $seoTemplate = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_template = FALSE;
     static $cached = array();
     $_md5 = md5($url . $seoTitle . $seoTemplate);
     if (array_key_exists($_md5, $cached)) {
         //print "Returned cache for: " . $url . "<br />";
         return $cached[$_md5];
     }
     //if ( $this->settings['use_friendly_urls'] AND is_array( $this->seoTemplates ) )
     if ($this->settings['use_friendly_urls'] and $seoTitle) {
         if ($seoTemplate and isset($this->seoTemplates[$seoTemplate])) {
             $_template = $seoTemplate;
         }
         /* Need to search for one - fast? */
         if ($_template === FALSE) {
             /* Search for one, then. Possibly a bit slower than we'd like! */
             foreach ($this->seoTemplates as $key => $data) {
                 if (stristr($url, $key)) {
                     $_template = $key;
                     break;
                 }
             }
         }
         // Switched this off for efficiency
         /* Need to search for one? */
         /*if ( $_template === FALSE )
         		{
         			/ * Search for one, then. Possibly a bit slower than we'd like! * /
         			foreach( $this->seoTemplates as $key => $data )
         			{
         				$regex = str_replace( '#', '\\#', $data['out'][0] );
         				
         				if ( preg_match( "#{$regex}#i", $url ) )
         				{
         					$_template = $key;
         					break;
         				}
         			}
         		}*/
         /* Got one to work with? */
         if ($_template !== FALSE) {
             if (substr($seoTitle, 0, 2) == '%%' and substr($seoTitle, -2) == '%%') {
                 $seoTitle = IPSText::makeSeoTitle(substr($seoTitle, 2, -2));
             }
             /* Do we need to encode? */
             if (IPS_DOC_CHAR_SET != 'UTF-8') {
                 $seoTitle = urlencode($seoTitle);
             }
             $replace = str_replace('#{__title__}', $seoTitle, $this->seoTemplates[$_template]['out'][1]);
             $url = preg_replace($this->seoTemplates[$_template]['out'][0], $replace, $url);
             $_anchor = '';
             $__url = $url;
             /* Protect html entities */
             $url = str_replace('&#', '~|~', $url);
             if (strstr($url, '&')) {
                 $restUrl = substr($url, strpos($url, '&'));
                 $url = substr($url, 0, strpos($url, '&'));
             } else {
                 $restUrl = '';
             }
             /* Anchor */
             if (strstr($restUrl, '#')) {
                 $_anchor = substr($restUrl, strpos($restUrl, '#'));
                 $restUrl = substr($restUrl, 0, strpos($restUrl, '#'));
             }
             switch ($this->settings['url_type']) {
                 case 'path_info':
                     if ($this->settings['htaccess_mod_rewrite']) {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', '', $url);
                     } else {
                         $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '/', $url);
                     }
                     break;
                 default:
                 case 'query_string':
                     $url = str_replace(IPS_PUBLIC_SCRIPT . '?', IPS_PUBLIC_SCRIPT . '?/', $url);
                     break;
             }
             /* Ensure that if the seoTitle is missing there is no double slash */
             # http://localhost/invisionboard3/user/1//
             # http://localhost/invisionboard3/user/1/mattm/
             if (substr($url, -2) == '//') {
                 $url = substr($url, 0, -1);
             }
             /* Others... */
             if ($restUrl) {
                 $_url = str_replace('&amp;', '&', str_replace('?', '', $restUrl));
                 $_data = explode("&", $_url);
                 $_add = array();
                 foreach ($_data as $k) {
                     if (strstr($k, '=')) {
                         list($kk, $vv) = explode('=', $k);
                         if ($kk and $vv) {
                             $_add[] = $kk . $this->seoTemplates['__data__']['varSep'] . $vv;
                         }
                     }
                 }
                 /* Got anything to add?... */
                 if (count($_add)) {
                     if (strrpos($url, $this->seoTemplates['__data__']['end']) + strlen($this->seoTemplates['__data__']['end']) == strlen($url)) {
                         $url = substr($url, 0, -1);
                     }
                     $url .= $this->seoTemplates['__data__']['varBlock'] . implode($this->seoTemplates['__data__']['varSep'], $_add);
                 }
             }
             /* anchor? */
             if ($_anchor) {
                 $url .= $_anchor;
             }
             /* Protect html entities */
             $url = str_replace('~|~', '&#', $url);
             $cached[$_md5] = $url;
             return $url;
         } else {
             $cached[$_md5] = $url;
             return $url;
         }
     } else {
         $cached[$_md5] = $url;
         return $url;
     }
 }
Пример #30
0
 /**
  * Return the SEO title for an announcement
  *
  * @return	@e mixed		The SEO friendly name or boolean false
  */
 public function _fetchSeoTitle_announcement()
 {
     $announce = $this->caches['announcements'][intval($this->_id)];
     if ($announce['announce_id']) {
         return $announce['announce_seo_title'] ? $announce['announce_seo_title'] : IPSText::makeSeoTitle($announce['announce_title']);
     }
     return FALSE;
 }