From e3026a1ddc88617058c8e0865b429b84df75ca2d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 1 Jun 2004 18:55:59 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3488 --- checkin_notes | 20 ++++++++++++++++ html/inc/forum_show.inc | 2 +- html/inc/host.inc | 35 ++++++++++++++++++++++++++++ html/inc/util.inc | 6 ++--- html/ops/host_update_credit.php | 7 ++++++ html/project.sample/project_news.inc | 12 ++++++++++ html/user/forum_edit.php | 2 +- html/user/forum_forum.php | 2 +- html/user/forum_user_posts.php | 2 +- html/user/host_edit_action.php | 4 ++++ html/user/host_update_credit.php | 35 +--------------------------- 11 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 html/ops/host_update_credit.php create mode 100644 html/project.sample/project_news.inc diff --git a/checkin_notes b/checkin_notes index 503477449c..ad4e76aae3 100755 --- a/checkin_notes +++ b/checkin_notes @@ -12906,7 +12906,27 @@ David May 31 2004 diagnostics.C David June 1 2004 + web stuff: + - fix bug in merging > 2 hosts - remove references to html/forum in setup script + - move host_update_credit() to host.inc + and make an ops page for updating a host's credit py/Boinc/ setup_project.py + +David June 1 2004 + - small web fixes related to moving forum files + html/ + inc/ + forum_show.inc + host.inc + util.inc + ops/ + host_update_credit.php (new) + user/ + forum_edit.php + forum_forum.php + forum_user_posts.php + host_edit_action.php + host_update_credit.php diff --git a/html/inc/forum_show.inc b/html/inc/forum_show.inc index 1867d7c55f..398818c333 100644 --- a/html/inc/forum_show.inc +++ b/html/inc/forum_show.inc @@ -115,7 +115,7 @@ function show_forum($category, $forum, $start, $sort_style) { } else { echo " ", $thread->replies+1, " - ", user_links($user, "../"), " + ", user_links($user), " ", $thread->views, " ", $x, " "; diff --git a/html/inc/host.inc b/html/inc/host.inc index bbd7ed1594..14ea864171 100644 --- a/html/inc/host.inc +++ b/html/inc/host.inc @@ -217,4 +217,39 @@ function hosts_compatible($host1, $host2) { return true; } +function host_update_credit($hostid) { + $t = 0; + $avg = 0; + $now = time(); + $avg_time = 0; + $half_life = 86400*7; + $r = mysql_query("select * from result where hostid=$hostid order by received_time"); + while ($result = mysql_fetch_object($r)) { + if ($result->granted_credit <= 0) continue; + $t += $result->granted_credit; + + // the following taken from lib/util.C + // + if ($avg_time) { + $diff = $result->received_time - $avg_time; + if ($diff <=0) $diff = 3600; + $diff_days = $diff/86400; + $weight = exp(-$diff*M_LN2/$half_life); + $avg *= $weight; + $avg += (1-$weight)*($result->granted_credit/$diff_days); + } else { + $dd = ($result->received_time - $result->sent_time)/86400; + $avg = $result->granted_credit/$dd; + } + $avg_time = $result->received_time; + echo "
$avg\n"; + } + mysql_free_result($r); + + $diff = $now - $avg_time; + $weight = exp(-$diff*M_LN2/$half_life); + $avg *= $weight; + mysql_query("update host set total_credit=$t, expavg_credit=$avg where id=$hostid"); +} + ?> diff --git a/html/inc/util.inc b/html/inc/util.inc index 5c01a87da0..5cfe0a7028 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -433,10 +433,10 @@ function project_is_stopped() { return file_exists("../stop_servers"); } -function user_links($user, $dir='') { - $x = "id>$user->name"; +function user_links($user) { + $x = "id>$user->name"; if ($user->has_profile) { - $x .= " id>"; + $x .= " id>"; } return $x; } diff --git a/html/ops/host_update_credit.php b/html/ops/host_update_credit.php new file mode 100644 index 0000000000..ad2a29c7a6 --- /dev/null +++ b/html/ops/host_update_credit.php @@ -0,0 +1,7 @@ + diff --git a/html/project.sample/project_news.inc b/html/project.sample/project_news.inc new file mode 100644 index 0000000000..9ef882479a --- /dev/null +++ b/html/project.sample/project_news.inc @@ -0,0 +1,12 @@ + diff --git a/html/user/forum_edit.php b/html/user/forum_edit.php index 433e0d15e8..2661249d15 100644 --- a/html/user/forum_edit.php +++ b/html/user/forum_edit.php @@ -51,7 +51,7 @@ if ($logged_in_user->id != $post->user) { show_forum_title($forum, $thread, $category->is_helpdesk); -echo "
id, "\" method=\"POST\">"; +echo "id method=POST>\n"; start_forum_table(array("Edit Your Post"), array(NULL), 2); if ($post->parent_post==0 and $thread->owner==$logged_in_user->id) { diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 3c4077a832..17d3e2d185 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -44,7 +44,7 @@ if ($category->is_helpdesk) { } echo " - + diff --git a/html/user/forum_user_posts.php b/html/user/forum_user_posts.php index 5b3fb3dc8f..7fb3dd9ade 100644 --- a/html/user/forum_user_posts.php +++ b/html/user/forum_user_posts.php @@ -25,7 +25,7 @@ if ($n == $count) { $offset += $count; echo "

- Next $count posts + Next $count posts "; } diff --git a/html/user/host_edit_action.php b/html/user/host_edit_action.php index 201fcb8975..5a87f19bf3 100644 --- a/html/user/host_edit_action.php +++ b/html/user/host_edit_action.php @@ -67,6 +67,10 @@ function merge_hosts($old_host, $new_host) { } else { merge_hosts($host, $latest_host); } + // reread latest_host from database since we just + // updated its credits + // + $latest_host = lookup_host($latest_host->id); } echo "

Return to list of your computers diff --git a/html/user/host_update_credit.php b/html/user/host_update_credit.php index 5a9123bb7a..38dd22b0ec 100644 --- a/html/user/host_update_credit.php +++ b/html/user/host_update_credit.php @@ -23,40 +23,7 @@ function get_host($hostid, $user) { page_head("Updating computer credit"); $hostid = $_GET["hostid"]; - $latest_host = get_host($hostid, $user); - $r = mysql_query("select * from result where hostid=$hostid order by received_time"); - $t = 0; - $avg = 0; - $hl = 86400*7; - $now = time(); - $avg_time = 0; - $half_life = 86400*7; - while ($result = mysql_fetch_object($r)) { - if ($result->granted_credit <= 0) continue; - $t += $result->granted_credit; - - // the following taken from lib/util.C - // - if ($avg_time) { - $diff = $result->received_time - $avg_time; - if ($diff <=0) $diff = 3600; - $diff_days = $diff/86400; - $weight = exp(-$diff*M_LN2/$half_life); - $avg *= $weight; - $avg += (1-$weight)*($result->granted_credit/$diff_days); - } else { - $dd = ($result->received_time - $result->sent_time)/86400; - $avg = $result->granted_credit/$dd; - } - $avg_time = $result->received_time; - echo "
$avg\n"; - } - mysql_free_result($r); - - $diff = $now - $avg_time; - $weight = exp(-$diff*M_LN2/$half_life); - $avg *= $weight; - mysql_query("update host set total_credit=$t, expavg_credit=$avg where id=$hostid"); + host_update_credit($hostid); echo "
Host credit updated"; page_tail();