Zdalny changelog z shoppro.project-dc.pl/updates/changelog.php zwracal niezbalansowany HTML (niezamkniety <script>/<style>/<textarea>/<!--), ktory "polykal" reszte dokumentu - inline-script z handlerami #confirm/#confirmUpdateAll i footer-script z main-layout.php (#clear-cache-btn) nigdy nie parsowaly sie jako JS. Klienci nie mogli aktualizowac shopPRO. Fix w admin/templates/update/main-view.php: 1. Blok <script> z handlerami przeniesiony PRZED sekcje Changelog - handlery podpinaja sie niezaleznie od zdalnego HTML. 2. Sanityzacja zdalnego changeloga: preg_replace usuwa komentarze HTML, strip_tags z whitelista (<p><br><b><strong><i><em><u><ul><ol><li> <h1>-<h6><span><div><a><pre><code><hr>) wycina tagi strukturalne i wykonywalne (<script>, <style>, <iframe>, <textarea>). Skutek uboczny: footer-script z main-layout.php (Wyczysc cache + globalne wyszukiwanie + sprawdzanie aktualizacji) dziala teraz na podstronie update. Po wgraniu na instancje: hard-reload (Ctrl+F5) + restart PHP-FPM / wyczyszczenie OPcache. Suita PHPUnit: 846 testow / 2348 assertions OK. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
146 lines
4.9 KiB
PHP
146 lines
4.9 KiB
PHP
<div class="panel">
|
|
<div class="panel-heading">
|
|
<span class="panel-title">Aktualizacja systemu</span>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="form-group">
|
|
<label class="control-label col-lg-4">Twoja wersja systemu</label>
|
|
<div class="col-lg-8">
|
|
<p class="form-control-static"><?= $this->ver; ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label col-lg-4">Aktualna wersja systemu</label>
|
|
<div class="col-lg-8">
|
|
<p class="form-control-static"><?= $this->new_ver; ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="progress-box hidden">
|
|
<div class="version">
|
|
<h3>Aktualizacja <span class="version_curent">0</span> / <span class="version_diff">0</span></h3>
|
|
</div>
|
|
<div class="progress">
|
|
<div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar"
|
|
aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<? if ( $this->ver < $this->new_ver ): ?>
|
|
<div class="row mt15">
|
|
<div class="form-group col-lg-6 text-right">
|
|
<a href="#" class="btn btn-system btn-sm mb5" id="confirm">Aktualizuj do wyższej wersji</a>
|
|
</div>
|
|
<div class="form-group col-lg-6">
|
|
<a href="#" class="btn btn-system btn-sm mb5" id="confirmUpdateAll">Aktualizuj do najwyższej wersji</a>
|
|
</div>
|
|
</div>
|
|
<div class="text-danger text-center">* Przed aktualizacją systemu zalecane jest wykonanie pełnej kopii zapasowej.</div>
|
|
<? endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<? if ( !empty( $this->log ) ): ?>
|
|
<div class="panel">
|
|
<div class="panel-heading">
|
|
<span class="panel-title">Log ostatniej aktualizacji</span>
|
|
</div>
|
|
<div class="panel-body">
|
|
<pre style="max-height: 400px; overflow-y: auto; font-size: 12px;"><?= htmlspecialchars( $this->log ); ?></pre>
|
|
</div>
|
|
</div>
|
|
<? endif; ?>
|
|
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
var version_current = <?= $this->ver; ?>;
|
|
var version_new = <?= $this->new_ver; ?>;
|
|
var version_diff = Math.round( ( version_new - version_current ) * 1000 );
|
|
var width = 0;
|
|
var ac_lp = 0;
|
|
|
|
$( '#confirm' ).on( 'click', function( e ) {
|
|
e.preventDefault();
|
|
$.confirm({
|
|
title: 'Potwierdź',
|
|
content: 'Na pewno chcesz dokonać aktualizacji systemu?',
|
|
buttons: {
|
|
tak: function() {
|
|
document.location.href = '/admin/update/update/';
|
|
},
|
|
nie: function() {}
|
|
}
|
|
});
|
|
});
|
|
|
|
$( '#confirmUpdateAll' ).on( 'click', function( e ) {
|
|
e.preventDefault();
|
|
$.confirm({
|
|
title: 'Potwierdź',
|
|
content: 'Na pewno chcesz dokonać aktualizacji systemu do najwyższej wersji?',
|
|
buttons: {
|
|
tak: function() {
|
|
$( '.progress-box' ).removeClass( 'hidden' );
|
|
$( '#confirm' ).css( 'pointer-events', 'none' );
|
|
$( '#confirmUpdateAll' ).css( 'pointer-events', 'none' );
|
|
$( '.version_diff' ).html( version_diff );
|
|
updateAll( version_current, version_new, version_diff, width, ac_lp );
|
|
},
|
|
nie: function() {}
|
|
}
|
|
});
|
|
});
|
|
|
|
function updateAll( version_current, version_new, version_diff, width, ac_lp ) {
|
|
$.ajax({
|
|
url: '/admin/update/updateAll/',
|
|
type: 'POST',
|
|
data: { version_current: version_current },
|
|
success: function( data ) {
|
|
var response = jQuery.parseJSON( data );
|
|
if ( response.status == true ) {
|
|
ac_lp = ac_lp + 1;
|
|
$( '.version_curent' ).html( ac_lp );
|
|
width = width + ( ( 1 / version_diff ) * 100 );
|
|
$( '.progress-bar' ).css( 'width', width + '%' );
|
|
if ( response.version < version_new ) {
|
|
updateAll( response.version, version_new, version_diff, width, ac_lp );
|
|
} else {
|
|
$.alert({
|
|
title: 'Informacja',
|
|
content: 'Aktualizacja przebiegła pomyślnie.',
|
|
onClose: function() {
|
|
window.location.href = '/admin/update/main_view/';
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
$.alert({
|
|
title: 'Błąd',
|
|
content: 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.',
|
|
onClose: function() {
|
|
window.location.href = '/admin/update/main_view/';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<div class="panel">
|
|
<div class="panel-heading">
|
|
<span class="panel-title">Changelog</span>
|
|
</div>
|
|
<div class="panel-body">
|
|
<?php
|
|
$changelog = (string) @file_get_contents( 'https://shoppro.project-dc.pl/updates/changelog.php?ver=' . $this->ver );
|
|
$changelog = preg_replace( '/<!--.*?-->/s', '', $changelog );
|
|
$changelog = strip_tags( $changelog, '<p><br><b><strong><i><em><u><ul><ol><li><h1><h2><h3><h4><h5><h6><span><div><a><pre><code><hr>' );
|
|
echo $changelog;
|
|
?>
|
|
</div>
|
|
</div>
|