From 98df3052c5c1766db8772b7060d486357c2c07b1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 25 Dec 2009 04:23:48 +0000 Subject: [PATCH] - 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 --- checkin_notes | 11 +++++++++++ html/inc/cache.inc | 27 ++++++++++++++++++++++----- html/user/create_profile.php | 1 + html/user/view_profile.php | 24 +++++++++++++----------- html/user/white.css | 2 +- 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/checkin_notes b/checkin_notes index 18d66fc93c..7c42ed057e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/html/inc/cache.inc b/html/inc/cache.inc index 98ddc91980..f861c23013 100644 --- a/html/inc/cache.inc +++ b/html/inc/cache.inc @@ -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); +} + +?> diff --git a/html/user/create_profile.php b/html/user/create_profile.php index df5985dab1..0b78cc855c 100644 --- a/html/user/create_profile.php +++ b/html/user/create_profile.php @@ -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; } diff --git a/html/user/view_profile.php b/html/user/view_profile.php index 34af59ce3f..e507537f21 100644 --- a/html/user/view_profile.php +++ b/html/user/view_profile.php @@ -15,7 +15,7 @@ // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see . - + 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 ""; - start_table(); - show_profile($user, $logged_in_user); - end_table(); +start_table(); +show_profile($user, $logged_in_user); +end_table(); echo ""; - start_table(); - row2(tra("Account data"), "".tra("View").""); +start_table(); +row2(tra("Account data"), + "".tra("View")."" +); - community_links($community_links_object, $logged_in_user); - end_table(); +community_links($community_links_object, $logged_in_user); +end_table(); echo ""; end_table(); diff --git a/html/user/white.css b/html/user/white.css index a430baf7b2..b135f5c1df 100644 --- a/html/user/white.css +++ b/html/user/white.css @@ -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; }