Exemplo n.º 1
0
    $page_gen_time = round(1000 * (get_microtime() - $s));
    if ($use_cache and !$cache_hit) {
        $cache->set_page_generation_time($page_gen_time);
        $cache->store(get_current_url(), $page);
    }
    if (is_developer() && !$requested_api) {
        $str = $page_gen_time . ' ms | ' . format_bytes_as_human_readable(memory_get_peak_usage(true)) . ' | ';
        if ($use_cache) {
            $str .= 'caching is ON: ';
            if ($cache_hit) {
                $str .= 'hit';
            } else {
                $str .= 'miss';
            }
        } else {
            $str .= 'caching is OFF: ' . implode(', ', $no_cache_reasons);
        }
        echo "\n" . '<div id="reasonDeveloper" style="background-color:#ddd;color:#555;font-size:0.75em;padding:1px 1em;">';
        echo '<p>' . $str . '</p>';
        if (isset($t) && method_exists($t, 'display_developer_section')) {
            $t->display_developer_section();
        }
        if (defined('THIS_IS_A_DEVELOPMENT_REASON_INSTANCE') && THIS_IS_A_DEVELOPMENT_REASON_INSTANCE) {
            echo '<p style="color:#777;">This instance of Reason is set up as a development/testing instance. As a result, this page is hidden from search engines. If this is an error, modify the setting THIS_IS_A_DEVELOPMENT_REASON_INSTANCE.</p>';
        }
        echo '</div>';
    }
    if (!$requested_api) {
        reason_log_page_generation_time($page_gen_time);
    }
}
Exemplo n.º 2
0
    // on the GET string.  Basically, the original REQUEST_URI has the
    // query string we are interested in, so we parse that URL and then
    // parse the query string.  Then, we merge the two query strings back
    // into the superglobal one.
    $url_arr = parse_url(get_current_url());
    $apparent_get = array();
    if (!empty($url_arr['query'])) {
        parse_str($url_arr['query'], $apparent_get);
    }
    // all additional request items must be integers.
    // This is a simple way to prevent SQL injection
    // if we need to do more at a later point we can
    // use a cleanup rules-style method of
    // managing request stuff.
    $cleanup_rules = $feed->get_cleanup_rules();
    // original request clobbers new request
    $full_get = array_merge($apparent_get, $_GET);
    foreach ($full_get as $key => $val) {
        if (empty($cleanup_rules[$key])) {
            $cleanup_rules[$key] = array('function' => 'turn_into_int');
        }
    }
    $full_get = carl_clean_vars($full_get, $cleanup_rules);
    $feed->set_request_vars($full_get);
    $feed->run();
} else {
    http_response_code(400);
    echo '<html><head><title>Feed did not work</title><meta name="robots" content="none" /></head><body><h1>Feed did not work</h1><p>Use the form "?type_id=xx [ &site_id=yy ]"</p></body></html>';
}
reason_log_page_generation_time(round(1000 * (get_microtime() - $start_time)));