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; } }
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 ";
// as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // 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() { 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"; } } } }
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"; } } }