source: subversion/sites/other/tilesAtHome/Credits/index.php @ 4734

Revision 4734, 3.2 KB checked in by deelkar, 7 years ago (diff)

clarify sort options

Line 
1<html>
2<head>
3<title>tiles@home credits</title>
4<link rel="stylesheet" href="../styles.css">
5<meta name="robots" content="nofollow,noindex">
6</head>
7<body>
8<div class="all">
9<h1 class="title"><a href="../"><img src="../Gfx/tah.png" alt="tiles@home" width="600" height="109"></a></h1>
10<p class="title">Credits</p>
11<hr>
12<p>The following people have been uploading tiles to the program:</p>
13
14<p><i>Counting began 10pm, 6<sup>th</sup> March 2007 - no records are available for earlier uploads. Blank tiles not included in count.</i></p>
15<p>blue row = upload within the last 10 minutes.</p>
16<?php
17include("../connect/connect.php");
18include("../lib/versions.inc");
19
20print("<p>Sort by <a href=\"./?sort=id\">user-id</a> or <a href=\"./\">activity</a></p>\n");
21
22
23$SQL = sprintf(
24  "select *, unix_timestamp(`last_upload`) as unixtime from tiles_users order by %s;",
25  $_GET["sort"] == "id" ? "id" : "tiles desc");
26 
27$Result = mysql_query($SQL);
28if(!mysql_error()){
29  if(mysql_num_rows($Result) > 0){
30   
31    # Start the HTML table
32    print "<table border=1 cellspacing=0 cellpadding=5>";
33   
34    # Header
35    $Columns = "ID, Name, Activity, Last upload, Version, Notes, Samples";
36    print "<tr><th>" . str_replace(", ", "</th><th>", $Columns) . "</th></tr>\n";
37   
38    ##-------------------------------------------------------
39    ## For each user...
40    ##-------------------------------------------------------
41    while($Data = mysql_fetch_assoc($Result)){
42      $Row = array();
43
44      # User ID
45      array_push($Row, sprintf("#%d", $Data["id"]));
46     
47      # Username
48      array_push($Row, sprintf("<b>%s</b>",htmlentities($Data["name"])));
49     
50      # Upload details
51      array_push($Row, sprintf("%s tiles in %s uploads",
52        number_format($Data["tiles"], 0, ".", ","),
53        number_format($Data["uploads"], 0, ".", ",")));
54   
55      # Time last seen
56      $Age = ageOf($Data["unixtime"]);
57      $OnNow = ($Age < 10 * 60)
58        && ($Data["tiles"] != 0);
59      array_push($Row, FormatAge($Age));
60     
61      # Version ID
62      array_push($Row, htmlentities(versionName($Data["version"])));
63     
64      # Notes
65      array_push($Row, sprintf("--"));
66     
67      # Link to samples
68      array_push($Row, sprintf("<a href=\"ByUser/?id=%d\">...</a>", $Data["id"]));
69     
70      # Convert all the data into a row of HTML table
71      $Style = $OnNow
72        ? "background-color:#44C"
73        : "background-color:#444";
74      print "<tr style=\"$Style\"><td>" . implode("</td><td>", $Row) . "</td><tr>\n";
75   
76    }
77    ##-------------------------------------------------------
78    print "</table>\n";
79  }
80}
81
82function ageOf($Timestamp){
83  if($Timestamp == 0)
84    return("never");
85 
86  $Age = time() - $Timestamp;
87  return($Age);
88}
89
90function FormatAge($Age){
91  if($Age < 0)
92    return("future");
93  if($Age < 120)
94    return(sprintf("%d seconds ago", $Age));
95  $Age /= 60;
96  if($Age < 120)
97    return(sprintf("%d minutes ago", $Age));
98  $Age /= 60;
99  if($Age < 24)
100    return(sprintf("%d hours ago", $Age));
101  $Age /= 24;
102  if($Age < 7)
103    return(sprintf("%d days ago", $Age));
104  $Age /= 7;
105  if($Age < 40)
106    return(sprintf("%d weeks ago", $Age));
107  $Age /= 30;
108  if($Age < 12)
109    return(sprintf("%d months ago", $Age));
110 
111  return("ages ago...");
112}
113?>
114
115</div>
116</body>
117</html>
Note: See TracBrowser for help on using the repository browser.