";
exit();
}
echo "\n";
fclose($file);
}
function get_profile($userid) {
$result = mysql_query("SELECT * FROM profile WHERE userid = $userid");
if (!$result) {
return NULL;
}
$profile = mysql_fetch_object($result);
mysql_free_result($result);
return $profile;
}
function show_profile_creation_page($user) {
// If the user already has a profile,
// fill in the fields with their current values.
//
$profile = get_profile($user->id);
if ($_POST['submit']) {
process_create_results($user, $profile);
exit();
}
if ($profile) {
page_head("Edit your profile");
} else {
page_head("Create a profile");
}
echo "
";
page_tail();
}
function show_description() {
echo "
Your profile lets you share your opinions and background
with the ".PROJECT." community.
To replace it,
click the \"Browse\" button and select a JPEG or PNG file (50KB or less).
To remove it from your profile,
check this box:
";
rowify(" ");
end_table();
echo "";
}
else {
rowify("
If you would like include a picture with your profile,
click the \"Browse\" button and select a JPEG or PNG file.
Please select images of 50KB or less.
View result";
*/
return array($image, $smallImage);
}
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;
}
function show_result_page($user) {
page_head("Profile Saved");
echo "
Congratulations!
Your profile was successfully entered into our database.
id>View your profile
";
page_tail();
}
// Builds a summary table of user profiles.
//
// $members is an array of userIDs;
// $offset indicates which entry to begin the table with
// $numToDisplay indicates how many profiles to display in this table
// $cols indicates how many profile summaries should be written per row
// $descriptor is an optional file descriptor to write the table to.
function show_user_table($members, $offset, $numToDisplay, $cols) {
echo "
\n";
for ($col = 0; $col < $cols; $col++) {
if ($count < $numMembers) {
$profile = get_profile($members[$count]);
if (!$profile) {
$numMembers--;
continue;
}
echo "
";
// Only link an image if the user has uploaded one.;
if ($profile->has_picture) {
echo "";
} else {
echo " ";
}
echo "
\n", get_profile_summary($profile), "
";
$count++;
} else {
echo "
";
}
}
echo "
\n";
}
echo "
\n";
}
// 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);
function show_profile($userid, $verify_mode = FALSE) {
$user = get_user_from_id($userid);
if (!$user) {
profile_error_page("No user exists for that ID, or there was a database error.
");
exit();
}
$profile = get_profile($userid);
if (!$profile) {
profile_error_page("No user profile exists for that user ID.");
}
if (!$verify_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 = $logged_in_user && $user->id == $logged_in_user->id;
if (!$verify_mode) {
page_head("Profile: ".$user->name);
}
start_table();
if ($can_edit) {
row1("Edit your profile");
}
if ($profile->has_picture) {
echo "
id , '.jpg' . "\">
";
}
show_user_summary_public($user);
//Setup text output options based on logged in user forum settings
$logged_in_user = get_logged_in_user(false);
$logged_in_user = getForumPreferences($logged_in_user);
$options = get_transform_settings_from_user($logged_in_user);
row1(show_profile_heading1());
row1(output_transform($profile->response1,$options), 2, "foobar");
row1(show_profile_heading2());
row1(output_transform($profile->response2,$options), 2, "foobar");
if (!$can_edit and !$verify_mode) {
row1("Your feedback on this profile");
row2(
"Recommend this profile for User of the Day:",
"I like this profile"
);
row2(
"Alert administrators to an offensive profile:",
"I don't like this profile"
);
}
end_table();
if (!$verify_mode) {
page_tail();
} else {
echo "";
}
if ($caching) end_cache(USER_PROFILE_TTL,$cache_args);
}
?>