referrer_url() static public method

static public referrer_url ( $fallback_on_http_referer = false )
示例#1
0
if (strpos($input['object'], 'content/') !== 0) {
    exit2('malformed parameter "object"');
}
# sanitize $input['comment']
$input['comment'] = preg_replace('/[^0-9\\.]+/', '', $input['comment']);
# look up post/page
$post = GBExposedContent::findByCacheName($input['object'] . gb::$content_cache_fnext);
# verify existing content and that comments are enabled
if (!$post) {
    exit2('no such object ' . $input['object']);
}
# remove from comment db
try {
    $cdb = $post->getCommentsDB();
    $removed_comment = $cdb->remove($input['comment']);
    $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) {