News.php 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. <?php
  2. /**
  3. * This file contains the files necessary to display news as an XML feed.
  4. *
  5. * Simple Machines Forum (SMF)
  6. *
  7. * @package SMF
  8. * @author Simple Machines http://www.simplemachines.org
  9. * @copyright 2012 Simple Machines Forum contributors
  10. * @license http://www.simplemachines.org/about/smf/license.php BSD
  11. *
  12. * @version 2.1 Alpha 1
  13. */
  14. if (!defined('SMF'))
  15. die('Hacking attempt...');
  16. /**
  17. * Outputs xml data representing recent information or a profile.
  18. * Can be passed 4 subactions which decide what is output:
  19. * 'recent' for recent posts,
  20. * 'news' for news topics,
  21. * 'members' for recently registered members,
  22. * 'profile' for a member's profile.
  23. * To display a member's profile, a user id has to be given. (;u=1)
  24. * Outputs an rss feed instead of a proprietary one if the 'type' $_GET
  25. * parameter is 'rss' or 'rss2'.
  26. * Accessed via ?action=.xml.
  27. * Does not use any templates, sub templates, or template layers.
  28. *
  29. * @uses Stats language file.
  30. */
  31. function ShowXmlFeed()
  32. {
  33. global $board, $board_info, $context, $scripturl, $boardurl, $txt, $modSettings, $user_info;
  34. global $query_this_board, $smcFunc, $forum_version, $cdata_override;
  35. // If it's not enabled, die.
  36. if (empty($modSettings['xmlnews_enable']))
  37. obExit(false);
  38. loadLanguage('Stats');
  39. // Default to latest 5. No more than 255, please.
  40. $_GET['limit'] = empty($_GET['limit']) || (int) $_GET['limit'] < 1 ? 5 : min((int) $_GET['limit'], 255);
  41. // Handle the cases where a board, boards, or category is asked for.
  42. $query_this_board = 1;
  43. $context['optimize_msg'] = array(
  44. 'highest' => 'm.id_msg <= b.id_last_msg',
  45. );
  46. if (!empty($_REQUEST['c']) && empty($board))
  47. {
  48. $_REQUEST['c'] = explode(',', $_REQUEST['c']);
  49. foreach ($_REQUEST['c'] as $i => $c)
  50. $_REQUEST['c'][$i] = (int) $c;
  51. if (count($_REQUEST['c']) == 1)
  52. {
  53. $request = $smcFunc['db_query']('', '
  54. SELECT name
  55. FROM {db_prefix}categories
  56. WHERE id_cat = {int:current_category}',
  57. array(
  58. 'current_category' => (int) $_REQUEST['c'][0],
  59. )
  60. );
  61. list ($feed_title) = $smcFunc['db_fetch_row']($request);
  62. $smcFunc['db_free_result']($request);
  63. $feed_title = ' - ' . strip_tags($feed_title);
  64. }
  65. $request = $smcFunc['db_query']('', '
  66. SELECT b.id_board, b.num_posts
  67. FROM {db_prefix}boards AS b
  68. WHERE b.id_cat IN ({array_int:current_category_list})
  69. AND {query_see_board}',
  70. array(
  71. 'current_category_list' => $_REQUEST['c'],
  72. )
  73. );
  74. $total_cat_posts = 0;
  75. $boards = array();
  76. while ($row = $smcFunc['db_fetch_assoc']($request))
  77. {
  78. $boards[] = $row['id_board'];
  79. $total_cat_posts += $row['num_posts'];
  80. }
  81. $smcFunc['db_free_result']($request);
  82. if (!empty($boards))
  83. $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
  84. // Try to limit the number of messages we look through.
  85. if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15)
  86. $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
  87. }
  88. elseif (!empty($_REQUEST['boards']))
  89. {
  90. $_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
  91. foreach ($_REQUEST['boards'] as $i => $b)
  92. $_REQUEST['boards'][$i] = (int) $b;
  93. $request = $smcFunc['db_query']('', '
  94. SELECT b.id_board, b.num_posts, b.name
  95. FROM {db_prefix}boards AS b
  96. WHERE b.id_board IN ({array_int:board_list})
  97. AND {query_see_board}
  98. LIMIT ' . count($_REQUEST['boards']),
  99. array(
  100. 'board_list' => $_REQUEST['boards'],
  101. )
  102. );
  103. // Either the board specified doesn't exist or you have no access.
  104. $num_boards = $smcFunc['db_num_rows']($request);
  105. if ($num_boards == 0)
  106. fatal_lang_error('no_board');
  107. $total_posts = 0;
  108. $boards = array();
  109. while ($row = $smcFunc['db_fetch_assoc']($request))
  110. {
  111. if ($num_boards == 1)
  112. $feed_title = ' - ' . strip_tags($row['name']);
  113. $boards[] = $row['id_board'];
  114. $total_posts += $row['num_posts'];
  115. }
  116. $smcFunc['db_free_result']($request);
  117. if (!empty($boards))
  118. $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')';
  119. // The more boards, the more we're going to look through...
  120. if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12)
  121. $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
  122. }
  123. elseif (!empty($board))
  124. {
  125. $request = $smcFunc['db_query']('', '
  126. SELECT num_posts
  127. FROM {db_prefix}boards
  128. WHERE id_board = {int:current_board}
  129. LIMIT 1',
  130. array(
  131. 'current_board' => $board,
  132. )
  133. );
  134. list ($total_posts) = $smcFunc['db_fetch_row']($request);
  135. $smcFunc['db_free_result']($request);
  136. $feed_title = ' - ' . strip_tags($board_info['name']);
  137. $query_this_board = 'b.id_board = ' . $board;
  138. // Try to look through just a few messages, if at all possible.
  139. if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10)
  140. $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
  141. }
  142. else
  143. {
  144. $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
  145. AND b.id_board != ' . $modSettings['recycle_board'] : '');
  146. $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 100 - $_GET['limit'] * 5);
  147. }
  148. // Show in rss or proprietary format?
  149. $xml_format = isset($_GET['type']) && in_array($_GET['type'], array('smf', 'rss', 'rss2', 'atom', 'rdf', 'webslice')) ? $_GET['type'] : 'smf';
  150. // @todo Birthdays?
  151. // List all the different types of data they can pull.
  152. $subActions = array(
  153. 'recent' => array('getXmlRecent', 'recent-post'),
  154. 'news' => array('getXmlNews', 'article'),
  155. 'members' => array('getXmlMembers', 'member'),
  156. 'profile' => array('getXmlProfile', null),
  157. );
  158. // Easy adding of sub actions
  159. call_integration_hook('integrate_xmlfeeds', array(&$subActions));
  160. if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
  161. $_GET['sa'] = 'recent';
  162. // @todo Temp - webslices doesn't do everything yet.
  163. if ($xml_format == 'webslice' && $_GET['sa'] != 'recent')
  164. $xml_format = 'rss2';
  165. // If this is webslices we kinda cheat - we allow a template that we call direct for the HTML, and we override the CDATA.
  166. elseif ($xml_format == 'webslice')
  167. {
  168. $context['user'] += $user_info;
  169. $cdata_override = true;
  170. loadTemplate('Xml');
  171. }
  172. // We only want some information, not all of it.
  173. $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']);
  174. foreach (array('board', 'boards', 'c') as $var)
  175. if (isset($_REQUEST[$var]))
  176. $cachekey[] = $_REQUEST[$var];
  177. $cachekey = md5(serialize($cachekey) . (!empty($query_this_board) ? $query_this_board : ''));
  178. $cache_t = microtime();
  179. // Get the associative array representing the xml.
  180. if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3))
  181. $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240);
  182. if (empty($xml))
  183. {
  184. $xml = $subActions[$_GET['sa']][0]($xml_format);
  185. if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3)
  186. || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2))))
  187. cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240);
  188. }
  189. $feed_title = htmlspecialchars(strip_tags($context['forum_name'])) . (isset($feed_title) ? $feed_title : '');
  190. // This is an xml file....
  191. ob_end_clean();
  192. if (!empty($modSettings['enableCompressedOutput']))
  193. @ob_start('ob_gzhandler');
  194. else
  195. ob_start();
  196. if ($xml_format == 'smf' || isset($_REQUEST['debug']))
  197. header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
  198. elseif ($xml_format == 'rss' || $xml_format == 'rss2' || $xml_format == 'webslice')
  199. header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
  200. elseif ($xml_format == 'atom')
  201. header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
  202. elseif ($xml_format == 'rdf')
  203. header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
  204. // First, output the xml header.
  205. echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>';
  206. // Are we outputting an rss feed or one with more information?
  207. if ($xml_format == 'rss' || $xml_format == 'rss2')
  208. {
  209. // Start with an RSS 2.0 header.
  210. echo '
  211. <rss version=', $xml_format == 'rss2' ? '"2.0"' : '"0.92"', ' xml:lang="', strtr($txt['lang_locale'], '_', '-'), '">
  212. <channel>
  213. <title>', $feed_title, '</title>
  214. <link>', $scripturl, '</link>
  215. <description><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></description>';
  216. // Output all of the associative array, start indenting with 2 tabs, and name everything "item".
  217. dumpTags($xml, 2, 'item', $xml_format);
  218. // Output the footer of the xml.
  219. echo '
  220. </channel>
  221. </rss>';
  222. }
  223. elseif ($xml_format == 'webslice')
  224. {
  225. $context['recent_posts_data'] = $xml;
  226. $context['can_pm_read'] = allowedTo('pm_read');
  227. // This always has RSS 2
  228. echo '
  229. <rss version="2.0" xmlns:mon="http://www.microsoft.com/schemas/rss/monitoring/2007" xml:lang="', strtr($txt['lang_locale'], '_', '-'), '">
  230. <channel>
  231. <title>', $feed_title, ' - ', $txt['recent_posts'], '</title>
  232. <link>', $scripturl, '?action=recent</link>
  233. <description><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></description>
  234. <item>
  235. <title>', $feed_title, ' - ', $txt['recent_posts'], '</title>
  236. <link>', $scripturl, '?action=recent</link>
  237. <description><![CDATA[
  238. ', template_webslice_header_above(), '
  239. ', template_webslice_recent_posts(), '
  240. ', template_webslice_header_below(), '
  241. ]]></description>
  242. </item>
  243. </channel>
  244. </rss>';
  245. }
  246. elseif ($xml_format == 'atom')
  247. {
  248. foreach (array('board', 'boards', 'c') as $var)
  249. if (isset($_REQUEST[$var]))
  250. $url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]);
  251. echo '
  252. <feed xmlns="http://www.w3.org/2005/Atom">
  253. <title>', $feed_title, '</title>
  254. <link rel="alternate" type="text/html" href="', $scripturl, '" />
  255. <link rel="self" type="application/rss+xml" href="', $scripturl, '?type=atom;action=.xml', !empty($url_parts) ? ';' . implode(';', $url_parts) : '', '" />
  256. <id>', $scripturl, '</id>
  257. <icon>', $boardurl, '/favicon.ico</icon>
  258. <updated>', gmstrftime('%Y-%m-%dT%H:%M:%SZ'), '</updated>
  259. <subtitle><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></subtitle>
  260. <generator uri="http://www.simplemachines.org" version="', strtr($forum_version, array('SMF' => '')), '">SMF</generator>
  261. <author>
  262. <name>', strip_tags($context['forum_name']), '</name>
  263. </author>';
  264. dumpTags($xml, 2, 'entry', $xml_format);
  265. echo '
  266. </feed>';
  267. }
  268. elseif ($xml_format == 'rdf')
  269. {
  270. echo '
  271. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
  272. <channel rdf:about="', $scripturl, '">
  273. <title>', $feed_title, '</title>
  274. <link>', $scripturl, '</link>
  275. <description><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></description>
  276. <items>
  277. <rdf:Seq>';
  278. foreach ($xml as $item)
  279. echo '
  280. <rdf:li rdf:resource="', $item['link'], '" />';
  281. echo '
  282. </rdf:Seq>
  283. </items>
  284. </channel>
  285. ';
  286. dumpTags($xml, 1, 'item', $xml_format);
  287. echo '
  288. </rdf:RDF>';
  289. }
  290. // Otherwise, we're using our proprietary formats - they give more data, though.
  291. else
  292. {
  293. echo '
  294. <smf:xml-feed xmlns:smf="http://www.simplemachines.org/" xmlns="http://www.simplemachines.org/xml/', $_GET['sa'], '" xml:lang="', strtr($txt['lang_locale'], '_', '-'), '">';
  295. // Dump out that associative array. Indent properly.... and use the right names for the base elements.
  296. dumpTags($xml, 1, $subActions[$_GET['sa']][1], $xml_format);
  297. echo '
  298. </smf:xml-feed>';
  299. }
  300. obExit(false);
  301. }
  302. /**
  303. * Called from dumpTags to convert data to xml
  304. * Finds urls for local sitte and santizes them
  305. *
  306. * @param type $val
  307. * @return type
  308. */
  309. function fix_possible_url($val)
  310. {
  311. global $modSettings, $context, $scripturl;
  312. if (substr($val, 0, strlen($scripturl)) != $scripturl)
  313. return $val;
  314. call_integration_hook('integrate_fix_url', array(&$val));
  315. if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd']))
  316. return $val;
  317. $val = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$/e', '\'\' . $scripturl . \'/\' . strtr(\'$1\', \'&;=\', \'//,\') . \'.html$2\'', $val);
  318. return $val;
  319. }
  320. /**
  321. * Ensures supplied data is properly encpsulated in cdata xml tags
  322. * Called from getXmlProfile in News.php
  323. *
  324. * @param type $data
  325. * @param type $ns
  326. * @return type
  327. */
  328. function cdata_parse($data, $ns = '')
  329. {
  330. global $smcFunc, $cdata_override;
  331. // Are we not doing it?
  332. if (!empty($cdata_override))
  333. return $data;
  334. $cdata = '<![CDATA[';
  335. for ($pos = 0, $n = $smcFunc['strlen']($data); $pos < $n; null)
  336. {
  337. $positions = array(
  338. $smcFunc['strpos']($data, '&', $pos),
  339. $smcFunc['strpos']($data, ']', $pos),
  340. );
  341. if ($ns != '')
  342. $positions[] = $smcFunc['strpos']($data, '<', $pos);
  343. foreach ($positions as $k => $dummy)
  344. {
  345. if ($dummy === false)
  346. unset($positions[$k]);
  347. }
  348. $old = $pos;
  349. $pos = empty($positions) ? $n : min($positions);
  350. if ($pos - $old > 0)
  351. $cdata .= $smcFunc['substr']($data, $old, $pos - $old);
  352. if ($pos >= $n)
  353. break;
  354. if ($smcFunc['substr']($data, $pos, 1) == '<')
  355. {
  356. $pos2 = $smcFunc['strpos']($data, '>', $pos);
  357. if ($pos2 === false)
  358. $pos2 = $n;
  359. if ($smcFunc['substr']($data, $pos + 1, 1) == '/')
  360. $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
  361. else
  362. $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
  363. $pos = $pos2 + 1;
  364. }
  365. elseif ($smcFunc['substr']($data, $pos, 1) == ']')
  366. {
  367. $cdata .= ']]>&#093;<![CDATA[';
  368. $pos++;
  369. }
  370. elseif ($smcFunc['substr']($data, $pos, 1) == '&')
  371. {
  372. $pos2 = $smcFunc['strpos']($data, ';', $pos);
  373. if ($pos2 === false)
  374. $pos2 = $n;
  375. $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1);
  376. if ($smcFunc['substr']($data, $pos + 1, 1) == '#')
  377. $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
  378. elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot')))
  379. $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
  380. $pos = $pos2 + 1;
  381. }
  382. }
  383. $cdata .= ']]>';
  384. return strtr($cdata, array('<![CDATA[]]>' => ''));
  385. }
  386. /**
  387. * Formats data retrieved in other functions into xml format.
  388. * Additionally formats data based on the specific format passed.
  389. * This function is recursively called to handle sub arrays of data.
  390. * @param array $data the array to output as xml data
  391. * @param int $i the amount of indentation to use.
  392. * @param string $tag if specified, it will be used instead of the keys of data.
  393. * @param string $xml_format
  394. */
  395. function dumpTags($data, $i, $tag = null, $xml_format = '')
  396. {
  397. global $modSettings, $context, $scripturl;
  398. // For every array in the data...
  399. foreach ($data as $key => $val)
  400. {
  401. // Skip it, it's been set to null.
  402. if ($val === null)
  403. continue;
  404. // If a tag was passed, use it instead of the key.
  405. $key = isset($tag) ? $tag : $key;
  406. // First let's indent!
  407. echo "\n", str_repeat("\t", $i);
  408. // Grr, I hate kludges... almost worth doing it properly, here, but not quite.
  409. if ($xml_format == 'atom' && $key == 'link')
  410. {
  411. echo '<link rel="alternate" type="text/html" href="', fix_possible_url($val), '" />';
  412. continue;
  413. }
  414. // If it's empty/0/nothing simply output an empty tag.
  415. if ($val == '')
  416. echo '<', $key, ' />';
  417. elseif ($xml_format == 'atom' && $key == 'category')
  418. echo '<', $key, ' term="', $val, '" />';
  419. else
  420. {
  421. // Beginning tag.
  422. if ($xml_format == 'rdf' && $key == 'item' && isset($val['link']))
  423. {
  424. echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">';
  425. echo "\n", str_repeat("\t", $i + 1);
  426. echo '<dc:format>text/html</dc:format>';
  427. }
  428. elseif ($xml_format == 'atom' && $key == 'summary')
  429. echo '<', $key, ' type="html">';
  430. else
  431. echo '<', $key, '>';
  432. if (is_array($val))
  433. {
  434. // An array. Dump it, and then indent the tag.
  435. dumpTags($val, $i + 1, null, $xml_format);
  436. echo "\n", str_repeat("\t", $i), '</', $key, '>';
  437. }
  438. // A string with returns in it.... show this as a multiline element.
  439. elseif (strpos($val, "\n") !== false || strpos($val, '<br />') !== false)
  440. echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i), '</', $key, '>';
  441. // A simple string.
  442. else
  443. echo fix_possible_url($val), '</', $key, '>';
  444. }
  445. }
  446. }
  447. /**
  448. * Retrieve the list of members from database.
  449. * The array will be generated to match the format.
  450. * @todo get the list of members from Subs-Members.
  451. *
  452. * @param string $xml_format
  453. * @return array
  454. */
  455. function getXmlMembers($xml_format)
  456. {
  457. global $scripturl, $smcFunc;
  458. if (!allowedTo('view_mlist'))
  459. return array();
  460. // Find the most recent members.
  461. $request = $smcFunc['db_query']('', '
  462. SELECT id_member, member_name, real_name, date_registered, last_login
  463. FROM {db_prefix}members
  464. ORDER BY id_member DESC
  465. LIMIT {int:limit}',
  466. array(
  467. 'limit' => $_GET['limit'],
  468. )
  469. );
  470. $data = array();
  471. while ($row = $smcFunc['db_fetch_assoc']($request))
  472. {
  473. // Make the data look rss-ish.
  474. if ($xml_format == 'rss' || $xml_format == 'rss2')
  475. $data[] = array(
  476. 'title' => cdata_parse($row['real_name']),
  477. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  478. 'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'],
  479. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']),
  480. 'guid' => $scripturl . '?action=profile;u=' . $row['id_member'],
  481. );
  482. elseif ($xml_format == 'rdf')
  483. $data[] = array(
  484. 'title' => cdata_parse($row['real_name']),
  485. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  486. );
  487. elseif ($xml_format == 'atom')
  488. $data[] = array(
  489. 'title' => cdata_parse($row['real_name']),
  490. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  491. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']),
  492. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']),
  493. 'id' => $scripturl . '?action=profile;u=' . $row['id_member'],
  494. );
  495. // More logical format for the data, but harder to apply.
  496. else
  497. $data[] = array(
  498. 'name' => cdata_parse($row['real_name']),
  499. 'time' => htmlspecialchars(strip_tags(timeformat($row['date_registered']))),
  500. 'id' => $row['id_member'],
  501. 'link' => $scripturl . '?action=profile;u=' . $row['id_member']
  502. );
  503. }
  504. $smcFunc['db_free_result']($request);
  505. return $data;
  506. }
  507. /**
  508. * Get the latest topics information from a specific board,
  509. * to display later.
  510. * The returned array will be generated to match the xmf_format.
  511. * @todo does not belong here
  512. *
  513. * @param $xml_format
  514. * @return array, array of topics
  515. */
  516. function getXmlNews($xml_format)
  517. {
  518. global $user_info, $scripturl, $modSettings, $board;
  519. global $query_this_board, $smcFunc, $settings, $context;
  520. /* Find the latest posts that:
  521. - are the first post in their topic.
  522. - are on an any board OR in a specified board.
  523. - can be seen by this user.
  524. - are actually the latest posts. */
  525. $done = false;
  526. $loops = 0;
  527. while (!$done)
  528. {
  529. $optimize_msg = implode(' AND ', $context['optimize_msg']);
  530. $request = $smcFunc['db_query']('', '
  531. SELECT
  532. m.smileys_enabled, m.poster_time, m.id_msg, m.subject, m.body, m.modified_time,
  533. m.icon, t.id_topic, t.id_board, t.num_replies,
  534. b.name AS bname,
  535. mem.hide_email, IFNULL(mem.id_member, 0) AS id_member,
  536. IFNULL(mem.email_address, m.poster_email) AS poster_email,
  537. IFNULL(mem.real_name, m.poster_name) AS poster_name
  538. FROM {db_prefix}topics AS t
  539. INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
  540. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  541. LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
  542. WHERE ' . $query_this_board . (empty($optimize_msg) ? '' : '
  543. AND {raw:optimize_msg}') . (empty($board) ? '' : '
  544. AND t.id_board = {int:current_board}') . ($modSettings['postmod_active'] ? '
  545. AND t.approved = {int:is_approved}' : '') . '
  546. ORDER BY t.id_first_msg DESC
  547. LIMIT {int:limit}',
  548. array(
  549. 'current_board' => $board,
  550. 'is_approved' => 1,
  551. 'limit' => $_GET['limit'],
  552. 'optimize_msg' => $optimize_msg,
  553. )
  554. );
  555. // If we don't have $_GET['limit'] results, try again with an unoptimized version covering all rows.
  556. if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
  557. {
  558. $smcFunc['db_free_result']($request);
  559. if (empty($_REQUEST['boards']) && empty($board))
  560. unset($context['optimize_msg']['lowest']);
  561. else
  562. $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
  563. $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg';
  564. $loops++;
  565. }
  566. else
  567. $done = true;
  568. }
  569. $data = array();
  570. while ($row = $smcFunc['db_fetch_assoc']($request))
  571. {
  572. // Limit the length of the message, if the option is set.
  573. if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
  574. $row['body'] = strtr($smcFunc['substr'](str_replace('<br />', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br />')) . '...';
  575. $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
  576. censorText($row['body']);
  577. censorText($row['subject']);
  578. // Being news, this actually makes sense in rss format.
  579. if ($xml_format == 'rss' || $xml_format == 'rss2')
  580. $data[] = array(
  581. 'title' => cdata_parse($row['subject']),
  582. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  583. 'description' => cdata_parse($row['body']),
  584. 'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['posterEmail'] . ' ('.$row['posterName'].')' : null,
  585. 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
  586. 'category' => '<![CDATA[' . $row['bname'] . ']]>',
  587. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
  588. 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  589. );
  590. elseif ($xml_format == 'rdf')
  591. $data[] = array(
  592. 'title' => cdata_parse($row['subject']),
  593. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  594. 'description' => cdata_parse($row['body']),
  595. );
  596. elseif ($xml_format == 'atom')
  597. $data[] = array(
  598. 'title' => cdata_parse($row['subject']),
  599. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  600. 'summary' => cdata_parse($row['body']),
  601. 'category' => $row['bname'],
  602. 'author' => array(
  603. 'name' => $row['poster_name'],
  604. 'email' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  605. 'uri' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
  606. ),
  607. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['poster_time']),
  608. 'modified' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
  609. 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  610. );
  611. // The biggest difference here is more information.
  612. else
  613. $data[] = array(
  614. 'time' => htmlspecialchars(strip_tags(timeformat($row['poster_time']))),
  615. 'id' => $row['id_topic'],
  616. 'subject' => cdata_parse($row['subject']),
  617. 'body' => cdata_parse($row['body']),
  618. 'poster' => array(
  619. 'name' => cdata_parse($row['poster_name']),
  620. 'id' => $row['id_member'],
  621. 'link' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
  622. ),
  623. 'topic' => $row['id_topic'],
  624. 'board' => array(
  625. 'name' => cdata_parse($row['bname']),
  626. 'id' => $row['id_board'],
  627. 'link' => $scripturl . '?board=' . $row['id_board'] . '.0',
  628. ),
  629. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  630. );
  631. }
  632. $smcFunc['db_free_result']($request);
  633. return $data;
  634. }
  635. /**
  636. * Get the recent topics to display.
  637. * The returned array will be generated to match the xml_format.
  638. * @todo does not belong here.
  639. *
  640. * @param $xml_format
  641. * @return array, of recent posts
  642. */
  643. function getXmlRecent($xml_format)
  644. {
  645. global $user_info, $scripturl, $modSettings, $board;
  646. global $query_this_board, $smcFunc, $settings, $context;
  647. $done = false;
  648. $loops = 0;
  649. while (!$done)
  650. {
  651. $optimize_msg = implode(' AND ', $context['optimize_msg']);
  652. $request = $smcFunc['db_query']('', '
  653. SELECT m.id_msg
  654. FROM {db_prefix}messages AS m
  655. INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  656. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
  657. WHERE ' . $query_this_board . (empty($optimize_msg) ? '' : '
  658. AND {raw:optimize_msg}') . (empty($board) ? '' : '
  659. AND m.id_board = {int:current_board}') . ($modSettings['postmod_active'] ? '
  660. AND m.approved = {int:is_approved}' : '') . '
  661. ORDER BY m.id_msg DESC
  662. LIMIT {int:limit}',
  663. array(
  664. 'limit' => $_GET['limit'],
  665. 'current_board' => $board,
  666. 'is_approved' => 1,
  667. 'optimize_msg' => $optimize_msg,
  668. )
  669. );
  670. // If we don't have $_GET['limit'] results, try again with an unoptimized version covering all rows.
  671. if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
  672. {
  673. $smcFunc['db_free_result']($request);
  674. if (empty($_REQUEST['boards']) && empty($board))
  675. unset($context['optimize_msg']['lowest']);
  676. else
  677. $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
  678. $loops++;
  679. }
  680. else
  681. $done = true;
  682. }
  683. $messages = array();
  684. while ($row = $smcFunc['db_fetch_assoc']($request))
  685. $messages[] = $row['id_msg'];
  686. $smcFunc['db_free_result']($request);
  687. if (empty($messages))
  688. return array();
  689. // Find the most recent posts this user can see.
  690. $request = $smcFunc['db_query']('', '
  691. SELECT
  692. m.smileys_enabled, m.poster_time, m.id_msg, m.subject, m.body, m.id_topic, t.id_board,
  693. b.name AS bname, t.num_replies, m.id_member, m.icon, mf.id_member AS id_first_member,
  694. IFNULL(mem.real_name, m.poster_name) AS poster_name, mf.subject AS first_subject,
  695. IFNULL(memf.real_name, mf.poster_name) AS first_poster_name, mem.hide_email,
  696. IFNULL(mem.email_address, m.poster_email) AS poster_email, m.modified_time
  697. FROM {db_prefix}messages AS m
  698. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
  699. INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
  700. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  701. LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
  702. LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)
  703. WHERE m.id_msg IN ({array_int:message_list})
  704. ' . (empty($board) ? '' : 'AND t.id_board = {int:current_board}') . '
  705. ORDER BY m.id_msg DESC
  706. LIMIT {int:limit}',
  707. array(
  708. 'limit' => $_GET['limit'],
  709. 'current_board' => $board,
  710. 'message_list' => $messages,
  711. )
  712. );
  713. $data = array();
  714. while ($row = $smcFunc['db_fetch_assoc']($request))
  715. {
  716. // Limit the length of the message, if the option is set.
  717. if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
  718. $row['body'] = strtr($smcFunc['substr'](str_replace('<br />', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br />')) . '...';
  719. $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
  720. censorText($row['body']);
  721. censorText($row['subject']);
  722. // Doesn't work as well as news, but it kinda does..
  723. if ($xml_format == 'rss' || $xml_format == 'rss2')
  724. $data[] = array(
  725. 'title' => $row['subject'],
  726. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  727. 'description' => cdata_parse($row['body']),
  728. 'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  729. 'category' => cdata_parse($row['bname']),
  730. 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
  731. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
  732. 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
  733. );
  734. elseif ($xml_format == 'rdf')
  735. $data[] = array(
  736. 'title' => $row['subject'],
  737. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  738. 'description' => cdata_parse($row['body']),
  739. );
  740. elseif ($xml_format == 'atom')
  741. $data[] = array(
  742. 'title' => $row['subject'],
  743. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  744. 'summary' => cdata_parse($row['body']),
  745. 'category' => $row['bname'],
  746. 'author' => array(
  747. 'name' => $row['poster_name'],
  748. 'email' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  749. 'uri' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''
  750. ),
  751. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['poster_time']),
  752. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
  753. 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  754. );
  755. // A lot of information here. Should be enough to please the rss-ers.
  756. else
  757. $data[] = array(
  758. 'time' => htmlspecialchars(strip_tags(timeformat($row['poster_time']))),
  759. 'id' => $row['id_msg'],
  760. 'subject' => cdata_parse($row['subject']),
  761. 'body' => cdata_parse($row['body']),
  762. 'starter' => array(
  763. 'name' => cdata_parse($row['first_poster_name']),
  764. 'id' => $row['id_first_member'],
  765. 'link' => !empty($row['id_first_member']) ? $scripturl . '?action=profile;u=' . $row['id_first_member'] : ''
  766. ),
  767. 'poster' => array(
  768. 'name' => cdata_parse($row['poster_name']),
  769. 'id' => $row['id_member'],
  770. 'link' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''
  771. ),
  772. 'topic' => array(
  773. 'subject' => cdata_parse($row['first_subject']),
  774. 'id' => $row['id_topic'],
  775. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.new#new'
  776. ),
  777. 'board' => array(
  778. 'name' => cdata_parse($row['bname']),
  779. 'id' => $row['id_board'],
  780. 'link' => $scripturl . '?board=' . $row['id_board'] . '.0'
  781. ),
  782. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
  783. );
  784. }
  785. $smcFunc['db_free_result']($request);
  786. return $data;
  787. }
  788. /**
  789. * Get the profile information for member into an array,
  790. * which will be generated to match the xml_format.
  791. * @todo refactor.
  792. *
  793. * @param $xml_format
  794. * @return array, of profile data.
  795. */
  796. function getXmlProfile($xml_format)
  797. {
  798. global $scripturl, $memberContext, $user_profile, $modSettings, $user_info;
  799. // You must input a valid user....
  800. if (empty($_GET['u']) || loadMemberData((int) $_GET['u']) === false)
  801. return array();
  802. // Make sure the id is a number and not "I like trying to hack the database".
  803. $_GET['u'] = (int) $_GET['u'];
  804. // Load the member's contextual information!
  805. if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view_any'))
  806. return array();
  807. // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type.
  808. $profile = &$memberContext[$_GET['u']];
  809. if ($xml_format == 'rss' || $xml_format == 'rss2')
  810. $data = array(array(
  811. 'title' => cdata_parse($profile['name']),
  812. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  813. 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  814. 'comments' => $scripturl . '?action=pm;sa=send;u=' . $profile['id'],
  815. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']),
  816. 'guid' => $scripturl . '?action=profile;u=' . $profile['id'],
  817. ));
  818. elseif ($xml_format == 'rdf')
  819. $data = array(array(
  820. 'title' => cdata_parse($profile['name']),
  821. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  822. 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  823. ));
  824. elseif ($xml_format == 'atom')
  825. $data[] = array(
  826. 'title' => cdata_parse($profile['name']),
  827. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  828. 'summary' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  829. 'author' => array(
  830. 'name' => $profile['real_name'],
  831. 'email' => in_array(showEmailAddress(!empty($profile['hide_email']), $profile['id']), array('yes', 'yes_permission_override')) ? $profile['email'] : null,
  832. 'uri' => !empty($profile['website']) ? $profile['website']['url'] : ''
  833. ),
  834. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['date_registered']),
  835. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['last_login']),
  836. 'id' => $scripturl . '?action=profile;u=' . $profile['id'],
  837. 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '',
  838. );
  839. else
  840. {
  841. $data = array(
  842. 'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? cdata_parse($profile['username']) : '',
  843. 'name' => cdata_parse($profile['name']),
  844. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  845. 'posts' => $profile['posts'],
  846. 'post-group' => cdata_parse($profile['post_group']),
  847. 'language' => cdata_parse($profile['language']),
  848. 'last-login' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['last_login']),
  849. 'registered' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered'])
  850. );
  851. // Everything below here might not be set, and thus maybe shouldn't be displayed.
  852. if ($profile['gender']['name'] != '')
  853. $data['gender'] = cdata_parse($profile['gender']['name']);
  854. if ($profile['avatar']['name'] != '')
  855. $data['avatar'] = $profile['avatar']['url'];
  856. // If they are online, show an empty tag... no reason to put anything inside it.
  857. if ($profile['online']['is_online'])
  858. $data['online'] = '';
  859. if ($profile['signature'] != '')
  860. $data['signature'] = cdata_parse($profile['signature']);
  861. if ($profile['blurb'] != '')
  862. $data['blurb'] = cdata_parse($profile['blurb']);
  863. if ($profile['location'] != '')
  864. $data['location'] = cdata_parse($profile['location']);
  865. if ($profile['title'] != '')
  866. $data['title'] = cdata_parse($profile['title']);
  867. if (!empty($profile['icq']['name']) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  868. $data['icq'] = $profile['icq']['name'];
  869. if ($profile['aim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  870. $data['aim'] = $profile['aim']['name'];
  871. if ($profile['msn']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  872. $data['msn'] = $profile['msn']['name'];
  873. if ($profile['yim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  874. $data['yim'] = $profile['yim']['name'];
  875. if ($profile['website']['title'] != '')
  876. $data['website'] = array(
  877. 'title' => cdata_parse($profile['website']['title']),
  878. 'link' => $profile['website']['url']
  879. );
  880. if ($profile['group'] != '')
  881. $data['position'] = cdata_parse($profile['group']);
  882. if (!empty($modSettings['karmaMode']))
  883. $data['karma'] = array(
  884. 'good' => $profile['karma']['good'],
  885. 'bad' => $profile['karma']['bad']
  886. );
  887. if (in_array($profile['show_email'], array('yes', 'yes_permission_override')))
  888. $data['email'] = $profile['email'];
  889. if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000')
  890. {
  891. list ($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d');
  892. $datearray = getdate(forum_time());
  893. $data['age'] = $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1);
  894. }
  895. }
  896. // Save some memory.
  897. unset($profile, $memberContext[$_GET['u']]);
  898. return $data;
  899. }
  900. ?>