Example #1
0
    ctx_log_start("Loading themelets");
    foreach (_get_themelet_files(get_theme()) as $themelet) {
        require_once $themelet;
    }
    ctx_log_endok();
    _load_extensions();
    // start the page generation waterfall
    $page = class_exists("CustomPage") ? new CustomPage() : new Page();
    $user = _get_user();
    send_event(new InitExtEvent());
    if (!is_cli()) {
        // web request
        send_event(new PageRequestEvent(@$_GET["q"]));
        $page->display();
    } else {
        // command line request
        send_event(new CommandEvent($argv));
    }
    // saving cache data and profiling data to disk can happen later
    if (function_exists("fastcgi_finish_request")) {
        fastcgi_finish_request();
    }
    $database->commit();
    ctx_log_endok();
} catch (Exception $e) {
    if ($database) {
        $database->rollback();
    }
    _fatal_error($e);
    ctx_log_ender();
}
$pycookie = $_SESSION['xnatview.authinfo']['pysessname'] . '=' . $_SESSION['xnatview.authinfo']['pysessid'];
$get_scans_url .= '?' . http_build_query($req_params);
$ch = curl_init($get_scans_url);
curl_setopt_array($ch, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_FAILONERROR => true, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_COOKIE => $pycookie));
$result = curl_exec($ch);
curl_close($ch);
unset($ch);
if ($result === false) {
    // FIXME should log error info
    _fatal_error("Unexpected error fetching the scan data.");
}
// now parse the XML
$xml = new SimpleXMLElement($result);
$img_tags = $xml->xpath('//image');
if (empty($img_tags)) {
    _fatal_error("No scan images were found.");
}
// construct the gallery container
ob_start();
echo "<div id='scanGallery'>\n";
foreach ($img_tags as $img_tag) {
    echo "\t<a href='", htmlspecialchars($img_tag['fullImage']), "'>";
    echo "<img src='", htmlspecialchars($img_tag['thumbnailImage']), "' ";
    echo "title='", htmlspecialchars($img_tag['title']), "' /></a>\n";
}
echo "</div>\n";
$gallery_html = ob_get_clean();
// begin main page now
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>