has_profile) return null;
$profile = BoincProfile::lookup("userid=$user->id");
if (!$profile->has_picture) return null;
if (profile_screening() && $profile->verification!=1) return null;
return profile_thumb_url($user->id);
}
// When passed profile->verification, this function is used to tell the
// user the verification status of their profile.
//
function offensive_profile_warning($verify_flag) {
if ($verify_flag == 0) {
return "
Your profile will be made visible to other people
as soon as it has been approved by the project.
This may take up to a few days.
";
} else if ($verify_flag == -1) {
return "
Your profile has been marked as unacceptable.
It is not visible to other people. Please change it.
";
}
return "";
}
// If the user with id = $userid has uploaded a picture his/herself,
// delete it and its thumbnail.
//
function delete_user_pictures($userid) {
$path = profile_image_path($userid);
if (file_exists($path)) {
unlink($path);
}
$path = profile_thumb_path($userid);
if (file_exists($path)) {
unlink($path);
}
}
function scale_image(
$image, $origWidth, $origHeight, $targetWidth, $targetHeight
) {
// If the image is already smaller than the target dimensions,
// just return it.
//
if ($origWidth <= $targetWidth && $origHeight <= $targetHeight) {
return $image;
}
($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($origHeight / $targetHeight);
if ($scalar != 0) {
$destWidth = $origWidth / $scalar;
$destHeight = $origHeight / $scalar;
} else {
$destWidth = $origWidth;
$destHeight = $origHeight;
}
$gd_info = gd_info();
$newGD = (strstr($gd_info["GD Version"], "2.0")!="");
if ($newGD) {
// If you are using a modern PHP/GD installation that does
// 'truecolor' images, this is what's needed.
$newImage = ImageCreateTrueColor($destWidth, $destHeight);
ImageCopyResampled(
$newImage, $image, 0, 0, 0, 0, $destWidth,
$destHeight, $origWidth, $origHeight
);
} else {
// If not, use this block.
// The image quality is lower but it works using older PHP/GD versions.
$newImage = ImageCreate($destWidth, $destHeight);
ImageCopyResized(
$newImage, $image, 0, 0, 0, 0, $destWidth, $destHeight,
$origWidth, $origHeight
);
}
return $newImage;
}
// Generates a string containing:
// 1) the name of the user with ID == $userid,
// with a link to a view of their profile
// 2) the first MAX_DESC_LENGTH characters from the response1 field
// of said user's profile.
function get_profile_summary($profile) {
$user = get_user_from_id($profile->userid);
if (!$user || !$profile) {
echo "Database error!"; // Change this to a standard error page.
exit();
}
$description = "";
if (strlen($profile->response1) != 0) {
$temp = $profile->response1;
$description = "(\"" . sub_sentence(strip_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
}
$summary = "userid."\">".$user->name." ".$description;
return $summary;
}
// Displays a user's profile (if they have one);
// $screen_mode is set if we're in the administrative profile-screening page,
// in which case we show everything
function show_profile($userid, $screen_mode = false) {
$user = get_user_from_id($userid);
if (!$user) {
error_page("No such user");
}
BoincForumPrefs::lookup($user);
if (is_banished($user)) {
error_page("User is banished");
}
$profile = get_profile($userid);
if (!$profile) {
error_page("No user profile exists for that user ID.");
}
if (!$screen_mode) {
$logged_in_user = get_logged_in_user(false);
if (!$logged_in_user || ($user->id != $logged_in_user->id)) {
$caching = true;
$cache_args = "userid=$userid";
start_cache(USER_PROFILE_TTL,$cache_args);
}
}
$can_edit = isset($logged_in_user) && $logged_in_user && $user->id == $logged_in_user->id;
if (!$screen_mode) {
page_head("Profile: ".$user->name);
}
start_table();
if ($can_edit) {
row1("Edit your profile");
}
// If screening is enabled, only show picture in certain situations
//
$show_picture = $profile->has_picture;
if (profile_screening()) {
if (!$screen_mode && !$can_edit && $profile->verification!=1) {
$show_picture = false;
}
}
if ($show_picture) {
echo "