From aad5f449d7eaec1fc635a334ba08f6a891607d0b Mon Sep 17 00:00:00 2001 From: Dan Werthimer Date: Fri, 11 Jul 2003 22:33:59 +0000 Subject: [PATCH] Files involved in profile functionality svn path=/trunk/boinc/; revision=1672 --- html/user/create_profile.php | 21 ++ html/user/delete_profile.php | 53 +++++ html/user/gallery.inc | 286 ++++++++++++++++++++++++ html/user/generate_country_pages.php | 14 ++ html/user/generate_picture_pages.php | 15 ++ html/user/languages.txt | 188 ++++++++++++++++ html/user/profile.inc | 323 +++++++++++++++++++++++++++ html/user/profile_menu.php | 81 +++++++ html/user/view_profile.php | 152 +++++++++++++ 9 files changed, 1133 insertions(+) create mode 100644 html/user/create_profile.php create mode 100644 html/user/delete_profile.php create mode 100755 html/user/gallery.inc create mode 100755 html/user/generate_country_pages.php create mode 100755 html/user/generate_picture_pages.php create mode 100644 html/user/languages.txt create mode 100644 html/user/profile.inc create mode 100644 html/user/profile_menu.php create mode 100644 html/user/view_profile.php diff --git a/html/user/create_profile.php b/html/user/create_profile.php new file mode 100644 index 0000000000..5f244a0c04 --- /dev/null +++ b/html/user/create_profile.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/html/user/delete_profile.php b/html/user/delete_profile.php new file mode 100644 index 0000000000..8eef0bd57f --- /dev/null +++ b/html/user/delete_profile.php @@ -0,0 +1,53 @@ +"; + +start_table_noborder(); +row1("Delete your profile"); + + +rowify(" +

Are you sure?

+Remember that deleted profiles are gone forever and cannot be recovered--you will have to start from scratch if you want another profile in the future. +"); +rowify("
If you're sure, click the \"Delete\" button below to remove your profile from our database."); +echo "
"; +end_table(); +echo ""; + +page_tail(); + + +function delete_profile($user) { + + $result = mysql_query("DELETE FROM profile WHERE userid = $user->id"); + if ($result) { + + delete_user_pictures($user->id); + page_head("Delete Confirmation"); + echo "Your profile has been deleted
"; + } else { + + // TODO: Change this to a standard dialog. + page_head("Deletion Error"); + echo "There was a problem deleting your profile."; + } + page_tail(); +} + +?> \ No newline at end of file diff --git a/html/user/gallery.inc b/html/user/gallery.inc new file mode 100755 index 0000000000..6ca74005a0 --- /dev/null +++ b/html/user/gallery.inc @@ -0,0 +1,286 @@ +"; + + // Build an array of IDs of all users with pictures in their profiles. + while ($row = mysql_fetch_array($result, MYSQL_NUM)) { // NUM is supposedly faster than ASSOC. + $userIds[] = $row[0]; + } + + mysql_free_result($result); + + // Randomize the ordering of users. + shuffle($userIds); + + $numPages = ceil(count($userIds)/($width * $height)); + + echo "Generating $numPages pages.
"; + + $count = 0; + + for ($page = 1; $page <= $numPages; $page++) { + $file = PROFILE_PATH . "user_gallery_" . $page . ".html"; + $descriptor = fopen($file, "w"); + + page_head("User Picture Gallery: Page $page of $numPages", null, $descriptor); + + fwrite($descriptor, "

User Profile Pictures

Last updated " . gmdate("r") . " UTC\n

Browse the user profiles by picture. Only user profiles with pictures are listed here."); + + fwrite($descriptor, "\n"); + + for ($row = 0; $row < $height; $row++) { + fwrite($descriptor, ""); + for ($col = 0; $col < $width; $col++) { + if ($count < $numIds) { + + fwrite($descriptor, ""); + $count++; + } + } + fwrite($descriptor, "\n"); + if ($count == $numIds) { + break; + } + } + + fwrite($descriptor, "
\n"); + + // Previous and Next links + + write_page_links("user_gallery", $page, $numPages, $descriptor); + + page_tail($descriptor); + + //fwrite($descriptor, ""); + fclose($descriptor); + + } + echo "

Go to the first generated page."; +} + +function build_country_pages() { + + $query = "SELECT * FROM profile"; + $result = mysql_query($query); + $numIds = 0; + + // Build a multi-dimensional array of countries, each element of which contains an array + // of the userids who belong to those countries. Format: array[country][index] = userid. + + while ($row = mysql_fetch_assoc($result)) { + $query2 = "SELECT * FROM user WHERE id = " . $row['userid']; + $result2 = mysql_query($query2); + $row2 = mysql_fetch_assoc($result2); + + if ($row2['country']) { + $countryMembers[$row2['country']][] = $row2['id']; + $numIds++; + } + } + + mysql_free_result($result); + mysql_free_result($result2); + + echo "$numIds users have profiles AND non-null country entries.
"; + + $countries = array_keys($countryMembers); + + // Build the pages. + foreach ($countries as $country) { + build_country_page($country, &$countryMembers[$country], 5); + } + + // Build the summary page linking to the individual country pages. + // TODO: Pass $countryMembers by reference. + build_country_summary_page($countryMembers); + echo "
View Summary Page"; + + echo "

Done"; + +} + +function build_country_page($name, $members, $rows) { + + $countryName = $name; + + // Make the country name a legal format for a filename. + $name = get_legal_filename($countryName); + + $name = ereg_replace(',', '', $name); + $name = ereg_replace(' ', '_', $name); + + $numMembers = count($members); + $numPages = ceil(count($members) / (2 * $rows)); + echo "
$countryName has $numMembers members. - $numPages pages will be generated. VIEW"; + + $count = 0; + + for ($page = 1; $page <= $numPages; $page++) { + + $filename = PROFILE_PATH . "profile_country_" . $name . "_" . $page . ".html"; + $descriptor = fopen($filename, "w"); + + // TODO: Page header. + //fwrite($descriptor, "\n"); + page_head("User Profiles from $countryName: Page $page of $numPages", null, $descriptor); + + fwrite($descriptor, "

$countryName

\n"); + fwrite($descriptor, "Last updated " . gmdate("r") . " UTC

\n"); + fwrite($descriptor, "\n"); + + for ($row = 0; $row < $rows; $row++) { + if ($count >= $numMembers) { + break; + } + + fwrite($descriptor, "\n"); + + // Formatting is a table with two columns of user summaries. + for ($col = 0; $col < 2; $col++) { + if ($count < $numMembers) { + fwrite($descriptor, ""); + $count++; + } + else { + // Empty entry. + fwrite($descriptor, ""); + } + } + fwrite($descriptor, "\n"); + } + fwrite($descriptor, "
"); + + // Only link an image if one exists. + if (file_exists(IMAGE_PATH . $members[$count] . '_sm.jpg')) { + fwrite($descriptor, ""); + } else { + fwrite($descriptor, " "); + } + + fwrite($descriptor, "
"); + fwrite($descriptor, get_profile_summary($members[$count])); + fwrite($descriptor, "
\n"); + + $tempFileName = "profile_country_" . $name; + write_page_links($tempFileName, $page, $numPages, $descriptor); + + page_tail($descriptor); + fclose($descriptor); + } + +} + +function get_legal_filename($name) { + $name = ereg_replace(',', '', $name); + return ereg_replace(' ', '_', $name); +} + +function get_profile_summary($userid) { + $result = mysql_query("SELECT * FROM profile WHERE userid = $userid"); + $result2 = mysql_query("SELECT name FROM user WHERE id = $userid"); + + if (!$result || !$result2) { + echo "Database error!"; // Change this to a standard error page. + exit(); + } + + $row = mysql_fetch_assoc($result); + $row2 = mysql_fetch_assoc($result2); + + mysql_free_result($result); + mysql_free_result($result2); + + if (strlen($row['response1']) != 0) { + + $description = "(\"" . substr($row['response1'], 0, MAX_DESC_LENGTH); + if (strlen($row['response1']) >= MAX_DESC_LENGTH) { + $description = $description . "..."; + } + $description = $description . "\")"; + } + + $summary = "" . $row2['name'] . " " . $description; + return $summary; +} + +function write_page_links($filename, $currPageNum, $numPages, $descriptor) { + fwrite($descriptor, "

Page $currPageNum of $numPages

"); + + $nextPageNum = $currPageNum + 1; + $prevPageNum = $currPageNum - 1; + + // Make the 'previous' and 'next' page links as appropriate. + if ($currPageNum > 1) { + fwrite($descriptor, "Previous Page"); + + if ($currPageNum != $numPages) { + fwrite($descriptor, " | "); + } + } + if ($currPageNum != $numPages) { + fwrite($descriptor, "Next Page"); + } + + fwrite($descriptor, "

\n\n\n"); + + // Make the individual page links (or a bold non-link for the current page). + for ($i = 1; $i <= $numPages; $i++) { + if ($i != $currPageNum) { + fwrite($descriptor, "\n"); + } else { + fwrite($descriptor, "\n"); + } + } + + fwrite($descriptor, "
Jump to Page:$i$i
\n"); +} + +function build_country_summary_page($countryMembers) { + $countries = array_keys($countryMembers); + + $filename = PROFILE_PATH . "profile_country.html"; + $descriptor = fopen($filename, "w"); + + echo "

Building country summary page...
"; + + page_head("User Profiles by Country", null, $descriptor); + fwrite($descriptor, "

User Profiles by Country

Last updated " . gmdate("r") . " UTC

"); + + fwrite($descriptor, "\n"); + fwrite($descriptor, "\n"); + + foreach ($countries as $country) { + $numMembers = count($countryMembers[$country]); + $name = get_legal_filename($country); + + fwrite($descriptor, "\n\n"); + + } + + fwrite($descriptor, "
CountryProfiles
$country$numMembers
"); + page_tail($descriptor); + + fclose($descriptor); +} +?> \ No newline at end of file diff --git a/html/user/generate_country_pages.php b/html/user/generate_country_pages.php new file mode 100755 index 0000000000..f12d46f023 --- /dev/null +++ b/html/user/generate_country_pages.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/html/user/generate_picture_pages.php b/html/user/generate_picture_pages.php new file mode 100755 index 0000000000..518ab93283 --- /dev/null +++ b/html/user/generate_picture_pages.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/html/user/languages.txt b/html/user/languages.txt new file mode 100644 index 0000000000..75a47507d9 --- /dev/null +++ b/html/user/languages.txt @@ -0,0 +1,188 @@ +Abkhazian +Afar +Afrikaans +Albanian +Amharic +Arabic +Armenian +Assamese +Aymara +Azebaijani +Bahasa Indonesia +Bangla +Bashkir +Basque +Bengali +Bhutanese +Bhutani +Bihari +Bislama +Breton +Bulgarian +Burmese +Byelorussian +Cambodian +Catalan +Chinese +chiShona +Choson-o +Corsican +Croat +Croatian +Czech +Danish +Dutch +English +Esperanto +Estonian +Faeroese +Faroese +Fiji +Fijian +Finnish +French +Frisian +Scots +Gaelic +Galician +Galla +Georgian +German +Greek +Greenlandic +Guaraní +Gujarati +Gujerati +Hausa +Hebrew +Hindi +Hungarian +Icelandic +Indonesian +Interlingua +Interlingue +Inupiak +Inuktitut +Irish +isiXhosa +isiZulu +Italian +Japanese +Javanese +Kannada +Kashmiri +Kazakh +kinyaRuanda +Kinyarwanda +Kirghiz +Kirundi +kiRundi +kiSwahili +Korean +Kurdish +Lao +Laothian +Latin +Latvian +Lettish +Lingala +liNgala +Lithuanian +Macedonian +Malagasy +Malay +Malayalam +Magyar +Mahrati +Maltese +Maori +Marathi +Moldavian +Mongolian +Nauru +Nepalese +Nepali +Nihongo +Norwegian +Occitan +Oriya +(Afan)Oromo +Pashto +Persian +Pha Xa Lao +Polish +Portuguese +Punjabi +Pushto +Pushtu +Quechua +Rhaeto-Romance +Rhaeto-Romanic +Romanian +Romansch +Rumanian +Russian +Samoan +Sangho +Sango-Ngbandi +Sanskrit +Scots Gaelic +Serbian +Serbo-Croatian +Sesotho +Setswana +Shona +Sindhi inghalese +Sinhalese +siSuthu +Siswati +siSwati +Slovak +Slovene +Slovenian +Somali +Spanish +Sundanese +Suomi +Swahili +Swedish +Tagalog +Tajik +Tajiki +Tamil +Tartar +Tatar +Telegu +Telugu +Thai +Tibetan +Tigrinya +Tonga +Tshi +Tsonga +Turcoman +Turkish +Turkmen +Turkoman +Twi +Uigur +Uighur +Ukrainian +Urdu +Usbeg +Usbek +Uyghur +Uzbeg +Uzbek +Vietnamese +Volapük +Welsh +Wolof +Xhosa +Xosa +Yiddish +Yoruba +Zhuang +Zimany Kurdy +Zulu +Other diff --git a/html/user/profile.inc b/html/user/profile.inc new file mode 100644 index 0000000000..9a32337ae2 --- /dev/null +++ b/html/user/profile.inc @@ -0,0 +1,323 @@ +id"); + if ($result) { + $profile_info = mysql_fetch_array($result, MYSQL_ASSOC); + } + + setup_form(); + $profile_info?page_head("Edit your Profile"):page_head("Create a Profile"); + start_table_noborder(); + show_description(); + show_questions(); + show_picture_option(); + show_finale(); + end_table(); + close_form(); + page_tail(); +} + +function setup_form() { + if ($_POST['submit']) { + process_results(); + exit(); + } + + echo " +

+"; +} + +function close_form() { + echo "
"; +} + +function show_description() { + global $profile_info; + global $user; + + $profile_info?row1("Edit User Profile: " . $user->name):row1("Create a User Profile"); + rowify(" +By creating a user profile you can share your opinions and background +with the entire ".PROJECT." community. +"); + rowify("
"); +} + +function show_questions() { + show_profile_heading1(); + show_profile_question1(); + rowify("
"); + show_textarea('response1'); + rowify("
"); + show_profile_heading2(); + show_profile_question2(); + rowify("
"); + show_textarea('response2'); + rowify("
"); + show_language_selection(); + rowify("
"); +} + +function show_textarea($name) { + global $profile_info; + + rowify(""); +} + +function show_picture_option() { + global $profile_info; + + row1("Your Picture"); + + if ($profile_info['has_picture']) { + echo " + + + + +"; + end_table(); + echo ""; + } + else { + rowify(" +Do you have a picture of yourself on your computer? +If you would like us to include it with your profile, +please click the \"Browse\" button and select the JPEG or PNG file +you want to send. (No animated GIFs, please!)
+
+NOTE: Please keep your image small (less than 50K bytes)
+ +"); + } + + +} + +function show_language_selection() { + global $profile_info; + + row1("Select Your Primary Language"); + rowify("Selecting a language will help others with the same language preference to find each others' profiles and message board postings."); + echo "\n"; +} + +function show_finale() { + row1("Submit Your Profile"); + rowify(" +
        "); +} + +function process_results() { + global $user; + global $profile_info; + + $response1 = $_POST['response1']; + $response2 = $_POST['response2']; + $language = $_POST['language']; + $delete_pic = $_POST['delete_pic']; + + if (strlen($response1)==0 && + strlen($response2)==0 && + $delete_pic != "on" && + !is_uploaded_file($_FILES['picture']['tmp_name'])) { + profile_error_page("Your profile submission was empty."); + exit(); + } + + // TODO: Having the delete checkbox and pic file form might confuse users. + // Should figure out a better way to handle this. Also might want to + // present some sort of verification dialog (javascript). + + if ($delete_pic == "on") { + + delete_user_pictures($profile_info['userid']); + + $profile_info['has_picture'] = false; + } + + $profile_info ? $hasPicture = $profile_info['has_picture']: $hasPicture = false; + + if (is_uploaded_file($_FILES['picture']['tmp_name'])) { + $hasPicture = true; + + /* + echo "
Name: " . $_FILES['picture']['name']; + echo "
Type: " . $_FILES['picture']['type']; + echo "
Size: " . $_FILES['picture']['size']; + echo "
Temp name: " . $_FILES['picture']['tmp_name']; + */ + + $images = getImages($_FILES['picture']['tmp_name']); + + // Write the original image file to disk. + // TODO: define a constant for image quality. + ImageJPEG($images[0], IMAGE_PATH . $user->id . '.jpg', 10); + ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg', 10); + } + if ($profile_info) { + + $query = 'UPDATE profile SET ' + ." response1 = '$response1'," + ." response2 = '$response2'," + ." language = '$language'," + ." has_picture = '$hasPicture'" + ." WHERE userid = '$user->id'"; + } else { + + $query = 'INSERT INTO profile SET ' + ." userid = '$user->id'," + ." language = '$language'," + ." response1 = '$response1'," + ." response2 = '$response2'," + ." has_picture = '$hasPicture'"; + } + + $result = mysql_query($query); + + if (!$result) { + profile_error_page("Couldn't create profile: database error!"); + exit(); + } + + show_result_page(); +} + +// Returns an array containing: +// [0]: The original image refered to by $fileName if its dimensions are +// less than MAX_IMG_WIDTH x MAX_IMG_HEIGHT, or a version scaled to +// those dimensions if it was too large. +// [1]: A scaled version of the above. + +function getImages($fileName) { + $size = getImageSize($fileName); + + // Determine if the filetype uploaded is supported. + // TODO: Change these to constants. + switch($size[2]) { + case '2': // JPEG + $image = imageCreateFromJPEG($fileName); + break; + case '3': // PNG + $image = imageCreateFromPNG($fileName); + break; + default: + profile_error_page("The format of your uploaded image is not supported by our system."); + exit(); + } + + $width = $size[0]; + $height = $size[1]; + + $smallImage = scale_image($image, $width, $height, SMALL_IMG_WIDTH, SMALL_IMG_HEIGHT); + + if ($width > MAX_IMG_WIDTH || $height > MAX_IMG_HEIGHT) { + $image = scale_image($image, $width, $height, MAX_IMG_WIDTH, MAX_IMG_HEIGHT); + } + + + /*($width > $height)? $scalar = ($width / SMALL_IMG_WIDTH) : $scalar = ($height / SMALL_IMG_HEIGHT); + + $dest_width = $width / $scalar; + $dest_height = $height / $scalar; + $horiz_offset = (SMALL_IMG_WIDTH - $dest_width) / 2; + $vert_offset = (SMALL_IMG_HEIGHT - $dest_height) / 2; + + // TODO: Switch once GD 2.0+ is installed. + //$smallImage = ImageCreateTrueColor(SMALL_IMG_WIDTH, SMALL_IMG_HEIGHT); + $smallImage = ImageCreate(SMALL_IMG_WIDTH, SMALL_IMG_HEIGHT); + + // TODO: Switch once GD 2.0+ is installed. + //ImageCopyResampled($smallImage, $image, $horiz_offset, $vert_offset, 0, 0, $dest_width, $dest_height, $width, $height); + ImageCopyResized($smallImage, $image, $horiz_offset, $vert_offset, 0, 0, $dest_width, $dest_height, $width, $height); + */ + /* + echo "

Image type: $size[2]"; + echo "
Original width: $width"; + echo "
Original height: $height"; + echo "
Scalar: $scalar"; + echo "
Dest width: " . ($width / $scalar); + echo "
Dest height: " . ($height / $scalar); + echo "
Horizontal offset: $horiz_offset"; + echo "
Vertical offset: $vert_offset"; + echo "

View result"; + */ + + return array($image, $smallImage); +} + +function scale_image($image, $origWidth, $origHeight, $targetWidth, $targetHeight) { + + ($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($height / $targetHeight); + + $dest_width = $origWidth / $scalar; + $dest_height = $origHeight / $scalar; + $horiz_offset = ($targetWidth - $dest_width) / 2; + $vert_offset = ($targetHeight - $dest_height) / 2; + + // TODO: Switch once GD 2.0+ is installed. + //$newImage = ImageCreateTrueColor($targetWidth, $targetHeight); + $newImage = ImageCreate($targetWidth, $targetHeight); + + // TODO: Switch once GD 2.0+ is installed. + //ImageCopyResampled($newImage, $image, $horiz_offset, $vert_offset, 0, 0, $dest_width, $dest_height, $origWidth, $origHeight); + ImageCopyResized($newImage, $image, $horiz_offset, $vert_offset, 0, 0, $dest_width, $dest_height, $origWidth, $origHeight); + + return $newImage; +} + +function show_result_page() { + global $user; + + page_head("Profile Saved"); + + echo " +

Congratulations!

+Your profile was successfully entered into our database.

+id>View your profile
+"; + + page_tail(); +} + +?> \ No newline at end of file diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php new file mode 100644 index 0000000000..f798da4655 --- /dev/null +++ b/html/user/profile_menu.php @@ -0,0 +1,81 @@ + +

  • View the User Picture Gallery. [Generate] +
  • Browse profiles by country. [Generate] +
  • Browse profiles at random, +at random with pictures, or +at random without pictures. + +
  • Alphabetical profile listings:
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    +"); +row1("Search"); +end_table(); + +echo " +
    + + + +"; + +end_table(); +page_tail(); + +function execute_command() { + + // Request for a random profile. + if ($_GET['cmd'] == "rand") { + if ($_GET['pic']) { + if ($_GET['pic'] == 0) { + $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 0"); + } else if ($_GET['pic'] == 1) { + $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 1"); + } + } else { + $result = mysql_query("SELECT userid FROM profile"); + } + + while ($row = mysql_fetch_row($result)) { + $userIds[] = $row[0]; + } + + shuffle($userIds); + + header("Location: " . MASTER_URL . "view_profile.php?userid=" . $userIds[0]); + exit(); + } + + else if ($_GET['cmd'] == "search") { + + if ($_GET['name']) { + $result = mysql_query("SELECT id FROM user WHERE name = " . $_GET['name']); + if ($result) { + while ($row = mysql_fetch_row($result)) { + echo "
    ID ", $row['0'], " has a name that matches your query."; + } + } else { + echo "No names matched your query.
    "; + } + } + } +} + +?> \ No newline at end of file diff --git a/html/user/view_profile.php b/html/user/view_profile.php new file mode 100644 index 0000000000..b7a6838ad4 --- /dev/null +++ b/html/user/view_profile.php @@ -0,0 +1,152 @@ +"); + exit(); +} + +$user = get_user_from_id($userid); + +if (!$user) { + profile_error_page("No user exists for that ID, or there was a database error.

    "); + exit(); +} + +// Check for recommendation or rejection votes. +if ($_POST['recommend']) { + process_results("recommend"); + exit(); +} else if ($_POST['reject']) { + process_results("reject"); + exit(); +} + +$result = mysql_query("SELECT * FROM profile WHERE userid = $user->id"); +if ($result) { + $profile_info = mysql_fetch_array($result, MYSQL_ASSOC); +} +else { + profile_error_page("No profile exists for that user, or there was a database error.

    "); + exit(); +} + +$logged_in_user = get_logged_in_user(false); // (false) since anyone can look at profiles. +$can_edit = $logged_in_user && $user->id == $logged_in_user->id; + + +page_head("User Profile: ".$user->name); + +if ($can_edit) { + echo "[Edit Your Profile]"; +} + +start_table_noborder(); +echo "

  • "; +show_profile_heading1(); +echo ""; +show_profile_heading2(); +echo ""; +end_table(); +page_tail(); + + +function show_profile_summary() { + global $user; + global $profile_info; + global $can_edit; + + echo " +

    +Delete +

    You have previously uploaded a picture of yourself to accompany your profile, shown at left. +If you would like to replace it, please click the \"Browse\" button and select the JPEG or PNG file +you would like to use instead. (No animated GIFs, please!) If you would rather not have a picture +with your profile, click the \"Delete\" checkbox. If you like your current picture, there is no need +to do anything.

    +
    +NOTE: Please keep your image small (less than 50K bytes)

    "; + if ($profile_info) { + show_combo_box("language", LANGUAGE_FILE, $profile_info['language']); + } else { + show_combo_box("language", LANGUAGE_FILE, "English"); + } + echo "
    "; +show_profile_summary(); +echo "
    ", $profile_info['response1'], "

    ", $profile_info['response2'], "
    \n +\n +

    $user->name

    "; + + if (!$can_edit) { + show_buttons(); + } + +echo "
    \n"; + + // Only display an image if the user has uploaded one. + if (file_exists(IMAGE_PATH . $user->id . '_sm.jpg')) { + echo " +id , '.jpg' . "\">id , '_sm.jpg' . "\">\n"; + } + + echo " + +Country: ", $user->country, "  Language: ", $profile_info['language'], "
    +Email: email_addr, "\">", $user->email_addr, "
    +Total Credit: ", $user->total_credit, "
    "; + + if ($user->teamid) { + $result = mysql_query("select * from team where id = $user->teamid"); + $team = mysql_fetch_object($result); + echo "Team: id>$team->name
    "; + } + echo " +Date Registered: ", date_str($user->create_time), " +
    +
    +
    \n"; +} + +function show_buttons() { + global $userid; + + echo " +
    + +what is recommend? +
    + +what is vote to reject? +
    +"; +} + +function process_results($vote) { + global $userid; + + if ($vote != "recommend" && $vote != "reject") { + echo "Invalid vote type.
    "; + exit(); + } + + $result = mysql_query("SELECT * FROM profile WHERE userid = $userid"); + $profile = mysql_fetch_array($result); + + $newValue = $profile[$vote] + 1; + $newresult = mysql_query("UPDATE profile SET $vote = $newValue WHERE userid = $userid"); + + page_head("Vote Recorded"); + + start_table_noborder(); + + row1("Thank you"); + + if ($vote == "recommend") { + rowify("Your recommendation has been recorded."); + } else { + rowify("Your vote to reject has been recorded."); + } + end_table(); + echo "
    Return to profile."; + + + page_tail(); + +} +?> \ No newline at end of file