xref: /web-php/include/version.inc (revision 631c8ca9)
1<?php
2/* The format is:
3 * array(
4 *     "major release number" => array(
5 *         "release" => array(
6 *             "source/windows" => array(
7 *                 "filename" => "filename.tar.bz2",
8 *                 "name"     => "package name",
9 *                 "sha256"   => "shasum -256",
10 *                 "date"     => "this files release date",
11 *                 "note"     => "this file was updated 29feb due to broken phar files..",
12 *             ),
13 *             "announcement" => "bool, release announcement exists in releases/?",
14 *         ),
15 *     ),
16 * );
17 */
18$RELEASES = (function () {
19    $data = [];
20
21    /* PHP 8.4 Release */
22    $data['8.4'] = [
23        'version' => '8.4.1',
24        'date' => '21 Nov 2024',
25        'tags' => ['security'], // Set to ['security'] for security releases.
26        'sha256' => [
27            'tar.gz' => 'c3d1ce4157463ea43004289c01172deb54ce9c5894d8722f4e805461bf9feaec',
28            'tar.bz2' => 'ef8a270118ed128b765fc31f198c7f4650c8171411b0f6a3a1a3aba11fcacc23',
29            'tar.xz' => '94c8a4fd419d45748951fa6d73bd55f6bdf0adaefb8814880a67baa66027311f',
30        ]
31    ];
32
33    /* PHP 8.3 Release */
34    $data['8.3'] = [
35        'version' => '8.3.14',
36        'date' => '21 Nov 2024',
37        'tags' => ['security'], // Set to ['security'] for security releases.
38        'sha256' => [
39            'tar.gz' => 'e4ee602c31e2f701c9f0209a2902dd4802727431246a9155bf56dda7bcf7fb4a',
40            'tar.bz2' => 'f56fa669ce4c01452a2921f40034d779d8c2b97d0749493ad4781813b9221cf8',
41            'tar.xz' => '58b4cb9019bf70c0cbcdb814c7df79b9065059d14cf7dbf48d971f8e56ae9be7',
42        ]
43    ];
44
45    /* PHP 8.2 Release */
46    $data['8.2'] = [
47        'version' => '8.2.26',
48        'date' => '21 Nov 2024',
49        'tags' => ['security'], // Set to ['security'] for security releases.
50        'sha256' => [
51            'tar.gz' => '04e47b46b347ed6404dcc9e9989486710b075eafc8490500fd271aeeac5d83cb',
52            'tar.bz2' => 'be57c347d451c905bcb4336832a864d9928dd0e20989b872705fea0ba6476c6b',
53            'tar.xz' => '54747400cb4874288ad41a785e6147e2ff546cceeeb55c23c00c771ac125c6ef',
54        ]
55    ];
56
57    /* PHP 8.1 Release */
58    $data['8.1'] = [
59        'version' => '8.1.31',
60        'date' => '21 Nov 2024',
61        'tags' => ['security'], // Set to ['security'] for security releases.
62        'sha256' => [
63            'tar.gz' => '618923b407c4575bfee085f00c4aaa16a5cc86d4b1eb893c0f352d61541bbfb1',
64            'tar.bz2' => '0b39828b345151caf1b795d9f4b923c9887231776c33076dfc9d90a44390d0dc',
65            'tar.xz' => 'c4f244d46ba51c72f7d13d4f66ce6a9e9a8d6b669c51be35e01765ba58e7afca',
66        ]
67    ];
68
69    $ret = [];
70    foreach ($data as $release) {
71        $version = $release['version'];
72        [$major] = explode('.', $version, 2);
73
74        $info = [
75            'announcement' => $release['announcement'] ?? true,
76            'tags' => $release['tags'],
77            'date' => $release['date'],
78            'source' => [],
79        ];
80        foreach ($release['sha256'] as $format => $hash) {
81            $info['source'][] = [
82                'filename' => "php-{$version}.{$format}",
83                'name' => "PHP {$version} ({$format})",
84                'sha256' => $hash,
85                'date' => $release['date'],
86            ];
87        }
88        $ret[$major][$version] = $info;
89    }
90    return $ret;
91})();
92
93// Get latest release version and info.
94function release_get_latest() {
95    global $RELEASES;
96
97    $version = '0.0.0';
98    $current = null;
99    foreach ($RELEASES as $versions) {
100        foreach ($versions as $ver => $info) {
101            if (version_compare($ver, $version) > 0) {
102                $version = $ver;
103                $current = $info;
104            }
105        }
106    }
107
108    return [$version, $current];
109}
110