diff options
| author | czaks <marcin@6irc.net> | 2013-11-11 21:54:35 +0100 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-11-11 21:54:35 +0100 |
| commit | f5657caf24753ed7c25d56659ae8dfe79d48b99a (patch) | |
| tree | 989f1149070194f18f6250c851159dda813151fe /post.php | |
| parent | 0a58973631626879abeea4956b33cc2b56dea453 (diff) | |
| parent | 9fb63b053fbb552a2a8bbde1e230a8b73296fb6d (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into vichan-devel-4.5
Conflicts:
inc/config.php
install.php
post.php
stylesheets/style.css
Diffstat (limited to 'post.php')
| -rw-r--r-- | post.php | 44 |
1 files changed, 43 insertions, 1 deletions
@@ -181,7 +181,8 @@ if (isset($_POST['delete'])) { error($config['error']['bot']); // Check the referrer - if (!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], rawurldecode($_SERVER['HTTP_REFERER']))) + if ($config['referer_match'] !== false && + (!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], rawurldecode($_SERVER['HTTP_REFERER'])))) error($config['error']['referer']); checkDNSBL(); @@ -779,6 +780,47 @@ if (isset($_POST['delete'])) { 'id' => $id )); } +} elseif (isset($_POST['appeal'])) { + if (!isset($_POST['ban_id'])) + error($config['error']['bot']); + + $ban_id = (int)$_POST['ban_id']; + + $bans = Bans::find($_SERVER['REMOTE_ADDR']); + foreach ($bans as $_ban) { + if ($_ban['id'] == $ban_id) { + $ban = $_ban; + break; + } + } + + if (!isset($ban)) { + error(_("That ban doesn't exist or is not for you.")); + } + + if ($ban['expires'] && $ban['expires'] - $ban['created'] <= $config['ban_appeals_min_length']) { + error(_("You cannot appeal a ban of this length.")); + } + + $query = query("SELECT `denied` FROM ``ban_appeals`` WHERE `ban_id` = $ban_id") or error(db_error()); + $ban_appeals = $query->fetchAll(PDO::FETCH_COLUMN); + + if (count($ban_appeals) >= $config['ban_appeals_max']) { + error(_("You cannot appeal this ban again.")); + } + + foreach ($ban_appeals as $is_denied) { + if (!$is_denied) + error(_("There is already a pending appeal for this ban.")); + } + + $query = prepare("INSERT INTO ``ban_appeals`` VALUES (NULL, :ban_id, :time, :message, 0)"); + $query->bindValue(':ban_id', $ban_id, PDO::PARAM_INT); + $query->bindValue(':time', time(), PDO::PARAM_INT); + $query->bindValue(':message', $_POST['appeal']); + $query->execute() or error(db_error($query)); + + displayBan($ban); } else { if (!file_exists($config['has_installed'])) { header('Location: install.php', true, $config['redirect_http']); |
