Ejemplo n.º 1
0
}
$s1 = $dbh->prepare('SELECT * FROM redirect WHERE short_url=?');
$s1->bindValue(1, $qs);
try {
    $s1->execute();
} catch (Exception $e) {
    //database error, not much we can do
    return false;
}
if (!($row = $s1->fetch())) {
    loghit($dbh, "Redirect not found: qs={$qs}");
    return false;
} else {
    if ($row['warning_page']) {
        //TODO: show warning page
        loghit($dbh, "Showing warning page: qs={$qs}");
    } else {
        switch ($row['http_response']) {
            case '301':
            case '302':
            case '303':
                header("Location: {$row['target']}", true, $row['http_response']);
                break;
            default:
                setStatus($row['http_response']);
                break;
        }
        loghit($dbh, "Success: qs={$qs}");
        return true;
    }
}
Ejemplo n.º 2
0
// Load all content hooks
foreach (glob("hooks/*.php") as $filename) {
    include $filename;
}
// Load dynamic adserving hooks
foreach (glob("adhooks/*.php") as $filename) {
    include $filename;
}
// setting us up the page
$page = GetPage($settings);
switch ($page->responsecode) {
    case 404:
        header("HTTP/1.0 404 Not Found");
        echo $page->content;
        break;
    case 302:
    case 301:
        header("Location: {$page->redirlink}");
        break;
    case 200:
        if ($page->dontskin == 1) {
            echo $page->content;
            break;
        }
        echo utf8_encode($page->Skin());
        break;
}
/* log ... */
if (OpenBHConf::get('loghits') == true) {
    loghit($page, $settings);
}