4832a229a794095e28c7d07b5c55797225b438b4
[m6w6/replicator] / public / index.php
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Replicator</title>
6 <link rel="stylesheet" href="concise/css/concise.min.css">
7 <link href="//fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet" type="text/css">
8 <meta name="viewport" content="width=device-width, initial-scale=1">
9 <style>
10 body {
11 padding-bottom: 4em;
12 padding-top: 10em;
13 }
14 .header {
15 top: 0;
16 width: 100%;
17 }
18 .footer {
19 bottom: 0;
20 width: 100%;
21 text-align: center;
22 }
23 .header, .footer {
24 position: fixed;
25 box-shadow: 0px 0px 1em .4em #89a;
26 background: #62B3E7;
27 padding: 1em 0;
28 }
29 .header h1 {
30 font-weight: bold;
31 }
32 .header h1 a, .footer a:hover {
33 text-decoration: none;
34 }
35 .header h1 a:hover {
36 text-decoration: underline;
37 }
38 .header h1 big {
39 /* normalize browser difference */
40 font-size: 1.8em;
41 }
42 .header h1 big, .footer, .footer a {
43 color: #fdfdfd;
44 text-shadow: grey 0 0 .1em;
45 }
46 .header h1 small {
47 color: #666;
48 text-shadow: white 0 0 .2em;
49 }
50 li {
51 list-style-type: circle;
52 }
53 </style>
54 </head>
55 <body>
56 <div class="header">
57 <header>
58 <h1 class="container">
59 <a href="?"><big>Replicator</big></a><br>
60 <small>Replicating PECL releases as pharext packages since 2015</small>
61 </h1>
62 <a href="https://github.com/m6w6/replicator"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
63 </header>
64 </div>
65 <div class="container">
66 <?php
67
68 $packages = array_map("basename", glob("phars/*", GLOB_NOSORT|GLOB_ONLYDIR));
69 sort($packages, SORT_NATURAL|SORT_FLAG_CASE);
70
71 ?>
72
73 <?php if ($_SERVER["QUERY_STRING"] && in_array($_SERVER["QUERY_STRING"], $packages, true)) : ?>
74
75 <h2><?= $package = $_SERVER["QUERY_STRING"]; ?></h2>
76 <table class="table table-full">
77 <thead>
78 <tr>
79 <th class="text-left">Package</th>
80 <th class="text-left">Date</th>
81 <th class="text-right">Size</th>
82 </tr>
83 </thead>
84 <tbody>
85 <?php foreach (array_reverse(glob("phars/$package/*.ext.phar*")) as $phar) : ?>
86
87 <tr>
88 <td class="text-left">
89 <a href="<?= htmlspecialchars($phar) ?>"
90 ><?= htmlspecialchars(basename($phar)) ?></a>
91 </td>
92 <td class="text-left">
93 <?php
94
95 $time = time();
96 $dsec = 86400;
97 $lmod = filemtime($phar);
98 $days = [1 => "today", "yesterday"];
99 do {
100 for ($i = 1; $i < 7; ++$i) {
101 if ($lmod > $time - $dsec * $i) {
102 switch ($i) {
103 case 1:
104 echo "today";
105 break 3;
106 case 2:
107 echo "yesterday";
108 break 3;
109 default:
110 echo "$i days ago";
111 break 3;
112 }
113 }
114 }
115 echo date("Y-m-d", $lmod);
116 } while (false);
117
118 ?>
119
120 </td>
121 <td class="text-right">
122 <?php
123
124 $u = ["Bytes", "KB", "MB"];
125 $s = filesize($phar);
126 $l = floor(log10($s));
127 printf("%1.1F %s\n", $s/pow(10,$l-($l%3)), $u[$l/3]);
128
129 ?>
130 </td>
131 </tr>
132 <?php endforeach; ?>
133
134 </tbody>
135 </table>
136 <?php else: ?>
137
138 <h2>Available Packages</h2>
139 <ul class="list-inline">
140 <?php foreach (array_map("htmlspecialchars", $packages) as $index => $package) : ?>
141 <?php $next = strtolower($package{0}); ?>
142 <?php if (isset($prev) && $next != $prev) : ?>
143
144 </ul>
145 <ul class="list-inline">
146 <?php endif; ?>
147
148 <li><a href="?<?= $package ?>"><?= $package ?></a></li>
149 <?php $prev = $next; ?>
150 <?php endforeach; ?>
151
152 </ul>
153 <?php endif; ?>
154
155 </div>
156 <div class="footer">
157 <footer>
158 &copy; 2015 m6w6, Michael Wallner
159 </footer>
160 </div>
161 </body>
162 </html>