2003-10-27 17:49:05 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-11-12 22:28:17 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
// show recent results for a host or user
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
2005-02-19 08:06:53 +00:00
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/result.inc");
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2011-02-09 22:11:34 +00:00
|
|
|
check_get_args(array("hostid", "userid", "offset", "appid", "state", "show_names"));
|
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
$config = get_config();
|
|
|
|
if (!parse_bool($config, "show_results")) {
|
2008-12-13 21:27:37 +00:00
|
|
|
error_page(tra("This feature is turned off temporarily"));
|
2005-02-19 08:06:53 +00:00
|
|
|
}
|
2004-07-02 19:17:53 +00:00
|
|
|
|
2009-05-18 16:58:11 +00:00
|
|
|
BoincDb::get(true);
|
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
$results_per_page = 20;
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
$hostid = get_int("hostid", true);
|
|
|
|
$userid = get_int("userid", true);
|
|
|
|
$offset = get_int("offset", true);
|
2010-09-12 09:43:20 +00:00
|
|
|
$appid = get_int("appid", true);
|
2005-02-19 08:06:53 +00:00
|
|
|
if (!$offset) $offset=0;
|
2009-03-18 22:53:55 +00:00
|
|
|
$state = get_int("state", true);
|
|
|
|
if (!$state) $state=0;
|
2009-02-19 18:39:03 +00:00
|
|
|
$show_names = get_int("show_names", true);
|
|
|
|
if (!$show_names) $show_names=0;
|
2004-01-06 22:09:19 +00:00
|
|
|
|
2009-06-04 16:43:52 +00:00
|
|
|
$s = $state_name[$state];
|
2011-06-01 04:29:43 +00:00
|
|
|
if ($appid) {
|
|
|
|
$app = BoincApp::lookup_id($appid);
|
|
|
|
if ($app) {
|
|
|
|
$s .= " $app->user_friendly_name ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
if ($hostid) {
|
2007-11-12 22:28:17 +00:00
|
|
|
$host = BoincHost::lookup_id($hostid);
|
2009-02-19 18:39:03 +00:00
|
|
|
if (!$host) error_page(tra("No computer with ID %1 found", $hostid));
|
2005-02-19 08:06:53 +00:00
|
|
|
$clause = "hostid=$hostid";
|
2009-06-04 16:43:52 +00:00
|
|
|
page_head(tra("$s tasks for computer %1", $host->id));
|
2010-06-12 22:08:15 +00:00
|
|
|
$show_host_link = false;
|
2008-12-13 21:27:37 +00:00
|
|
|
} else if ($userid){
|
2005-02-19 08:06:53 +00:00
|
|
|
$user = get_logged_in_user();
|
|
|
|
if ($userid != $user->id) {
|
2008-12-13 21:27:37 +00:00
|
|
|
error_page(tra("No access"));
|
2003-10-27 17:49:05 +00:00
|
|
|
}
|
2005-02-19 08:06:53 +00:00
|
|
|
$clause = "userid=$userid";
|
2009-06-04 16:43:52 +00:00
|
|
|
page_head(tra("$s tasks for $user->name"));
|
2010-06-12 22:08:15 +00:00
|
|
|
$show_host_link = true;
|
2008-12-13 21:27:37 +00:00
|
|
|
} else {
|
2009-03-16 19:39:16 +00:00
|
|
|
error_page(tra("Missing user ID or host ID"));
|
2005-02-19 08:06:53 +00:00
|
|
|
}
|
2009-03-16 19:39:16 +00:00
|
|
|
|
2009-03-18 22:53:55 +00:00
|
|
|
$clause2 = $clause. $state_clause[$state];
|
2010-09-12 09:43:20 +00:00
|
|
|
if ($appid) {
|
|
|
|
$clause2 .= ' AND appid='.$appid;
|
|
|
|
}
|
2009-03-16 19:39:16 +00:00
|
|
|
|
2009-03-18 22:53:55 +00:00
|
|
|
$query = "$clause2 order by id desc limit $offset,".($results_per_page+1);
|
2007-11-12 22:28:17 +00:00
|
|
|
$results = BoincResult::enum($query);
|
2009-02-19 18:39:03 +00:00
|
|
|
|
2013-05-09 05:42:43 +00:00
|
|
|
$info = new StdClass;
|
2009-02-19 18:39:03 +00:00
|
|
|
$info->number_of_results = count($results);
|
|
|
|
$info->clause = $clause;
|
|
|
|
$info->results_per_page = $results_per_page;
|
|
|
|
$info->offset = $offset;
|
|
|
|
$info->show_names = $show_names;
|
2009-03-18 22:53:55 +00:00
|
|
|
$info->state = $state;
|
2010-09-12 09:43:20 +00:00
|
|
|
$info->appid = $appid;
|
2009-02-19 18:39:03 +00:00
|
|
|
|
2011-06-01 04:53:16 +00:00
|
|
|
$nav = result_navigation($info, $clause);
|
2009-06-04 16:43:52 +00:00
|
|
|
if (count($results)) {
|
2011-06-01 04:53:16 +00:00
|
|
|
echo $nav;
|
2010-06-12 22:08:15 +00:00
|
|
|
result_table_start(true, $show_host_link, $info);
|
2009-06-04 16:43:52 +00:00
|
|
|
$i = 0;
|
|
|
|
foreach ($results as $result) {
|
|
|
|
if ($i >= $results_per_page) break;
|
2010-06-12 22:08:15 +00:00
|
|
|
show_result_row($result, true, $show_host_link, $show_names, $i);
|
2009-06-04 16:43:52 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
} else {
|
|
|
|
start_table();
|
|
|
|
row1(tra("No tasks to display"));
|
|
|
|
end_table();
|
2005-02-19 08:06:53 +00:00
|
|
|
}
|
2004-03-24 01:41:49 +00:00
|
|
|
|
2011-06-01 04:53:16 +00:00
|
|
|
echo $nav;
|
2003-10-27 17:49:05 +00:00
|
|
|
|
2005-02-19 08:06:53 +00:00
|
|
|
page_tail();
|
2003-10-27 17:49:05 +00:00
|
|
|
?>
|