Ejemplo n.º 1
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";
}
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
function send_notify_email($userid, $message)
{
    $user = BoincUser::lookup_id($userid);
    $subject = "Daily notification summary from " . PROJECT;
    $body = "The following events occurred in the past day at " . PROJECT . ".\nFor details, visit your Account page at\n" . secure_url_base() . "home.php\n\n{$message}\n---------------\nTo change your email preferences for " . PROJECT . ", visit:\n" . secure_url_base() . "edit_forum_preferences_form.php\n\nDo not reply to this email.\n";
    send_email($user, $subject, $body);
    echo "sending to {$user->email_addr}\n";
}
Ejemplo n.º 4
0
function show_admin($user, $admin)
{
    $admin_user = BoincUser::lookup_id($admin->userid);
    $tokens = url_tokens($user->authenticator);
    $date = date_str($admin->create_time);
    echo "<tr>\n        <td>" . user_links($admin_user) . "</td>\n        <td>{$date}</td>\n        <td>\n    ";
    show_button("team_admins.php?teamid={$admin->teamid}&action=remove&userid={$admin_user->id}" . $tokens, tra("Remove"), tra("Remove Team Admin status from this member"));
    echo "</td></tr>\n    ";
}
function send_founder_transfer_email($team, $user)
{
    $founder = BoincUser::lookup_id($team->userid);
    // send founder a private message for good measure
    $subject = "Team founder transfer request";
    $body = "Team member " . $user->name . " has asked that you\ntransfer foundership of {$team->name}.\nPlease go [url=" . URL_BASE . "team_change_founder_form.php?teamid={$team->id}]here[/url] to grant or decline the request.\n    \nIf you do not respond within 60 days, " . $user->name . " will\nbe allowed to become the team founder.\n";
    pm_send($user, $founder, $subject, $body, false);
    $subject = PROJECT . " team founder transfer";
    $body = "Team member " . $user->name . " has asked that you\ntransfer foundership of {$team->name} in " . PROJECT . ".\nPlease visit\n" . URL_BASE . "team_change_founder_form.php?teamid=" . $team->id . "\nto grant or decline the request.\n    \nIf you do not respond within 60 days, " . $user->name . " will\nbe allowed to become the team founder.\n    \nPlease do not respond to this email.\nThe mailbox is not monitored and the email\nwas sent using an automated system.";
    return send_email($founder, $subject, $body);
}
Ejemplo n.º 6
0
function show_delta($delta)
{
    global $xml;
    $user = BoincUser::lookup_id($delta->userid);
    $when = time_str($delta->timestamp);
    $what = $delta->joining ? "joined" : "quit";
    if ($xml) {
        echo "    <action>\n        <id>{$user->id}</id>\n        <name>{$user->name}</name>\n        <action>{$what}</action>\n        <total_credit>{$delta->total_credit}</total_credit>\n        <when>{$when}</when>\n    </action>\n";
    } else {
        echo "<tr>\n           <td>{$when}</td>\n           <td>", user_links($user), " (ID {$user->id})</td>\n           <td>{$what}</td>\n           <td>{$delta->total_credit}</td>\n           </tr>\n        ";
    }
}
Ejemplo n.º 7
0
function show_admin_page($user, $team)
{
    page_head(tra("Team administration for %1", $team->name));
    echo "\n        <ul>\n        <li><a href=team_edit_form.php?teamid={$team->id}>" . tra("Edit team info") . "</a>\n            <br><p class=\"text-muted\">" . tra("Change team name, URL, description, type, or country") . "</p>\n        <li>\n            " . tra("Member list:") . "\n        <a href=team_email_list.php?teamid={$team->id}>" . tra("HTML") . "</a>\n        &middot; <a href=team_email_list.php?teamid={$team->id}&plain=1>" . tra("text") . "</a>\n            <br><p class=\"text-muted\">" . tra("View member names and email addresses") . "</p>\n        <li>" . tra("View change history:") . "\n            <a href=team_delta.php?teamid={$team->id}>" . tra("HTML") . "</a>\n            &middot; <a href=team_delta.php?teamid={$team->id}&xml=1>" . tra("XML") . "</a>\n            <br><p class=\"text-muted\">" . tra("See when members joined or quit this team") . "</p>\n    ";
    // founder-only stuff follows
    //
    if ($team->userid == $user->id) {
        $tokens = url_tokens($user->authenticator);
        if ($team->ping_user > 0) {
            $user2 = BoincUser::lookup_id($team->ping_user);
            $deadline = date_str(transfer_ok_time($team));
            echo "<li>\n                <a href=team_change_founder_form.php?teamid={$team->id}><font color=red><strong>" . tra("Respond to foundership request.") . "</strong></font></a>  " . tra("If you don't respond by %1, %2 may assume foundership of this team.", $deadline, $user2->name);
        }
        echo "\n            <li><a href=team_remove_inactive_form.php?teamid={$team->id}>" . tra("Remove members") . "</a>\n                <br><p class=\"text-muted\">" . tra("Remove inactive or unwanted members from this team") . "</p>\n            <li><a href=team_change_founder_form.php?teamid={$team->id}>" . tra("Change founder") . "</a>\n                <br><p class=\"text-muted\">" . tra("Transfer foundership to another member") . "</p>\n            <li><a href=team_admins.php?teamid={$team->id}>" . tra("Add/remove Team Admins") . "</a>\n                <br><p class=\"text-muted\">" . tra("Give selected team members Team Admin privileges") . "</p>\n\n            <li><a href=team_manage.php?teamid={$team->id}&action=delete&{$tokens}>" . tra("Remove team") . "</a>\n                <br><p class=\"text-muted\">" . tra("Allowed only if team has no members") . "</p>\n            <li><a href=team_forum.php?teamid={$team->id}&cmd=manage>" . tra("Message board") . "</a>\n                <br><p class=\"text-muted\">" . tra("Create or manage a team message board") . "</p>\n        ";
    }
    echo "\n\n        <p>\n        <li>\n            " . tra("To have this team created on all BOINC projects (current and future) you can make it into a %1BOINC-wide team%2.", "<a href=http://boinc.berkeley.edu/teams/>", "</a>") . "\n        <li>\n            " . tra("Team admins are encouraged to join and participate in the Google %1boinc-team-founders%2 group.", "<a href=http://groups.google.com/group/boinc-team-founders>", "</a>") . "\n    </ul>\n    ";
    page_tail();
}
Ejemplo n.º 8
0
function login_via_link($id, $t, $h)
{
    $user = BoincUser::lookup_id($id);
    if (!$user) {
        error_page("Invalid user ID.\n            Please make sure you visited the complete URL;\n            it may have been split across lines by your email reader.");
    }
    $x = $id . $user->authenticator . $t;
    $x = md5($x);
    $x = substr($x, 0, 16);
    if ($x != $h) {
        error_page("Invalid authenticator.\n            Please make sure you visited the complete URL;\n            it may have been split across lines by your email reader.");
    }
    if (time() - $t > 86400) {
        error_page("Link has expired;\n            go <a href=get_passwd.php>here</a> to\n            get a new login link by email.");
    }
    send_cookie('auth', $user->authenticator, true);
    Header("Location: home.php");
}
Ejemplo n.º 9
0
function handle_team($team, $f)
{
    $user = BoincUser::lookup_id($team->userid);
    if (!$user) {
        echo "no user for team {$team->id}\n";
        exit(1);
    }
    if ($user->teamid != $team->id) {
        echo "Founder is not member of {$team->name}\n";
        return;
    }
    if (!$user->email_validated) {
        echo "the founder of {$team->name}, {$user->email_addr}, is not validated\n";
        return;
    }
    $user_email_munged = str_rot13($user->email_addr);
    fwrite($f, "<team>\n   <name>" . htmlspecialchars($team->name) . "</name>\n   <url>" . htmlspecialchars($team->url) . "</url>\n   <type>{$team->type}</type>\n   <name_html>" . htmlspecialchars($team->name_html) . "</name_html>\n   <description>\n" . htmlspecialchars($team->description) . "\n\t</description>\n   <country>{$team->country}</country>\n   <id>{$team->id}</id>\n   <user_email_munged>{$user_email_munged}</user_email_munged>\n   <user_name>" . htmlspecialchars($user->name) . "</user_name>\n   <user_country>" . htmlspecialchars($user->country) . "</user_country>\n   <user_postal_code>" . htmlspecialchars($user->postal_code) . "</user_postal_code>\n   <user_url>" . htmlspecialchars($user->url) . "</user_url>\n</team>\n");
}
Ejemplo n.º 10
0
function show_admin_page($user, $team)
{
    page_head("Team administration for {$team->name}");
    echo "\r\n\t\t<ul>\r\n\t\t<li><a href=team_edit_form.php?teamid={$team->id}>Edit team info</a>\r\n\t\t\t<br><span class=note>Change team name, URL, description, type, or country</span>\r\n\t\t<li>\r\n\t\t\tMember list:\r\n\t\t<a href=team_email_list.php?teamid={$team->id}>HTML</a>\r\n\t\t| <a href=team_email_list.php?teamid={$team->id}&plain=1>text</a>\r\n\t\t\t<br><span class=note> View member names and email addresses </span>\r\n\t\t<li>View change history:\r\n\t\t\t<a href=team_delta.php?teamid={$team->id}>HTML</a>\r\n\t\t\t| <a href=team_delta.php?teamid={$team->id}&xml=1>XML</a>\r\n\t\t\t<br><span class=note>See when members joined or quit this team</span>\r\n\t";
    // founder-only stuff follows
    //
    if ($team->userid == $user->id) {
        $tokens = url_tokens($user->authenticator);
        if ($team->ping_user > 0) {
            $user2 = BoincUser::lookup_id($team->ping_user);
            $deadline = date_str(transfer_ok_time($team));
            echo "<li>\r\n\t\t\t\t<a href=team_change_founder_form.php?teamid={$team->id}><font color=red><b>Respond to foundership request</b></font></a>.  If you don't respond by {$deadline}, {$user2->name} may assume foundership of this team.\r\n\t\t\t";
        }
        echo "\r\n\t\t\t<li><a href=team_remove_inactive_form.php?teamid={$team->id}>Remove members</a>\r\n\t\t\t\t<br><span class=note>Remove inactive or unwanted members from this team</span>\r\n\t\t\t<li><a href=team_change_founder_form.php?teamid={$team->id}>Change founder</a>\r\n\t\t\t\t<br><span class=note>Transfer foundership to another member</span>\r\n\t\t\t<li><a href=team_admins.php?teamid={$team->id}>Add/remove Team Admins</a>\r\n\t\t\t\t<br><span class=note>Give selected team members Team Admin privileges</span>\r\n\r\n\t\t\t<li><a href=team_manage.php?teamid={$team->id}&action=delete&{$tokens}>Remove team</a>\r\n\t\t\t\t<br><span class=note>Allowed only if team has no members</a>\r\n\t\t\t<li><a href=team_forum.php?teamid={$team->id}&cmd=manage>Message board</a>\r\n\t\t\t\t<br><span class=note>Create or manage team message board</span>\r\n\t\t";
    }
    echo "\r\n\r\n\t\t<p>\r\n\t\t<li>\r\n\t\t\tTo have this team created on all BOINC projects\r\n\t\t\t(current and future) you can make it into a\r\n\t\t\t<a href=http://boinc.berkeley.edu/teams/>BOINC-wide team</a>.\r\n\t\t<li>\r\n\t\t\tTeam admins are encouraged to join and participate in the Google\r\n\t\t\t<a href=http://groups.google.com/group/boinc-team-founders>boinc-team-founders</a> group.\r\n\t\t<li>\r\n\t\t\tOther resources for BOINC team admins\r\n\t\t\tare available from a third-party site,\r\n\t\t\t<a href=http://www.boincteams.com>www.boincteams.com</a>.\r\n\t</ul>\r\n\t";
    page_tail();
}
Ejemplo n.º 11
0
function validate()
{
    $x = get_str("x");
    $u = get_int("u");
    $user = BoincUser::lookup_id($u);
    if (!$user) {
        error_page(tra("No such user."));
    }
    $x2 = $user->signature;
    if ($x2 != $x) {
        error_page(tra("Error in URL data - can't validate email address"));
    }
    $result = $user->update("email_validated=1");
    if (!$result) {
        error_page(tra("Database update failed - please try again later."));
    }
    page_head(tra("Validate email address"));
    echo tra("The email address of your account has been validated.");
    page_tail();
}
Ejemplo n.º 12
0
function notify_users()
{
    $now = time();
    $rs = BoltRefresh::enum("due_time < {$now}");
    $users = array();
    foreach ($rs as $r) {
        $view = BoltView::lookup_id($r->view_id);
        $user_id = $view->user_id;
        if (!key_exists($user_id)) {
            $user = BoincUser::lookup_id($user_id);
            BoltUser::lookup($user);
            $user->refresh = array();
            $users[$user_id] = $user;
        }
        $users[$user_id]->refresh[] = $r;
    }
    foreach ($users as $user) {
        notify_user($user);
    }
}
Ejemplo n.º 13
0
function process_batch($b)
{
    $app = BoincApp::lookup_id($b->app_id);
    if (!$app) {
        echo "no app for batch {$b->id}\n";
        return;
    }
    if ($b->fraction_done > 0 && $b->credit_canonical > 0) {
        $credit_total = $b->credit_canonical / $b->fraction_done;
        $fpops_total = $credit_total * (86400000000000.0 / 200);
    } else {
        $db = BoincDb::get();
        $fpops_total = $db->sum("workunit", "rsc_fpops_est*target_nresults", "where batch={$b->id}");
    }
    echo "batch {$b->id} fpops_total {$fpops_total}\n";
    if ($fpops_total == 0) {
        return;
    }
    // adjust the user's logical start time
    //
    $user = BoincUser::lookup_id($b->user_id);
    if (!$user) {
        die("no user {$b->user_id}\n");
    }
    $us = BoincUserSubmit::lookup_userid("{$user->id}");
    if (!$us) {
        die("no user submit record\n");
    }
    $lst = $us->logical_start_time;
    $cmd = "cd ../../bin; ./adjust_user_priority --user {$user->id} --flops {$fpops_total} --app {$app->name}";
    system($cmd);
    $us = BoincUserSubmit::lookup_userid("{$user->id}");
    $let = $us->logical_start_time;
    $let = (int) $let;
    // set the priority of workunits and results in this batch
    // to the user's new logical start time
    //
    $clause = "priority={$let} where batch={$b->id}";
    BoincResult::update_aux($clause);
    BoincWorkunit::update_aux($clause);
}
Ejemplo n.º 14
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";
}
Ejemplo n.º 15
0
function do_pass()
{
    $int_max = 2147483647;
    $now = time();
    $insts = BossaJobInst::enum("timeout < {$now}");
    if (!count($insts)) {
        return false;
    }
    foreach ($insts as $inst) {
        BossaDb::start_transaction();
        $inst = BossaJobInst::lookup_id($inst->id);
        // reread instance within transation
        if ($inst->transition_time < $now) {
            $job = BossaJob::lookup_id($inst->job_id);
            $user = BoincUser::lookup_id($inst->user_id);
            BossaUser::lookup($user);
            job_timed_out($job, $inst, $user);
        }
        $inst->update("timeout={$int_max}");
        BossaDb::commit();
    }
    return true;
}
function show_profile_link2($profile, $n)
{
    $user = BoincUser::lookup_id($profile->userid);
    echo "<tr><td>" . user_links($user) . "</td><td>" . date_str($user->create_time) . "</td><td>{$user->country}</td><td>" . (int) $user->total_credit . "</td><td>" . (int) $user->expavg_credit . "</td></tr>\n";
}
    $forum_highlight_special = $user->prefs->highlight_special ? "checked=\"checked\"" : "";
    $forum_minimum_wrap_postcount = intval($user->prefs->minimum_wrap_postcount);
    $forum_display_wrap_postcount = intval($user->prefs->display_wrap_postcount);
    row1(tra("Message display"));
    row2(tra("What to display"), "<input type=\"checkbox\" name=\"forum_hide_avatars\" " . $forum_hide_avatars . "> " . tra("Hide avatar images") . "<br>\n    <input type=\"checkbox\" name=\"forum_hide_signatures\" " . $forum_hide_signatures . "> " . tra("Hide signatures") . "<br>\n    <input type=\"checkbox\" name=\"forum_images_as_links\" " . $forum_image_as_link . "> " . tra("Show images as links") . "<br>\n    <input type=\"checkbox\" name=\"forum_link_popup\" " . $forum_link_popup . "> " . tra("Open links in new window/tab") . "<br>\n    <input type=\"checkbox\" name=\"forum_highlight_special\" " . $forum_highlight_special . "> " . tra("Highlight special users") . "<br>\n    <input type=\"text\" name=\"forum_display_wrap_postcount\" size=3 value=\"" . $forum_display_wrap_postcount . "\"> " . tra("Display this many messages per page") . "<br />\n    ");
    row2(tra("How to sort"), tra("Threads:") . " " . select_from_array("forum_sort", $forum_sort_styles, $user->prefs->forum_sorting) . "<br>" . tra("Posts:") . " " . select_from_array("thread_sort", $thread_sort_styles, $user->prefs->thread_sorting) . "<br>\n    <input type=\"checkbox\" name=\"forum_jump_to_unread\" " . $forum_jump_to_unread . "> " . tra("Jump to first new post in thread automatically") . "<br>\n    <input type=\"checkbox\" name=\"forum_ignore_sticky_posts\" " . $forum_ignore_sticky_posts . ">" . tra("Don't move sticky posts to top") . "<br>\n    ");
}
// DISABLE_FORUMS
// ------------ Message filtering  -----------
row1(tra("Message filtering"));
$filtered_userlist = get_ignored_list($user);
$forum_filtered_userlist = "";
for ($i = 0; $i < sizeof($filtered_userlist); $i++) {
    $id = (int) $filtered_userlist[$i];
    if ($id) {
        $filtered_user = BoincUser::lookup_id($id);
        if (!$filtered_user) {
            echo "Missing user {$id}";
            continue;
        }
        $forum_filtered_userlist .= "<input class=\"btn btn-default\" type=\"submit\" name=\"remove" . $filtered_user->id . "\" value=\"" . tra("Remove") . "\"> " . $filtered_user->id . " - " . user_links($filtered_user) . "<br>";
    }
}
row2(tra("Filtered users") . "<br><p class=\"text-muted\">" . tra("Ignore message board posts and private messages from these users.") . "</p>", "{$forum_filtered_userlist}\n        <input type=\"text\" name=\"forum_filter_user\" size=12> " . tra("User ID (For instance: 123456789)") . "\n        <br><input class=\"btn btn-default\" type=\"submit\" name=\"add_user_to_filter\" value=\"" . tra("Add user to filter") . "\">\n    ");
row1(tra("Update"));
row2(tra("Click here to update preferences"), "<input class=\"btn btn-primary\" type=submit value=\"" . tra("Update") . "\">");
echo "</form>\n";
row1(tra("Reset"));
row2(tra("Or click here to reset preferences to the defaults"), "<form method=\"post\" action=\"edit_forum_preferences_action.php\"><input class=\"btn btn-warning\" type=\"submit\" value=\"" . tra("Reset") . "\"><input type=\"hidden\" name=\"action\" value=\"reset_confirm\"></form>");
end_table();
page_tail();
Ejemplo n.º 18
0
    $host_content .= "\n    Total Disk Space: {$y} GB";
    $x = $host->d_free / (1024 * 1024 * 1024);
    $y = round($x, 2);
    $host_content .= "\n    Free Disk Space: {$y} GB\n    Avg network bandwidth (upstream): {$host->n_bwup} bytes/sec\n    Avg network bandwidth (downstream): {$host->n_bwdown} bytes/sec";
    $x = $host->avg_turnaround / 86400;
    $host_content .= "\n    Average turnaround: " . round($x, 2) . " days\n    Number of RPCs: {$host->rpc_seqno}\n    Last RPC: " . time_str($host->rpc_time) . "\n    % of time client on: " . 100 * $host->on_frac . " %\n    % of time host connected: " . 100 * $host->connected_frac . " %\n    % of time user active: " . 100 * $host->active_frac . " %\n    # of results today: " . $host->nresults_today;
    $subject = PROJECT . " notice for {$user->name}";
    $body = PROJECT . " notification:\n\nDear {$user->name}\nYour machine (host # {$host->id}) described below appears to have a misconfigured BOINC\ninstallation.  Could you please have a look at it?\n\nSincerely,\n        The " . PROJECT . " team\n";
    $body .= "\n\nThis is the content of our database:\n" . $host_content . "\n\nFor further information and assistance with " . PROJECT . " go to {$master_url}";
    echo nl2br($body) . "<br><br>";
    return send_email($user, $subject, $body);
}
$hostid = get_int("hostid", true);
if (!$hostid) {
    admin_page_head("Misconfigured Host");
    echo "This script sends an email to the owner of the supplied host which says that something gone wrong with his configuration.<br>";
    echo "<br><form method=\"get\" action=\"problem_host.php\">\n    Host ID: \n    <input type=\"text\" size=\"5\" name=\"hostid\">\n    <input class=\"btn btn-default\" type=\"submit\" value=\"Send Email\">\n    </form>\n    ";
} else {
    $host = BoincHost::lookup_id($hostid);
    if (!$host) {
        echo "<h2>No host with that ID</h2>\n\t \t<center>Please <a href=\"problem_host.php\">try again</a></center>";
    } else {
        $user = BoincUser::lookup_id($host->userid);
        echo "<a href=\"problem_host.php\">Do another?</a><br><br>";
        send_problem_email($user, $host);
        echo "Email to " . $user->email_addr . " has been sent.<br>";
    }
}
admin_page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
Ejemplo n.º 19
0
function handle_add_action()
{
    $user_id = get_int('user_id');
    $user = BoincUser::lookup_id($user_id);
    if (!$user) {
        error_page("no such user");
    }
    $us = BoincUserSubmit::lookup_userid($user_id);
    if (!$us) {
        if (!BoincUserSubmit::insert("(user_id) values ({$user_id})")) {
            error_page("Insert failed");
        }
    }
    header("Location: manage_project.php?action=edit_form&user_id={$user_id}");
}
Ejemplo n.º 20
0
function show_forum($forum, $start, $sort_style, $user)
{
    $gotoStr = "";
    $nav = show_page_nav($forum, $start);
    if ($nav) {
        $gotoStr = "<div align=\"right\">{$nav}</div><br />";
    }
    echo $gotoStr;
    // Display the navbar
    start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>"));
    $sticky_first = !$user || !$user->prefs->ignore_sticky_posts;
    // Show hidden threads if logged in user is a moderator
    //
    $show_hidden = is_moderator($user, $forum);
    $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
    if ($user) {
        $subs = BoincSubscription::enum("userid={$user->id}");
    }
    // Run through the list of threads, displaying each of them
    $n = 0;
    $i = 0;
    foreach ($threads as $thread) {
        $owner = BoincUser::lookup_id($thread->owner);
        $unread = thread_is_unread($user, $thread);
        //if ($thread->status==1){
        // This is an answered helpdesk thread
        if ($user && is_subscribed($thread, $subs)) {
            echo '<tr class="row_hd' . $n . '">';
        } else {
            echo '<tr class="row' . $n . '">';
        }
        echo '<td width="1%"><nobr>';
        if ($user && $thread->rating() > $user->prefs->high_rating_threshold) {
            show_image(EMPHASIZE_IMAGE, "This message has a high average rating", "Highly rated");
        }
        if ($user && $thread->rating() < $user->prefs->low_rating_threshold) {
            show_image(FILTER_IMAGE, "This message has a low average rating", "Low rated");
        }
        if ($thread->hidden) {
            echo "[hidden]";
        }
        if ($unread) {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet", "sticky/locked/unread");
                } else {
                    show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet", "sticky/unread");
                }
            } else {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked", "unread/locked");
                } else {
                    show_image(NEW_IMAGE, "You haven't read this thread yet", "unread");
                }
            }
        } else {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked", "sticky/locked");
                } else {
                    show_image(IMAGE_STICKY, "This thread is sticky", "sticky");
                }
            } else {
                if ($thread->locked) {
                    show_image(IMAGE_LOCKED, "This thread is locked", "locked");
                }
            }
        }
        echo "</nobr></td>";
        $titlelength = 48;
        $title = $thread->title;
        if (strlen($title) > $titlelength) {
            $title = substr($title, 0, $titlelength) . "...";
        }
        $title = cleanup_title($title);
        echo '<td class="threadline">
			<a href="forum_thread.php?id=' . $thread->id . '"><strong>' . $title . '</strong></a>
			<br /></td>';
        $n = ($n + 1) % 2;
        echo '<td class="numbers leftborder">' . ($thread->replies + 1) . '</td>
			<td class="author leftborder">' . user_links($owner) . '</td>
			<td class="numbers leftborder">' . $thread->views . '</td>
			<td class="lastpost leftborder">' . time_diff_str($thread->timestamp, time()) . '</td>
			</tr>';
        flush();
    }
    end_table();
    echo "<br />{$gotoStr}";
    // show page links
}
Ejemplo n.º 21
0
    page_tail();
    exit;
}
if ($user->id == $team->ping_user) {
    echo "<p>" . tra("You requested the foundership of %1 on %2.", $team->name, date_str($team->ping_time)) . "\n    </p>";
    if (transfer_ok($team, $now)) {
        echo tra("60 days have elapsed since your request, and the founder has not responded. You may now assume foundership by clicking here:") . "<form method=\"post\" action=\"team_founder_transfer_action.php\">\n            <input type=\"hidden\" name=\"action\" value=\"finalize_transfer\">\n            <input class=\"btn btn-default\" type=\"submit\" value=\"" . tra("Assume foundership") . "\">\n            </form>\n        ";
    } else {
        echo "<p>" . tra("The founder was notified of your request. If he/she does not respond by %1 you will be given an option to become founder.", date_str(transfer_ok_time($team))) . "</p>";
    }
} else {
    if (new_transfer_request_ok($team, $now)) {
        echo "<form method=\"post\" action=\"team_founder_transfer_action.php\">";
        echo "<p>" . tra("If the team founder is not active and you want to assume the role of founder, click the button below. The current founder will be sent an email detailing your request, and will be able to transfer foundership to you or to decline your request. If the founder does not respond in 60 days, you will be allowed to become the founder.<br /><br />\n                       Are you sure you want to request foundership?") . "</p>";
        echo "<input type=\"hidden\" name=\"action\" value=\"initiate_transfer\">\n            <input class=\"btn btn-default\" type=\"submit\" value=\"" . tra("Request foundership") . "\">\n            </form>\n        ";
    } else {
        if ($team->ping_user) {
            if ($team->ping_user < 0) {
                $team->ping_user = -$team->ping_user;
            }
            $ping_user = BoincUser::lookup_id($team->ping_user);
            echo "<p>" . tra("Founder change has already been requested by %1 on %2.", user_links($ping_user), date_str($team->ping_time)) . "</p>";
        } else {
            echo "<p>" . tra("A foundership change was requested during the last 90 days, so new requests are not allowed. Please try again later.") . "</p>";
        }
    }
}
echo "<p><a href=\"team_display.php?teamid=" . $team->id . "\">" . tra("Return to team page") . "</a>";
page_tail();
$cvs_version_tracker[] = "\$Id\$";
//Generated automatically - do not edit
Ejemplo n.º 22
0
function batches_form($app)
{
    page_head("Manage jobs for {$app->name}");
    echo "\n        <form action=manage_app.php>\n        <input type=hidden name=action value=batches_action>\n        <input type=hidden name=app_id value={$app->id}>\n    ";
    start_table();
    table_header("Batch ID", "Submitter", "Submitted", "State", "# jobs", "Abort?");
    $batches = BoincBatch::enum("app_id={$app->id}");
    foreach ($batches as $batch) {
        $user = BoincUser::lookup_id($batch->user_id);
        echo "<tr>\n            <td>{$batch->id}</td>\n            <td>{$user->name}</td>\n            <td>" . time_str($batch->create_time) . "</td>\n            <td>" . batch_state_string($batch->state) . "\n            <td>{$batch->njobs}</td>\n            <td><input type=checkbox name=abort_{$batch->id}></td>\n            </tr>\n        ";
    }
    echo "<tr>\n        <td colspan=5>Abort all jobs for {$app->name}?</td>\n        <td><input type=checkbox name=abort_all></td>\n        </tr>\n    ";
    echo "<tr>\n        <td><br></td>\n        <td><br></td>\n        <td><br></td>\n        <td><input class=\"btn btn-default\" type=submit value=OK></td>\n        </tr>\n    ";
    end_table();
    page_tail();
}
Ejemplo n.º 23
0
function get_wu_output_files($wu_id, $auth_str)
{
    $wu = BoincWorkunit::lookup_id($wu_id);
    if (!$wu) {
        die("no workunit {$wu_id}");
    }
    $batch = BoincBatch::lookup_id($wu->batch);
    if (!$batch) {
        die("no batch {$wu->batch}");
    }
    $user = BoincUser::lookup_id($batch->user_id);
    if (!$user) {
        die("no user {$batch->user_id}");
    }
    $x = md5($user->authenticator . $wu_id);
    echo "user authenticator= {$user->authenticator}, wu_id={$wu_id}<br/>";
    if ($x != $auth_str) {
        die("bad auth str: x={$x}, auth_str={$auth_str}");
    }
    $zip_basename = tempnam("/tmp", "boinc_wu_" . $wu->name . "_");
    $zip_filename = $zip_basename . ".zip";
    $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
    $upload_dir = parse_config(get_config(), "<upload_dir>");
    if (!$wu->canonical_resultid) {
        die("no canonical result for wu {$wu->name}");
    }
    $result = BoincResult::lookup_id($wu->canonical_resultid);
    $names = get_outfile_names($result);
    foreach ($names as $name) {
        $path = dir_hier_path($name, $upload_dir, $fanout);
        if (is_file($path)) {
            system("nice -9 zip -jq {$zip_basename} {$path}");
        }
    }
    do_download($zip_filename);
    unlink($zip_filename);
    unlink($zip_basename);
}
Ejemplo n.º 24
0
}
$thread = BoincThread::lookup_id($post->thread);
if (!$thread) {
    error_page("no such thread");
}
$forum = BoincForum::lookup_id($thread->forum);
if (!is_moderator($logged_in_user, $forum)) {
    if (time() > $post->timestamp + MAXIMUM_EDIT_TIME) {
        error_page(tra("You can no longer edit this post.<br/>Posts can only be edited at most %1 minutes after they have been created.", MAXIMUM_EDIT_TIME / 60));
    }
}
$post_owner = BoincUser::lookup_id($post->user);
if ($logged_in_user->id != $post_owner->id || can_reply($thread, $forum, $logged_in_user) == false) {
    error_page(tra("You are not authorized to edit this post."));
}
$thread_owner = BoincUser::lookup_id($thread->owner);
// If this post belongs to the creator of the thread and is at top-level
// (ie. not a response to another post)
// allow the user to modify the thread title
//
$can_edit_title = $post->parent_post == 0 && $thread_owner->id == $logged_in_user->id && !is_banished($logged_in_user);
$content = post_str("content", true);
$title = post_str("title", true);
$preview = post_str("preview", true);
if (post_str('submit', true) && !$preview) {
    check_tokens($logged_in_user->authenticator);
    $add_signature = post_str('add_signature', true) == "1" ? 1 : 0;
    $content = substr($content, 0, 64000);
    $content = trim($content);
    if (strlen($content)) {
        $content = BoincDb::escape_string($content);
Ejemplo n.º 25
0
require_once "../inc/util.inc";
require_once "../inc/xml.inc";
xml_header();
if (DISABLE_FORUMS) {
    xml_error(-1, "Forums are disabled");
}
$retval = db_init_xml();
if ($retval) {
    xml_error($retval);
}
$method = get_str("method", true);
if ($method != "user_posts" && $method != "user_threads") {
    xml_error(-1);
}
$userid = get_int("userid", true);
$user = BoincUser::lookup_id($userid);
if (!$user) {
    xml_error(ERR_DB_NOT_FOUND);
}
if ($method == "user_posts") {
    $count = get_int("count", true);
    if (!$count || $count <= 0 || $count > 50) {
        $count = 10;
    }
    $length = get_int("contentlength", true);
    if ($length == null || $length <= 0) {
        $length = 0;
    }
    $posts = BoincPost::enum("user={$userid} ORDER BY timestamp DESC LIMIT {$count}");
    $realcount = BoincPost::count("user={$userid}");
    echo "<rpc_response>\n";
Ejemplo n.º 26
0
if ($search_max_time) {
    $min_timestamp = time() - $search_max_time * 3600 * 24;
} else {
    $min_timestamp = 0;
}
$limit = 100;
if ($search_forum == -1) {
    $forum = null;
} else {
    if ($search_forum) {
        $forum = BoincForum::lookup_id($search_forum);
    }
}
$user = null;
if ($search_author) {
    $user = BoincUser::lookup_id($search_author);
}
// First search thread titles; if we get a hit there it's probably relevant
//
$threads = search_thread_titles($search_list, $forum, $user, $min_timestamp, round($limit / 7), $search_sort, $show_hidden_posts);
// Display the threads while we search for posts
if (count($threads)) {
    echo "<span class=title>" . tra("Thread titles matching your query:") . "</span>";
    show_thread_and_context_header();
    $i = 0;
    foreach ($threads as $thread) {
        if ($thread->hidden) {
            continue;
        }
        show_thread_and_context($thread, $logged_in_user, $i++);
    }
Ejemplo n.º 27
0
function show_simulation()
{
    $scen = get_str("scen");
    $sim = get_str("sim");
    $dir = "scenarios/{$scen}/simulations/{$sim}";
    if (!is_dir($dir)) {
        error_page("No such simulation");
    }
    page_head("Simulation {$sim}");
    start_table();
    $userid = (int) file_get_contents("{$dir}/userid");
    $user = BoincUser::lookup_id($userid);
    $date = date_str(filemtime($dir));
    row2("Scenario", "<a href=sim_web.php?action=show_scenario&name={$scen}>{$scen}</a>");
    row2("Who", $user->name);
    row2("When", $date);
    row2("Parameters", "<pre>" . file_get_contents("{$dir}/inputs.txt") . "</pre>");
    row2("Results", "<pre>" . file_get_contents("{$dir}/results.txt") . "</pre>");
    $x = file_get_contents("{$dir}/index.html");
    $x = str_replace("<h3>Output files</h3>", "", $x);
    $x = str_replace("href=", "href=scenarios/{$scen}/simulations/{$sim}/", $x);
    row2("Output files", $x);
    $x = get_comments($dir);
    if ($x) {
        row2("Comments", $x);
    }
    echo "<form action=sim_web.php>\n        <input type=hidden name=scen value={$scen}>\n        <input type=hidden name=sim value={$sim}>\n        <input type=hidden name=action value=add_comment>\n    ";
    row2("<input type=submit value=\"Add comment\">", "<textarea name=comment></textarea>");
    echo "</form>";
    end_table();
    page_tail();
}
    $user_to_add = trim($_POST["forum_filter_user"]);
    if ($user_to_add != "" and $user_to_add == strval(intval($user_to_add))) {
        $other_user = BoincUser::lookup_id($user_to_add);
        if (!$other_user) {
            echo tra("No such user:"******" " . $user_to_add;
        } else {
            add_ignored_user($user, $other_user);
        }
    }
}
// Or remove some from the ignore list
//
$ignored_users = get_ignored_list($user);
for ($i = 0; $i < sizeof($ignored_users); $i++) {
    if ($_POST["remove" . trim($ignored_users[$i])] != "") {
        $other_user = BoincUser::lookup_id($ignored_users[$i]);
        if (!$other_user) {
            echo tra("No such user:"******" " . $ignored_users[$j];
        } else {
            remove_ignored_user($user, $other_user);
        }
    }
}
if ($rpc == false) {
    // If we get down here everything went ok
    // redirect the user to the setup page again
    //
    Header("Location: edit_forum_preferences_form.php");
} else {
    echo "<status>\n";
    echo "    <success>1</success>\n";
Ejemplo n.º 29
0
}
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);
    if ($cached_data) {
        // We found some old but non-stale data, let's use it
        $team = unserialize($cached_data);
    } else {
        $get_from_db = true;
    }
}
if ($get_from_db) {
    $team->nusers = BoincUser::count("teamid={$teamid}");
    $team->nusers_worked = BoincUser::count("teamid={$teamid} and total_credit>0");
    $team->nusers_active = BoincUser::count("teamid={$teamid} and expavg_credit>0.1");
    $team->forum = BoincForum::lookup("parent_type=1 and category={$team->id}");
    $team->new_members = new_member_list($teamid);
    $team->admins = admin_list($teamid);
    $team->founder = BoincUser::lookup_id($team->userid);
    set_cached_data(TEAM_PAGE_TTL, serialize($team), $cache_args);
}
if (!$team) {
    error_page(tra("no such team"));
}
display_team_page($team, $user);
page_tail(true);
Ejemplo n.º 30
0
function do_confirmedblock($logged_in_user)
{
    check_tokens($logged_in_user->authenticator);
    $id = post_int("id");
    $blocked_user = BoincUser::lookup_id($id);
    if (!$blocked_user) {
        error_page(tra("no such user"));
    }
    add_ignored_user($logged_in_user, $blocked_user);
    page_head(tra("User %1 blocked", $blocked_user->name));
    echo "<div>" . tra("User %1 has been blocked from sending you private messages.", $blocked_user->name) . "\n";
    echo tra("To unblock, visit %1message board preferences%2", "<a href=\"edit_forum_preferences_form.php\">", "</a>") . "</div>\n";
}