Who.php 28 KB

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