function process_create_profile($user, $profile) { global $config; $response1 = post_str('response1', true); $response2 = post_str('response2', true); $language = post_str('language', true); $privatekey = parse_config($config, "<recaptcha_private_key>"); if ($privatekey) { $recaptcha = new ReCaptcha($privatekey); $resp = $recaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); if (!$resp->success) { $profile->response1 = $response1; $profile->response2 = $response2; show_profile_form($profile, tra("Your ReCaptcha response was not correct. Please try again.")); return; } } if (!akismet_check($user, $response1)) { $profile->response1 = $response1; $profile->response2 = $response2; show_profile_form($profile, tra("Your first response was flagged as spam by the Akismet anti-spam system. Please modify your text and try again.")); return; } if (!akismet_check($user, $response2)) { $profile->response1 = $response1; $profile->response2 = $response2; show_profile_form($profile, tra("Your second response was flagged as spam by the Akismet anti-spam system. Please modify your text and try again.")); return; } if (isset($_POST['delete_pic'])) { $delete_pic = $_POST['delete_pic']; } else { $delete_pic = "off"; } if (strlen($response1) == 0 && strlen($response2) == 0 && $delete_pic != "on" && !is_uploaded_file($_FILES['picture']['tmp_name'])) { error_page(tra("Your profile submission was empty.")); exit; } if ($delete_pic == "on") { delete_user_pictures($profile->userid); $profile->has_picture = false; $profile->verification = 0; } $profile ? $has_picture = $profile->has_picture : ($has_picture = false); if (is_uploaded_file($_FILES['picture']['tmp_name'])) { $has_picture = true; if ($profile) { $profile->verification = 0; } // echo "<br>Name: " . $_FILES['picture']['name']; // echo "<br>Type: " . $_FILES['picture']['type']; // echo "<br>Size: " . $_FILES['picture']['size']; // echo "<br>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'); ImageJPEG($images[1], IMAGE_PATH . $user->id . '_sm.jpg'); } $response1 = sanitize_html($response1); $response2 = sanitize_html($response2); $has_picture = $has_picture ? 1 : 0; if ($profile) { $query = " response1 = '" . BoincDb::escape_string($response1) . "'," . " response2 = '" . BoincDb::escape_string($response2) . "'," . " language = '" . BoincDb::escape_string($language) . "'," . " has_picture = {$has_picture}," . " verification = {$profile->verification}" . " WHERE userid = {$user->id}"; $result = BoincProfile::update_aux($query); if (!$result) { error_page(tra("Could not update the profile: database error")); } } else { $query = 'SET ' . " userid={$user->id}," . " language = '" . BoincDb::escape_string($language) . "'," . " response1 = '" . BoincDb::escape_string($response1) . "'," . " response2 = '" . BoincDb::escape_string($response2) . "'," . " has_picture = {$has_picture}," . " recommend=0, " . " reject=0, " . " posts=0, " . " uotd_time=0, " . " verification=0"; $result = BoincProfile::insert($query); if (!$result) { error_page(tra("Could not create the profile: database error")); } } $user->update("has_profile=1"); page_head(tra("Profile saved")); echo tra("Congratulations! Your profile was successfully entered into our database.") . "<br><br>" . "<a href=\"view_profile.php?userid=" . $user->id . "\">" . tra("View your profile") . "</a><br>"; page_tail(); }