~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to html/user/user_search_action.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
require_once("../inc/db.inc");
4
 
require_once("../inc/util.inc");
5
 
 
6
 
function format_float($x) {
7
 
    if ($x<1.e-5) {
8
 
        return '0';
9
 
    } else if ($x<0.01) {
10
 
        return sprintf("%0.5f", $x);
11
 
    } else if ($x<0.1) {
12
 
        return sprintf("%0.4f", $x);
13
 
    } else if ($x<1) {
14
 
        return sprintf("%0.3f", $x);
15
 
    } else if ($x<10) {
16
 
        return sprintf("%0.2f", $x);
17
 
    } else if ($x<100) {
18
 
        return sprintf("%0.1f", $x);
19
 
    } else if ($x<1000) {
20
 
        return sprintf("%0.0f", $x);
21
 
    } else {
22
 
        return number_format($x);
23
 
    }
24
 
    return '';
25
 
}
26
 
 
27
 
function show_user($user, $which) {
28
 
    $rac=format_float($user->expavg_credit);
29
 
    $tot=format_float($user->total_credit);
30
 
    echo 
31
 
"  <tr>
32
 
    <td align=\"center\">$which</td>
33
 
    <td align=\"center\">".user_links($user)."</td>
34
 
    <td align=\"center\">".date_str($user->create_time)."</td>
35
 
    <td align=\"center\">".$user->country."</td>
36
 
    <td align=\"center\">$tot</td>
37
 
    <td align=\"center\">$rac</td>
38
 
  </tr>\n";
39
 
}
40
 
 
41
 
function print_table_header($urls, $nextd) {
42
 
    echo
43
 
"<table align=\"center\" cellpadding=\"2\" border=\"1\" width=\"100%\">
44
 
  <tr>
45
 
    <th align=\"center\">Position</th>
46
 
    <th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=name>User name</a></th>
47
 
    <th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=create_time>Joined project</a></th>
48
 
    <th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=country>Country</a></th>
49
 
    <th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=total_credit>Total credit</a></th>
50
 
    <th align=\"center\"><a href=user_search_action.php?search_string=$urls&offset=0&descending=$nextd&order=expavg_credit>Recent credit</a></th>
51
 
  </tr>\n";
52
 
}
53
 
 
54
 
/* if needed to help prevent database stress, sleep! */
55
 
/* sleep(2); */
56
 
 
57
 
db_init();
58
 
 
59
 
$default_sort = 'id';
60
 
$allowed_order = array('id', 'name', 'create_time','country', 'total_credit', 'expavg_credit');
61
 
$nice_names    = array('', 'sorted by name', 'sorted by date joined', 'sorted by country', 'sorted by total credit', 'sorted by recent average credit');
62
 
 
63
 
if (!isset ($_GET['order']) || !in_array ($_GET['order'], $allowed_order)) {
64
 
    $order = $default_sort;
65
 
    $nice_name='';
66
 
} else {
67
 
    $order = $_GET['order'];
68
 
    $nice_name = $nice_names[array_search($order, $allowed_order)];
69
 
}
70
 
 
71
 
$search_string = get_str('search_string');
72
 
 
73
 
if (isset($_GET['offset'])) $offset = $_GET['offset'];
74
 
if (!is_numeric($offset) || $offset<0) $offset=0;
75
 
 
76
 
if (isset($_GET['descending']) && $_GET['descending']==1) {
77
 
    $upordown='desc';
78
 
    $descending=1;
79
 
    $nextd=0;
80
 
} else {
81
 
    $upordown='asc';
82
 
    $descending=0;
83
 
    $nextd=1;
84
 
}
85
 
 
86
 
$count = 100;
87
 
 
88
 
page_head("Search results");
89
 
 
90
 
if (strlen($search_string)>=3) {
91
 
    $urls = urlencode($search_string);
92
 
    $s = escape_pattern($search_string);
93
 
    $q = "select * from user where name like '$s%' order by $order $upordown limit $offset,$count";
94
 
    $result = mysql_query($q);
95
 
    
96
 
    $n=0;
97
 
    while ($user = mysql_fetch_object($result)) {
98
 
        if ($n==0) {
99
 
            echo "<h2>User names starting with '$search_string' $nice_name</h2>\n";
100
 
            print_table_header($urls, $nextd);
101
 
        }
102
 
        show_user($user, $n+$offset+1);
103
 
        $n++;
104
 
    }
105
 
    echo "</table>\n";
106
 
    mysql_free_result($result);
107
 
    if (!$n) {
108
 
        echo "<h2>No user names found starting with '$search_string'</h2>\n";
109
 
    }
110
 
    
111
 
    echo "<br><br>\n";
112
 
    echo "<h3>";
113
 
    
114
 
    if ($offset>=$count) {
115
 
        $prev= $offset-$count;
116
 
        echo "<a href=user_search_action.php?search_string=$urls&offset=$prev&descending=$descending&order=$order>Previous $count</a>&nbsp;&nbsp;&nbsp;&nbsp;\n";
117
 
    }
118
 
    if ($n==$count) {
119
 
        $next= $offset+$count;
120
 
        echo "<a href=user_search_action.php?search_string=$urls&offset=$next&descending=$descending&order=$order>Next $count</a>\n";
121
 
    }
122
 
    echo "</h3>";
123
 
 
124
 
} else {
125
 
    echo "<h2>Search string must be at least three characters long!</h2>\n";
126
 
}
127
 
echo "<br><h3><a href=profile_menu.php>Return to profile zone</a></h3><br>\n";
128
 
 
129
 
page_tail();
130
 
?>