181dfcb02be0319053bba0b1296092d3768d6ad7
[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 $packages = array_map("basename", glob("phars/*")); ?>
67
68 <?php if ($_SERVER["QUERY_STRING"] && in_array($_SERVER["QUERY_STRING"], $packages, true)) : ?>
69
70 <h2><?= $package = $_SERVER["QUERY_STRING"]; ?></h2>
71 <table class="table table-full">
72 <thead>
73 <tr>
74 <th class="text-left">Package</th>
75 <th class="text-left">Date</th>
76 <th class="text-right">Size</th>
77 </tr>
78 </thead>
79 <tbody>
80 <?php foreach (array_reverse(glob("phars/$package/*.ext.phar*")) as $phar) : ?>
81
82 <tr>
83 <td class="text-left">
84 <a href="<?= htmlspecialchars($phar) ?>"
85 ><?= htmlspecialchars(basename($phar)) ?></a>
86 </td>
87 <td class="text-left">
88 <?php
89
90 $time = time();
91 $dsec = 86400;
92 $lmod = filemtime($phar);
93 $days = [1 => "today", "yesterday"];
94 do {
95 for ($i = 1; $i < 7; ++$i) {
96 if ($lmod > $time - $dsec * $i) {
97 switch ($i) {
98 case 1:
99 echo "today";
100 break 3;
101 case 2:
102 echo "yesterday";
103 break 3;
104 default:
105 echo "$i days ago";
106 break 3;
107 }
108 }
109 }
110 echo date("Y-m-d", $lmod);
111 } while (false);
112
113 ?>
114
115 </td>
116 <td class="text-right">
117 <?php
118
119 $u = ["Bytes", "KB", "MB"];
120 $s = filesize($phar);
121 $l = floor(log10($s));
122 printf("%1.1F %s\n", $s/pow(10,$l-($l%3)), $u[$l/3]);
123
124 ?>
125 </td>
126 </tr>
127 <?php endforeach; ?>
128
129 </tbody>
130 </table>
131 <?php else: ?>
132
133 <h2>Available Packages</h2>
134 <ul class="list-inline">
135 <?php foreach (array_map("htmlspecialchars", $packages) as $index => $package) : ?>
136 <?php $next = strtolower($package{0}); ?>
137 <?php if (isset($prev) && $next != $prev) : ?>
138
139 </ul>
140 <ul class="list-inline">
141 <?php endif; ?>
142
143 <li><a href="?<?= $package ?>"><?= $package ?></a></li>
144 <?php $prev = $next; ?>
145 <?php endforeach; ?>
146
147 </ul>
148 <?php endif; ?>
149
150 </div>
151 <div class="footer">
152 <footer>
153 &copy; 2015 m6w6, Michael Wallner
154 </footer>
155 </div>
156 </body>
157 </html>