-
Notifications
You must be signed in to change notification settings - Fork 14
/
release.php
192 lines (168 loc) · 6.42 KB
/
release.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
// error_reporting(E_ALL);
$rootpath = $_SERVER['DOCUMENT_ROOT'] . '/';
$releasespath = 'releases/';
function safe_filesize($size)
{
if ($size >= 1048576)
return round($size / 1048576) . ' MiB';
else if ($size >= 1024)
return round($size / 1024) . ' KiB';
else if ($size != 0)
return $size . ' B';
else
return '0 B';
}
// And you're ready to go!
$filename = "latest";
$myfile = fopen($filename, "r");
$contents = fread($myfile, filesize($filename));
fclose($myfile);
$response = json_decode($contents);
$tag_name = $response->tag_name;
$version = str_replace("mame0","",$tag_name);
$whatsnew = 'whatsnew_0' . $version . '.txt';
$whatsnew_dc = 0;
$listxml = $tag_name . 'lx.zip';
$listxml_dc = 0;
$source_exe = $tag_name . 's.exe';
$source_exe_dc = 0;
$source_zip = $tag_name . 's.zip';
$source_zip_dc = 0;
$binary_64bit = $tag_name . 'b_64bit.exe';
$binary_64bit_dc = 0;
foreach ($response->assets as $asset) {
switch ($asset->name) {
case $whatsnew:
$whatsnew_size = safe_filesize($asset->size);
$whatsnew_dc = $asset->download_count;
break;
case $listxml:
$listxml_size = safe_filesize($asset->size);
$listxml_dc = $asset->download_count;
break;
case $source_exe:
$source_exe_size = safe_filesize($asset->size);
$source_exe_dc = $asset->download_count;
break;
case $binary_64bit:
$binary_64bit_size = safe_filesize($asset->size);
$binary_64bit_dc = $asset->download_count;
break;
}
}
function release_mirror_file($filename)
{
global $version;
if (true)
echo '<a href="https://github.com/mamedev/mame/releases/download/mame0' . htmlspecialchars($version) . '/' . htmlspecialchars($filename) . '">' . htmlspecialchars($filename) . '</a>';
else
echo '<a href="https://sourceforge.net/projects/mame/files/mame/0.' . htmlspecialchars($version) . '/' . htmlspecialchars($filename) . '">' . htmlspecialchars($filename) . '</a>';
}
$title = 'MAME | Latest MAME Release';
?>
<?php require($_SERVER['DOCUMENT_ROOT'] . '/_include/html/header.html'); ?>
<!-- Page Content -->
<div class="container">
<h1 class="page-header" style="text-align: center;">Latest MAME Release</h1>
<p>
Latest official MAME release at <a href="https://github.com/mamedev/mame/releases/<?php echo 'mame0' . $version ?>/"
target="_blank">GitHub</a> or <a href="https://sourceforge.net/projects/mame/files/<?php echo 'mame/0.' . $version ?>/"
target="_blank">SourceForge</a>
</p>
<h2>Official Windows Binary Packages</h2>
<p>
The table below provides links to the official Windows
binaries. They provide both GUI (just launch the exe)
and command-line operation (for starting by hand or
from a frontend). Larger files are hosted on external
mirrors, selected at random, which may require a
temporary redirect to the mirror site in order to
download the file.
</p>
<p><b>Statistics are updated each 5 minutes</b></p>
<div class="panel panel-primary">
<div class="panel-heading">MAME 0.<?php echo $version ?> Official Binaries</div>
<table class="table">
<tr>
<th width="23%">File</th>
<th width="12%">Size</th>
<th width="53%">Description</th>
<th width="12%">Downloads</th>
</tr>
<tr>
<td class="link"><?php release_mirror_file($binary_64bit); ?></td>
<td class="number"><?php echo $binary_64bit_size ?></td>
<td>MAME 0.<?php echo $version ?> 64-bit Windows binaries.</td>
<td align="right"><span class="badge"><?php echo $binary_64bit_dc ?></span></td>
</tr>
<tr>
<td class="link"><?php release_mirror_file($listxml); ?></td>
<td class="number"><?php echo $listxml_size ?></td>
<td>MAME 0.<?php echo $version ?> full driver information in XML format.</td>
<td align="right"><span class="badge"><?php echo $listxml_dc ?></span></td>
</tr>
</table>
<div class="panel-footer">
<center><?php require($_SERVER['DOCUMENT_ROOT'] . '/mirrors.txt'); ?></center>
</div>
</div>
<br/>
<hr/>
<h2>Official Source Code Packages</h2>
<p>
The latest official MAME release is version 0.<?php echo $version ?>. The table below provides links to the source code.
</p>
<p>
We recommend cloning source code from our <a href="https://github.com/mamedev/mame/" target="_blank">official
git repository on GitHub</a>. You can also clone tagged releases from our mirrors at <a
href="https://gitlab.com/mamedev/mame" target="_blank">GitLab</a> and <a href="https://sourceforge.net/p/mame/code/"
target="_blank">SourceForge</a>. You can clone the MAME 0.<?php echo $version ?> source code without
fetching the entire revision history with this command:<br/>
<tt>git clone -b mame0<?php echo $version ?> --depth 1 https://github.com/mamedev/mame.git mame0<?php echo $version ?></tt>
</p>
<p>
The table below provides links to packaged source archives. Larger files are hosted on external
mirrors, selected at random, which may require a temporary redirect to the mirror site in order to
download the file.
</p>
<div class="panel panel-primary">
<div class="panel-heading">MAME 0.<?php echo $version ?> Source Code</div>
<table class="table">
<tr>
<th width="23%">File</th>
<th width="12%">Size</th>
<th width="53%">Description</th>
<th width="12%">Downloads</th>
</tr>
<tr>
<td class="link">
<a href="<?php echo $releasespath . $whatsnew ?>">
<?php echo $whatsnew ?>
</a></td>
<td class="number"><?php echo $whatsnew_size ?></td>
<td>List of what is new in this MAME release</td>
<td align="right"> </td>
</tr>
<tr>
<td class="link"><?php release_mirror_file($source_exe); ?></td>
<td class="number"><?php echo $source_exe_size ?></td>
<td>MAME 0.<?php echo $version ?> sources in self-extracting 7-Zip format (self-extracting on Windows, can be extracted with P7ZIP on other operating systems)</td>
<td align="right"><span class="badge"><?php echo $source_exe_dc ?></span></td>
</tr>
</table>
<div class="panel-footer">
<center><?php require($_SERVER['DOCUMENT_ROOT'] . '/mirrors.txt'); ?></center>
</div>
</div>
<br/>
<p>
If you are running Windows, and/or have <a href="https://www.7-zip.org/" target="_blank">7-Zip</a> or
<a href="http://p7zip.sourceforge.net/" target="_blank">P7ZIP</a> installed, you can download the
self-extracting 7-Zip self-extracting archive.
</p>
<!-- content end -->
</div>
<!-- /.container -->
<br/><br/><br/>
<?php require($_SERVER['DOCUMENT_ROOT'] . '/_include/html/footer.html'); ?>