示例#1
0
文件: visit.php 项目: rair/yacs
// get the related anchor, if any
if ($anchor) {
    $anchor = Anchors::get($anchor);
}
// required to format the roster
load_skin('users');
// stop crawlers
if (Surfer::is_crawler()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // an anchor is mandatory
} elseif (!is_object($anchor)) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    die(i18n::s('No anchor has been found.'));
    // provide updated information for this anchor
} else {
    // silently record this visit
    Visits::track($anchor->get_reference(), $anchor->get_active());
    // return an updated list of current visitors, to be used in AJAX
    $output = Visits::list_users_at_anchor($anchor->get_reference());
    // ensure we are producing some text -- open links in separate pages
    if (is_array($output)) {
        $output =& Skin::build_list($output, 'compact', NULL, TRUE);
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $output;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
}