~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to html/inc/user.inc

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
function get_other_projects($user) {
77
77
    $cpid = md5($user->cross_project_id . $user->email_addr);
 
78
    
 
79
    $timeout = 3;
 
80
    $old_timeout = ini_set('default_socket_timeout', $timeout);
78
81
    $url = "http://boinc.netsoft-online.com/get_user.php?cpid=$cpid";
79
 
    $f = fopen($url, "r");
 
82
    $f = @fopen($url, "r");
 
83
    ini_set('default_socket_timeout', $old_timeout);
80
84
    if (!$f) {
81
85
        return $user;
82
86
    }
157
161
    }
158
162
    $x .= "<br/><span class=\"smalltext\">".tra("Cross-project ID").": $cpid</span>\n";
159
163
    row2(tra("Cross-project statistics"), $x);
160
 
    $x = "<a href=cert1.php>Account</a>";
 
164
    $x = '<a href="cert1.php">'.tra("Account").'</a>';
161
165
    if ($user->teamid) {
162
 
        $x .= " | <a href=cert_team.php>Team</a>";
 
166
        $x .= ' | <a href="cert_team.php">'.tra("Team").'</a>';
163
167
    }
164
 
    $x .= " | <a href=cert_all.php>Cross-project</a>";
 
168
    $x .= ' | <a href="cert_all.php">'.tra("Cross-project").'</a>';
165
169
    row2(tra("Certificate"), $x);
166
170
    row2(tra("Stats on your cell phone"), URL_BASE."userw.php?id=$user->id");
167
171
}
177
181
    case NOTIFY_SUBSCRIBED_POST:
178
182
        return subscribed_post_web_line($notify);
179
183
    }
180
 
    return "Unknown notification type: $notify->type";
 
184
    return tra("Unknown notification type: %1", $notify->type);
181
185
}
182
186
 
183
187
function weak_auth($user) {
191
195
    if (is_valid_email_addr($user->email_addr)) {
192
196
        $email_text = $user->email_addr;
193
197
    } else {
194
 
        $email_text = "Verification pending";
 
198
        $email_text = tra("Email address verification pending");
195
199
    }
196
200
 
197
201
    row1(tra("Account information"));
205
209
    row2(tra("Postal code"), $user->postal_code);
206
210
    row2(tra("%1 member since", PROJECT), date_str($user->create_time));
207
211
    $url_tokens = url_tokens($user->authenticator);
208
 
    row2(tra("Change"), "<a href=\"edit_email_form.php\">".tra("email address")."</a> | <a href=\"edit_passwd_form.php\">".tra("password")."</a> | <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>");
 
212
    row2(tra("Change"), "<a href=\"edit_email_form.php\">".tra("email address")."</a> | <a href=\"".SECURE_URL_BASE."/edit_passwd_form.php\">".tra("password")."</a> | <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>");
209
213
    row2("", "<a href=\"logout.php?$url_tokens\">".tra("Log out")."</a>");
210
214
    row2(tra("User ID")."<br/><span class=\"note\">".tra("Used in community functions")."</span>", $user->id);
211
215
    if (!no_computing()) {
212
216
        row2(tra("Account key")."<br/><span class=\"note\">".tra("Provides full access to your account")."</span>", $user->authenticator);
213
 
        row2(tra("Weak account key")."<br/><span class=\"note\">".tra("Provides")." <a href=\"weak_auth.php\">".tra("limited access")."</a> ".tra("to your account")."</span>", weak_auth($user));
 
217
        row2(tra("Weak account key")."<br/><span class=\"note\">".tra("Provides %1limited access%2 to your account", "<a href=\"weak_auth.php\">", "</a> ")."</span>", weak_auth($user));
214
218
    }
215
219
 
216
220
    row1("<a name=\"prefs\"></a>".tra("Preferences"));
224
228
        "<a href=\"edit_forum_preferences_form.php\">".tra("Community preferences")."</a>"
225
229
    );
226
230
    if (!no_computing()) {
227
 
        row2(tra("Resource share and graphics"),
 
231
        row2(tra("Preferences for this project"),
228
232
            "<a href=\"prefs.php?subset=project\">".tra("%1 preferences", PROJECT)."</a>"
229
233
        );
230
234
    }
256
260
        row2(tra("Notifications"), $x);
257
261
    }
258
262
 
259
 
    if ($user->teamid) {
260
 
        $team = lookup_team($user->teamid);
261
 
        $x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>
262
 
            | <a href=\"team_quit_form.php\">".tra("Quit team")."</a>";
263
 
        if (is_team_admin($user, $team)) {
264
 
            $x .= " | <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>";
265
 
        }
 
263
    if (!defined('NO_TEAMS')) {
 
264
        if ($user->teamid) {
 
265
            $team = lookup_team($user->teamid);
 
266
            $x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>
 
267
                | <a href=\"team_quit_form.php\">".tra("Quit team")."</a>";
 
268
            if (is_team_admin($user, $team)) {
 
269
                $x .= " | <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>";
 
270
            }
266
271
 
267
 
        // if there's a foundership request, notify the founder
268
 
        //
269
 
        if ($user->id==$team->userid && $team->ping_user >0) {
270
 
            $x .= "<span style=\"color:red;\">".tra("(foundership change request pending)")."</span>";
271
 
        }
272
 
        row2(tra("Member of team"), $x);
273
 
    } else {
274
 
        row2(tra("Team"), tra("None")." | <a href=\"team_search.php\">".tra("find a team")."</a>");
275
 
    }
276
 
    
277
 
    $teams_founded = BoincTeam::enum("userid=$user->id");
278
 
    foreach ($teams_founded as $team) {
279
 
        if ($team->id != $user->teamid) {
280
 
            $x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>";
281
 
            $x .= "| <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>";
282
 
            if ($team->ping_user > 0) {
 
272
            // if there's a foundership request, notify the founder
 
273
            //
 
274
            if ($user->id==$team->userid && $team->ping_user >0) {
283
275
                $x .= "<span style=\"color:red;\">".tra("(foundership change request pending)")."</span>";
284
276
            }
285
 
            row2(tra("Founder but not member of"), $x);
 
277
            row2(tra("Member of team"), $x);
 
278
        } else {
 
279
            row2(tra("Team"), tra("None")." | <a href=\"team_search.php\">".tra("find a team")."</a>");
 
280
        }
 
281
        
 
282
        $teams_founded = BoincTeam::enum("userid=$user->id");
 
283
        foreach ($teams_founded as $team) {
 
284
            if ($team->id != $user->teamid) {
 
285
                $x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>";
 
286
                $x .= "| <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>";
 
287
                if ($team->ping_user > 0) {
 
288
                    $x .= "<span style=\"color:red;\">".tra("(foundership change request pending)")."</span>";
 
289
                }
 
290
                row2(tra("Founder but not member of"), $x);
 
291
            }
286
292
        }
287
293
    }
288
294
 
327
333
    }
328
334
}
329
335
 
330
 
function community_links($user) {
331
 
    global $g_logged_in_user;
332
 
    if ($user->teamid && ($team = lookup_team($user->teamid))) {
333
 
        row2(tra("Team"), "<a href=\"".URL_BASE."team_display.php?teamid=$team->id\">$team->name</a>");
334
 
    } else {
335
 
        row2(tra("Team"), tra("None"));
336
 
    }
337
 
    $tot = total_posts($user);
 
336
// Returns a cacheable community links data object
 
337
// @param user The user to produce a community links object for
 
338
 
 
339
function get_community_links_object($user){
 
340
    $cache_object->post_count = total_posts($user);
 
341
    $cache_object->user = $user;
 
342
    $cache_object->team = lookup_team($user->teamid);
 
343
 
 
344
    $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
 
345
    $n = count($friends);
 
346
    if ($n) {
 
347
        $x = null;
 
348
        foreach($friends as $friend) {
 
349
            $fuser = BoincUser::lookup_id($friend->user_dest);
 
350
            $cache_object->friends[] = $fuser;
 
351
        }
 
352
    }
 
353
    return $cache_object;
 
354
}
 
355
 
 
356
function community_links($clo, $logged_in_user){
 
357
    $user = $clo->user;
 
358
    $team = $clo->team;
 
359
    $friends = $clo->friends;
 
360
    $tot = $clo->post_count;
 
361
    
 
362
    if (!defined('NO_TEAMS')) {
 
363
        if ($user->teamid && $team) {
 
364
            row2(tra("Team"), "<a href=\"".URL_BASE."team_display.php?teamid=$team->id\">$team->name</a>");
 
365
        } else {
 
366
            row2(tra("Team"), tra("None"));
 
367
        }
 
368
    }
338
369
    if ($tot) {
339
370
        row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
340
371
    }
341
 
    if ($g_logged_in_user && $g_logged_in_user->id != $user->id) {
 
372
    if ($logged_in_user && $logged_in_user->id != $user->id) {
342
373
        row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>");
343
 
        $friend = BoincFriend::lookup($g_logged_in_user->id, $user->id);
 
374
        $friend = BoincFriend::lookup($logged_in_user->id, $user->id);
344
375
        if ($friend && $friend->reciprocated) {
345
376
            row2(tra("This person is a friend"), 
346
377
                "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
351
382
            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
352
383
        }
353
384
    }
354
 
    $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
355
 
    $n = count($friends);
356
 
    if ($n) {
 
385
    
 
386
    if ($friends) {
357
387
        $x = null;
358
388
        foreach($friends as $friend) {
359
 
            $fuser = BoincUser::lookup_id($friend->user_dest);
360
 
            $x .= friend_links($fuser);
 
389
            $x .= friend_links($friend);
361
390
        }
362
 
        row2(tra("Friends")." ($n)", $x);
 
391
        row2(tra("Friends")." (".sizeof($friends).")", $x);
363
392
    }
364
393
}
365
394
 
369
398
    }
370
399
}
371
400
 
 
401
function show_account_private($user) {
 
402
    start_table_noborder();
 
403
    echo "<tr><td valign=top>";
 
404
    start_table();
 
405
    show_user_info_private($user);
 
406
    if (!no_computing()) {
 
407
        show_user_stats_private($user);
 
408
    }
 
409
 
 
410
    if (file_exists("../project/donations.inc")) {
 
411
        require_once("../project/donations.inc");
 
412
        if (function_exists('show_user_donations_private')) {
 
413
            show_user_donations_private($user);
 
414
        }
 
415
    }
 
416
    end_table();
 
417
    show_other_projects($user, true);
 
418
    project_user_page_private($user);
 
419
    echo "</td><td valign=top>";
 
420
    start_table();
 
421
    show_community_private($user);
 
422
    end_table();
 
423
 
 
424
    echo "</td></tr></table>";
 
425
}
 
426
 
 
427
function is_banned_email_addr($email_addr) {
 
428
    global $banned_email_domains;
 
429
    if (isset($banned_email_domains)) {
 
430
        foreach($banned_email_domains as $d) {
 
431
            $x = strstr($email_addr, $d);
 
432
            if ($x == $d) return true;
 
433
        }
 
434
    }
 
435
    return false;
 
436
}
 
437
 
372
438
// the following DB-escapes its args
373
439
//
374
440
function make_user(
376
442
    $country=null, $postal_code=null, $project_prefs=null, $teamid=0
377
443
) {
378
444
    if (!is_valid_email_addr($email_addr)) return null;
 
445
    if (is_banned_email_addr($email_addr)) return null;
 
446
 
379
447
    $authenticator = random_string();
380
448
    $cross_project_id = random_string();
381
449
    $now = time();
382
450
    if (!is_valid_country($country)) return null;
383
451
 
384
 
    $email_addr = process_user_text($email_addr);
385
 
    $name = process_user_text($name);
386
 
    $passwd_hash = process_user_text($passwd_hash);
 
452
    $email_addr = BoincDb::escape_string($email_addr);
 
453
    $name = strip_tags($name);
 
454
    $name = BoincDb::escape_string($name);
 
455
    $passwd_hash = BoincDb::escape_string($passwd_hash);
387
456
 
388
457
    $country = BoincDb::escape_string($country);
389
 
    $postal_code = strip_tags(process_user_text($postal_code));
 
458
    $postal_code = strip_tags(BoincDb::escape_string($postal_code));
390
459
 
391
460
    $uid = BoincUser::insert("(create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid,  send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$email_addr', '$name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 1, 1, '$cross_project_id', '$passwd_hash')");
392
461
 
397
466
    }
398
467
}
399
468
 
400
 
$cvs_version_tracker[]="\$Id: user.inc 16228 2008-10-17 16:47:02Z boincadm $";  //Generated automatically - do not edit
 
469
$cvs_version_tracker[]="\$Id: user.inc 22366 2010-09-15 23:47:49Z davea $";  //Generated automatically - do not edit
401
470
 
402
471
?>