Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions include/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -92,76 +92,3 @@ $RELEASES = (function () {
}
return $ret;
})();

// Get latest release version and info.
function release_get_latest() {
global $RELEASES;

$version = '0.0.0';
$current = null;
foreach ($RELEASES as $versions) {
foreach ($versions as $ver => $info) {
if (version_compare($ver, $version) > 0) {
$version = $ver;
$current = $info;
}
}
}

return [$version, $current];
}

function show_source_releases()
{
global $RELEASES;

$SHOW_COUNT = 4;

$current_uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');

$i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
$releases = array_slice($major_releases, 0, $SHOW_COUNT);
?>
<a id="v<?php echo $MAJOR; ?>"></a>
<?php foreach ($releases as $v => $a): ?>
<?php $mver = substr($v, 0, strrpos($v, '.')); ?>
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?>

<h3 id="v<?php echo $v; ?>" class="title">
<span class="release-state"><?php echo $stable; ?></span>
PHP <?php echo $v; ?>
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>)
</h3>
<div class="content-box">

<ul>
<?php foreach ($a['source'] as $rel): ?>
<li>
<?php download_link($rel['filename'], $rel['filename']); ?>
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>
<?php
if (isset($rel['sha256'])) {
echo sha256_html($rel['sha256']);
}
?>
<?php if (isset($rel['note']) && $rel['note']): ?>
<p>
<strong>Note:</strong>
<?php echo $rel['note']; ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li>
<a href="/downloads.php?os=windows&osvariant=windows-downloads&version=<?php echo urlencode($mver); ?>">
Windows downloads
</a>
</li>
</ul>

<a href="<?php echo $current_uri; ?>#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a>
</div>
<?php endforeach; ?>
<?php endforeach; /* major releases loop end */ ?>
<?php
}
24 changes: 6 additions & 18 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1260,24 +1260,6 @@ parameters:
count: 1
path: include/site.inc

-
message: '#^Function release_get_latest\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: include/version.inc

-
message: '#^Function show_source_releases\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: include/version.inc

-
message: '#^Parameter \#3 \$length of function substr expects int\|null, int\|false given\.$#'
identifier: argument.type
count: 1
path: include/version.inc

-
message: '#^Variable \$SIDEBAR_DATA might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -2454,6 +2436,12 @@ parameters:
count: 1
path: src/News/NewsHandler.php

-
message: '#^Parameter \#3 \$length of function substr expects int\|null, int\|false given\.$#'
identifier: argument.type
count: 1
path: src/Releases/Releases.php

-
message: '#^Method phpweb\\Themes\\FeatureComparison\:\:__construct\(\) has parameter \$links with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down
3 changes: 2 additions & 1 deletion public/downloads.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
use phpweb\Downloads\OptionResolver;
use phpweb\Releases\Releases;

$_SERVER['BASE_PAGE'] = 'downloads.php';
require_once __DIR__ . '/../include/prepend.inc';
Expand Down Expand Up @@ -168,7 +169,7 @@ function option(string $value, string $desc, $attributes = []): string
<?php if (!$instructionsShown): ?>

<h2>Source Code</h2>
<?php show_source_releases(); ?>
<?php new Releases()->showSource(); ?>

<hr>
<h2>GPG Keys</h2>
Expand Down
3 changes: 2 additions & 1 deletion public/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use phpweb\I18n\Languages;
use phpweb\ProjectGlobals;
use phpweb\Releases\Releases;
use phpweb\UserPreferences;

// Ensure that our environment is set up
Expand Down Expand Up @@ -145,7 +146,7 @@
$df = $dlinfo[1];
if (strpos($df, "7-LATEST") !== false) {
require_once __DIR__ . "/../include/version.inc";
[$latest] = release_get_latest();
[$latest] = new Releases()->getLatest();
$df = str_replace("7-LATEST", $latest, $df);
}

Expand Down
5 changes: 3 additions & 2 deletions public/mirror-info.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

// Define $MYSITE and $LAST_UPDATED variables
use phpweb\ProjectGlobals;
use phpweb\Releases\Releases;

// Define $MYSITE and $LAST_UPDATED variables
require_once __DIR__ . '/../include/prepend.inc';

// Define release_get_latest() function.
Expand All @@ -15,7 +16,7 @@
$mirror_stats = (int) (isset($_SERVER['MIRROR_STATS']) && $_SERVER['MIRROR_STATS'] == '1');

// SHA256 check last release file (identifies rsync setup problems)
[, $latest] = release_get_latest();
[, $latest] = new Releases()->getLatest();
$dist = $latest['source'][0];
$filename = ProjectGlobals::getPublicRoot() . "/distributions/{$dist['filename']}";
if (!file_exists($filename)) {
Expand Down
94 changes: 94 additions & 0 deletions src/Releases/Releases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace phpweb\Releases;

use function array_slice;
use function date;
use function download_link;
use function htmlspecialchars;
use function sha256_html;
use function strrpos;
use function strtotime;
use function substr;
use function urlencode;
use function version_compare;

final class Releases
{
/**
* Get latest release version and info
*
* @return array{string, array<mixed>|null}
*/
public function getLatest(): array {
global $RELEASES;

$version = '0.0.0';
$current = null;
foreach ($RELEASES as $versions) {
foreach ($versions as $ver => $info) {
if (version_compare($ver, $version) > 0) {
$version = $ver;
$current = $info;
}
}
}

return [$version, $current];
}

public function showSource(): void
{
global $RELEASES;

$SHOW_COUNT = 4;

$current_uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8');

$i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
$releases = array_slice($major_releases, 0, $SHOW_COUNT);
?>
<a id="v<?php echo $MAJOR; ?>"></a>
<?php foreach ($releases as $v => $a): ?>
<?php $mver = substr($v, 0, strrpos($v, '.')); ?>
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?>

<h3 id="v<?php echo $v; ?>" class="title">
<span class="release-state"><?php echo $stable; ?></span>
PHP <?php echo $v; ?>
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>)
</h3>
<div class="content-box">

<ul>
<?php foreach ($a['source'] as $rel): ?>
<li>
<?php download_link($rel['filename'], $rel['filename']); ?>
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>
<?php
if (isset($rel['sha256'])) {
echo sha256_html($rel['sha256']);
}
?>
<?php if (isset($rel['note']) && $rel['note']): ?>
<p>
<strong>Note:</strong>
<?php echo $rel['note']; ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; ?>
<li>
<a href="/downloads.php?os=windows&osvariant=windows-downloads&version=<?php echo urlencode($mver); ?>">
Windows downloads
</a>
</li>
</ul>

<a href="<?php echo $current_uri; ?>#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a>
</div>
<?php endforeach; ?>
<?php endforeach; /* major releases loop end */ ?>
<?php
}
}
Loading
Loading