當前位置: 首頁>>代碼示例>>PHP>>正文


PHP http::validate方法代碼示例

本文整理匯總了PHP中http::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP http::validate方法的具體用法?PHP http::validate怎麽用?PHP http::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在http的用法示例。


在下文中一共展示了http::validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render_raw

        $text = @$result[1];
        // save in cache for the next request
        Cache::put($cache_id, $text, 'articles');
    }
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/xml; charset=' . $context['charset']);
    // suggest a name on download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii($context['site_name'] . '.section.' . $item['id'] . '.rss.xml');
        Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
    http::expire(1800);
    // strong validator
    $etag = '"' . md5($text) . '"';
    // manage web cache
    if (http::validate(NULL, $etag)) {
        return;
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $text;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
}
// render the skin
render_skin();
開發者ID:rair,項目名稱:yacs,代碼行數:31,代碼來源:feed.php

示例2: fseek

             Safe::header('Content-Length: ' . $length);
             // actual transmission except on a HEAD request
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                 fseek($handle, $offset);
                 $slice = fread($handle, $length);
                 echo $slice;
             }
             fclose($handle);
             // regular download
         } else {
             // file size
             Safe::header('Content-Length: ' . $stat['size']);
             // weak validator
             $last_modified = gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT';
             // validate content in cache
             if (http::validate($last_modified)) {
                 return;
             }
             // actual transmission except on a HEAD request
             if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
                 fpassthru($handle);
             }
             fclose($handle);
         }
         // the post-processing hook, then exit even on HEAD
         finalize_page();
         return;
     }
     // redirect to the actual file
     $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode($item['file_name']);
 }
開發者ID:rair,項目名稱:yacs,代碼行數:31,代碼來源:fetch.php


注:本文中的http::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。