PageRenderTime 69ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 1ms

/inc/classes/manage.class.php

https://github.com/Laurelai/tsukiboards
PHP | 4602 lines | 4050 code | 375 blank | 177 comment | 981 complexity | 05741b6fad9baf617ffa2d4dcc051621 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * arcNET 0.2
  4. *
  5. * arcNET uses core code from ONEECHAN and KUSABA X 0.9.3
  6. *
  7. * http://tsukihi.me
  8. *
  9. * http://img.oneechan.org
  10. *
  11. * +------------------------------------------------------------------------------+
  12. * Manage Class
  13. * +------------------------------------------------------------------------------+
  14. * Manage functions, along with the pages available
  15. * +------------------------------------------------------------------------------+
  16. */
  17. class Manage {
  18. /* Show the header of the manage page */
  19. function Header() {
  20. global $dwoo_data, $tpl_page;
  21. if (is_file(KU_ROOTDIR . 'inc/pages/modheader.html')) {
  22. $tpl_includeheader = file_get_contents(KU_ROOTDIR . 'inc/pages/modheader.html');
  23. } else {
  24. $tpl_includeheader = '';
  25. }
  26. $dwoo_data->assign('includeheader', $tpl_includeheader);
  27. }
  28. /* Show the footer of the manage page */
  29. function Footer() {
  30. global $dwoo_data, $dwoo, $tpl_page;
  31. $dwoo_data->assign('page', $tpl_page);
  32. $board_class = new Board('');
  33. $dwoo->output(KU_TEMPLATEDIR . '/manage.tpl', $dwoo_data);
  34. }
  35. // Creates a salt to be used for passwords
  36. function CreateSalt() {
  37. $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  38. $salt = '';
  39. for ($i = 0; $i < 3; ++$i) {
  40. $salt .= $chars[mt_rand(0, strlen($chars) - 1)];
  41. }
  42. return $salt;
  43. }
  44. /* Validate the current session */
  45. function ValidateSession($is_menu = false) {
  46. global $tc_db, $tpl_page;
  47. if (isset($_SESSION['manageusername']) && isset($_SESSION['managepassword'])) {
  48. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `username` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']) . " AND `password` = " . $tc_db->qstr($_SESSION['managepassword']) . " LIMIT 1");
  49. if (count($results) == 0) {
  50. session_destroy();
  51. exitWithErrorPage(_gettext('Invalid session.'), '<a href="manage_page.php">'. _gettext('Log in again.') . '</a>');
  52. }
  53. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "staff` SET `lastactive` = " . time() . " WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']));
  54. return true;
  55. } else {
  56. if (!$is_menu) {
  57. $this->LoginForm();
  58. die($tpl_page);
  59. } else {
  60. return false;
  61. }
  62. }
  63. }
  64. /* Show the login form and halt execution */
  65. function LoginForm() {
  66. global $tc_db, $tpl_page;
  67. if (file_exists(KU_ROOTDIR . 'inc/pages/manage_login.html')) {
  68. $tpl_page .= file_get_contents(KU_ROOTDIR . 'inc/pages/manage_login.html');
  69. }
  70. }
  71. /* Log moderator IP's */
  72. function LogStaffIP(){
  73. global $tc_db;
  74. $getlog = $tc_db->GetAll("SELECT HIGH_PRIORITY `iplog` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']). " LIMIT 1");
  75. $ip = $_SERVER['REMOTE_ADDR'];
  76. if(filter_var($ip, FILTER_VALIDATE_IP)) {
  77. $encip = md5_encrypt($ip, KU_RANDOMSEED);
  78. $logevents = 2;
  79. if(isset($getlog[0]['iplog'])){
  80. $log = $getlog[0]['iplog'];
  81. $currentlog = explode('|', $log);
  82. foreach($currentlog as $log){
  83. if(!isset($log)){
  84. unset($log);
  85. }
  86. }
  87. $currentlog[] = $encip;
  88. if(count($currentlog)>$logevents){
  89. unset($currentlog[0]);
  90. }
  91. if(is_array($currentlog)){
  92. $log = implode('|', $currentlog);
  93. }
  94. }
  95. else{
  96. $log = $encip;
  97. }
  98. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "staff` SET `iplog` = ".$tc_db->qstr($log)." WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']));
  99. }
  100. return true;
  101. }
  102. /* Check login names and create session if user/pass is correct */
  103. function CheckLogin() {
  104. global $tc_db, $action;
  105. $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "loginattempts` WHERE `timestamp` < '" . (time() - 1200) . "'");
  106. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `ip` FROM `" . KU_DBPREFIX . "loginattempts` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' LIMIT 6");
  107. if (count($results) > 5) {
  108. exitWithErrorPage(_gettext('System lockout'), _gettext('Sorry, because of your numerous failed logins, you have been locked out from logging in for 20 minutes. Please wait and then try again.'));
  109. } else {
  110. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `username`, `password`, `salt` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = " . $tc_db->qstr($_POST['username']) . " AND `type` != 3 LIMIT 1");
  111. if (count($results) > 0) {
  112. if (empty($results[0]['salt'])) {
  113. if (md5($_POST['password']) == $results[0]['password']) {
  114. $salt = $this->CreateSalt();
  115. $tc_db->Execute("UPDATE `" .KU_DBPREFIX. "staff` SET salt = '" .$salt. "' WHERE username = " .$tc_db->qstr($_POST['username']));
  116. $newpass = md5($_POST['password'] . $salt);
  117. $tc_db->Execute("UPDATE `" .KU_DBPREFIX. "staff` SET password = '" .$newpass. "' WHERE username = " .$tc_db->qstr($_POST['username']));
  118. $_SESSION['manageusername'] = $_POST['username'];
  119. $_SESSION['managepassword'] = $newpass;
  120. $_SESSION['token'] = md5($_SESSION['manageusername'] . $_SESSION['managepassword'] . rand(0,100));
  121. $this->SetModerationCookies();
  122. $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "loginattempts` WHERE `ip` < '" . $_SERVER['REMOTE_ADDR'] . "'");
  123. $action = 'posting_rates';
  124. $this->LogStaffIP();
  125. management_addlogentry(_gettext('Logged in'), 1);
  126. die('<script type="text/javascript">top.location.href = \''. KU_CGIPATH .'/manage.php\';</script>');
  127. } else {
  128. $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "loginattempts` ( `username` , `ip` , `timestamp` ) VALUES ( " . $tc_db->qstr($_POST['username']) . " , '" . $_SERVER['REMOTE_ADDR'] . "' , '" . time() . "' )");
  129. exitWithErrorPage(_gettext('Incorrect username/password.'));
  130. }
  131. } else {
  132. if (md5($_POST['password'] . $results[0]['salt']) == $results[0]['password']) {
  133. $_SESSION['manageusername'] = $_POST['username'];
  134. $_SESSION['managepassword'] = md5($_POST['password'] . $results[0]['salt']);
  135. $_SESSION['token'] = md5($_SESSION['manageusername'] . $_SESSION['managepassword'] . rand(0,100));
  136. $this->SetModerationCookies();
  137. $action = 'posting_rates';
  138. $this->LogStaffIP();
  139. management_addlogentry(_gettext('Logged in'), 1);
  140. die('<script type="text/javascript">top.location.href = \''. KU_CGIPATH .'/manage.php\';</script>');
  141. } else {
  142. $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "loginattempts` ( `username` , `ip` , `timestamp` ) VALUES ( " . $tc_db->qstr($_POST['username']) . " , '" . $_SERVER['REMOTE_ADDR'] . "' , '" . time() . "' )");
  143. exitWithErrorPage(_gettext('Incorrect username/password.'));
  144. }
  145. }
  146. } else {
  147. $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "loginattempts` ( `username` , `ip` , `timestamp` ) VALUES ( " . $tc_db->qstr($_POST['username']) . " , '" . $_SERVER['REMOTE_ADDR'] . "' , '" . time() . "' )");
  148. exitWithErrorPage(_gettext('Incorrect username/password.'));
  149. }
  150. }
  151. }
  152. /* Set mod cookies for boards */
  153. function SetModerationCookies() {
  154. global $tc_db, $tpl_page;
  155. if (isset($_SESSION['manageusername'])) {
  156. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `boards` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']) . " LIMIT 1");
  157. if ($this->CurrentUserIsAdministrator() || $results[0][0] == 'allboards') {
  158. setcookie("kumod", "allboards", time() + 3600, KU_BOARDSFOLDER, KU_DOMAIN);
  159. } else {
  160. if ($results[0][0] != '') {
  161. setcookie("kumod", $results[0][0], time() + 3600, KU_BOARDSFOLDER, KU_DOMAIN);
  162. }
  163. }
  164. }
  165. }
  166. function CheckToken($posttoken) {
  167. if ($posttoken != $_SESSION['token']) {
  168. // Something is strange
  169. session_destroy();
  170. exitWithErrorPage(_gettext('Invalid Token'));
  171. }
  172. }
  173. /* Log current user out */
  174. function Logout() {
  175. global $tc_db, $tpl_page;
  176. setcookie('kumod', '', time() - 3600, KU_BOARDSFOLDER, KU_DOMAIN);
  177. session_destroy();
  178. unset($_SESSION['manageusername']);
  179. unset($_SESSION['managepassword']);
  180. unset($_SESSION['token']);
  181. die('<script type="text/javascript">top.location.href = \''. KU_CGIPATH .'/manage.php\';</script>');
  182. }
  183. /* If the user logged in isn't an admin, kill the script */
  184. function AdministratorsOnly() {
  185. global $tc_db, $tpl_page;
  186. if (!$this->CurrentUserIsAdministrator()) {
  187. exitWithErrorPage('That page is for admins only.');
  188. }
  189. }
  190. /* If the user logged in isn't an moderator or higher, kill the script */
  191. function ModeratorsOnly() {
  192. global $tc_db, $tpl_page;
  193. if ($this->CurrentUserIsAdministrator()) {
  194. return true;
  195. } else {
  196. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `type` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = '" . $_SESSION['manageusername'] . "' AND `password` = '" . $_SESSION['managepassword'] . "' LIMIT 1");
  197. foreach ($results as $line) {
  198. if ($line['type'] != 2) {
  199. exitWithErrorPage(_gettext('That page is for moderators and administrators only.'));
  200. }
  201. }
  202. }
  203. }
  204. /* See if the user logged in is an admin */
  205. function CurrentUserIsAdministrator() {
  206. global $tc_db, $tpl_page;
  207. if ($_SESSION['manageusername'] == '' || $_SESSION['managepassword'] == '' || $_SESSION['token'] == '') {
  208. $_SESSION['manageusername'] = '';
  209. $_SESSION['managepassword'] = '';
  210. $_SESSION['token'] = '';
  211. return false;
  212. }
  213. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `type` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = '" . $_SESSION['manageusername'] . "' AND `password` = '" . $_SESSION['managepassword'] . "' LIMIT 1");
  214. foreach ($results as $line) {
  215. if ($line['type'] == 1) {
  216. return true;
  217. } else {
  218. return false;
  219. }
  220. }
  221. /* If the function reaches this point, something is fishy. Kill their session */
  222. session_destroy();
  223. exitWithErrorPage(_gettext('Invalid session, please log in again.'));
  224. }
  225. /* See if the user logged in is a moderator */
  226. function CurrentUserIsModerator() {
  227. global $tc_db, $tpl_page;
  228. if ($_SESSION['manageusername'] == '' || $_SESSION['managepassword'] == '' || $_SESSION['token'] == '') {
  229. $_SESSION['manageusername'] = '';
  230. $_SESSION['managepassword'] = '';
  231. $_SESSION['token'] = '';
  232. return false;
  233. }
  234. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `type` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = '" . $_SESSION['manageusername'] . "' AND `password` = '" . $_SESSION['managepassword'] . "' LIMIT 1");
  235. foreach ($results as $line) {
  236. if ($line['type'] == 2) {
  237. return true;
  238. } else {
  239. return false;
  240. }
  241. }
  242. /* If the function reaches this point, something is fishy. Kill their session */
  243. session_destroy();
  244. exitWithErrorPage(_gettext('Invalid session, please log in again.'));
  245. }
  246. /* See if the user logged in is a moderator of a specified board */
  247. function CurrentUserIsModeratorOfBoard($board, $username) {
  248. global $tc_db, $tpl_page;
  249. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `type`, `boards` FROM `" . KU_DBPREFIX . "staff` WHERE `username` = '" . $username . "' LIMIT 1");
  250. if (count($results) > 0) {
  251. foreach ($results as $line) {
  252. if ($line['boards'] == 'allboards') {
  253. return true;
  254. } else {
  255. if ($line['type'] == '1') {
  256. return true;
  257. } else {
  258. $array_boards = explode('|', $line['boards']);
  259. if (in_array($board, $array_boards)) {
  260. return true;
  261. } else {
  262. return false;
  263. }
  264. }
  265. }
  266. }
  267. } else {
  268. return false;
  269. }
  270. }
  271. /*
  272. * +------------------------------------------------------------------------------+
  273. * Manage pages
  274. * +------------------------------------------------------------------------------+
  275. */
  276. /*
  277. * +------------------------------------------------------------------------------+
  278. * Home Pages
  279. * +------------------------------------------------------------------------------+
  280. */
  281. /* View Announcements */
  282. function announcements() {
  283. global $tc_db, $tpl_page;
  284. $this->ModeratorsOnly();
  285. $tpl_page .= '<h1><center>'. _gettext('Announcements') .'</center></h1>'. "\n";
  286. $entries = 0;
  287. /* Get all of the announcements, ordered with the newest one placed on top */
  288. $results = $tc_db->GetAll("SELECT * FROM `".KU_DBPREFIX."announcements` ORDER BY `postedat` DESC");
  289. foreach($results AS $line) {
  290. $entries++;
  291. $tpl_page .= '<h2>'.stripslashes($line['subject']).' '. _gettext('by') .' ';
  292. $tpl_page .= stripslashes($line['postedby']);
  293. $tpl_page .= ' - '.date("n/j/y @ g:iA T", $line['postedat']);
  294. $tpl_page .= '</h2>' .
  295. '<p>'. stripslashes($line['message']) . '</p>';
  296. }
  297. }
  298. function posting_rates() {
  299. global $tc_db, $tpl_page;
  300. $tpl_page .= '<h2>'. _gettext('Posting rates (past hour)') . '</h2><br />';
  301. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "boards` ORDER BY `name` ASC");
  302. if (count($results) > 0) {
  303. $tpl_page .= '<table border="1" cellspacing="2" cellpadding="2" width="100%"><tr><th>'. _gettext('Board') . '</th><th>'. _gettext('Threads') . '</th><th>'. _gettext('Replies') . '</th><th>'. _gettext('Posts') . '</th></tr>';
  304. foreach ($results as $line) {
  305. $rows_threads = $tc_db->GetOne("SELECT HIGH_PRIORITY count(id) FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $line['id'] . " AND `parentid` = 0 AND `timestamp` >= " . (time() - 3600));
  306. $rows_replies = $tc_db->GetOne("SELECT HIGH_PRIORITY count(id) FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $line['id'] . " AND `parentid` != 0 AND `timestamp` >= " . (time() - 3600));
  307. $rows_posts = $rows_threads + $rows_replies;
  308. $threads_perminute = $rows_threads;
  309. $replies_perminute = $rows_replies;
  310. $posts_perminute = $rows_posts;
  311. $tpl_page .= '<tr><td><strong><a href="'. KU_WEBFOLDER . $line['name'] . '">'. $line['name'] . '</a></strong></td><td>'. $threads_perminute . '</td><td>'. $replies_perminute . '</td><td>'. $posts_perminute . '</td></tr>';
  312. }
  313. $tpl_page .= '</table>';
  314. } else {
  315. $tpl_page .= _gettext('No boards');
  316. }
  317. }
  318. function statistics() {
  319. global $tc_db, $tpl_page;
  320. $tpl_page .= '<h2>'. _gettext('Statistics') .'</h2><br />';
  321. $tpl_page .= '<img src="manage_page.php?graph&type=day" />
  322. <img src="manage_page.php?graph&type=week" />
  323. <img src="manage_page.php?graph&type=postnum" />
  324. <img src="manage_page.php?graph&type=unique" />
  325. <img src="manage_page.php?graph&type=posttime" />';
  326. }
  327. function changepwd() {
  328. global $tc_db, $tpl_page;
  329. $tpl_page .= '<h2>'. _gettext('Change account password') . '</h2><br />';
  330. if (isset($_POST['oldpwd']) && isset($_POST['newpwd']) && isset($_POST['newpwd2'])) {
  331. $this->CheckToken($_POST['token']);
  332. if ($_POST['oldpwd'] != '' && $_POST['newpwd'] != '' && $_POST['newpwd2'] != '') {
  333. if ($_POST['newpwd'] == $_POST['newpwd2']) {
  334. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "staff` WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']) . "");
  335. foreach ($results as $line) {
  336. $staff_passwordenc = $line['password'];
  337. $staff_salt = $line['salt'];
  338. }
  339. if (md5($_POST['oldpwd'].$staff_salt) == $staff_passwordenc) {
  340. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "staff` SET `password` = '" . md5($_POST['newpwd'].$staff_salt) . "' WHERE `username` = " . $tc_db->qstr($_SESSION['manageusername']) . "");
  341. $_SESSION['managepassword'] = md5($_POST['newpwd'].$staff_salt);
  342. $tpl_page .= _gettext('Password successfully changed.');
  343. } else {
  344. $tpl_page .= _gettext('The old password you provided did not match the current one.');
  345. }
  346. } else {
  347. $tpl_page .= _gettext('The second password did not match the first.');
  348. }
  349. } else {
  350. $tpl_page .= _gettext('Please fill in all required fields.');
  351. }
  352. $tpl_page .= '<hr />';
  353. }
  354. $tpl_page .= '<form action="manage_page.php?action=changepwd" method="post">
  355. <input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
  356. <label for="oldpwd">'. _gettext('Old password') . ':</label>
  357. <input type="password" name="oldpwd" /><br />
  358. <label for="newpwd">'. _gettext('New password') . ':</label>
  359. <input type="password" name="newpwd" /><br />
  360. <label for="newpwd2">'. _gettext('New password again') . ':</label>
  361. <input type="password" name="newpwd2" /><br />
  362. <input type="submit" value="' ._gettext('Change account password') . '" />
  363. </form>';
  364. }
  365. /*
  366. * +------------------------------------------------------------------------------+
  367. * Site Administration Pages
  368. * +------------------------------------------------------------------------------+
  369. */
  370. function addannouncement() {
  371. global $tc_db, $tpl_page;
  372. $this->AdministratorsOnly();
  373. $disptable = true; $formval = 'add'; $title = _gettext('Announcement Management');
  374. if(isset($_GET['act'])) {
  375. if ($_GET['act'] == 'edit') {
  376. if (isset($_POST['announcement'])) {
  377. $this->CheckToken($_POST['token']);
  378. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "announcements` SET `subject` = " . $tc_db->qstr($_POST['subject']) . ", `message` = " . $tc_db->qstr($_POST['announcement']) . " WHERE `id` = " . $tc_db->qstr($_GET['id']));
  379. $tpl_page .= '<hr /><h3>'. _gettext('Announcement edited') .'</h3><hr />';
  380. management_addlogentry(_gettext('Edited an announcement'));
  381. }
  382. $formval = 'edit&amp;id='. $_GET['id']; $title .= ' - Edit';
  383. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "announcements` WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  384. $values = $results[0]; $disptable = false;
  385. } elseif ($_GET['act'] == 'del') {
  386. $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "announcements` WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  387. $tpl_page .= '<hr /><h3>'. _gettext('Announcement successfully deleted') .'</h3><hr />';
  388. management_addlogentry(_gettext('Deleted an announcement'), 9);
  389. } elseif ($_GET['act'] == 'add' && isset($_POST['announcement']) && isset($_POST['subject'])) {
  390. if (!empty($_POST['announcement']) && !empty($_POST['subject'])) {
  391. $tpl_page .= '<hr />';
  392. $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "announcements` ( `subject` , `message` , `postedat` , `postedby` ) VALUES ( " . $tc_db->qstr($_POST['subject']) . " , " . $tc_db->qstr($_POST['announcement']) . " , '" . time() . "' , " . $tc_db->qstr($_SESSION['manageusername']) . " )");
  393. $tpl_page .= '<h3>'. _gettext('Announcement successfully added.') . '</h3>';
  394. management_addlogentry(_gettext('Added an announcement'), 9);
  395. $tpl_page .= '<hr />';
  396. } else {
  397. $tpl_page .= '<hr />'. _gettext('You must enter a subject as well as a post.') .'<hr />';
  398. }
  399. }
  400. }
  401. $tpl_page .= '<h2>'. $title . '</h2><br />
  402. <form method="post" action="?action=addannouncement&amp;act='. $formval . '">
  403. <input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
  404. <table><tr><td>
  405. <label for="subject">'. _gettext('Subject') . ':</label>
  406. </td><td>
  407. <input type="text" id="subject" name="subject" value="'. (isset($values['subject']) ? $values['subject'] : '') . '" />
  408. <div class="desc">'. _gettext('Can not be left blank') . '</div>
  409. </td></tr><tr><td>
  410. <label for="announcement">'. _gettext('Post') . ':</label>
  411. </td><td>
  412. <textarea id="announcement" name="announcement" rows="25" cols="80">' . (isset($values['message']) ? htmlspecialchars($values['message']) : '') . '</textarea>
  413. </td></tr></table>
  414. <input type="submit" value="'. _gettext('Add') . '" />
  415. </form>
  416. <script type="text/javascript">
  417. $(document).ready(function() {
  418. $("#announcement").markItUp(myHtmlSettings);
  419. });
  420. </script>
  421. ';
  422. if ($disptable) {
  423. $tpl_page .= '<br /><hr /><h1>'. _gettext('Edit/Delete announcement') .'</h1>';
  424. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "announcements` ORDER BY `id` DESC");
  425. if (count($results) > 0) {
  426. $tpl_page .= '<table border="1" width="100%"><tr><th>'. _gettext('Date Added') .'</th><th>'. _gettext('Subject') .'</th><th>'. _gettext('Message') .'</th><th>'. _gettext('Edit/Delete') .'</th></tr>';
  427. foreach ($results as $line) {
  428. $tpl_page .= '<tr><td>'. date('F j, Y, g:i a', $line['postedat']) . '</td><td>'. $line['subject'] . '</td><td>'. $line['message'] . '</td><td>[<a href="?action=addannouncement&amp;act=edit&amp;id='. $line['id'] . '">'. _gettext('Edit') .'</a>] [<a href="?action=addannouncement&amp;act=del&amp;id='. $line['id'] . '">'. _gettext('Delete') .'</a>]</td></tr>';
  429. }
  430. $tpl_page .= '</table>';
  431. } else {
  432. $tpl_page .= _gettext('No announcements yet.');
  433. }
  434. }
  435. }
  436. /* Edit Dwoo templates */
  437. function templates() {
  438. global $tc_db, $tpl_page;
  439. $this->AdministratorsOnly();
  440. $files = array();
  441. $tpl_page .= '<h2>'. _gettext('Template editor') .'</h2><br />';
  442. if ($dh = opendir(KU_TEMPLATEDIR)) {
  443. while (($file = readdir($dh)) !== false) {
  444. if($file != '.' && $file != '..')
  445. $files[] = $file;
  446. }
  447. closedir($dh);
  448. }
  449. sort($files);
  450. if(isset($_POST['templatedata']) && isset($_POST['template'])) {
  451. $this->CheckToken($_POST['token']);
  452. $file = basename($_POST['template']);
  453. if (in_array($file, $files)) {
  454. if(file_exists(KU_TEMPLATEDIR . '/'. $file)) {
  455. file_put_contents(KU_TEMPLATEDIR . '/'. $file, $_POST['templatedata']);
  456. $tpl_page .= '<hr /><h3>'. _gettext('Template edited') .'</h3><hr />';
  457. if (isset($_POST['rebuild'])) {
  458. $this->rebuildall();
  459. }
  460. unset($_POST['template']);
  461. unset($_POST['templatedata']);
  462. }
  463. }
  464. }
  465. if(!isset($_POST['templatedata']) && !isset($_POST['template'])) {
  466. $tpl_page .= '<form method="post" action="?action=templates">
  467. <label for="template">' ._gettext('Template'). ':</label>
  468. <select name="template" id="template">';
  469. foreach($files as $template) {
  470. $tpl_page .='<option name="'. $template .'">'. $template . '</option>';
  471. }
  472. $tpl_page .= '</select>';
  473. }
  474. if(!isset($_POST['templatedata']) && isset($_POST['template'])) {
  475. $file = basename($_POST['template']);
  476. if (in_array($file, $files)) {
  477. if(file_exists(KU_TEMPLATEDIR . '/'. $file)) {
  478. $tpl_page .= '<form method="post" action="?action=templates">
  479. <input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
  480. <input type="hidden" name="template" value="'. $file .'" />
  481. <textarea wrap=off rows=40 cols=100 name="templatedata">'. htmlspecialchars(file_get_contents(KU_TEMPLATEDIR . '/'. $file)) . '</textarea>
  482. <label for="rebuild">'. _gettext('Rebuild HTML after edit?') .'</label>
  483. <input type="checkbox" name="rebuild" /><br /><br />
  484. <div class="desc">'. _gettext('Visit <a href="http://wiki.dwoo.org/">http://wiki.dwoo.org/</a> for syntax information.') . '</div>
  485. <div class="desc">'. sprintf(_gettext('To access Kusaba variables, use {%%KU_VARNAME}, for example {%%KU_BOARDSPATH} would be replaced with %s'), KU_BOARDSPATH) . '</div>
  486. <div class="desc">'. _gettext('Enclose text in {t}{/t} blocks to allow them to be translated for different languages.') . '</div><br /><br />';
  487. }
  488. }
  489. }
  490. $tpl_page .= '<input type="submit" value="' ._gettext('Edit') . '" /></form>';
  491. }
  492. function index() {
  493. global $tpl_page;
  494. $this->AdministratorsOnly();
  495. $faq = KU_ROOTDIR . 'index.php';
  496. if (!empty($_POST['niggers'])) {
  497. file_put_contents($faq, $_POST['niggers']);
  498. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  499. }
  500. $content = file_get_contents(KU_ROOTDIR . 'index.php');
  501. $tpl_page .= '<h2>'. _gettext('Index.php') .'</h2> Raw PHP editor for the index.php page.<br /><br />'. "\n" .
  502. '<form action="?action=index" method="post">'. "\n" .
  503. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  504. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  505. '</form>'. "\n";
  506. }
  507. # SQL Dumper
  508. function sqldump() {
  509. global $tc_db, $tpl_page;
  510. $this->AdministratorsOnly();
  511. $tpl_page .= '<h2>' . _gettext('Execute a MySQL dump') . '</h2><br />';
  512. $tpl_page .= '<table width="400px"><tr><td>Connecting to server...</td><td>';
  513. $con = mysql_connect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD);
  514. if (!$con) {
  515. $tpl_page .= '[&nbsp;<span style="color:#FF0000">FAILED</span>&nbsp;]</td></tr><tr><td colspan="2">' . mysql_error() . '</td></tr></table><br /><br />A dump cannot be taken until connection error(s) are corrected.';
  516. } else {
  517. $tpl_page .= '[&nbsp;&nbsp;&nbsp;<span style="color:#00FF00">OK</span>&nbsp;&nbsp;&nbsp;]</td></tr><tr><td>Connecting to database...</td><td>';
  518. $db_selected = mysql_select_db(KU_DBDATABASE, $con);
  519. if (!$db_selected) {
  520. $tpl_page .= '[&nbsp;<span style="color:#FF0000">FAILED</span>&nbsp;]</td></tr><tr><td colspan="2">' . mysql_error() . '</td></tr></table><br /><br />A dump cannot be taken until database error(s) are corrected.';
  521. } else {
  522. $tpl_page .= '[&nbsp;&nbsp;&nbsp;<span style="color:#00FF00">OK</span>&nbsp;&nbsp;&nbsp;]</td></tr></table><br /><br />A dump can be taken.&nbsp;&nbsp;&nbsp;[&nbsp;<a href="manage_page.php?action=sqldump&dump=1">Execute</a>&nbsp;]';
  523. }
  524. }
  525. if (isset($_GET['dump'])) {
  526. header('Content-type: text/plain');
  527. header('Content-Disposition: attachment; filename="' . date('Y') . '.' . date('m') . '.' . date ('d') . '.http@www' . KU_DOMAIN . '.sql"');
  528. _mysqldump($db_selected);
  529. die();
  530. }
  531. }
  532. /* Add, edit, delete, and view news entries */
  533. function news() {
  534. global $tc_db, $tpl_page;
  535. $this->AdministratorsOnly();
  536. $disptable = true; $formval = 'add'; $title = _gettext('News Management');
  537. if(isset($_GET['act'])) {
  538. if ($_GET['act'] == 'edit') {
  539. if (isset($_POST['news'])) {
  540. $this->CheckToken($_POST['token']);
  541. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "front` SET `subject` = " . $tc_db->qstr($_POST['subject']) . ", `message` = " . $tc_db->qstr($_POST['news']) . ", `email` = " . $tc_db->qstr($_POST['email']) . " WHERE `id` = " . $tc_db->qstr($_GET['id']) . " AND `page` = 0");
  542. $tpl_page .= '<hr /><h3>'. _gettext('News post edited') .'</h3><hr />';
  543. management_addlogentry(_gettext('Edited a news entry'), 9);
  544. }
  545. $formval = 'edit&amp;id='. $_GET['id']; $title .= ' - Edit';
  546. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "front` WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  547. $values = $results[0];
  548. $disptable = false;
  549. } elseif ($_GET['act'] == 'del') {
  550. $results = $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "front` WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  551. $tpl_page .= '<hr /><h3>'. _gettext('News post deleted') .'</h3><hr />';
  552. management_addlogentry(_gettext('Deleted a news entry'), 9);
  553. } elseif ($_GET['act'] == 'add') {
  554. if (isset($_POST['news']) && isset($_POST['subject']) && isset($_POST['email'])) {
  555. if (!empty($_POST['news']) || !empty($_POST['subject'])) {
  556. $this->CheckToken($_POST['token']);
  557. $tpl_page .= '<hr />';
  558. $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "front` ( `page`, `subject` , `message` , `timestamp` , `poster` , `email` ) VALUES ( '0', " . $tc_db->qstr($_POST['subject']) . " , " . $tc_db->qstr($_POST['news']) . " , '" . time() . "' , " . $tc_db->qstr($_SESSION['manageusername']) . " , " . $tc_db->qstr($_POST['email']) . " )");
  559. $tpl_page .= '<h3>'. _gettext('News entry successfully added.') . '</h3>';
  560. management_addlogentry(_gettext('Added a news entry'), 9);
  561. $tpl_page .= '<hr />';
  562. } else {
  563. $tpl_page .= '<hr />'. _gettext('You must enter a subject as well as a post.') .'<hr />';
  564. }
  565. }
  566. }
  567. }
  568. $tpl_page .= '<h2>'. $title . '</h2><br />
  569. <form method="post" action="?action=news&amp;act='. $formval . '">
  570. <input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
  571. <table><tr>
  572. <td><label for="subject">'. _gettext('Subject') . ':</label></td>
  573. <td><input type="text" size="50" id="subject" name="subject" value="'. (isset($values['subject']) ? $values['subject'] : '') . '" />
  574. <div class="desc">'. _gettext('Can not be left blank.') . '</div></td></tr><tr>
  575. <td><label for="news"> '. _gettext('Post') . ':</label></td>
  576. <td><textarea id="news" name="news" rows="25" cols="80">' . (isset($values['message']) ? htmlspecialchars($values['message']) : '') . '</textarea><br /></td></tr><tr>
  577. <td><label for="email">'. _gettext('E-mail') . ':</label></td>
  578. <td><input type="text" id="email" name="email" value="'. (isset($values['postedemail']) ? $values['postedemail'] : '') . '" />
  579. <div class="desc">'. _gettext('Can be left blank.') . '</div></td></tr></table>
  580. <input type="submit" value="'. _gettext('Add') . '" />
  581. </form>
  582. <script type="text/javascript">
  583. $(document).ready(function() {
  584. $("#news").markItUp(myHtmlSettings);
  585. });
  586. </script>
  587. ';
  588. if ($disptable) {
  589. $tpl_page .= '<br /><hr /><h1>'. _gettext('Edit/Delete News') .'</h1>';
  590. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 0 ORDER BY `timestamp` DESC");
  591. if (count($results) > 0) {
  592. $tpl_page .= '<table border="1" width="100%"><tr><th>'. _gettext('Date Added') .'</th><th>'. _gettext('Subject') .'</th><th>'. _gettext('Message') .'</th><th>'. _gettext('Edit/Delete') .'</th></tr>';
  593. foreach ($results as $line) {
  594. $tpl_page .= '<tr><td>'. date('F j, Y, g:i a', $line['timestamp']) . '</td><td>'. $line['subject'] . '</td><td>'. $line['message'] . '</td><td>[<a href="?action=news&amp;act=edit&amp;id='. $line['id'] . '">'. _gettext('Edit') .'</a>] [<a href="?action=news&amp;act=del&amp;id='. $line['id'] . '">'. _gettext('Delete') .'</a>]</td></tr>';
  595. }
  596. $tpl_page .= '</table>';
  597. } else {
  598. $tpl_page .= _gettext('No news posts yet.');
  599. }
  600. }
  601. }
  602. function faq() {
  603. global $tc_db, $tpl_page;
  604. $this->AdministratorsOnly();
  605. $faq = KU_ROOTDIR . 'faq.php';
  606. if (!empty($_POST['niggers'])) {
  607. file_put_contents($faq, $_POST['niggers']);
  608. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  609. }
  610. $content = file_get_contents(KU_ROOTDIR . 'faq.php');
  611. $tpl_page .= '<h2>'. _gettext('Frequently Asked Questions') .'</h2> Raw PHP editor for the FAQ page.<br /><br />'. "\n" .
  612. '<form action="?action=faq" method="post">'. "\n" .
  613. '<textarea name="niggers" id="faqEditor" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  614. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  615. '</form>
  616. <script type="text/javascript">
  617. $(document).ready(function() {
  618. $("#faqEditor").markItUp(myHtmlSettings);
  619. });
  620. </script>
  621. '. "\n";
  622. }
  623. function rules() {
  624. global $tc_db, $tpl_page;
  625. $this->AdministratorsOnly();
  626. if (!empty($_POST['rules'])) {
  627. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "front` SET `message` = " . $tc_db->qstr($_POST['rules']) . " WHERE `id` = " . $tc_db->qstr($_POST['ruleId']) . " AND `page` = 2");
  628. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  629. $tpl_page .= $tc_db->ErrorMsg();
  630. }
  631. $vals = $tc_db->GetAll("SELECT `id`, `message` FROM `" . KU_DBPREFIX . "front` WHERE `page` = 2 ORDER BY `id` LIMIT 1");
  632. if (count($vals) == 0) {
  633. $id = $tc_db->Execute("INSERT INTO `" . KU_DBPREFIX . "front` ( `page`, `subject` , `message` , `timestamp` , `poster` , `email` ) VALUES ( '2', 'Rules', '', '" . time() . "', '', '')");
  634. $content = '';
  635. $tpl_page .= 'Inserted rules post with Id ' . $id;
  636. } else {
  637. $id = $vals[0]['id'];
  638. $content = $vals[0]['message'];
  639. }
  640. $tpl_page .= '<h2>'. _gettext('Rules Management') .'</h2> Raw HTML editor for the Rules page.<br /><br />'. "\n" .
  641. '<form action="?action=rules" method="post">'. "\n" .
  642. '<input type="hidden" name="ruleId" value="' . $id . '" />'."\n" .
  643. '<textarea name="rules" id="rulesEditor" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  644. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  645. '</form>
  646. <script type="text/javascript">
  647. $(document).ready(function() {
  648. $("#rulesEditor").markItUp(myHtmlSettings);
  649. });
  650. </script>
  651. '. "\n";
  652. }
  653. function staffpage() {
  654. global $tpl_page;
  655. $this->AdministratorsOnly();
  656. $faq = KU_ROOTDIR . 'staff.php';
  657. if (!empty($_POST['niggers'])) {
  658. file_put_contents($faq, $_POST['niggers']);
  659. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  660. }
  661. $content = file_get_contents(KU_ROOTDIR . 'staff.php');
  662. $tpl_page .= '<h2>'. _gettext('Staff') .'</h2> Raw PHP editor for the Staff page.<br /><br />'. "\n" .
  663. '<form action="?action=staffpage" method="post">'. "\n" .
  664. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  665. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  666. '</form>'. "\n";
  667. }
  668. function legal() {
  669. global $tpl_page;
  670. $this->AdministratorsOnly();
  671. $faq = KU_ROOTDIR . 'legal.php';
  672. if (!empty($_POST['niggers'])) {
  673. file_put_contents($faq, $_POST['niggers']);
  674. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  675. }
  676. $content = file_get_contents(KU_ROOTDIR . 'legal.php');
  677. $tpl_page .= '<h2>'. _gettext('Legal') .'</h2> Raw PHP editor for the Legal page.<br /><br />'. "\n" .
  678. '<form action="?action=legal" method="post">'. "\n" .
  679. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  680. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  681. '</form>'. "\n";
  682. }
  683. function boardman() {
  684. global $tpl_page;
  685. $this->AdministratorsOnly();
  686. $faq = KU_ROOTDIR . 'boardlist.php';
  687. if (!empty($_POST['niggers'])) {
  688. file_put_contents($faq, $_POST['niggers']);
  689. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  690. }
  691. $content = file_get_contents(KU_ROOTDIR . 'boardlist.php');
  692. $tpl_page .= '<h2>'. _gettext('Boardlist Template') .'</h2> Raw PHP editor for the boards table.<br /><br />'. "\n" .
  693. '<form action="?action=boardman" method="post">'. "\n" .
  694. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  695. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  696. '</form>'. "\n";
  697. }
  698. function tempfooter() {
  699. global $tpl_page;
  700. $this->AdministratorsOnly();
  701. $faq = KU_ROOTDIR . 'footer.php';
  702. if (!empty($_POST['niggers'])) {
  703. file_put_contents($faq, $_POST['niggers']);
  704. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  705. }
  706. $content = file_get_contents(KU_ROOTDIR . 'footer.php');
  707. $tpl_page .= '<h2>'. _gettext('Footer Template') .'</h2> Raw PHP editor for the footer template.<br /><br />'. "\n" .
  708. '<form action="?action=tempfooter" method="post">'. "\n" .
  709. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  710. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  711. '</form>'. "\n";
  712. }
  713. function tempheader() {
  714. global $tpl_page;
  715. $this->AdministratorsOnly();
  716. $faq = KU_ROOTDIR . 'header.php';
  717. if (!empty($_POST['niggers'])) {
  718. file_put_contents($faq, $_POST['niggers']);
  719. $tpl_page .= '<hr />'. _gettext('Templates successfully edited.') .'<hr />';
  720. }
  721. $content = file_get_contents(KU_ROOTDIR . 'header.php');
  722. $tpl_page .= '<h2>'. _gettext('Header Template') .'</h2> Raw PHP editor for the header template.<br /><br />'. "\n" .
  723. '<form action="?action=tempheader" method="post">'. "\n" .
  724. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  725. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  726. '</form>'. "\n";
  727. }
  728. function boardhtml() {
  729. global $tpl_page;
  730. $this->AdministratorsOnly();
  731. $faq = KU_ROOTDIR . 'boards.html';
  732. if (!empty($_POST['niggers'])) {
  733. file_put_contents($faq, $_POST['niggers']);
  734. $tpl_page .= '<hr />'. _gettext('boards.html successfully edited. REMEMBER TO REBUILD HTML') .'<hr />';
  735. }
  736. $content = file_get_contents(KU_ROOTDIR . 'boards.html');
  737. $tpl_page .= '<h2>'. _gettext('Header Template') .'</h2> Raw PHP editor for boards.html<br /><br />'. "\n" .
  738. '<form action="?action=tempheader" method="post">'. "\n" .
  739. '<textarea name="niggers" rows="25" cols="140">' . $content . '</textarea><br />' . "\n" .
  740. '<input type="submit" value="'. _gettext('Submit') .'" />'. "\n" .
  741. '</form>'. "\n";
  742. }
  743. function blotter() {
  744. global $tc_db, $tpl_page;
  745. $this->AdministratorsOnly();
  746. if (!KU_BLOTTER) exitWithErrorPage(_gettext('Blotter is disabled'));
  747. $tpl_page .= '<h2>' ._gettext('Blotter'). '</h2><br />';
  748. $act = 'add'; $values = array();
  749. if (isset($_GET['act'])) {
  750. switch($_GET['act']) {
  751. case 'add':
  752. if (isset($_POST['message'])) {
  753. $this->CheckToken($_POST['token']);
  754. $important = (isset($_POST['important'])) ? 1 : 0;
  755. $tc_db->Execute("INSERT INTO `" . KU_DBPREFIX . "blotter` (`at`, `message`, `important`) VALUES ('" . time() . "', " . $tc_db->qstr($_POST['message']) . ", '" . $important . "')");
  756. $tpl_page .= '<h3>'. _gettext('Blotter entry added.') . '</h3>';
  757. clearBlotterCache();
  758. }
  759. break;
  760. case 'del':
  761. if (is_numeric($_GET['id'])) {
  762. $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "blotter` WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  763. $tpl_page .= '<hr /><h3>'. _gettext('Blotter entry deleted.') . '</h3><hr />';
  764. clearBlotterCache();
  765. } else {
  766. exitWithErrorPage(_gettext('Invalid ID'));
  767. }
  768. break;
  769. case 'edit':
  770. if (is_numeric($_GET['id'])) {
  771. $act = 'edit&amp;id=' .$_GET['id'];
  772. if (isset($_POST['message'])) {
  773. $this->CheckToken($_POST['token']);
  774. $important = (isset($_POST['important'])) ? 1 : 0;
  775. $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "blotter` SET `message` = " . $tc_db->qstr($_POST['message']) . ", `important` = '" . $important . "' WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  776. $tpl_page .= '<h3>'. _gettext('Blotter entry updated.') . '</h3>';
  777. clearBlotterCache();
  778. }
  779. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "blotter` WHERE `id` = " . $tc_db->qstr($_GET['id']) . " LIMIT 1");
  780. $values = $results[0];
  781. } else {
  782. exitWithErrorPage(_gettext('Invalid ID'));
  783. }
  784. break;
  785. default:
  786. exitWithErrorPage(_gettext('Invalid value for \'act\''));
  787. break;
  788. }
  789. }
  790. $tpl_page .= '<form action="?action=blotter&amp;act=' .$act. '" method="post">
  791. <input type="hidden" name="token" value="' . $_SESSION['token'] . '" />
  792. <label for="message">' ._gettext('Message'). ':</label>
  793. <input type="text" id="message" name="message" value="' .(isset($values['message']) ? $values['message'] : ''). '" size="75" /><br />
  794. <label for="important">' ._gettext('Important'). ':</label>
  795. <input type="checkbox" id="important" name="important" ';
  796. if (isset($values['important']) && $values['important'] == 1) $tpl_page .= 'checked="checked" ';
  797. $tpl_page .= '/><br />
  798. <input type="submit" value="' ._gettext('Submit'). '" /><br />
  799. </form><br /><br />';
  800. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "blotter` ORDER BY `id` DESC");
  801. if (count($results) > 0) {
  802. $tpl_page .= '<table border="1" width="100%"><tr><th>'. _gettext('At') . '</th><th>'. _gettext('Message') . '</th><th>'. _gettext('Important') . '</th><th>&nbsp;</th></tr>';
  803. foreach ($results as $line) {
  804. $tpl_page .= '<tr><td>'. date('m/d/y', $line['at']) . '</td><td>'. $line['message'] . '</td><td>';
  805. $tpl_page .= ($line['important'] == 1) ? _gettext('Yes') : _gettext('No');
  806. $tpl_page .= '</td><td>[<a href="?action=blotter&amp;act=edit&amp;id='. $line['id'] . '">'. _gettext('Edit') .'</a>] [<a href="?action=blotter&amp;act=del&amp;id='. $line['id'] . '">'. _gettext('Delete') .'</a>]</td></tr>';
  807. }
  808. $tpl_page .= '</table>';
  809. } else {
  810. $tpl_page .= _gettext('No blotter entries');
  811. }
  812. }
  813. /* Display disk space used per board, and finally total in a large table */
  814. function spaceused() {
  815. global $tc_db, $tpl_page;
  816. $this->AdministratorsOnly();
  817. $tpl_page .= '<h2>'. _gettext('Disk space used') . '</h2><br />';
  818. $spaceused_res = 0;
  819. $spaceused_src = 0;
  820. $spaceused_thumb = 0;
  821. $spaceused_total = 0;
  822. $files_res = 0;
  823. $files_src = 0;
  824. $files_thumb = 0;
  825. $files_total = 0;
  826. $tpl_page .= '<table border="1" width="100%"><tr><th>'. _gettext('Board') .'</th><th>'. _gettext('Area') .'</th><th>'. _gettext('Files') .'</th><th>'. _gettext('Space Used') .'</th></tr>';
  827. $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `name` FROM `" . KU_DBPREFIX . "boards` ORDER BY `name` ASC");
  828. foreach ($results as $line) {
  829. list($spaceused_board_res, $files_board_res) = recursive_directory_size(KU_BOARDSDIR . $line['name'] . '/res');
  830. list($spaceused_board_src, $files_board_src) = recursive_directory_size(KU_BOARDSDIR . $line['name'] . '/src');
  831. list($spaceused_board_thumb, $files_board_thumb) = recursive_directory_size(KU_BOARDSDIR . $line['name'] . '/thumb');
  832. $spaceused_board_total = $spaceused_board_res + $spaceused_board_src + $spaceused_board_thumb;
  833. $files_board_total = $files_board_res + $files_board_src + $files_board_thumb;
  834. $spaceused_res += $spaceused_board_res;
  835. $files_res += $files_board_res;
  836. $spaceused_src += $spaceused_board_src;
  837. $files_src += $files_board_src;
  838. $spaceused_thumb += $spaceused_board_thumb;
  839. $files_thumb += $files_board_thumb;
  840. $spaceused_total += $spaceused_board_total;
  841. $files_total += $files_board_total;
  842. $tpl_page .= '<tr><td rowspan="4">/'.$line['name'].'/</td><td>res/</td><td>'. number_format($files_board_res) . '</td><td>'. ConvertBytes($spaceused_board_res) . '</td></tr>';
  843. $tpl_page .= '<tr><td>src/</td><td>'. number_format($files_board_src) . '</td><td>'. ConvertBytes($spaceused_board_src) . '</td></tr>';
  844. $tpl_page .= '<tr><td>thumb/</td><td>'. number_format($files_board_thumb) . '</td><td>'. ConvertBytes($spaceused_board_thumb) . '</td></tr>';
  845. $tpl_page .= '<tr><td><strong>'. _gettext('Total') .'</strong></td><td>'. number_format($files_board_total) . '</td><td>'. ConvertBytes($spaceused_board_total) . '</td></tr>';
  846. }
  847. $tpl_page .= '<tr><td rowspan="4"><strong>'. _gettext('All boards') .'</strong></td><td>res/</td><td>'. number_format($files_res) . '</td><td>'. ConvertBytes($spaceused_res) . '</td></tr>';
  848. $tpl_page .= '<tr><td>src/</td><td>'. number_format($files_src) . '</td><td>'. ConvertBytes($spaceused_src) . '</td></tr>';
  849. $tpl_page .= '<tr><td>thumb/</td><td>'. number_format($files_thumb) . '</td><td>'. ConvertBytes($s

Large files files are truncated, but you can click here to view the full file