- web: if someone edits their profile, remove it from the cache

so that they and others will see the new version.

svn path=/trunk/boinc/; revision=20039
This commit is contained in:
David Anderson 2009-12-25 04:23:48 +00:00
parent 4ae4fce8c0
commit 98df3052c5
5 changed files with 48 additions and 17 deletions

View File

@ -10741,3 +10741,14 @@ David 24 Dec 2009
rr_sim.cpp
sched/
handle_request.cpp
David 24 Dec 2009
- web: if someone edits their profile, remove it from the cache
so that they and others will see the new version.
html/
inc/
cache.inc
user/
view_profile.php
create_profile.php

View File

@ -41,10 +41,14 @@ function make_cache_dirs() {
}
}
function get_path($params) {
function get_path($params, $phpfile=null) {
if (!@filemtime("../cache/00")) make_cache_dirs();
$y = pathinfo($_SERVER["PHP_SELF"]);
$z = $y["basename"];
if ($phpfile) {
$z = $phpfile;
} else {
$y = pathinfo($_SERVER["PHP_SELF"]);
$z = $y["basename"];
}
// add a layer of subdirectories for reducing file lookup time
$sz = substr(md5($z."_".urlencode($params)),1,2);
@ -241,7 +245,20 @@ function set_cache_data($data,$params=""){
}
$path = get_path($params);
//echo $path;
$fhandle=fopen($path, "w");
$fhandle = fopen($path, "w");
fwrite($fhandle, $data);
fclose($fhandle);
}?>
}
function clear_cache_entry($phpfile, $params) {
if (strstr($phpfile, "..")) {
return;
}
if (strstr($params, "..")) {
return;
}
$path = get_path($params, $phpfile);
unlink($path);
}
?>

View File

@ -339,6 +339,7 @@ if ($min_credit && $user->expavg_credit < $min_credit) {
if (post_str("submit", true)) {
process_create_profile($user, $profile);
clear_cache_entry("view_profile.php", "userid=$user->id");
exit;
}

View File

@ -15,7 +15,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
require_once("../inc/profile.inc");
$userid = get_int('userid');
@ -31,29 +31,31 @@ $logged_in_user = get_logged_in_user(false);
check_whether_to_show_profile($user, $logged_in_user);
$cache_args = "userid=$userid";
$cacheddata=get_cached_data(USER_PROFILE_TTL, $cache_args);
$cacheddata = get_cached_data(USER_PROFILE_TTL, $cache_args);
if ($cacheddata){
// Already got a cached version of the information
$community_links_object = unserialize($cacheddata);
} else {
// Need to generate a new bunch of data
$community_links_object = get_community_links_object($user);
set_cache_data(serialize($community_links_object),$cache_args);
set_cache_data(serialize($community_links_object), $cache_args);
}
page_head("Profile: $user->name");
start_table();
echo "<tr><td valign=\"top\">";
start_table();
show_profile($user, $logged_in_user);
end_table();
start_table();
show_profile($user, $logged_in_user);
end_table();
echo "</td><td valign=\"top\">";
start_table();
row2(tra("Account data"), "<a href=\"show_user.php?userid=".$userid."\">".tra("View")."</a>");
start_table();
row2(tra("Account data"),
"<a href=\"show_user.php?userid=".$userid."\">".tra("View")."</a>"
);
community_links($community_links_object, $logged_in_user);
end_table();
community_links($community_links_object, $logged_in_user);
end_table();
echo "</td></tr>";
end_table();

View File

@ -3,7 +3,7 @@ a, a:link, a:visited, a:active {
}
body {
background: #fff url("img/gray_gradient.png") repeat-x;
#background: #fff url("img/gray_gradient.png") repeat-x;
color: black;
}