$referrer = gb::referrer_url(); # comment not found if (!$removed_comment) { if ($referrer) { $referrer['gb-error'] = 'Comment ' . $input['comment'] . ' not found'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else { header('HTTP/1.1 404 Not Found'); } exit('no such comment ' . $input['comment']); } gb::log(LOG_NOTICE, 'removed comment %s by %s from post %s', $input['comment'], $removed_comment->name, $post->cachename()); gb::event('did-remove-comment', $removed_comment); # done OK if ($referrer) { $referrer->fragment = 'comments'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else { exit2("removed comment: {$removed_comment->id}\n", '200 OK'); } } catch (Exception $e) { gb::log(LOG_ERR, 'failed to remove comment %s from %s', $input['comment'], $post->cachename()); header('HTTP/1.1 500 Internal Server Error'); echo '$input => '; var_export($input); echo "\n"; gb_flush(); throw $e; }
exit(0); } else { exit2("new comment: {$comment->id}\n", '200 OK'); } } catch (Exception $e) { if ($e instanceof GitError && strpos($e->getMessage(), 'nothing to commit') !== false) { gb::log('skipped duplicate comment from ' . var_export($comment->email, 1) . ' (nothing to commit)'); gb::event('was-duplicate-comment', $comment); header('HTTP/1.1 304 Not Modified'); header('Location: ' . $input['gb-referrer'] . '#skipped-duplicate-reply'); exit(0); } gb::log(LOG_ERR, 'failed to add comment ' . var_export($comment->body, 1) . ' from ' . var_export($comment->name, 1) . ' <' . var_export($comment->email, 1) . '>' . ' to ' . $post->cachename()); header('HTTP/1.1 500 Internal Server Error'); echo '$input => '; var_export($input); echo "\n"; gb_flush(); throw $e; } } else { # rejected by filter(s) if ($referrer) { $referrer->fragment = 'comments'; $referrer['comment-status'] = 'rejected'; header('HTTP/1.1 303 See Other'); header('Location: ' . $referrer); } else { exit2("rejected\n", '200 OK'); } }