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

Last change on this file since 2877 was 2372, checked in by ojw, 13 years ago

Thousands separator for large numbers

File size: 2.6 KB
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
16<?php
17include("../connect/connect.php");
18include("../lib/versions.inc");
19
20$SQL = "select *, unix_timestamp(`last_upload`) as unixtime from tiles_users order by tiles desc;";
21$Result = mysql_query($SQL);
22if(!mysql_error()){
23  if(mysql_num_rows($Result) > 0){
24   
25    # Start the HTML table
26    print "<table border=1 cellspacing=0 cellpadding=5>";
27   
28    # Header
29    $Columns = "Name, Activity, Last upload, Version, Samples";
30    print "<tr><th>" . str_replace(", ", "</th><th>", $Columns) . "</th></tr>\n";
31   
32    ##-------------------------------------------------------
33    ## For each user...
34    ##-------------------------------------------------------
35    while($Data = mysql_fetch_assoc($Result)){
36      $Row = array();
37     
38      # Username
39      array_push($Row, sprintf("<b>%s</b>",htmlentities($Data["name"])));
40     
41      # Upload details
42      array_push($Row, sprintf("%s tiles in %s uploads",
43        number_format($Data["tiles"], 0, ".", ","),
44        number_format($Data["uploads"], 0, ".", ",")));
45   
46      # Time last seen
47      array_push($Row, ageOf($Data["unixtime"]));
48     
49      # Version ID
50      array_push($Row, htmlentities(versionName($Data["version"])));
51     
52      # Version ID
53      array_push($Row, sprintf("<a href=\"ByUser/?id=%d\">...</a>", $Data["id"]));
54     
55      # Convert all the data into a row of HTML table
56      print "<tr><td>" . implode("</td><td>", $Row) . "</td><tr>\n";
57   
58    }
59    ##-------------------------------------------------------
60    print "</table>\n";
61  }
62}
63
64function ageOf($Timestamp){
65  if($Timestamp == 0)
66    return("never");
67 
68  $Age = time() - $Timestamp;
69  if($Age < 0)
70    return("future");
71  if($Age < 120)
72    return(sprintf("%d seconds ago", $Age));
73  $Age /= 60;
74  if($Age < 120)
75    return(sprintf("%d minutes ago", $Age));
76  $Age /= 60;
77  if($Age < 24)
78    return(sprintf("%d hours ago", $Age));
79  $Age /= 24;
80  if($Age < 7)
81    return(sprintf("%d days ago", $Age));
82  $Age /= 7;
83  if($Age < 40)
84    return(sprintf("%d weeks ago", $Age));
85  $Age /= 30;
86  if($Age < 12)
87    return(sprintf("%d months ago", $Age));
88 
89  return("ages ago...");
90}
91?>
92
93</div>
94</body>
95</html>
Note: See TracBrowser for help on using the repository browser.