News.php 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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
  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. // This always has RSS 2
  227. echo '
  228. <rss version="2.0" xmlns:mon="http://www.microsoft.com/schemas/rss/monitoring/2007" xml:lang="', strtr($txt['lang_locale'], '_', '-'), '">
  229. <channel>
  230. <title>', $feed_title, ' - ', $txt['recent_posts'], '</title>
  231. <link>', $scripturl, '?action=recent</link>
  232. <description><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></description>
  233. <item>
  234. <title>', $feed_title, ' - ', $txt['recent_posts'], '</title>
  235. <link>', $scripturl, '?action=recent</link>
  236. <description><![CDATA[
  237. ', template_webslice_header_above(), '
  238. ', template_webslice_recent_posts(), '
  239. ', template_webslice_header_below(), '
  240. ]]></description>
  241. </item>
  242. </channel>
  243. </rss>';
  244. }
  245. elseif ($xml_format == 'atom')
  246. {
  247. foreach (array('board', 'boards', 'c') as $var)
  248. if (isset($_REQUEST[$var]))
  249. $url_parts[] = $var . '=' . (is_array($_REQUEST[$var]) ? implode(',', $_REQUEST[$var]) : $_REQUEST[$var]);
  250. echo '
  251. <feed xmlns="http://www.w3.org/2005/Atom">
  252. <title>', $feed_title, '</title>
  253. <link rel="alternate" type="text/html" href="', $scripturl, '" />
  254. <link rel="self" type="application/rss+xml" href="', $scripturl, '?type=atom;action=.xml', !empty($url_parts) ? ';' . implode(';', $url_parts) : '', '" />
  255. <id>', $scripturl, '</id>
  256. <icon>', $boardurl, '/favicon.ico</icon>
  257. <updated>', gmstrftime('%Y-%m-%dT%H:%M:%SZ'), '</updated>
  258. <subtitle><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></subtitle>
  259. <generator uri="http://www.simplemachines.org" version="', strtr($forum_version, array('SMF' => '')), '">SMF</generator>
  260. <author>
  261. <name>', strip_tags($context['forum_name']), '</name>
  262. </author>';
  263. dumpTags($xml, 2, 'entry', $xml_format);
  264. echo '
  265. </feed>';
  266. }
  267. elseif ($xml_format == 'rdf')
  268. {
  269. echo '
  270. <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/">
  271. <channel rdf:about="', $scripturl, '">
  272. <title>', $feed_title, '</title>
  273. <link>', $scripturl, '</link>
  274. <description><![CDATA[', strip_tags($txt['xml_rss_desc']), ']]></description>
  275. <items>
  276. <rdf:Seq>';
  277. foreach ($xml as $item)
  278. echo '
  279. <rdf:li rdf:resource="', $item['link'], '" />';
  280. echo '
  281. </rdf:Seq>
  282. </items>
  283. </channel>
  284. ';
  285. dumpTags($xml, 1, 'item', $xml_format);
  286. echo '
  287. </rdf:RDF>';
  288. }
  289. // Otherwise, we're using our proprietary formats - they give more data, though.
  290. else
  291. {
  292. echo '
  293. <smf:xml-feed xmlns:smf="http://www.simplemachines.org/" xmlns="http://www.simplemachines.org/xml/', $_GET['sa'], '" xml:lang="', strtr($txt['lang_locale'], '_', '-'), '">';
  294. // Dump out that associative array. Indent properly.... and use the right names for the base elements.
  295. dumpTags($xml, 1, $subActions[$_GET['sa']][1], $xml_format);
  296. echo '
  297. </smf:xml-feed>';
  298. }
  299. obExit(false);
  300. }
  301. /**
  302. * Called from dumpTags to convert data to xml
  303. * Finds urls for local sitte and santizes them
  304. *
  305. * @param type $val
  306. * @return type
  307. */
  308. function fix_possible_url($val)
  309. {
  310. global $modSettings, $context, $scripturl;
  311. if (substr($val, 0, strlen($scripturl)) != $scripturl)
  312. return $val;
  313. call_integration_hook('integrate_fix_url', array(&$val));
  314. 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']))
  315. return $val;
  316. $val = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$/e', '\'\' . $scripturl . \'/\' . strtr(\'$1\', \'&;=\', \'//,\') . \'.html$2\'', $val);
  317. return $val;
  318. }
  319. /**
  320. * Ensures supplied data is properly encpsulated in cdata xml tags
  321. * Called from getXmlProfile in News.php
  322. *
  323. * @param type $data
  324. * @param type $ns
  325. * @return type
  326. */
  327. function cdata_parse($data, $ns = '')
  328. {
  329. global $smcFunc, $cdata_override;
  330. // Are we not doing it?
  331. if (!empty($cdata_override))
  332. return $data;
  333. $cdata = '<![CDATA[';
  334. for ($pos = 0, $n = $smcFunc['strlen']($data); $pos < $n; null)
  335. {
  336. $positions = array(
  337. $smcFunc['strpos']($data, '&', $pos),
  338. $smcFunc['strpos']($data, ']', $pos),
  339. );
  340. if ($ns != '')
  341. $positions[] = $smcFunc['strpos']($data, '<', $pos);
  342. foreach ($positions as $k => $dummy)
  343. {
  344. if ($dummy === false)
  345. unset($positions[$k]);
  346. }
  347. $old = $pos;
  348. $pos = empty($positions) ? $n : min($positions);
  349. if ($pos - $old > 0)
  350. $cdata .= $smcFunc['substr']($data, $old, $pos - $old);
  351. if ($pos >= $n)
  352. break;
  353. if ($smcFunc['substr']($data, $pos, 1) == '<')
  354. {
  355. $pos2 = $smcFunc['strpos']($data, '>', $pos);
  356. if ($pos2 === false)
  357. $pos2 = $n;
  358. if ($smcFunc['substr']($data, $pos + 1, 1) == '/')
  359. $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA[';
  360. else
  361. $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '<![CDATA[';
  362. $pos = $pos2 + 1;
  363. }
  364. elseif ($smcFunc['substr']($data, $pos, 1) == ']')
  365. {
  366. $cdata .= ']]>&#093;<![CDATA[';
  367. $pos++;
  368. }
  369. elseif ($smcFunc['substr']($data, $pos, 1) == '&')
  370. {
  371. $pos2 = $smcFunc['strpos']($data, ';', $pos);
  372. if ($pos2 === false)
  373. $pos2 = $n;
  374. $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1);
  375. if ($smcFunc['substr']($data, $pos + 1, 1) == '#')
  376. $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
  377. elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot')))
  378. $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA[';
  379. $pos = $pos2 + 1;
  380. }
  381. }
  382. $cdata .= ']]>';
  383. return strtr($cdata, array('<![CDATA[]]>' => ''));
  384. }
  385. /**
  386. * Formats data retrieved in other functions into xml format.
  387. * Additionally formats data based on the specific format passed.
  388. * This function is recursively called to handle sub arrays of data.
  389. * @param array $data the array to output as xml data
  390. * @param int $i the amount of indentation to use.
  391. * @param string $tag if specified, it will be used instead of the keys of data.
  392. * @param string $xml_format
  393. */
  394. function dumpTags($data, $i, $tag = null, $xml_format = '')
  395. {
  396. global $modSettings, $context, $scripturl;
  397. // For every array in the data...
  398. foreach ($data as $key => $val)
  399. {
  400. // Skip it, it's been set to null.
  401. if ($val === null)
  402. continue;
  403. // If a tag was passed, use it instead of the key.
  404. $key = isset($tag) ? $tag : $key;
  405. // First let's indent!
  406. echo "\n", str_repeat("\t", $i);
  407. // Grr, I hate kludges... almost worth doing it properly, here, but not quite.
  408. if ($xml_format == 'atom' && $key == 'link')
  409. {
  410. echo '<link rel="alternate" type="text/html" href="', fix_possible_url($val), '" />';
  411. continue;
  412. }
  413. // If it's empty/0/nothing simply output an empty tag.
  414. if ($val == '')
  415. echo '<', $key, ' />';
  416. elseif ($xml_format == 'atom' && $key == 'category')
  417. echo '<', $key, ' term="', $val, '" />';
  418. else
  419. {
  420. // Beginning tag.
  421. if ($xml_format == 'rdf' && $key == 'item' && isset($val['link']))
  422. {
  423. echo '<', $key, ' rdf:about="', fix_possible_url($val['link']), '">';
  424. echo "\n", str_repeat("\t", $i + 1);
  425. echo '<dc:format>text/html</dc:format>';
  426. }
  427. elseif ($xml_format == 'atom' && $key == 'summary')
  428. echo '<', $key, ' type="html">';
  429. else
  430. echo '<', $key, '>';
  431. if (is_array($val))
  432. {
  433. // An array. Dump it, and then indent the tag.
  434. dumpTags($val, $i + 1, null, $xml_format);
  435. echo "\n", str_repeat("\t", $i), '</', $key, '>';
  436. }
  437. // A string with returns in it.... show this as a multiline element.
  438. elseif (strpos($val, "\n") !== false || strpos($val, '<br />') !== false)
  439. echo "\n", fix_possible_url($val), "\n", str_repeat("\t", $i), '</', $key, '>';
  440. // A simple string.
  441. else
  442. echo fix_possible_url($val), '</', $key, '>';
  443. }
  444. }
  445. }
  446. /**
  447. * Retrieve the list of members from database.
  448. * The array will be generated to match the format.
  449. * @todo get the list of members from Subs-Members.
  450. *
  451. * @param string $xml_format
  452. * @return array
  453. */
  454. function getXmlMembers($xml_format)
  455. {
  456. global $scripturl, $smcFunc;
  457. if (!allowedTo('view_mlist'))
  458. return array();
  459. // Find the most recent members.
  460. $request = $smcFunc['db_query']('', '
  461. SELECT id_member, member_name, real_name, date_registered, last_login
  462. FROM {db_prefix}members
  463. ORDER BY id_member DESC
  464. LIMIT {int:limit}',
  465. array(
  466. 'limit' => $_GET['limit'],
  467. )
  468. );
  469. $data = array();
  470. while ($row = $smcFunc['db_fetch_assoc']($request))
  471. {
  472. // Make the data look rss-ish.
  473. if ($xml_format == 'rss' || $xml_format == 'rss2')
  474. $data[] = array(
  475. 'title' => cdata_parse($row['real_name']),
  476. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  477. 'comments' => $scripturl . '?action=pm;sa=send;u=' . $row['id_member'],
  478. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['date_registered']),
  479. 'guid' => $scripturl . '?action=profile;u=' . $row['id_member'],
  480. );
  481. elseif ($xml_format == 'rdf')
  482. $data[] = array(
  483. 'title' => cdata_parse($row['real_name']),
  484. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  485. );
  486. elseif ($xml_format == 'atom')
  487. $data[] = array(
  488. 'title' => cdata_parse($row['real_name']),
  489. 'link' => $scripturl . '?action=profile;u=' . $row['id_member'],
  490. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['date_registered']),
  491. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['last_login']),
  492. 'id' => $scripturl . '?action=profile;u=' . $row['id_member'],
  493. );
  494. // More logical format for the data, but harder to apply.
  495. else
  496. $data[] = array(
  497. 'name' => cdata_parse($row['real_name']),
  498. 'time' => htmlspecialchars(strip_tags(timeformat($row['date_registered']))),
  499. 'id' => $row['id_member'],
  500. 'link' => $scripturl . '?action=profile;u=' . $row['id_member']
  501. );
  502. }
  503. $smcFunc['db_free_result']($request);
  504. return $data;
  505. }
  506. /**
  507. * Get the latest topics information from a specific board,
  508. * to display later.
  509. * The returned array will be generated to match the xmf_format.
  510. * @todo does not belong here
  511. *
  512. * @param $xml_format
  513. * @return array, array of topics
  514. */
  515. function getXmlNews($xml_format)
  516. {
  517. global $user_info, $scripturl, $modSettings, $board;
  518. global $query_this_board, $smcFunc, $settings, $context;
  519. /* Find the latest posts that:
  520. - are the first post in their topic.
  521. - are on an any board OR in a specified board.
  522. - can be seen by this user.
  523. - are actually the latest posts. */
  524. $done = false;
  525. $loops = 0;
  526. while (!$done)
  527. {
  528. $optimize_msg = implode(' AND ', $context['optimize_msg']);
  529. $request = $smcFunc['db_query']('', '
  530. SELECT
  531. m.smileys_enabled, m.poster_time, m.id_msg, m.subject, m.body, m.modified_time,
  532. m.icon, t.id_topic, t.id_board, t.num_replies,
  533. b.name AS bname,
  534. mem.hide_email, IFNULL(mem.id_member, 0) AS id_member,
  535. IFNULL(mem.email_address, m.poster_email) AS poster_email,
  536. IFNULL(mem.real_name, m.poster_name) AS poster_name
  537. FROM {db_prefix}topics AS t
  538. INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
  539. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  540. LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
  541. WHERE ' . $query_this_board . (empty($optimize_msg) ? '' : '
  542. AND {raw:optimize_msg}') . (empty($board) ? '' : '
  543. AND t.id_board = {int:current_board}') . ($modSettings['postmod_active'] ? '
  544. AND t.approved = {int:is_approved}' : '') . '
  545. ORDER BY t.id_first_msg DESC
  546. LIMIT {int:limit}',
  547. array(
  548. 'current_board' => $board,
  549. 'is_approved' => 1,
  550. 'limit' => $_GET['limit'],
  551. 'optimize_msg' => $optimize_msg,
  552. )
  553. );
  554. // If we don't have $_GET['limit'] results, try again with an unoptimized version covering all rows.
  555. if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
  556. {
  557. $smcFunc['db_free_result']($request);
  558. if (empty($_REQUEST['boards']) && empty($board))
  559. unset($context['optimize_msg']['lowest']);
  560. else
  561. $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg';
  562. $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg';
  563. $loops++;
  564. }
  565. else
  566. $done = true;
  567. }
  568. $data = array();
  569. while ($row = $smcFunc['db_fetch_assoc']($request))
  570. {
  571. // Limit the length of the message, if the option is set.
  572. if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
  573. $row['body'] = strtr($smcFunc['substr'](str_replace('<br />', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br />')) . '...';
  574. $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
  575. censorText($row['body']);
  576. censorText($row['subject']);
  577. // Being news, this actually makes sense in rss format.
  578. if ($xml_format == 'rss' || $xml_format == 'rss2')
  579. $data[] = array(
  580. 'title' => cdata_parse($row['subject']),
  581. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  582. 'description' => cdata_parse($row['body']),
  583. 'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['posterEmail'] . ' ('.$row['posterName'].')' : null,
  584. 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
  585. 'category' => '<![CDATA[' . $row['bname'] . ']]>',
  586. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
  587. 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  588. );
  589. elseif ($xml_format == 'rdf')
  590. $data[] = array(
  591. 'title' => cdata_parse($row['subject']),
  592. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  593. 'description' => cdata_parse($row['body']),
  594. );
  595. elseif ($xml_format == 'atom')
  596. $data[] = array(
  597. 'title' => cdata_parse($row['subject']),
  598. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  599. 'summary' => cdata_parse($row['body']),
  600. 'category' => $row['bname'],
  601. 'author' => array(
  602. 'name' => $row['poster_name'],
  603. 'email' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  604. 'uri' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
  605. ),
  606. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['poster_time']),
  607. 'modified' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
  608. 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  609. );
  610. // The biggest difference here is more information.
  611. else
  612. $data[] = array(
  613. 'time' => htmlspecialchars(strip_tags(timeformat($row['poster_time']))),
  614. 'id' => $row['id_topic'],
  615. 'subject' => cdata_parse($row['subject']),
  616. 'body' => cdata_parse($row['body']),
  617. 'poster' => array(
  618. 'name' => cdata_parse($row['poster_name']),
  619. 'id' => $row['id_member'],
  620. 'link' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : '',
  621. ),
  622. 'topic' => $row['id_topic'],
  623. 'board' => array(
  624. 'name' => cdata_parse($row['bname']),
  625. 'id' => $row['id_board'],
  626. 'link' => $scripturl . '?board=' . $row['id_board'] . '.0',
  627. ),
  628. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
  629. );
  630. }
  631. $smcFunc['db_free_result']($request);
  632. return $data;
  633. }
  634. /**
  635. * Get the recent topics to display.
  636. * The returned array will be generated to match the xml_format.
  637. * @todo does not belong here.
  638. *
  639. * @param $xml_format
  640. * @return array, of recent posts
  641. */
  642. function getXmlRecent($xml_format)
  643. {
  644. global $user_info, $scripturl, $modSettings, $board;
  645. global $query_this_board, $smcFunc, $settings, $context;
  646. $done = false;
  647. $loops = 0;
  648. while (!$done)
  649. {
  650. $optimize_msg = implode(' AND ', $context['optimize_msg']);
  651. $request = $smcFunc['db_query']('', '
  652. SELECT m.id_msg
  653. FROM {db_prefix}messages AS m
  654. INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  655. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
  656. WHERE ' . $query_this_board . (empty($optimize_msg) ? '' : '
  657. AND {raw:optimize_msg}') . (empty($board) ? '' : '
  658. AND m.id_board = {int:current_board}') . ($modSettings['postmod_active'] ? '
  659. AND m.approved = {int:is_approved}' : '') . '
  660. ORDER BY m.id_msg DESC
  661. LIMIT {int:limit}',
  662. array(
  663. 'limit' => $_GET['limit'],
  664. 'current_board' => $board,
  665. 'is_approved' => 1,
  666. 'optimize_msg' => $optimize_msg,
  667. )
  668. );
  669. // If we don't have $_GET['limit'] results, try again with an unoptimized version covering all rows.
  670. if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit'])
  671. {
  672. $smcFunc['db_free_result']($request);
  673. if (empty($_REQUEST['boards']) && empty($board))
  674. unset($context['optimize_msg']['lowest']);
  675. else
  676. $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2';
  677. $loops++;
  678. }
  679. else
  680. $done = true;
  681. }
  682. $messages = array();
  683. while ($row = $smcFunc['db_fetch_assoc']($request))
  684. $messages[] = $row['id_msg'];
  685. $smcFunc['db_free_result']($request);
  686. if (empty($messages))
  687. return array();
  688. // Find the most recent posts this user can see.
  689. $request = $smcFunc['db_query']('', '
  690. SELECT
  691. m.smileys_enabled, m.poster_time, m.id_msg, m.subject, m.body, m.id_topic, t.id_board,
  692. b.name AS bname, t.num_replies, m.id_member, m.icon, mf.id_member AS id_first_member,
  693. IFNULL(mem.real_name, m.poster_name) AS poster_name, mf.subject AS first_subject,
  694. IFNULL(memf.real_name, mf.poster_name) AS first_poster_name, mem.hide_email,
  695. IFNULL(mem.email_address, m.poster_email) AS poster_email, m.modified_time
  696. FROM {db_prefix}messages AS m
  697. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
  698. INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
  699. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  700. LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
  701. LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)
  702. WHERE m.id_msg IN ({array_int:message_list})
  703. ' . (empty($board) ? '' : 'AND t.id_board = {int:current_board}') . '
  704. ORDER BY m.id_msg DESC
  705. LIMIT {int:limit}',
  706. array(
  707. 'limit' => $_GET['limit'],
  708. 'current_board' => $board,
  709. 'message_list' => $messages,
  710. )
  711. );
  712. $data = array();
  713. while ($row = $smcFunc['db_fetch_assoc']($request))
  714. {
  715. // Limit the length of the message, if the option is set.
  716. if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen'])
  717. $row['body'] = strtr($smcFunc['substr'](str_replace('<br />', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br />')) . '...';
  718. $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
  719. censorText($row['body']);
  720. censorText($row['subject']);
  721. // Doesn't work as well as news, but it kinda does..
  722. if ($xml_format == 'rss' || $xml_format == 'rss2')
  723. $data[] = array(
  724. 'title' => $row['subject'],
  725. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  726. 'description' => cdata_parse($row['body']),
  727. 'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  728. 'category' => cdata_parse($row['bname']),
  729. 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0',
  730. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $row['poster_time']),
  731. 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
  732. );
  733. elseif ($xml_format == 'rdf')
  734. $data[] = array(
  735. 'title' => $row['subject'],
  736. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  737. 'description' => cdata_parse($row['body']),
  738. );
  739. elseif ($xml_format == 'atom')
  740. $data[] = array(
  741. 'title' => $row['subject'],
  742. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  743. 'summary' => cdata_parse($row['body']),
  744. 'category' => $row['bname'],
  745. 'author' => array(
  746. 'name' => $row['poster_name'],
  747. 'email' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null,
  748. 'uri' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''
  749. ),
  750. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['poster_time']),
  751. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']),
  752. 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
  753. );
  754. // A lot of information here. Should be enough to please the rss-ers.
  755. else
  756. $data[] = array(
  757. 'time' => htmlspecialchars(strip_tags(timeformat($row['poster_time']))),
  758. 'id' => $row['id_msg'],
  759. 'subject' => cdata_parse($row['subject']),
  760. 'body' => cdata_parse($row['body']),
  761. 'starter' => array(
  762. 'name' => cdata_parse($row['first_poster_name']),
  763. 'id' => $row['id_first_member'],
  764. 'link' => !empty($row['id_first_member']) ? $scripturl . '?action=profile;u=' . $row['id_first_member'] : ''
  765. ),
  766. 'poster' => array(
  767. 'name' => cdata_parse($row['poster_name']),
  768. 'id' => $row['id_member'],
  769. 'link' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''
  770. ),
  771. 'topic' => array(
  772. 'subject' => cdata_parse($row['first_subject']),
  773. 'id' => $row['id_topic'],
  774. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.new#new'
  775. ),
  776. 'board' => array(
  777. 'name' => cdata_parse($row['bname']),
  778. 'id' => $row['id_board'],
  779. 'link' => $scripturl . '?board=' . $row['id_board'] . '.0'
  780. ),
  781. 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']
  782. );
  783. }
  784. $smcFunc['db_free_result']($request);
  785. return $data;
  786. }
  787. /**
  788. * Get the profile information for member into an array,
  789. * which will be generated to match the xml_format.
  790. * @todo refactor.
  791. *
  792. * @param $xml_format
  793. * @return array, of profile data.
  794. */
  795. function getXmlProfile($xml_format)
  796. {
  797. global $scripturl, $memberContext, $user_profile, $modSettings, $user_info;
  798. // You must input a valid user....
  799. if (empty($_GET['u']) || loadMemberData((int) $_GET['u']) === false)
  800. return array();
  801. // Make sure the id is a number and not "I like trying to hack the database".
  802. $_GET['u'] = (int) $_GET['u'];
  803. // Load the member's contextual information!
  804. if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view_any'))
  805. return array();
  806. // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type.
  807. $profile = &$memberContext[$_GET['u']];
  808. if ($xml_format == 'rss' || $xml_format == 'rss2')
  809. $data = array(array(
  810. 'title' => cdata_parse($profile['name']),
  811. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  812. 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  813. 'comments' => $scripturl . '?action=pm;sa=send;u=' . $profile['id'],
  814. 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered']),
  815. 'guid' => $scripturl . '?action=profile;u=' . $profile['id'],
  816. ));
  817. elseif ($xml_format == 'rdf')
  818. $data = array(array(
  819. 'title' => cdata_parse($profile['name']),
  820. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  821. 'description' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  822. ));
  823. elseif ($xml_format == 'atom')
  824. $data[] = array(
  825. 'title' => cdata_parse($profile['name']),
  826. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  827. 'summary' => cdata_parse(isset($profile['group']) ? $profile['group'] : $profile['post_group']),
  828. 'author' => array(
  829. 'name' => $profile['real_name'],
  830. 'email' => in_array(showEmailAddress(!empty($profile['hide_email']), $profile['id']), array('yes', 'yes_permission_override')) ? $profile['email'] : null,
  831. 'uri' => !empty($profile['website']) ? $profile['website']['url'] : ''
  832. ),
  833. 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['date_registered']),
  834. 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $user_profile[$profile['id']]['last_login']),
  835. 'id' => $scripturl . '?action=profile;u=' . $profile['id'],
  836. 'logo' => !empty($profile['avatar']) ? $profile['avatar']['url'] : '',
  837. );
  838. else
  839. {
  840. $data = array(
  841. 'username' => $user_info['is_admin'] || $user_info['id'] == $profile['id'] ? cdata_parse($profile['username']) : '',
  842. 'name' => cdata_parse($profile['name']),
  843. 'link' => $scripturl . '?action=profile;u=' . $profile['id'],
  844. 'posts' => $profile['posts'],
  845. 'post-group' => cdata_parse($profile['post_group']),
  846. 'language' => cdata_parse($profile['language']),
  847. 'last-login' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['last_login']),
  848. 'registered' => gmdate('D, d M Y H:i:s \G\M\T', $user_profile[$profile['id']]['date_registered'])
  849. );
  850. // Everything below here might not be set, and thus maybe shouldn't be displayed.
  851. if ($profile['gender']['name'] != '')
  852. $data['gender'] = cdata_parse($profile['gender']['name']);
  853. if ($profile['avatar']['name'] != '')
  854. $data['avatar'] = $profile['avatar']['url'];
  855. // If they are online, show an empty tag... no reason to put anything inside it.
  856. if ($profile['online']['is_online'])
  857. $data['online'] = '';
  858. if ($profile['signature'] != '')
  859. $data['signature'] = cdata_parse($profile['signature']);
  860. if ($profile['blurb'] != '')
  861. $data['blurb'] = cdata_parse($profile['blurb']);
  862. if ($profile['location'] != '')
  863. $data['location'] = cdata_parse($profile['location']);
  864. if ($profile['title'] != '')
  865. $data['title'] = cdata_parse($profile['title']);
  866. if (!empty($profile['icq']['name']) && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  867. $data['icq'] = $profile['icq']['name'];
  868. if ($profile['aim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  869. $data['aim'] = $profile['aim']['name'];
  870. if ($profile['msn']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  871. $data['msn'] = $profile['msn']['name'];
  872. if ($profile['yim']['name'] != '' && !(!empty($modSettings['guest_hideContacts']) && $user_info['is_guest']))
  873. $data['yim'] = $profile['yim']['name'];
  874. if ($profile['website']['title'] != '')
  875. $data['website'] = array(
  876. 'title' => cdata_parse($profile['website']['title']),
  877. 'link' => $profile['website']['url']
  878. );
  879. if ($profile['group'] != '')
  880. $data['position'] = cdata_parse($profile['group']);
  881. if (!empty($modSettings['karmaMode']))
  882. $data['karma'] = array(
  883. 'good' => $profile['karma']['good'],
  884. 'bad' => $profile['karma']['bad']
  885. );
  886. if (in_array($profile['show_email'], array('yes', 'yes_permission_override')))
  887. $data['email'] = $profile['email'];
  888. if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000')
  889. {
  890. list ($birth_year, $birth_month, $birth_day) = sscanf($profile['birth_date'], '%d-%d-%d');
  891. $datearray = getdate(forum_time());
  892. $data['age'] = $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1);
  893. }
  894. }
  895. // Save some memory.
  896. unset($profile, $memberContext[$_GET['u']]);
  897. return $data;
  898. }
  899. ?>