From fb4f0672d7258a2f4139d61b20b0f046ed800f8d Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 30 Jul 2011 15:42:28 +1000 Subject: [PATCH] redirect after posting IP address note so they cannot repost with F5 --- mod.php | 340 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 171 insertions(+), 169 deletions(-) diff --git a/mod.php b/mod.php index df7e8a63..6af3986a 100644 --- a/mod.php +++ b/mod.php @@ -2110,183 +2110,185 @@ markup($_POST['note']); $query->bindValue(':body', $_POST['note']); $query->execute() or error(db_error($query)); - } - - $body = ''; - $boards = listBoards(); - foreach($boards as &$_board) { - openBoard($_board['uri']); - $temp = ''; - $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` DESC LIMIT :limit", $_board['uri'])); - $query->bindValue(':ip', $ip); - $query->bindValue(':limit', $config['mod']['ip_recentposts'], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + header('Location: ?/IP/' . $ip, true, $config['redirect_http']); + } else { + $body = ''; + $boards = listBoards(); + foreach($boards as &$_board) { + openBoard($_board['uri']); - while($post = $query->fetch()) { - if(!$post['thread']) { - $po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], '?/', $mod, false); - } else { - $po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod); - } - $temp .= $po->build(true) . '
'; - } + $temp = ''; + $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `time` DESC LIMIT :limit", $_board['uri'])); + $query->bindValue(':ip', $ip); + $query->bindValue(':limit', $config['mod']['ip_recentposts'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); - if(!empty($temp)) - $body .= '
Last ' . $query->rowCount() . ' posts on ' . - sprintf($config['board_abbreviation'], $_board['uri']) . ' - ' . $_board['title'] . - '' . $temp . '
'; - } - - if($mod['type'] >= $config['mod']['view_notes']) { - $query = prepare("SELECT * FROM `ip_notes` WHERE `ip` = :ip ORDER BY `id` DESC"); - $query->bindValue(':ip', $ip); - $query->execute() or error(db_error($query)); - - if($query->rowCount() > 0 || $mod['type'] >= $config['mod']['create_notes'] ) { - $body .= '
' . - $query->rowCount() . ' note' . ($query->rowCount() == 1 ?'' : 's') . ' on record' . - ''; - if($query->rowCount() > 0) { - $body .= '' . - '' . - ($mod['type'] >= $config['mod']['remove_notes'] ? '' : '') . - ''; - while($note = $query->fetch()) { - - if($note['mod']) { - $_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id"); - $_query->bindValue(':id', $note['mod']); - $_query->execute() or error(db_error($_query)); - if($_mod = $_query->fetch()) { - if($mod['type'] >= $config['mod']['editusers']) - $staff = '' . htmlentities($_mod['username']) . ''; - else - $staff = $_mod['username']; - } else { - $staff = '??'; - } - } else { - $staff = 'system'; - } - $body .= '' . - '' . - ($mod['type'] >= $config['mod']['remove_notes'] ? - '' - : '') . - ''; + while($post = $query->fetch()) { + if(!$post['thread']) { + $po = new Thread($post['id'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['sticky'], $post['locked'], $post['embed'], '?/', $mod, false); + } else { + $po = new Post($post['id'], $post['thread'], $post['subject'], $post['email'], $post['name'], $post['trip'], $post['capcode'], $post['body'], $post['time'], $post['thumb'], $post['thumbwidth'], $post['thumbheight'], $post['file'], $post['filewidth'], $post['fileheight'], $post['filesize'], $post['filename'], $post['ip'], $post['embed'], '?/', $mod); } - $body .= '
StaffNoteDateActions
' . - $staff . - '' . - $note['body'] . - '' . - date($config['post_date'], $note['time']) . - '[delete]
'; + $temp .= $po->build(true) . '
'; } - - if($mod['type'] >= $config['mod']['create_notes']) { - $body .= '
' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - '
Staff' . $mod['username'] . '
' . - '
'; - } - - $body .= '
'; - } - } - - if($mod['type'] >= $config['mod']['view_ban']) { - $query = prepare("SELECT * FROM `bans` LEFT JOIN `boards` ON `boards`.`id` = `board` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `ip` = :ip"); - $query->bindValue(':ip', $ip); - $query->execute() or error(db_error($query)); - if($query->rowCount() > 0) { - $body .= '
Ban' . ($query->rowCount() == 1 ? '' : 's') . ' on record
'; - - while($ban = $query->fetch()) { - $body .= '' . - - // IP - '' . - - // Reason - '' . - - // Board - '' . - - // Set - '' . - - // Expires - '' . - - // Staff - '' . - - '
Status' . - ($config['mod']['view_banexpired'] && $ban['expires'] != 0 && $ban['expires'] < time() ? - 'Expired' - : 'Active') . - '
IP' . $ban['ip'] . '
Reason' . $ban['reason'] . '
Board' . - (isset($ban['uri']) ? - sprintf($config['board_abbreviation'], $ban['uri']) - : - 'all boards' - ) . '
Set' . date($config['post_date'], $ban['set']) . '
Expires' . - ($ban['expires'] == 0 ? - 'Never' - : - date($config['post_date'], $ban['expires']) - ) . - '
Staff' . - ($mod['type'] < $config['mod']['view_banstaff'] ? - ($config['mod']['view_banquestionmark'] ? - '?' - : - ($ban['type'] == JANITOR ? 'Janitor' : - ($ban['type'] == MOD ? 'Mod' : - ($ban['type'] == ADMIN ? 'Admin' : - '?'))) - ) - : - $ban['username'] - ) . - '
'; - } - - $body .= '
'; + if(!empty($temp)) + $body .= '
Last ' . $query->rowCount() . ' posts on ' . + sprintf($config['board_abbreviation'], $_board['uri']) . ' - ' . $_board['title'] . + '' . $temp . '
'; } + + if($mod['type'] >= $config['mod']['view_notes']) { + $query = prepare("SELECT * FROM `ip_notes` WHERE `ip` = :ip ORDER BY `id` DESC"); + $query->bindValue(':ip', $ip); + $query->execute() or error(db_error($query)); + + if($query->rowCount() > 0 || $mod['type'] >= $config['mod']['create_notes'] ) { + $body .= '
' . + $query->rowCount() . ' note' . ($query->rowCount() == 1 ?'' : 's') . ' on record' . + ''; + if($query->rowCount() > 0) { + $body .= '' . + '' . + ($mod['type'] >= $config['mod']['remove_notes'] ? '' : '') . + ''; + while($note = $query->fetch()) { + + if($note['mod']) { + $_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id"); + $_query->bindValue(':id', $note['mod']); + $_query->execute() or error(db_error($_query)); + if($_mod = $_query->fetch()) { + if($mod['type'] >= $config['mod']['editusers']) + $staff = '' . htmlentities($_mod['username']) . ''; + else + $staff = $_mod['username']; + } else { + $staff = '??'; + } + } else { + $staff = 'system'; + } + $body .= '' . + '' . + ($mod['type'] >= $config['mod']['remove_notes'] ? + '' + : '') . + ''; + } + $body .= '
StaffNoteDateActions
' . + $staff . + '' . + $note['body'] . + '' . + date($config['post_date'], $note['time']) . + '[delete]
'; + } + + if($mod['type'] >= $config['mod']['create_notes']) { + $body .= '
' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '
Staff' . $mod['username'] . '
' . + '
'; + } + + $body .= '
'; + } + } + + if($mod['type'] >= $config['mod']['view_ban']) { + $query = prepare("SELECT * FROM `bans` LEFT JOIN `boards` ON `boards`.`id` = `board` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `ip` = :ip"); + $query->bindValue(':ip', $ip); + $query->execute() or error(db_error($query)); + + if($query->rowCount() > 0) { + $body .= '
Ban' . ($query->rowCount() == 1 ? '' : 's') . ' on record
'; + + while($ban = $query->fetch()) { + $body .= '' . + + // IP + '' . + + // Reason + '' . + + // Board + '' . + + // Set + '' . + + // Expires + '' . + + // Staff + '' . + + '
Status' . + ($config['mod']['view_banexpired'] && $ban['expires'] != 0 && $ban['expires'] < time() ? + 'Expired' + : 'Active') . + '
IP' . $ban['ip'] . '
Reason' . $ban['reason'] . '
Board' . + (isset($ban['uri']) ? + sprintf($config['board_abbreviation'], $ban['uri']) + : + 'all boards' + ) . '
Set' . date($config['post_date'], $ban['set']) . '
Expires' . + ($ban['expires'] == 0 ? + 'Never' + : + date($config['post_date'], $ban['expires']) + ) . + '
Staff' . + ($mod['type'] < $config['mod']['view_banstaff'] ? + ($config['mod']['view_banquestionmark'] ? + '?' + : + ($ban['type'] == JANITOR ? 'Janitor' : + ($ban['type'] == MOD ? 'Mod' : + ($ban['type'] == ADMIN ? 'Admin' : + '?'))) + ) + : + $ban['username'] + ) . + '
'; + } + + $body .= '
'; + } + } + + if($mod['type'] >= $config['mod']['ip_banform']) + $body .= form_newBan($ip, null, '?/IP/' . $ip); + + echo Element('page.html', Array( + 'config'=>$config, + 'title'=>'IP: ' . $ip, + 'subtitle' => $host, + 'body'=>$body, + 'mod'=>true + ) + ); } - - if($mod['type'] >= $config['mod']['ip_banform']) - $body .= form_newBan($ip, null, '?/IP/' . $ip); - - echo Element('page.html', Array( - 'config'=>$config, - 'title'=>'IP: ' . $ip, - 'subtitle' => $host, - 'body'=>$body, - 'mod'=>true - ) - ); } else { error($config['error']['404']); }