From ad3ad64c5af69d45af9614e6ed029c25e98580bb Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Tue, 5 Aug 2003 21:16:16 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=1993 --- html/ops/db_action.php | 2 +- html/ops/db_ops.inc | 134 ++++++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 64 deletions(-) diff --git a/html/ops/db_action.php b/html/ops/db_action.php index 1a985461df..6491913cfb 100644 --- a/html/ops/db_action.php +++ b/html/ops/db_action.php @@ -46,7 +46,7 @@ Displaying $start_at to $last.

"; - $urlquery = urlencode($q->query); + $urlquery = $q->urlquery; echo "
"; if ($start_at) { $prev_pos = $start_at - $page_entries_to_show; diff --git a/html/ops/db_ops.inc b/html/ops/db_ops.inc index e0fa12c012..edbbfec261 100644 --- a/html/ops/db_ops.inc +++ b/html/ops/db_ops.inc @@ -29,7 +29,12 @@ function lookup_user_auth($auth) { class SqlQueryString { var $table; var $query; - function SqlQueryString($table, $query) { $this->table = $table; $this->query = $query; } + var $urlquery; + function SqlQueryString() { + $this->table = $_GET['table']; + $this->query = $_GET['query']; + $this->urlquery = "table=$this->table&query=$this->query"; + } function add($clause) { if (!$this->query) { $this->query .= "where $clause"; @@ -42,19 +47,25 @@ class SqlQueryString { $this->add($clause); } } - function addeq($name, $value) { + function addeq($name) { + $value = $_GET[$name]; if (strlen($value)) { - $this->add("$name = $value"); + $this->add("$name = '$value'"); + $this->urlquery .= "&$name=".urlencode($value); } } - function addeqnz($name, $value) { + function addeqnz($name) { + $value = $_GET[$name]; if (strlen($value) && $value > 0) { - $this->add("$name = $value"); + $this->add("$name = '$value'"); + $this->urlquery .= "&$name=".urlencode($value); } } - function addgt($name, $value) { + function addgt($name) { + $value = $_GET[$name]; if (strlen($value) && $value > 0) { - $this->add("$name > $value"); + $this->add("$name > '$value'"); + $this->urlquery .= "&$name=".urlencode($value); } } @@ -79,27 +90,24 @@ class SqlQueryString { } } -function build_sql_query($table) +function build_sql_query() { - parse_str(getenv("QUERY_STRING")); + $q = new SqlQueryString(); - $q = new SqlQueryString($table, $query); - - $q->addclause($clauses); - $q->addeq('id', $id); - $q->addeq('platformid', $plat_id); - $q->addeq('appid', $app_id); - $q->addeq('workunitd', $wu_id); - $q->addeq('hostid', $hostid); - $q->addeq('userid', $userid); - $q->addeq('teamid', $team_id); + $q->addeq('id'); + $q->addeq('platformid'); + $q->addeq('appid'_id); + $q->addeq('workunitid'); + $q->addeq('hostid'); + $q->addeq('userid'); + $q->addeq('teamid'); if ($nsecs) { $received_time = time() - $nsecs; } - $q->addgt('received_time', $received_time); - $q->addeqnz('server_state', $result_server_state); - $q->addeqnz('outcome', $result_outcome); - $q->addeqnz('client_state', $result_client_state); + $q->addgt('received_time'); + $q->addeqnz('server_state'); + $q->addeqnz('outcome'); + $q->addeqnz('client_state'); if (strlen($sort_by)) { $q->query .= " order by $sort_by desc"; @@ -134,7 +142,7 @@ function show_result_summary() $q = build_sql_query('result'); $main_query = $q->get_select_query(0,0); - $urlquery = urlencode($q->query); + $urlquery = $q->urlquery; echo "

Query: $main_query

\n"; $result = mysql_query($main_query); $ntotal =0; // TODO: how to count $result? @@ -153,66 +161,66 @@ function show_result_summary() echo ""; echo ""; echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; echo ""; echo ""; echo ""; echo "

" . link_results("$ntotal results", $urlquery, '') . "

" . link_results("'Over' results", $urlquery, "result_server_state=5") . "

" . link_results("'Client error' results", $urlquery, "result_outcome=3") . "

" . link_results("'Over' results", $urlquery, "server_state=5") . "

" . link_results("'Client error' results", $urlquery, "outcome=3") . "

\n"; for ($ss=1; $ss<6; $ss++) { - row2(result_server_state_string($ss), - link_results($server_state[$ss], $urlquery,"result_server_state=$ss")); + row2(server_state_string($ss), + link_results($server_state[$ss], $urlquery,"server_state=$ss")); } echo "
Server state# results
\n"; for ($ro=0; $ro<6; $ro++) { - c_row2(outcome_color($ro), result_outcome_string($ro), - link_results($outcome[$ro], $urlquery, "result_outcome=$ro")); + c_row2(outcome_color($ro), outcome_string($ro), + link_results($outcome[$ro], $urlquery, "outcome=$ro")); } echo "
Outcome# results
\n"; for ($cs=1; $cs<6; $cs++) { - row2(result_client_state_string($cs), - link_results($client_state[$cs], $urlquery, "result_client_state=$cs")); + row2(client_state_string($cs), + link_results($client_state[$cs], $urlquery, "client_state=$cs")); } print "
Client state# results
"; print "
"; } -function result_server_state_select() { +function server_state_select() { echo " -

"; } -function result_server_state_string($s) { +function server_state_string($s) { switch($s) { case 1: return "Inactive"; case 2: return "Unsent"; @@ -413,7 +421,7 @@ function result_server_state_string($s) { return "Unknown"; } -function result_outcome_string($s) { +function outcome_string($s) { switch($s) { case 1: return "Success"; case 2: return "Couldn't send"; @@ -424,7 +432,7 @@ function result_outcome_string($s) { return "Unknown"; } -function result_client_state_string($s) { +function client_state_string($s) { switch($s) { case 0: return "New"; case 1: return "Downloading"; @@ -487,9 +495,9 @@ function show_result($result, $hide_xml_docs, $hide_stderr, $hide_times) { } row("Name", $result->name); row("Workunit", "workunitid>" . wu_name_by_id($result->workunitid) . "" ); - row("Server state", result_server_state_string($result->server_state)); - row("Outcome", result_outcome_string($result->outcome)); - row("Client state", result_client_state_string($result->client_state)); + row("Server state", server_state_string($result->server_state)); + row("Outcome", outcome_string($result->outcome)); + row("Client state", client_state_string($result->client_state)); row("Host ID", "hostid>" . host_name_by_id($result->hostid) . ""); row("Report deadline", time_str($result->report_deadline)); row("CPU time", $result->cpu_time); @@ -526,10 +534,10 @@ function result_short_header() { } function show_result_short($result) { - $ss = result_server_state_string($result->server_state); - $oc = result_outcome_string($result->outcome); + $ss = server_state_string($result->server_state); + $oc = outcome_string($result->outcome); if ($result->outcome == 3) { - $cs = result_client_state_string($result->client_state); + $cs = client_state_string($result->client_state); $oc = "$oc ($cs)"; } $received = time_str($result->received_time); @@ -591,12 +599,12 @@ function show_team($team) { row("Url", "url>" . $team->url . ""); row("Type", team_type_string($team->type)); row("Description", $team->description); - row("", "id>List All Members"); + row("", "id>List All Members"); end_table(); } -function team_name_by_id($team_id) { - $result = mysql_query("select * from team where id = $team_id"); +function team_name_by_id($teamid) { + $result = mysql_query("select * from team where id = $teamid"); $team = mysql_fetch_object($result); return $team->name; } @@ -607,20 +615,20 @@ function user_name_by_id($user_id) { return $user->name; } -function app_name_by_id($app_id) { - $result = mysql_query("select * from app where id = $app_id"); +function app_name_by_id($appid) { + $result = mysql_query("select * from app where id = $appid"); $app = mysql_fetch_object($result); return $app->name; } -function wu_name_by_id($wu_id) { - $result = mysql_query("select * from workunit where id = $wu_id"); +function wu_name_by_id($workunitid) { + $result = mysql_query("select * from workunit where id = $workunitid"); $wu = mysql_fetch_object($result); return $wu->name; } -function platform_name_by_id($plat_id) { - $result = mysql_query("select * from platform where id = $plat_id"); +function platform_name_by_id($platformid) { + $result = mysql_query("select * from platform where id = $platformid"); $plat = mysql_fetch_object($result); return $plat->name; }