Merge pull request 'Release: dev -> main (restore fixes, theming, schema-checker, quickicon hardening)' (#300) from release/dev-to-main-r2 into main
Generic: Standards Compliance / Secret Scanning (push) Failing after 4s
Generic: Standards Compliance / License Header Validation (push) Successful in 4s
Generic: Standards Compliance / Repository Structure Validation (push) Successful in 4s
Generic: Standards Compliance / Coding Standards Check (push) Successful in 5s
Generic: Standards Compliance / Workflow Configuration Check (push) Failing after 4s
Generic: Standards Compliance / Documentation Quality Check (push) Successful in 4s
Generic: Standards Compliance / README Completeness Check (push) Failing after 4s
Generic: Standards Compliance / Git Repository Hygiene (push) Successful in 7s
Generic: Standards Compliance / Script Integrity Validation (push) Successful in 5s
Generic: Standards Compliance / File Naming Standards (push) Successful in 4s
Generic: Standards Compliance / Line Length Check (push) Successful in 6s
Generic: Standards Compliance / Insecure Code Pattern Detection (push) Successful in 5s
Generic: Standards Compliance / Version Consistency Check (push) Successful in 50s
Generic: Standards Compliance / Dead Code Detection (push) Successful in 6s
Generic: Standards Compliance / File Size Limits (push) Successful in 3s
Generic: Standards Compliance / Binary File Detection (push) Successful in 6s
Generic: Standards Compliance / TODO/FIXME Tracking (push) Successful in 3s
Generic: Standards Compliance / Code Complexity Analysis (push) Successful in 45s
Generic: Standards Compliance / Code Duplication Detection (push) Successful in 44s
Generic: Standards Compliance / Broken Link Detection (push) Successful in 3s
Generic: Standards Compliance / API Documentation Coverage (push) Successful in 3s
Generic: Standards Compliance / Accessibility Check (push) Successful in 3s
Generic: Standards Compliance / Performance Metrics (push) Successful in 4s
Generic: Standards Compliance / Dependency Vulnerability Scanning (push) Successful in 48s
Generic: Standards Compliance / Unused Dependencies Check (push) Successful in 51s
Generic: Standards Compliance / Terraform Configuration Validation (push) Successful in 7s
Generic: Standards Compliance / Enterprise Readiness Check (push) Failing after 47s
Generic: Standards Compliance / Repository Health Check (push) Failing after 46s
Generic: Standards Compliance / Compliance Summary (push) Has been cancelled
Generic: Standards Compliance / Secret Scanning (push) Failing after 4s
Generic: Standards Compliance / License Header Validation (push) Successful in 4s
Generic: Standards Compliance / Repository Structure Validation (push) Successful in 4s
Generic: Standards Compliance / Coding Standards Check (push) Successful in 5s
Generic: Standards Compliance / Workflow Configuration Check (push) Failing after 4s
Generic: Standards Compliance / Documentation Quality Check (push) Successful in 4s
Generic: Standards Compliance / README Completeness Check (push) Failing after 4s
Generic: Standards Compliance / Git Repository Hygiene (push) Successful in 7s
Generic: Standards Compliance / Script Integrity Validation (push) Successful in 5s
Generic: Standards Compliance / File Naming Standards (push) Successful in 4s
Generic: Standards Compliance / Line Length Check (push) Successful in 6s
Generic: Standards Compliance / Insecure Code Pattern Detection (push) Successful in 5s
Generic: Standards Compliance / Version Consistency Check (push) Successful in 50s
Generic: Standards Compliance / Dead Code Detection (push) Successful in 6s
Generic: Standards Compliance / File Size Limits (push) Successful in 3s
Generic: Standards Compliance / Binary File Detection (push) Successful in 6s
Generic: Standards Compliance / TODO/FIXME Tracking (push) Successful in 3s
Generic: Standards Compliance / Code Complexity Analysis (push) Successful in 45s
Generic: Standards Compliance / Code Duplication Detection (push) Successful in 44s
Generic: Standards Compliance / Broken Link Detection (push) Successful in 3s
Generic: Standards Compliance / API Documentation Coverage (push) Successful in 3s
Generic: Standards Compliance / Accessibility Check (push) Successful in 3s
Generic: Standards Compliance / Performance Metrics (push) Successful in 4s
Generic: Standards Compliance / Dependency Vulnerability Scanning (push) Successful in 48s
Generic: Standards Compliance / Unused Dependencies Check (push) Successful in 51s
Generic: Standards Compliance / Terraform Configuration Validation (push) Successful in 7s
Generic: Standards Compliance / Enterprise Readiness Check (push) Failing after 47s
Generic: Standards Compliance / Repository Health Check (push) Failing after 46s
Generic: Standards Compliance / Compliance Summary (push) Has been cancelled
This commit was merged in pull request #300.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoGIT.Workflow
|
||||
# INGROUP: MokoCLI.Automation
|
||||
# VERSION: 01.00.00
|
||||
# VERSION: 02.64.13
|
||||
# BRIEF: Auto-create feature branch when an issue is opened
|
||||
|
||||
name: "Universal: Issue Branch"
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
# Changelog
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- Backup- and restore-progress modals (backups view) now have the same controls as the full-screen runbackup screen: an "automatically return to the list when finished" checkbox, a Cancel button (double-confirmed) while running, and terminal action buttons. Backup: View backup record / Back to backups on success, Retry / Back on failure. Restore matches, with a stronger cancel warning (a restore cannot be rolled back mid-flight) and no record link.
|
||||
|
||||
### Fixed
|
||||
- ntfy default server URL now points to `ntfy.mokoconsulting.tech` (was the public `ntfy.sh`) in the profile form default/hint, `NotificationSender` fallbacks, the `ntfy_server` column default, and the field description. (#166)
|
||||
- Non-stepped restore (`RestoreEngine`) now surfaces database-import failures instead of always reporting a clean success: it checks `DatabaseImporter::hasErrors()`, logs the failed statements, and returns a `warning` with a "database may be incomplete" message. `DatabaseImporter`'s statement splitter is also now quote-aware (a `;`/newline inside a value no longer splits a statement) with comments only skipped between statements. (#188)
|
||||
- Restore Cancel no longer orphans server-side state. The stepped-restore modal's Cancel button now calls a new `ajax.restoreCancel` action that deletes the restore staging directory and session/state files, and `SteppedSession::cleanupOldSessions()` gained a backstop that reaps orphaned `mokosuitebackup-restore-*` staging dirs (for restores abandoned by closing the browser). Previously a cancelled/abandoned restore left the extracted staging dir behind indefinitely.
|
||||
- Stepped restore no longer reports a partial database import as a clean "Restore complete". `SteppedRestoreEngine::stepDatabase()` now counts failed statements and surfaces the total (the completion message warns and the modal keeps the result on-screen instead of auto-returning). The statement splitter is also quote-aware — a `;` or newline inside a string value no longer splits a statement mid-value — and comment lines are only skipped between statements. (Sibling of #188 for the stepped/standalone paths; see #291.)
|
||||
- Database view "One Problem" on MokoSuiteBackup: reconciled the `#__mokosuitebackup_profiles` schema-checker output with the update-file history. Corrected the stale `TINYINT` definition in `01.01.01.sql` to the final `VARCHAR(20)` type, fixed the `MODIFY COLUMN` parser trip-up in `01.39.00.sql`, and rewrote the retired `sftp_*` `ADD COLUMN` statements in `01.35.00.sql`/`01.36.00.sql` as bare `ADD` so Joomla's checker no longer demands columns that `02.52.25` and the postflight purge deliberately remove. Joomla's schema checker now reports no problems.
|
||||
|
||||
### Changed
|
||||
- Backup/restore progress modals in the backups view now use the same full-screen black, big-text, animated Atum-coloured progress-bar theme as the `runbackup` screen, so all backup progress surfaces match. New `media/css/backup-progress.css` scopes the black to the modal (the list page is unaffected until a modal opens).
|
||||
- Standalone MokoRestore wizard (generated `restore.php`) re-branded to the full-black MokoSuite theme — black background, big header, dark panels/forms, and MokoSuite accent colours — so the restore experience matches the rest of the system instead of the old light blue "Joomla-styled" look.
|
||||
|
||||
## [02.64.00] --- 2026-07-14
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFGROUP: Template-Joomla
|
||||
INGROUP: Template-Joomla.Documentation
|
||||
REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Joomla
|
||||
PATH: /SECURITY.md
|
||||
VERSION: 02.64.06
|
||||
VERSION: 02.64.13
|
||||
BRIEF: Security vulnerability reporting and handling policy
|
||||
-->
|
||||
|
||||
|
||||
@@ -292,8 +292,8 @@
|
||||
label="COM_MOKOJOOMBACKUP_FIELD_NTFY_SERVER"
|
||||
description="COM_MOKOJOOMBACKUP_FIELD_NTFY_SERVER_DESC"
|
||||
maxlength="512"
|
||||
default="https://ntfy.sh"
|
||||
hint="https://ntfy.sh"
|
||||
default="https://ntfy.mokoconsulting.tech"
|
||||
hint="https://ntfy.mokoconsulting.tech"
|
||||
/>
|
||||
<field
|
||||
name="ntfy_token"
|
||||
|
||||
@@ -259,7 +259,7 @@ COM_MOKOJOOMBACKUP_FIELD_NTFY_SPACER_DESC="<strong>Push Notifications (ntfy)</st
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_TOPIC="ntfy Topic"
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_TOPIC_DESC="The ntfy topic to publish notifications to. Leave blank to disable push notifications."
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_SERVER="ntfy Server"
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_SERVER_DESC="URL of the ntfy server. Default is the public ntfy.sh service. Use your own server URL for self-hosted instances."
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_SERVER_DESC="URL of the ntfy server. Default is the Moko Consulting ntfy server (ntfy.mokoconsulting.tech). Use your own server URL for self-hosted instances, or https://ntfy.sh for the public service."
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_TOKEN="Access Token"
|
||||
COM_MOKOJOOMBACKUP_FIELD_NTFY_TOKEN_DESC="Optional access token for private ntfy topics. Leave blank for public topics."
|
||||
|
||||
|
||||
@@ -78,6 +78,40 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Auto-continue opt-out, matching the runbackup screen's checkbox. */
|
||||
.msb-progress-modal .msb-pm-autocontinue {
|
||||
margin-top: 1.5rem;
|
||||
color: rgba(255, 255, 255, .85);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.msb-progress-modal .msb-pm-autocontinue label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: .5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.msb-progress-modal .msb-pm-autocontinue input {
|
||||
width: 1.1rem;
|
||||
height: 1.1rem;
|
||||
}
|
||||
|
||||
/* Terminal-state action buttons and the running-state cancel button. */
|
||||
.msb-progress-modal .msb-pm-actions,
|
||||
.msb-progress-modal .msb-pm-cancel {
|
||||
margin-top: 1.5rem;
|
||||
display: flex;
|
||||
gap: .75rem;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.msb-progress-modal .msb-pm-actions .btn,
|
||||
.msb-progress-modal .msb-pm-cancel .btn {
|
||||
min-width: 10rem;
|
||||
}
|
||||
|
||||
.msb-progress-modal .msb-pm-warn {
|
||||
color: #ffd23f;
|
||||
font-weight: 600;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
display label there.
|
||||
-->
|
||||
<name>MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS `#__mokosuitebackup_profiles` (
|
||||
`retention_days` INT(11) NOT NULL DEFAULT 0 COMMENT 'Delete backups older than N days; 0 = unlimited',
|
||||
`retention_count` INT(11) NOT NULL DEFAULT 0 COMMENT 'Keep newest N backups; 0 = unlimited',
|
||||
`ntfy_topic` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'ntfy topic name',
|
||||
`ntfy_server` VARCHAR(512) NOT NULL DEFAULT 'https://ntfy.sh' COMMENT 'ntfy server URL',
|
||||
`ntfy_server` VARCHAR(512) NOT NULL DEFAULT 'https://ntfy.mokoconsulting.tech' COMMENT 'ntfy server URL',
|
||||
`ntfy_token` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'ntfy access token (optional)',
|
||||
`published` TINYINT(1) NOT NULL DEFAULT 1,
|
||||
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/* 02.64.09 — no schema changes */
|
||||
@@ -0,0 +1 @@
|
||||
/* 02.64.10 — no schema changes */
|
||||
@@ -0,0 +1 @@
|
||||
/* 02.64.11 — no schema changes */
|
||||
@@ -0,0 +1 @@
|
||||
/* 02.64.12 — no schema changes */
|
||||
@@ -0,0 +1 @@
|
||||
/* 02.64.13 — no schema changes */
|
||||
@@ -509,6 +509,39 @@ class AjaxController extends BaseController
|
||||
$this->sendJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel an in-progress stepped restore and clean up its staging directory
|
||||
* and session/state files (prevents orphaned artefacts on a client cancel).
|
||||
* POST: task=ajax.restoreCancel&session_id=mb_...
|
||||
*/
|
||||
public function restoreCancel(): void
|
||||
{
|
||||
if (!Session::checkToken('get') && !Session::checkToken('post')) {
|
||||
$this->sendJson(['error' => true, 'message' => 'Invalid token'], 403);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->app->getIdentity()->authorise('mokosuitebackup.backup.restore', 'com_mokosuitebackup')) {
|
||||
$this->sendJson(['error' => true, 'message' => 'Access denied'], 403);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$sessionId = $this->input->getString('session_id', '');
|
||||
|
||||
if (empty($sessionId)) {
|
||||
$this->sendJson(['error' => true, 'message' => 'Missing session_id']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$engine = new SteppedRestoreEngine();
|
||||
$result = $engine->cancel($sessionId);
|
||||
|
||||
$this->sendJson($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse archive contents without extracting.
|
||||
* POST: task=ajax.browseArchive&id=123
|
||||
|
||||
@@ -61,34 +61,37 @@ class DatabaseImporter
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$trimmed = trim($line);
|
||||
|
||||
// Skip empty lines
|
||||
if ($trimmed === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip single-line comments
|
||||
if (str_starts_with($trimmed, '--') || str_starts_with($trimmed, '#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle multi-line comments
|
||||
if (str_starts_with($trimmed, '/*')) {
|
||||
$inMultiLineComment = true;
|
||||
}
|
||||
|
||||
if ($inMultiLineComment) {
|
||||
if (str_contains($trimmed, '*/')) {
|
||||
$inMultiLineComment = false;
|
||||
// Comment/blank skipping applies only BETWEEN statements — never
|
||||
// inside an accumulating statement, where a line may be part of a
|
||||
// multi-line string value that happens to start with --, # or /*.
|
||||
if ($currentStatement === '') {
|
||||
if ($trimmed === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
if (str_starts_with($trimmed, '--') || str_starts_with($trimmed, '#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_starts_with($trimmed, '/*')) {
|
||||
$inMultiLineComment = true;
|
||||
}
|
||||
|
||||
if ($inMultiLineComment) {
|
||||
if (str_contains($trimmed, '*/')) {
|
||||
$inMultiLineComment = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulate the statement
|
||||
$currentStatement .= $line;
|
||||
|
||||
// Check if statement is complete (ends with semicolon)
|
||||
if (str_ends_with($trimmed, ';')) {
|
||||
// A statement ends at a ';' that is NOT inside a quoted string
|
||||
// literal, so a ';' or newline in a value does not split it early.
|
||||
if ($this->isCompleteStatement($currentStatement)) {
|
||||
$statement = trim($currentStatement);
|
||||
$currentStatement = '';
|
||||
|
||||
@@ -136,6 +139,52 @@ class DatabaseImporter
|
||||
return $statementsExecuted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an accumulated SQL string is a complete statement: it ends with
|
||||
* ';' that is NOT inside a quoted string literal. Tracks single/double/
|
||||
* backtick quoting (with backslash escapes; MySQL '' doubling falls out of
|
||||
* the toggle naturally) so a ';' or newline inside a value does not
|
||||
* terminate the statement early.
|
||||
*/
|
||||
private function isCompleteStatement(string $sql): bool
|
||||
{
|
||||
$len = \strlen($sql);
|
||||
$inSingle = false;
|
||||
$inDouble = false;
|
||||
$inBacktick = false;
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$ch = $sql[$i];
|
||||
|
||||
if ($inSingle) {
|
||||
if ($ch === '\\') { $i++; continue; }
|
||||
if ($ch === "'") { $inSingle = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($inDouble) {
|
||||
if ($ch === '\\') { $i++; continue; }
|
||||
if ($ch === '"') { $inDouble = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($inBacktick) {
|
||||
if ($ch === '`') { $inBacktick = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ch === "'") { $inSingle = true; }
|
||||
elseif ($ch === '"') { $inDouble = true; }
|
||||
elseif ($ch === '`') { $inBacktick = true; }
|
||||
}
|
||||
|
||||
if ($inSingle || $inDouble || $inBacktick) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str_ends_with(rtrim($sql), ';');
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-fatal errors from the last import(), if any. A non-empty result
|
||||
* means the restore completed with problems and should be treated as a
|
||||
|
||||
@@ -232,13 +232,13 @@ REPL,
|
||||
|
||||
if (backups.length === 0) {
|
||||
var alert = document.createElement('div');
|
||||
alert.style.cssText = 'padding:12px;background:#fef2f2;border:1px solid #fecaca;border-radius:6px;color:#dc2626;';
|
||||
alert.style.cssText = 'padding:12px;background:rgba(224,49,49,0.12);border:1px solid rgba(224,49,49,0.4);border-radius:6px;color:#ff8787;';
|
||||
alert.textContent = 'No ZIP files found in this directory. Upload a backup archive first.';
|
||||
list.appendChild(alert);
|
||||
} else if (backups.length === 1) {
|
||||
hiddenInput.value = backups[0].name;
|
||||
var found = document.createElement('div');
|
||||
found.style.cssText = 'padding:12px;background:#dcfce7;border:1px solid #bbf7d0;border-radius:6px;color:#16a34a;';
|
||||
found.style.cssText = 'padding:12px;background:rgba(47,158,68,0.15);border:1px solid rgba(47,158,68,0.35);border-radius:6px;color:#69db7c;';
|
||||
var strong = document.createElement('strong');
|
||||
strong.textContent = backups[0].name;
|
||||
found.appendChild(document.createTextNode('Found: '));
|
||||
@@ -247,13 +247,13 @@ REPL,
|
||||
list.appendChild(found);
|
||||
} else {
|
||||
var hint = document.createElement('div');
|
||||
hint.style.cssText = 'padding:8px 12px;background:#eff6ff;border:1px solid #bfdbfe;border-radius:6px;color:#1d4ed8;margin-bottom:8px;font-size:0.9em;';
|
||||
hint.style.cssText = 'padding:8px 12px;background:rgba(42,105,184,0.12);border:1px solid rgba(42,105,184,0.35);border-radius:6px;color:#a5d8ff;margin-bottom:8px;font-size:0.9em;';
|
||||
hint.textContent = 'Multiple backup archives found \u2014 select which one to restore:';
|
||||
list.appendChild(hint);
|
||||
backups.forEach(function(b, i) {
|
||||
var label = document.createElement('label');
|
||||
label.style.cssText = 'display:flex;align-items:center;padding:10px 12px;margin:4px 0;border:1px solid #e2e8f0;border-radius:6px;cursor:pointer;transition:background 0.15s;';
|
||||
label.onmouseover = function() { this.style.background = '#f8fafc'; };
|
||||
label.style.cssText = 'display:flex;align-items:center;padding:10px 12px;margin:4px 0;border:1px solid #2a2f37;border-radius:6px;cursor:pointer;transition:background 0.15s;';
|
||||
label.onmouseover = function() { this.style.background = '#1e2229'; };
|
||||
label.onmouseout = function() { this.style.background = ''; };
|
||||
var radio = document.createElement('input');
|
||||
radio.type = 'radio';
|
||||
@@ -268,7 +268,7 @@ REPL,
|
||||
nameStrong.textContent = b.name;
|
||||
info.appendChild(nameStrong);
|
||||
var meta = document.createElement('div');
|
||||
meta.style.cssText = 'font-size:0.85em;color:#64748b;margin-top:2px;';
|
||||
meta.style.cssText = 'font-size:0.85em;color:#9aa4b2;margin-top:2px;';
|
||||
meta.textContent = (b.size / 1048576).toFixed(1) + ' MB \u2014 ' + b.date;
|
||||
info.appendChild(meta);
|
||||
label.appendChild(info);
|
||||
@@ -1507,92 +1507,107 @@ PHP_BACKEND;
|
||||
<title>MokoRestore — Site Installer</title>
|
||||
<style>
|
||||
*{box-sizing:border-box;margin:0;padding:0}
|
||||
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;background:#f0f4f8;color:#333;line-height:1.6}
|
||||
.mr-header{background:linear-gradient(135deg,#1a3c5e 0%,#2d6a9f 100%);color:#fff;padding:1.5rem 2rem;text-align:center}
|
||||
.mr-header h1{font-size:1.6rem;font-weight:700;margin-bottom:0.2rem}
|
||||
.mr-header p{font-size:0.9rem;opacity:0.85}
|
||||
/* Full-black MokoSuite theme, matching the runbackup / backup-progress screens. */
|
||||
:root{
|
||||
--mr-bg:#000;
|
||||
--mr-panel:#15181d;
|
||||
--mr-input:#1e2229;
|
||||
--mr-border:#2a2f37;
|
||||
--mr-text:#f1f3f5;
|
||||
--mr-muted:#9aa4b2;
|
||||
--mr-accent:#2a69b8;
|
||||
--mr-accent2:#3b82f6;
|
||||
--mr-success:#2f9e44;
|
||||
--mr-danger:#e03131;
|
||||
--mr-warn:#f0b429;
|
||||
}
|
||||
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;background:var(--mr-bg);color:var(--mr-text);line-height:1.6}
|
||||
.mr-header{background:#000;color:#fff;padding:2.25rem 2rem;text-align:center;border-bottom:1px solid var(--mr-border)}
|
||||
.mr-header h1{font-size:2.5rem;font-weight:700;letter-spacing:.01em;margin-bottom:0.25rem}
|
||||
.mr-header p{font-size:1rem;color:var(--mr-muted)}
|
||||
.mr-container{max-width:800px;margin:1.5rem auto;padding:0 1rem}
|
||||
|
||||
/* Step progress bar */
|
||||
.mr-steps{display:flex;justify-content:center;margin-bottom:1.5rem;gap:0;flex-wrap:wrap}
|
||||
.mr-step{display:flex;align-items:center;gap:0.5rem;padding:0.5rem 1rem;font-size:0.8rem;color:#94a3b8;cursor:default;position:relative}
|
||||
.mr-step .mr-num{width:28px;height:28px;border-radius:50%;border:2px solid #cbd5e1;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:0.75rem;background:#fff;flex-shrink:0}
|
||||
.mr-step.active{color:#1e40af;font-weight:600}
|
||||
.mr-step.active .mr-num{border-color:#2563eb;background:#2563eb;color:#fff}
|
||||
.mr-step.done{color:#16a34a}
|
||||
.mr-step.done .mr-num{border-color:#16a34a;background:#16a34a;color:#fff}
|
||||
.mr-step::after{content:'';width:24px;height:2px;background:#cbd5e1;margin-left:0.5rem}
|
||||
.mr-step{display:flex;align-items:center;gap:0.5rem;padding:0.5rem 1rem;font-size:0.8rem;color:var(--mr-muted);cursor:default;position:relative}
|
||||
.mr-step .mr-num{width:28px;height:28px;border-radius:50%;border:2px solid var(--mr-border);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:0.75rem;background:var(--mr-input);color:var(--mr-muted);flex-shrink:0}
|
||||
.mr-step.active{color:#fff;font-weight:600}
|
||||
.mr-step.active .mr-num{border-color:var(--mr-accent);background:var(--mr-accent);color:#fff}
|
||||
.mr-step.done{color:var(--mr-success)}
|
||||
.mr-step.done .mr-num{border-color:var(--mr-success);background:var(--mr-success);color:#fff}
|
||||
.mr-step::after{content:'';width:24px;height:2px;background:var(--mr-border);margin-left:0.5rem}
|
||||
.mr-step:last-child::after{display:none}
|
||||
.mr-step.done::after{background:#16a34a}
|
||||
.mr-step.done::after{background:var(--mr-success)}
|
||||
|
||||
/* Panels */
|
||||
.mr-panel{display:none;background:#fff;border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,0.1);padding:2rem;margin-bottom:1rem}
|
||||
.mr-panel{display:none;background:var(--mr-panel);border:1px solid var(--mr-border);border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,0.5);padding:2rem;margin-bottom:1rem}
|
||||
.mr-panel.visible{display:block}
|
||||
.mr-panel h2{font-size:1.2rem;color:#1e293b;margin-bottom:0.25rem}
|
||||
.mr-panel .mr-desc{color:#64748b;font-size:0.9rem;margin-bottom:1.5rem}
|
||||
.mr-panel h2{font-size:1.4rem;color:#fff;margin-bottom:0.25rem}
|
||||
.mr-panel .mr-desc{color:var(--mr-muted);font-size:0.9rem;margin-bottom:1.5rem}
|
||||
|
||||
/* Form elements */
|
||||
.mr-field{margin-bottom:1rem}
|
||||
.mr-field label{display:block;font-weight:600;font-size:0.85rem;color:#475569;margin-bottom:0.3rem}
|
||||
.mr-field input,.mr-field select{width:100%;padding:0.6rem 0.75rem;border:1px solid #d1d5db;border-radius:6px;font-size:0.9rem;color:#1e293b;background:#fff;transition:border-color 0.2s}
|
||||
.mr-field input:focus,.mr-field select:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,0.1)}
|
||||
.mr-field .mr-hint{font-size:0.8rem;color:#94a3b8;margin-top:0.2rem}
|
||||
.mr-field label{display:block;font-weight:600;font-size:0.85rem;color:#cfd6df;margin-bottom:0.3rem}
|
||||
.mr-field input,.mr-field select{width:100%;padding:0.6rem 0.75rem;border:1px solid var(--mr-border);border-radius:6px;font-size:0.9rem;color:var(--mr-text);background:var(--mr-input);transition:border-color 0.2s}
|
||||
.mr-field input::placeholder{color:#69707c}
|
||||
.mr-field input:focus,.mr-field select:focus{outline:none;border-color:var(--mr-accent);box-shadow:0 0 0 3px rgba(42,105,184,0.25)}
|
||||
.mr-field .mr-hint{font-size:0.8rem;color:var(--mr-muted);margin-top:0.2rem}
|
||||
.mr-row{display:flex;gap:1rem}
|
||||
.mr-row .mr-field{flex:1}
|
||||
|
||||
/* Buttons */
|
||||
.mr-btn{display:inline-flex;align-items:center;gap:0.4rem;padding:0.65rem 1.5rem;border:none;border-radius:6px;font-size:0.9rem;font-weight:600;cursor:pointer;transition:all 0.2s}
|
||||
.mr-btn:disabled{opacity:0.5;cursor:not-allowed}
|
||||
.mr-btn-primary{background:#2563eb;color:#fff}
|
||||
.mr-btn-primary:hover:not(:disabled){background:#1d4ed8}
|
||||
.mr-btn-success{background:#16a34a;color:#fff}
|
||||
.mr-btn-success:hover:not(:disabled){background:#15803d}
|
||||
.mr-btn-danger{background:#dc2626;color:#fff}
|
||||
.mr-btn-danger:hover:not(:disabled){background:#b91c1c}
|
||||
.mr-btn-outline{background:transparent;color:#2563eb;border:1px solid #2563eb}
|
||||
.mr-btn-outline:hover:not(:disabled){background:#eff6ff}
|
||||
.mr-actions{display:flex;justify-content:space-between;align-items:center;margin-top:1.5rem;padding-top:1rem;border-top:1px solid #e2e8f0}
|
||||
.mr-btn-primary{background:var(--mr-accent);color:#fff}
|
||||
.mr-btn-primary:hover:not(:disabled){filter:brightness(1.15)}
|
||||
.mr-btn-success{background:var(--mr-success);color:#fff}
|
||||
.mr-btn-success:hover:not(:disabled){filter:brightness(1.15)}
|
||||
.mr-btn-danger{background:var(--mr-danger);color:#fff}
|
||||
.mr-btn-danger:hover:not(:disabled){filter:brightness(1.15)}
|
||||
.mr-btn-outline{background:transparent;color:#74c0fc;border:1px solid var(--mr-accent)}
|
||||
.mr-btn-outline:hover:not(:disabled){background:rgba(42,105,184,0.15)}
|
||||
.mr-actions{display:flex;justify-content:space-between;align-items:center;margin-top:1.5rem;padding-top:1rem;border-top:1px solid var(--mr-border)}
|
||||
|
||||
/* Check list */
|
||||
.mr-checks{list-style:none;margin:0;padding:0}
|
||||
.mr-checks li{display:flex;align-items:center;gap:0.75rem;padding:0.5rem 0;border-bottom:1px solid #f1f5f9;font-size:0.9rem}
|
||||
.mr-checks li{display:flex;align-items:center;gap:0.75rem;padding:0.5rem 0;border-bottom:1px solid var(--mr-border);font-size:0.9rem}
|
||||
.mr-checks li:last-child{border-bottom:none}
|
||||
.mr-check-icon{width:24px;height:24px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:0.75rem;font-weight:700;flex-shrink:0}
|
||||
.mr-check-ok{background:#dcfce7;color:#16a34a}
|
||||
.mr-check-warn{background:#fef9c3;color:#a16207}
|
||||
.mr-check-fail{background:#fef2f2;color:#dc2626}
|
||||
.mr-check-info{background:#e0f2fe;color:#0284c7}
|
||||
.mr-check-label{flex:1;font-weight:500}
|
||||
.mr-check-value{color:#64748b;font-size:0.85rem}
|
||||
.mr-check-hint{font-size:0.8rem;color:#94a3b8}
|
||||
.mr-check-ok{background:rgba(47,158,68,0.18);color:#69db7c}
|
||||
.mr-check-warn{background:rgba(240,180,41,0.18);color:#ffd43b}
|
||||
.mr-check-fail{background:rgba(224,49,49,0.18);color:#ff8787}
|
||||
.mr-check-info{background:rgba(42,105,184,0.18);color:#74c0fc}
|
||||
.mr-check-label{flex:1;font-weight:500;color:var(--mr-text)}
|
||||
.mr-check-value{color:var(--mr-muted);font-size:0.85rem}
|
||||
.mr-check-hint{font-size:0.8rem;color:var(--mr-muted)}
|
||||
|
||||
/* Alert */
|
||||
.mr-alert{padding:0.75rem 1rem;border-radius:6px;font-size:0.9rem;margin-bottom:1rem;display:flex;align-items:flex-start;gap:0.5rem}
|
||||
.mr-alert-warn{background:#fef3c7;color:#92400e;border:1px solid #fde68a}
|
||||
.mr-alert-danger{background:#fef2f2;color:#991b1b;border:1px solid #fecaca}
|
||||
.mr-alert-success{background:#f0fdf4;color:#166534;border:1px solid #bbf7d0}
|
||||
.mr-alert-info{background:#eff6ff;color:#1e40af;border:1px solid #bfdbfe}
|
||||
.mr-alert-warn{background:rgba(240,180,41,0.12);color:#ffe08a;border:1px solid rgba(240,180,41,0.35)}
|
||||
.mr-alert-danger{background:rgba(224,49,49,0.12);color:#ffc9c9;border:1px solid rgba(224,49,49,0.4)}
|
||||
.mr-alert-success{background:rgba(47,158,68,0.12);color:#b2f2bb;border:1px solid rgba(47,158,68,0.35)}
|
||||
.mr-alert-info{background:rgba(42,105,184,0.12);color:#a5d8ff;border:1px solid rgba(42,105,184,0.35)}
|
||||
|
||||
/* Progress */
|
||||
.mr-progress{background:#e2e8f0;border-radius:8px;overflow:hidden;height:8px;margin:1rem 0}
|
||||
.mr-progress-bar{height:100%;background:linear-gradient(90deg,#2563eb,#3b82f6);transition:width 0.4s;border-radius:8px}
|
||||
.mr-status{font-size:0.85rem;color:#64748b;min-height:1.2rem}
|
||||
.mr-progress{background:var(--mr-input);border-radius:8px;overflow:hidden;height:8px;margin:1rem 0}
|
||||
.mr-progress-bar{height:100%;background:linear-gradient(90deg,var(--mr-accent),var(--mr-accent2));transition:width 0.4s;border-radius:8px}
|
||||
.mr-status{font-size:0.85rem;color:var(--mr-muted);min-height:1.2rem}
|
||||
|
||||
/* Provisioning checkboxes */
|
||||
.mr-provision-list{list-style:none;padding:0;margin:0}
|
||||
.mr-provision-list li{display:flex;align-items:center;gap:0.75rem;padding:0.6rem 0.5rem;border-bottom:1px solid #f1f5f9;font-size:0.9rem;cursor:pointer;border-radius:4px}
|
||||
.mr-provision-list li:hover{background:#f8fafc}
|
||||
.mr-provision-list li{display:flex;align-items:center;gap:0.75rem;padding:0.6rem 0.5rem;border-bottom:1px solid var(--mr-border);font-size:0.9rem;cursor:pointer;border-radius:4px}
|
||||
.mr-provision-list li:hover{background:var(--mr-input)}
|
||||
.mr-provision-list li:last-child{border-bottom:none}
|
||||
.mr-provision-list input[type=checkbox]{width:18px;height:18px;accent-color:#2563eb}
|
||||
.mr-provision-desc{font-size:0.8rem;color:#94a3b8;margin-left:auto}
|
||||
.mr-provision-list input[type=checkbox]{width:18px;height:18px;accent-color:var(--mr-accent)}
|
||||
.mr-provision-desc{font-size:0.8rem;color:var(--mr-muted);margin-left:auto}
|
||||
|
||||
/* Log */
|
||||
.mr-log{background:#1e293b;color:#94a3b8;border-radius:8px;padding:1rem;font-family:'SF Mono',SFMono-Regular,Consolas,monospace;font-size:0.8rem;max-height:200px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;margin-top:1rem;display:none}
|
||||
.mr-log{background:#0d0f12;color:var(--mr-muted);border:1px solid var(--mr-border);border-radius:8px;padding:1rem;font-family:'SF Mono',SFMono-Regular,Consolas,monospace;font-size:0.8rem;max-height:200px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;margin-top:1rem;display:none}
|
||||
.mr-log.visible{display:block}
|
||||
|
||||
/* Footer */
|
||||
.mr-footer{text-align:center;padding:1.5rem;color:#94a3b8;font-size:0.8rem}
|
||||
.mr-footer a{color:#2563eb;text-decoration:none}
|
||||
.mr-footer{text-align:center;padding:1.5rem;color:var(--mr-muted);font-size:0.8rem}
|
||||
.mr-footer a{color:#74c0fc;text-decoration:none}
|
||||
|
||||
/* Spinner */
|
||||
.mr-spinner{display:inline-block;width:16px;height:16px;border:2px solid rgba(255,255,255,0.3);border-radius:50%;border-top-color:#fff;animation:spin 0.6s linear infinite}
|
||||
@@ -1629,11 +1644,11 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N
|
||||
<div class="mr-panel <?php echo $securityVerified ? '' : 'visible'; ?>" id="panel0">
|
||||
<h2>Security Verification</h2>
|
||||
<p class="mr-desc">To prevent unauthorized access, enter the security code from the file <code>mokorestore-security.php</code> in your site root.</p>
|
||||
<div style="border:1px solid #e2e8f0;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#f8fafc">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#334155;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<div style="border:1px solid #2a2f37;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#1e2229">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#cfd6df;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<span style="font-size:1.1rem">🔒</span> How to find the code
|
||||
</div>
|
||||
<ol style="margin:0;padding-left:1.25rem;color:#475569;font-size:0.9rem;line-height:1.6">
|
||||
<ol style="margin:0;padding-left:1.25rem;color:#9aa4b2;font-size:0.9rem;line-height:1.6">
|
||||
<li>Connect to your server via FTP, SSH, or file manager</li>
|
||||
<li>Open <code>mokorestore-security.php</code> in the site root directory</li>
|
||||
<li>Copy the 8-character code and enter it below</li>
|
||||
@@ -1666,7 +1681,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N
|
||||
<h2>Extract Backup</h2>
|
||||
<p class="mr-desc">Extract site-backup.zip into the current directory.</p>
|
||||
<div class="mr-field">
|
||||
<label>Archive Password <span style="font-weight:normal;color:#94a3b8">(leave blank if not encrypted)</span></label>
|
||||
<label>Archive Password <span style="font-weight:normal;color:#9aa4b2">(leave blank if not encrypted)</span></label>
|
||||
<input type="password" id="archivePassword" placeholder="Optional decryption password">
|
||||
</div>
|
||||
<div class="mr-progress"><div class="mr-progress-bar" id="extractProgress" style="width:0%"></div></div>
|
||||
@@ -1694,8 +1709,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N
|
||||
<strong>Merge</strong> = keep existing table, INSERT IGNORE new rows.
|
||||
<strong>Data Only</strong> = keep schema, INSERT data as-is (assumes matching structure).
|
||||
</div>
|
||||
<div id="tableResolutionList" style="max-height:400px;overflow-y:auto;border:1px solid #e2e8f0;border-radius:8px;margin-top:1rem">
|
||||
<div style="padding:1rem;color:#94a3b8;text-align:center">Scanning tables...</div>
|
||||
<div id="tableResolutionList" style="max-height:400px;overflow-y:auto;border:1px solid #2a2f37;border-radius:8px;margin-top:1rem">
|
||||
<div style="padding:1rem;color:#9aa4b2;text-align:center">Scanning tables...</div>
|
||||
</div>
|
||||
<input type="hidden" id="tableResolutions" value="{}">
|
||||
<div class="mr-status" id="tableScanStatus"></div>
|
||||
@@ -1735,21 +1750,21 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N
|
||||
<h2>Site Configuration</h2>
|
||||
<p class="mr-desc">Configure your site settings. Credentials were removed from the backup for security — enter the correct values for this server.</p>
|
||||
|
||||
<div style="border:1px solid #e2e8f0;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#f8fafc">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#334155;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<div style="border:1px solid #2a2f37;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#1e2229">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#cfd6df;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<span style="font-size:1.1rem">🌐</span> General
|
||||
</div>
|
||||
<div class="mr-field"><label>Site Name</label><input type="text" id="siteName" value="Joomla Site"></div>
|
||||
<div class="mr-field">
|
||||
<label>Live Site URL <span style="font-weight:normal;color:#94a3b8">(optional)</span></label>
|
||||
<label>Live Site URL <span style="font-weight:normal;color:#9aa4b2">(optional)</span></label>
|
||||
<input type="text" id="liveSite" placeholder="https://example.com">
|
||||
<div class="mr-hint">Leave blank to auto-detect. Set this if using a reverse proxy or custom domain.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="border:1px solid #e2e8f0;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#f8fafc">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#334155;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<span style="font-size:1.1rem">✉</span> Mail / SMTP <span style="font-weight:normal;font-size:0.8rem;color:#94a3b8">— leave blank if using PHP mail()</span>
|
||||
<div style="border:1px solid #2a2f37;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#1e2229">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#cfd6df;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<span style="font-size:1.1rem">✉</span> Mail / SMTP <span style="font-weight:normal;font-size:0.8rem;color:#9aa4b2">— leave blank if using PHP mail()</span>
|
||||
</div>
|
||||
<div class="mr-field"><label>SMTP Host</label><input type="text" id="smtpHost" placeholder="smtp.example.com"></div>
|
||||
<div class="mr-row">
|
||||
@@ -1758,8 +1773,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica N
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="border:1px solid #e2e8f0;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#f8fafc">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#334155;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<div style="border:1px solid #2a2f37;border-radius:8px;padding:1.25rem;margin-bottom:1.25rem;background:#1e2229">
|
||||
<div style="font-weight:600;font-size:0.9rem;color:#cfd6df;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem">
|
||||
<span style="font-size:1.1rem">🛠</span> Server
|
||||
</div>
|
||||
<div class="mr-field" style="display:flex;align-items:center;gap:0.5rem">
|
||||
@@ -2031,7 +2046,7 @@ async function runPreflight() {
|
||||
li.appendChild(val);
|
||||
if (c.warn && c.hint) {
|
||||
var hint = document.createElement('div');
|
||||
hint.style.cssText = 'font-size:0.85em;color:#a16207;margin-top:4px;padding:4px 8px;background:#fef9c3;border-radius:4px;';
|
||||
hint.style.cssText = 'font-size:0.85em;color:#ffd43b;margin-top:4px;padding:4px 8px;background:rgba(240,180,41,0.12);border-radius:4px;';
|
||||
hint.textContent = c.hint;
|
||||
li.appendChild(hint);
|
||||
}
|
||||
@@ -2113,7 +2128,7 @@ async function scanTables() {
|
||||
const r = await post('scanTables');
|
||||
|
||||
if (!r.success || !r.tables || r.tables.length === 0) {
|
||||
container.innerHTML = '<div style="padding:1rem;color:#94a3b8;text-align:center">No tables found in database.sql (or file not present). You can skip this step.</div>';
|
||||
container.innerHTML = '<div style="padding:1rem;color:#9aa4b2;text-align:center">No tables found in database.sql (or file not present). You can skip this step.</div>';
|
||||
setStatus('tableScanStatus', r.tables ? 'No tables found' : (r.message || 'Scan failed'), r.success ? '' : 'error');
|
||||
log(r.message || 'No tables found');
|
||||
return;
|
||||
@@ -2134,16 +2149,16 @@ function renderTableList() {
|
||||
|
||||
tableList.forEach(function(name) {
|
||||
var row = document.createElement('div');
|
||||
row.style.cssText = 'display:flex;align-items:center;justify-content:space-between;padding:0.5rem 0.75rem;border-bottom:1px solid #f1f5f9;font-size:0.85rem;';
|
||||
row.style.cssText = 'display:flex;align-items:center;justify-content:space-between;padding:0.5rem 0.75rem;border-bottom:1px solid #2a2f37;font-size:0.85rem;';
|
||||
|
||||
var label = document.createElement('span');
|
||||
label.style.cssText = 'font-family:monospace;color:#334155;word-break:break-all;flex:1;margin-right:0.75rem;';
|
||||
label.style.cssText = 'font-family:monospace;color:#cfd6df;word-break:break-all;flex:1;margin-right:0.75rem;';
|
||||
label.textContent = name;
|
||||
|
||||
var sel = document.createElement('select');
|
||||
sel.dataset.table = name;
|
||||
sel.className = 'table-mode-select';
|
||||
sel.style.cssText = 'padding:0.3rem 0.5rem;border:1px solid #d1d5db;border-radius:4px;font-size:0.8rem;min-width:120px;background:#fff;';
|
||||
sel.style.cssText = 'padding:0.3rem 0.5rem;border:1px solid #2a2f37;border-radius:4px;font-size:0.8rem;min-width:120px;background:var(--mr-input);';
|
||||
|
||||
var modes = [
|
||||
['replace', 'Replace'],
|
||||
|
||||
@@ -153,7 +153,7 @@ class NotificationSender
|
||||
private static function sendNtfy(object $profile, object $record, bool $success): bool
|
||||
{
|
||||
$topic = trim($profile->ntfy_topic ?? '');
|
||||
$server = trim($profile->ntfy_server ?? 'https://ntfy.sh');
|
||||
$server = trim($profile->ntfy_server ?? 'https://ntfy.mokoconsulting.tech');
|
||||
$token = trim($profile->ntfy_token ?? '');
|
||||
|
||||
if ($topic === '') {
|
||||
@@ -428,7 +428,7 @@ class NotificationSender
|
||||
private static function sendRestoreNtfy(object $profile, string $type, array $details): bool
|
||||
{
|
||||
$topic = trim($profile->ntfy_topic ?? '');
|
||||
$server = trim($profile->ntfy_server ?? 'https://ntfy.sh');
|
||||
$server = trim($profile->ntfy_server ?? 'https://ntfy.mokoconsulting.tech');
|
||||
$token = trim($profile->ntfy_token ?? '');
|
||||
|
||||
if ($topic === '') {
|
||||
|
||||
@@ -122,6 +122,8 @@ class RestoreEngine
|
||||
}
|
||||
|
||||
// Step 4: Import database
|
||||
$dbErrorCount = 0;
|
||||
|
||||
if ($restoreDb) {
|
||||
$sqlFile = $this->stagingDir . '/database.sql';
|
||||
|
||||
@@ -130,6 +132,16 @@ class RestoreEngine
|
||||
$importer = new DatabaseImporter();
|
||||
$tableCount = $importer->import($sqlFile);
|
||||
$this->log('Database imported: ' . $tableCount . ' statements executed');
|
||||
|
||||
if ($importer->hasErrors()) {
|
||||
$dbErrors = $importer->getErrors();
|
||||
$dbErrorCount = count($dbErrors);
|
||||
$this->log('WARNING: ' . $dbErrorCount . ' database statement(s) FAILED during import — the database may be incomplete:');
|
||||
|
||||
foreach (array_slice($dbErrors, 0, 5) as $err) {
|
||||
$this->log(' - ' . substr($err, 0, 200));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->log('No database.sql found in archive — skipping database restore');
|
||||
}
|
||||
@@ -172,7 +184,10 @@ class RestoreEngine
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Restore complete from: ' . basename($archivePath),
|
||||
'warning' => $dbErrorCount > 0,
|
||||
'message' => $dbErrorCount > 0
|
||||
? 'Restore finished, but ' . $dbErrorCount . ' database statement(s) failed — the database may be incomplete. Check the log.'
|
||||
: 'Restore complete from: ' . basename($archivePath),
|
||||
'log' => implode("\n", $this->log),
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@@ -185,15 +185,25 @@ class SteppedRestoreEngine
|
||||
break;
|
||||
|
||||
case 'complete':
|
||||
$sqlErrors = (int) ($restoreState['sql_errors'] ?? 0);
|
||||
|
||||
$this->destroyRestoreState($sessionId);
|
||||
$session->destroy();
|
||||
|
||||
$completeMsg = 'Restore complete: ' . $session->archiveName;
|
||||
|
||||
if ($sqlErrors > 0) {
|
||||
$completeMsg .= ' — WARNING: ' . $sqlErrors
|
||||
. ' database statement(s) failed during import; the restored database may be incomplete. Check the site log.';
|
||||
}
|
||||
|
||||
return [
|
||||
'session_id' => $sessionId,
|
||||
'phase' => 'complete',
|
||||
'progress' => 100,
|
||||
'message' => 'Restore complete: ' . $session->archiveName,
|
||||
'message' => $completeMsg,
|
||||
'done' => true,
|
||||
'sql_errors' => $sqlErrors,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -230,6 +240,39 @@ class SteppedRestoreEngine
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel an in-progress restore: delete the staging directory and the
|
||||
* session/state files so a client-side cancel does not leave orphaned
|
||||
* artefacts (staging dir + *.restore.json) behind. Best-effort — a missing
|
||||
* or already-finished session is treated as success.
|
||||
*
|
||||
* @param string $sessionId The stepped-restore session id
|
||||
*
|
||||
* @return array ['error' => bool, 'message' => string]
|
||||
*/
|
||||
public function cancel(string $sessionId): array
|
||||
{
|
||||
$restoreState = $this->loadRestoreState($sessionId);
|
||||
|
||||
if ($restoreState !== null) {
|
||||
$stagingDir = $restoreState['staging_dir'] ?? '';
|
||||
|
||||
if (!empty($stagingDir) && is_dir($stagingDir)) {
|
||||
$this->recursiveDelete($stagingDir);
|
||||
}
|
||||
}
|
||||
|
||||
$this->destroyRestoreState($sessionId);
|
||||
|
||||
$session = SteppedSession::load($sessionId);
|
||||
|
||||
if ($session) {
|
||||
$session->destroy();
|
||||
}
|
||||
|
||||
return ['error' => false, 'message' => 'Restore cancelled'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract phase: extract archive to staging directory.
|
||||
*/
|
||||
@@ -480,34 +523,37 @@ class SteppedRestoreEngine
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$trimmed = trim($line);
|
||||
|
||||
// Skip empty lines
|
||||
if ($trimmed === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip single-line comments
|
||||
if (str_starts_with($trimmed, '--') || str_starts_with($trimmed, '#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle multi-line comments
|
||||
if (str_starts_with($trimmed, '/*')) {
|
||||
$inMultiLineComment = true;
|
||||
}
|
||||
|
||||
if ($inMultiLineComment) {
|
||||
if (str_contains($trimmed, '*/')) {
|
||||
$inMultiLineComment = false;
|
||||
// Comment/blank skipping applies only BETWEEN statements — never inside
|
||||
// an accumulating statement, where a line may be part of a multi-line
|
||||
// string value that happens to start with --, # or /*.
|
||||
if ($currentStatement === '') {
|
||||
if ($trimmed === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
if (str_starts_with($trimmed, '--') || str_starts_with($trimmed, '#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_starts_with($trimmed, '/*')) {
|
||||
$inMultiLineComment = true;
|
||||
}
|
||||
|
||||
if ($inMultiLineComment) {
|
||||
if (str_contains($trimmed, '*/')) {
|
||||
$inMultiLineComment = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Accumulate the statement
|
||||
$currentStatement .= $line;
|
||||
|
||||
// Check if statement is complete (ends with semicolon)
|
||||
if (str_ends_with($trimmed, ';')) {
|
||||
// A statement ends at a ';' that is NOT inside a quoted string literal,
|
||||
// so a ';' or newline embedded in a value does not split it prematurely.
|
||||
if ($this->isCompleteStatement($currentStatement)) {
|
||||
$statement = trim($currentStatement);
|
||||
$currentStatement = '';
|
||||
|
||||
@@ -522,7 +568,7 @@ class SteppedRestoreEngine
|
||||
$db->setQuery($statement);
|
||||
$db->execute();
|
||||
} catch (\Exception $e) {
|
||||
error_log('MokoSuiteBackup SQL import warning: ' . $e->getMessage());
|
||||
$this->recordSqlError($state, $e->getMessage());
|
||||
}
|
||||
|
||||
$statementsExecuted++;
|
||||
@@ -553,7 +599,7 @@ class SteppedRestoreEngine
|
||||
$db->execute();
|
||||
$state['sql_executed']++;
|
||||
} catch (\Exception $e) {
|
||||
error_log('MokoSuiteBackup SQL import warning (final): ' . $e->getMessage());
|
||||
$this->recordSqlError($state, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,8 +608,78 @@ class SteppedRestoreEngine
|
||||
$state['sql_done'] = true;
|
||||
$session->currentStep++;
|
||||
$session->phase = 'config';
|
||||
$session->statusMessage = 'Database import complete: ' . $state['sql_executed'] . ' statements';
|
||||
$session->log('Database import complete: ' . $state['sql_executed'] . ' statements executed');
|
||||
|
||||
$sqlErrors = (int) ($state['sql_errors'] ?? 0);
|
||||
$doneMsg = 'Database import complete: ' . $state['sql_executed'] . ' statements'
|
||||
. ($sqlErrors > 0 ? ' (' . $sqlErrors . ' statement(s) FAILED — see log)' : '');
|
||||
$session->statusMessage = $doneMsg;
|
||||
$session->log($doneMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether an accumulated SQL string is a complete statement: it
|
||||
* ends with ';' that is NOT inside a quoted string literal. Tracks single,
|
||||
* double and backtick quoting (with backslash escapes; MySQL '' doubling
|
||||
* falls out of the toggle naturally) so a ';' or newline inside a value does
|
||||
* not terminate the statement early.
|
||||
*/
|
||||
private function isCompleteStatement(string $sql): bool
|
||||
{
|
||||
$len = \strlen($sql);
|
||||
$inSingle = false;
|
||||
$inDouble = false;
|
||||
$inBacktick = false;
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$ch = $sql[$i];
|
||||
|
||||
if ($inSingle) {
|
||||
if ($ch === '\\') { $i++; continue; }
|
||||
if ($ch === "'") { $inSingle = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($inDouble) {
|
||||
if ($ch === '\\') { $i++; continue; }
|
||||
if ($ch === '"') { $inDouble = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($inBacktick) {
|
||||
if ($ch === '`') { $inBacktick = false; }
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ch === "'") { $inSingle = true; }
|
||||
elseif ($ch === '"') { $inDouble = true; }
|
||||
elseif ($ch === '`') { $inBacktick = true; }
|
||||
}
|
||||
|
||||
// If we ended inside a string literal, the statement is not finished yet.
|
||||
if ($inSingle || $inDouble || $inBacktick) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str_ends_with(rtrim($sql), ';');
|
||||
}
|
||||
|
||||
/**
|
||||
* Record a failed SQL statement in the restore state (count + first few
|
||||
* messages) so a partial import is surfaced instead of silently passing.
|
||||
*/
|
||||
private function recordSqlError(array &$state, string $message): void
|
||||
{
|
||||
$state['sql_errors'] = (int) ($state['sql_errors'] ?? 0) + 1;
|
||||
|
||||
if (!isset($state['sql_error_list']) || !\is_array($state['sql_error_list'])) {
|
||||
$state['sql_error_list'] = [];
|
||||
}
|
||||
|
||||
if (\count($state['sql_error_list']) < 5) {
|
||||
$state['sql_error_list'][] = substr($message, 0, 200);
|
||||
}
|
||||
|
||||
error_log('MokoSuiteBackup SQL import error: ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -171,6 +171,11 @@ class SteppedSession
|
||||
|
||||
/**
|
||||
* Clean up old session files (older than 24 hours).
|
||||
*
|
||||
* Reaps backup + restore session state (mb_*.json covers both the
|
||||
* `<id>.json` and `<id>.restore.json` files) and, as a backstop for
|
||||
* restores abandoned without a cancel (e.g. the browser was just closed),
|
||||
* any orphaned restore staging directories left in the tmp folder.
|
||||
*/
|
||||
public static function cleanupOldSessions(): void
|
||||
{
|
||||
@@ -182,10 +187,42 @@ class SteppedSession
|
||||
|
||||
$cutoff = time() - 86400;
|
||||
|
||||
foreach (glob($dir . '/mb_*.json') as $file) {
|
||||
foreach (glob($dir . '/mb_*.json') ?: [] as $file) {
|
||||
if (filemtime($file) < $cutoff) {
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
// Orphaned restore staging directories (mokosuitebackup-restore-<tag>-<id>).
|
||||
foreach (glob(JPATH_ROOT . '/tmp/mokosuitebackup-restore-*', GLOB_ONLYDIR) ?: [] as $stagingDir) {
|
||||
if (@filemtime($stagingDir) < $cutoff) {
|
||||
self::recursiveDelete($stagingDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a directory (used to reap orphaned restore staging dirs).
|
||||
*/
|
||||
private static function recursiveDelete(string $dir): void
|
||||
{
|
||||
if ($dir === '' || !is_dir($dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$items = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->isDir()) {
|
||||
@rmdir($item->getPathname());
|
||||
} else {
|
||||
@unlink($item->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ $canDownload = $user->authorise('mokosuitebackup.backup.download', 'com_mokosuit
|
||||
|
||||
$ajaxToken = Session::getFormToken();
|
||||
$ajaxUrl = Route::_('index.php?option=com_mokosuitebackup&format=json', false);
|
||||
// Template for the "View backup record" button on the progress modal (__MSBID__ swapped in JS).
|
||||
$recordUrlTpl = Route::_('index.php?option=com_mokosuitebackup&view=backup&id=__MSBID__', false);
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
@@ -146,8 +148,8 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title" id="mb-modal-title">
|
||||
<span class="icon-archive" aria-hidden="true"></span>
|
||||
Backup in Progress
|
||||
<span class="icon-archive" aria-hidden="true" id="mb-modal-icon"></span>
|
||||
<span id="mb-modal-titletext">Backup in Progress</span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@@ -160,6 +162,23 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
</div>
|
||||
<p id="mb-status" class="msb-pm-status">Initializing...</p>
|
||||
<p id="mb-phase" class="msb-pm-phase">Phase: init</p>
|
||||
|
||||
<div class="msb-pm-autocontinue" id="mb-autocontinue-wrap">
|
||||
<label>
|
||||
<input type="checkbox" id="mb-autocontinue" checked>
|
||||
Automatically return to the backups list when the backup finishes
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="msb-pm-actions d-none" id="mb-actions">
|
||||
<button type="button" id="mb-retry" class="btn btn-primary d-none">Retry backup</button>
|
||||
<a href="#" id="mb-record" class="btn btn-primary d-none" target="_blank" rel="noopener">View backup record</a>
|
||||
<button type="button" id="mb-done" class="btn btn-secondary d-none">Back to backups</button>
|
||||
</div>
|
||||
|
||||
<div class="msb-pm-cancel" id="mb-cancel-wrap">
|
||||
<button type="button" id="mb-cancel" class="btn btn-outline-danger">Cancel backup</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -231,25 +250,111 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// --- Progress-modal controls (auto-continue, cancel, terminal buttons) ---
|
||||
var RECORD_URL = <?php echo json_encode($recordUrlTpl); ?>;
|
||||
var mbRecordId = 0;
|
||||
var mbCancelled = false;
|
||||
|
||||
function mbEl(id) { return document.getElementById(id); }
|
||||
function mbShow(n) { if (n) { n.classList.remove('d-none'); } }
|
||||
function mbHide(n) { if (n) { n.classList.add('d-none'); } }
|
||||
|
||||
// Update the modal title's icon + text without innerHTML (values are static).
|
||||
function setBackupTitle(iconClass, text) {
|
||||
var ic = mbEl('mb-modal-icon');
|
||||
if (ic) { ic.className = iconClass; }
|
||||
var tx = mbEl('mb-modal-titletext');
|
||||
if (tx) { tx.textContent = text; }
|
||||
}
|
||||
|
||||
// Reset to the "running" control state (cancel + auto-continue visible, no actions).
|
||||
function mbRunningControls() {
|
||||
mbHide(mbEl('mb-actions'));
|
||||
mbHide(mbEl('mb-retry'));
|
||||
mbHide(mbEl('mb-record'));
|
||||
mbHide(mbEl('mb-done'));
|
||||
mbShow(mbEl('mb-cancel-wrap'));
|
||||
mbShow(mbEl('mb-autocontinue-wrap'));
|
||||
if (mbEl('mb-cancel')) { mbEl('mb-cancel').disabled = false; }
|
||||
}
|
||||
|
||||
// Switch out of the "running" control state (hide cancel + auto-continue).
|
||||
function mbTerminalControls() {
|
||||
backupRunning = false;
|
||||
mbHide(mbEl('mb-cancel-wrap'));
|
||||
mbHide(mbEl('mb-autocontinue-wrap'));
|
||||
}
|
||||
|
||||
function leaveToList() { hideModal(); location.reload(); }
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var doneBtn = mbEl('mb-done');
|
||||
if (doneBtn) { doneBtn.addEventListener('click', leaveToList); }
|
||||
|
||||
// Cancel: double confirmation, then stop the loop and cancel the record.
|
||||
var cancelBtn = mbEl('mb-cancel');
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function() {
|
||||
if (!backupRunning || mbCancelled) { return; }
|
||||
if (!confirm('Cancel the backup that is in progress?')) { return; }
|
||||
if (!confirm('Are you sure? The backup will be stopped.')) { return; }
|
||||
mbCancelled = true;
|
||||
backupRunning = false;
|
||||
cancelBtn.disabled = true;
|
||||
document.getElementById('mb-status').textContent = 'Cancelling…';
|
||||
if (mbRecordId > 0) {
|
||||
postAjax({ task: 'ajax.cancelBackup', id: mbRecordId }).then(leaveToList, leaveToList);
|
||||
} else {
|
||||
leaveToList();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function backupComplete() {
|
||||
updateProgress(100, 'Backup complete.', 'complete');
|
||||
setBackupTitle('icon-check', 'Backup Complete');
|
||||
mbTerminalControls();
|
||||
// Auto-continue: return to the list automatically unless the user opted out.
|
||||
if (mbEl('mb-autocontinue') && mbEl('mb-autocontinue').checked) {
|
||||
setTimeout(leaveToList, 1500);
|
||||
return;
|
||||
}
|
||||
mbShow(mbEl('mb-actions'));
|
||||
mbShow(mbEl('mb-done'));
|
||||
if (mbRecordId > 0 && RECORD_URL) {
|
||||
var rec = mbEl('mb-record');
|
||||
rec.setAttribute('href', RECORD_URL.replace('__MSBID__', String(mbRecordId)));
|
||||
mbShow(rec);
|
||||
}
|
||||
}
|
||||
|
||||
function backupFailed(message) {
|
||||
updateProgress(0, 'ERROR: ' + (message || 'Backup failed'), 'failed');
|
||||
setBackupTitle('icon-cancel', 'Backup Failed');
|
||||
mbTerminalControls();
|
||||
mbShow(mbEl('mb-actions'));
|
||||
mbShow(mbEl('mb-done'));
|
||||
var retry = mbEl('mb-retry');
|
||||
mbShow(retry);
|
||||
retry.onclick = function() { startSteppedBackup(); };
|
||||
}
|
||||
|
||||
async function startSteppedBackup() {
|
||||
const profileSelect = document.getElementById('mb-profile-select');
|
||||
const profileId = profileSelect ? profileSelect.value : '1';
|
||||
|
||||
mbRecordId = 0;
|
||||
mbCancelled = false;
|
||||
mbRunningControls();
|
||||
setBackupTitle('icon-archive', 'Backup in Progress');
|
||||
showModal();
|
||||
updateProgress(0, 'Initializing backup...', 'init');
|
||||
|
||||
try {
|
||||
// Init
|
||||
const initResult = await postAjax({
|
||||
task: 'ajax.init',
|
||||
profile_id: profileId
|
||||
});
|
||||
const initResult = await postAjax({ task: 'ajax.init', profile_id: profileId });
|
||||
|
||||
if (initResult.error) {
|
||||
updateProgress(0, 'ERROR: ' + initResult.message, 'failed');
|
||||
setTimeout(hideModal, 5000);
|
||||
return;
|
||||
}
|
||||
if (initResult.error) { backupFailed(initResult.message); return; }
|
||||
|
||||
// Show preflight warnings if any
|
||||
if (initResult.warnings && initResult.warnings.length > 0) {
|
||||
@@ -259,36 +364,25 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
}
|
||||
|
||||
const sessionId = initResult.session_id;
|
||||
if (initResult.record_id) { mbRecordId = initResult.record_id; }
|
||||
updateProgress(initResult.progress, initResult.message, initResult.phase);
|
||||
|
||||
// Run steps until done
|
||||
// Run steps until done (or cancelled)
|
||||
let done = false;
|
||||
while (!done) {
|
||||
const stepResult = await postAjax({
|
||||
task: 'ajax.step',
|
||||
session_id: sessionId
|
||||
});
|
||||
|
||||
if (stepResult.error) {
|
||||
updateProgress(0, 'ERROR: ' + stepResult.message, 'failed');
|
||||
setTimeout(hideModal, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!done && !mbCancelled) {
|
||||
const stepResult = await postAjax({ task: 'ajax.step', session_id: sessionId });
|
||||
if (stepResult.error) { backupFailed(stepResult.message); return; }
|
||||
if (stepResult.record_id) { mbRecordId = stepResult.record_id; }
|
||||
updateProgress(stepResult.progress, stepResult.message, stepResult.phase);
|
||||
done = stepResult.done || false;
|
||||
}
|
||||
|
||||
// Complete
|
||||
document.getElementById('mb-modal-title').textContent = 'Backup Complete';
|
||||
setTimeout(function() {
|
||||
hideModal();
|
||||
location.reload();
|
||||
}, 2000);
|
||||
if (mbCancelled) { return; }
|
||||
backupComplete();
|
||||
|
||||
} catch (err) {
|
||||
updateProgress(0, 'ERROR: ' + err.message, 'failed');
|
||||
setTimeout(hideModal, 5000);
|
||||
if (mbCancelled) { return; }
|
||||
backupFailed(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,8 +412,10 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
|
||||
// Close restore modal handled by Bootstrap data-bs-dismiss
|
||||
|
||||
// AJAX stepped restore
|
||||
var restoreRunning = false;
|
||||
// --- AJAX stepped restore (controls mirror the backup-progress modal) ---
|
||||
var restoreRunning = false;
|
||||
var restoreCancelled = false;
|
||||
var restoreSessionId = '';
|
||||
|
||||
function showRestoreProgress() {
|
||||
restoreRunning = true;
|
||||
@@ -332,6 +428,31 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
bootstrap.Modal.getInstance(document.getElementById('mb-restore-progress-modal'))?.hide();
|
||||
}
|
||||
|
||||
// Update the restore title's icon + text without innerHTML (values are static).
|
||||
function setRestoreTitle(iconClass, text) {
|
||||
var ic = mbEl('mb-restore-icon');
|
||||
if (ic) { ic.className = iconClass; }
|
||||
var tx = mbEl('mb-restore-titletext');
|
||||
if (tx) { tx.textContent = text; }
|
||||
}
|
||||
|
||||
function restoreRunningControls() {
|
||||
mbHide(mbEl('mb-restore-actions'));
|
||||
mbHide(mbEl('mb-restore-retry'));
|
||||
mbHide(mbEl('mb-restore-done'));
|
||||
mbShow(mbEl('mb-restore-cancel-wrap'));
|
||||
mbShow(mbEl('mb-restore-autocontinue-wrap'));
|
||||
if (mbEl('mb-restore-cancel')) { mbEl('mb-restore-cancel').disabled = false; }
|
||||
}
|
||||
|
||||
function restoreTerminalControls() {
|
||||
restoreRunning = false;
|
||||
mbHide(mbEl('mb-restore-cancel-wrap'));
|
||||
mbHide(mbEl('mb-restore-autocontinue-wrap'));
|
||||
}
|
||||
|
||||
function leaveRestoreToList() { hideRestoreProgress(); location.reload(); }
|
||||
|
||||
function updateRestoreProgress(progress, message, phase) {
|
||||
var bar = document.getElementById('mb-restore-progress-bar');
|
||||
bar.style.width = progress + '%';
|
||||
@@ -348,15 +469,79 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
}
|
||||
});
|
||||
|
||||
async function startSteppedRestore(e) {
|
||||
e.preventDefault();
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var doneBtn = mbEl('mb-restore-done');
|
||||
if (doneBtn) { doneBtn.addEventListener('click', leaveRestoreToList); }
|
||||
|
||||
// Cancel: double confirmation. A restore cannot be rolled back mid-flight,
|
||||
// so the second prompt warns that the site may be left partially restored.
|
||||
var cancelBtn = mbEl('mb-restore-cancel');
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function() {
|
||||
if (!restoreRunning || restoreCancelled) { return; }
|
||||
if (!confirm('Cancel the restore that is in progress?')) { return; }
|
||||
if (!confirm('Are you sure? Stopping mid-restore may leave the site partially restored.')) { return; }
|
||||
restoreCancelled = true;
|
||||
restoreRunning = false;
|
||||
cancelBtn.disabled = true;
|
||||
document.getElementById('mb-restore-status').textContent = 'Cancelling…';
|
||||
// Tell the server to clean up the staging dir + session state, then leave.
|
||||
if (restoreSessionId) {
|
||||
postAjax({ task: 'ajax.restoreCancel', session_id: restoreSessionId }).then(leaveRestoreToList, leaveRestoreToList);
|
||||
} else {
|
||||
leaveRestoreToList();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function restoreComplete(result) {
|
||||
var sqlErrors = (result && result.sql_errors) ? result.sql_errors : 0;
|
||||
|
||||
if (sqlErrors > 0) {
|
||||
// Partial DB import — surface the warning and do NOT auto-return, so the
|
||||
// admin actually sees that the restored database may be incomplete.
|
||||
updateRestoreProgress(100, (result && result.message) || 'Restore finished, but some database statements failed.', 'complete');
|
||||
setRestoreTitle('icon-warning', 'Restore Complete (with warnings)');
|
||||
restoreTerminalControls();
|
||||
mbShow(mbEl('mb-restore-actions'));
|
||||
mbShow(mbEl('mb-restore-done'));
|
||||
return;
|
||||
}
|
||||
|
||||
updateRestoreProgress(100, 'Restore complete.', 'complete');
|
||||
setRestoreTitle('icon-check', 'Restore Complete');
|
||||
restoreTerminalControls();
|
||||
if (mbEl('mb-restore-autocontinue') && mbEl('mb-restore-autocontinue').checked) {
|
||||
setTimeout(leaveRestoreToList, 1500);
|
||||
return;
|
||||
}
|
||||
mbShow(mbEl('mb-restore-actions'));
|
||||
mbShow(mbEl('mb-restore-done'));
|
||||
}
|
||||
|
||||
function restoreFailed(message) {
|
||||
updateRestoreProgress(0, 'ERROR: ' + (message || 'Restore failed'), 'failed');
|
||||
setRestoreTitle('icon-cancel', 'Restore Failed');
|
||||
restoreTerminalControls();
|
||||
mbShow(mbEl('mb-restore-actions'));
|
||||
mbShow(mbEl('mb-restore-done'));
|
||||
var retry = mbEl('mb-restore-retry');
|
||||
mbShow(retry);
|
||||
retry.onclick = function() { runSteppedRestore(); };
|
||||
}
|
||||
|
||||
async function runSteppedRestore() {
|
||||
var recordId = document.getElementById('mb-restore-record-id').value;
|
||||
var restoreFiles = document.getElementById('mb-restore-files').checked ? 1 : 0;
|
||||
var restoreDb = document.getElementById('mb-restore-db').checked ? 1 : 0;
|
||||
var preserveConfig = document.getElementById('mb-restore-config').checked ? 1 : 0;
|
||||
var password = document.getElementById('mb-restore-password').value;
|
||||
|
||||
restoreCancelled = false;
|
||||
restoreSessionId = '';
|
||||
restoreRunningControls();
|
||||
setRestoreTitle('icon-refresh', 'Restore in Progress');
|
||||
showRestoreProgress();
|
||||
updateRestoreProgress(0, 'Initializing restore...', 'init');
|
||||
|
||||
@@ -370,47 +555,36 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
encryption_password: password
|
||||
});
|
||||
|
||||
if (initResult.error) {
|
||||
updateRestoreProgress(0, 'ERROR: ' + initResult.message, 'failed');
|
||||
document.getElementById('mb-restore-title').textContent = 'Restore Failed';
|
||||
setTimeout(hideRestoreProgress, 5000);
|
||||
return;
|
||||
}
|
||||
if (initResult.error) { restoreFailed(initResult.message); return; }
|
||||
|
||||
var sessionId = initResult.session_id;
|
||||
restoreSessionId = sessionId;
|
||||
updateRestoreProgress(initResult.progress, initResult.message, initResult.phase);
|
||||
|
||||
var done = false;
|
||||
while (!done) {
|
||||
var stepResult = await postAjax({
|
||||
task: 'ajax.restoreStep',
|
||||
session_id: sessionId
|
||||
});
|
||||
|
||||
if (stepResult.error) {
|
||||
updateRestoreProgress(0, 'ERROR: ' + stepResult.message, 'failed');
|
||||
document.getElementById('mb-restore-title').textContent = 'Restore Failed';
|
||||
setTimeout(hideRestoreProgress, 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
var lastResult = null;
|
||||
while (!done && !restoreCancelled) {
|
||||
var stepResult = await postAjax({ task: 'ajax.restoreStep', session_id: sessionId });
|
||||
if (stepResult.error) { restoreFailed(stepResult.message); return; }
|
||||
updateRestoreProgress(stepResult.progress, stepResult.message, stepResult.phase);
|
||||
lastResult = stepResult;
|
||||
done = stepResult.done || false;
|
||||
}
|
||||
|
||||
document.getElementById('mb-restore-title').textContent = 'Restore Complete';
|
||||
setTimeout(function() {
|
||||
hideRestoreProgress();
|
||||
location.reload();
|
||||
}, 2000);
|
||||
if (restoreCancelled) { return; }
|
||||
restoreComplete(lastResult);
|
||||
|
||||
} catch (err) {
|
||||
updateRestoreProgress(0, 'ERROR: ' + err.message, 'failed');
|
||||
document.getElementById('mb-restore-title').textContent = 'Restore Failed';
|
||||
setTimeout(hideRestoreProgress, 5000);
|
||||
if (restoreCancelled) { return; }
|
||||
restoreFailed(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
function startSteppedRestore(e) {
|
||||
e.preventDefault();
|
||||
runSteppedRestore();
|
||||
}
|
||||
|
||||
// Attach the AJAX restore handler to the restore form
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var restoreForm = document.getElementById('mb-restore-form');
|
||||
@@ -484,8 +658,8 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title" id="mb-restore-title">
|
||||
<span class="icon-refresh" aria-hidden="true"></span>
|
||||
Restore in Progress
|
||||
<span class="icon-refresh" aria-hidden="true" id="mb-restore-icon"></span>
|
||||
<span id="mb-restore-titletext">Restore in Progress</span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@@ -498,6 +672,22 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
</div>
|
||||
<p id="mb-restore-status" class="msb-pm-status">Initializing...</p>
|
||||
<p id="mb-restore-phase" class="msb-pm-phase">Phase: init</p>
|
||||
|
||||
<div class="msb-pm-autocontinue" id="mb-restore-autocontinue-wrap">
|
||||
<label>
|
||||
<input type="checkbox" id="mb-restore-autocontinue" checked>
|
||||
Automatically return to the backups list when the restore finishes
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="msb-pm-actions d-none" id="mb-restore-actions">
|
||||
<button type="button" id="mb-restore-retry" class="btn btn-primary d-none">Retry restore</button>
|
||||
<button type="button" id="mb-restore-done" class="btn btn-secondary d-none">Back to backups</button>
|
||||
</div>
|
||||
|
||||
<div class="msb-pm-cancel" id="mb-restore-cancel-wrap">
|
||||
<button type="button" id="mb-restore-cancel" class="btn btn-outline-danger">Cancel restore</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -447,7 +447,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
var label = document.createElement('label');
|
||||
label.className = 'form-check-label';
|
||||
label.setAttribute('for', 'mb-rtype-' + type);
|
||||
label.textContent = typeLabels[TYPE] || type;
|
||||
label.textContent = typeLabels[type] || type;
|
||||
|
||||
div.appendChild(input);
|
||||
div.appendChild(label);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
-->
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>Module - MokoSuiteBackup - cPanel</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-23</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="actionlog" method="upgrade">
|
||||
<name>Action Log - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-04</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="console" method="upgrade">
|
||||
<name>Console - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-04</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="content" method="upgrade">
|
||||
<name>Content - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-04</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="quickicon" method="upgrade">
|
||||
<name>Quick Icon - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
+36
-13
@@ -39,6 +39,34 @@ final class MokoSuiteBackupQuickicon extends CMSPlugin implements SubscriberInte
|
||||
return;
|
||||
}
|
||||
|
||||
// A dashboard quick-icon must NEVER be able to crash the whole admin page.
|
||||
// Build the icon defensively; on any failure, contribute nothing and log.
|
||||
try {
|
||||
$icon = $this->buildStatusIcon();
|
||||
} catch (\Throwable $e) {
|
||||
error_log('MokoSuiteBackup quickicon widget failed: ' . $e->getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The module (mod_quickicon) expects each plugin to append a LIST of icons
|
||||
// to the 'result' argument; it then iterates that list and array_merge()s a
|
||||
// defaults array into each icon. Appending a bare icon dict instead of a
|
||||
// [ list ] makes it iterate the dict's string values and crash in
|
||||
// array_merge — so the wrapping [$icon] here is load-bearing.
|
||||
$result = $event->getArgument('result', []);
|
||||
$result[] = [$icon];
|
||||
|
||||
$event->setArgument('result', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the single status quick-icon (backup freshness / failures).
|
||||
*
|
||||
* @return array A mod_quickicon icon definition.
|
||||
*/
|
||||
private function buildStatusIcon(): array
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Get last completed backup
|
||||
@@ -91,20 +119,15 @@ final class MokoSuiteBackupQuickicon extends CMSPlugin implements SubscriberInte
|
||||
$subtitle = $ago . ' | ' . ($stats->total ?? 0) . ' backups | ' . $sizeTotal . ' MB';
|
||||
}
|
||||
|
||||
$result = $event->getArgument('result', []);
|
||||
$result[] = [
|
||||
[
|
||||
'link' => 'index.php?option=com_mokosuitebackup&view=backups',
|
||||
'image' => $warning ? 'icon-warning' : 'icon-database',
|
||||
'icon' => $warning ? 'icon-warning' : 'icon-database',
|
||||
'text' => Text::_($text),
|
||||
'linkadd' => $subtitle ? '<br><small>' . htmlspecialchars($subtitle) . '</small>' : '',
|
||||
'id' => 'plg_quickicon_mokosuitebackup',
|
||||
'group' => 'MOD_QUICKICON_MAINTENANCE',
|
||||
],
|
||||
return [
|
||||
'link' => 'index.php?option=com_mokosuitebackup&view=backups',
|
||||
'image' => $warning ? 'icon-warning' : 'icon-database',
|
||||
'icon' => $warning ? 'icon-warning' : 'icon-database',
|
||||
'text' => Text::_($text),
|
||||
'linkadd' => $subtitle ? '<br><small>' . htmlspecialchars($subtitle) . '</small>' : '',
|
||||
'id' => 'plg_quickicon_mokosuitebackup',
|
||||
'group' => 'MOD_QUICKICON_MAINTENANCE',
|
||||
];
|
||||
|
||||
$event->setArgument('result', $result);
|
||||
}
|
||||
|
||||
private function timeAgo(string $datetime): string
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@ PLG_SYSTEM_MOKOJOOMBACKUP_BACKUP_FAILED="Backup failed"
|
||||
PLG_SYSTEM_MOKOJOOMBACKUP_BACKUP_STARTING="Starting backup…"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_UPDATE_RUNNING="Backup complete. The update is now running — please wait and do not close this window…"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_TITLE="Backup in progress"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_MESSAGE="A MokoSuiteBackup backup is currently running in another window. The administrator area is locked until it finishes — this page will refresh automatically. Please do not make changes while the backup runs."
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_MESSAGE="A MokoSuiteBackup is currently running in another window. The administrator area is locked until it finishes — this page will refresh automatically. Please do not make changes while the backup runs."
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@ PLG_SYSTEM_MOKOJOOMBACKUP_BACKUP_FAILED="Backup failed"
|
||||
PLG_SYSTEM_MOKOJOOMBACKUP_BACKUP_STARTING="Starting backup…"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_UPDATE_RUNNING="Backup complete. The update is now running — please wait and do not close this window…"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_TITLE="Backup in progress"
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_MESSAGE="A MokoSuiteBackup backup is currently running in another window. The administrator area is locked until it finishes — this page will refresh automatically. Please do not make changes while the backup runs."
|
||||
PLG_SYSTEM_MOKOSUITEBACKUP_LOCK_MESSAGE="A MokoSuiteBackup is currently running in another window. The administrator area is locked until it finishes — this page will refresh automatically. Please do not make changes while the backup runs."
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="system" method="upgrade">
|
||||
<name>System - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="task" method="upgrade">
|
||||
<name>Task - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
-->
|
||||
<extension type="plugin" group="webservices" method="upgrade">
|
||||
<name>Web Services - MokoSuiteBackup</name>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<extension type="package" method="upgrade">
|
||||
<name>Package - MokoSuiteBackup</name>
|
||||
<packagename>mokosuitebackup</packagename>
|
||||
<version>02.64.06</version>
|
||||
<version>02.64.13</version>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
|
||||
Reference in New Issue
Block a user