*** empty log message ***

svn path=/trunk/boinc/; revision=3943
This commit is contained in:
Eric J. Korpela 2004-07-22 23:42:50 +00:00
parent 50c9d27e33
commit a7a656299d
10 changed files with 46 additions and 8 deletions

View File

@ -1,11 +1,26 @@
<?php
require_once("../project/cache_parameters.inc");
// mechanism for caching commonly-accessed pages
function make_cache_dirs() {
if (!@filemtime("../cache")) mkdir("../cache");
for ($i=0;$i<256;$i++) {
$j=sprintf("%02x",$i);
if (!@filemtime("../cache/$j")) {
mkdir("../cache/$j");
}
}
}
function get_path($params) {
if (!@filemtime("../cache/00")) make_cache_dirs();
$y = pathinfo($_SERVER["PHP_SELF"]);
$z = $y["basename"];
$path = "../cache/".$z;
// add a layer of subdirectories for reducing file lookup time
$sz = substr(md5($z."_".urlencode($params)),1,2);
$path = "../cache/".$sz."/".$z;
if ($params) {
$path = $path."_".urlencode($params);
}

View File

@ -3,6 +3,7 @@
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/sanitize_html.inc");
require_once("../inc/cache.inc");
// TODO: Determine if we can always assume these will be the same number.
define('SMALL_IMG_WIDTH', 64);
@ -422,6 +423,16 @@ function show_profile($userid, $verify_mode=false) {
exit();
}
if (!$verify_mode) {
$logged_in_user = get_logged_in_user(false); // (false) since anyone can look at profiles.;
if (!$logged_in_user || ($user->id != $logged_in_user->id)) {
$caching = true;
$cache_args = "userid=$userid";
start_cache(USER_PROFILE_TTL,$cache_args);
}
}
$profile = get_profile($userid);
if (!$profile) {
@ -451,6 +462,7 @@ function show_profile($userid, $verify_mode=false) {
if (!$verify_mode) {
page_tail();
}
if ($caching) end_cache($cache_args);
}
function show_profile_summary($user, $profile, $can_edit, $verify_mode) {

View File

@ -0,0 +1,11 @@
<?php
// This file defines the lifetime of public php pages
define('TEAM_PAGE_TTL',3600);
define('USER_PAGE_TTL',3600);
define('USER_PROFILE_TTL',3600);
define('TOP_PAGES_TTL',43200);
define('DOWNLOAD_PAGE_TTL',3600);
define('INDEX_PAGE_TTL',3600);
?>

View File

@ -3,7 +3,7 @@
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
start_cache(3600);
start_cache(DOWNLOAD_PAGE_TTL);
require_once("../inc/db.inc");
require_once("../inc/download.inc");

View File

@ -44,7 +44,7 @@ function show_nav() {
";
}
//start_cache(3600);
//start_cache(INDEX_PAGE_TTL);
$stopped = project_is_stopped();

View File

@ -8,7 +8,7 @@
if ($format) {
$cache_args .= "&format=xml";
}
start_cache(600, $cache_args);
start_cache(USER_PAGE_TTL, $cache_args);
require_once("../inc/db.inc");
require_once("../inc/user.inc");

View File

@ -15,7 +15,7 @@ if ($offset > 1000) {
}
$cache_args = "teamid=$teamid&sort_by=$sort_by&offset=$offset";
start_cache(3600, $cache_args);
start_cache(TEAM_PAGE_TTL, $cache_args);
require_once("../inc/db.inc");
require_once("../inc/util.inc");

View File

@ -13,7 +13,7 @@
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(12*3600, $cache_args);
start_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";

View File

@ -13,7 +13,7 @@
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(12*3600, $cache_args);
start_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";

View File

@ -13,7 +13,7 @@
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(12*3600, $cache_args);
start_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";