예제 #1
0
function add_admin($team)
{
    $email_addr = get_str('email_addr');
    $user = BoincUser::lookup("email_addr='{$email_addr}'");
    if (!$user) {
        error_page(tra("no such user"));
    }
    if ($user->teamid != $team->id) {
        error_page(tra("User is not member of team"));
    }
    if (is_team_admin($user, $team)) {
        error_page(tra("%1 is already an admin of %2", $email_addr, $team->name));
    }
    $now = time();
    $ret = BoincTeamAdmin::insert("(teamid, userid, create_time) values ({$team->id}, {$user->id}, {$now})");
    if (!$ret) {
        error_page(tra("Couldn't add admin"));
    }
}
function authenticate_user($r, $app)
{
    $auth = (string) $r->authenticator;
    if (!$auth) {
        error("no authenticator");
    }
    $user = BoincUser::lookup("authenticator='{$auth}'");
    if (!$user) {
        error("bad authenticator");
    }
    $user_submit = BoincUserSubmit::lookup_userid($user->id);
    if (!$user_submit) {
        error("no submit access");
    }
    if ($app && !$user_submit->submit_all) {
        $usa = BoincUserSubmitApp::lookup("user_id={$user->id} and app_id={$app->id}");
        if (!$usa) {
            error("no submit access");
        }
    }
    return array($user, $user_submit);
}
예제 #3
0
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
// Show results with pending credit for a user
require_once "../inc/util.inc";
require_once "../inc/boinc_db.inc";
require_once "../inc/xml.inc";
check_get_args(array("format", "authenticator"));
BoincDb::get(true);
$config = get_config();
if (!parse_bool($config, "show_results")) {
    error_page("This feature is turned off temporarily");
}
$format = get_str("format", true);
if ($format == "xml") {
    xml_header();
    $auth = BoincDb::escape_string(get_str('authenticator'));
    $user = BoincUser::lookup("authenticator='{$auth}'");
    if (!$user) {
        echo "<error>" . xml_error(-136) . "</error>\n";
        exit;
    }
    $sum = 0;
    echo "<pending_credit>\n";
    $results = BoincResult::enum("userid={$user->id} AND (validate_state=0 OR validate_state=4) AND claimed_credit > 0");
    foreach ($results as $result) {
        echo "<result>\n";
        echo "    <resultid>" . $result->id . "</resultid>\n";
        echo "    <workunitid>" . $result->workunitid . "</workunitid>\n";
        echo "    <hostid>" . $result->hostid . "</hostid>\n";
        echo "    <claimed_credit>" . $result->claimed_credit . "</claimed_credit>\n";
        echo "    <received_time>" . $result->received_time . "</received_time>\n";
        echo "</result>\n";
예제 #4
0
//
// This file was modified by contributors of "BOINC Web Tweak" project.
// RPC handler for account lookup
require_once "../inc/boinc_db.inc";
require_once "../inc/util.inc";
require_once "../inc/email.inc";
require_once "../inc/xml.inc";
xml_header();
$retval = db_init_xml();
if ($retval) {
    xml_error($retval);
}
$email_addr = get_str("email_addr");
$passwd_hash = get_str("passwd_hash", true);
$email_addr = BoincDb::escape_string($email_addr);
$user = BoincUser::lookup("email_addr='{$email_addr}'");
if (!$user) {
    xml_error(-136);
}
if (!$passwd_hash) {
    echo "<account_out>\r\n\t<success/>\r\n</account_out>\r\n";
    exit;
}
$auth_hash = md5($user->authenticator . $user->email_addr);
// if no password set, set password to account key
//
if (!strlen($user->passwd_hash)) {
    $user->passwd_hash = $auth_hash;
    $user->update("passwd_hash='{$user->passwd_hash}'");
}
// if the given password hash matches (auth+email), accept it