expavg_credit);
$tot=format_float($user->total_credit);
echo
"
$which |
".user_links($user)." |
".date_str($user->create_time)." |
".$user->country." |
$tot |
$rac |
\n";
}
function print_table_header($urls, $nextd) {
echo
"
Position |
User name |
Joined project |
Country |
Total credit |
Recent credit |
\n";
}
/* if needed to help prevent database stress, sleep! */
/* sleep(2); */
db_init();
$default_sort = 'id';
$allowed_order = array('id', 'name', 'create_time','country', 'total_credit', 'expavg_credit');
$nice_names = array('', 'sorted by name', 'sorted by date joined', 'sorted by country', 'sorted by total credit', 'sorted by recent average credit');
if (!isset ($_GET['order']) || !in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
$nice_name='';
} else {
$order = $_GET['order'];
$nice_name = $nice_names[array_search($order, $allowed_order)];
}
$search_string = get_str('search_string');
if (isset($_GET['offset'])) $offset = $_GET['offset'];
if (!is_numeric($offset) || $offset<0) $offset=0;
if (isset($_GET['descending']) && $_GET['descending']==1) {
$upordown='desc';
$descending=1;
$nextd=0;
} else {
$upordown='asc';
$descending=0;
$nextd=1;
}
$count = 100;
page_head("Search results");
if (strlen($search_string)>=3) {
$urls = urlencode($search_string);
$s = escape_pattern($search_string);
$q = "select * from user where name like '$s%' order by $order $upordown limit $offset,$count";
$result = mysql_query($q);
$n=0;
while ($user = mysql_fetch_object($result)) {
if ($n==0) {
echo "User names starting with '".htmlspecialchars($search_string)."' $nice_name
\n";
print_table_header($urls, $nextd);
}
show_user($user, $n+$offset+1);
$n++;
}
echo "
\n";
mysql_free_result($result);
if (!$n) {
echo "No user names found starting with '".htmlspecialchars($search_string)."'
\n";
}
echo "
\n";
echo "";
if ($offset>=$count) {
$prev= $offset-$count;
echo "Previous $count \n";
}
if ($n==$count) {
$next= $offset+$count;
echo "Next $count\n";
}
echo "
";
} else {
echo "Search string must be at least three characters long!
\n";
}
echo "
\n";
page_tail();
?>