2
0

Who.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. <?php
  2. /**
  3. * This file is mainly concerned with the Who's Online list.
  4. * Although, it also handles credits. :P
  5. *
  6. * Simple Machines Forum (SMF)
  7. *
  8. * @package SMF
  9. * @author Simple Machines http://www.simplemachines.org
  10. * @copyright 2013 Simple Machines and individual contributors
  11. * @license http://www.simplemachines.org/about/smf/license.php BSD
  12. *
  13. * @version 2.1 Alpha 1
  14. */
  15. if (!defined('SMF'))
  16. die('No direct access...');
  17. /**
  18. * Who's online, and what are they doing?
  19. * This function prepares the who's online data for the Who template.
  20. * It requires the who_view permission.
  21. * It is enabled with the who_enabled setting.
  22. * It is accessed via ?action=who.
  23. *
  24. * @uses Who template, main sub-template
  25. * @uses Who language file.
  26. */
  27. function Who()
  28. {
  29. global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc;
  30. // Permissions, permissions, permissions.
  31. isAllowedTo('who_view');
  32. // You can't do anything if this is off.
  33. if (empty($modSettings['who_enabled']))
  34. fatal_lang_error('who_off', false);
  35. // Load the 'Who' template.
  36. loadTemplate('Who');
  37. loadLanguage('Who');
  38. // Sort out... the column sorting.
  39. $sort_methods = array(
  40. 'user' => 'mem.real_name',
  41. 'time' => 'lo.log_time'
  42. );
  43. $show_methods = array(
  44. 'members' => '(lo.id_member != 0)',
  45. 'guests' => '(lo.id_member = 0)',
  46. 'all' => '1=1',
  47. );
  48. // Store the sort methods and the show types for use in the template.
  49. $context['sort_methods'] = array(
  50. 'user' => $txt['who_user'],
  51. 'time' => $txt['who_time'],
  52. );
  53. $context['show_methods'] = array(
  54. 'all' => $txt['who_show_all'],
  55. 'members' => $txt['who_show_members_only'],
  56. 'guests' => $txt['who_show_guests_only'],
  57. );
  58. // Can they see spiders too?
  59. if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
  60. {
  61. $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
  62. $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
  63. $context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
  64. }
  65. elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
  66. unset($_SESSION['who_online_filter']);
  67. // Does the user prefer a different sort direction?
  68. if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
  69. {
  70. $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
  71. $sort_method = $sort_methods[$_REQUEST['sort']];
  72. }
  73. // Did we set a preferred sort order earlier in the session?
  74. elseif (isset($_SESSION['who_online_sort_by']))
  75. {
  76. $context['sort_by'] = $_SESSION['who_online_sort_by'];
  77. $sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
  78. }
  79. // Default to last time online.
  80. else
  81. {
  82. $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
  83. $sort_method = 'lo.log_time';
  84. }
  85. $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
  86. $conditions = array();
  87. if (!allowedTo('moderate_forum'))
  88. $conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
  89. // Fallback to top filter?
  90. if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
  91. $_REQUEST['show'] = $_REQUEST['show_top'];
  92. // Does the user wish to apply a filter?
  93. if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
  94. {
  95. $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
  96. $conditions[] = $show_methods[$_REQUEST['show']];
  97. }
  98. // Perhaps we saved a filter earlier in the session?
  99. elseif (isset($_SESSION['who_online_filter']))
  100. {
  101. $context['show_by'] = $_SESSION['who_online_filter'];
  102. $conditions[] = $show_methods[$_SESSION['who_online_filter']];
  103. }
  104. else
  105. $context['show_by'] = $_SESSION['who_online_filter'] = 'all';
  106. // Get the total amount of members online.
  107. $request = $smcFunc['db_query']('', '
  108. SELECT COUNT(*)
  109. FROM {db_prefix}log_online AS lo
  110. LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? '
  111. WHERE ' . implode(' AND ', $conditions) : ''),
  112. array(
  113. )
  114. );
  115. list ($totalMembers) = $smcFunc['db_fetch_row']($request);
  116. $smcFunc['db_free_result']($request);
  117. // Prepare some page index variables.
  118. $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
  119. $context['start'] = $_REQUEST['start'];
  120. // Look for people online, provided they don't mind if you see they are.
  121. $request = $smcFunc['db_query']('', '
  122. SELECT
  123. lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name,
  124. lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
  125. lo.id_spider
  126. FROM {db_prefix}log_online AS lo
  127. LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
  128. LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? '
  129. WHERE ' . implode(' AND ', $conditions) : '') . '
  130. ORDER BY {raw:sort_method} {raw:sort_direction}
  131. LIMIT {int:offset}, {int:limit}',
  132. array(
  133. 'regular_member' => 0,
  134. 'sort_method' => $sort_method,
  135. 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC',
  136. 'offset' => $context['start'],
  137. 'limit' => $modSettings['defaultMaxMembers'],
  138. )
  139. );
  140. $context['members'] = array();
  141. $member_ids = array();
  142. $url_data = array();
  143. while ($row = $smcFunc['db_fetch_assoc']($request))
  144. {
  145. $actions = @unserialize($row['url']);
  146. if ($actions === false)
  147. continue;
  148. // Send the information to the template.
  149. $context['members'][$row['session']] = array(
  150. 'id' => $row['id_member'],
  151. 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '',
  152. // It is *going* to be today or yesterday, so why keep that information in there?
  153. 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')),
  154. 'timestamp' => forum_time(true, $row['log_time']),
  155. 'query' => $actions,
  156. 'is_hidden' => $row['show_online'] == 0,
  157. 'id_spider' => $row['id_spider'],
  158. 'color' => empty($row['online_color']) ? '' : $row['online_color']
  159. );
  160. $url_data[$row['session']] = array($row['url'], $row['id_member']);
  161. $member_ids[] = $row['id_member'];
  162. }
  163. $smcFunc['db_free_result']($request);
  164. // Load the user data for these members.
  165. loadMemberData($member_ids);
  166. // Load up the guest user.
  167. $memberContext[0] = array(
  168. 'id' => 0,
  169. 'name' => $txt['guest_title'],
  170. 'group' => $txt['guest_title'],
  171. 'href' => '',
  172. 'link' => $txt['guest_title'],
  173. 'email' => $txt['guest_title'],
  174. 'is_guest' => true
  175. );
  176. // Are we showing spiders?
  177. $spiderContext = array();
  178. if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
  179. {
  180. foreach (unserialize($modSettings['spider_name_cache']) as $id => $name)
  181. $spiderContext[$id] = array(
  182. 'id' => 0,
  183. 'name' => $name,
  184. 'group' => $txt['spiders'],
  185. 'href' => '',
  186. 'link' => $name,
  187. 'email' => $name,
  188. 'is_guest' => true
  189. );
  190. }
  191. $url_data = determineActions($url_data);
  192. // Setup the linktree and page title (do it down here because the language files are now loaded..)
  193. $context['page_title'] = $txt['who_title'];
  194. $context['linktree'][] = array(
  195. 'url' => $scripturl . '?action=who',
  196. 'name' => $txt['who_title']
  197. );
  198. // Put it in the context variables.
  199. foreach ($context['members'] as $i => $member)
  200. {
  201. if ($member['id'] != 0)
  202. $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
  203. // Keep the IP that came from the database.
  204. $memberContext[$member['id']]['ip'] = $member['ip'];
  205. $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
  206. if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
  207. $context['members'][$i] += $spiderContext[$member['id_spider']];
  208. else
  209. $context['members'][$i] += $memberContext[$member['id']];
  210. }
  211. // Some people can't send personal messages...
  212. $context['can_send_pm'] = allowedTo('pm_send');
  213. $context['can_send_email'] = allowedTo('send_email_to_members');
  214. // any profile fields disabled?
  215. $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
  216. }
  217. /**
  218. * This function determines the actions of the members passed in urls.
  219. *
  220. * Adding actions to the Who's Online list:
  221. * Adding actions to this list is actually relatively easy...
  222. * - for actions anyone should be able to see, just add a string named whoall_ACTION.
  223. * (where ACTION is the action used in index.php.)
  224. * - for actions that have a subaction which should be represented differently, use whoall_ACTION_SUBACTION.
  225. * - for actions that include a topic, and should be restricted, use whotopic_ACTION.
  226. * - for actions that use a message, by msg or quote, use whopost_ACTION.
  227. * - for administrator-only actions, use whoadmin_ACTION.
  228. * - for actions that should be viewable only with certain permissions,
  229. * use whoallow_ACTION and add a list of possible permissions to the
  230. * $allowedActions array, using ACTION as the key.
  231. *
  232. * @param mixed $urls a single url (string) or an array of arrays, each inner array being (serialized request data, id_member)
  233. * @param string $preferred_prefix = false
  234. * @return array, an array of descriptions if you passed an array, otherwise the string describing their current location.
  235. */
  236. function determineActions($urls, $preferred_prefix = false)
  237. {
  238. global $txt, $user_info, $modSettings, $smcFunc, $context;
  239. if (!allowedTo('who_view'))
  240. return array();
  241. loadLanguage('Who');
  242. // Actions that require a specific permission level.
  243. $allowedActions = array(
  244. 'admin' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'admin_forum', 'manage_permissions', 'send_mail', 'manage_attachments', 'manage_smileys', 'manage_boards', 'edit_news'),
  245. 'ban' => array('manage_bans'),
  246. 'boardrecount' => array('admin_forum'),
  247. 'calendar' => array('calendar_view'),
  248. 'editnews' => array('edit_news'),
  249. 'mailing' => array('send_mail'),
  250. 'maintain' => array('admin_forum'),
  251. 'manageattachments' => array('manage_attachments'),
  252. 'manageboards' => array('manage_boards'),
  253. 'mlist' => array('view_mlist'),
  254. 'moderate' => array('access_mod_center', 'moderate_forum', 'manage_membergroups'),
  255. 'optimizetables' => array('admin_forum'),
  256. 'repairboards' => array('admin_forum'),
  257. 'search' => array('search_posts'),
  258. 'search2' => array('search_posts'),
  259. 'setcensor' => array('moderate_forum'),
  260. 'setreserve' => array('moderate_forum'),
  261. 'stats' => array('view_stats'),
  262. 'viewErrorLog' => array('admin_forum'),
  263. 'viewmembers' => array('moderate_forum'),
  264. );
  265. if (!is_array($urls))
  266. $url_list = array(array($urls, $user_info['id']));
  267. else
  268. $url_list = $urls;
  269. // These are done to later query these in large chunks. (instead of one by one.)
  270. $topic_ids = array();
  271. $profile_ids = array();
  272. $board_ids = array();
  273. $data = array();
  274. foreach ($url_list as $k => $url)
  275. {
  276. // Get the request parameters..
  277. $actions = @unserialize($url[0]);
  278. if ($actions === false)
  279. continue;
  280. // If it's the admin or moderation center, and there is an area set, use that instead.
  281. if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
  282. $actions['action'] = $actions['area'];
  283. // Check if there was no action or the action is display.
  284. if (!isset($actions['action']) || $actions['action'] == 'display')
  285. {
  286. // It's a topic! Must be!
  287. if (isset($actions['topic']))
  288. {
  289. // Assume they can't view it, and queue it up for later.
  290. $data[$k] = $txt['who_hidden'];
  291. $topic_ids[(int) $actions['topic']][$k] = $txt['who_topic'];
  292. }
  293. // It's a board!
  294. elseif (isset($actions['board']))
  295. {
  296. // Hide first, show later.
  297. $data[$k] = $txt['who_hidden'];
  298. $board_ids[$actions['board']][$k] = $txt['who_board'];
  299. }
  300. // It's the board index!! It must be!
  301. else
  302. $data[$k] = $txt['who_index'];
  303. }
  304. // Probably an error or some goon?
  305. elseif ($actions['action'] == '')
  306. $data[$k] = $txt['who_index'];
  307. // Some other normal action...?
  308. else
  309. {
  310. // Viewing/editing a profile.
  311. if ($actions['action'] == 'profile')
  312. {
  313. // Whose? Their own?
  314. if (empty($actions['u']))
  315. $actions['u'] = $url[1];
  316. $data[$k] = $txt['who_hidden'];
  317. $profile_ids[(int) $actions['u']][$k] = $actions['action'] == 'profile' ? $txt['who_viewprofile'] : $txt['who_profile'];
  318. }
  319. elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
  320. {
  321. $data[$k] = $txt['who_hidden'];
  322. $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
  323. }
  324. // A subaction anyone can view... if the language string is there, show it.
  325. elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
  326. $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
  327. // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
  328. elseif (isset($txt['whoall_' . $actions['action']]))
  329. $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
  330. // Viewable if and only if they can see the board...
  331. elseif (isset($txt['whotopic_' . $actions['action']]))
  332. {
  333. // Find out what topic they are accessing.
  334. $topic = (int) (isset($actions['topic']) ? $actions['topic'] : (isset($actions['from']) ? $actions['from'] : 0));
  335. $data[$k] = $txt['who_hidden'];
  336. $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
  337. }
  338. elseif (isset($txt['whopost_' . $actions['action']]))
  339. {
  340. // Find out what message they are accessing.
  341. $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
  342. $result = $smcFunc['db_query']('', '
  343. SELECT m.id_topic, m.subject
  344. FROM {db_prefix}messages AS m
  345. INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  346. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
  347. WHERE m.id_msg = {int:id_msg}
  348. AND {query_see_board}' . ($modSettings['postmod_active'] ? '
  349. AND m.approved = {int:is_approved}' : '') . '
  350. LIMIT 1',
  351. array(
  352. 'is_approved' => 1,
  353. 'id_msg' => $msgid,
  354. )
  355. );
  356. list ($id_topic, $subject) = $smcFunc['db_fetch_row']($result);
  357. $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
  358. $smcFunc['db_free_result']($result);
  359. if (empty($id_topic))
  360. $data[$k] = $txt['who_hidden'];
  361. }
  362. // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
  363. elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
  364. $data[$k] = $txt['whoadmin_' . $actions['action']];
  365. // Viewable by permission level.
  366. elseif (isset($allowedActions[$actions['action']]))
  367. {
  368. if (allowedTo($allowedActions[$actions['action']]))
  369. $data[$k] = $txt['whoallow_' . $actions['action']];
  370. elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
  371. $data[$k] = $txt['who_moderate'];
  372. elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
  373. $data[$k] = $txt['who_admin'];
  374. else
  375. $data[$k] = $txt['who_hidden'];
  376. }
  377. elseif (!empty($actions['action']))
  378. $data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
  379. else
  380. $data[$k] = $txt['who_unknown'];
  381. }
  382. // Maybe the action is integrated into another system?
  383. if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
  384. {
  385. foreach ($integrate_actions as $integrate_action)
  386. {
  387. if (!empty($integrate_action))
  388. {
  389. $data[$k] = $integrate_action;
  390. break;
  391. }
  392. }
  393. }
  394. }
  395. // Load topic names.
  396. if (!empty($topic_ids))
  397. {
  398. $result = $smcFunc['db_query']('', '
  399. SELECT t.id_topic, m.subject
  400. FROM {db_prefix}topics AS t
  401. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  402. INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
  403. WHERE {query_see_board}
  404. AND t.id_topic IN ({array_int:topic_list})' . ($modSettings['postmod_active'] ? '
  405. AND t.approved = {int:is_approved}' : '') . '
  406. LIMIT {int:limit}',
  407. array(
  408. 'topic_list' => array_keys($topic_ids),
  409. 'is_approved' => 1,
  410. 'limit' => count($topic_ids),
  411. )
  412. );
  413. while ($row = $smcFunc['db_fetch_assoc']($result))
  414. {
  415. // Show the topic's subject for each of the actions.
  416. foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
  417. $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
  418. }
  419. $smcFunc['db_free_result']($result);
  420. }
  421. // Load board names.
  422. if (!empty($board_ids))
  423. {
  424. $result = $smcFunc['db_query']('', '
  425. SELECT b.id_board, b.name
  426. FROM {db_prefix}boards AS b
  427. WHERE {query_see_board}
  428. AND b.id_board IN ({array_int:board_list})
  429. LIMIT ' . count($board_ids),
  430. array(
  431. 'board_list' => array_keys($board_ids),
  432. )
  433. );
  434. while ($row = $smcFunc['db_fetch_assoc']($result))
  435. {
  436. // Put the board name into the string for each member...
  437. foreach ($board_ids[$row['id_board']] as $k => $session_text)
  438. $data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
  439. }
  440. $smcFunc['db_free_result']($result);
  441. }
  442. // Load member names for the profile.
  443. if (!empty($profile_ids) && (allowedTo('profile_view_any') || allowedTo('profile_view_own')))
  444. {
  445. $result = $smcFunc['db_query']('', '
  446. SELECT id_member, real_name
  447. FROM {db_prefix}members
  448. WHERE id_member IN ({array_int:member_list})
  449. LIMIT ' . count($profile_ids),
  450. array(
  451. 'member_list' => array_keys($profile_ids),
  452. )
  453. );
  454. while ($row = $smcFunc['db_fetch_assoc']($result))
  455. {
  456. // If they aren't allowed to view this person's profile, skip it.
  457. if (!allowedTo('profile_view_any') && $user_info['id'] != $row['id_member'])
  458. continue;
  459. // Set their action on each - session/text to sprintf.
  460. foreach ($profile_ids[$row['id_member']] as $k => $session_text)
  461. $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
  462. }
  463. $smcFunc['db_free_result']($result);
  464. }
  465. if (!is_array($urls))
  466. return isset($data[0]) ? $data[0] : false;
  467. else
  468. return $data;
  469. }
  470. /**
  471. * It prepares credit and copyright information for the credits page or the admin page
  472. *
  473. * @param bool $in_admin = false, if parameter is true the it will not load the sub-template nor the template file
  474. */
  475. function Credits($in_admin = false)
  476. {
  477. global $context, $smcFunc, $modSettings, $forum_copyright, $forum_version, $boardurl, $txt, $user_info;
  478. // Don't blink. Don't even blink. Blink and you're dead.
  479. loadLanguage('Who');
  480. if($in_admin)
  481. {
  482. $context[$context['admin_menu_name']]['tab_data'] = array(
  483. 'title' => $txt['support_credits_title'],
  484. 'help' => '',
  485. 'description' => '',
  486. );
  487. }
  488. $context['credits'] = array(
  489. array(
  490. 'pretext' => $txt['credits_intro'],
  491. 'title' => $txt['credits_team'],
  492. 'groups' => array(
  493. array(
  494. 'title' => $txt['credits_groups_pm'],
  495. 'members' => array(
  496. 'Michael &quot;Oldiesmann&quot; Eshom',
  497. ),
  498. ),
  499. array(
  500. 'title' => $txt['credits_groups_dev'],
  501. 'members' => array(
  502. // Lead Developer
  503. // 'Steven &quot;Fustrate&quot; Hoffman',
  504. // Developers
  505. 'Brad &quot;IchBin&trade;&quot; Grow',
  506. 'emanuele',
  507. 'Norv',
  508. // 'Spuds', // Doesn't want to be listed here
  509. // Former Developers
  510. 'Aaron van Geffen',
  511. 'Antechinus',
  512. 'Bjoern &quot;Bloc&quot; Kristiansen',
  513. 'Hendrik Jan &quot;Compuart&quot; Visser',
  514. 'Juan &quot;JayBachatero&quot; Hernandez',
  515. 'Karl &quot;RegularExpression&quot; Benson',
  516. $user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf': 'Grudge',
  517. 'Michael &quot;Thantos&quot; Miller',
  518. 'Selman &quot;[SiNaN]&quot; Eser',
  519. 'Theodore &quot;Orstio&quot; Hildebrandt',
  520. 'Thorsten &quot;TE&quot; Eurich',
  521. 'winrules',
  522. ),
  523. ),
  524. array(
  525. 'title' => $txt['credits_groups_support'],
  526. 'members' => array(
  527. // Lead Support Specialist
  528. 'Kat',
  529. // Support Specialists
  530. 'Aleksi &quot;Lex&quot; Kilpinen',
  531. 'Bigguy',
  532. 'Chas Large',
  533. 'Duncan85',
  534. 'JimM',
  535. 'Mashby',
  536. 'Old Fossil',
  537. 'Yoshi',
  538. 'ziycon',
  539. // Former Support Specialists
  540. 'CapadY',
  541. 'gbsothere',
  542. 'Kevin &quot;greyknight17&quot; Hou',
  543. 'Michele &quot;Illori&quot; Davis',
  544. 'S-Ace',
  545. 'Wade &quot;s&eta;&sigma;&omega;&quot; Poulsen',
  546. 'xenovanis',
  547. ),
  548. ),
  549. array(
  550. 'title' => $txt['credits_groups_customize'],
  551. 'members' => array(
  552. // Lead Customizer
  553. 'Gary M. Gadsdon',
  554. // Customizers
  555. 'Jessica Gonz&aacute;lez',
  556. 'Kays',
  557. 'Matthew &quot;Labradoodle-360&quot; Kerle',
  558. 'Ricky.',
  559. // Former Customizers
  560. 'Brannon &quot;B&quot; Hall',
  561. 'Joey &quot;Tyrsson&quot; Smith',
  562. ),
  563. ),
  564. array(
  565. 'title' => $txt['credits_groups_docs'],
  566. 'members' => array(
  567. // Doc Coordinator
  568. 'AngelinaBelle',
  569. // Doc Writers
  570. 'Graeme Spence',
  571. 'Joshua &quot;groundup&quot; Dickerson',
  572. ),
  573. ),
  574. array(
  575. 'title' => $txt['credits_groups_internationalizers'],
  576. 'members' => array(
  577. // Lead Localizer
  578. 'Nikola &quot;Dzonny&quot; Novakovi&cacute;',
  579. // Localizers
  580. 'Dr. Deejay',
  581. 'Relyana',
  582. ),
  583. ),
  584. array(
  585. 'title' => $txt['credits_groups_marketing'],
  586. 'members' => array(
  587. // Marketing Coordinator
  588. 'Ralph &quot;[n3rve]&quot; Otowo',
  589. // Marketing
  590. 'Bryan &quot;Runic&quot; Deakin',
  591. 'Adish &quot;(F.L.A.M.E.R)&quot; Patel',
  592. // Former Marketing
  593. 'Kindred',
  594. 'Marcus &quot;c&sigma;&sigma;&#1082;&iota;&#1108; &#1084;&sigma;&eta;&#1109;&#1090;&#1108;&#1103;&quot; Forsberg',
  595. ),
  596. ),
  597. array(
  598. 'title' => $txt['credits_groups_site'],
  599. 'members' => array(
  600. 'Jeremy &quot;SleePy&quot; Darwood',
  601. ),
  602. ),
  603. array(
  604. 'title' => $txt['credits_groups_servers'],
  605. 'members' => array(
  606. 'Derek Schwab',
  607. 'Liroy &quot;CoreISP&quot; van Hoewijk',
  608. ),
  609. ),
  610. ),
  611. ),
  612. );
  613. // Give the translators some credit for their hard work.
  614. if (!empty($txt['translation_credits']))
  615. $context['credits'][] = array(
  616. 'title' => $txt['credits_groups_translation'],
  617. 'groups' => array(
  618. array(
  619. 'title' => $txt['credits_groups_translation'],
  620. 'members' => $txt['translation_credits'],
  621. ),
  622. ),
  623. );
  624. $context['credits'][] = array(
  625. 'title' => $txt['credits_special'],
  626. 'posttext' => $txt['credits_anyone'],
  627. 'groups' => array(
  628. array(
  629. 'title' => $txt['credits_groups_consultants'],
  630. 'members' => array(
  631. 'Brett Flannigan',
  632. 'Mark Rose',
  633. 'Ren&eacute;-Gilles &quot;Nao &#23578;&quot; Deberdt',
  634. ),
  635. ),
  636. array(
  637. 'title' => $txt['credits_groups_beta'],
  638. 'members' => array(
  639. $txt['credits_beta_message'],
  640. ),
  641. ),
  642. array(
  643. 'title' => $txt['credits_groups_translators'],
  644. 'members' => array(
  645. $txt['credits_translators_message'],
  646. ),
  647. ),
  648. array(
  649. 'title' => $txt['credits_groups_founder'],
  650. 'members' => array(
  651. 'Unknown W. &quot;[Unknown]&quot; Brackets',
  652. ),
  653. ),
  654. array(
  655. 'title' => $txt['credits_groups_orignal_pm'],
  656. 'members' => array(
  657. 'Jeff Lewis',
  658. 'Joseph Fung',
  659. 'David Recordon',
  660. ),
  661. ),
  662. ),
  663. );
  664. // Give credit to any graphic library's, software library's, plugins etc
  665. $context['credits_software_graphics'] = array(
  666. 'graphics' => array(
  667. '<a href="http://p.yusukekamiyamane.com/">Fugue Icons</a> | &copy; 2012 Yusuke Kamiyamane | These icons are licensed under a Creative Commons Attribution 3.0 License',
  668. '<a href="http://www.oxygen-icons.org/">Oxygen Icons</a> | These icons are licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>',
  669. ),
  670. 'software' => array(
  671. '<a href="http://jquery.org/">JQuery</a> | &copy; John Resig | Licensed under <a href="http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt">The MIT License (MIT)</a>',
  672. '<a href="http://cherne.net/brian/resources/jquery.hoverIntent.html">hoverIntent</a> | &copy; Brian Cherne | Licensed under <a href="http://en.wikipedia.org/wiki/MIT_License">The MIT License (MIT)</a>',
  673. '<a href="http://users.tpg.com.au/j_birch/plugins/superfish/">Superfish</a> | &copy; Joel Birch | Licensed under <a href="http://en.wikipedia.org/wiki/MIT_License">The MIT License (MIT)</a>',
  674. '<a href="http://www.sceditor.com/">SCEditor</a> | &copy; Sam Clarke | Licensed under <a href="http://en.wikipedia.org/wiki/MIT_License">The MIT License (MIT)</a>',
  675. '<a href="http://wayfarerweb.com/jquery/plugins/animadrag/">animaDrag</a> | &copy; Abel Mohler | Licensed under <a href="http://en.wikipedia.org/wiki/MIT_License">The MIT License (MIT)</a>',
  676. ),
  677. 'fonts' => array(
  678. '<a href="http://openfontlibrary.org/en/font/anonymous-pro"> Anonymous Pro</a> |&copy; 2009 | This font is licensed under the SIL Open Font License, Version 1.1',
  679. '<a href="http://openfontlibrary.org/en/font/consolamono"> ConsolaMono</a> |&copy; 2012 | This font is licensed under the SIL Open Font License, Version 1.1',
  680. '<a href="http://openfontlibrary.org/en/font/phennig"> Phennig</a> |&copy; 2009-2012 | This font is licensed under the SIL Open Font License, Version 1.1',
  681. ),
  682. );
  683. // Support for mods that use the <credits> tag via the package manager
  684. $context['credits_modifications'] = array();
  685. if (($mods = cache_get_data('mods_credits', 86400)) === null)
  686. {
  687. $mods = array();
  688. $request = $smcFunc['db_query']('substring', '
  689. SELECT version, name, credits
  690. FROM {db_prefix}log_packages
  691. WHERE install_state = {int:installed_mods}
  692. AND credits != {string:empty}
  693. AND SUBSTRING(filename, 1, 9) != {string:patch_name}',
  694. array(
  695. 'installed_mods' => 1,
  696. 'patch_name' => 'smf_patch',
  697. 'empty' => '',
  698. )
  699. );
  700. while ($row = $smcFunc['db_fetch_assoc']($request))
  701. {
  702. $credit_info = unserialize($row['credits']);
  703. $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' &copy; ' . $smcFunc['htmlspecialchars']($credit_info['copyright']);
  704. $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . $smcFunc['htmlspecialchars']($credit_info['license']);
  705. $version = $txt['credits_version'] . ' ' . $row['version'];
  706. $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version;
  707. // build this one out and stash it away
  708. $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
  709. $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : '');
  710. }
  711. cache_put_data('mods_credits', $mods, 86400);
  712. }
  713. $context['credits_modifications'] = $mods;
  714. $context['copyrights'] = array(
  715. 'smf' => sprintf($forum_copyright, $forum_version),
  716. /* Modification Authors: You may add a copyright statement to this array for your mods.
  717. Copyright statements should be in the form of a value only without a array key. I.E.:
  718. 'Some Mod by Thantos &copy; 2010',
  719. $txt['some_mod_copyright'],
  720. */
  721. 'mods' => array(
  722. ),
  723. );
  724. // Support for those that want to use a hook as well
  725. call_integration_hook('integrate_credits');
  726. if (!$in_admin)
  727. {
  728. loadTemplate('Who');
  729. $context['sub_template'] = 'credits';
  730. $context['robot_no_index'] = true;
  731. $context['page_title'] = $txt['credits'];
  732. }
  733. }
  734. ?>