2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
|
|
|
|
2007-10-29 04:02:41 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/sanitize_html.inc");
|
2004-07-22 23:42:50 +00:00
|
|
|
require_once("../inc/cache.inc");
|
2005-04-08 00:06:52 +00:00
|
|
|
require_once("../inc/user.inc");
|
2005-10-01 01:39:32 +00:00
|
|
|
require_once("../inc/translation.inc");
|
2005-10-14 00:05:41 +00:00
|
|
|
require_once("../inc/text_transform.inc");
|
2007-12-18 20:28:08 +00:00
|
|
|
require_once("../inc/forum.inc");
|
2007-10-25 10:43:16 +00:00
|
|
|
require_once("../inc/recaptchalib.php");
|
2004-02-02 23:34:39 +00:00
|
|
|
|
|
|
|
define('SMALL_IMG_WIDTH', 64);
|
|
|
|
define('SMALL_IMG_HEIGHT', 64);
|
|
|
|
|
|
|
|
define('MAX_IMG_WIDTH', 800);
|
|
|
|
define('MAX_IMG_HEIGHT', 600);
|
|
|
|
|
|
|
|
define('MAX_DESC_LENGTH', 90);
|
|
|
|
|
|
|
|
define('GALLERY_WIDTH', 7);
|
|
|
|
define('GALLERY_HEIGHT', 4);
|
|
|
|
|
2005-09-26 20:01:01 +00:00
|
|
|
function profile_screening() {
|
|
|
|
$config = get_config();
|
|
|
|
return parse_bool($config, "profile_screening");
|
|
|
|
}
|
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
function get_profile($userid) {
|
2007-10-29 04:02:41 +00:00
|
|
|
return BoincProfile::lookup("userid = $userid");
|
2004-05-30 21:47:11 +00:00
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
// TODO: use the following functions instead of hardwired crap everywhere
|
2004-05-30 21:47:11 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function profile_image_path($userid) {
|
|
|
|
return IMAGE_PATH.$userid.'.jpg';
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function profile_thumb_path($userid) {
|
|
|
|
return IMAGE_PATH.$userid.'_sm.jpg';
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function profile_image_url($userid) {
|
|
|
|
return URL_BASE.IMAGE_URL.$userid.'.jpg';
|
|
|
|
}
|
2007-10-25 10:43:16 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function profile_thumb_url($userid) {
|
|
|
|
return URL_BASE.IMAGE_URL.$userid.'_sm.jpg';
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function profile_user_thumb_url($user) {
|
|
|
|
if (!$user->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);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-11 07:31:42 +00:00
|
|
|
// 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 "
|
2007-10-26 22:07:39 +00:00
|
|
|
<font size='+2' color='#33cc33'>
|
2005-09-11 07:31:42 +00:00
|
|
|
Your profile will be made visible to other people<br>
|
|
|
|
as soon as it has been approved by the project.<br>
|
|
|
|
This may take up to a few days.<br>
|
2005-09-26 20:01:01 +00:00
|
|
|
</font>
|
|
|
|
";
|
2005-09-11 07:31:42 +00:00
|
|
|
} else if ($verify_flag == -1) {
|
|
|
|
return "
|
2007-10-26 22:07:39 +00:00
|
|
|
<font size='+2' color='#ff3333'>
|
2005-09-11 07:31:42 +00:00
|
|
|
Your profile has been marked as unacceptable.<br>
|
|
|
|
It is not visible to other people. Please change it.<br>
|
2005-09-26 20:01:01 +00:00
|
|
|
</font>
|
|
|
|
";
|
2005-09-11 07:31:42 +00:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
// If the user with id = $userid has uploaded a picture his/herself,
|
|
|
|
// delete it and its thumbnail.
|
|
|
|
//
|
|
|
|
function delete_user_pictures($userid) {
|
2007-12-18 20:28:08 +00:00
|
|
|
$path = profile_image_path($userid);
|
|
|
|
if (file_exists($path)) {
|
|
|
|
unlink($path);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2007-12-18 20:28:08 +00:00
|
|
|
$path = profile_thumb_path($userid);
|
|
|
|
if (file_exists($path)) {
|
|
|
|
unlink($path);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-26 20:01:01 +00:00
|
|
|
function scale_image(
|
|
|
|
$image, $origWidth, $origHeight, $targetWidth, $targetHeight
|
|
|
|
) {
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2005-09-26 20:01:01 +00:00
|
|
|
// If the image is already smaller than the target dimensions,
|
|
|
|
// just return it.
|
|
|
|
//
|
2004-02-02 23:34:39 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-09-26 20:01:01 +00:00
|
|
|
$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
|
|
|
|
);
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
|
|
|
|
return $newImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generates a string containing:
|
2005-09-26 20:01:01 +00:00
|
|
|
// 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.
|
2004-02-02 23:34:39 +00:00
|
|
|
|
|
|
|
function get_profile_summary($profile) {
|
2004-05-30 21:47:11 +00:00
|
|
|
$user = get_user_from_id($profile->userid);
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
if (!$user || !$profile) {
|
2004-02-02 23:34:39 +00:00
|
|
|
echo "Database error!"; // Change this to a standard error page.
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$description = "";
|
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
if (strlen($profile->response1) != 0) {
|
|
|
|
$temp = $profile->response1;
|
2004-02-02 23:34:39 +00:00
|
|
|
$description = "(\"" . sub_sentence(strip_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-11-18 22:42:47 +00:00
|
|
|
$summary = "<a href=\"".URL_BASE."view_profile.php?userid=".$profile->userid."\">".$user->name."</a> ".$description;
|
2004-02-02 23:34:39 +00:00
|
|
|
return $summary;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Displays a user's profile (if they have one);
|
2007-12-18 20:28:08 +00:00
|
|
|
// $screen_mode is set if we're in the administrative profile-screening page,
|
|
|
|
// in which case we show everything
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function show_profile($userid, $screen_mode = false) {
|
2004-02-02 23:34:39 +00:00
|
|
|
$user = get_user_from_id($userid);
|
|
|
|
|
|
|
|
if (!$user) {
|
2007-12-02 21:11:17 +00:00
|
|
|
error_page("No such user");
|
|
|
|
}
|
|
|
|
BoincForumPrefs::lookup($user);
|
|
|
|
if (is_banished($user)) {
|
|
|
|
error_page("User is banished");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2004-05-30 21:47:11 +00:00
|
|
|
$profile = get_profile($userid);
|
|
|
|
if (!$profile) {
|
2007-12-02 21:11:17 +00:00
|
|
|
error_page("No user profile exists for that user ID.");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$screen_mode) {
|
2005-01-24 13:17:49 +00:00
|
|
|
$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);
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2005-10-01 18:40:39 +00:00
|
|
|
$can_edit = isset($logged_in_user) && $logged_in_user && $user->id == $logged_in_user->id;
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$screen_mode) {
|
2005-01-24 13:17:49 +00:00
|
|
|
page_head("Profile: ".$user->name);
|
|
|
|
}
|
2005-01-18 19:56:18 +00:00
|
|
|
|
|
|
|
start_table();
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2005-01-18 19:56:18 +00:00
|
|
|
if ($can_edit) {
|
|
|
|
row1("<a href=create_profile.php>Edit your profile</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2005-01-18 19:56:18 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
// If screening is enabled, only show picture in certain situations
|
2005-09-11 07:31:42 +00:00
|
|
|
//
|
2005-09-26 20:01:01 +00:00
|
|
|
$show_picture = $profile->has_picture;
|
|
|
|
if (profile_screening()) {
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$screen_mode && !$can_edit && $profile->verification!=1) {
|
2005-09-26 20:01:01 +00:00
|
|
|
$show_picture = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($show_picture) {
|
2005-01-18 19:56:18 +00:00
|
|
|
echo "
|
2007-07-05 19:37:33 +00:00
|
|
|
<tr><td colspan=\"2\" align=\"center\">
|
2007-12-18 20:28:08 +00:00
|
|
|
<img vspace=\"6\" hspace=\"9\" src=\"".profile_image_url($user->id)."\">
|
2005-01-18 19:56:18 +00:00
|
|
|
</td></tr>
|
|
|
|
";
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-26 20:01:01 +00:00
|
|
|
// If the user is viewing their own picture, display its status if it's not
|
2005-09-11 07:31:42 +00:00
|
|
|
// yet verified. This will tell them if other users can't view it yet, or
|
|
|
|
// if there is a problem with it and they need to replace it.
|
|
|
|
//
|
2005-10-01 16:00:31 +00:00
|
|
|
if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification!=1) {
|
2005-09-26 20:01:01 +00:00
|
|
|
row1(offensive_profile_warning($profile->verification));
|
|
|
|
}
|
2005-09-11 07:31:42 +00:00
|
|
|
|
2005-04-08 00:06:52 +00:00
|
|
|
show_user_summary_public($user);
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2007-09-12 12:13:33 +00:00
|
|
|
// Setup text output options based on logged in user forum settings
|
|
|
|
//
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$screen_mode) {
|
2006-08-14 22:11:53 +00:00
|
|
|
$logged_in_user = get_logged_in_user(false);
|
2007-12-18 20:28:08 +00:00
|
|
|
$logged_in_user = BoincForumPrefs::lookup($logged_in_user);
|
2006-08-14 22:11:53 +00:00
|
|
|
$options = get_transform_settings_from_user($logged_in_user);
|
|
|
|
}
|
|
|
|
|
2005-01-18 19:56:18 +00:00
|
|
|
row1(show_profile_heading1());
|
2005-08-30 09:41:47 +00:00
|
|
|
row1(output_transform($profile->response1,$options), 2, "foobar");
|
2005-01-18 19:56:18 +00:00
|
|
|
row1(show_profile_heading2());
|
2005-08-30 09:41:47 +00:00
|
|
|
row1(output_transform($profile->response2,$options), 2, "foobar");
|
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$can_edit and !$screen_mode) {
|
2005-01-18 19:56:18 +00:00
|
|
|
row1("Your feedback on this profile");
|
|
|
|
row2(
|
|
|
|
"Recommend this profile for User of the Day:",
|
|
|
|
"I <a href=profile_rate.php?userid=$userid&vote=recommend>like</a> this profile"
|
|
|
|
);
|
|
|
|
row2(
|
|
|
|
"Alert administrators to an offensive profile:",
|
|
|
|
"I <a href=profile_rate.php?userid=$userid&vote=reject>don't like</a> this profile"
|
|
|
|
);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
end_table();
|
2007-12-18 20:28:08 +00:00
|
|
|
if (!$screen_mode) {
|
2005-01-24 13:17:49 +00:00
|
|
|
page_tail();
|
|
|
|
} else {
|
|
|
|
echo "<hr>";
|
|
|
|
}
|
2005-10-01 18:30:15 +00:00
|
|
|
if (isset($caching) && $caching) end_cache(USER_PROFILE_TTL,$cache_args);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2007-11-14 16:03:47 +00:00
|
|
|
|
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|