1<?php 2// This file is part of BOINC. 3// http://boinc.berkeley.edu 4// Copyright (C) 2008 University of California 5// 6// BOINC is free software; you can redistribute it and/or modify it 7// under the terms of the GNU Lesser General Public License 8// as published by the Free Software Foundation, 9// either version 3 of the License, or (at your option) any later version. 10// 11// BOINC is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14// See the GNU Lesser General Public License for more details. 15// 16// You should have received a copy of the GNU Lesser General Public License 17// along with BOINC. If not, see <http://www.gnu.org/licenses/>. 18 19// show recent results for a host or user 20 21require_once("../inc/boinc_db.inc"); 22require_once("../inc/util.inc"); 23require_once("../inc/result.inc"); 24 25check_get_args(array("hostid", "userid", "offset", "appid", "state", "show_names")); 26 27$config = get_config(); 28if (!parse_bool($config, "show_results")) { 29 error_page(tra("This feature is turned off temporarily")); 30} 31 32BoincDb::get(true); 33 34$results_per_page = 20; 35 36$hostid = get_int("hostid", true); 37$userid = get_int("userid", true); 38$offset = get_int("offset", true); 39$appid = get_int("appid", true); 40if (!$offset) $offset=0; 41$state = get_int("state", true); 42if (!$state) $state=0; 43$show_names = get_int("show_names", true); 44if (!$show_names) $show_names=0; 45 46$s = $state_name[$state]; 47if ($appid) { 48 $app = BoincApp::lookup_id($appid); 49 if ($app) { 50 $s .= " $app->user_friendly_name "; 51 } 52} 53 54if ($hostid) { 55 $host = BoincHost::lookup_id($hostid); 56 if (!$host) error_page(tra("No computer with ID %1 found", $hostid)); 57 $clause = "hostid=$hostid"; 58 page_head(tra("$s tasks for computer %1", $host->id)); 59 $show_host_link = false; 60} else if ($userid){ 61 $user = get_logged_in_user(); 62 if ($userid != $user->id) { 63 error_page(tra("No access")); 64 } 65 $clause = "userid=$userid"; 66 page_head(tra("$s tasks for $user->name")); 67 $show_host_link = true; 68} else { 69 error_page(tra("Missing user ID or host ID")); 70} 71 72$clause2 = $clause. $state_clause[$state]; 73if ($appid) { 74 $clause2 .= ' AND appid='.$appid; 75} 76 77if ($show_names) { 78 $order_clause = "order by name"; 79} else { 80 $order_clause = "order by sent_time desc"; 81} 82$query = "$clause2 $order_clause limit $offset,".($results_per_page+1); 83$results = BoincResult::enum($query); 84 85$info = new StdClass; 86$info->number_of_results = count($results); 87$info->clause = $clause; 88$info->results_per_page = $results_per_page; 89$info->offset = $offset; 90$info->show_names = $show_names; 91$info->state = $state; 92$info->appid = $appid; 93 94$nav = result_navigation($info, $clause); 95$i = 0; 96if (count($results)) { 97 echo $nav; 98 result_table_start(true, $show_host_link, $info); 99 foreach ($results as $result) { 100 if ($i++ >= $results_per_page) break; 101 show_result_row($result, true, $show_host_link, $show_names); 102 } 103 end_table(); 104} else { 105 start_table(); 106 row1(tra("No tasks to display")); 107 end_table(); 108} 109 110echo $nav; 111 112page_tail(); 113?> 114