11<?php
22
3+ use phpweb \Releases \Branches ;
4+
35include_once __DIR__ . '/releases.inc ' ;
46include_once __DIR__ . '/version.inc ' ;
57
@@ -10,37 +12,7 @@ include_once __DIR__ . '/version.inc';
1012 * - stable: the end of active support (usually two years after release).
1113 * - security: the end of security support (usually release + 3 years).
1214 */
13- $ BRANCHES = [
14- /* 3.0 is here because version_compare() can't handle the only version in
15- * $OLDRELEASES, and it saves another special case in
16- * get_branch_security_eol_date(). */
17- '3.0 ' => [
18- 'security ' => '2000-10-20 ' ,
19- ],
20- '5.3 ' => [
21- 'stable ' => '2013-07-11 ' ,
22- 'security ' => '2014-08-14 ' ,
23- ],
24- '5.4 ' => [
25- 'stable ' => '2014-09-14 ' ,
26- 'security ' => '2015-09-03 ' ,
27- ],
28- '5.5 ' => [
29- 'stable ' => '2015-07-10 ' ,
30- 'security ' => '2016-07-21 ' ,
31- ],
32- '5.6 ' => [
33- 'stable ' => '2017-01-19 ' ,
34- 'security ' => '2018-12-31 ' ,
35- ],
36- '7.0 ' => [
37- 'stable ' => '2018-01-04 ' ,
38- 'security ' => '2019-01-10 ' ,
39- ],
40- '8.4 ' => [
41- 'date ' => '2024-11-21 ' ,
42- ],
43- ];
15+ $ BRANCHES = require __DIR__ . '/branch-overrides.inc ' ;
4416
4517/* Time to keep EOLed branches in the array returned by get_active_branches(),
4618 * which is used on the front page download links and the supported versions
@@ -98,6 +70,7 @@ function version_number_to_branch(string $version): ?string {
9870 return null ;
9971}
10072
73+ #[Deprecated('Use Branches::get_all_branches() ' )]
10174function get_all_branches () {
10275 $ branches = [];
10376
@@ -135,7 +108,8 @@ function get_all_branches() {
135108 return $ branches ;
136109}
137110
138- function get_active_branches ($ include_recent_eols = true ) {
111+ #[Deprecated('Use Branches::active() ' )]
112+ function get_active_branches (bool $ include_recent_eols = true ) {
139113 $ branches = [];
140114 $ now = new DateTime ();
141115
@@ -170,6 +144,7 @@ function get_active_branches($include_recent_eols = true) {
170144/* If you provide an array to $always_include, note that the version numbers
171145 * must be in $RELEASES _and_ must be the full version number, not the branch:
172146 * ie provide array('5.3.29'), not array('5.3'). */
147+ #[Deprecated('Use Branches::eol() ' )]
173148function get_eol_branches ($ always_include = null ) {
174149 $ always_include = $ always_include ?: [];
175150 $ branches = [];
@@ -246,6 +221,7 @@ function get_eol_branches($always_include = null) {
246221 * MAJOR.MINOR.REVISION (the REVISION will be ignored if provided). This will
247222 * return either null (if no release exists on the given branch), or the usual
248223 * version metadata from $RELEASES for a single release. */
224+ #[Deprecated('Use Branches::getInitialRelease ' )]
249225function get_initial_release ($ branch ) {
250226 $ branch = version_number_to_branch ($ branch );
251227 if (!$ branch ) {
@@ -274,6 +250,7 @@ function get_initial_release($branch) {
274250 return null ;
275251}
276252
253+ #[Deprecated('Use Branches::getFinalRelease ' )]
277254function get_final_release ($ branch ) {
278255 $ branch = version_number_to_branch ($ branch );
279256 if (!$ branch ) {
@@ -305,6 +282,7 @@ function get_final_release($branch) {
305282 return null ;
306283}
307284
285+ #[Deprecated('Use Branches::getBranchBugsEOLDate ' )]
308286function get_branch_bug_eol_date ($ branch ): ?DateTime
309287{
310288 if (isset ($ GLOBALS ['BRANCHES ' ][$ branch ]['stable ' ])) {
@@ -324,6 +302,7 @@ function get_branch_bug_eol_date($branch): ?DateTime
324302 return $ date ?->setDate($ date ->format ('Y ' ), 12 , 31 );
325303}
326304
305+ #[Deprecated('Use Branches::getBranchSecurityEOLDate ' )]
327306function get_branch_security_eol_date ($ branch ): ?DateTime
328307{
329308 if (isset ($ GLOBALS ['BRANCHES ' ][$ branch ]['security ' ])) {
@@ -351,13 +330,15 @@ function get_branch_security_eol_date($branch): ?DateTime
351330 return $ date ?->setDate($ date ->format ('Y ' ), 12 , 31 );
352331}
353332
333+ #[Deprecated('Use Branches::getBranchReleaseDate ' )]
354334function get_branch_release_date ($ branch ): ?DateTime
355335{
356336 $ initial = get_initial_release ($ branch );
357337
358338 return isset ($ initial ['date ' ]) ? new DateTime ($ initial ['date ' ]) : null ;
359339}
360340
341+ #[Deprecated('Use Branches::getBranchSupportState ' )]
361342function get_branch_support_state ($ branch ) {
362343 $ initial = get_branch_release_date ($ branch );
363344 $ bug = get_branch_bug_eol_date ($ branch );
@@ -399,7 +380,7 @@ function compare_version(array $arrayA, string $versionB)
399380 return 0 ;
400381}
401382
402- function version_array (string $ version , ?int $ length = null )
383+ function version_array (string $ version , ?int $ length = null ): mixed
403384{
404385 $ versionArray = array_map (
405386 'intval ' ,
@@ -419,6 +400,7 @@ function version_array(string $version, ?int $length = null)
419400 return $ versionArray ;
420401}
421402
403+ #[Deprecated('Use Branches::getCurrentReleaseForBranch ' )]
422404function get_current_release_for_branch (int $ major , ?int $ minor ): ?string {
423405 global $ RELEASES , $ OLDRELEASES ;
424406
@@ -441,3 +423,80 @@ function get_current_release_for_branch(int $major, ?int $minor): ?string {
441423
442424 return null ;
443425}
426+
427+
428+ // Get latest release version and info.
429+ /**
430+ * @return array{mixed,mixed}
431+ */
432+ function release_get_latest (): array {
433+ $ RELEASES = Branches::getReleaseData ();
434+
435+ $ version = '0.0.0 ' ;
436+ $ current = null ;
437+ foreach ($ RELEASES as $ versions ) {
438+ foreach ($ versions as $ ver => $ info ) {
439+ if (version_compare ($ ver , $ version ) > 0 ) {
440+ $ version = $ ver ;
441+ $ current = $ info ;
442+ }
443+ }
444+ }
445+
446+ return [$ version , $ current ];
447+ }
448+
449+ function show_source_releases (): void
450+ {
451+ $ RELEASES = Branches::getReleaseData ();
452+
453+ $ SHOW_COUNT = 4 ;
454+
455+ $ current_uri = htmlspecialchars ($ _SERVER ['REQUEST_URI ' ], ENT_QUOTES , 'UTF-8 ' );
456+
457+ $ i = 0 ; foreach ($ RELEASES as $ MAJOR => $ major_releases ): /* major releases loop start */
458+ $ releases = array_slice ($ major_releases , 0 , $ SHOW_COUNT );
459+ ?>
460+ <a id="v<?php echo $ MAJOR ; ?> "></a>
461+ <?php foreach ($ releases as $ v => $ a ): ?>
462+ <?php $ mver = substr ($ v , 0 , strrpos ($ v , '. ' )); ?>
463+ <?php $ stable = $ i ++ === 0 ? "Current Stable " : "Old Stable " ; ?>
464+
465+ <h3 id="v<?php echo $ v ; ?> " class="title">
466+ <span class="release-state"><?php echo $ stable ; ?> </span>
467+ PHP <?php echo $ v ; ?>
468+ (<a href="/ChangeLog-<?php echo $ MAJOR ; ?> .php#<?php echo urlencode ($ v ); ?> " class="changelog">Changelog</a>)
469+ </h3>
470+ <div class="content-box">
471+
472+ <ul>
473+ <?php foreach ($ a ['source ' ] as $ rel ): ?>
474+ <li>
475+ <?php download_link ($ rel ['filename ' ], $ rel ['filename ' ]); ?>
476+ <span class="releasedate"><?php echo date ('d M Y ' , strtotime ($ rel ['date ' ])); ?> </span>
477+ <?php
478+ if (isset ($ rel ['md5 ' ])) echo '<span class="md5sum"> ' , $ rel ['md5 ' ], '</span> ' ;
479+ if (isset ($ rel ['sha256 ' ])) echo '<span class="sha256"> ' , $ rel ['sha256 ' ], '</span> ' ;
480+ ?>
481+ <?php if (isset ($ rel ['note ' ]) && $ rel ['note ' ]): ?>
482+ <p>
483+ <strong>Note:</strong>
484+ <?php echo $ rel ['note ' ]; ?>
485+ </p>
486+ <?php endif ; ?>
487+ </li>
488+ <?php endforeach ; ?>
489+ <li>
490+ <a href="/downloads.php?os=windows&osvariant=windows-downloads&version=<?php echo urlencode ($ mver ); ?> ">
491+ Windows downloads
492+ </a>
493+ </li>
494+ </ul>
495+
496+ <a href="<?php echo $ current_uri ; ?> #gpg-<?php echo $ mver ; ?> ">GPG Keys for PHP <?php echo $ mver ; ?> </a>
497+ </div>
498+ <?php endforeach ; ?>
499+ <?php endforeach ; /* major releases loop end */ ?>
500+ <?php
501+ }
502+
0 commit comments