Advertisement
Guest User

Untitled

a guest
May 11th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.46 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * MyShoutBox for MyBB 1.4.x (MYBB_ROOT/inc/plugins/shoutbox.php)
  5. * Copyright © 2009 Pirata Nervo, All Rights Reserved!
  6. *
  7. * Website: http://www.mybb-plugins.com
  8. * License:
  9. * "This plugin is offered "as is" with no guarantees.
  10. * You may redistribute it provided the code and credits
  11. * remain intact with no changes. This is not distributed
  12. * under GPL, so you may NOT re-use the code in any other
  13. * module, plugin, or program.
  14. *
  15. * Free for non-commercial purposes!"
  16. *
  17. * This plugin is based off Asad Niazi's spicefuse shoutbox plugin.
  18. * Spicefuse Shoutbox website: www.spicefuse.com
  19. *
  20. *
  21. * File description: MyShoutbox main file
  22. */
  23.  
  24. if(!defined('IN_MYBB'))
  25. die('This file cannot be accessed directly.');
  26.  
  27. $plugins->add_hook("index_end", "myshoutbox_index");
  28. $plugins->add_hook("xmlhttp", "myshoutbox_load");
  29. $plugins->add_hook("pre_output_page", "myshoutbox_output_control");
  30.  
  31. $plugins->add_hook('admin_load', 'myshoutbox_admin');
  32. $plugins->add_hook('admin_tools_menu', 'myshoutbox_admin_tools_menu');
  33. $plugins->add_hook('admin_tools_action_handler', 'myshoutbox_admin_tools_action_handler');
  34. $plugins->add_hook('admin_tools_permissions', 'myshoutbox_admin_permissions');
  35.  
  36. // reported shouts notice
  37. $plugins->add_hook('admin_home_menu', 'myshoutbox_admin_home_menu');
  38.  
  39. function myshoutbox_info()
  40. {
  41. return array(
  42. 'name' => 'MyShoutbox',
  43. 'description' => 'A powerful AJAX shoutbox for MyBB.',
  44. 'website' => 'http://consoleaddicted.com/',
  45. 'author' => 'Pirata Nervo',
  46. 'authorsite' => 'http://consoleaddicted.com/',
  47. 'version' => '1.7',
  48. 'guid' => 'c7e5e6c1a57f0639ea52d7813b23579f',
  49. 'compatibility' => '14*,15*,16*',
  50. );
  51. }
  52.  
  53. function myshoutbox_install()
  54. {
  55. global $db;
  56.  
  57. $shoutbox_group = array(
  58. "name" => "mysb_shoutbox",
  59. "title" => "MyShoutbox",
  60. "description" => "Settings for the MyShoutbox plugin.",
  61. "disporder" => "1",
  62. "isdefault" => "no",
  63. );
  64.  
  65. $db->insert_query("settinggroups", $shoutbox_group);
  66. $gid = $db->insert_id();
  67.  
  68. $shoutbox_setting_1 = array(
  69. "name" => "mysb_shouts_main",
  70. "title" => "# of Shouts to display",
  71. "description" => "The maximum number of shouts you want to be displayed.",
  72. "optionscode" => "text",
  73. "value" => "30",
  74. "disporder" => "1",
  75. "gid" => intval($gid),
  76. );
  77.  
  78. $shoutbox_setting_2 = array(
  79. "name" => "mysb_refresh_interval",
  80. "title" => "Refresh Interval",
  81. "description" => "How many seconds before the shoutbox is reloaded using AJAX transparently. ",
  82. "optionscode" => "text",
  83. "value" => "15",
  84. "disporder" => "2",
  85. "gid" => intval($gid),
  86. );
  87.  
  88. $shoutbox_setting_3 = array(
  89. "name" => "mysb_allow_mycode",
  90. "title" => "Allow MyCode?",
  91. "description" => "Allow MyBB code in shouts to format text using [b], [i] etc..?",
  92. "optionscode" => "yesno",
  93. "value" => "yes",
  94. "disporder" => "3",
  95. "gid" => intval($gid),
  96. );
  97.  
  98. $shoutbox_setting_4 = array(
  99. "name" => "mysb_allow_smilies",
  100. "title" => "Allow Smilies?",
  101. "description" => "Allow smilies in shouts?",
  102. "optionscode" => "yesno",
  103. "value" => "yes",
  104. "disporder" => "4",
  105. "gid" => intval($gid),
  106. );
  107.  
  108. $shoutbox_setting_5 = array(
  109. "name" => "mysb_allow_imgcode",
  110. "title" => "Allow IMGCode?",
  111. "description" => "Allow images in shoutbox? Note: Some can post too big images and mess up your layout.",
  112. "optionscode" => "yesno",
  113. "value" => "no",
  114. "disporder" => "5",
  115. "gid" => intval($gid),
  116. );
  117.  
  118. $shoutbox_setting_6 = array(
  119. "name" => "mysb_height",
  120. "title" => "ShoutBox Height",
  121. "description" => "Set the height for shoutbox here.",
  122. "optionscode" => "text",
  123. "value" => "125",
  124. "disporder" => "6",
  125. "gid" => intval($gid),
  126. );
  127.  
  128. $shoutbox_setting_7 = array(
  129. "name" => "mysb_datetime",
  130. "title" => "ShoutBox Date/Time",
  131. "description" => "PHP date time format for shoutbox. <a href=\"http://php.net/date\" target=\"_blank\">check here</a> for more info.",
  132. "optionscode" => "text",
  133. "value" => "d-m-H:i",
  134. "disporder" => "7",
  135. "gid" => intval($gid),
  136. );
  137.  
  138. $shoutbox_setting_8 = array(
  139. "name" => "mysb_full_ppage",
  140. "title" => "Shouts per page on full view?",
  141. "description" => "The number of shouts you want to be displayed, per page, on the full shoutbox view.",
  142. "optionscode" => "text",
  143. "value" => "50",
  144. "disporder" => "8",
  145. "gid" => intval($gid),
  146. );
  147.  
  148. $shoutbox_setting_9 = array(
  149. "name" => "mysb_allow_smods",
  150. "title" => "Allow super moderators to delete?",
  151. "description" => "Allow super mods to delete shouts in the shoutbox?",
  152. "optionscode" => "yesno",
  153. "value" => "yes",
  154. "disporder" => "9",
  155. "gid" => intval($gid),
  156. );
  157.  
  158. $shoutbox_setting_10 = array(
  159. "name" => "mysb_allow_html",
  160. "title" => "Allow HTML?",
  161. "description" => "Allow html in shoutbox?",
  162. "optionscode" => "yesno",
  163. "value" => "no",
  164. "disporder" => "10",
  165. "gid" => intval($gid),
  166. );
  167.  
  168. $shoutbox_setting_11 = array(
  169. "name" => "mysb_allow_video",
  170. "title" => "Allow Videos?",
  171. "description" => "Allow videos in shoutbox? (MyBB 1.6 only)",
  172. "optionscode" => "yesno",
  173. "value" => "no",
  174. "disporder" => "11",
  175. "gid" => intval($gid),
  176. );
  177.  
  178. $shoutbox_setting_12 = array(
  179. "name" => "mysb_flood_time",
  180. "title" => "Flood Check?",
  181. "description" => "Add a flood check for everyone but the moderators. Enter a time in seconds here. Enter 0 to disable.",
  182. "optionscode" => "text",
  183. "value" => "5",
  184. "disporder" => "12",
  185. "gid" => intval($gid),
  186. );
  187.  
  188. $shoutbox_setting_13 = array(
  189. "name" => "mysb_usergroups",
  190. "title" => "Groups allowed to view the shoutbox",
  191. "description" => "The groupd ids of the users allowed to view the shoutbox. (Seperated by a comma. Leave blank to allow all.)",
  192. "optionscode" => "text",
  193. "value" => "",
  194. "disporder" => "13",
  195. "gid" => intval($gid),
  196. );
  197.  
  198. $shoutbox_setting_14 = array(
  199. "name" => "mysb_additional_groups",
  200. "title" => "Check additional groups?",
  201. "description" => "Set this to yes if you want additional groups to be checked. (This setting will only take effect if the above one is not blank)",
  202. "optionscode" => "yesno",
  203. "value" => "no",
  204. "disporder" => "14",
  205. "gid" => intval($gid),
  206. );
  207.  
  208. $shoutbox_setting_15 = array(
  209. "name" => "mysb_allow_mods",
  210. "title" => "Allow moderators to delete?",
  211. "description" => "Allow moderators to delete shouts in the shoutbox?",
  212. "optionscode" => "yesno",
  213. "value" => "yes",
  214. "disporder" => "15",
  215. "gid" => intval($gid),
  216. );
  217.  
  218. $shoutbox_setting_16 = array(
  219. "name" => "mysb_display_message",
  220. "title" => "Do you want to show a message to banned users?",
  221. "description" => "Do you want to show a message to banned users? The message can be changed in the language files of MyShoutbox. (it is displayed instead of the shoutbox)",
  222. "value" => 1,
  223. "optionscode" => "yesno",
  224. "disporder" => "16",
  225. "gid" => intval($gid),
  226. );
  227.  
  228. $shoutbox_setting_17 = array(
  229. "name" => "mysb_text_size",
  230. "title" => "Font size",
  231. "description" => "Enter the font size of the shouts. Default is 12.",
  232. "value" => 12,
  233. "optionscode" => "text",
  234. "disporder" => "17",
  235. "gid" => intval($gid),
  236. );
  237.  
  238. $shoutbox_setting_18 = array(
  239. "name" => "mysb_key",
  240. "title" => "Key",
  241. "description" => "Enter a random string for your key. All {myshoutbox_KEY} entries found in your templates or anywhere else will be replaced with the actual shoutbox.",
  242. "value" => "abcd",
  243. "optionscode" => "text",
  244. "disporder" => "18",
  245. "gid" => intval($gid),
  246. );
  247.  
  248. $db->insert_query("settings", $shoutbox_setting_1);
  249. $db->insert_query("settings", $shoutbox_setting_2);
  250. $db->insert_query("settings", $shoutbox_setting_3);
  251. $db->insert_query("settings", $shoutbox_setting_4);
  252. $db->insert_query("settings", $shoutbox_setting_5);
  253. $db->insert_query("settings", $shoutbox_setting_6);
  254. $db->insert_query("settings", $shoutbox_setting_7);
  255. $db->insert_query("settings", $shoutbox_setting_8);
  256. $db->insert_query("settings", $shoutbox_setting_9);
  257. $db->insert_query("settings", $shoutbox_setting_10);
  258. $db->insert_query("settings", $shoutbox_setting_11);
  259. $db->insert_query("settings", $shoutbox_setting_12);
  260. $db->insert_query("settings", $shoutbox_setting_13);
  261. $db->insert_query("settings", $shoutbox_setting_14);
  262. $db->insert_query("settings", $shoutbox_setting_15);
  263. $db->insert_query("settings", $shoutbox_setting_16);
  264. $db->insert_query("settings", $shoutbox_setting_17);
  265. $db->insert_query("settings", $shoutbox_setting_18);
  266.  
  267. // create table
  268. $db->write_query("CREATE TABLE `".TABLE_PREFIX."mysb_shouts` (
  269. `id` int(10) NOT NULL auto_increment,
  270. `uid` int(10) NOT NULL,
  271. `shout_msg` text NOT NULL,
  272. `shout_date` int(10) NOT NULL,
  273. `shout_ip` varchar(30) NOT NULL,
  274. `hidden` varchar(10) NOT NULL,
  275. PRIMARY KEY (`id`)
  276. ) ENGINE=MyISAM");
  277.  
  278. // create reports table
  279. $db->write_query("CREATE TABLE `".TABLE_PREFIX."mysb_reports` (
  280. `rid` int(10) NOT NULL auto_increment,
  281. `username` varchar(100) NOT NULL DEFAULT '',
  282. `uid` int(10) NOT NULL DEFAULT 0,
  283. `reason` varchar(255) NOT NULL DEFAULT '',
  284. `date` bigint(30) NOT NULL DEFAULT 0,
  285. `sid` int(10) NOT NULL DEFAULT 0,
  286. `marked` tinyint(1) NOT NULL DEFAULT 0,
  287. `author_uid` int(10) NOT NULL DEFAULT 0,
  288. `author_username` varchar(30) NOT NULL DEFAULT '',
  289. PRIMARY KEY (`rid`), KEY(`date`)
  290. ) ENGINE=MyISAM");
  291.  
  292. $db->write_query("INSERT INTO ".TABLE_PREFIX."mysb_shouts VALUES (NULL, 1, 'Test Shout! Without any shout, shoutbox will display Loading... forever.. you need at least one shout, so here it is.', ".time().", '127.0.0.1', 'no')");
  293.  
  294. $db->write_query("ALTER TABLE `".TABLE_PREFIX."users` ADD `mysb_banned` smallint(1) NOT NULL DEFAULT 0;");
  295. $db->write_query("ALTER TABLE `".TABLE_PREFIX."users` ADD `mysb_banned_reason` varchar(255) NOT NULL DEFAULT '';");
  296.  
  297. // rebuild settings...
  298. rebuild_settings();
  299. }
  300.  
  301. function myshoutbox_activate()
  302. {
  303. global $db, $mybb;
  304.  
  305. // load templates
  306. $mysb_shoutbox_tpl = '
  307. <script type="text/javascript" src="jscripts/myshoutbox.js?ver=1400"></script>
  308. <style type="text/css">
  309.  
  310. .shoutbox {
  311. margin: 0;
  312. padding: 0;
  313. left: 0;
  314. }
  315.  
  316.  
  317. li.shoutbox_normal {
  318. list-style: none;
  319. margin: 0;
  320. position: relative;
  321. cursor: pointer;
  322. color: transparent;
  323. display: inline ;
  324. border: 1px;
  325. border-color: #FFFFFF;
  326. }
  327.  
  328. li.shoutbox_color {
  329. list-style: none;
  330. position: relative;
  331. cursor: pointer;
  332. color: transparent;
  333. display: inline ;
  334. border: 0px;
  335. float: left;
  336. margin: 1px;
  337. }
  338.  
  339. .shoutbox_button_color a {
  340. width: 9px;
  341. height: 9px;
  342. display: block;
  343. border: 1px solid #FFF;
  344. }
  345.  
  346. </style>
  347.  
  348. <table border="0" cellspacing="1" cellpadding="4" class="tborder">
  349. <thead>
  350. <tr>
  351. <td class="thead" colspan="2">
  352. <div class="expcolimage"><img src="{$theme[\'imgdir\']}/collapse.gif" id="shoutbox_img" class="expander" alt="[-]" /></div>
  353. <div><strong>{$lang->mysb_shoutbox}</strong> (<a href="index.php?action=full_shoutbox">{$lang->mysb_fullsbox}</a> - <a href="pspshoutbox.php">{$lang->mysb_portable}</a>)<br /></div>
  354. </td>
  355. </tr>
  356. </thead>
  357.  
  358. <tbody id="shoutbox_e">
  359. <tr>
  360. <td class="trow2" width="66%" align="center"><form onsubmit="ShoutBox.postShout(); $(\'shout_data\').value = \'\'; return false;">{$lang->mysb_shout} <input type="text" id="shout_data" size="50" /> - <input type="submit" value="{$lang->mysb_shoutnow}" id="shouting-status" /></form></td>
  361. <td class="trow2" width="12%" align="center">{$lang->mysb_options}</td>
  362. </tr>
  363. <tr>
  364. <td class="trow1" width="76%"><div id="shoutbox_data" style="height: {$mybb->settings[\'mysb_height\']}px; overflow: auto;">{$lang->mysb_loading}</div></td>
  365. <td class="trow1" width="12%" align="center">
  366. <a style="cursor: pointer;" id="smilies" onclick="window.open(\'misc.php?action=smilies&amp;popup=true&amp;editor=clickableEditor\',\'{$lang->mysb_smilies}\',\'scrollbars=yes, menubar=no,width=460,height=360,toolbar=no\');">{$lang->mysb_smilies}</a>
  367. <br />
  368. <a style="cursor: pointer;" onclick="window.open(\'shoutbox.php\',\'{$lang->mysb_shoutbox}\',\'scrollbars=yes, menubar=no,width=825,height=449,toolbar=no\');">{$lang->mysb_popup_shoutbox}</a>
  369. </td>
  370. </tr>
  371. </tbody>
  372. </table>
  373.  
  374. <script type="text/javascript">
  375. ShoutBox.refreshInterval = {$mybb->settings[\'mysb_refresh_interval\']};
  376. ShoutBox.MaxEntries = {$mybb->settings[\'mysb_shouts_main\']};
  377. ShoutBox.lang = [\'{$lang->mysb_posting}\', \'{$lang->mysb_shoutnow}\', \'{$lang->mysb_loading}\', \'{$lang->mysb_flood_check}\', \'{$lang->mysb_no_perform}\', \'{$lang->mysb_already_sent}\', \'{$lang->mysb_deleted}\', \'{$lang->mysb_invalid}\', \'{$lang->mysb_self}\', \'{$lang->mysb_report_invalid_sid}\', \'{$lang->mysb_shout_reported}\', \'{$lang->mysb_shout_already_reported}\'];
  378. {$extra_js}
  379. Event.observe(window, \'load\', ShoutBox.showShouts);
  380. </script>
  381.  
  382. <br />';
  383.  
  384. $mysb_boxfull_tpl = '<html>
  385. <head>
  386. <title>Full Shoutbox</title>
  387. {$headerinclude}
  388. </head>
  389. <body>
  390. {$header}
  391.  
  392. <table border="0" cellspacing="1" cellpadding="4" class="tborder">
  393. <thead>
  394. <tr>
  395. <td class="thead" colspan="2">
  396. <div><strong>{$lang->mysb_shoutbox}</strong><br /></div>
  397. </td>
  398. </tr>
  399. </thead>
  400.  
  401. <tr>
  402. {$mysb_shoutbox_data}
  403. </tr>
  404. </table>
  405.  
  406. <br />
  407.  
  408. <center>$multipage</center>
  409.  
  410. {$footer}
  411. </body>
  412. </html>
  413. ';
  414.  
  415. $mysb_popup_shoutbox_tpl = '
  416. <html>
  417. <head>
  418. <title>{$lang->mysb_shoutbox}</title>
  419. {$headerinclude}
  420. <script type="text/javascript" src="jscripts/myshoutbox.js?ver=1400"></script>
  421. </head>
  422. <body>
  423.  
  424. <style type="text/css">
  425.  
  426. .shoutbox {
  427. margin: 0;
  428. padding: 0;
  429. left: 0;
  430. }
  431.  
  432.  
  433. li.shoutbox_normal {
  434. list-style: none;
  435. margin: 0;
  436. position: relative;
  437. cursor: pointer;
  438. color: transparent;
  439. display: inline ;
  440. border: 1px;
  441. border-color: #FFFFFF;
  442. }
  443.  
  444. li.shoutbox_color {
  445. list-style: none;
  446. position: relative;
  447. cursor: pointer;
  448. color: transparent;
  449. display: inline ;
  450. border: 0px;
  451. float: left;
  452. margin: 1px;
  453. }
  454.  
  455. .shoutbox_button_color a {
  456. width: 9px;
  457. height: 9px;
  458. display: block;
  459. border: 1px solid #FFF;
  460. }
  461.  
  462. </style>
  463.  
  464. <table border="0" cellspacing="1" cellpadding="4" class="tborder">
  465. <thead>
  466. <tr>
  467. <td class="thead" colspan="2">
  468. <div class="expcolimage"><img src="{$theme[\'imgdir\']}/collapse.gif" id="shoutbox_img" class="expander" alt="[-]" /></div>
  469. <div><strong>{$lang->mysb_shoutbox}</strong> (<a href="index.php?action=full_shoutbox">{$lang->mysb_fullsbox}</a> - <a href="pspshoutbox.php">{$lang->mysb_portable}</a>)<br /></div>
  470. </td>
  471. </tr>
  472. </thead>
  473.  
  474. <tbody id="shoutbox_e">
  475. <tr>
  476. <td class="trow2" width="66%" align="center"><form onSubmit="ShoutBox.postShout(); $(\'shout_data\').value = \'\'; return false;">{$lang->mysb_shout} <input type="text" id="shout_data" size="50" /> - <input type="submit" value="{$lang->mysb_shoutnow}" id="shouting-status" /></form></td>
  477. <td class="trow2" width="12%" align="center">{$lang->mysb_options}</td>
  478. </tr>
  479. <tr>
  480. <td class="trow1" width="76%"><div align="left" id="shoutbox_data" style="height: {$mybb->settings[\'mysb_height\']}px; overflow: auto;">{$lang->mysb_loading}</div></td>
  481. <td class="trow1" width="12%" align="center">
  482. <a style="cursor: pointer;" id="smilies" onclick="window.open(\'misc.php?action=smilies&popup=true&editor=clickableEditor\',\'{$lang->mysb_smilies}\',\'scrollbars=yes, menubar=no,width=460,height=360,toolbar=no\');">{$lang->mysb_smilies}</a>
  483. <br />
  484. <a style="cursor: pointer;" onclick="window.open(\'shoutbox.php\',\'{$lang->mysb_shoutbox}\',\'scrollbars=yes, menubar=no,width=825,height=449,toolbar=no\');">{$lang->mysb_popup_shoutbox}</a>
  485. </td>
  486. </tbody>
  487. </table>
  488.  
  489. <script>
  490. ShoutBox.refreshInterval = {$mybb->settings[\'mysb_refresh_interval\']};
  491. ShoutBox.MaxEntries = {$mybb->settings[\'mysb_shouts_main\']};
  492. ShoutBox.lang = [\'{$lang->mysb_posting}\', \'{$lang->mysb_shoutnow}\', \'{$lang->mysb_loading}\', \'{$lang->mysb_flood_check}\', \'{$lang->mysb_no_perform}\', \'{$lang->mysb_already_sent}\', \'{$lang->mysb_deleted}\', \'{$lang->mysb_invalid}\', \'{$lang->mysb_self}\', \'{$lang->mysb_report_invalid_sid}\', \'{$lang->mysb_shout_reported}\', \'{$lang->mysb_shout_already_reported}\'];
  493. {$extra_js}
  494. Event.observe(window, \'load\', ShoutBox.showShouts);
  495. </script>
  496.  
  497. </body>
  498. </html>';
  499.  
  500. $mysb_portable_tpl = '
  501. <html>
  502. <head>
  503. <title>{$lang->mysb_shoutbox}</title>
  504. {$headerinclude}
  505. <!--<SCRIPT>var timeID = setTimeout("document.forms[0].submit()", 30000)</SCRIPT>-->
  506. </head>
  507. <body>
  508.  
  509. <form id="0" action="pspshoutbox.php"></form>
  510.  
  511. <table border="0" cellspacing="1" cellpadding="4" class="tborder">
  512. <thead>
  513. <tr>
  514. <td class="thead" colspan="2">
  515. <form id="1" action="pspshoutbox.php?action=shout" method="post">{$lang->mysb_shout} <input type="hidden" name="postcode" value="{$mybb->post_code}" /> <input type="text" name="shout_data" size="50" /> - <input type="submit" value="{$lang->mysb_shoutnow}" id="shouting-status" /></form>
  516. </td>
  517. </tr>
  518. <tr>
  519. <td class="thead" colspan="2">
  520. <div><strong>{$lang->mysb_shoutbox}</strong> - <!--<a href="pspshoutbox.php">Refresh</a> --><small>(<a href="pspshoutbox.php?action=refresh">Refresh</a>)</small> <br /></div>
  521. </td>
  522. </tr>
  523. </thead>
  524.  
  525. <tr>
  526. {$mysb_shoutbox_data}
  527. </tr>
  528. </table>
  529.  
  530. </body>
  531.  
  532. </html>';
  533.  
  534. $mysb_banned = '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
  535. <tr>
  536. <td class="thead"><strong>{$lang->mysb_shoutbox}</strong></td>
  537. </tr>
  538. <tr>
  539. <td class="trow1">{$lang->mysb_error_ban}</td>
  540. </tr>
  541. </table><br />';
  542.  
  543.  
  544. // insert templates
  545. $db->insert_query('templates', array('title' => 'mysb_shoutbox', 'sid' => '-1', 'template' => $db->escape_string($mysb_shoutbox_tpl), 'version' => '1411', 'status' => '', 'dateline' => TIME_NOW));
  546. $db->insert_query('templates', array('title' => 'mysb_shoutbox_full', 'sid' => '-1', 'template' => $db->escape_string($mysb_boxfull_tpl), 'version' => '1411', 'status' => '', 'dateline' => TIME_NOW));
  547. $db->insert_query('templates', array('title' => 'mysb_shoutbox_popup', 'sid' => '-1', 'template' => $db->escape_string($mysb_popup_shoutbox_tpl), 'version' => '1411', 'status' => '', 'dateline' => TIME_NOW));
  548. $db->insert_query('templates', array('title' => 'mysb_shoutbox_psp', 'sid' => '-1', 'template' => $db->escape_string($mysb_portable_tpl), 'version' => '1411', 'status' => '', 'dateline' => TIME_NOW));
  549. $db->insert_query('templates', array('title' => 'mysb_shoutbox_banned', 'sid' => '-1', 'template' => $db->escape_string($mysb_banned), 'version' => '1411', 'status' => '', 'dateline' => TIME_NOW));
  550.  
  551. require_once MYBB_ROOT.'inc/adminfunctions_templates.php';
  552.  
  553. find_replace_templatesets('index', '#{\$boardstats}#', "{myshoutbox_".$mybb->settings['mysb_key']."}\n{\$boardstats}");
  554.  
  555. }
  556.  
  557. function myshoutbox_uninstall()
  558. {
  559. global $db;
  560.  
  561. $db->write_query("DROP TABLE ".TABLE_PREFIX."mysb_shouts");
  562. $db->write_query("DROP TABLE ".TABLE_PREFIX."mysb_reports");
  563. $db->write_query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name = 'mysb_shoutbox'");
  564. $db->write_query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('mysb_shouts_main','mysb_refresh_interval','mysb_allow_mycode',
  565. 'mysb_allow_smilies','mysb_allow_imgcode','mysb_height','mysb_datetime','mysb_full_ppage','mysb_allow_smods',
  566. 'mysb_allow_html','mysb_flood_time','mysb_usergroups','mysb_additional_groups','mysb_allow_mods','mysb_display_message','mysb_allow_video')");
  567.  
  568. $db->write_query("ALTER TABLE `".TABLE_PREFIX."users` DROP `mysb_banned`;");
  569. $db->write_query("ALTER TABLE `".TABLE_PREFIX."users` DROP `mysb_banned_reason`;");
  570. }
  571.  
  572. function myshoutbox_is_installed()
  573. {
  574. global $db;
  575.  
  576. if ($db->table_exists('mysb_shouts'))
  577. return true;
  578.  
  579. return false;
  580. }
  581.  
  582. function myshoutbox_deactivate()
  583. {
  584. global $db, $mybb;
  585. $db->write_query("DELETE FROM ".TABLE_PREFIX."templates WHERE title IN('mysb_shoutbox','mysb_shoutbox_full','mysb_shoutbox_popup','mysb_shoutbox_popup_full','mysb_shoutbox_psp','mysb_shoutbox_banned') AND sid='-1'");
  586.  
  587. require_once MYBB_ROOT.'inc/adminfunctions_templates.php';
  588.  
  589. find_replace_templatesets('index', '#{myshoutbox_'.$mybb->settings['mysb_key'].'}#', '', 0);
  590. }
  591.  
  592. function myshoutbox_load()
  593. {
  594. global $mybb, $lang, $charset;
  595.  
  596. $lang->load("myshoutbox");
  597.  
  598. // Send our headers.
  599. header("Content-type: text/html; charset={$charset}");
  600.  
  601. switch ($mybb->input['action'])
  602. {
  603. case 'show_shouts':
  604. myshoutbox_show_shouts(intval($mybb->input['last_id']));
  605. break;
  606.  
  607. case 'add_shout':
  608. myshoutbox_add_shout();
  609. break;
  610.  
  611. case 'delete_shout':
  612. myshoutbox_delete_shout(intval($mybb->input['id']));
  613. break;
  614.  
  615. case 'remove_shout':
  616. myshoutbox_remove_shout(intval($mybb->input['id']));
  617. break;
  618.  
  619. case 'recover_shout':
  620. myshoutbox_recover_shout(intval($mybb->input['id']));
  621. break;
  622.  
  623. case 'report_shout':
  624. myshoutbox_report_shout($mybb->input['reason'], intval($mybb->input['sid']));
  625. break;
  626. }
  627. }
  628.  
  629. function myshoutbox_psp_show()
  630. {
  631. global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset;
  632.  
  633. $lang->load('myshoutbox');
  634.  
  635. // Send our headers.
  636. header("Content-type: text/html; charset={$charset}");
  637.  
  638. // Make navigation
  639. add_breadcrumb($lang->mysb_shoutbox, "pspshoutbox.php");
  640. $per_page = intval($mybb->settings['mysb_full_ppage']);
  641.  
  642. // pagination
  643. $query = $db->simple_select("mysb_shouts", "COUNT(*) as shouts_count");
  644. $shouts_count = $db->fetch_field($query, 'shouts_count');
  645.  
  646. // Pagination
  647. $per_page = intval($mybb->settings['mysb_full_ppage']);;
  648. if(intval($mybb->input['page']) > 0)
  649. {
  650. $page = (int)$mybb->input['page'];
  651. $start = ($page-1) * $per_page;
  652. $pages = $shouts_count / $per_page;
  653. $pages = ceil($pages);
  654. if($page > $pages)
  655. {
  656. $start = 0;
  657. $page = 1;
  658. }
  659. }
  660. else
  661. {
  662. $start = 0;
  663. $page = 1;
  664. }
  665.  
  666. // multi-page
  667. if ($shouts_count > $per_page) {
  668. $multipage = multipage($shouts_count, $per_page, $page, "pspshoutbox.php?action=full");
  669. }
  670.  
  671. // get data
  672. require_once MYBB_ROOT.'inc/class_parser.php';
  673. $parser = new postParser;
  674.  
  675. $usernames_cache = array();
  676.  
  677. $query = $db->write_query("SELECT s.*, u.username, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."mysb_shouts s
  678. LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = s.uid)
  679. ORDER by s.id DESC LIMIT {$start}, {$per_page}");
  680.  
  681. while ($row = $db->fetch_array($query))
  682. {
  683. $parser_options = array(
  684. 'allow_mycode' => $mybb->settings['mysb_allow_mycode'],
  685. 'allow_smilies' => $mybb->settings['mysb_allow_smilies'],
  686. 'allow_imgcode' => $mybb->settings['mysb_allow_imgcode'],
  687. 'allow_html' => $mybb->settings['mysb_allow_html'],
  688. "allow_videocode" => $mybb->settings['mysb_allow_video'],
  689. 'me_username' => $row['username']
  690. );
  691.  
  692. $message = $parser->parse_message($row['shout_msg'], $parser_options);
  693.  
  694. $find = stripos($message, "/pvt");
  695. if($find == 0 && $find !== false)
  696. {
  697. sscanf($message, "/pvt %d", $userID);
  698. $userID = (int)$userID;
  699. $message = str_replace("/pvt ".$userID." ", "", $message);
  700. if ($mybb->user['uid'] == intval($userID) || $mybb->user['uid'] == $row['uid'])
  701. {
  702. if ($mybb->user['uid'] == intval($userID))
  703. {
  704. $userName = $mybb->user['username'];
  705. }
  706. else {
  707. // Unfortunately, we do not have this username...let's check our cache, if it's not in cache, query it
  708. if (!empty($usernames_cache[$userID]))
  709. {
  710. $userName = $usernames_cache[$userID];
  711. }
  712. else {
  713. $userName = $db->fetch_field($db->simple_select('users', 'username', 'uid=\''.$userID.'\''), 'username');
  714. $usernames_cache[$userID] = $userName;
  715. }
  716. }
  717.  
  718. $message = "<span style=\"background-color: #AF4300; font-weight: bold;\">{$lang->mysb_pvt_to} ".htmlspecialchars_uni($userName).": ".$message."</span>";
  719.  
  720. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  721.  
  722. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  723.  
  724. $username = '<a href="./member.php?action=profile&uid='.$row['uid'].'" {$extra}>'.$row['username'].'</a>';
  725. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  726. $class = alt_trow();
  727.  
  728. if (myshoutbox_can_delete() && $row['hidden'] == "yes") {
  729. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td align=\"left\" class='{$class}'>&raquo; <strong><span style=\"color: #FF0000\";>{$lang->mysb_deleted_info}</span></strong> &raquo; {$username} - {$date_time} -- {$message}</td></tr>";
  730. }
  731. elseif ($row['hidden'] == "no")
  732. {
  733. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td align=\"left\" class='{$class}'>&raquo; {$username} - {$date_time} -- {$message}</td></tr>";
  734. }
  735. }
  736. }
  737. else {
  738. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  739.  
  740. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  741.  
  742. $username = '<a href="./member.php?action=profile&uid='.$row['uid'].'" {$extra}>'.$row['username'].'</a>';
  743. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  744. $class = alt_trow();
  745.  
  746. if (myshoutbox_can_delete() && $row['hidden'] == "yes") {
  747. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td align=\"left\" class='{$class}'><span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; <strong><span style=\"color: #FF0000\";>{$lang->mysb_deleted_info}</span></strong> &raquo; {$username} - {$date_time} -- {$message}</span></td></tr>";
  748. }
  749. elseif ($row['hidden'] == "no")
  750. {
  751. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td align=\"left\" class='{$class}'><span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; {$username} - {$date_time} -- {$message}</span></td></tr>";
  752. }
  753. }
  754. }
  755.  
  756.  
  757. eval("\$shoutbox = \"".$templates->get("mysb_shoutbox_psp")."\";");
  758.  
  759. $db->write_query("SELECT * FROM ".TABLE_PREFIX."mysb_shouts ORDER by id DESC LIMIT 10");
  760.  
  761. output_page($shoutbox);
  762. exit;
  763. }
  764.  
  765. function myshoutbox_show_full()
  766. {
  767. global $db, $mybb, $templates, $lang, $footer, $headerinclude, $header, $charset;
  768.  
  769. $lang->load('myshoutbox');
  770.  
  771. // Send our headers.
  772. header("Content-type: text/html; charset={$charset}");
  773.  
  774. // Make navigation
  775. add_breadcrumb($lang->mysb_shoutbox, "index.php?action=full_shoutbox");
  776.  
  777. // pagination
  778. $query = $db->simple_select("mysb_shouts", "COUNT(*) as shouts_count");
  779. $shouts_count = $db->fetch_field($query, 'shouts_count');
  780.  
  781. // Pagination
  782. $per_page = intval($mybb->settings['mysb_full_ppage']);;
  783. if(intval($mybb->input['page']) > 0)
  784. {
  785. $page = (int)$mybb->input['page'];
  786. $start = ($page-1) * $per_page;
  787. $pages = $shouts_count / $per_page;
  788. $pages = ceil($pages);
  789. if($page > $pages)
  790. {
  791. $start = 0;
  792. $page = 1;
  793. }
  794. }
  795. else
  796. {
  797. $start = 0;
  798. $page = 1;
  799. }
  800.  
  801. // multi-page
  802. if ($shouts_count > $per_page) {
  803. $multipage = multipage($shouts_count, $per_page, $page, "index.php?action=full_shoutbox");
  804. }
  805.  
  806. // get data
  807. require_once MYBB_ROOT.'inc/class_parser.php';
  808. $parser = new postParser;
  809.  
  810. $usernames_cache = array();
  811.  
  812. $query = $db->write_query("SELECT s.*, u.username, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."mysb_shouts s
  813. LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = s.uid)
  814. ORDER by s.id DESC LIMIT {$start}, {$per_page}");
  815.  
  816. while ($row = $db->fetch_array($query))
  817. {
  818. $parser_options = array(
  819. 'allow_mycode' => $mybb->settings['mysb_allow_mycode'],
  820. 'allow_smilies' => $mybb->settings['mysb_allow_smilies'],
  821. 'allow_imgcode' => $mybb->settings['mysb_allow_imgcode'],
  822. 'allow_html' => $mybb->settings['mysb_allow_html'],
  823. "allow_videocode" => $mybb->settings['mysb_allow_video'],
  824. 'me_username' => $row['username']
  825. );
  826.  
  827. $message = $parser->parse_message($row['shout_msg'], $parser_options);
  828.  
  829. $find = stripos($message, "/pvt");
  830. if($find == 0 && $find !== false)
  831. {
  832. sscanf($message, "/pvt %d", $userID);
  833. $userID = (int)$userID;
  834. $message = str_replace("/pvt ".$userID." ", "", $message);
  835. if ($mybb->user['uid'] == intval($userID) || $mybb->user['uid'] == $row['uid'])
  836. {
  837. if ($mybb->user['uid'] == intval($userID))
  838. {
  839. $userName = $mybb->user['username'];
  840. }
  841. else {
  842. // Unfortunately, we do not have this username...let's check our cache, if it's not in cache, query it
  843. if (!empty($usernames_cache[$userID]))
  844. {
  845. $userName = $usernames_cache[$userID];
  846. }
  847. else {
  848. $userName = $db->fetch_field($db->simple_select('users', 'username', 'uid=\''.$userID.'\''), 'username');
  849. $usernames_cache[$userID] = $userName;
  850. }
  851. }
  852.  
  853. $message = "<span style=\"background-color: #AF4300; font-weight: bold;\">{$lang->mysb_pvt_to} ".htmlspecialchars_uni($userName).": ".$message."</span>";
  854.  
  855. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  856.  
  857. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  858.  
  859. $username = '<a href="./member.php?action=profile&uid='.$row['uid'].'" {$extra}>'.$row['username'].'</a>';
  860. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  861. $class = alt_trow();
  862.  
  863. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td class='{$class}'><span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; {$report}{$username} - {$date_time} -- {$message}</span></td></tr>";
  864. }
  865. }
  866. else {
  867. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  868.  
  869. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  870.  
  871. $username = '<a href="./member.php?action=profile&uid='.$row['uid'].'" {$extra}>'.$row['username'].'</a>';
  872. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  873. $class = alt_trow();
  874.  
  875. $mysb_shoutbox_data .= "<tr id='shout-{$row[id]}'><td class='{$class}'><span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; {$report}{$username} - {$date_time} -- {$message}</span></td></tr>";
  876. }
  877. }
  878.  
  879.  
  880. eval("\$shoutbox_full = \"".$templates->get("mysb_shoutbox_full")."\";");
  881.  
  882. $db->write_query("SELECT * FROM ".TABLE_PREFIX."mysb_shouts ORDER by id DESC LIMIT 10");
  883.  
  884. output_page($shoutbox_full);
  885. exit;
  886. }
  887.  
  888. function myshoutbox_index()
  889. {
  890. global $mybb, $lang;
  891.  
  892. // show full shoutbox
  893. if ($mybb->input['action'] == 'full_shoutbox')
  894. {
  895. $lang->load('myshoutbox');
  896.  
  897. $perms = myshoutbox_can_view();
  898.  
  899. if ($perms && $perms !== 2) {
  900.  
  901. myshoutbox_show_full();
  902. exit;
  903. }
  904. elseif ($perms === 2 && $mybb->settings['mysb_display_message'] == 1)
  905. {
  906. $lang->mysb_error_ban = $lang->sprintf($lang->mysb_error_ban, htmlspecialchars_uni($mybb->user['mysb_banned_reason']));
  907.  
  908. error($lang->mysb_error_ban);
  909. }
  910. else {
  911. error_no_permission();
  912. }
  913. }
  914. }
  915.  
  916. /**
  917. * Add shoutbox template before output
  918. */
  919. function myshoutbox_output_control(&$page_data)
  920. {
  921. global $mybb, $templates, $mysb_shoutbox, $lang, $theme, $db, $mysb_message;
  922.  
  923. $perms = myshoutbox_can_view();
  924.  
  925. if ($perms && $perms !== 2) {
  926. $lang->load('myshoutbox');
  927.  
  928. // no shout button for guests
  929. if ($mybb->user['usergroup'] == 1)
  930. $extra_js = "ShoutBox.disableShout();";
  931. else
  932. $extra_js = "";
  933.  
  934. eval("\$mysb_shoutbox = \"".$templates->get("mysb_shoutbox")."\";");
  935. }
  936. elseif ($perms === 2 && $mybb->settings['mysb_display_message'] == 1)
  937. {
  938. $lang->load('myshoutbox');
  939.  
  940. $lang->mysb_error_ban = $lang->sprintf($lang->mysb_error_ban, htmlspecialchars_uni($mybb->user['mysb_banned_reason']));
  941.  
  942. // display banned from shoutbox message
  943. eval("\$mysb_shoutbox = \"".$templates->get("mysb_shoutbox_banned")."\";");
  944. }
  945. else {
  946. $mysb_shoutbox = '';
  947. }
  948.  
  949. return str_replace('{myshoutbox_'.$mybb->settings['mysb_key'].'}', $mysb_shoutbox, $page_data); // still allow the shoutbox to be placed anywhere the admin wants
  950. }
  951.  
  952. function myshoutbox_show_shouts($last_id = 0)
  953. {
  954. global $db, $mybb, $parser, $charset, $lang;
  955.  
  956. $perms = myshoutbox_can_view();
  957. if (!$perms || $perms === 2) return;
  958.  
  959. require_once MYBB_ROOT.'inc/class_parser.php';
  960. $parser = new postParser;
  961.  
  962. $last_id = (int)$last_id; // not needed here since when we call the function it converts $last_id to int already
  963.  
  964. $query = $db->write_query("SELECT s.*, u.username, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."mysb_shouts s
  965. LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = s.uid)
  966. WHERE s.id>{$last_id} ORDER by s.id DESC LIMIT {$mybb->settings['mysb_shouts_main']}");
  967.  
  968. // fetch results
  969. $messages = "";
  970. $entries = 0;
  971. $usernames_cache = array();
  972. while ($row = $db->fetch_array($query))
  973. {
  974. $report = "(<a id=\"report_".$row['id']."\" href=\"#shoutbox\" onclick=\"javascript: return ShoutBox.promptReason(".$row['id'].");\" style=\"cursor: pointer;\">{$lang->mysb_report_button}</a>) ";
  975.  
  976.  
  977.  
  978. $parser_options = array(
  979. 'allow_mycode' => $mybb->settings['mysb_allow_mycode'],
  980. 'allow_smilies' => $mybb->settings['mysb_allow_smilies'],
  981. 'allow_imgcode' => $mybb->settings['mysb_allow_imgcode'],
  982. 'allow_html' => $mybb->settings['mysb_allow_html'],
  983. "allow_videocode" => $mybb->settings['mysb_allow_video'],
  984. 'me_username' => $row['username']
  985. );
  986.  
  987.  
  988.  
  989. $profile = "(a href="
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000. $message = $parser->parse_message($row['shout_msg'], $parser_options);
  1001.  
  1002. $find = stripos($message, "/pvt");
  1003. if($find == 0 && $find !== false)
  1004. {
  1005. sscanf($message, "/pvt %d", $userID);
  1006. $userID = (int)$userID;
  1007. $message = str_replace("/pvt ".$userID." ", "", $message);
  1008. if ($mybb->user['uid'] == intval($userID) || $mybb->user['uid'] == $row['uid'])
  1009. {
  1010. if ($mybb->user['uid'] == intval($userID))
  1011. {
  1012. $userName = $mybb->user['username'];
  1013. }
  1014. else {
  1015. // Unfortunately, we do not have this username...let's check our cache, if it's not in cache, query it
  1016. if (!empty($usernames_cache[$userID]))
  1017. {
  1018. $userName = $usernames_cache[$userID];
  1019. }
  1020. else {
  1021. $userName = $db->fetch_field($db->simple_select('users', 'username', 'uid=\''.$userID.'\''), 'username');
  1022. $usernames_cache[$userID] = $userName;
  1023. }
  1024. }
  1025.  
  1026. $message = "<span style=\"background-color: #AF4300; font-weight: bold;\">{$lang->mysb_pvt_to} ".htmlspecialchars_uni($userName).": ".$message."</span>";
  1027.  
  1028. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  1029. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  1030.  
  1031. $username = $row['username'];
  1032. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  1033.  
  1034. if (myshoutbox_can_delete()) {
  1035. $delete = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.deleteShout({$row[id]}, 1,\"{$lang->mysb_delconfirm}\");'>{$lang->mysb_delete}</a>) ";
  1036. if ($row['hidden'] == "yes"){
  1037. $recover = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.recoverShout({$row[id]}, 1, \"{$lang->mysb_recconfirm}\");'>{$lang->mysb_recover}</a>) ";
  1038. $remove = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.removeShout({$row[id]}, 1, \"{$lang->mysb_remconfirm}\");'>{$lang->mysb_remove}</a>) ";
  1039. }
  1040. }
  1041. else {
  1042. $delete = '&nbsp;';
  1043. $recover = '&nbsp;';
  1044. $remove = '&nbsp;';
  1045. }
  1046.  
  1047. if (myshoutbox_can_delete() && $row['hidden'] == "yes") {
  1048. $messages .= "<span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; <strong><span style=\"color: #FF0000\";>{$lang->mysb_deleted_info}</span></strong> &raquo; {$remove}{$recover}{$report}<a href='#' onClick=\"javascript: ShoutBox.pvtAdd(".$row['uid']."); return false;\" {$extra}>{$username}</a> - {$date_time} -- {$message}</span><br />\r\n";
  1049. }
  1050. elseif ($row['hidden'] == "no") $messages .= "<span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; {$delete}{$recover}{$report}<span style=\"\"><a href='#' onClick=\"javascript: ShoutBox.pvtAdd(".$row['uid']."); return false;\" {$extra}>{$username}</a></span> - {$date_time} -- {$message}</span><br />\r\n";
  1051.  
  1052. $entries++;
  1053.  
  1054. if ($entries == 1) {
  1055. $maxid = $row['id'];
  1056. }
  1057. }
  1058. }
  1059. else {
  1060. $row['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
  1061.  
  1062. $extra = ($mybb->usergroup['cancp'] == 1 ? "title='{$row[shout_ip]}'" : "");
  1063.  
  1064. $username = ''.$row['username'].'';
  1065. $date_time = my_date($mybb->settings['mysb_datetime'], $row['shout_date']);
  1066.  
  1067. if (myshoutbox_can_delete()) {
  1068. $delete = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.deleteShout({$row[id]}, 1,\"{$lang->mysb_delconfirm}\");'>{$lang->mysb_delete}</a>) ";
  1069. if ($row['hidden'] == "yes"){
  1070. $recover = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.recoverShout({$row[id]}, 1, \"{$lang->mysb_recconfirm}\");'>{$lang->mysb_recover}</a>) ";
  1071. $remove = "(<a href='#shoutbox' onclick='javascript: return ShoutBox.removeShout({$row[id]}, 1, \"{$lang->mysb_remconfirm}\");'>{$lang->mysb_remove}</a>) ";
  1072. }
  1073. }
  1074. else {
  1075. $delete = '&nbsp;';
  1076. $recover = '&nbsp;';
  1077. $remove = '&nbsp;';
  1078. }
  1079.  
  1080. if (myshoutbox_can_delete() && $row['hidden'] == "yes") {
  1081. $messages .= "<span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; <strong><span style=\"color: #FF0000\";>{$lang->mysb_deleted_info}</span></strong> &raquo; {$remove}{$recover}{$report}<a href='#' onClick=\"javascript: ShoutBox.pvtAdd(".$row['uid']."); return false;\" {$extra}>{$username}</a> - {$date_time} -- {$message}</span><br />\r\n";
  1082. }
  1083. elseif ($row['hidden'] == "no") $messages .= "<span style=\"font-size: {$mybb->settings['mysb_text_size']}px\">&raquo; {$delete}{$recover}{$report}<a href='#' onClick=\"javascript: ShoutBox.pvtAdd(".$row['uid']."); return false;\" {$extra}>{$username}</a> - {$date_time} -- {$message}</span><br />\r\n";
  1084.  
  1085. $entries++;
  1086.  
  1087. if ($entries == 1) {
  1088. $maxid = $row['id'];
  1089. }
  1090. }
  1091. }
  1092.  
  1093. if (!$maxid) {
  1094. $maxid = $last_id;
  1095. }
  1096.  
  1097. echo "{$maxid}^--^{$entries}^--^{$messages}^--^{$chat_messages}";
  1098. exit;
  1099. }
  1100.  
  1101. function myshoutbox_report_shout($reason, $sid)
  1102. {
  1103. global $db, $mybb;
  1104.  
  1105. $sid = intval($sid); // shout id
  1106.  
  1107. if ($mybb->user['uid'] <= 0)
  1108. return false; // guests can't report shouts
  1109.  
  1110. // cannot report an invalid shout
  1111. // get shout
  1112. $query = $db->simple_select('mysb_shouts', '*', 'id=\''.intval($sid).'\'');
  1113. $shout = $db->fetch_array($query);
  1114. if (empty($shout))
  1115. {
  1116. echo "invalid_shout";
  1117. exit;
  1118. }
  1119.  
  1120. // make sure we haven't reported it already
  1121. if (($rid = $db->fetch_field($db->simple_select('mysb_reports', 'rid', 'sid='.intval($sid).' AND username=\''.$db->escape_string($mybb->user['username']).'\''),'rid')))
  1122. {
  1123. echo "already_reported";
  1124. exit;
  1125. }
  1126.  
  1127. // get username of the author of the shout
  1128. $query = $db->simple_select('users', 'username', 'uid=\''.intval($shout['uid']).'\'');
  1129. $username = $db->fetch_field($query, 'username');
  1130.  
  1131. $report = array(
  1132. 'username' => $db->escape_string($mybb->user['username']),
  1133. 'uid' => intval($mybb->user['uid']),
  1134. 'reason' => $db->escape_string($reason),
  1135. 'date' => TIME_NOW,
  1136. 'sid' => $sid,
  1137. 'author_uid' => intval($shout['uid']),
  1138. 'author_username' => $db->escape_string($username)
  1139. );
  1140.  
  1141. $db->insert_query('mysb_reports', $report);
  1142.  
  1143. echo 'shout_reported';
  1144. exit;
  1145. }
  1146.  
  1147. function myshoutbox_profile_click
  1148.  
  1149.  
  1150. 'uid' => intval($mybb->user['uid']),
  1151.  
  1152.  
  1153.  
  1154. function myshoutbox_psp_add_shout()
  1155. {
  1156. global $db, $mybb;
  1157.  
  1158. $perms = myshoutbox_can_view();
  1159.  
  1160. // guests not allowed! neither banned people
  1161. if (!$perms || $perms === 2 || $mybb->user['usergroup'] == 1 || !$mybb->user['uid'])
  1162. {
  1163. die("failed!");
  1164. }
  1165.  
  1166. $shout_data = array(
  1167. 'uid' => (int)$mybb->user['uid'],
  1168. 'shout_msg' => $db->escape_string(str_replace('^--^', '-', $mybb->input['shout_data'])),
  1169. 'shout_date' => TIME_NOW,
  1170. 'shout_ip' => get_ip(),
  1171. 'hidden' => "no"
  1172. );
  1173.  
  1174. if ($db->insert_query('mysb_shouts', $shout_data)) {
  1175. redirect("pspshoutbox.php", "Success! Redirecting..", "Success!");
  1176. } else {
  1177. redirect("pspshoutbox.php", "Failed! Redirecting..", "Failed!");
  1178. }
  1179.  
  1180. exit;
  1181. }
  1182.  
  1183. function myshoutbox_add_shout()
  1184. {
  1185. global $db, $mybb;
  1186.  
  1187. $perms = myshoutbox_can_view();
  1188.  
  1189. // guests not allowed! neither banned users
  1190. if (!$perms || $perms === 2 || $mybb->user['usergroup'] == 1 || $mybb->user['uid'] < 1)
  1191. {
  1192. die("failed!");
  1193. }
  1194.  
  1195. // purge database?
  1196. $postData = trim($mybb->input['shout_data']);
  1197. if ($mybb->usergroup['cancp'] == 1 && substr($postData, 0, 7) == '/delete') {
  1198.  
  1199. preg_match('/\/delete\s{1,}(all|older than|newer than)($|\s{1,}([0-9]+\-[0-9]+\-[0-9]+)|\s{1,}[0-9]+)/i', $postData, $match);
  1200.  
  1201. // we have date?
  1202. if (stristr($match[2], '-'))
  1203. $date = explode('-', $match[2]);
  1204.  
  1205. // purge?
  1206. if ($match[1] == 'all') {
  1207. $db->delete_query('mysb_shouts');
  1208. $db->insert_query('mysb_shouts', array('uid' => intval($mybb->user['uid']), 'shout_msg' => 'First shout', 'shout_date' => time(), 'shout_ip' => get_ip()));
  1209. }
  1210. elseif (strtolower($match[1]) == 'older than')
  1211. {
  1212.  
  1213. if ($date) {
  1214. $timeStamp = mktime(23, 59, 59, $date[0], ($date[1]-1), $date[2]);
  1215. $db->delete_query('mysb_shouts', 'shout_date <= ' . $timeStamp);
  1216. }
  1217. else // delete based on id
  1218. $db->delete_query('mysb_shouts', 'id < ' . intval($match[2]));
  1219. }
  1220. elseif (strtolower($match[1]) == 'newer than')
  1221. {
  1222. if ($date) {
  1223.  
  1224. $timeStamp = mktime(1, 1, 1, $date[0], ($date[1]+1), $date[2]);
  1225. $db->delete_query('mysb_shouts', 'shout_date >= ' . $timeStamp);
  1226. }
  1227. else // delete based on id
  1228. $db->delete_query('mysb_shouts', 'id > ' . intval($match[2]));
  1229. }
  1230.  
  1231. die("deleted");
  1232. }
  1233.  
  1234. // flood check
  1235. if (intval($mybb->settings['mysb_flood_time']) && !is_moderator()) {
  1236. $lastShout = $db->fetch_field($db->simple_select('mysb_shouts', 'MAX(shout_date) as lastShout', 'uid = '.intval($mybb->user['uid'])), 'lastShout');
  1237. $interval = time() - $lastShout;
  1238.  
  1239. if ($interval <= $mybb->settings['mysb_flood_time'])
  1240. die("flood|" . ($mybb->settings['mysb_flood_time'] - $interval));
  1241. }
  1242.  
  1243. // Uid cannot be lower than 1
  1244. $ret = sscanf($postData, "/pvt %d", $userID);
  1245. if ($ret)
  1246. {
  1247. $userID = (int)$userID;
  1248. if ($userID < 1)
  1249. die("failed!");
  1250. }
  1251.  
  1252. $shout_data = array(
  1253. 'uid' => $mybb->user['uid'],
  1254. 'shout_msg' => $db->escape_string(str_replace('^--^', '-', $mybb->input['shout_data'])),
  1255. 'shout_date' => time(),
  1256. 'shout_ip' => get_ip(),
  1257. 'hidden' => "no"
  1258. );
  1259.  
  1260. if ($db->insert_query('mysb_shouts', $shout_data)) {
  1261. echo "success!!";
  1262. } else {
  1263. echo "failed!";
  1264. }
  1265.  
  1266. exit;
  1267. }
  1268.  
  1269. function myshoutbox_delete_shout($shout_id)
  1270. {
  1271. global $db;
  1272.  
  1273. $shout_id = intval($shout_id);
  1274.  
  1275. if (myshoutbox_can_delete()) {
  1276. $db->update_query("mysb_shouts", array('hidden' => "yes"), "id='".$shout_id."'", 1);
  1277. echo "success!";
  1278. }
  1279. else
  1280. echo "failed!";
  1281.  
  1282. exit;
  1283. }
  1284.  
  1285. function myshoutbox_remove_shout($shout_id)
  1286. {
  1287. global $db;
  1288.  
  1289. $shout_id = intval($shout_id);
  1290.  
  1291. if (myshoutbox_can_delete()) {
  1292. $db->write_query("DELETE FROM ".TABLE_PREFIX."mysb_shouts WHERE id = {$shout_id}");
  1293. echo "success!";
  1294. }
  1295. else
  1296. echo "failed!";
  1297.  
  1298. exit;
  1299. }
  1300.  
  1301. function myshoutbox_recover_shout($shout_id)
  1302. {
  1303. global $db;
  1304.  
  1305. $shout_id = intval($shout_id);
  1306.  
  1307. if (myshoutbox_can_delete()) {
  1308. $db->update_query("mysb_shouts", array('hidden' => "no"), "id='".$shout_id."'", 1);
  1309. echo "success!";
  1310. }
  1311. else
  1312. echo "failed!";
  1313.  
  1314. exit;
  1315. }
  1316.  
  1317. function myshoutbox_can_delete()
  1318. {
  1319. global $mybb;
  1320.  
  1321. if ($mybb->usergroup['cancp'] == 1 || ($mybb->settings['mysb_allow_smods'] == 1 && $mybb->usergroup['issupermod'] == 1) || ($mybb->settings['mysb_allow_mods'] == 1 && $mybb->usergroup['canmodcp'] == 1))
  1322. return true;
  1323.  
  1324. return false;
  1325. }
  1326.  
  1327. function myshoutbox_can_view()
  1328. {
  1329. global $mybb;
  1330.  
  1331. if ($mybb->usergroup['canview'] == 0) // can view the board?
  1332. return false;
  1333.  
  1334. // verify if is banned user before checking usergroups
  1335. if (intval($mybb->user['mysb_banned']) == 1) // banned from the shoutbox
  1336. return 2; // 2 means we have been banned
  1337.  
  1338. if (empty($mybb->settings['mysb_usergroups']))
  1339. return true;
  1340.  
  1341. // can guests view the shoutbox?
  1342. /*if ($mybb->settings['mysb_guestview'] == 0 && $mybb->user['usergroup'] == 1)
  1343. return false;*/
  1344.  
  1345. $groups = explode(",", $mybb->settings['mysb_usergroups']);
  1346. $add_groups = "";
  1347.  
  1348. if ($mybb->settings['mysb_additional_groups'] == 1 && $mybb->user['additionalgroups'])
  1349. $add_groups = explode(",", $mybb->user['additionalgroups']);
  1350.  
  1351. if (!in_array($mybb->user['usergroup'], $groups)) { // is the user allowed to view the shoutbox?
  1352. // didn't find gid (primary) in allowed list, check additonal groups if setting is set to yes and if any were found
  1353.  
  1354. if ($add_groups) {
  1355. if (count(array_intersect($add_groups, $groups)) == 0)
  1356. return false;
  1357. }
  1358. else
  1359. return false;
  1360. }
  1361.  
  1362. return true;
  1363.  
  1364. }
  1365.  
  1366. function myshoutbox_admin_home_menu(&$sub_menu)
  1367. {
  1368. global $lang, $db;
  1369.  
  1370. $lang->load('myshoutbox');
  1371.  
  1372. $reports = $db->fetch_field($db->simple_select("mysb_reports", "COUNT(rid) as reports", "marked='0'"), "reports");
  1373.  
  1374. //$reports = $db->fetch_field($db->simple_select("plaza_mydownloads_downloads", "COUNT(did) as comments", "hidden=0"), "comments");
  1375.  
  1376. $sub_menu[] = array('id' => 'myshoutbox', 'title' => $lang->sprintf($lang->myshoutbox_unread_reports, $reports), 'link' => 'index.php?module=tools/myshoutbox&action=reports');
  1377. }
  1378.  
  1379. function myshoutbox_admin_tools_menu(&$sub_menu)
  1380. {
  1381. global $lang;
  1382.  
  1383. $lang->load('myshoutbox');
  1384. $sub_menu[] = array('id' => 'myshoutbox', 'title' => $lang->myshoutbox_index, 'link' => 'index.php?module=tools/myshoutbox');
  1385. }
  1386.  
  1387. function myshoutbox_admin_tools_action_handler(&$actions)
  1388. {
  1389. $actions['myshoutbox'] = array('active' => 'myshoutbox', 'file' => 'myshoutbox');
  1390. }
  1391.  
  1392. function myshoutbox_admin_permissions(&$admin_permissions)
  1393. {
  1394. global $db, $mybb, $lang;
  1395.  
  1396. $lang->load("mysb_shoutbox", false, true);
  1397. $admin_permissions['mysb_shoutbox'] = $lang->mysb_shoutbox_canmanage;
  1398.  
  1399. }
  1400.  
  1401. function myshoutbox_admin()
  1402. {
  1403. global $db, $lang, $mybb, $page, $run_module, $action_file, $mybbadmin, $plugins;
  1404.  
  1405. $lang->load("myshoutbox", false, true);
  1406.  
  1407. if($run_module == 'tools' && $action_file == 'myshoutbox')
  1408. {
  1409. if ($mybb->input['action'] == 'ban')
  1410. {
  1411. if ($mybb->request_method == "post")
  1412. {
  1413. if(!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key'] || !$mybb->input['username'])
  1414. {
  1415. $mybb->request_method = "get";
  1416. flash_message($lang->myshoutbox_error, 'error');
  1417. admin_redirect("index.php?module=tools/myshoutbox");
  1418. }
  1419.  
  1420. $db->update_query('users', array('mysb_banned' => 1, 'mysb_banned_reason' => $db->escape_string($mybb->input['reason'])), 'username=\''.$db->escape_string($mybb->input['username']).'\'', 1);
  1421.  
  1422. $lang->myshoutbox_log_banned = $lang->sprintf($lang->myshoutbox_log_banned, $mybb->input['username']);
  1423. log_admin_action($lang->myshoutbox_log_banned);
  1424.  
  1425. flash_message($lang->myshoutbox_user_banned, 'success');
  1426. admin_redirect("index.php?module=tools/myshoutbox");
  1427. }
  1428. }
  1429. elseif ($mybb->input['action'] == 'unban')
  1430. {
  1431. if ($mybb->request_method == "post")
  1432. {
  1433. if(!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key'] || !$mybb->input['username'])
  1434. {
  1435. $mybb->request_method = "get";
  1436. flash_message($lang->myshoutbox_error, 'error');
  1437. admin_redirect("index.php?module=tools/myshoutbox");
  1438. }
  1439.  
  1440. $db->update_query('users', array('mysb_banned' => 0, 'mysb_banned_reason' => ''), 'username=\''.$db->escape_string($mybb->input['username']).'\'', 1);
  1441.  
  1442. $lang->myshoutbox_log_unbanned = $lang->sprintf($lang->myshoutbox_log_unbanned, $mybb->input['username']);
  1443. log_admin_action($lang->myshoutbox_log_unbanned);
  1444.  
  1445. flash_message($lang->myshoutbox_user_unbanned, 'success');
  1446. admin_redirect("index.php?module=tools/myshoutbox");
  1447. }
  1448. }
  1449. elseif ($mybb->input['action'] == 'delete_report')
  1450. {
  1451. if ($mybb->request_method == "post")
  1452. {
  1453. if(!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key'] || !$mybb->input['rid'])
  1454. {
  1455. $mybb->request_method = "get";
  1456. flash_message($lang->myshoutbox_error, 'error');
  1457. admin_redirect("index.php?module=tools/myshoutbox");
  1458. }
  1459.  
  1460. // don't check if the report id exists, just try to delete it
  1461. $db->delete_query('mysb_reports', 'rid='.intval($mybb->input['rid']), 1);
  1462.  
  1463. log_admin_action($lang->myshoutbox_log_deleted_report);
  1464.  
  1465. flash_message($lang->myshoutbox_report_deleted, 'success');
  1466. admin_redirect("index.php?module=tools/myshoutbox&amp;action=reports");
  1467. }
  1468. }
  1469. elseif ($mybb->input['action'] == 'mark_report')
  1470. {
  1471. if ($mybb->request_method == "post")
  1472. {
  1473. if(!isset($mybb->input['my_post_key']) || $mybb->post_code != $mybb->input['my_post_key'] || !$mybb->input['rid'])
  1474. {
  1475. $mybb->request_method = "get";
  1476. flash_message($lang->myshoutbox_error, 'error');
  1477. admin_redirect("index.php?module=tools/myshoutbox");
  1478. }
  1479.  
  1480. // don't check if the report id exists, just try to mark it as read
  1481. $db->update_query('mysb_reports', array('marked' => 1), 'rid=\''.intval($mybb->input['rid']).'\'', 1);
  1482.  
  1483. log_admin_action($lang->myshoutbox_log_marked_report);
  1484.  
  1485. flash_message($lang->myshoutbox_report_marked, 'success');
  1486. admin_redirect("index.php?module=tools/myshoutbox&amp;action=reports");
  1487. }
  1488. }
  1489. elseif ($mybb->input['action'] == 'reports')
  1490. {
  1491. $page->add_breadcrumb_item($lang->myshoutbox_reported_shouts, 'index.php?module=tools/myshoutbox');
  1492.  
  1493. $page->output_header($lang->myshoutbox_reported_shouts);
  1494.  
  1495. $sub_tabs['myshoutbox'] = array(
  1496. 'title' => $lang->myshoutbox_home,
  1497. 'link' => 'index.php?module=tools/myshoutbox',
  1498. 'description' => $lang->myshoutbox_description
  1499. );
  1500.  
  1501. $sub_tabs['myshoutbox_reports'] = array(
  1502. 'title' => $lang->myshoutbox_reported_shouts." (".intval($db->fetch_field($db->simple_select("mysb_reports", "COUNT(rid) as reports", "marked='0'"), "reports")).")",
  1503. 'link' => 'index.php?module=tools/myshoutbox&amp;action=reports',
  1504. 'description' => $lang->myshoutbox_myshoutbox_reported_shouts_description
  1505. );
  1506.  
  1507. $page->output_nav_tabs($sub_tabs, 'myshoutbox_reports');
  1508.  
  1509. // table
  1510. $table = new Table;
  1511. $table->construct_header($lang->myshoutbox_sid, array('width' => '10%'));
  1512. $table->construct_header($lang->myshoutbox_username);
  1513. $table->construct_header($lang->myshoutbox_reported_by);
  1514. $table->construct_header($lang->myshoutbox_reason);
  1515. $table->construct_header($lang->myshoutbox_date, array('width' => '15%'));
  1516. $table->construct_header($lang->myshoutbox_view);
  1517. $table->construct_header($lang->myshoutbox_delete);
  1518. $table->construct_header($lang->myshoutbox_mark);
  1519.  
  1520. // pagination
  1521. $per_page = 15;
  1522. if($mybb->input['page'] && intval($mybb->input['page']) > 1)
  1523. {
  1524. $mybb->input['page'] = intval($mybb->input['page']);
  1525. $start = ($mybb->input['page']*$per_page)-$per_page;
  1526. }
  1527. else
  1528. {
  1529. $mybb->input['page'] = 1;
  1530. $start = 0;
  1531. }
  1532.  
  1533. $query = $db->simple_select("mysb_reports", "COUNT(rid) as reports");
  1534. $total_rows = $db->fetch_field($query, "reports");
  1535.  
  1536. echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools/myshoutbox&amp;action=reports&amp;page={page}");
  1537.  
  1538. $query = $db->write_query("
  1539. SELECT s.*, r.*
  1540. FROM ".TABLE_PREFIX."mysb_reports r
  1541. LEFT JOIN ".TABLE_PREFIX."mysb_shouts s ON (s.id=r.sid)
  1542. ORDER BY r.date DESC LIMIT {$start}, {$per_page}
  1543. ");
  1544. while($r = $db->fetch_array($query)) {
  1545.  
  1546. if ($r['marked'] == 0)
  1547. {
  1548. $styles = 'background-color: #FFD7D7';
  1549. }
  1550. else
  1551. $styles = '';
  1552.  
  1553. $table->construct_cell(htmlspecialchars_uni($r['sid']), array('width' => '10%', 'style' => $styles));
  1554. $table->construct_cell(build_profile_link($r['author_username'], $r['author_uid']), array('style' => $styles));
  1555. $table->construct_cell(build_profile_link($r['username'], $r['uid']), array('style' => $styles));
  1556. $table->construct_cell(htmlspecialchars_uni($r['reason']), array('style' => $styles));
  1557.  
  1558. $html_data = " <input type=\"submit\" class=\"submit_button\" value=\"{$lang->myshoutbox_view}\" onclick=\"alert('".myshoutbox_jsspecialchars(htmlspecialchars_uni($r['shout_msg']))."')\" />";
  1559.  
  1560. $table->construct_cell(my_date($mybb->settings['dateformat'], $r['date'], '', false).", ".my_date($mybb->settings['timeformat'], $r['date']), array('width' => '15%', 'style' => $styles));
  1561.  
  1562. $table->construct_cell($html_data, array('width' => '10%', 'style' => $styles));
  1563.  
  1564. $form = new Form("index.php?module=tools/myshoutbox&amp;action=delete_report", "post", 'myshoutbox" onsubmit="return confirm(\''.myshoutbox_jsspecialchars($lang->myshoutbox_delete_report_confirm).'\');', 0, "", true);
  1565. $html_data = $form->construct_return;
  1566. $html_data .= $form->generate_hidden_field("rid", $r['rid']);
  1567. $html_data .= "<input type=\"submit\" class=\"submit_button\" value=\"{$lang->myshoutbox_delete}\" />";
  1568. $html_data .= $form->end();
  1569.  
  1570. $table->construct_cell($html_data, array('width' => '10%', 'style' => $styles));
  1571.  
  1572. $form = new Form("index.php?module=tools/myshoutbox&amp;action=mark_report", "post", 'myshoutbox" onsubmit="return confirm(\''.myshoutbox_jsspecialchars($lang->myshoutbox_mark_report_confirm).'\');', 0, "", true);
  1573. $html_data = $form->construct_return;
  1574. $html_data .= $form->generate_hidden_field("rid", $r['rid']);
  1575. $html_data .= "<input type=\"submit\" class=\"submit_button\" value=\"{$lang->myshoutbox_mark}\" />";
  1576. $html_data .= $form->end();
  1577.  
  1578. $table->construct_cell($html_data, array('width' => '10%', 'style' => $styles));
  1579.  
  1580. $table->construct_row();
  1581. $found = true;
  1582. }
  1583.  
  1584. if (!$found)
  1585. {
  1586. $table->construct_cell($lang->myshoutbox_no_shouts_reported, array('colspan' => 8));
  1587. $table->construct_row();
  1588. }
  1589.  
  1590. $table->output($lang->myshoutbox_reported_shouts);
  1591.  
  1592. $page->output_footer();
  1593.  
  1594. exit;
  1595. }
  1596.  
  1597. // no action
  1598. $page->add_breadcrumb_item($lang->myshoutbox_home, 'index.php?module=tools/myshoutbox');
  1599.  
  1600. $page->output_header($lang->myshoutbox_home);
  1601.  
  1602. $sub_tabs['myshoutbox'] = array(
  1603. 'title' => $lang->myshoutbox_home,
  1604. 'link' => 'index.php?module=tools/myshoutbox',
  1605. 'description' => $lang->myshoutbox_description
  1606. );
  1607.  
  1608. $sub_tabs['myshoutbox_reports'] = array(
  1609. 'title' => $lang->myshoutbox_reported_shouts." (".intval($db->fetch_field($db->simple_select("mysb_reports", "COUNT(rid) as reports", "marked='0'"), "reports")).")",
  1610. 'link' => 'index.php?module=tools/myshoutbox&amp;action=reports',
  1611. 'description' => $lang->myshoutbox_myshoutbox_reported_shouts_description
  1612. );
  1613.  
  1614. $page->output_nav_tabs($sub_tabs, 'myshoutbox');
  1615.  
  1616. $tabs = array(
  1617. 'banuser' => $lang->myshoutbox_quick_ban,
  1618. 'unbanuser' => $lang->myshoutbox_quick_unban
  1619. );
  1620.  
  1621. $page->output_tab_control($tabs);
  1622.  
  1623. // quick ban user form
  1624. echo "<div id=\"tab_banuser\">\n";
  1625. $form = new Form("index.php?module=tools/myshoutbox&amp;action=ban", "post", "myshoutbox");
  1626.  
  1627. $form_container = new FormContainer($lang->myshoutbox_ban_user);
  1628. $form_container->output_row($lang->myshoutbox_ban_username, htmlspecialchars_uni($lang->myshoutbox_ban_username_desc), $form->generate_text_box('username', htmlspecialchars_uni($mybb->input['username']), array('id' => 'username')), 'username');
  1629. $form_container->output_row($lang->myshoutbox_ban_reason, htmlspecialchars_uni($lang->myshoutbox_ban_reason_desc), $form->generate_text_box('reason', htmlspecialchars_uni($mybb->input['reason']), array('id' => 'reason')), 'reason');
  1630.  
  1631. $form_container->end();
  1632.  
  1633. $buttons = "";
  1634. $buttons[] = $form->generate_submit_button($lang->myshoutbox_submit);
  1635. $buttons[] = $form->generate_reset_button($lang->myshoutbox_reset);
  1636. $form->output_submit_wrapper($buttons);
  1637. $form->end();
  1638.  
  1639. echo "</div>\n";
  1640.  
  1641. // quick unban user form
  1642. echo "<div id=\"tab_unbanuser\">\n";
  1643. $form = new Form("index.php?module=tools/myshoutbox&amp;action=unban", "post", "myshoutbox");
  1644.  
  1645. $form_container = new FormContainer($lang->myshoutbox_unban_user);
  1646. $form_container->output_row($lang->myshoutbox_unban_username, htmlspecialchars_uni($lang->myshoutbox_unban_username_desc), $form->generate_text_box('username', htmlspecialchars_uni($mybb->input['username']), array('id' => 'username')), 'username');
  1647.  
  1648. $form_container->end();
  1649.  
  1650. $buttons = "";
  1651. $buttons[] = $form->generate_submit_button($lang->myshoutbox_submit);
  1652. $buttons[] = $form->generate_reset_button($lang->myshoutbox_reset);
  1653. $form->output_submit_wrapper($buttons);
  1654. $form->end();
  1655.  
  1656. echo "</div>\n";
  1657.  
  1658. // pagination
  1659. $per_page = 15;
  1660. if($mybb->input['page'] && intval($mybb->input['page']) > 1)
  1661. {
  1662. $mybb->input['page'] = intval($mybb->input['page']);
  1663. $start = ($mybb->input['page']*$per_page)-$per_page;
  1664. }
  1665. else
  1666. {
  1667. $mybb->input['page'] = 1;
  1668. $start = 0;
  1669. }
  1670.  
  1671. $query = $db->simple_select("users", "COUNT(uid) as users", 'mysb_banned=1');
  1672. $total_rows = $db->fetch_field($query, "users");
  1673.  
  1674. echo "<br />".draw_admin_pagination($mybb->input['page'], $per_page, $total_rows, "index.php?module=tools/myshoutbox&amp;page={page}");
  1675.  
  1676. // table
  1677. $table = new Table;
  1678. $table->construct_header("<div style=\"width: 30%;\">".$lang->myshoutbox_username."</div>");
  1679. $table->construct_header("<div style=\"width: 70%;\">".$lang->myshoutbox_reason."</div>");
  1680.  
  1681. $query = $db->simple_select('users', 'uid,username,mysb_banned_reason', 'mysb_banned=1', array('order_by' => 'uid', 'order_dir' => 'ASC', 'limit' => "{$start}, {$per_page}"));
  1682. while($r = $db->fetch_array($query)) {
  1683. $table->construct_cell(htmlspecialchars_uni($r['username']));
  1684. $table->construct_cell(htmlspecialchars_uni($r['mysb_banned_reason']));
  1685. $table->construct_row();
  1686. $found = true;
  1687. }
  1688.  
  1689. if (!$found)
  1690. {
  1691. $table->construct_cell($lang->myshoutbox_no_users_banned, array('colspan' => 2));
  1692. $table->construct_row();
  1693. }
  1694.  
  1695. $table->output($lang->myshoutbox_banned_users);
  1696.  
  1697. $page->output_footer();
  1698.  
  1699. exit;
  1700. }
  1701. }
  1702.  
  1703. /**
  1704. * Somewhat like htmlspecialchars_uni but for JavaScript strings
  1705. *
  1706. * @param string: The string to be parsed
  1707. * @return string: Javascript compatible string
  1708. */
  1709. function myshoutbox_jsspecialchars($str)
  1710. {
  1711. // Converts & -> &amp; allowing Unicode
  1712. // Parses out HTML comments as the XHTML validator doesn't seem to like them
  1713. $string = preg_replace(array("#\<\!--.*?--\>#", "#&(?!\#[0-9]+;)#"), array('','&amp;'), $str);
  1714. return strtr($string, array("\n" => '\n', "\r" => '\r', '\\' => '\\\\', '"' => '\x22', "'" => '\x27', '<' => '&lt;', '>' => '&gt;'));
  1715. }
  1716.  
  1717. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement