コード例 #1
0
 private function delete_all()
 {
     global $wpdb;
     check_admin_referer('amber_dashboard');
     $storage = Amber::get_storage();
     $storage->delete_all();
     $status = Amber::get_status();
     $status->delete_all();
     $prefix = $wpdb->prefix;
     $wpdb->query("DELETE from {$prefix}amber_queue");
 }
コード例 #2
0
ファイル: amber.php プロジェクト: su/amber_wordpress
    /**
     * Request handling function to display cached content and assets
     */
    public static function display_cached_content($wp)
    {
        $cache_frame_id = !empty($wp->query_vars['amber_cacheframe']) ? $wp->query_vars['amber_cacheframe'] : "";
        $cache_id = !empty($wp->query_vars['amber_cache']) ? $wp->query_vars['amber_cache'] : "";
        $asset_id = !empty($wp->query_vars['amber_asset']) ? $wp->query_vars['amber_asset'] : "";
        $asset_id = rtrim($asset_id, "/");
        /* Get rid of stray characters on the end */
        /* Displaying the cache frame page with an iframe referencing the cached item */
        if (!empty($cache_id)) {
            status_header(200);
            /* This must be set BEFORE any content is printed */
            $data = Amber::retrieve_cache_item($cache_id);
            /* If the document is a PDF, serve it directly rather than in an iframe. Browsers
               will not render PDFs within sandboxed iframes. */
            if (isset($data['metadata']['type']) && $data['metadata']['type'] == 'application/pdf') {
                print $data['data'];
                $status = Amber::get_status();
                $status->save_view($cache_id);
                die;
            }
            $uri = $_SERVER["REQUEST_URI"];
            $iframe_url = "";
            if ($uri && strrpos($uri, "/") == strlen($uri) - 1) {
                $iframe_url = "../";
            }
            $iframe_url .= "../" . "cacheframe/{$cache_id}/";
            print <<<EOF
<!DOCTYPE html>
<html style="height: 100%">
<head>
<title>Amber</title>
</head>
<body style="margin:0; padding: 0; height: 100%">
<iframe 
sandbox="allow-scripts allow-forms allow-popups allow-pointer-lock"
security="restricted"
style="border:0 none transparent; background-color:transparent; width:100%; height:100%;" 
src="{$iframe_url}"></iframe>
</body>
</html>
EOF;
            die;
        }
        if (!empty($cache_frame_id)) {
            status_header(200);
            /* This must be set BEFORE any content is printed */
            if (empty($asset_id)) {
                /* This is the root item */
                $data = Amber::retrieve_cache_item($cache_frame_id);
                $status = Amber::get_status();
                $status->save_view($cache_frame_id);
                print $data['data'];
                die;
            } else {
                /* This is an asset */
                $data = Amber::retrieve_cache_asset($cache_frame_id, $asset_id);
                print $data['data'];
                die;
            }
        }
    }
コード例 #3
0
ファイル: amber.php プロジェクト: genevec/amber_wordpress
 public static function ajax_log_cache_view()
 {
     if (isset($_GET['cache'])) {
         header("Cache-Control: no-cache, must-revalidate");
         header("Pragma: no-cache");
         header("Expires: 0");
         $status = Amber::get_status();
         if ($status->save_view_for_external_cache_location($_GET['cache'])) {
             status_header(200);
         } else {
             status_header(404);
         }
     } else {
         status_header(400);
     }
     die;
 }