function select_profile($cmd) { // Request for a random profile. // if ($cmd == "rand") { $profiles = array(); $pic = get_int('pic'); if ($pic == 0) { $profiles = BoincProfile::enum("has_picture=0", "limit 1000"); } else { if ($pic == 1) { $profiles = BoincProfile::enum("has_picture=1", "limit 1000"); } else { if ($pic == -1) { $profiles = BoincProfile::enum(null, "limit 1000"); } } } if (count($profiles) == 0) { page_head(tra("No profiles")); echo tra("No profiles matched your query."); page_tail(); exit; } shuffle($profiles); $userid = $profiles[0]->userid; header("Location: " . URL_BASE . "view_profile.php?userid={$userid}"); exit; } }
function delete_profile($user) { $result = BoincProfile::delete_aux("userid = {$user->id}"); if (!$result) { error_page("couldn't delete profile - please try again later"); } delete_user_pictures($user->id); page_head("Delete Confirmation"); $user->update("has_profile=0"); echo "Your profile has been deleted<br />"; page_tail(); }
check_get_args(array("search_string", "offset")); function show_profile_link2($profile, $n) { $user = BoincUser::lookup_id($profile->userid); echo "<tr><td>" . user_links($user) . "</td><td>" . date_str($user->create_time) . "</td><td>{$user->country}</td><td>" . (int) $user->total_credit . "</td><td>" . (int) $user->expavg_credit . "</td></tr>\n"; } $search_string = get_str('search_string'); $search_string = sanitize_tags($search_string); $search_string = BoincDb::escape_string($search_string); $offset = get_int('offset', true); if (!$offset) { $offset = 0; } $count = 10; page_head(tra("Profiles containing '%1'", $search_string)); $profiles = BoincProfile::enum("match(response1, response2) against ('{$search_string}') limit {$offset},{$count}"); start_table(); echo "\n <tr><th>" . tra("User name") . "</th>\n <th>" . tra("Joined project") . "</th>\n <th>" . tra("Country") . "</th>\n <th>" . tra("Total credit") . "</th>\n <th>" . tra("Recent credit") . "</th></tr>\n"; $n = 0; foreach ($profiles as $profile) { show_profile_link2($profile, $n + $offset + 1); $n += 1; } end_table(); if ($offset == 0 && $n == 0) { echo tra("No profiles found containing '%1'", $search_string); } if ($n == $count) { $s = urlencode($search_string); $offset += $count; echo "\n <a href=profile_search_action.php?search_string={$s}&offset={$offset}>" . tra("Next %1", $count) . "</a>\n ";
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see <http://www.gnu.org/licenses/>. require_once "../inc/profile.inc"; check_get_args(array("userid")); $userid = get_int('userid'); $user = BoincUser::lookup_id($userid); if (!$user) { error_page(tra("No such user")); } if (!$user->has_profile) { // check whether user.has_profile is out of synch w/ profile table // $profile = BoincProfile::lookup("userid={$user->id}"); if ($profile) { $user->update("has_profile=1"); $user->has_profile = 1; } else { error_page(tra("This user has no profile")); } } $logged_in_user = get_logged_in_user(false); check_whether_to_show_profile($user, $logged_in_user); $cache_args = "userid={$userid}"; $cacheddata = get_cached_data(USER_PROFILE_TTL, $cache_args); if ($cacheddata) { // Already got a cached version of the information $community_links_object = unserialize($cacheddata); } else {
function build_alpha_pages() { print_debug_msg("Beginning to build alphabetical pages..."); global $alphabet; $profiles = BoincProfile::enum_fields('userid'); $numIds = 0; $members = array(); foreach ($profiles as $profile) { $user = BoincUser::lookup_id($profile->userid); if (!$user) { continue; } // maybe we should delete the profile if user is non-existent anymore? if ($user->name) { $name = ltrim($user->name); $members[strtoupper($name[0])][] = $user->id; $numIds++; } } print_debug_msg("{$numIds} users have profiles AND names."); $letters = array_keys($members); foreach ($letters as $letter) { // NOTE: Array indexing is case sensitive. $filePath = PROFILE_PATH; if (in_array($letter, $alphabet)) { build_profile_pages($members[$letter], "User Profiles - Names beginning with {$letter}", "Names beginning with {$letter}", 5, 2, $filePath, "profile_{$letter}"); } else { build_profile_pages($members[$letter], "User Profiles - Names beginning with other characters", "Names beginning with other characters", 5, 2, $filePath, "profile_other"); } $letters_used[$letter] = 1; } build_alpha_summary_page($letters_used); print_debug_msg("done building alphabetical pages"); }
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(); }
// BOINC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see <http://www.gnu.org/licenses/>. require_once "../inc/util.inc"; require_once "../inc/boinc_db.inc"; if (DISABLE_PROFILES) { error_page("Profiles are disabled"); } check_get_args(array("userid", "vote")); $userid = get_int('userid'); $vote = get_str('vote'); $logged_in_user = get_logged_in_user(); if ($vote != "recommend" && $vote != "reject") { error_page(tra("Invalid vote type:") . " " . htmlentities($vote)); } BoincProfile::update_aux("{$vote}={$vote}+1 WHERE userid = {$userid}"); page_head(tra("Vote Recorded")); start_table_noborder(); row1(tra("Thank you")); if ($vote == "recommend") { rowify(tra("Your recommendation has been recorded.")); } else { rowify(tra("Your vote to reject this profile has been recorded.")); } end_table(); echo "<br><a href=\"view_profile.php?userid=", $userid, "\">" . tra("Return to profile.") . "</a>"; page_tail();
function delete_profiles() { global $test, $days; $profiles = BoincProfile::enum(""); foreach ($profiles as $p) { if (has_link($p->response1) || has_link($p->response2)) { $user = BoincUser::lookup_id($p->userid); if (!$user) { echo "profile has missing user: {$p->userid}\n"; continue; } if ($days) { if ($user->create_time < time() - $days * 86400) { continue; } } $n = BoincHost::count("userid={$p->userid}"); if ($n) { continue; } $n = BoincPost::count("user={$p->userid}"); if ($n) { continue; } do_delete_user($user); if ($test) { echo "\n{$p->userid}\n{$p->response1}\n{$p->response2}\n"; } } } }
// BOINC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with BOINC. If not, see <http://www.gnu.org/licenses/>. // script to repair the "has_picture" field of profiles ini_set("memory_limit", "1023M"); $cli_only = true; require_once "../inc/util_ops.inc"; BoincDb::get(); $profiles = BoincProfile::enum(""); foreach ($profiles as $p) { $id = $p->userid; $path = "../user_profile/images/{$id}.jpg"; $smpath = "../user_profile/images/" . $id . "_sm.jpg"; $has_pic = file_exists($path); $has_pic_sm = file_exists($smpath); if ($p->has_picture) { if (!$has_pic || !$has_pic_sm) { echo "{$id} {$p->has_picture} {$has_pic} {$has_pic_sm}\n"; BoincProfile::update_aux("has_picture=0 where userid={$id}"); } } else { if ($has_pic && $has_pic_sm) { echo "{$id} {$p->has_picture} {$has_pic} {$has_pic_sm}\n"; BoincProfile::update_aux("has_picture=1 where userid={$id}"); } } }
function delete_profiles_strict() { global $test; $profiles = BoincProfile::enum(""); foreach ($profiles as $p) { $user = BoincUser::lookup_id($p->userid); if (!$user) { echo "profile has missing user: {$p->userid}\n"; continue; } $n = BoincPost::count("user={$p->userid}"); if ($n) { continue; } do_delete_user($user); if ($test) { echo "\n{$p->userid}\n{$p->response1}\n{$p->response2}\n"; } } }