2003-12-22 23:41:36 +00:00
|
|
|
<?php
|
2007-09-13 09:46:36 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/util.inc");
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
function format_float($x) {
|
|
|
|
if ($x<1.e-5) {
|
|
|
|
return '0';
|
|
|
|
} else if ($x<0.01) {
|
|
|
|
return sprintf("%0.5f", $x);
|
|
|
|
} else if ($x<0.1) {
|
|
|
|
return sprintf("%0.4f", $x);
|
|
|
|
} else if ($x<1) {
|
|
|
|
return sprintf("%0.3f", $x);
|
|
|
|
} else if ($x<10) {
|
|
|
|
return sprintf("%0.2f", $x);
|
|
|
|
} else if ($x<100) {
|
|
|
|
return sprintf("%0.1f", $x);
|
|
|
|
} else if ($x<1000) {
|
|
|
|
return sprintf("%0.0f", $x);
|
|
|
|
} else {
|
|
|
|
return number_format($x);
|
|
|
|
}
|
|
|
|
return '';
|
2003-12-22 23:41:36 +00:00
|
|
|
}
|
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
function show_user($user, $which) {
|
|
|
|
$rac=format_float($user->expavg_credit);
|
|
|
|
$tot=format_float($user->total_credit);
|
|
|
|
echo
|
|
|
|
" <tr>
|
|
|
|
<td align=\"center\">$which</td>
|
|
|
|
<td align=\"center\">".user_links($user)."</td>
|
|
|
|
<td align=\"center\">".date_str($user->create_time)."</td>
|
|
|
|
<td align=\"center\">".$user->country."</td>
|
|
|
|
<td align=\"center\">$tot</td>
|
|
|
|
<td align=\"center\">$rac</td>
|
|
|
|
</tr>\n";
|
|
|
|
}
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
function print_table_header($urls, $nextd) {
|
|
|
|
echo
|
|
|
|
"<table align=\"center\" cellpadding=\"2\" border=\"1\" width=\"100%\">
|
|
|
|
<tr>
|
|
|
|
<th align=\"center\">Position</th>
|
|
|
|
<th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=name>User name</a></th>
|
|
|
|
<th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=create_time>Joined project</a></th>
|
|
|
|
<th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=country>Country</a></th>
|
|
|
|
<th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=total_credit>Total credit</a></th>
|
|
|
|
<th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=expavg_credit>Recent credit</a></th>
|
|
|
|
</tr>\n";
|
|
|
|
}
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
/* if needed to help prevent database stress, sleep! */
|
|
|
|
/* sleep(2); */
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
db_init();
|
2004-06-30 18:53:35 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
$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');
|
2004-06-30 18:53:35 +00:00
|
|
|
|
2006-03-11 00:17:46 +00:00
|
|
|
if (!isset ($_GET['order']) || !in_array ($_GET['order'], $allowed_order)) {
|
2005-12-27 18:21:00 +00:00
|
|
|
$order = $default_sort;
|
|
|
|
$nice_name='';
|
|
|
|
} else {
|
|
|
|
$order = $_GET['order'];
|
|
|
|
$nice_name = $nice_names[array_search($order, $allowed_order)];
|
2003-12-22 23:41:36 +00:00
|
|
|
}
|
2005-12-27 18:21:00 +00:00
|
|
|
|
2006-03-11 00:17:46 +00:00
|
|
|
$search_string = get_str('search_string');
|
2005-12-27 18:21:00 +00:00
|
|
|
|
|
|
|
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;
|
2003-12-22 23:41:36 +00:00
|
|
|
}
|
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
$count = 100;
|
|
|
|
|
|
|
|
page_head("Search results");
|
|
|
|
|
|
|
|
if (strlen($search_string)>=3) {
|
|
|
|
$urls = urlencode($search_string);
|
2006-03-11 00:17:46 +00:00
|
|
|
$s = escape_pattern($search_string);
|
2005-12-27 18:21:00 +00:00
|
|
|
$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) {
|
2007-09-13 09:46:36 +00:00
|
|
|
echo "<h2>User names starting with '".htmlspecialchars($search_string)."' $nice_name</h2>\n";
|
2005-12-27 18:21:00 +00:00
|
|
|
print_table_header($urls, $nextd);
|
|
|
|
}
|
|
|
|
show_user($user, $n+$offset+1);
|
|
|
|
$n++;
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
mysql_free_result($result);
|
|
|
|
if (!$n) {
|
2007-09-13 09:46:36 +00:00
|
|
|
echo "<h2>No user names found starting with '".htmlspecialchars($search_string)."'</h2>\n";
|
2005-12-27 18:21:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "<br><br>\n";
|
|
|
|
echo "<h3>";
|
|
|
|
|
|
|
|
if ($offset>=$count) {
|
|
|
|
$prev= $offset-$count;
|
|
|
|
echo "<a href=user_search_action.php?search_string=$urls&offset=$prev&descending=$descending&order=$order>Previous $count</a> \n";
|
|
|
|
}
|
|
|
|
if ($n==$count) {
|
|
|
|
$next= $offset+$count;
|
|
|
|
echo "<a href=user_search_action.php?search_string=$urls&offset=$next&descending=$descending&order=$order>Next $count</a>\n";
|
|
|
|
}
|
|
|
|
echo "</h3>";
|
2003-12-22 23:41:36 +00:00
|
|
|
|
2005-12-27 18:21:00 +00:00
|
|
|
} else {
|
|
|
|
echo "<h2>Search string must be at least three characters long!</h2>\n";
|
2003-12-22 23:41:36 +00:00
|
|
|
}
|
2005-12-27 18:21:00 +00:00
|
|
|
echo "<br><h3><a href=profile_menu.php>Return to profile zone</a></h3><br>\n";
|
2003-12-22 23:41:36 +00:00
|
|
|
|
|
|
|
page_tail();
|
|
|
|
?>
|