diff --git a/imgboard.php b/imgboard.php index 97bb146..9f555fd 100644 --- a/imgboard.php +++ b/imgboard.php @@ -571,6 +571,11 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) } rebuildIndexes(); $text .= manageInfo(__('Rebuilt board.')); + } else if (isset($_GET['reports'])) { + if (!TINYIB_REPORT) { + fancyDie(__('Reporting is disabled.')); + } + $text .= manageReportsPage($_GET['reports']); } elseif (isset($_GET['bans'])) { clearExpiredBans(); @@ -581,6 +586,10 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) fancyDie(__('Sorry, there is already a ban on record for that IP address.')); } + if (TINYIB_REPORT) { + deleteReportsByIP($_POST['ip']); + } + $ban = array(); $ban['ip'] = $_POST['ip']; $ban['expire'] = ($_POST['expire'] > 0) ? (time() + $_POST['expire']) : 0; diff --git a/inc/defines.php b/inc/defines.php index 4c74320..24c5c60 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -53,7 +53,7 @@ if (!defined('TINYIB_MANAGECAPTCHA')) { define('TINYIB_MANAGECAPTCHA', ''); } if (!defined('TINYIB_REPORT')) { - define('TINYIB_REPORT', ''); + define('TINYIB_REPORT', false); } if (!defined('TINYIB_REQMOD')) { define('TINYIB_REQMOD', ''); diff --git a/inc/html.php b/inc/html.php index 1b5db6c..3f50636 100644 --- a/inc/html.php +++ b/inc/html.php @@ -748,6 +748,9 @@ function adminBar() { $output = '[' . __('Status') . '] ['; if ($isadmin) { + if (TINYIB_REPORT) { + $output .= '' . __('Reports') . '] ['; + } $output .= '' . __('Bans') . '] ['; $output .= '' . __('Keywords') . '] ['; } @@ -849,6 +852,74 @@ function manageLogInForm() { EOF; } +function manageReportsPage($ip) { + $reports = allReports(); + $report_counts = array(); + $posts = array(); + foreach ($reports as $report) { + if ($ip != '' && $report['ip'] != $ip && $report['ip'] != hashData($ip)) { + continue; + } + + $post = postByID($report['post']); + if (empty($post)) { + continue; + } + + if ($ip == '') { + $post['reportedby'] = $report['ip']; + + if (!isset($report_counts[$report['ip']])) { + $report_counts[$report['ip']] = 0; + } + $report_counts[$report['ip']]++; + } + + $posts[] = $post; + } + + $txt_reported = __('Reported posts'); + if ($ip != '') { + if (count($posts) == 1) { + $format = __('%1$d report by %2$s'); + } else { + $format = __('%1$d reports by %2$s'); + } + $txt_reported = sprintf($format, count($posts), '' . htmlentities($ip) . ''); + } + + $post_html = ''; + foreach ($posts as $post) { + if ($post_html != '') { + $post_html .= '