/**
     * Connection checker
     *
     * @param	string		Raw HTTP headers
     * @param	string		Request result
     * @param	string		Raw HTTPS headers
     * @param	string		Request result
     * @return	string		HTML
     */
    public function connectionCheckerResult($headers = '', $output = '', $headers_ssl = '', $output_ssl = '')
    {
        $IPBHTML = "";
        //--starthtml--//
        $output = IPSText::mbsubstr(htmlspecialchars($output), 0, 2000);
        $output_ssl = IPSText::mbsubstr(htmlspecialchars($output_ssl), 0, 2000);
        $IPBHTML .= <<<EOF

<div class='information-box'>
\t{$this->lang->words['connections__message']}
</div>
<br />
<div class='section_title'>
\t<h2>{$this->lang->words['connectionchecker']}</h2>
</div>

<div class='acp-box'>
\t<h3>{$this->lang->words['connections__headers']}</h3>
\t<pre style='overflow: auto;'>{$headers}</pre>
</div>
<br />
<div class='acp-box'>
\t<h3>{$this->lang->words['connections__output']}</h3>
\t<pre style='overflow: auto;'>{$output}</pre>
</div>
<br />
<div class='acp-box'>
\t<h3>{$this->lang->words['connections__headers1']}</h3>
\t<pre style='overflow: auto;'>{$headers_ssl}</pre>
</div>
<br />
<div class='acp-box'>
\t<h3>{$this->lang->words['connections__output1']}</h3>
\t<pre style='overflow: auto;'>{$output_ssl}</pre>
</div>
EOF;
        //--endhtml--//
        return $IPBHTML;
    }
 /**
  * Edit a member [process]
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _memberDoEdit()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $this->request['member_id'] = intval($this->request['member_id']);
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Load and config the std/rte editors
     //-----------------------------------------
     IPSText::getTextClass('editor')->from_acp = 1;
     //-----------------------------------------
     // Get member
     //-----------------------------------------
     $member = IPSMember::load($this->request['member_id'], 'all');
     //-----------------------------------------
     // Allowed to edit administrators?
     //-----------------------------------------
     if ($member['member_id'] != $this->memberData['member_id'] and $member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin')) {
         $this->registry->output->global_message = $this->lang->words['m_editadmin'];
         $this->_memberView();
         return;
     }
     //-----------------------------------------
     // Allowed to change an admin's groups?
     //-----------------------------------------
     if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin1')) {
         $same = false;
         if ($this->request['member_group_id'] == $member['member_group_id']) {
             $omgroups = explode(',', IPSText::cleanPermString($member['mgroup_others']));
             $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
             if (!count(array_diff($omgroups, $groups))) {
                 $same = true;
             }
         }
         if (!$same) {
             $this->registry->output->global_message = $this->lang->words['m_admindemote'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // What about promoting to admin?
     //-----------------------------------------
     if (!$member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_move_admin2')) {
         $groups = $_POST['mgroup_others'] ? $_POST['mgroup_others'] : array();
         $groups[] = intval($this->request['member_group_id']);
         foreach ($groups as $group_id) {
             if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
                 $this->registry->output->global_message = $this->lang->words['m_adminpromote'];
                 $this->_memberView();
                 return;
             }
         }
     }
     if ($this->request['identity_url']) {
         $account = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'members', 'where' => "identity_url='" . trim($this->request['identity_url']) . "' AND member_id<>" . $member['member_id']));
         if ($account['member_id']) {
             $this->registry->output->global_message = $this->lang->words['identity_url_inuse'];
             $this->_memberView();
             return;
         }
     }
     //-----------------------------------------
     // Convert sig
     //-----------------------------------------
     $signature = IPSText::getTextClass('editor')->processRawPost('signature');
     IPSText::getTextClass('bbcode')->parse_smilies = 0;
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['sig_allow_ibc'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['sig_allow_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
     $signature = IPSText::getTextClass('bbcode')->preDbParse($signature);
     $cacheSignature = IPSText::getTextClass('bbcode')->preDisplayParse($signature);
     //-----------------------------------------
     // And 'About Me'
     //-----------------------------------------
     $aboutme = IPSText::getTextClass('editor')->processRawPost('aboutme');
     IPSText::getTextClass('bbcode')->parse_smilies = $this->settings['aboutme_emoticons'];
     IPSText::getTextClass('bbcode')->parse_bbcode = $this->settings['aboutme_bbcode'];
     IPSText::getTextClass('bbcode')->parse_html = $this->settings['aboutme_html'];
     IPSText::getTextClass('bbcode')->parse_nl2br = 1;
     IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
     $aboutme = IPSText::getTextClass('bbcode')->preDbParse($aboutme);
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     $additionalCore = array();
     $additionalExtended = array();
     IPSLib::loadInterface('admin/member_form.php');
     foreach (ipsRegistry::$applications as $app_dir => $app_data) {
         if (!IPSLib::appIsInstalled($app_dir)) {
             continue;
         }
         if (file_exists(IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php')) {
             require_once IPSLib::getAppDir($app_dir) . '/extensions/admin/member_form.php';
             $_class = 'admin_member_form__' . $app_dir;
             $_object = new $_class($this->registry);
             $remote = $_object->getForSave();
             $additionalCore = array_merge($remote['core'], $additionalCore);
             $additionalExtended = array_merge($remote['extendedProfile'], $additionalExtended);
         }
     }
     //-----------------------------------------
     // Fix custom title
     // @see	http://forums./index.php?app=tracker&showissue=17383
     //-----------------------------------------
     $memberTitle = $this->request['title'];
     $rankCache = ipsRegistry::cache()->getCache('ranks');
     if (is_array($rankCache) && count($rankCache)) {
         foreach ($rankCache as $k => $v) {
             if ($member['posts'] >= $v['POSTS']) {
                 /* If this is the title passed to us from the form, we didn't have a custom title */
                 if ($v['TITLE'] == $memberTitle) {
                     $memberTitle = '';
                 }
                 break;
             }
         }
     }
     $newMember = array('member_group_id' => intval($this->request['member_group_id']), 'title' => $memberTitle, 'time_offset' => floatval($this->request['time_offset']), 'language' => $this->request['language'], 'skin' => intval($this->request['skin']), 'hide_email' => intval($this->request['hide_email']), 'allow_admin_mails' => intval($this->request['allow_admin_mails']), 'view_sigs' => intval($this->request['view_sigs']), 'view_pop' => intval($this->request['view_pop']), 'email_pm' => intval($this->request['email_pm']), 'posts' => intval($this->request['posts']), 'bday_day' => intval($this->request['bday_day']), 'bday_month' => intval($this->request['bday_month']), 'bday_year' => intval($this->request['bday_year']), 'warn_level' => intval($this->request['warn_level']), 'members_disable_pm' => intval($this->request['members_disable_pm']), 'mgroup_others' => $_POST['mgroup_others'] ? ',' . implode(",", $_POST['mgroup_others']) . ',' : '', 'identity_url' => trim($this->request['identity_url']));
     //-----------------------------------------
     // Throw to the DB
     //-----------------------------------------
     IPSMember::save($this->request['member_id'], array('core' => array_merge($newMember, $additionalCore), 'extendedProfile' => array_merge(array('pp_gender' => $this->request['pp_gender'] == 'male' ? 'male' : ($this->request['pp_gender'] == 'female' ? 'female' : ''), 'pp_bio_content' => IPSText::mbsubstr(nl2br($this->request['pp_bio_content']), 0, 300), 'pp_about_me' => $aboutme, 'signature' => $signature, 'pp_reputation_points' => intval($this->request['pp_reputation_points']), 'pp_status' => $this->request['pp_status'], 'pp_setting_count_visitors' => intval($this->request['pp_setting_count_visitors']), 'pp_setting_count_comments' => intval($this->request['pp_setting_count_comments']), 'pp_setting_count_friends' => intval($this->request['pp_setting_count_friends']), 'pp_setting_notify_comments' => $this->request['pp_setting_notify_comments'], 'pp_setting_notify_friend' => $this->request['pp_setting_notify_friend'], 'pp_setting_moderate_comments' => intval($this->request['pp_setting_moderate_comments']), 'pp_setting_moderate_friends' => intval($this->request['pp_setting_moderate_friends'])), $additionalExtended)));
     if ($member['member_group_id'] != $newMember['member_group_id']) {
         IPSLib::runMemberSync('onGroupChange', $this->request['member_id'], $newMember['member_group_id']);
         //-----------------------------------------
         // Remove restrictions if member demoted
         // Commenting out as this may cause more problems than it's worth
         // e.g. if you had accidentally changed their group, you'd need to reconfigure all restrictions
         //-----------------------------------------
         /*if( !$this->caches['group_cache'][ $newMember['member_group_id'] ]['g_access_cp'] )
         		{
         			$this->DB->delete( 'admin_permission_rows', 'row_id=' . $member['member_id'] . " AND row_id_type='member'" );
         		}*/
     }
     //-----------------------------------------
     // Restriction permissions stuff
     //-----------------------------------------
     if (is_array($this->registry->getClass('class_permissions')->restrictions_row) and count($this->registry->getClass('class_permissions')->restrictions_row)) {
         $is_admin = 0;
         $groups = ipsRegistry::cache()->getCache('group_cache');
         if (is_array($this->request['mgroup_others']) and count($this->request['mgroup_others'])) {
             foreach ($this->request['mgroup_others'] as $omg) {
                 if ($groups[intval($omg)]['g_access_cp']) {
                     $is_admin = 1;
                     break;
                 }
             }
         }
         if ($groups[intval($this->request['member_group_id'])]['g_access_cp']) {
             $is_admin = 1;
         }
         if ($is_admin) {
             //-------------------------------------------------
             // Copy restrictions if they do not have any yet...
             //-------------------------------------------------
             $check = $this->DB->buildAndFetch(array('select' => 'row_updated', 'from' => 'admin_permission_rows', 'where' => "row_id_type='member' AND row_id=" . $this->request['member_id']));
             if (!$check['row_updated']) {
                 $this->DB->replace('admin_permission_rows', array('row_id' => $this->request['member_id'], 'row_id_type' => 'member', 'row_perm_cache' => serialize($this->registry->getClass('class_permissions')->restrictions_row), 'row_updated' => time()), array('row_id', 'row_id_type'));
             }
         }
     }
     //-----------------------------------------
     // Moved from validating group?
     //-----------------------------------------
     if ($member['member_group_id'] == $this->settings['auth_group']) {
         if ($this->request['member_group_id'] != $this->settings['auth_group']) {
             //-----------------------------------------
             // Yes...
             //-----------------------------------------
             $this->DB->delete('validating', "member_id=" . $this->request['member_id']);
         }
     }
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->initData('edit');
     $fields->parseToSave($_POST);
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     if (count($fields->out_fields)) {
         //-----------------------------------------
         // Do we already have an entry in
         // the content table?
         //-----------------------------------------
         $test = $this->DB->buildAndFetch(array('select' => 'member_id', 'from' => 'pfields_content', 'where' => 'member_id=' . $this->request['member_id']));
         if ($test['member_id']) {
             //-----------------------------------------
             // We have it, so simply update
             //-----------------------------------------
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $this->DB->update('pfields_content', $fields->out_fields, 'member_id=' . $this->request['member_id']);
         } else {
             $this->DB->force_data_type = array();
             foreach ($fields->out_fields as $_field => $_data) {
                 $this->DB->force_data_type[$_field] = 'string';
             }
             $fields->out_fields['member_id'] = $this->request['member_id'];
             $this->DB->insert('pfields_content', $fields->out_fields);
         }
     }
     /* Update cache */
     IPSContentCache::update($this->request['member_id'], 'sig', $cacheSignature);
     //-----------------------------------------
     // Redirect
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_editedlog'], $member['members_display_name']));
     $this->registry->output->global_message = $this->lang->words['m_edited'];
     $newMember['member_id'] = $this->request['member_id'];
     $newMember['members_display_name'] = $member['members_display_name'];
     $triggerGroups = $member['mgroup_others'] ? implode(',', array_merge(is_array($member['mgroup_others']) ? $member['mgroup_others'] : array(), array($member['member_group_id']))) : $member['member_group_id'];
     //$this->_memberView();
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&do=viewmember&trigger=' . $triggerGroups . '&member_id=' . $this->request['member_id']);
 }
Example #3
0
 /**
  * Clean the topic title
  *
  * @param	string	Raw title
  * @return	string	Cleaned title
  */
 public function cleanTopicTitle($title = "")
 {
     if ($this->settings['etfilter_punct']) {
         $title = preg_replace('/\\?{1,}/', "?", $title);
         $title = preg_replace("/(&#33;){1,}/", "&#33;", $title);
     }
     //-----------------------------------------
     // The DB column is 250 chars, so we need to do true mb_strcut, then fix broken HTML entities
     // This should be fine, as DB would do it regardless (cept we can fix the entities)
     //-----------------------------------------
     $title = preg_replace("/&(#{0,}([a-zA-Z0-9]+?)?)?\$/", '', IPSText::mbsubstr($title, 0, 250));
     $title = IPSText::stripAttachTag($title);
     $title = str_replace("<br />", "", $title);
     $title = trim($title);
     return $title;
 }
 function __f__d6ef75c64bd4fbf9d0af5b37cd8fa121($month = "", $mid = "", $year = "", $events = "", $day_words = "")
 {
     $_ips___x_retval = '';
     foreach ($day_words as $day) {
         $_ips___x_retval .= "\n\t\t\t<th>" . IPSText::mbsubstr($day, 0, 1) . "</th>\n\t\t\n";
     }
     $_ips___x_retval .= '';
     return $_ips___x_retval;
 }
 /**
  * Build the actual output to show
  *
  * @access	protected
  * @param	array		$content	Display text
  * @param	string		$option		URL to link to
  * @return	string					Content to replace bbcode with
  */
 protected function _buildOutput($content, $option)
 {
     // This is problematic if url contains a ' or "
     // $option = str_replace( array( '"', "'", '&#39;', '&quot;' ), '', $option );
     //-----------------------------------------
     // Remove " and ' from beginning + end
     //-----------------------------------------
     if (substr($option, 0, 5) == '&#39;') {
         $option = substr($option, 5);
     } else {
         if (substr($option, 0, 6) == '&quot;') {
             $option = substr($option, 6);
         } else {
             if (substr($option, 0, 1) == "'") {
                 $option = substr($option, 1);
             } else {
                 if (substr($option, 0, 1) == '"') {
                     $option = substr($option, 1);
                 }
             }
         }
     }
     if (substr($option, -5) == '&#39;') {
         $option = substr($option, 0, -5);
     } else {
         if (substr($option, -6) == '&quot;') {
             $option = substr($option, 0, -6);
         } else {
             if (substr($option, -1) == "'") {
                 $option = substr($option, 0, -1);
             } else {
                 if (substr($option, -1) == '"') {
                     $option = substr($option, 0, -1);
                 }
             }
         }
     }
     //-----------------------------------------
     // Some security checking
     //-----------------------------------------
     if (IPSText::xssCheckUrl($option) !== TRUE) {
         return $content;
     }
     /* Check for mangled or embedded URLs */
     if (stristr($option, '[attachment') or stristr($option, '[quote') or stristr($option, '[url') or stristr($option, '[/url') or stristr($content, '[url') or stristr($content, '[/url')) {
         return $content;
     }
     //-----------------------------------------
     // Fix quotes in urls
     //-----------------------------------------
     $option = str_replace(array('&#39;', "'"), '%27', $option);
     $option = str_replace(array('&quot;', '"'), '%22', $option);
     foreach ($this->cache->getCache('bbcode') as $bbcode) {
         $_tags = $this->_retrieveTags();
         foreach ($_tags as $tag) {
             if (strpos($option, '[' . $tag) !== false) {
                 return $content;
             }
         }
     }
     //-----------------------------------------
     // URL filtering?
     //-----------------------------------------
     if ($this->settings['ipb_use_url_filter']) {
         $list_type = $this->settings['ipb_url_filter_option'] == "black" ? "blacklist" : "whitelist";
         if ($this->settings['ipb_url_' . $list_type]) {
             $list_values = array();
             $list_values = explode("\n", str_replace("\r", "", $this->settings['ipb_url_' . $list_type]));
             if ($list_type == "whitelist") {
                 $list_values[] = "http://{$_SERVER['HTTP_HOST']}/*";
             }
             if (count($list_values)) {
                 $good_url = 0;
                 foreach ($list_values as $my_url) {
                     if (!trim($my_url)) {
                         continue;
                     }
                     $my_url = preg_quote($my_url, '/');
                     $my_url = str_replace('\\*', "(.*?)", $my_url);
                     if ($list_type == "blacklist") {
                         if (preg_match('/' . $my_url . '/i', $option)) {
                             $this->warning = 'domain_not_allowed';
                             return $content;
                         }
                     } else {
                         if (preg_match('/' . $my_url . '/i', $option)) {
                             $good_url = 1;
                         }
                     }
                 }
                 if (!$good_url and $list_type == "whitelist") {
                     $this->warning = 'domain_not_allowed';
                     return $content;
                 }
             }
         }
     }
     //-----------------------------------------
     // Let's remove any nested links..
     //-----------------------------------------
     $content = preg_replace('/<a href=\'(.+?)\'(.*?)>(.+?)<\\/a>/is', "\\3", $content);
     //-----------------------------------------
     // Need to "truncate" the "content" to ~35
     // EDIT: but only if it's the same as content
     //-----------------------------------------
     /* Changes here @link http://community.invisionpower.com/tracker/issue-36082-long-links-on-mobile-extend-width/ */
     if (empty($this->settings['__noTruncateUrl']) and IPSText::mbstrlen($content) > 38 and (substr($content, 0, 7) == 'http://' or substr($content, 0, 8) == 'https://')) {
         $content = htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($content)), 0, 20)) . '...' . htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($content)), -15));
     }
     //-----------------------------------------
     // Adding rel='nofollow'?
     //-----------------------------------------
     $rels = array();
     $rel = '';
     $_title = '';
     /* Fetch actual host for better matching */
     $data = @parse_url($option);
     if ($this->settings['posts_add_nofollow']) {
         if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
             $rels[] = "nofollow";
         }
     }
     if ($this->settings['links_external']) {
         if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
             /* Look a little closer */
             $rels[] = "external";
             $_title = $this->lang->words['bbc_external_link'];
         }
     }
     if (count($rels)) {
         $rel = " rel='" . implode(' ', $rels) . "'";
     }
     return "<a href='{$option}' class='bbc_url' title='{$_title}'{$rel}>{$content}</a>";
 }
 /**
  * Load member
  *
  * @param 	string	Member key: Either ID or email address OR array of IDs when $key_type is either ID or not set OR a list of $key_type strings (email address, name, etc)
  * @param 	string	Extra tables to load(all, none or comma delisted tables) Tables: members, pfields_content, profile_portal, groups, sessions, core_item_markers_storage, members_partial.
  *					You can also use the aliases: 'extendedProfile', 'customFields' and 'itemMarkingStorage'
  * @param	string  Key type. Leave it blank to auto-detect or specify "id", "email", "username", "displayname".
  * @return	array   Array containing member data
  * <code>
  * # Single member
  * $member = IPSMember::load( 1, 'extendedProfile,groups' );
  * $member = IPSMember::load( '*****@*****.**', 'all' );
  * $member = IPSMember::load( 'MattM', 'all', 'displayname' ); // Can also use 'username', 'email' or 'id'
  * # Multiple members
  * $members = IPSMember::load( array( 1, 2, 10 ), 'all' );
  * $members = IPSMember::load( array( 'MattM, 'JoeD', 'DaveP' ), 'all', 'displayname' );
  * </code>
  */
 public static function load($member_key, $extra_tables = 'all', $key_type = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_value = 0;
     $members = array();
     $multiple_ids = array();
     $member_field = '';
     $joins = array();
     $tables = array('pfields_content' => 0, 'profile_portal' => 0, 'groups' => 0, 'sessions' => 0, 'members_partial' => 0);
     $remap = array('extendedProfile' => 'profile_portal', 'customFields' => 'pfields_content');
     //-----------------------------------------
     // ID or email?
     //-----------------------------------------
     if (!$key_type) {
         if (is_array($member_key)) {
             $multiple_ids = array_map('intval', $member_key);
             // Bug #20908
             $member_field = 'member_id';
         } else {
             if (strstr($member_key, '@')) {
                 if (strstr($member_key, ' ')) {
                     $member_key = '';
                 }
                 $member_key = IPSText::mbsubstr($member_key, 0, 150);
                 $member_value = "'" . ipsRegistry::DB()->addSlashes(strtolower($member_key)) . "'";
                 $member_field = 'email';
             } else {
                 $member_value = intval($member_key);
                 $member_field = 'member_id';
             }
         }
     } else {
         switch ($key_type) {
             default:
             case 'id':
                 if (is_array($member_key)) {
                     $multiple_ids = $member_key;
                 } else {
                     $member_value = intval($member_key);
                 }
                 $member_field = 'member_id';
                 break;
             case 'fb_uid':
                 if (is_array($member_key)) {
                     $multiple_ids = $member_key;
                 } else {
                     $member_value = is_numeric($member_key) ? $member_key : 0;
                 }
                 $member_field = 'fb_uid';
                 if ($member_value == 0) {
                     return array();
                 }
                 break;
             case 'twitter_id':
                 if (is_array($member_key)) {
                     $multiple_ids = $member_key;
                 } else {
                     $member_value = is_numeric($member_key) ? $member_key : 0;
                 }
                 $member_field = 'twitter_id';
                 if ($member_value == 0) {
                     return array();
                 }
                 break;
             case 'email':
                 if (is_array($member_key)) {
                     array_walk($member_key, create_function('&$v,$k', '$v="\'".( ( strstr( $v, \' \' ) ) ? \'\' : ipsRegistry::DB()->addSlashes( IPSText::mbsubstr( strtolower( $v ), 0, 150 ) ) ) . "\'";'));
                     $multiple_ids = $member_key;
                 } else {
                     if (strstr($member_key, ' ')) {
                         $member_key = '';
                     }
                     $member_key = IPSText::mbsubstr($member_key, 0, 150);
                     $member_value = "'" . ipsRegistry::DB()->addSlashes(strtolower($member_key)) . "'";
                 }
                 $member_field = 'email';
                 break;
             case 'username':
                 if (is_array($member_key)) {
                     array_walk($member_key, create_function('&$v,$k', '$v="\'".ipsRegistry::DB()->addSlashes( IPSText::mbsubstr( strtolower( $v ), 0, 255 ) ) . "\'";'));
                     $multiple_ids = $member_key;
                 } else {
                     $member_key = IPSText::mbsubstr($member_key, 0, 255);
                     $member_value = "'" . ipsRegistry::DB()->addSlashes(strtolower($member_key)) . "'";
                 }
                 $member_field = 'members_l_username';
                 break;
             case 'displayname':
                 if (is_array($member_key)) {
                     array_walk($member_key, create_function('&$v,$k', '$v="\'".ipsRegistry::DB()->addSlashes( IPSText::mbsubstr( strtolower( $v ), 0, 255 ) ) . "\'";'));
                     $multiple_ids = $member_key;
                 } else {
                     $member_key = IPSText::mbsubstr($member_key, 0, 255);
                     $member_value = "'" . ipsRegistry::DB()->addSlashes(strtolower($member_key)) . "'";
                 }
                 $member_field = 'members_l_display_name';
                 break;
             case 'ipsconnect':
                 if (is_array($member_key)) {
                     $multiple_ids = $member_key;
                 } else {
                     $member_value = intval($member_key);
                 }
                 $member_field = 'ipsconnect_id';
                 break;
         }
     }
     //-----------------------------------------
     // Protected against member_id=0
     //-----------------------------------------
     if (!count($multiple_ids) or !is_array($multiple_ids)) {
         if ($member_field == 'member_id' and !$member_value) {
             return array();
         }
     }
     //-----------------------------------------
     // Sort out joins...
     //-----------------------------------------
     if ($extra_tables == 'all') {
         foreach ($tables as $_table => $_val) {
             /* Let's not load sessions or members_partial unless specifically requested */
             if ($_table == 'sessions' or $_table == 'members_partial') {
                 continue;
             }
             $tables[$_table] = 1;
         }
     } else {
         if ($extra_tables) {
             $_tables = explode(",", $extra_tables);
             foreach ($_tables as $_t) {
                 $_t = trim($_t);
                 if (isset($tables[$_t])) {
                     $tables[$_t] = 1;
                 } else {
                     if (isset(self::$remap[$_t])) {
                         if (strstr($tables[self::$remap[$_t]], ',')) {
                             $__tables = explode(',', $tables[self::$remap[$_t]]);
                             foreach ($__tables as $__t) {
                                 $tables[$__t] = 1;
                             }
                         } else {
                             $tables[self::$remap[$_t]] = 1;
                         }
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Grab used tables
     //-----------------------------------------
     $_usedTables = array();
     foreach ($tables as $_name => $_use) {
         if ($_use) {
             $_usedTables[] = $_name;
         }
     }
     //-----------------------------------------
     // Check the cache first...
     //-----------------------------------------
     if ($member_field == 'member_id' and $member_value) {
         $member = self::_fetchFromCache($member_value, $_usedTables);
         if ($member !== FALSE) {
             return $member;
         }
     } else {
         if (count($multiple_ids) and is_array($multiple_ids)) {
             $_totalUsers = count($multiple_ids);
             $_gotFromCache = 0;
             $_fromCache = array();
             foreach ($multiple_ids as $_memberValue) {
                 $member = self::_fetchFromCache($_memberValue, $_usedTables);
                 if ($member !== FALSE) {
                     $_fromCache[$member['member_id']] = $member;
                     $_gotFromCache++;
                 }
             }
             //-----------------------------------------
             // Did we find all the members in cache?
             //-----------------------------------------
             if ($_gotFromCache == $_totalUsers) {
                 return $_fromCache;
             }
         }
     }
     self::$ignoreCache = FALSE;
     //-----------------------------------------
     // Fix up joins...
     //-----------------------------------------
     if ($tables['pfields_content']) {
         $joins[] = array('select' => 'p.*', 'from' => array('pfields_content' => 'p'), 'where' => 'p.member_id=m.member_id', 'type' => 'left');
     }
     if ($tables['profile_portal']) {
         $joins[] = array('select' => 'pp.*', 'from' => array('profile_portal' => 'pp'), 'where' => 'pp.pp_member_id=m.member_id', 'type' => 'left');
     }
     if ($tables['groups']) {
         $joins[] = array('select' => 'g.*', 'from' => array('groups' => 'g'), 'where' => 'g.g_id=m.member_group_id', 'type' => 'left');
     }
     if ($tables['sessions']) {
         $joins[] = array('select' => 's.*', 'from' => array('sessions' => 's'), 'where' => 's.member_id=m.member_id', 'type' => 'left');
     }
     if ($tables['core_item_markers_storage']) {
         $joins[] = array('select' => 'im.*', 'from' => array('core_item_markers_storage' => 'im'), 'where' => 'im.item_member_id=m.member_id', 'type' => 'left');
     }
     if ($tables['members_partial']) {
         $joins[] = array('select' => 'mp.*', 'from' => array('members_partial' => 'mp'), 'where' => 'mp.partial_member_id=m.member_id', 'type' => 'left');
     }
     if (IPSContentCache::isEnabled()) {
         if (IPSContentCache::fetchSettingValue('sig')) {
             $joins[] = IPSContentCache::join('sig', 'm.member_id', 'ccb', 'left', 'ccb.cache_content');
         }
     }
     //-----------------------------------------
     // Do eeet
     //-----------------------------------------
     if (count($joins)) {
         ipsRegistry::DB()->build(array('select' => 'm.*, m.member_id as my_member_id', 'from' => array('members' => 'm'), 'where' => (is_array($multiple_ids) and count($multiple_ids)) ? 'm.' . $member_field . ' IN (' . implode(',', $multiple_ids) . ')' : 'm.' . $member_field . '=' . $member_value, 'add_join' => $joins));
     } else {
         ipsRegistry::DB()->build(array('select' => '*', 'from' => 'members', 'where' => (is_array($multiple_ids) and count($multiple_ids)) ? $member_field . ' IN (' . implode(',', $multiple_ids) . ')' : $member_field . '=' . $member_value));
     }
     //-----------------------------------------
     // Execute
     //-----------------------------------------
     ipsRegistry::DB()->execute();
     while ($mem = ipsRegistry::DB()->fetch()) {
         if (isset($mem['my_member_id'])) {
             $mem['member_id'] = $mem['my_member_id'];
         }
         $mem['full'] = true;
         if (!$mem['email'] or !$mem['members_display_name'] or $mem['email'] == $mem['name'] . '@' . $mem['joined']) {
             $mem['full'] = false;
             $mem['timenow'] = $mem['joined'];
         }
         /* Clean secondary groups */
         $mem['mgroup_others'] = $mem['mgroup_others'] != '' ? IPSText::cleanPermString($mem['mgroup_others']) : '';
         //-----------------------------------------
         // Be sure we properly apply secondary permissions
         //-----------------------------------------
         if ($tables['groups']) {
             $mem = ips_MemberRegistry::setUpSecondaryGroups($mem);
             /* Unpack groups */
             $mem = IPSMember::unpackGroup($mem, TRUE, TRUE);
         }
         //-----------------------------------------
         // Unblockable
         //-----------------------------------------
         $mem['_canBeIgnored'] = self::isIgnorable($mem['member_group_id'], $mem['mgroup_others']);
         /* Bitwise Options */
         $mem = self::buildBitWiseOptions($mem);
         /* Twitter is disabled them remove twitter tokens and such */
         if ($mem['twitter_id'] && !IPSLib::twitter_enabled()) {
             $mem['twitter_token'] = '';
             $mem['twitter_secret'] = '';
             $mem['twitter_id'] = '';
         }
         /* Add to array */
         $members[$mem['member_id']] = $mem;
         //-----------------------------------------
         // Add to cache
         //-----------------------------------------
         self::_addToCache($mem, $_usedTables);
     }
     //-----------------------------------------
     // Return just a single if we only sent one id
     //-----------------------------------------
     return (is_array($multiple_ids) and count($multiple_ids)) ? $members : array_shift($members);
 }
Example #7
0
 function __f__dbe8275c142422a1dbf962583d35a571($data)
 {
     $_ips___x_retval = '';
     $__iteratorCount = 0;
     foreach ($data['day_words'] as $day) {
         $__iteratorCount++;
         $_ips___x_retval .= "\n\t\t\t\t<th>" . IPSText::mbsubstr($day, 0, 1) . "</th>\n\t\t\t\n";
     }
     $_ips___x_retval .= '';
     unset($__iteratorCount);
     return $_ips___x_retval;
 }
Example #8
0
 /**
  * Post a status update to Facebook based on native content
  * Which may be longer and such and so on and so forth, etc
  *
  * @access	public
  * @param	string		Content
  * @param	string		URL to add
  * @param	bool		Always add the URL regardless of content length
  */
 public function updateStatusWithUrl($content, $url, $alwaysAdd = false)
 {
     $memberData = $this->memberData;
     /* Got a member? */
     if (!$memberData['member_id']) {
         throw new Exception('NO_MEMBER');
     }
     /* Linked account? */
     if (!$memberData['fb_uid']) {
         throw new Exception('NOT_LINKED');
     }
     /* Ensure content is correctly de-html-ized */
     $content = IPSText::UNhtmlspecialchars($content);
     /* Ensure it's converted cleanly into utf-8 */
     $content = html_entity_decode($content, ENT_QUOTES, 'UTF-8');
     /* Is the text longer than 140 chars? */
     if ($alwaysAdd === TRUE or IPSText::mbstrlen($content) > 500) {
         /* Leave 26 chars for URL shortener */
         $content = IPSText::mbsubstr($content, 0, 474) . '...';
         if (IPSText::mbstrlen($url) > 26) {
             /* Generate short URL */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/url/shorten.php', 'urlShorten');
             $shorten = new $classToLoad();
             try {
                 $data = $shorten->shorten($url, IPS_URL_SHORTEN_SERVICE);
                 $url = $data['url'];
             } catch (Exception $ex) {
                 /* Stop the exception bubbling back to parent classes */
             }
         }
         $content .= ' ' . $url;
     }
     /* POST the data */
     try {
         $this->_api->api(array('method' => 'users.setStatus', 'access_token' => $this->_userToken, 'uid' => $this->_userId, 'status' => $content, 'status_includes_verb' => true));
     } catch (Exception $e) {
         $this->registry->output->logErrorMessage($e->getMessage(), 'FB-EXCEPTION');
     }
 }
Example #9
0
 /**
  * Post a status update to twitter based on native content
  * Which may be longer and such and so on and so forth, etc
  *
  * @access	public
  * @param	string		Content
  * @param	string		URL to add
  * @param	bool		Always add the URL regardless of content length
  * @param	bool		Add a hashtag
  */
 public function updateStatusWithUrl($content, $url, $alwaysAdd = TRUE, $hashtag = '')
 {
     if (is_string($hashtag) && !empty($hashtag)) {
         if (substr($hashtag, 0, 1) != '#') {
             $hashtag = '#' . $hashtag;
         }
         $hashtag = ' ' . $hashtag;
     } else {
         if (!is_string($hashtag)) {
             $hashtag = '';
         }
     }
     /* Ensure content is correctly de-html-ized */
     $content = IPSText::UNhtmlspecialchars($content);
     /* Is the text longer than 140 chars? */
     if ($alwaysAdd === TRUE or IPSText::mbstrlen($content) > 140) {
         /* Leave 26 chars for URL shortener */
         $less = 26 + strlen($hashtag);
         if (IPSText::mbstrlen($content) > 140 - $less) {
             $content = IPSText::mbsubstr($content, 0, 140 - ($less + 3)) . '...' . $hashtag;
         }
         if (IPSText::mbstrlen($url) > 26) {
             /* Generate short URL */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/url/shorten.php', 'urlShorten');
             $shorten = new $classToLoad();
             try {
                 $data = $shorten->shorten($url, IPS_URL_SHORTEN_SERVICE);
                 $url = $data['url'];
             } catch (Exception $ex) {
                 /* Stop the exception bubbling back to parent classes */
             }
         }
         return $this->updateStatus($content . ' ' . $url);
     } else {
         /* Just post it */
         return $this->updateStatus($content);
     }
 }
Example #10
0
 function __f__80b8170fedb0bf6e656e59f768de6697($data)
 {
     $_ips___x_retval = '';
     $__iteratorCount = 0;
     foreach ($data['day_words'] as $day) {
         $__iteratorCount++;
         $_ips___x_retval .= "\n\t\t\t\t\t<th>" . IPSText::mbsubstr($day, 0, 1) . "</th>\n\t\t\t\t\n";
     }
     $_ips___x_retval .= '';
     unset($__iteratorCount);
     return $_ips___x_retval;
 }
 /**
  * UserCP Save Form: Profile Info
  *
  * @access	public
  * @return	array	Errors
  */
 public function saveProfileInfo()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $pp_setting_notify_comments = trim(substr($this->request['pp_setting_notify_comments'], 0, 10));
     $pp_setting_notify_friend = trim(substr($this->request['pp_setting_notify_friend'], 0, 10));
     $pp_setting_moderate_comments = intval($this->request['pp_setting_moderate_comments']);
     $pp_setting_moderate_friends = intval($this->request['pp_setting_moderate_friends']);
     $pp_setting_count_visitors = intval($this->request['pp_setting_count_visitors']);
     $pp_setting_count_comments = intval($this->request['pp_setting_count_comments']);
     $pp_setting_count_friends = intval($this->request['pp_setting_count_friends']);
     $_gender = $this->request['gender'] == 'male' ? 'male' : ($this->request['gender'] == 'female' ? 'female' : '');
     //-----------------------------------------
     // Check to make sure that we can edit profiles..
     //-----------------------------------------
     if (!$this->memberData['g_edit_profile']) {
         $this->registry->getClass('output')->showError('members_profile_disabled', 10214);
     }
     //-----------------------------------------
     // make sure that either we entered
     // all calendar fields, or we left them
     // all blank
     //-----------------------------------------
     $c_cnt = 0;
     foreach (array('day', 'month', 'year') as $v) {
         if ($this->request[$v]) {
             $c_cnt++;
         }
     }
     if ($c_cnt > 0 && $c_cnt < 2) {
         $this->registry->getClass('output')->showError('member_bad_birthday', 10215);
     } else {
         if ($c_cnt > 0) {
             //-----------------------------------------
             // Make sure it's a legal date
             //-----------------------------------------
             $_year = $this->request['year'] ? $this->request['year'] : 1999;
             if (!checkdate($this->request['month'], $this->request['day'], $_year)) {
                 $this->registry->getClass('output')->showError('member_bad_birthday', 10216);
             }
         }
     }
     if ($this->memberData['g_edit_profile']) {
         $pp_bio_content = IPSText::mbsubstr(nl2br($this->request['pp_bio_content']), 0, 300);
     }
     if (!$this->memberData['g_edit_profile']) {
         $pp_bio_content = $this->memberData['pp_bio_content'];
     }
     //-----------------------------------------
     // Start off our array
     //-----------------------------------------
     $core = array('bday_day' => $this->request['day'], 'bday_month' => $this->request['month'], 'bday_year' => $this->request['year']);
     $extendedProfile = array('pp_bio_content' => IPSText::getTextClass('bbcode')->stripBadWords($pp_bio_content), 'pp_setting_notify_comments' => $pp_setting_notify_comments, 'pp_setting_notify_friend' => $pp_setting_notify_friend, 'pp_setting_moderate_comments' => $pp_setting_moderate_comments, 'pp_setting_moderate_friends' => $pp_setting_moderate_friends, 'pp_setting_count_visitors' => $pp_setting_count_visitors, 'pp_setting_count_comments' => $pp_setting_count_comments, 'pp_setting_count_friends' => $pp_setting_count_friends);
     //-----------------------------------------
     // check to see if we can enter a member title
     // and if one is entered, update it.
     //-----------------------------------------
     if (isset($this->request['member_title']) and $this->settings['post_titlechange'] and $this->memberData['posts'] >= $this->settings['post_titlechange']) {
         $core['title'] = IPSText::getTextClass('bbcode')->stripBadWords($this->request['member_title']);
     }
     //-----------------------------------------
     // Custom profile field stuff
     //-----------------------------------------
     require_once IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php';
     $fields = new customProfileFields();
     $fields->member_data = $this->member->fetchMemberData();
     $fields->initData('edit');
     /* Use $_POST and not ipsRegistry::$request as the custom profile field kernel class has its own cleaning routines for saving and showing
        which means we end up with double & -> &amp; conversion (&amp;lt;, etc) */
     $fields->parseToSave($_POST);
     if ($fields->error_messages) {
         return $fields->error_messages;
     }
     /* Check the website url field */
     $website_field = $fields->getFieldIDByKey('website');
     if ($website_field && $fields->out_fields['field_' . $website_field]) {
         if (!stristr($fields->out_fields['field_' . $website_field], 'http://')) {
             $fields->out_fields['field_' . $website_field] = 'http://' . $fields->out_fields['field_' . $website_field];
         }
     }
     //-----------------------------------------
     // Check...
     //-----------------------------------------
     if (count($fields->error_fields['empty'])) {
         $this->registry->getClass('output')->showError(array('customfields_empty', $fields->error_fields['empty'][0]['pf_title']), 10217);
     }
     if (count($fields->error_fields['invalid'])) {
         $this->registry->getClass('output')->showError(array('customfields_invalid', $fields->error_fields['invalid'][0]['pf_title']), 10218);
     }
     if (count($fields->error_fields['toobig'])) {
         $this->registry->getClass('output')->showError(array('customfields_toobig', $fields->error_fields['toobig'][0]['pf_title']), 10219);
     }
     //-----------------------------------------
     // Update the DB
     //-----------------------------------------
     IPSMember::save($this->memberData['member_id'], array('core' => $core, 'customFields' => $fields->out_fields, 'extendedProfile' => $extendedProfile));
     return TRUE;
 }
 function __f__376ad1e62926b98d829f55e6871bf3ab($month = "", $mid = "", $year = "", $events = "", $day_words = "")
 {
     $_ips___x_retval = '';
     foreach ($day_words as $day) {
         $_ips___x_retval .= "\n\t\t<th>" . IPSText::mbsubstr($day, 0, 1) . "</th>\n\t\n";
     }
     $_ips___x_retval .= '';
     return $_ips___x_retval;
 }
Example #13
0
 /**
  * Post a status update to vk wall based on native content
  * Which may be longer and such and so on and so forth, etc
  *
  * @access	public
  * @param	string		Content
  * @param	string		URL to add
  * @param	bool		Always add the URL regardless of content length
  */
 public function updateStatusWithUrl($content, $url, $alwaysAdd = TRUE)
 {
     /* Ensure content is correctly de-html-ized */
     $content = IPSText::UNhtmlspecialchars($content);
     /* Is the text longer than 140 chars? */
     if ($alwaysAdd === TRUE or IPSText::mbstrlen($content) > 140) {
         /* Leave 26 chars for URL shortener */
         if (IPSText::mbstrlen($content) > 117) {
             $content = IPSText::mbsubstr($content, 0, 114) . '...';
         }
         /* Generate short URL */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/url/shorten.php', 'urlShorten');
         $shorten = new $classToLoad();
         $data = $shorten->shorten($url, IPS_URL_SHORTEN_SERVICE);
         return $this->updateStatus($content . ' ' . $data['url']);
     } else {
         /* Just post it */
         return $this->updateStatus($content);
     }
 }
 /**
  * Rebuild the RSS Stream cache
  *
  * @access	public
  * @param	mixed	$rss_import_id	ID of the stream to import
  * @param	bool	$return			Set to true to return true/false
  * @param	bool	$id_is_array	Set to true if the first paramter is an array of ids
  * @return	mixed
  **/
 public function rssImportRebuildCache($rss_import_id, $return = true, $id_is_array = false)
 {
     /* INIT */
     $errors = array();
     $affected_forum_ids = array();
     $affected_members = array();
     $rss_error = array();
     $rss_import_ids = array();
     $items_imported = 0;
     /* Check the ID */
     if (!$rss_import_id) {
         $rss_import_id = $this->request['rss_import_id'] == 'all' ? 'all' : intval($this->request['rss_import_id']);
     }
     /* No ID Found */
     if (!$rss_import_id) {
         $this->registry->output->global_message = $this->lang->words['im_noid'];
         $this->rssImportOverview();
         return;
     }
     /* Create an array of ids */
     if ($id_is_array == 1) {
         $rss_import_ids = explode(",", $rss_import_id);
     }
     /* Load the classes we need */
     if (!$this->classes_loaded) {
         /* Get the RSS Class */
         if (!is_object($this->class_rss)) {
             require_once IPS_KERNEL_PATH . 'classRss.php';
             $this->class_rss = new classRss();
             $this->class_rss->use_sockets = $this->use_sockets;
             $this->class_rss->rss_max_show = 100;
         }
         /* Get the post class */
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         $this->post = new classPost($this->registry);
         /* Load the mod libarry */
         if (!$this->func_mod) {
             require_once IPSLib::getAppDir('forums') . '/sources/classes/moderate.php';
             $this->func_mod = new moderatorLibrary($this->registry);
         }
         $this->classes_loaded = 1;
     }
     /* INIT Forums */
     if (!is_array($this->registry->class_forums->forum_by_id) or !count($this->registry->class_forums->forum_by_id)) {
         $this->registry->class_forums->forumsInit();
     }
     /* Query the RSS imports */
     $this->DB->build(array('select' => '*', 'from' => 'rss_import'));
     $outer = $this->DB->execute();
     /* Loop through and build cache */
     while ($row = $this->DB->fetch($outer)) {
         /* Are we caching this one? */
         if ($rss_import_id == 'all' or $row['rss_import_id'] == $rss_import_id or $id_is_array == 1 and in_array($row['rss_import_id'], $rss_import_ids)) {
             /* Skip non-existent forums - bad stuff happens	*/
             if (!isset($this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']])) {
                 continue;
             }
             /* Allowing badwords? */
             IPSText::getTextClass('bbcode')->bypass_badwords = $row['rss_import_allow_html'];
             /* Set this import's doctype */
             $this->class_rss->doc_type = IPS_DOC_CHAR_SET;
             $this->class_rss->feed_charset = $row['rss_import_charset'];
             if (strtolower($row['rss_import_charset']) != IPS_DOC_CHAR_SET) {
                 $this->class_rss->convert_charset = 1;
             } else {
                 $this->class_rss->convert_charset = 0;
             }
             /* Set this import's authentication */
             $this->class_rss->auth_req = $row['rss_import_auth'];
             $this->class_rss->auth_user = $row['rss_import_auth_user'];
             $this->class_rss->auth_pass = $row['rss_import_auth_pass'];
             /* Clear RSS object's error cache first */
             $this->class_rss->errors = array();
             $this->class_rss->rss_items = array();
             /* Reset the rss count as this is a new feed */
             $this->class_rss->rss_count = 0;
             $this->class_rss->rss_max_show = $row['rss_import_pergo'];
             /* Parse RSS */
             $this->class_rss->parseFeedFromUrl($row['rss_import_url']);
             /* Check for errors */
             if (is_array($this->class_rss->errors) and count($this->class_rss->errors)) {
                 $rss_error = array_merge($rss_error, $this->class_rss->errors);
                 continue;
             }
             if (!is_array($this->class_rss->rss_channels) or !count($this->class_rss->rss_channels)) {
                 $rss_error[] = sprintf($this->lang->words['im_noopen'], $row['rss_import_url']);
                 continue;
             }
             /* Update last check time */
             $this->DB->update('rss_import', array('rss_import_last_import' => time()), 'rss_import_id=' . $row['rss_import_id']);
             /* Apparently so: Parse feeds and check for already imported GUIDs */
             $final_items = array();
             $items = array();
             $check_guids = array();
             $final_guids = array();
             $count = 0;
             if (!is_array($this->class_rss->rss_items) or !count($this->class_rss->rss_items)) {
                 $rss_error[] = $row['rss_import_url'] . $this->lang->words['im_noimport'];
                 continue;
             }
             /* Loop through the channels */
             foreach ($this->class_rss->rss_channels as $channel_id => $channel_data) {
                 if (is_array($this->class_rss->rss_items[$channel_id]) and count($this->class_rss->rss_items[$channel_id])) {
                     /* Loop through the items in this channel */
                     foreach ($this->class_rss->rss_items[$channel_id] as $item_data) {
                         /* Item Data */
                         $item_data['content'] = $item_data['content'] ? $item_data['content'] : $item_data['description'];
                         $item_data['guid'] = md5($row['rss_import_id'] . ($item_data['guid'] ? $item_data['guid'] : preg_replace("#\\s|\r|\n#is", "", $item_data['title'] . $item_data['link'] . $item_data['description'])));
                         $item_data['unixdate'] = intval($item_data['unixdate']) ? intval($item_data['unixdate']) : time();
                         /*  Convert char set? */
                         if ($row['rss_import_charset'] and strtolower(IPS_DOC_CHAR_SET) != strtolower($row['rss_import_charset'])) {
                             $item_data['title'] = IPSText::convertCharsets($item_data['title'], $row['rss_import_charset'], IPS_DOC_CHAR_SET);
                             $item_data['content'] = IPSText::convertCharsets($item_data['content'], $row['rss_import_charset'], IPS_DOC_CHAR_SET);
                         }
                         /* Dates */
                         if ($item_data['unixdate'] < 1) {
                             $item_data['unixdate'] = time();
                         } else {
                             if ($item_data['unixdate'] > time()) {
                                 $item_data['unixdate'] = time();
                             }
                         }
                         /* Error check */
                         if (!$item_data['title'] or !$item_data['content']) {
                             $rss_error[] = sprintf($this->lang->words['im_notitle'], $item_data['title']);
                             continue;
                         }
                         /* Add to array */
                         $items[$item_data['guid']] = $item_data;
                         $check_guids[] = $item_data['guid'];
                     }
                 }
             }
             /* Check GUIDs */
             if (!count($check_guids)) {
                 $rss_error[] = $this->lang->words['im_noitems'];
                 continue;
             }
             $this->DB->build(array('select' => '*', 'from' => 'rss_imported', 'where' => "rss_imported_guid IN ('" . implode("','", $check_guids) . "')"));
             $this->DB->execute();
             while ($guid = $this->DB->fetch()) {
                 $final_guids[$guid['rss_imported_guid']] = $guid['rss_imported_guid'];
             }
             /* Compare GUIDs */
             $item_count = 0;
             foreach ($items as $guid => $data) {
                 if (in_array($guid, $final_guids)) {
                     continue;
                 } else {
                     $item_count++;
                     /* Make sure each item has a unique date */
                     $final_items[$data['unixdate'] . $item_count] = $data;
                 }
             }
             /* Sort Array */
             krsort($final_items);
             /* Pick off last X */
             $count = 1;
             $tmp_final_items = $final_items;
             $final_items = array();
             foreach ($tmp_final_items as $date => $data) {
                 $final_items[$date] = $data;
                 if ($count >= $row['rss_import_pergo']) {
                     break;
                 }
                 $count++;
             }
             /* Anything left? */
             if (!count($final_items)) {
                 continue;
             }
             /* Figure out MID */
             $member = $this->DB->buildAndFetch(array('select' => 'member_id, name, members_display_name, ip_address', 'from' => 'members', 'where' => "member_id={$row['rss_import_mid']}"));
             if (!$member['member_id']) {
                 continue;
             }
             /* Set member in post class */
             $this->post->setAuthor($member['member_id']);
             $this->post->setForumData($this->registry->getClass('class_forums')->forum_by_id[$row['rss_import_forum_id']]);
             /* Make 'dem posts */
             $affected_forum_ids[] = $row['rss_import_forum_id'];
             foreach ($final_items as $topic_item) {
                 /* Fix &amp; */
                 $topic_item['title'] = str_replace('&amp;', '&', $topic_item['title']);
                 $topic_item['title'] = trim(IPSText::br2nl($topic_item['title']));
                 $topic_item['title'] = strip_tags($topic_item['title']);
                 $topic_item['title'] = IPSText::parseCleanValue($topic_item['title']);
                 /* Fix up &amp;reg; */
                 $topic_item['title'] = str_replace('&amp;reg;', '&reg;', $topic_item['title']);
                 if ($row['rss_import_topic_pre']) {
                     $topic_item['title'] = str_replace('&nbsp;', ' ', str_replace('&amp;nbsp;', '&nbsp;', $row['rss_import_topic_pre'])) . ' ' . $topic_item['title'];
                 }
                 /* Build topic insert array */
                 $topic = array('title' => IPSText::mbsubstr($topic_item['title'], 0, 250), 'title_seo' => IPSText::makeSeoTitle(IPSText::mbsubstr($topic_item['title'], 0, 250)), 'description' => '', 'state' => $row['rss_import_topic_open'] ? 'open' : 'closed', 'posts' => 0, 'starter_id' => $member['member_id'], 'starter_name' => $member['members_display_name'], 'start_date' => $topic_item['unixdate'], 'last_poster_id' => $member['member_id'], 'last_poster_name' => $member['members_display_name'], 'last_post' => $topic_item['unixdate'], 'icon_id' => 0, 'author_mode' => 1, 'poll_state' => 0, 'last_vote' => 0, 'views' => 0, 'forum_id' => $row['rss_import_forum_id'], 'approved' => $row['rss_import_topic_hide'] ? 0 : 1, 'pinned' => 0);
                 /* More post class stuff */
                 $this->post->setPublished($row['rss_import_topic_hide'] ? FALSE : TRUE);
                 /* Sort post content: Convert HTML to BBCode */
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_html = intval($row['rss_import_allow_html']);
                 IPSText::getTextClass('bbcode')->parse_bbcode = 1;
                 IPSText::getTextClass('bbcode')->parsing_section = 'topics';
                 $this->memberData['_canUseRTE'] = true;
                 $_POST['ed-0_wysiwyg_used'] = 1;
                 IPSText::getTextClass('editor')->method = 'rte';
                 /* Clean up.. */
                 $topic_item['content'] = preg_replace("#<br />(\r)?\n#is", "<br />", $topic_item['content']);
                 /* Add in Show link... */
                 if ($row['rss_import_showlink'] and $topic_item['link']) {
                     $the_link = str_replace('{url}', trim($topic_item['link']), $row['rss_import_showlink']);
                     if ($row['rss_import_allow_html']) {
                         $_POST['_tmpPostField'] = IPSText::getTextClass('bbcode')->preEditParse(stripslashes($the_link));
                         $the_link = "<br /><br />" . IPSText::getTextClass('bbcode')->preDbParse(IPSText::getTextClass('editor')->processRawPost('_tmpPostField'));
                     } else {
                         $the_link = "<br /><br />" . $the_link;
                     }
                     $topic_item['content'] .= $the_link;
                 }
                 if (!$row['rss_import_allow_html']) {
                     $_POST['_tmpPostField'] = stripslashes($topic_item['content']);
                     //IPSText::getTextClass( 'bbcode' )->preEditParse( stripslashes($topic_item['content']) );
                     $post_content = IPSText::getTextClass('bbcode')->preDbParse(IPSText::getTextClass('editor')->processRawPost('_tmpPostField'));
                 } else {
                     $post_content = stripslashes($topic_item['content']);
                 }
                 /* Build Post insert array */
                 $post = array('author_id' => $member['member_id'], 'use_sig' => 1, 'use_emo' => 1, 'ip_address' => $member['ip_address'], 'post_date' => $topic_item['unixdate'], 'icon_id' => 0, 'post' => $post_content, 'author_name' => $member['members_display_name'], 'topic_id' => "", 'queued' => 0, 'post_htmlstate' => 0);
                 /* Insert the topic into the database to get the last inserted value of the auto_increment field follow suit with the post */
                 $this->DB->insert('topics', $topic);
                 $post['topic_id'] = $this->DB->getInsertId();
                 $topic['tid'] = $post['topic_id'];
                 /* Update the post info with the upload array info */
                 $post['post_key'] = md5(uniqid(microtime()));
                 $post['new_topic'] = 1;
                 /* Add post to DB */
                 $this->DB->insert('posts', $post);
                 $post['pid'] = $this->DB->getInsertId();
                 /* Update topic with firstpost ID */
                 $this->DB->build(array('update' => 'topics', 'set' => "topic_firstpost=" . $post['pid'], 'where' => "tid=" . $topic['tid']));
                 $this->DB->execute();
                 /* Insert GUID match */
                 $this->DB->insert('rss_imported', array('rss_imported_impid' => $row['rss_import_id'], 'rss_imported_guid' => $topic_item['guid'], 'rss_imported_tid' => $topic['tid']));
                 /* Are we tracking this forum? If so generate some mailies - yay! */
                 $this->post->forum = $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']];
                 $this->post->sendOutTrackedForumEmails($row['rss_import_forum_id'], $topic['tid'], $topic['title'], $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']]['name'], $post['post'], $member['member_id'], $member['members_display_name']);
                 if ($topic['approved'] == 0) {
                     $this->post->sendNewTopicForApprovalEmails($topic['tid'], $topic['title'], $topic['starter_name'], $post['pid']);
                 }
                 $this->import_count++;
                 /* Increment user? */
                 if ($row['rss_import_inc_pcount'] and $this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']]['inc_postcount']) {
                     if (!$affected_members[$member['member_id']] or $affected_members[$member['member_id']] < 0) {
                         $affected_members[$member['member_id']] = 0;
                     }
                     $affected_members[$member['member_id']]++;
                 }
             }
         }
     }
     /* Update Members */
     if (is_array($affected_members) and count($affected_members)) {
         foreach ($affected_members as $mid => $inc) {
             if ($mid and $inc) {
                 $this->post->setAuthor($mid);
                 $this->post->incrementUsersPostCount($inc);
             }
         }
     }
     /* Recount Stats */
     if (is_array($affected_forum_ids) and count($affected_forum_ids)) {
         foreach ($affected_forum_ids as $fid) {
             $this->func_mod->forumRecount($fid);
         }
         $this->func_mod->statsRecount();
     }
     /* Return */
     if ($return) {
         $this->registry->output->global_message = $this->lang->words['im_recached'];
         if (count($rss_error)) {
             $this->registry->output->global_message .= "<br />" . implode("<br />", $rss_error);
         }
         $this->rssImportOverview();
         return;
     } else {
         return TRUE;
     }
 }
Example #15
0
 /**
  * Finish URLs for display
  * Truncates them, applies white/black lists, adds rel / targets
  * @param	string	In
  * @return	string	Out
  */
 protected function _finishUrlsForDisplay($txt)
 {
     /* If HTML mode, don't clean links */
     if (parent::$Perms['parseHtml']) {
         return $txt;
     }
     /* Reset counter */
     $this->cache->updateCacheWithoutSaving('_tmp_bbcode_media', 0);
     /* Parse media URLs that are NOT linked */
     $txt = preg_replace_callback('#(^|\\s|\\)|\\(|\\{|\\}|>|\\]|\\[|;|href=\\S)((http|https|news|ftp)://(?:[^<>\\)\\[\\"\\s]+|[a-zA-Z0-9/\\._\\-!&\\#;,%\\+\\?:=]+))(</a>)?#is', array($this, '_parseMediaUrls_CallBack'), $txt);
     /* LEGACY stuffs - a post from < 3.4 may not be HTMLised properly */
     if ($this->_urlsEnabled === true && preg_match('#(http|https)://#', $txt) && !stristr($txt, '<a')) {
         $txt = $this->_autoLinkUrls($txt);
     }
     preg_match_all('#<a\\s+?(?:[^>]*?)href=["\']([^"\']+?)?["\']([^>]*?)?>(.+?)</a>#is', $txt, $urlMatches);
     /* Finish up URLs and such */
     for ($i = 0; $i < count($urlMatches[0]); $i++) {
         $raw = $urlMatches[0][$i];
         $url = $urlMatches[1][$i];
         $attr = $urlMatches[2][$i];
         $text = $urlMatches[3][$i];
         $done = false;
         $pm = true;
         preg_match('#data-ipb=["\']([^"\']+?)?["\']#i', $raw, $matches);
         if ($matches[1] && stristr($matches[1], 'noparse')) {
             continue;
         } else {
             if ($matches[1] && stristr($matches[1], 'nomediaparse')) {
                 $pm = false;
             }
         }
         preg_match('#rel=["\']([^"\']+?)?["\']#i', $raw, $matches);
         if ($matches[1] && stristr($matches[1], 'lightbox')) {
             continue;
         }
         /* Urls disabled? */
         if ($this->_urlsEnabled !== true) {
             $txt = str_replace($raw, $url, $txt);
             continue;
         }
         /* Restored 1st March, Matt @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/some-previously-embedded-content-youtube-etc-now-showing-as-links-after-upgrade-r41411 */
         /* Is this a media URL? */
         /* Updated 14 May, http://community.invisionpower.com/resources/bugs.html/_/ip-board/url-tags-get-changed-to-media-tags-automatically-r40467 - 
         			Editor now sets "noparsemedia" data-ipb attribute, which we can skip here for automatic parsing */
         if ($pm and $this->settings['bbcode_automatic_media'] and isset($this->_bbcodes['media']) and ($this->_bbcodes['media']['bbcode_sections'] == 'all' or in_array(parent::$Perms['parseArea'], explode(',', $this->_bbcodes['media']['bbcode_sections'])))) {
             $media = $this->cache->getCache('mediatag');
             if ($url == $text && is_array($media) and count($media)) {
                 foreach ($media as $type => $r) {
                     if (preg_match("#^" . $r['match'] . "\$#is", $url)) {
                         $this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 1);
                         $_result = $this->_parseBBCode('[media]' . $url . '[/media]', 'display', array('media'));
                         $this->cache->updateCacheWithoutSaving('_tmp_autoparse_media', 0);
                         $txt = str_replace($raw, $_result, $txt);
                         $done = true;
                     }
                 }
             }
         }
         /* Format the URL */
         if ($done !== true) {
             // -----------------------------------------
             // URL filtering?
             // -----------------------------------------
             if (!$this->isAllowedUrl($url)) {
                 /* Unlink */
                 $txt = str_replace($raw, $url, $txt);
             }
             // -----------------------------------------
             // Let's remove any nested links..
             // -----------------------------------------
             $text = preg_replace('/<a href=[\'"](.+?)[\'"](.*?)>(.+?)<\\/a>/is', "\\3", $text);
             // -----------------------------------------
             // Need to "truncate" the "content" to ~35
             // EDIT: but only if it's the same as content
             // -----------------------------------------
             /*
              * Changes here @link
              * http://community.invisionpower.com/tracker/issue-36082-long-links-on-mobile-extend-width/   # V V Don't split if URL has entities V V #
              */
             if (empty($this->settings['__noTruncateUrl']) and IPSText::mbstrlen($text) > 38 && !preg_match('#&\\#([0-9]{2,4})#i', $text) and (substr($text, 0, 7) == 'http://' or substr($text, 0, 8) == 'https://')) {
                 $text = htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($text)), 0, 20)) . '...' . htmlspecialchars(IPSText::mbsubstr(html_entity_decode(urldecode($text)), -15));
             }
             // -----------------------------------------
             // Adding rel='nofollow'?
             // -----------------------------------------
             $rels = array();
             $rel = '';
             $_title = '';
             /* Skipping VigLink? */
             if ($this->settings['viglink_norewrite'] and IPSMember::isInGroup(parent::$Perms['memberData'], explode(',', $this->settings['viglink_norewrite']))) {
                 $rels[] = 'norewrite';
             }
             /* Fetch actual host for better matching */
             $data = @parse_url($url);
             if ($this->settings['posts_add_nofollow']) {
                 if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
                     $rels[] = "nofollow";
                 }
             }
             if ($this->settings['links_external']) {
                 if (!stristr($data['host'], $_SERVER['HTTP_HOST'])) {
                     /* Look a little closer */
                     $rels[] = "external";
                     $_title = $this->lang->words['bbc_external_link'];
                 }
             }
             if (count($rels)) {
                 $rel = " rel='" . implode(' ', $rels) . "'";
             }
             $replace = "<a href='{$url}' class='bbc_url' title='{$_title}'{$rel}>{$text}</a>";
             $txt = str_replace($raw, $replace, $txt);
         }
     }
     return $txt;
 }
Example #16
0
 /**
  * Set member based on IPS Connect
  *
  * @param	array	Data returned from IPS Connect
  * @return	void
  */
 protected function _handleIpsConnect($data)
 {
     if ($data['connect_status'] != 'SUCCESS') {
         return false;
     }
     $update = array();
     $member = IPSMember::load($data['connect_id'], 'all,members_partial', 'ipsconnect');
     if (!isset($member['member_id'])) {
         if (IPSText::mbstrlen($data['connect_username']) > ipsRegistry::$settings['max_user_name_length']) {
             $data['connect_username'] = IPSText::mbsubstr($data['connect_username'], 0, ipsRegistry::$settings['max_user_name_length']);
         }
         $member = IPSMember::create(array('members' => array('name' => $data['connect_username'], 'members_display_name' => $data['connect_displayname'], 'email' => $data['connect_email'], 'ipsconnect_id' => $data['connect_id'])), FALSE, TRUE, FALSE);
     }
     if (!$member['ipsconnect_id']) {
         $update['ipsconnect_id'] = $data['connect_id'];
     }
     if ($member['name'] != $data['connect_username'] and !defined('CONNECT_NOSYNC_NAMES')) {
         $update['name'] = $data['connect_username'];
     }
     if ($member['members_display_name'] != $data['connect_displayname'] and !defined('CONNECT_NOSYNC_NAMES')) {
         $update['members_display_name'] = $data['connect_displayname'];
     }
     if ($member['email'] != $data['connect_email']) {
         $update['email'] = $data['connect_email'];
     }
     if (!empty($update)) {
         IPSMember::save($member['member_id'], array('members' => $update));
     }
     self::setMember($member['member_id']);
     if ($member['partial_member_id']) {
         $this->DB->delete('members_partial', "partial_member_id={$member['partial_member_id']}");
     }
 }
Example #17
0
 /**
  * Rebuild the RSS Stream cache
  *
  * @param	mixed	$rss_import_id	ID of the stream to import
  * @param	bool	$return			Set to true to return true/false
  * @param	bool	$id_is_array	Set to true if the first paramter is an array of ids
  * @return	mixed
  */
 public function rssImportRebuildCache($rss_import_id, $return = true, $id_is_array = false)
 {
     /* INIT */
     $errors = array();
     $affected_forum_ids = array();
     $rss_error = array();
     $rss_import_ids = array();
     $items_imported = 0;
     /* Check the ID */
     if (!$rss_import_id) {
         $rss_import_id = $this->request['rss_import_id'] == 'all' ? 'all' : intval($this->request['rss_import_id']);
     }
     /* No ID Found */
     if (!$rss_import_id) {
         $this->registry->output->global_error = $this->lang->words['im_noid'];
         $this->rssImportOverview();
         return;
     }
     /* Create an array of ids */
     if ($id_is_array == 1) {
         $rss_import_ids = explode(",", $rss_import_id);
     }
     /* Load the classes we need */
     if (!$this->classes_loaded) {
         /* Get the RSS Class */
         if (!is_object($this->class_rss)) {
             $classToLoad = IPSLib::loadLibrary(IPS_KERNEL_PATH . 'classRss.php', 'classRss');
             $this->class_rss = new $classToLoad();
             $this->class_rss->rss_max_show = 100;
         }
         /* Get the post class */
         require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php';
         /*noLibHook*/
         $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums');
         $this->post = new $classToLoad($this->registry);
         /* Load the mod libarry */
         if (!$this->func_mod) {
             $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums');
             $this->func_mod = new $classToLoad($this->registry);
         }
         $this->classes_loaded = 1;
     }
     /* INIT Forums */
     if (!is_array($this->registry->class_forums->forum_by_id) or !count($this->registry->class_forums->forum_by_id)) {
         $this->registry->class_forums->forumsInit();
     }
     /* Sort out which IDs to load.. */
     if ($rss_import_id == 'all') {
         $where = 'rss_import_enabled=1';
         // Update only enabled ones!
     } elseif ($id_is_array == 1) {
         $where = 'rss_import_id IN (' . implode(',', $rss_import_ids) . ')';
     } else {
         $where = 'rss_import_id=' . $rss_import_id;
     }
     /* Query the RSS imports */
     $this->DB->build(array('select' => '*', 'from' => 'rss_import', 'where' => $where));
     $outer = $this->DB->execute();
     /* Loop through and build cache */
     while ($row = $this->DB->fetch($outer)) {
         /* Skip non-existent forums - bad stuff happens */
         if (empty($this->registry->class_forums->forum_by_id[$row['rss_import_forum_id']])) {
             continue;
         }
         /* Allowing badwords? */
         IPSText::getTextClass('bbcode')->bypass_badwords = $row['rss_import_allow_html'];
         /* Set this import's doctype */
         $this->class_rss->doc_type = strtoupper(IPS_DOC_CHAR_SET);
         /* Set this import's authentication */
         $this->class_rss->auth_req = $row['rss_import_auth'];
         $this->class_rss->auth_user = $row['rss_import_auth_user'];
         $this->class_rss->auth_pass = $row['rss_import_auth_pass'];
         /* Clear RSS object's error cache first */
         $this->class_rss->errors = array();
         $this->class_rss->rss_items = array();
         /* Reset the rss count as this is a new feed */
         $this->class_rss->rss_count = 0;
         $this->class_rss->rss_max_show = $row['rss_import_pergo'];
         /* Parse RSS */
         $this->class_rss->parseFeedFromUrl($row['rss_import_url']);
         /* Check for errors */
         if (is_array($this->class_rss->errors) and count($this->class_rss->errors)) {
             $rss_error = array_merge($rss_error, $this->class_rss->errors);
             continue;
         }
         if (!is_array($this->class_rss->rss_channels) or !count($this->class_rss->rss_channels)) {
             $rss_error[] = sprintf($this->lang->words['im_noopen'], $row['rss_import_url']);
             continue;
         }
         /* Update last check time */
         $this->DB->update('rss_import', array('rss_import_last_import' => IPS_UNIX_TIME_NOW), 'rss_import_id=' . $row['rss_import_id']);
         /* Apparently so: Parse feeds and check for already imported GUIDs */
         $final_items = array();
         $items = array();
         $check_guids = array();
         $final_guids = array();
         $count = 0;
         if (!is_array($this->class_rss->rss_items) or !count($this->class_rss->rss_items)) {
             $rss_error[] = $row['rss_import_url'] . $this->lang->words['im_noimport'];
             continue;
         }
         /* Loop through the channels */
         foreach ($this->class_rss->rss_channels as $channel_id => $channel_data) {
             if (is_array($this->class_rss->rss_items[$channel_id]) and count($this->class_rss->rss_items[$channel_id])) {
                 /* Loop through the items in this channel */
                 foreach ($this->class_rss->rss_items[$channel_id] as $item_data) {
                     /* Item Data */
                     $item_data['content'] = $item_data['content'] ? $item_data['content'] : $item_data['description'];
                     $item_data['guid'] = md5($row['rss_import_id'] . ($item_data['guid'] ? $item_data['guid'] : preg_replace('#\\s|\\r|\\n#is', "", $item_data['title'] . $item_data['link'] . $item_data['description'])));
                     $item_data['unixdate'] = intval($item_data['unixdate']) ? intval($item_data['unixdate']) : IPS_UNIX_TIME_NOW;
                     /*  If feed charset doesn't match original, we converted to utf-8 and need to convert back now */
                     if ($this->class_rss->doc_type != $this->class_rss->orig_doc_type) {
                         $item_data['title'] = IPSText::convertCharsets($item_data['title'], "UTF-8", IPS_DOC_CHAR_SET);
                         $item_data['content'] = IPSText::convertCharsets($item_data['content'], "UTF-8", IPS_DOC_CHAR_SET);
                     }
                     /* Error check */
                     if (!$item_data['title'] or !$item_data['content']) {
                         $rss_error[] = sprintf($this->lang->words['im_notitle'], $item_data['title']);
                         continue;
                     }
                     /* Dates */
                     if ($item_data['unixdate'] < 1) {
                         $item_data['unixdate'] = IPS_UNIX_TIME_NOW;
                     } else {
                         if ($item_data['unixdate'] > IPS_UNIX_TIME_NOW) {
                             $item_data['unixdate'] = IPS_UNIX_TIME_NOW;
                         }
                     }
                     /* Add to array */
                     $items[$item_data['guid']] = $item_data;
                     $check_guids[] = $item_data['guid'];
                 }
             }
         }
         /* Check GUIDs */
         if (!count($check_guids)) {
             $rss_error[] = $this->lang->words['im_noitems'];
             continue;
         }
         $this->DB->build(array('select' => '*', 'from' => 'rss_imported', 'where' => "rss_imported_guid IN ('" . implode("','", $check_guids) . "')"));
         $this->DB->execute();
         while ($guid = $this->DB->fetch()) {
             $final_guids[$guid['rss_imported_guid']] = $guid['rss_imported_guid'];
         }
         /* Compare GUIDs */
         $item_count = 0;
         foreach ($items as $guid => $data) {
             if (in_array($guid, $final_guids)) {
                 continue;
             } else {
                 $item_count++;
                 /* Make sure each item has a unique date */
                 $final_items[$data['unixdate'] . $item_count] = $data;
             }
         }
         /* Sort Array */
         krsort($final_items);
         /* Pick off last X */
         $count = 1;
         $tmp_final_items = $final_items;
         $final_items = array();
         foreach ($tmp_final_items as $date => $data) {
             $final_items[$date] = $data;
             if ($count >= $row['rss_import_pergo']) {
                 break;
             }
             $count++;
         }
         /* Anything left? */
         if (!count($final_items)) {
             continue;
         }
         /* Figure out MID */
         $member = $this->DB->buildAndFetch(array('select' => 'member_id, name, members_display_name, ip_address', 'from' => 'members', 'where' => "member_id={$row['rss_import_mid']}"));
         if (!$member['member_id']) {
             continue;
         }
         /* Set member in post class */
         $this->post->setAuthor($member['member_id']);
         $this->post->setForumData($this->registry->getClass('class_forums')->forum_by_id[$row['rss_import_forum_id']]);
         $this->post->setBypassPermissionCheck(true);
         $this->post->setForumID($row['rss_import_forum_id']);
         /* Make 'dem posts */
         $affected_forum_ids[] = $row['rss_import_forum_id'];
         /* Get editor */
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite');
         $editor = new $classToLoad();
         /* Force RTE */
         $editor->setForceRte(true);
         $editor->setRteEnabled(true);
         $editor->setLegacyMode(false);
         foreach ($final_items as $topic_item) {
             /* Fix &amp; */
             $topic_item['title'] = str_replace('&amp;', '&', $topic_item['title']);
             $topic_item['title'] = str_replace(array("\r", "\n"), ' ', $topic_item['title']);
             $topic_item['title'] = str_replace(array("<br />", "<br>"), ' ', $topic_item['title']);
             $topic_item['title'] = trim($topic_item['title']);
             $topic_item['title'] = strip_tags($topic_item['title']);
             $topic_item['title'] = IPSText::parseCleanValue($topic_item['title']);
             /* Fix up &amp;reg; */
             $topic_item['title'] = str_replace('&amp;reg;', '&reg;', $topic_item['title']);
             if ($row['rss_import_topic_pre']) {
                 $topic_item['title'] = str_replace('&nbsp;', ' ', str_replace('&amp;nbsp;', '&nbsp;', $row['rss_import_topic_pre'])) . ' ' . $topic_item['title'];
             }
             $this->post->setTopicTitle(IPSText::mbsubstr($topic_item['title'], 0, $this->settings['topic_title_max_len']));
             $this->post->setDate($topic_item['unixdate']);
             $this->post->setPublished($row['rss_import_topic_hide'] ? false : true);
             $this->post->setPublishedRedirectSkip(true);
             /* Clean up.. */
             $topic_item['content'] = preg_replace("#<br />(\r)?\n#is", "<br />", $topic_item['content']);
             if (!$row['rss_import_allow_html']) {
                 $topic_item['content'] = stripslashes($topic_item['content']);
                 $post_content = $editor->process($topic_item['content']);
             } else {
                 $post_content = stripslashes($topic_item['content']);
             }
             /* Add in Show link... */
             if ($row['rss_import_showlink'] and $topic_item['link']) {
                 $the_link = str_replace('{url}', trim($topic_item['link']), $row['rss_import_showlink']);
                 $the_link = "<br /><br />" . stripslashes($the_link);
                 $post_content .= $the_link;
             }
             /* Make sure HTML mode is enabled correctly */
             $this->request['post_htmlstatus'] = 1;
             /* Prevent invalid img extensions from breaking */
             $_hack = $this->settings['img_ext'];
             $_zack = $this->settings['max_quotes_per_post'];
             $this->settings['img_ext'] = null;
             $this->settings['max_quotes_per_post'] = 500;
             $tmpForum = $this->post->getForumData();
             $tmpAuthor = $this->post->getAuthor();
             $this->post->setForumData(array_merge($tmpForum, array('use_html' => 1)));
             $this->post->setAuthor(array_merge($tmpAuthor, array('g_dohtml' => 1)));
             $this->post->setPostContentPreFormatted($post_content);
             /* Insert */
             try {
                 $this->post->addTopic();
             } catch (Exception $e) {
             }
             /* Reset */
             $this->settings['img_ext'] = $_hack;
             $this->settings['max_quotes_per_post'] = $_zack;
             $this->request['post_htmlstatus'] = 0;
             $this->post->setForumData($tmpForum);
             $this->post->setAuthor($tmpAuthor);
             if (!$row['rss_import_topic_open']) {
                 if (!$this->modLibrary) {
                     $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('forums') . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums');
                     $this->modLibrary = new $classToLoad($this->registry);
                 }
                 $this->modLibrary->init($row['rss_import_forum_id']);
                 $this->modLibrary->topicClose($this->post->getTopicData('tid'));
             }
             /* Insert GUID match */
             $this->DB->insert('rss_imported', array('rss_imported_impid' => $row['rss_import_id'], 'rss_imported_guid' => $topic_item['guid'], 'rss_imported_tid' => $this->post->getTopicData('tid')));
             $this->import_count++;
         }
     }
     /* Uncomment when testing imports */
     //$this->DB->delete( 'rss_imported', '1=1');
     /* Recount Stats */
     if (count($affected_forum_ids)) {
         foreach ($affected_forum_ids as $fid) {
             $this->func_mod->forumRecount($fid);
         }
         $this->cache->rebuildCache('stats', 'global');
     }
     /* Return */
     if ($return) {
         $this->registry->output->global_message = $this->lang->words['im_recached'];
         if (count($rss_error)) {
             $this->registry->output->global_message .= "<br />" . implode("<br />", $rss_error);
         }
         $this->rssImportOverview();
         return;
     } else {
         return TRUE;
     }
 }
Example #18
0
 /**
  * Authenticate the request
  *
  * @access	public
  * @param	string		Username
  * @param	string		Email Address
  * @param	string		Password
  * @return	boolean		Authentication successful
  */
 public function authenticate($username, $email_address, $password)
 {
     //-----------------------------------------
     // Set basic data
     //-----------------------------------------
     $send = array('act' => 'login', 'key' => $this->connectConfig['master_key'], 'password' => md5($password));
     //-----------------------------------------
     // Load to check if we have master ID already
     //-----------------------------------------
     if ($username) {
         $_member = IPSMember::load($username, 'all', 'username');
     } else {
         $_member = IPSMember::load($email_address, 'all', 'email');
     }
     if ($_member['ipsconnect_id']) {
         $send['idType'] = 'id';
         $send['id'] = $_member['ipsconnect_id'];
     } else {
         if ($username) {
             $send['idType'] = 'username';
             $send['id'] = $username;
         } else {
             $send['idType'] = 'email';
             $send['id'] = $email_address;
         }
     }
     //-----------------------------------------
     // Send API Call
     //-----------------------------------------
     $send['key'] = md5($send['key'] . $send['id']);
     $url = $this->connectConfig['master_url'] . '?' . http_build_query($send);
     $return = $this->cfm->getFileContents($url);
     $data = @json_decode($return, TRUE);
     if (!isset($data['connect_status']) or !$data['connect_status']) {
         $this->return_code = 'WRONG_AUTH';
         return false;
     }
     //-----------------------------------------
     // If unsuccessful, return
     //-----------------------------------------
     if ($data['connect_status'] != 'SUCCESS') {
         $this->return_code = $data['connect_status'];
         if ($this->return_code == 'ACCOUNT_LOCKED') {
             $this->account_unlock = $data['connect_unlock'];
             /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/ipsconnect-account-unlock-time-r40812 */
             if ($data['connect_unlock_period']) {
                 $this->settings['ipb_bruteforce_period'] = $data['connect_unlock_period'];
             }
         }
         if ($this->return_code == 'VALIDATING') {
             $this->revalidate_url = $data['connect_revalidate_url'];
         }
         return false;
     }
     //-----------------------------------------
     // Create or update member accordingly
     //-----------------------------------------
     $update = array();
     $this->member_data = IPSMember::load($data['connect_id'], 'all', 'ipsconnect');
     if (!isset($this->member_data['member_id']) and isset($_member['member_id'])) {
         $this->member_data = $_member;
         $update['ipsconnect_id'] = $data['connect_id'];
     }
     if (!isset($this->member_data['member_id'])) {
         if (IPSText::mbstrlen($data['connect_username']) > ipsRegistry::$settings['max_user_name_length']) {
             $data['connect_username'] = IPSText::mbsubstr($data['connect_username'], 0, ipsRegistry::$settings['max_user_name_length']);
         }
         $this->member_data = $this->createLocalMember(array('members' => array('name' => $data['connect_username'], 'members_display_name' => $data['connect_displayname'], 'email' => $email_address, 'password' => $password, 'ipsconnect_id' => $data['connect_id'])));
     } else {
         if ($this->member_data['name'] != $data['connect_username'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['name'] = $data['connect_username'];
         }
         if ($this->member_data['members_display_name'] != $data['connect_displayname'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['members_display_name'] = $data['connect_displayname'];
         }
         if ($this->member_data['email'] != $data['connect_email']) {
             $update['email'] = $data['connect_email'];
         }
         IPSMember::updatePassword($this->member_data['member_id'], md5($password));
     }
     //-----------------------------------------
     // Privacy
     //-----------------------------------------
     $privacy = $this->member_data['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['anonymous']) ? 1 : 0;
     $update['login_anonymous'] = intval($privacy) . '&1';
     //-----------------------------------------
     // Update
     //-----------------------------------------
     if (!empty($update)) {
         IPSMember::save($this->member_data['member_id'], array('members' => $update));
     }
     //-----------------------------------------
     // If this is ACP or cross domain, just log in without SSO
     // http://community.invisionpower.com/resources/bugs.html/_/ip-board/cross-domain-connect-logins-r41932
     //-----------------------------------------
     $local = strtolower(@parse_url($this->settings['board_url'], PHP_URL_HOST));
     $connect = strtolower(@parse_url($this->connectConfig['master_url'], PHP_URL_HOST));
     if (strstr($local, '.') && !IPSLib::validateIPv4($local)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $local)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $local = '.' . implode('.', array_reverse($_domain));
     }
     if (strstr($connect, '.') && !IPSLib::validateIPv4($connect)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $connect)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $connect = '.' . implode('.', array_reverse($_domain));
     }
     if ($this->is_admin_auth or $this->is_password_check or $local != $connect) {
         $this->return_code = 'SUCCESS';
         return;
     }
     //-----------------------------------------
     // And redirect to log us in centrally
     //-----------------------------------------
     $redirect = $this->request['referer'] ? $this->request['referer'] : $this->settings['board_url'];
     if (strpos($redirect, '?') === FALSE) {
         $redirect .= '?';
     }
     $this->registry->output->silentRedirect($url . '&noparams=1&redirect=' . base64_encode($redirect) . '&redirectHash=' . md5($this->connectConfig['master_key'] . base64_encode($redirect)));
 }
Example #19
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');
 }
 /**
  * Save the topic title edits
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private 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';
     require_once IPSLib::getAppDir('forums') . '/sources/classes/post/classPostForms.php';
     $_postClass = new classPostForms($this->registry);
     $this->request['TopicTitle'] = $_postClass->cleanTopicTitle($this->request['TopicTitle']);
     $this->request['TopicTitle'] = trim(IPSText::getTextClass('bbcode')->stripBadWords($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'], 'description' => $this->request['TopicDesc'], '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'], $topic_title));
     $this->registry->output->redirectScreen($this->lang->words['p_edited'], $this->settings['base_url'] . "showtopic=" . $this->topic['tid']);
 }