*** empty log message ***

svn path=/trunk/boinc/; revision=4797
This commit is contained in:
David Anderson 2004-12-08 22:05:56 +00:00
parent 873e8de9bd
commit 4acb793e6e
6 changed files with 110 additions and 57 deletions

View File

@ -20905,3 +20905,15 @@ David 8 Dec 2004
Makefile.am
lib/
Makefile.am
David 8 Dec 2004
- web site: added Team leaderboards broken down by type (see team.php)
html/
inc/
team.inc
util.inc
user/
sample_index.php
team.php
top_teams.php

View File

@ -11,6 +11,19 @@ function show_team_create_account_url($team) {
row2("Create team account URL<br><font size=-2>Accounts created via this URL will belong to this team and will have the project preferences of its founder</font>", "<a href=$url>$url</a>");
}
function team_type_name($type) {
switch ($type) {
case 1: return "Unclassified";
case 2: return "Company";
case 3: return "Primary school";
case 4: return "Secondary school";
case 5: return "Junior college";
case 6: return "University or department";
case 7: return "Government agency";
}
return "Unknown";
}
function display_team_page($team, $offset, $sort_by) {
$n = 20;
@ -37,7 +50,12 @@ function display_team_page($team, $offset, $sort_by) {
row2("Description", sanitize_html($team->description));
}
if (strlen($team->url)) {;
row2("Web site", "<a href=http://$team->url>http://$team->url</a>");
if (strstr($team->url, "http://")) {
$x = $team->url;
} else {
$x = "http://$team->url";
}
row2("Web site", "<a href=$x>$x</a>");
}
row2("Members", $team->nusers);
@ -46,6 +64,7 @@ function display_team_page($team, $offset, $sort_by) {
$user = lookup_user_id($team->userid);
row2("Founder", user_links($user));
row2("Country", $team->country);
row2("Type", team_type_name($team->type));
row2("Join this team", "<a href=team_join_form.php?id=$team->id>Join</a>");
show_team_create_account_url($team);
echo "</table>";

View File

@ -433,7 +433,7 @@ function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) {
}
function format_credit($cobblestones) {
return sprintf("%.2f", $cobblestones);
return number_format($cobblestones, 2);
}
function project_is_stopped() {

View File

@ -38,7 +38,7 @@ function show_nav() {
<ul>
<li><a href=top_users.php>Top participants</a>
<li><a href=top_hosts.php>Top computers</a>
<li><a href=top_teams.php>Top teams</a>
<li><a href=team.php>Top teams</a>
<li><a href=stats.php>Other statistics</a></h3>
</ul>
";

View File

@ -34,9 +34,20 @@ echo "<p>".PROJECT." participants may form <b>teams</b>.
<input name=team_name>
<input type=submit name=search value=Search>
</form>
<li> <a href=top_teams.php>Show top teams</a>
<li> <a href=team_create_form.php>Create a team</a>
</ul>
Show top teams:
<ul>
<li> <a href=top_teams.php>All teams</a>
";
for ($i=1; $i<8; $i++) {
echo "<li> <a href=top_teams.php?type=$i>".team_type_name($i)." teams</a>
";
}
echo "
</ul>
";
page_tail();

View File

@ -1,69 +1,80 @@
<?php {
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
<?php
$n = 20;
require_once("../inc/cache.inc");
require_once("../inc/util.inc");
require_once("../inc/team.inc");
$sort_by = $_GET["sort_by"];
if (!$sort_by) $sort_by = "expavg_credit";
$offset = $_GET["offset"];
if (!$offset) $offset=0;
$n = 20;
if ($offset % $n) $offset = 0;
$sort_by = $_GET["sort_by"];
if (!$sort_by) $sort_by = "expavg_credit";
$offset = $_GET["offset"];
if (!$offset) $offset=0;
$type = $_GET["type"];
$type = $type + 0;
if ($type < 1 || $type > 7) {
$type = null;
}
if ($type) {
$type_url = "&type=$type";
$type_sql = "where type=$type";
$type_name = team_type_name($type);
}
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset";
start_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";
page_tail();
exit();
}
if ($offset % $n) $offset = 0;
require_once("../inc/db.inc");
require_once("../inc/user.inc");
require_once("../inc/team.inc");
if ($offset < 1000) {
$cache_args = "sort_by=$sort_by&offset=$offset".$type_url;
start_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_head("Limit exceeded");
echo "Sorry - first 1000 only.";
page_tail();
exit();
}
db_init();
require_once("../inc/db.inc");
require_once("../inc/user.inc");
page_head("Top teams");
db_init();
page_head("Top $type_name teams");
if ($sort_by == "total_credit") {
$sort_clause = "total_credit desc";
} else {
$sort_clause = "expavg_credit desc";
}
$result = mysql_query("select * from team $type_sql order by $sort_clause limit $offset,$n");
start_table();
row1("Teams", 6);
team_table_start($sort_by);
$i = $offset + 1;
while ($team = mysql_fetch_object($result)) {
if ($sort_by == "total_credit") {
$sort_clause = "total_credit desc";
show_team_row($team, $i);
$i++;
} else {
$sort_clause = "expavg_credit desc";
}
$result = mysql_query("select * from team order by $sort_clause limit $offset,$n");
start_table();
row1("Teams", 6);
team_table_start($sort_by);
$i = $offset + 1;
while ($team = mysql_fetch_object($result)) {
if ($sort_by == "total_credit") {
if (!team_inactive_ndays($team, 7)) {
show_team_row($team, $i);
$i++;
} else {
if (!team_inactive_ndays($team, 7)) {
show_team_row($team, $i);
$i++;
}
}
}
mysql_free_result($result);
echo "</table>\n<p>\n";
if ($offset > 0) {
$new_offset = $offset - $n;
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset>Last $n</a> | ";
}
mysql_free_result($result);
echo "</table>\n<p>\n";
if ($offset > 0) {
$new_offset = $offset - $n;
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset".$type_url.">Last $n</a> | ";
}
$new_offset = $offset + $n;
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset>Next $n</a>";
}
$new_offset = $offset + $n;
echo "<a href=top_teams.php?sort_by=$sort_by&offset=$new_offset".$type_url.">Next $n</a>";
if ($offset < 1000) {
page_tail(true);
end_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_tail();
}
if ($offset < 1000) {
page_tail(true);
end_cache(TOP_PAGES_TTL, $cache_args);
} else {
page_tail();
}
} ?>
?>