PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/sources/controllers/Who.controller.php

https://github.com/Arantor/Elkarte
PHP | 632 lines | 455 code | 59 blank | 118 comment | 81 complexity | 91940f4b50459a0759a62433bd5b6232 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /**
  3. * @name ElkArte Forum
  4. * @copyright ElkArte Forum contributors
  5. * @license BSD http://opensource.org/licenses/BSD-3-Clause
  6. *
  7. * This software is a derived product, based on:
  8. *
  9. * Simple Machines Forum (SMF)
  10. * copyright: 2011 Simple Machines (http://www.simplemachines.org)
  11. * license: BSD, See included LICENSE.TXT for terms and conditions.
  12. *
  13. * @version 1.0 Alpha
  14. *
  15. * This file is mainly concerned with the Who's Online list.
  16. * Although, it also handles credits. :P
  17. *
  18. */
  19. if (!defined('ELKARTE'))
  20. die('No access...');
  21. /**
  22. * Who's online, and what are they doing?
  23. * This function prepares the who's online data for the Who template.
  24. * It requires the who_view permission.
  25. * It is enabled with the who_enabled setting.
  26. * It is accessed via ?action=who.
  27. *
  28. * @uses Who template, main sub-template
  29. * @uses Who language file.
  30. */
  31. function action_who()
  32. {
  33. global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc;
  34. // Permissions, permissions, permissions.
  35. isAllowedTo('who_view');
  36. // You can't do anything if this is off.
  37. if (empty($modSettings['who_enabled']))
  38. fatal_lang_error('who_off', false);
  39. // Load the 'Who' template.
  40. loadTemplate('Who');
  41. loadLanguage('Who');
  42. // Sort out... the column sorting.
  43. $sort_methods = array(
  44. 'user' => 'mem.real_name',
  45. 'time' => 'lo.log_time'
  46. );
  47. $show_methods = array(
  48. 'members' => '(lo.id_member != 0)',
  49. 'guests' => '(lo.id_member = 0)',
  50. 'all' => '1=1',
  51. );
  52. // Store the sort methods and the show types for use in the template.
  53. $context['sort_methods'] = array(
  54. 'user' => $txt['who_user'],
  55. 'time' => $txt['who_time'],
  56. );
  57. $context['show_methods'] = array(
  58. 'all' => $txt['who_show_all'],
  59. 'members' => $txt['who_show_members_only'],
  60. 'guests' => $txt['who_show_guests_only'],
  61. );
  62. // Can they see spiders too?
  63. if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
  64. {
  65. $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
  66. $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
  67. $context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
  68. }
  69. elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
  70. unset($_SESSION['who_online_filter']);
  71. // Does the user prefer a different sort direction?
  72. if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
  73. {
  74. $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
  75. $sort_method = $sort_methods[$_REQUEST['sort']];
  76. }
  77. // Did we set a preferred sort order earlier in the session?
  78. elseif (isset($_SESSION['who_online_sort_by']))
  79. {
  80. $context['sort_by'] = $_SESSION['who_online_sort_by'];
  81. $sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
  82. }
  83. // Default to last time online.
  84. else
  85. {
  86. $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
  87. $sort_method = 'lo.log_time';
  88. }
  89. $context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
  90. $conditions = array();
  91. if (!allowedTo('moderate_forum'))
  92. $conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
  93. // Fallback to top filter?
  94. if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
  95. $_REQUEST['show'] = $_REQUEST['show_top'];
  96. // Does the user wish to apply a filter?
  97. if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
  98. {
  99. $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
  100. $conditions[] = $show_methods[$_REQUEST['show']];
  101. }
  102. // Perhaps we saved a filter earlier in the session?
  103. elseif (isset($_SESSION['who_online_filter']))
  104. {
  105. $context['show_by'] = $_SESSION['who_online_filter'];
  106. $conditions[] = $show_methods[$_SESSION['who_online_filter']];
  107. }
  108. else
  109. $context['show_by'] = $_SESSION['who_online_filter'] = 'all';
  110. // Get the total amount of members online.
  111. $request = $smcFunc['db_query']('', '
  112. SELECT COUNT(*)
  113. FROM {db_prefix}log_online AS lo
  114. LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? '
  115. WHERE ' . implode(' AND ', $conditions) : ''),
  116. array(
  117. )
  118. );
  119. list ($totalMembers) = $smcFunc['db_fetch_row']($request);
  120. $smcFunc['db_free_result']($request);
  121. // Prepare some page index variables.
  122. $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']);
  123. $context['start'] = $_REQUEST['start'];
  124. // Look for people online, provided they don't mind if you see they are.
  125. $request = $smcFunc['db_query']('', '
  126. SELECT
  127. lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name,
  128. lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
  129. lo.id_spider
  130. FROM {db_prefix}log_online AS lo
  131. LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
  132. 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) ? '
  133. WHERE ' . implode(' AND ', $conditions) : '') . '
  134. ORDER BY {raw:sort_method} {raw:sort_direction}
  135. LIMIT {int:offset}, {int:limit}',
  136. array(
  137. 'regular_member' => 0,
  138. 'sort_method' => $sort_method,
  139. 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC',
  140. 'offset' => $context['start'],
  141. 'limit' => $modSettings['defaultMaxMembers'],
  142. )
  143. );
  144. $context['members'] = array();
  145. $member_ids = array();
  146. $url_data = array();
  147. while ($row = $smcFunc['db_fetch_assoc']($request))
  148. {
  149. $actions = @unserialize($row['url']);
  150. if ($actions === false)
  151. continue;
  152. // Send the information to the template.
  153. $context['members'][$row['session']] = array(
  154. 'id' => $row['id_member'],
  155. 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '',
  156. // It is *going* to be today or yesterday, so why keep that information in there?
  157. 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')),
  158. 'timestamp' => forum_time(true, $row['log_time']),
  159. 'query' => $actions,
  160. 'is_hidden' => $row['show_online'] == 0,
  161. 'id_spider' => $row['id_spider'],
  162. 'color' => empty($row['online_color']) ? '' : $row['online_color']
  163. );
  164. $url_data[$row['session']] = array($row['url'], $row['id_member']);
  165. $member_ids[] = $row['id_member'];
  166. }
  167. $smcFunc['db_free_result']($request);
  168. // Load the user data for these members.
  169. loadMemberData($member_ids);
  170. // Load up the guest user.
  171. $memberContext[0] = array(
  172. 'id' => 0,
  173. 'name' => $txt['guest_title'],
  174. 'group' => $txt['guest_title'],
  175. 'href' => '',
  176. 'link' => $txt['guest_title'],
  177. 'email' => $txt['guest_title'],
  178. 'is_guest' => true
  179. );
  180. // Are we showing spiders?
  181. $spiderContext = array();
  182. if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
  183. {
  184. foreach (unserialize($modSettings['spider_name_cache']) as $id => $name)
  185. $spiderContext[$id] = array(
  186. 'id' => 0,
  187. 'name' => $name,
  188. 'group' => $txt['spiders'],
  189. 'href' => '',
  190. 'link' => $name,
  191. 'email' => $name,
  192. 'is_guest' => true
  193. );
  194. }
  195. $url_data = determineActions($url_data);
  196. // Setup the linktree and page title (do it down here because the language files are now loaded..)
  197. $context['page_title'] = $txt['who_title'];
  198. $context['linktree'][] = array(
  199. 'url' => $scripturl . '?action=who',
  200. 'name' => $txt['who_title']
  201. );
  202. // Put it in the context variables.
  203. foreach ($context['members'] as $i => $member)
  204. {
  205. if ($member['id'] != 0)
  206. $member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
  207. // Keep the IP that came from the database.
  208. $memberContext[$member['id']]['ip'] = $member['ip'];
  209. $context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
  210. if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
  211. $context['members'][$i] += $spiderContext[$member['id_spider']];
  212. else
  213. $context['members'][$i] += $memberContext[$member['id']];
  214. }
  215. // Some people can't send personal messages...
  216. $context['can_send_pm'] = allowedTo('pm_send');
  217. $context['can_send_email'] = allowedTo('send_email_to_members');
  218. // any profile fields disabled?
  219. $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
  220. }
  221. /**
  222. * This function determines the actions of the members passed in urls.
  223. *
  224. * Adding actions to the Who's Online list:
  225. * Adding actions to this list is actually relatively easy...
  226. * - for actions anyone should be able to see, just add a string named whoall_ACTION.
  227. * (where ACTION is the action used in index.php.)
  228. * - for actions that have a subaction which should be represented differently, use whoall_ACTION_SUBACTION.
  229. * - for actions that include a topic, and should be restricted, use whotopic_ACTION.
  230. * - for actions that use a message, by msg or quote, use whopost_ACTION.
  231. * - for administrator-only actions, use whoadmin_ACTION.
  232. * - for actions that should be viewable only with certain permissions,
  233. * use whoallow_ACTION and add a list of possible permissions to the
  234. * $allowedActions array, using ACTION as the key.
  235. *
  236. * @param mixed $urls a single url (string) or an array of arrays, each inner array being (serialized request data, id_member)
  237. * @param string $preferred_prefix = false
  238. * @return array, an array of descriptions if you passed an array, otherwise the string describing their current location.
  239. */
  240. function determineActions($urls, $preferred_prefix = false)
  241. {
  242. global $txt, $user_info, $modSettings, $smcFunc, $context;
  243. if (!allowedTo('who_view'))
  244. return array();
  245. loadLanguage('Who');
  246. // Actions that require a specific permission level.
  247. $allowedActions = array(
  248. 'admin' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'admin_forum', 'manage_permissions', 'send_mail', 'manage_attachments', 'manage_smileys', 'manage_boards', 'edit_news'),
  249. 'ban' => array('manage_bans'),
  250. 'boardrecount' => array('admin_forum'),
  251. 'calendar' => array('calendar_view'),
  252. 'editnews' => array('edit_news'),
  253. 'mailing' => array('send_mail'),
  254. 'maintain' => array('admin_forum'),
  255. 'manageattachments' => array('manage_attachments'),
  256. 'manageboards' => array('manage_boards'),
  257. 'memberlist' => array('view_mlist'),
  258. 'moderate' => array('access_mod_center', 'moderate_forum', 'manage_membergroups'),
  259. 'optimizetables' => array('admin_forum'),
  260. 'repairboards' => array('admin_forum'),
  261. 'search' => array('search_posts'),
  262. 'search2' => array('search_posts'),
  263. 'setcensor' => array('moderate_forum'),
  264. 'setreserve' => array('moderate_forum'),
  265. 'stats' => array('view_stats'),
  266. 'viewErrorLog' => array('admin_forum'),
  267. 'viewmembers' => array('moderate_forum'),
  268. );
  269. if (!is_array($urls))
  270. $url_list = array(array($urls, $user_info['id']));
  271. else
  272. $url_list = $urls;
  273. // These are done to later query these in large chunks. (instead of one by one.)
  274. $topic_ids = array();
  275. $profile_ids = array();
  276. $board_ids = array();
  277. $data = array();
  278. foreach ($url_list as $k => $url)
  279. {
  280. // Get the request parameters..
  281. $actions = @unserialize($url[0]);
  282. if ($actions === false)
  283. continue;
  284. // If it's the admin or moderation center, and there is an area set, use that instead.
  285. if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
  286. $actions['action'] = $actions['area'];
  287. // Check if there was no action or the action is display.
  288. if (!isset($actions['action']) || $actions['action'] == 'display')
  289. {
  290. // It's a topic! Must be!
  291. if (isset($actions['topic']))
  292. {
  293. // Assume they can't view it, and queue it up for later.
  294. $data[$k] = $txt['who_hidden'];
  295. $topic_ids[(int) $actions['topic']][$k] = $txt['who_topic'];
  296. }
  297. // It's a board!
  298. elseif (isset($actions['board']))
  299. {
  300. // Hide first, show later.
  301. $data[$k] = $txt['who_hidden'];
  302. $board_ids[$actions['board']][$k] = $txt['who_board'];
  303. }
  304. // It's the board index!! It must be!
  305. else
  306. $data[$k] = $txt['who_index'];
  307. }
  308. // Probably an error or some goon?
  309. elseif ($actions['action'] == '')
  310. $data[$k] = $txt['who_index'];
  311. // Some other normal action...?
  312. else
  313. {
  314. // Viewing/editing a profile.
  315. if ($actions['action'] == 'profile')
  316. {
  317. // Whose? Their own?
  318. if (empty($actions['u']))
  319. $actions['u'] = $url[1];
  320. $data[$k] = $txt['who_hidden'];
  321. $profile_ids[(int) $actions['u']][$k] = $actions['action'] == 'profile' ? $txt['who_viewprofile'] : $txt['who_profile'];
  322. }
  323. elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
  324. {
  325. $data[$k] = $txt['who_hidden'];
  326. $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
  327. }
  328. // A subaction anyone can view... if the language string is there, show it.
  329. elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
  330. $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']];
  331. // An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
  332. elseif (isset($txt['whoall_' . $actions['action']]))
  333. $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
  334. // Viewable if and only if they can see the board...
  335. elseif (isset($txt['whotopic_' . $actions['action']]))
  336. {
  337. // Find out what topic they are accessing.
  338. $topic = (int) (isset($actions['topic']) ? $actions['topic'] : (isset($actions['from']) ? $actions['from'] : 0));
  339. $data[$k] = $txt['who_hidden'];
  340. $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
  341. }
  342. elseif (isset($txt['whopost_' . $actions['action']]))
  343. {
  344. // Find out what message they are accessing.
  345. $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
  346. $result = $smcFunc['db_query']('', '
  347. SELECT m.id_topic, m.subject
  348. FROM {db_prefix}messages AS m
  349. INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  350. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
  351. WHERE m.id_msg = {int:id_msg}
  352. AND {query_see_board}' . ($modSettings['postmod_active'] ? '
  353. AND m.approved = {int:is_approved}' : '') . '
  354. LIMIT 1',
  355. array(
  356. 'is_approved' => 1,
  357. 'id_msg' => $msgid,
  358. )
  359. );
  360. list ($id_topic, $subject) = $smcFunc['db_fetch_row']($result);
  361. $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
  362. $smcFunc['db_free_result']($result);
  363. if (empty($id_topic))
  364. $data[$k] = $txt['who_hidden'];
  365. }
  366. // Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
  367. elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
  368. $data[$k] = $txt['whoadmin_' . $actions['action']];
  369. // Viewable by permission level.
  370. elseif (isset($allowedActions[$actions['action']]))
  371. {
  372. if (allowedTo($allowedActions[$actions['action']]))
  373. $data[$k] = $txt['whoallow_' . $actions['action']];
  374. elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
  375. $data[$k] = $txt['who_moderate'];
  376. elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
  377. $data[$k] = $txt['who_admin'];
  378. else
  379. $data[$k] = $txt['who_hidden'];
  380. }
  381. elseif (!empty($actions['action']))
  382. $data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
  383. else
  384. $data[$k] = $txt['who_unknown'];
  385. }
  386. // Maybe the action is integrated into another system?
  387. if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0)
  388. {
  389. foreach ($integrate_actions as $integrate_action)
  390. {
  391. if (!empty($integrate_action))
  392. {
  393. $data[$k] = $integrate_action;
  394. break;
  395. }
  396. }
  397. }
  398. }
  399. // Load topic names.
  400. if (!empty($topic_ids))
  401. {
  402. $result = $smcFunc['db_query']('', '
  403. SELECT t.id_topic, m.subject
  404. FROM {db_prefix}topics AS t
  405. INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  406. INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
  407. WHERE {query_see_board}
  408. AND t.id_topic IN ({array_int:topic_list})' . ($modSettings['postmod_active'] ? '
  409. AND t.approved = {int:is_approved}' : '') . '
  410. LIMIT {int:limit}',
  411. array(
  412. 'topic_list' => array_keys($topic_ids),
  413. 'is_approved' => 1,
  414. 'limit' => count($topic_ids),
  415. )
  416. );
  417. while ($row = $smcFunc['db_fetch_assoc']($result))
  418. {
  419. // Show the topic's subject for each of the actions.
  420. foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
  421. $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
  422. }
  423. $smcFunc['db_free_result']($result);
  424. }
  425. // Load board names.
  426. if (!empty($board_ids))
  427. {
  428. $result = $smcFunc['db_query']('', '
  429. SELECT b.id_board, b.name
  430. FROM {db_prefix}boards AS b
  431. WHERE {query_see_board}
  432. AND b.id_board IN ({array_int:board_list})
  433. LIMIT ' . count($board_ids),
  434. array(
  435. 'board_list' => array_keys($board_ids),
  436. )
  437. );
  438. while ($row = $smcFunc['db_fetch_assoc']($result))
  439. {
  440. // Put the board name into the string for each member...
  441. foreach ($board_ids[$row['id_board']] as $k => $session_text)
  442. $data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
  443. }
  444. $smcFunc['db_free_result']($result);
  445. }
  446. // Load member names for the profile.
  447. if (!empty($profile_ids) && (allowedTo('profile_view_any') || allowedTo('profile_view_own')))
  448. {
  449. $result = $smcFunc['db_query']('', '
  450. SELECT id_member, real_name
  451. FROM {db_prefix}members
  452. WHERE id_member IN ({array_int:member_list})
  453. LIMIT ' . count($profile_ids),
  454. array(
  455. 'member_list' => array_keys($profile_ids),
  456. )
  457. );
  458. while ($row = $smcFunc['db_fetch_assoc']($result))
  459. {
  460. // If they aren't allowed to view this person's profile, skip it.
  461. if (!allowedTo('profile_view_any') && $user_info['id'] != $row['id_member'])
  462. continue;
  463. // Set their action on each - session/text to sprintf.
  464. foreach ($profile_ids[$row['id_member']] as $k => $session_text)
  465. $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
  466. }
  467. $smcFunc['db_free_result']($result);
  468. }
  469. if (!is_array($urls))
  470. return isset($data[0]) ? $data[0] : false;
  471. else
  472. return $data;
  473. }
  474. /**
  475. * It prepares credit and copyright information for the credits page or the admin page.
  476. * @todo two functions: split the data from loading templates and stuff, and remove the parameter.
  477. * - a function for action=who;sa=credits, and another for the data needed for this and admin.
  478. *
  479. * @param bool $in_admin = false, if parameter is true the it will not load the sub-template nor the template file
  480. */
  481. function action_credits($in_admin = false)
  482. {
  483. global $context, $smcFunc, $modSettings, $forum_copyright, $forum_version, $boardurl, $txt, $user_info;
  484. // Don't blink. Don't even blink. Blink and you're dead.
  485. loadLanguage('Who');
  486. $context[$context['admin_menu_name']]['tab_data'] = array(
  487. 'title' => $txt['support_credits_title'],
  488. 'help' => '',
  489. 'description' => '',
  490. );
  491. $context['credits'] = array(
  492. array(
  493. 'pretext' => $txt['credits_intro'],
  494. 'title' => $txt['credits_team'],
  495. 'groups' => array(
  496. array(
  497. 'title' => $txt['credits_groups_dev'],
  498. 'members' => array(
  499. 'Add this at some point',
  500. ),
  501. ),
  502. ),
  503. ),
  504. );
  505. // Give credit to any graphic library's, software library's, plugins etc
  506. $context['credits_software_graphics'] = array(
  507. 'graphics' => array(
  508. '<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',
  509. '<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>',
  510. ),
  511. 'software' => array(
  512. '<a href="http://www.simplemachines.org/">Simple Machines</a> | &copy; Simple Machines | Licensed under <a href="http://www.simplemachines.org/about/smf/license.php">The BSD License</a>',
  513. '<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>',
  514. '<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>',
  515. '<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>',
  516. '<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>',
  517. '<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>',
  518. ),
  519. );
  520. // Support for mods that use the <credits> tag via the package manager
  521. $context['credits_modifications'] = array();
  522. if (($mods = cache_get_data('mods_credits', 86400)) === null)
  523. {
  524. $mods = array();
  525. $request = $smcFunc['db_query']('substring', '
  526. SELECT version, name, credits
  527. FROM {db_prefix}log_packages
  528. WHERE install_state = {int:installed_mods}
  529. AND credits != {string:empty}
  530. AND SUBSTRING(filename, 1, 9) != {string:old_patch_name}
  531. AND SUBSTRING(filename, 1, 9) != {string:patch_name}',
  532. array(
  533. 'installed_mods' => 1,
  534. 'old_patch_name' => 'smf_patch',
  535. 'patch_name' => 'elk_patch',
  536. 'empty' => '',
  537. )
  538. );
  539. while ($row = $smcFunc['db_fetch_assoc']($request))
  540. {
  541. $credit_info = unserialize($row['credits']);
  542. $copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' &copy; ' . $smcFunc['htmlspecialchars']($credit_info['copyright']);
  543. $license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . $smcFunc['htmlspecialchars']($credit_info['license']);
  544. $version = $txt['credits_version'] . ' ' . $row['version'];
  545. $title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version;
  546. // build this one out and stash it away
  547. $mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
  548. $mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : '');
  549. }
  550. cache_put_data('mods_credits', $mods, 86400);
  551. }
  552. $context['credits_modifications'] = $mods;
  553. $context['copyrights'] = array(
  554. 'elkarte' => sprintf($forum_copyright, ucfirst(strtolower($forum_version))),
  555. /* Modification Authors: You may add a copyright statement to this array for your mods.
  556. Copyright statements should be in the form of a value only without a array key. I.E.:
  557. 'Some Mod by Thantos &copy; 2010',
  558. $txt['some_mod_copyright'],
  559. But its better and simpler to just your package.xml and add in the <credits> <license> tags
  560. */
  561. 'mods' => array(
  562. ),
  563. );
  564. // Support for those that want to use a hook as well
  565. call_integration_hook('integrate_credits');
  566. if (!$in_admin)
  567. {
  568. loadTemplate('Who');
  569. $context['sub_template'] = 'credits';
  570. $context['robot_no_index'] = true;
  571. $context['page_title'] = $txt['credits'];
  572. }
  573. }