function getXmlProfile($xml_format) { global $scripturl, $memberContext, $user_profile, $modSettings, $user_info; // You must input a valid user.... if (empty($_GET['u']) || loadMemberData((int) $_GET['u']) === false) { return array(); } // Make sure the id is a number and not "I like trying to hack the database". $_GET['u'] = (int) $_GET['u']; // Load the member's contextual information! if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view_any')) { return array(); } // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. $profile =& $memberContext[$_GET['u']]; if ($xml_format == 'rss' || $xml_format == 'rss2') { $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'comments' => $scripturl . '?action=pm;sa=send;u=' . $profile['id'], 'pubDate' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['dateRegistered']), 'guid' => $scripturl . '?action=profile;u=' . $profile['id'])); } elseif ($xml_format == 'rdf') { $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']))); } elseif ($xml_format == 'atom') { $data[] = array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'summary' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'created' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['dateRegistered']), 'issued' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['dateRegistered']), 'modified' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['lastLogin']), 'id' => $scripturl . '?action=profile;u=' . $profile['id']); } else { $data = array('username' => cdata_parse($profile['username']), 'name' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'posts' => $profile['posts'], 'post-group' => cdata_parse($profile['post_group']), 'language' => cdata_parse($profile['language']), 'last-login' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['lastLogin']), 'registered' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['dateRegistered'])); // Everything below here might not be set, and thus maybe shouldn't be displayed. if ($profile['gender']['name'] != '') { $data['gender'] = cdata_parse($profile['gender']['name']); } if ($profile['avatar']['name'] != '') { $data['avatar'] = $profile['avatar']['url']; } // If they are online, show an empty tag... no reason to put anything inside it. if ($profile['online']['is_online']) { $data['online'] = ''; } if ($profile['signature'] != '') { $data['signature'] = cdata_parse($profile['signature']); } if ($profile['blurb'] != '') { $data['blurb'] = cdata_parse($profile['blurb']); } if ($profile['location'] != '') { $data['location'] = cdata_parse($profile['location']); } if ($profile['title'] != '') { $data['title'] = cdata_parse($profile['title']); } if (!empty($profile['icq']['name']) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) { $data['icq'] = $profile['icq']['name']; } if ($profile['aim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) { $data['aim'] = $profile['aim']['name']; } if ($profile['msn']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) { $data['msn'] = $profile['msn']['name']; } if ($profile['yim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) { $data['yim'] = $profile['yim']['name']; } if ($profile['website']['title'] != '') { $data['website'] = array('title' => cdata_parse($profile['website']['title']), 'link' => $profile['website']['url']); } if ($profile['group'] != '') { $data['postition'] = cdata_parse($profile['group']); } if (!empty($modSettings['karmaMode'])) { $data['karma'] = array('good' => $profile['karma']['good'], 'bad' => $profile['karma']['bad']); } if ((empty($profile['hide_email']) || empty($modSettings['allow_hideEmail'])) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest'])) { $data['email'] = $profile['email']; } if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') { list($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d'); $datearray = getdate(forum_time()); $data['age'] = $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1); } } // Save some memory. unset($profile); unset($memberContext[$_GET['u']]); return $data; }
/** * Get the profile information for member into an array, * which will be generated to match the xml_format. * * @param string $xml_format one of rss, rss2, rdf, atom * @return mixed[] array of profile data. */ public function action_xmlprofile($xml_format) { global $scripturl, $memberContext, $user_profile, $modSettings, $user_info; // You must input a valid user.... if (empty($_GET['u']) || loadMemberData((int) $_GET['u']) === false) { return array(); } // Make sure the id is a number and not "I like trying to hack the database". $uid = (int) $_GET['u']; // Load the member's contextual information! if (!loadMemberContext($uid) || !allowedTo('profile_view_any')) { return array(); } $profile =& $memberContext[$uid]; // No feed data yet $data = array(); if ($xml_format == 'rss' || $xml_format == 'rss2') { $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'comments' => $scripturl . '?action=pm;sa=send;u=' . $profile['id'], 'pubDate' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['date_registered']), 'guid' => $scripturl . '?action=profile;u=' . $profile['id'])); } elseif ($xml_format == 'rdf') { $data = array(array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']))); } elseif ($xml_format == 'atom') { $data[] = array('title' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'summary' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']), 'author' => array('name' => $profile['real_name'], 'email' => in_array(showEmailAddress(!empty($profile['hide_email']), $profile['id']), array('yes', 'yes_permission_override')) ? $profile['email'] : null, 'uri' => !empty($profile['website']) ? $profile['website']['url'] : ''), 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['date_registered']), 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['last_login']), 'id' => $scripturl . '?action=profile;u=' . $profile['id'], 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : ''); } else { $data = array('username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? cdata_parse($profile['username']) : '', 'name' => cdata_parse($profile['name']), 'link' => $scripturl . '?action=profile;u=' . $profile['id'], 'posts' => $profile['posts'], 'post-group' => cdata_parse($profile['post_group']), 'language' => cdata_parse($profile['language']), 'last-login' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['last_login']), 'registered' => gmdate('D, d M Y H:i:s \\G\\M\\T', $user_profile[$profile['id']]['date_registered'])); // Everything below here might not be set, and thus maybe shouldn't be displayed. if ($profile['gender']['name'] != '') { $data['gender'] = cdata_parse($profile['gender']['name']); } if ($profile['avatar']['name'] != '') { $data['avatar'] = $profile['avatar']['url']; } // If they are online, show an empty tag... no reason to put anything inside it. if ($profile['online']['is_online']) { $data['online'] = ''; } if ($profile['signature'] != '') { $data['signature'] = cdata_parse($profile['signature']); } if ($profile['blurb'] != '') { $data['blurb'] = cdata_parse($profile['blurb']); } if ($profile['location'] != '') { $data['location'] = cdata_parse($profile['location']); } if ($profile['title'] != '') { $data['title'] = cdata_parse($profile['title']); } if ($profile['website']['title'] != '') { $data['website'] = array('title' => cdata_parse($profile['website']['title']), 'link' => $profile['website']['url']); } if ($profile['group'] != '') { $data['position'] = cdata_parse($profile['group']); } if (!empty($modSettings['karmaMode'])) { $data['karma'] = array('good' => $profile['karma']['good'], 'bad' => $profile['karma']['bad']); } if (in_array($profile['show_email'], array('yes', 'yes_permission_override'))) { $data['email'] = $profile['email']; } if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') { list($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d'); $datearray = getdate(forum_time()); $data['age'] = $datearray['year'] - $birth_year - ($datearray['mon'] > $birth_month || $datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day ? 0 : 1); } } // Save some memory. unset($profile, $memberContext[$uid]); return $data; }