예제 #1
0
파일: userw.php 프로젝트: Turante/boincweb
function show_user_wap($user)
{
    wap_begin();
    if (!$user) {
        echo "<br/>User not found!<br/>";
        wap_end();
        return;
    }
    // keep a 'running tab' in wapstr in case exceeds 1K WAP limit
    $wapstr = PROJECT . "<br/>Account Data<br/>for {$user->name}<br/>Time: " . wap_timestamp();
    $wapstr .= show_credit_wap($user);
    if ($user->teamid) {
        $team = BoincTeam::lookup_id($user->teamid);
        $wapstr .= "<br/>Team: {$team->name}<br/>";
        $wapstr .= "Team TotCred: " . format_credit($team->total_credit) . "<br/>";
        $wapstr .= "Team AvgCred: " . format_credit($team->expavg_credit) . "<br/>";
    } else {
        $wapstr .= "<br/>Team: None<br/>";
    }
    // don't want to send more than 1KB probably?
    if (strlen($wapstr) > 1024) {
        echo substr($wapstr, 0, 1024);
    } else {
        echo $wapstr;
    }
    wap_end();
}
예제 #2
0
function export($is_user, $dir)
{
    $n = 0;
    $filename = $is_user ? "{$dir}/user_work" : "{$dir}/team_work";
    $f = fopen($filename, "w");
    if (!$f) {
        die("fopen");
    }
    $is_user ? fprintf($f, "<users>\n") : fprintf($f, "<teams>\n");
    $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id");
    while ($n <= $maxid) {
        $m = $n + 1000;
        if ($is_user) {
            $items = BoincUser::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
        } else {
            $items = BoincTeam::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0");
        }
        foreach ($items as $item) {
            export_item($item, $is_user, $f);
        }
        $n = $m;
    }
    $is_user ? fprintf($f, "</users>\n") : fprintf($f, "</teams>\n");
    fclose($f);
    system("gzip -f {$filename}");
}
예제 #3
0
파일: userw.php 프로젝트: CalvinZhu/boinc
function show_user_wap($userid)
{
    wap_begin();
    $user = BoincUser::lookup_id($userid);
    if (!$user) {
        echo "<br/>" . tra("User not found!") . "<br/>";
        wap_end();
        return;
    }
    if ($user->teamid) {
        $team = BoincTeam::lookup_id($user->teamid);
    }
    $wapstr = PROJECT . "<br/>" . tra("Account Data<br/>for %1<br/>Time:", $user->name) . " " . wap_timestamp();
    $wapstr .= show_credit_wap($user);
    if ($user->teamid && $team) {
        $wapstr .= "<br/>" . tra("Team:") . " " . $team->name . "<br/>";
        $wapstr .= tra("Team TotCred:") . " " . format_credit($team->total_credit) . "<br/>";
        $wapstr .= tra("Team AvgCred:") . " " . format_credit($team->expavg_credit) . "<br/>";
    } else {
        $wapstr .= "<br/>" . tra("Team: None") . "<br/>";
    }
    // don't want to send more than 1KB (WAP limit)
    //
    if (strlen($wapstr) > 1024) {
        $wapstr = substr($wapstr, 0, 1024);
    }
    echo $wapstr;
    wap_end();
}
예제 #4
0
function show_row($x, $y, $mode, $i)
{
    $class = $i % 2 ? "row0" : "row1";
    echo "<tr class={$class}><td>";
    switch ($mode) {
        case 'host':
            echo "<a href=show_host_detail.php?hostid={$x}>{$x}</a>";
            break;
        case 'user':
            $user = BoincUser::lookup_id($x);
            echo "<a href=show_user.php?userid={$x}>{$user->name}</a>";
            break;
        case 'team':
            $team = BoincTeam::lookup_id($x);
            if ($team) {
                echo "<a href=team_display.php?teamid={$x}>{$team->name}</a>";
            } else {
                echo "(no team)";
            }
            break;
        case 'model':
            echo $x;
            break;
        case 'day':
            echo $x;
            break;
    }
    echo "</td><td align=right>" . format_credit_large($y->credit), "</td><td align=right>{$y->nresults}</td></tr>\n";
}
예제 #5
0
function get_teams($clause, $active)
{
    $c2 = '';
    if ($active) {
        $c2 = "and expavg_credit>0.1";
    }
    return BoincTeam::enum("{$clause} {$c2} order by expavg_credit desc limit 20");
}
예제 #6
0
function show_user($user)
{
    echo "\n        <tr class=row1>\n        <td>", user_links($user), " (ID {$user->id})</td>\n    ";
    if ($user->teamid) {
        $team = BoincTeam::lookup_id($user->teamid);
        echo "\n            <td> <a href=team_display.php?teamid={$team->id}>{$team->name}</a> </td>\n        ";
    } else {
        echo "<td><br></td>";
    }
    echo "\n        <td align=right>", format_credit($user->expavg_credit), "</td>\n        <td align=right>", format_credit_large($user->total_credit), "</td>\n        <td>", $user->country, "</td>\n        <td>", time_str($user->create_time), "</td>\n        </tr>\n    ";
}
예제 #7
0
function main()
{
    $f = fopen("temp.xml", "w");
    $teams = BoincTeam::enum();
    fwrite($f, "<teams>\n");
    foreach ($teams as $team) {
        handle_team($team, $f);
    }
    fwrite($f, "</teams>\n");
    fclose($f);
    rename("temp.xml", "/home/boincadm/boinc/doc/boinc_teams.xml");
}
예제 #8
0
function get_teams($clause, $active)
{
    $c2 = '';
    if ($active) {
        $c2 = "and expavg_credit>0.1";
    }
    $x = BoincTeam::enum("{$clause} {$c2} order by expavg_credit desc limit 20");
    foreach ($x as $t) {
        $t->refcnt = 0;
    }
    return $x;
}
예제 #9
0
function main()
{
    echo "------------ Starting at " . time_str(time()) . "-------\n";
    $f = fopen("temp.xml", "w");
    $teams = BoincTeam::enum(null);
    fwrite($f, "<teams>\n");
    foreach ($teams as $team) {
        handle_team($team, $f);
    }
    fwrite($f, "</teams>\n");
    fclose($f);
    if (!rename("temp.xml", "/home/boincadm/boinc/doc/boinc_teams.xml")) {
        echo "Rename failed\n";
    }
}
예제 #10
0
function get_top_teams($offset, $sort_by, $type)
{
    global $teams_per_page;
    $db = BoincDb::get(true);
    $type_clause = null;
    if ($type) {
        $type_clause = "type={$type}";
    }
    if ($sort_by == "total_credit") {
        $sort_order = "total_credit desc";
    } else {
        $sort_order = "expavg_credit desc";
    }
    return BoincTeam::enum($type_clause, "order by {$sort_order} limit {$offset}, {$teams_per_page}");
}
예제 #11
0
function assign_badges($is_user, $badge_pctiles, $badge_images)
{
    $kind = $is_user ? "user" : "team";
    $badges = get_pct_badges($kind . "_pct", $badge_pctiles, $badge_images);
    $pctiles = get_percentiles($is_user, $badge_pctiles);
    //echo "thresholds for $kind badges: $pctiles[0] $pctiles[1] $pctiles[2]\n";
    $n = 0;
    $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id");
    while ($n <= $maxid) {
        $m = $n + 1000;
        if ($is_user) {
            $items = BoincUser::enum_fields("id, expavg_credit", "id>={$n} and id<{$m} and total_credit>0");
        } else {
            $items = BoincTeam::enum_fields("id, expavg_credit", "id>={$n} and id<{$m} and total_credit>0");
        }
        foreach ($items as $item) {
            assign_pct_badge($is_user, $item, $pctiles, $badges);
            // ... assign other types of badges
        }
        $n = $m;
    }
}
예제 #12
0
파일: forum_index.php 프로젝트: happyj/qcn
function show_forum_summary($forum, $i)
{
    switch ($forum->parent_type) {
        case 0:
            $t = $forum->title;
            $d = $forum->description;
            break;
        case 1:
            $team = BoincTeam::lookup_id($forum->category);
            $t = $forum->title;
            if (!strlen($t)) {
                $t = $team->name;
            }
            $d = $forum->description;
            if (!strlen($d)) {
                $d = tra("Discussion among members of %1", $team->name);
            }
            break;
    }
    $j = $i % 2;
    echo "\n        <tr class=\"row{$j}\">\n        <td>\n            <a href=\"forum_forum.php?id={$forum->id}\">{$t}</a>\n            <br><span class=\"smalltext\">{$d}</span>\n        </td>\n        <td class=\"numbers\">{$forum->threads}</td>\n        <td class=\"numbers\">{$forum->posts}</td>\n        <td class=\"lastpost\">" . time_diff_str($forum->timestamp, time()) . "</td>\n    </tr>";
}
예제 #13
0
function show_row($item, $apps, $is_team, $i)
{
    $j = $i % 2;
    if ($is_team) {
        $team = BoincTeam::lookup_id($item->teamid);
        if (!$team) {
            return;
        }
        $x = "<td>" . team_links($team) . "</td>\n";
    } else {
        $user = BoincUser::lookup_id($item->userid);
        if (!$user) {
            return;
        }
        $x = "<td>" . user_links($user, BADGE_HEIGHT_MEDIUM) . "</td>\n";
    }
    echo "<tr class=row{$j}>";
    echo "<td>{$i}</td>\n";
    echo $x;
    foreach ($apps as $app) {
        if ($app->id == $item->appid) {
            $c = $item;
        } else {
            if ($is_team) {
                $c = BoincCreditTeam::lookup("teamid={$item->teamid} and appid={$app->id}");
            } else {
                $c = BoincCreditUser::lookup("userid={$item->userid} and appid={$app->id}");
            }
            if (!$c) {
                $c = new StdClass();
                $c->expavg = 0;
                $c->total = 0;
            }
        }
        echo "<td align=right>" . format_credit($c->expavg) . "</td><td align=right>" . format_credit_large($c->total) . "</td>\n";
    }
    echo "</tr>\n";
}
예제 #14
0
    case 0:
        $category = BoincCategory::lookup_id($forum->category);
        if ($category->is_helpdesk) {
            page_head(tra("Questions and Answers") . ' : ' . $forum->title);
            ?>
<link href="forum_help_desk.php" rel="up" title="Forum Index"><?php 
        } else {
            page_head(tra("Message boards") . ' : ' . $forum->title);
            ?>
<link href="forum_index.php" rel="up" title="Forum Index"><?php 
        }
        show_forum_header($user);
        show_forum_title($category, $forum, NULL);
        break;
    case 1:
        $team = BoincTeam::lookup_id($forum->category);
        page_head('Team message board for <a href="team_display.php?teamid=$team->id">$team->name</a>');
        show_forum_header($user);
        show_team_forum_title($forum);
        break;
}
?>
<form action="forum_forum.php" method="get">
<?php 
echo start_table("noborder");
?>
<table width="100%">
	<tr valign="top">
	<td colspan="2">
		<?php 
show_button("forum_post.php?id={$id}", "New thread", "Add a new thread to this forum");
예제 #15
0
if (_mysql_num_rows($result) < 1) {
    echo "There are no new users.";
    admin_page_tail();
}
start_table();
table_header("ID", "Name", "Email", "Team", "Country", "Joined");
while ($row = _mysql_fetch_object($result)) {
    $id = $row->id;
    $name = $row->name;
    $email = $row->email_addr;
    $country = $row->country;
    $joined = time_str($row->create_time);
    $email_validated = $row->email_validated;
    $team_name = "";
    if ($row->teamid > 0) {
        $team = BoincTeam::lookup_id($row->teamid);
        $team_name = $team->name;
    }
    // Special Users:
    $roles = "";
    $user = $row;
    BoincForumPrefs::lookup($user);
    $special_bits = $user->prefs->special_user;
    if ($special_bits != "0") {
        for ($i = 0; $i < 7; $i++) {
            $bit = substr($special_bits, $i, 1);
            if ($bit == '1') {
                if (!empty($roles)) {
                    $roles .= ", ";
                }
                $roles .= $special_user_bitfield[$i];
예제 #16
0
function assign_all_badges($is_user, $badge_levels, $badge_level_names, $badge_images, $subprojects_list)
{
    $kind = $is_user ? "user" : "team";
    // get badges for all subprojects including total
    //
    foreach ($subprojects_list as $sp) {
        $badges[$sp["short_name"]] = get_badges($kind, $badge_level_names, $badge_images, $sp);
    }
    $n = 0;
    $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id");
    while ($n <= $maxid) {
        $m = $n + 1000;
        if ($is_user) {
            $items = BoincUser::enum_fields("id, total_credit", "id>={$n} and id<{$m} and total_credit>0");
        } else {
            $items = BoincTeam::enum_fields("id, total_credit", "id>={$n} and id<{$m} and total_credit>0");
        }
        // for every user/team
        //
        foreach ($items as $item) {
            // for every subproject (incl. total)
            //
            foreach ($subprojects_list as $sp) {
                if ($sp["short_name"] == "total") {
                    assign_tot_badge($is_user, $item, $badge_levels, $badges["total"]);
                } else {
                    // appids come from project/project.inc
                    $where_clause = "appid in (" . implode(',', $sp["appids"]) . ")";
                    assign_sub_badge($is_user, $item, $badge_levels, $badges[$sp["short_name"]], $where_clause);
                }
            }
        }
        $n = $m;
    }
}
예제 #17
0
// 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/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/xml.inc";
xml_header();
$retval = db_init_xml();
if ($retval) {
    xml_error($retval);
}
check_get_args(array("account_key"));
$auth = get_str("account_key");
$user = BoincUser::lookup_auth($auth);
if (!$user) {
    xml_error(ERR_DB_NOT_FOUND);
}
$name = urlencode($user->name);
$country = urlencode($user->country);
$postal_code = urlencode($user->postal_code);
$url = urlencode($user->url);
$weak_auth = weak_auth($user);
$cpid = md5($user->cross_project_id . $user->email_addr);
$ret = "<id>{$user->id}</id>\n<name>{$name}</name>\n<country>{$country}</country>\n<weak_auth>{$weak_auth}</weak_auth>\n<postal_code>{$postal_code}</postal_code>\n<cpid>{$cpid}</cpid>\n<has_profile>{$user->has_profile}</has_profile>\n<create_time>{$user->create_time}</create_time>\n<global_prefs>\n{$user->global_prefs}\n</global_prefs>\n<project_prefs>\n{$user->project_prefs}\n</project_prefs>\n<url>{$url}</url>\n<send_email>{$user->send_email}</send_email>\n<show_hosts>{$user->show_hosts}</show_hosts>\n<teamid>{$user->teamid}</teamid>\n<venue>{$user->venue}</venue>";
if ($user->teamid) {
    $team = BoincTeam::lookup_id_nocache($user->teamid);
    if ($team->userid == $user->id) {
        $ret = $ret . "<teamfounder/>\n";
    }
}
echo "<am_get_info_reply>\n    <success/>\n    {$ret}\n</am_get_info_reply>\n";
예제 #18
0
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2014 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/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
require_once "../inc/team.inc";
if (DISABLE_TEAMS) {
    error_page("Teams are disabled");
}
check_get_args(array());
$user = get_logged_in_user();
page_head(tra("Create a team"));
if ($user->teamid && ($team = BoincTeam::lookup_id($user->teamid))) {
    echo tra("You belong to %1. You must %2quit this team%3 before creating a new one.", "<a href=\"team_display.php?teamid=" . $team->id . "\">" . $team->name . "</a>", "<a href=\"team_quit_form.php\">", "</a>");
} else {
    team_edit_form(null, tra("Create a team"), "team_create_action.php");
}
page_tail();
예제 #19
0
파일: pm.php 프로젝트: gchilders/boinc
function do_send_team($logged_in_user)
{
    check_tokens($logged_in_user->authenticator);
    $subject = post_str("subject", true);
    $content = post_str("content", true);
    $teamid = post_int("teamid");
    if (post_str("preview", true) == tra("Preview")) {
        pm_team_form($logged_in_user, $teamid);
        return;
    }
    // make sure user is authorized, i.e. is a team admin
    //
    $team = BoincTeam::lookup_id($teamid);
    if (!$team) {
        error_page("no such team");
    }
    if (!is_team_admin($logged_in_user, $team)) {
        error_page("no team admin");
    }
    if ($subject == null || $content == null) {
        pm_team_form($logged_in_user, $teamid, tra("You need to fill all fields to send a private message"));
        return;
    }
    $subject = "Message from team " . $team->name . ": " . $subject;
    // don't use tra() here because we don't know language of recipient
    // Also, we use it in pm_count() to exclude team messages from limit check
    $users = BoincUser::enum("teamid={$teamid}");
    foreach ($users as $user) {
        pm_send_msg($logged_in_user, $user, $subject, $content, true);
    }
    page_head(tra("Message sent"));
    echo tra("Your message was sent to %1 team members.", count($users));
    page_tail();
}
예제 #20
0
function handle_team($f)
{
    $t = parse_team($f);
    if (!$t) {
        echo "Failed to parse team\n";
        return;
    }
    //print_r($t);
    //return;
    if (!valid_team($t)) {
        echo "Invalid team\n";
        return;
    }
    echo "Processing {$t->name} {$t->user_email}\n";
    $user = BoincUser::lookup_email_addr($t->user_email);
    $team = BoincTeam::lookup_name($t->name);
    if ($team) {
        if (!$user) {
            echo "   team exists but user {$t->user_email} doesn't\n";
            return;
        }
        if ($user->id != $team->userid) {
            echo "   team exists but is owned by a different user\n";
            return;
        }
        if ($team->seti_id) {
            if ($team->seti_id == $t->id) {
                echo "   case 1\n";
                update_team($t, $team, $user);
                // update1 case
            } else {
                echo "   team exists but has wrong seti_id\n";
            }
        } else {
            $team2 = lookup_team_seti_id($t->id);
            if ($team2) {
                // update1 case
                echo "   case 2\n";
                update_team($t, $team2, $user);
            } else {
                // update2 case
                echo "   case 3\n";
                update_team($t, $team, $user);
            }
        }
    } else {
        $team = lookup_team_seti_id($t->id);
        if ($team) {
            echo "   A team with same ID but different name exists;\n";
            echo "   Please report this to {$t->user_email};\n";
        } else {
            echo "   Adding team\n";
            insert_case($t, $user);
        }
    }
}
예제 #21
0
// 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/>.
require_once "../inc/util.inc";
require_once "../inc/cert.inc";
check_get_args(array("border"));
$user = get_logged_in_user();
$team = BoincTeam::lookup_id($user->teamid);
if (!$team) {
    error_page("no team");
}
$join = gmdate('j F Y', $team->create_time);
$today = gmdate('j F Y', time(0));
credit_to_ops($team->total_credit, $ops, $unit);
$border = get_str("border", true);
if ($border == "no") {
    $border = 0;
} else {
    $border = 8;
}
$credit = credit_string($team->total_credit, false);
$title_font = "\"Optima,ZapfChancery\"";
$font = "\"Optima,Lucida Bright,Times New Roman\"";
예제 #22
0
                $total++;
                if ($total == 100) {
                    break;
                }
            }
            //do not error out
        }
    }
    echo "</teams>\n";
    exit;
}
$team_name = get_str("team_name");
$name_lc = strtolower($team_name);
$name_lc = escape_pattern($name_lc);
$clause = "name like '%" . BoincDb::escape_string($name_lc) . "%' order by expavg_credit desc limit 100";
$teams = BoincTeam::enum($clause);
if ($format == 'xml') {
    echo "<teams>\n";
    $total = 0;
    foreach ($teams as $team) {
        show_team_xml($team);
        $total++;
        if ($total == 100) {
            break;
        }
    }
    echo "</teams>\n";
    exit;
}
page_head(tra("Search Results"));
if (count($teams)) {
예제 #23
0
function delete_team_id_range($id1, $id2)
{
    for ($i = $id1; $i <= $id2; $i++) {
        echo "deleting team {$i}\n";
        $team = BoincTeam::lookup_id($i);
        if ($team) {
            $team->delete();
            $user = BoincUser::lookup_id($team->userid);
            if ($user) {
                $user->delete();
            }
        }
    }
}
예제 #24
0
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
require_once "../inc/team.inc";
if (DISABLE_TEAMS) {
    error_page("Teams are disabled");
}
check_get_args(array());
$user = get_logged_in_user();
$name = post_str("name", true);
if (strlen($name) == 0) {
    error_page(tra("You must choose a non-blank team name"));
}
$new_team = BoincTeam::lookup_name($name);
if ($new_team) {
    error_page(tra("A team named %1 already exists - try another name", htmlentities($name)));
}
$url = post_str("url", true);
$type = post_str("type", true);
$name_html = post_str("name_html", true);
$description = post_str("description", true);
$country = post_str("country", true);
if ($country == "") {
    $country = "International";
}
$new_team = make_team($user->id, $name, $url, $type, $name_html, $description, $country);
if ($new_team) {
    user_join_team($new_team, $user);
    Header("Location: team_display.php?teamid={$new_team->id}");
예제 #25
0
$team_name = BoincDb::escape_string(strip_tags(post_str("name")));
$team_name_lc = strtolower($team_name);
$tnh = post_str("name_html", true);
$team_name_html = sanitize_html($tnh);
$team_name_html = BoincDb::escape_string($team_name_html);
$team_description = BoincDb::escape_string(post_str("description", true));
$type = BoincDb::escape_string(post_str("type", true));
$country = BoincDb::escape_string(post_str("country", true));
if ($country == "") {
    $country = "International";
}
if (!is_valid_country($country)) {
    error_page("bad country");
}
$joinable = post_str('joinable', true) ? 1 : 0;
$t = BoincTeam::lookup("name='{$team_name}'");
if ($t && $t->id != $teamid) {
    error_page("The name '{$team_name}' is being used by another team.");
}
if (strlen($team_name) == 0) {
    error_page("Must specify team name");
}
// Should be caught up with the post_str("name"),
// but you can never be too safe.
$clause = sprintf("name = '%s',\r\n\tname_lc = '%s',\r\n\tname_html = '%s',\r\n\turl = '%s',\r\n\tdescription = '%s',\r\n\ttype = %d,\r\n\tcountry='%s',\r\n\tjoinable=%d", $team_name, $team_name_lc, $team_name_html, $team_url, $team_description, $type, $country, $joinable);
$ret = $team->update($clause);
if ($ret) {
    Header("Location: team_display.php?teamid={$team->id}");
} else {
    error_page("Could not update team - please try later.");
}
예제 #26
0
// 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/>.
require_once "../inc/cache.inc";
require_once "../inc/util.inc";
require_once "../inc/boinc_db.inc";
require_once "../inc/team.inc";
check_get_args(array("teamid"));
$teamid = get_int("teamid");
$team = BoincTeam::lookup_id($teamid);
$get_from_db = false;
$user = get_logged_in_user(false);
// always show fresh copy to admins; they might be editing info
//
if (is_team_admin($user, $team)) {
    $get_from_db = true;
}
if ($user->id == $team->ping_user) {
    $get_from_db = true;
}
// Cache the team record, its forum record, its new members,
// its admins, and its member counts
$cache_args = "teamid={$teamid}";
if (!$get_from_db) {
    $cached_data = get_cached_data(TEAM_PAGE_TTL, $cache_args);
예제 #27
0
function delete_teams()
{
    global $days, $test;
    $query = "nusers < 2 and seti_id=0 and total_credit=0";
    if ($days) {
        $x = time() - $days * 86400;
        $query .= " and create_time > {$x}";
    }
    $teams = BoincTeam::enum($query);
    foreach ($teams as $team) {
        $n = team_count_members($team->id);
        if ($n > 1) {
            continue;
        }
        if (!has_link($team->description)) {
            continue;
        }
        $user = BoincUser::lookup_id($team->userid);
        if ($user) {
            $n = BoincPost::count("user={$user->id}");
            if ($n) {
                continue;
            }
            $n = BoincHost::count("userid={$user->id}");
            if ($n) {
                continue;
            }
        }
        if ($test) {
            echo "would delete team:\n";
            echo "   ID: {$team->id}\n";
            echo "   name: {$team->name}\n";
            echo "   description: {$team->description}\n";
        } else {
            $team->delete();
            echo "deleted team ID {$team->id} name {$team->name}\n";
            if ($user) {
                do_delete_user($user);
            }
        }
    }
}