team lookup web RPC

svn path=/trunk/boinc/; revision=9209
This commit is contained in:
David Anderson 2006-01-10 23:21:23 +00:00
parent 60aef9aa55
commit 2c1bf9fb82
4 changed files with 113 additions and 40 deletions

View File

@ -277,3 +277,12 @@ David 10 Jan 2006
client/
gui_rpc_server.C
David 10 Jan 2006
- Add XML option for team lookup web interface
html/
inc/
xml.inc
user/
team_lookup.php

View File

@ -243,7 +243,46 @@ list_item("action",
returns a list of hosts associated with the account."
);
list_end();
echo "
<h3>Look up teams</h3>
";
list_start();
list_item("URL",
"project/team_lookup.php?team_name=string&format=xml"
);
list_item("input",
"Substring of team name"
);
list_item("output",
html_text("<teams>
<team>
<id>5</id>
<name>BOINC@AUSTRALIA</name>
<country>Australia</country>
</team>
<team>
<id>9</id>
<name>BOINC Synergy</name>
<country>International</country>
</team>
<team>
<id>16</id>
<name>BOINC.BE</name>
<country>Belgium</country>
</team>
<team>
<id>23</id>
<name>HispaSeti & BOINC</name>
<country>International</country>
</team>
</teams
")
);
list_item("action",
"Teams with names matching *string* will be returned.
A maximum of 100 teams will be returned."
);
list_end();
page_tail();
?>

View File

@ -60,4 +60,13 @@ echo"</user>
";
}
function show_team_xml($team) {
echo "<team>
<id>$team->id</id>
<name>".htmlspecialchars($team->name)."</name>
<country>$team->country</country>
</team>
";
}
?>

View File

@ -1,46 +1,62 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/team.inc");
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/team.inc");
db_init();
init_session();
db_init();
init_session();
$team_name = $_GET["team_name"];
$name_lc = strtolower($team_name);
$name_lc = escape_pattern($name_lc);
$query = "select * from team where name like '%$name_lc%'";
$result_list = mysql_query($query);
page_head("Search Results");
if ($result_list) {
$total = 0;
echo "<h2>Search results for '$team_name'</h2>";
echo "<p>";
echo "You may view these teams' members, statistics, and information.";
echo "<ul>";
while ($team_possible = mysql_fetch_object($result_list)) {
if ($total >= 100) {
$too_many = true;
break;
}
echo "<li>";
echo "<a href=team_display.php?teamid=$team_possible->id>";
echo "$team_possible->name</a></li>";
$total++;
}
echo "</ul>";
if ($too_many) {
echo "
More than 100 teams match your search.
The first 100 are shown.<br>
";
}
$team_name = $_GET["team_name"];
$name_lc = strtolower($team_name);
$name_lc = escape_pattern($name_lc);
$format = get_str("format", true);
$query = "select * from team where name like '%$name_lc%'";
$result_list = mysql_query($query);
if ($format == 'xml') {
require_once ('../inc/xml.inc');
xml_header();
echo "<teams>\n";
$total = 0;
while ($team = mysql_fetch_object($result_list)) {
show_team_xml($team);
$total++;
if ($total == 100) break;
}
echo "End of results<br>";
echo "If you cannot find the team you are looking for, you may create a team ";
echo "by clicking <a href=team_create_form.php>here</a>.";
page_tail();
echo "</teams>\n";
exit();
}
page_head("Search Results");
if ($result_list) {
$total = 0;
echo "<h2>Search results for '$team_name'</h2>";
echo "<p>";
echo "You may view these teams' members, statistics, and information.";
echo "<ul>";
while ($team_possible = mysql_fetch_object($result_list)) {
if ($total >= 100) {
$too_many = true;
break;
}
echo "<li>";
echo "<a href=team_display.php?teamid=$team_possible->id>";
echo "$team_possible->name</a></li>";
$total++;
}
echo "</ul>";
if ($too_many) {
echo "
More than 100 teams match your search.
The first 100 are shown.<br>
";
}
}
echo "End of results<br>";
echo "If you cannot find the team you are looking for, you may create a team ";
echo "by clicking <a href=team_create_form.php>here</a>.";
page_tail();
?>