Files
shopPRO/autoload/admin/Controllers/UpdateController.php
Jacek Pyziak b409806f02 ver. 0.300: Manifest-based update system with checksum verification and file backup
Replaces the manual ZIP packaging workflow with an automated build script.
UpdateRepository now supports both manifest JSON format (new) and legacy
_sql.txt/_files.txt format (fallback), enabling a smooth transition for
existing client instances.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 23:30:58 +01:00

53 lines
1.5 KiB
PHP

<?php
namespace admin\Controllers;
use Domain\Update\UpdateRepository;
class UpdateController
{
private UpdateRepository $repository;
public function __construct( UpdateRepository $repository )
{
$this->repository = $repository;
}
public function main_view(): string
{
$logContent = @file_get_contents( '../libraries/update_log.txt' );
return \Shared\Tpl\Tpl::view( 'update/main-view', [
'ver' => \Shared\Helpers\Helpers::get_version(),
'new_ver' => \Shared\Helpers\Helpers::get_new_version(),
'log' => $logContent ?: '',
] );
}
public function update(): void
{
$result = $this->repository->update();
if ( !$result['success'] ) {
\Shared\Helpers\Helpers::alert( 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.' );
} else {
\Shared\Helpers\Helpers::set_message( 'Aktualizacja przebiegła pomyślnie.' );
}
header( 'Location: /admin/update/main_view/' );
exit;
}
public function updateAll(): void
{
$result = $this->repository->update();
$response = [
'status' => !empty( $result['success'] ) && empty( $result['no_updates'] ),
'version' => number_format( (float) \Shared\Helpers\Helpers::get( 'version_current' ) + 0.001, 3, '.', '' ),
];
echo json_encode( $response );
exit;
}
}