mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
1018 lines
44 KiB
HTML
1018 lines
44 KiB
HTML
<!-- manager/flarum.html -->
|
|
{% extends 'base.html' %}
|
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
<style>
|
|
.st1 {
|
|
fill: #192030;
|
|
}
|
|
|
|
|
|
/* Style for dark mode svg icons */
|
|
[data-skin="dark"] .st1 {
|
|
fill: #506fd9;
|
|
}
|
|
</style>
|
|
|
|
|
|
<style>
|
|
.nije-link {
|
|
text-decoration: none;
|
|
color: black;
|
|
border-bottom: 1px dashed black;
|
|
}
|
|
|
|
.ikona:hover {
|
|
background: aliceblue;
|
|
}
|
|
|
|
|
|
#action_description p {
|
|
display: none;
|
|
margin-bottom: 0px;
|
|
margin-top: 1rem;
|
|
}
|
|
</style>
|
|
{% if current_domain %}
|
|
|
|
|
|
<div class="card">
|
|
<div class="row">
|
|
|
|
<div class="col-md-auto">
|
|
{% include 'partials/screenshot.html' %}
|
|
</div>
|
|
|
|
<div class="col">
|
|
<a href="#" onclick="updateScreenshot()" id="refresh_site_screenshot">
|
|
<i class="bi bi-arrow-clockwise" style="left: 15px;top: 15px;position: absolute; padding: 6px 10px;" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="Refresh website screenshot"></i>
|
|
</a>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text"> </small>
|
|
<p class="card-text">
|
|
<a href="#" id="purge_cache_button" class="btn btn-primary mb-3">
|
|
<span id="spinner" class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span>
|
|
<span id="button_purge_text">{{ _('Purge Cache') }}<span class="desktop-only"> <i class="bi bi-arrow-clockwise"></i></span></span>
|
|
</a>
|
|
|
|
|
|
<style>
|
|
/* Styles for desktop */
|
|
@media (min-width: 768px) {
|
|
#purge_cache_button {
|
|
/* Desktop-specific styles */
|
|
--bs-btn-padding-y: .5rem;
|
|
--bs-btn-padding-x: 1rem;
|
|
--bs-btn-font-size: 1.09375rem;
|
|
--bs-btn-border-radius: .5rem;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
|
|
<script>
|
|
var purgeCacheButton = document.getElementById('purge_cache_button');
|
|
var spinner = document.getElementById('spinner');
|
|
var buttonText = document.getElementById('button_purge_text');
|
|
|
|
// Function to handle the button click
|
|
purgeCacheButton.addEventListener('click', function (event) {
|
|
event.preventDefault(); // Prevent the default anchor behavior
|
|
|
|
// Disable the button
|
|
purgeCacheButton.disabled = true;
|
|
// Show the loading spinner
|
|
spinner.classList.remove('d-none');
|
|
// Change the button text to "Purging.."
|
|
buttonText.textContent = 'Purging..';
|
|
|
|
// Send an AJAX request to the server to purge the cache
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/flarum/purge-cache', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
// Prepare the data to send
|
|
var requestData = JSON.stringify({ domain: '{{ current_domain }}' });
|
|
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
// Re-enable the button and hide the spinner
|
|
purgeCacheButton.disabled = false;
|
|
spinner.classList.add('d-none');
|
|
buttonText.innerHTML = `{{ _("Purge Cache") }} <i class="bi bi-arrow-clockwise"></i>`;
|
|
|
|
if (xhr.status === 200) {
|
|
var response = JSON.parse(xhr.responseText);
|
|
// Optionally show a success message or handle the response
|
|
const toast = toaster({
|
|
body: response.message,
|
|
className: 'border-0 text-white bg-success',
|
|
});
|
|
} else {
|
|
// Handle errors here
|
|
var errorResponse = JSON.parse(xhr.responseText);
|
|
const toast = toaster({
|
|
body: 'An error occurred while purging the cache.',
|
|
className: 'border-0 text-white bg-success',
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
xhr.send(requestData);
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('Type') }}</small>
|
|
<p class="card-text">
|
|
<i class=""><img src="/static/images/icons/flarum-text-logo.svg" style="width: 120px;"></i>
|
|
</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('Files') }} <span id="filesSize">({{ _('Calculating size...') }})</span></small>
|
|
<p class="card-text"><a class="nije-link" href="/files/{{ current_domain }}">{{ domain_directory }}</a></p>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('Domain:') }}</small>
|
|
<p class="card-text">
|
|
<span id="favicon"></span> <a class="punycode nije-link" href="/domains">
|
|
{{ current_domain }}
|
|
</a>
|
|
</p>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">
|
|
<a class="nije-link" data-bs-toggle="collapse" href="#collapseDB" aria-expanded="false" aria-controls="collapseDB">{{ _('Database') }} <span id="databaseSize"></span></a>
|
|
</small>
|
|
<p class="card-text">
|
|
<div class="collapse" id="collapseDB">
|
|
<ul class="list-group">
|
|
<li class="list-group-item"><small>{{ _('Database:') }}</small> <span><b><span id="database-name"></span></b></span></li>
|
|
<li class="list-group-item"><small>{{ _('Table prefix:') }}</small> <span><b><span id="database-table-prefix"></span></b></span></li>
|
|
<li class="list-group-item"><small>{{ _('Username:') }}</small> <span><b><span id="database-user"></span></b></span></li>
|
|
|
|
<li class="list-group-item" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="Click to show/hide"><small>{{ _('Password:') }}</small> <span> <b><span id="database-password" style="filter: blur(5px); cursor: pointer;" onclick="revealPassword()"></span></b>
|
|
|
|
</span></li>
|
|
</ul>
|
|
</div>
|
|
<script>
|
|
function revealPassword() {
|
|
// Get the span element
|
|
var passwordSpan = document.getElementById("database-password");
|
|
|
|
// Check if the blur is applied (initial state)
|
|
if (passwordSpan.style.filter === "blur(5px)") {
|
|
// Remove the blur effect
|
|
passwordSpan.style.filter = "none";
|
|
} else {
|
|
// Add the blur effect
|
|
passwordSpan.style.filter = "blur(5px)";
|
|
}
|
|
}
|
|
</script>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('Created') }} <a data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="{{ container.created_date }}"><i class="bi bi-info-circle"></i></a></small>
|
|
</button>
|
|
<p class="card-text">
|
|
<span id="created_date">{{ container.created_date }}</span>
|
|
</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('Flarum version:') }}</small>
|
|
<h4 class="card-text"><span id="flarum-version"></span><a href="#" id="version_check_flarum"></a></h4>
|
|
</div>
|
|
</div><div class="col">
|
|
|
|
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('PHP version:') }}</small>
|
|
<h4 class="card-text"><span id="php-version"></span></h4>
|
|
</div>
|
|
</div>
|
|
<div class="col">
|
|
<div class="card-body">
|
|
<small class="card-text">{{ _('MySQL version:') }}</small>
|
|
<h4 class="card-text"><span id="mysql-version"></span></h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--p>domain id: {{ container.domain_id }}</p-->
|
|
|
|
|
|
<div class="row my-4">
|
|
<div role="group" aria-label="WP Actions" style="width: 100%; margin-top: 0px;" class="btn-group">
|
|
{% if 'temporary_links' in enabled_modules %}
|
|
<button type="button" class="btn btn-outline-dark btn-lg" data-bs-description="preview" data-selected-domain="{{ current_domain }}" data-bs-toggle="modal" data-bs-target="#previewModal" onclick="sendDataToPreview(event)"><span class="desktop-only">{{ _('Preview') }}</span><span class="mobile-only"><i class="bi bi-box-arrow-up-right"></i></span></button>
|
|
|
|
<script>
|
|
function sendDataToPreview(event) {
|
|
const button = event.currentTarget;
|
|
const domain = button.getAttribute('data-selected-domain');
|
|
|
|
fetch(`/domains/temporary-link?domain=${encodeURIComponent(domain)}`)
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
if (data.link) {
|
|
window.open(data.link, '_blank');
|
|
} else {
|
|
console.error('No link found in the response.');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
}
|
|
</script>
|
|
{% endif %}
|
|
<!--button type="button" class="btn btn-outline-primary btn-lg" data-description="clone"><span class="desktop-only">Clone</span><span class="mobile-only"><i class="bi bi-copy"></i></span></button>
|
|
<button type="button" class="btn btn-outline-primary btn-lg" data-description="staging"><span class="desktop-only">Staging</span><span class="mobile-only"><i class="bi bi-layers"></i></span></button-->
|
|
<button type="button" class="btn btn-outline-primary btn-lg" data-bs-description="backup" data-selected-domain="{{ current_domain }}" data-bs-toggle="modal" data-bs-target="#backupModal"><span class="desktop-only">{{ _('Backup') }}</span><span class="mobile-only"><i class="bi bi-cloud-upload"></i></span></button>
|
|
|
|
{% if backup_files_available %}
|
|
{% endif %}
|
|
|
|
<button type="button" class="btn btn-outline-primary btn-lg" data-bs-description="restore" data-selected-domain="{{ current_domain }}" data-bs-toggle="modal" data-bs-target="#restoreModal">
|
|
<span class="desktop-only">{{ _('Restore') }}</span><span class="mobile-only"><i class="bi bi-cloud-download"></i></span>
|
|
</button>
|
|
|
|
|
|
<button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#detachModal{{ container.id }}" data-bs-description="remove"><i class="bi bi-x"></i><span class="desktop-only"> {{ _('Detach') }}</span></button>
|
|
<button type="button" class="btn btn-danger btn-lg" data-bs-toggle="modal" data-bs-target="#removeModal{{ container.id }}" data-bs-description="uninstall"><i class="bi bi-trash3"></i><span class="desktop-only"> {{ _('Uninstall') }}</span></button>
|
|
</div>
|
|
|
|
<div id="action_description" class="">
|
|
<!--p id="clone-description" class="">Create a duplicate copy of the WordPress website for testing or development purposes.</p>
|
|
<p id="staging-description">Set up a staging environment to safely test changes before deploying them to the live website.</p-->
|
|
<p id="preview-description">{{ _("Preview website with a temporary domain,") }} <b>{{ _("valid for 15 minutes only!") }}</b> {{ _("Helpful if your domain hasn't been pointed to the server's IP address yet and lacks an SSL certificate.") }}</p>
|
|
<p id="backup-description">{{ _("Create a manual backup of the ") }} {{container.type}} {{ _("website's files and database for data protection.") }}</p>
|
|
<p id="restore-description">{{ _('Restore the website to a previous state using a previously created backup.') }}</p>
|
|
<p id="remove-description">{{ _('Remove the {{container.type}} website from this manager without actually deleting any files or database.') }}</p>
|
|
<p id="uninstall-description">{{ _('Completely remove the {{container.type}} website, including its files, database, and records from this manager.') }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<script>
|
|
// Function to attach event listeners
|
|
function GetWPSiteInfo() {
|
|
// Get the value of the "domain" parameter from the URL
|
|
var domainParam = new URLSearchParams(window.location.search).get('domain');
|
|
|
|
// Use setTimeout to send the AJAX request 100ms after the page loads
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/website/flarum_info/" + domainParam,
|
|
dataType: "json",
|
|
success: function(data) {
|
|
var databaseHost = data.database_info.database_host;
|
|
var databaseName = data.database_info.database_name;
|
|
var databasePassword = data.database_info.database_password;
|
|
var databaseTablePrefix = data.database_info.database_table_prefix;
|
|
var databaseUser = data.database_info.database_user;
|
|
var mysqlVersion = data.flarum_info.mysql_version;
|
|
var phpVersion = data.flarum_info.php_version;
|
|
var flarumVersion = data.flarum_info.core_version;
|
|
var sslStatus = data.ssl_status;
|
|
|
|
var currentDomain = "{{ current_domain }}";
|
|
|
|
// Check if currentDomain is in punycode format
|
|
if (punycode.toASCII(currentDomain) !== currentDomain) {
|
|
currentDomain = punycode.toUnicode(currentDomain);
|
|
}
|
|
|
|
// Update SSL status display based on the response
|
|
var sslButton;
|
|
if (sslStatus.includes("VALID")) {
|
|
var expiryDate = new Date(sslStatus.split(": ")[1]);
|
|
var day = expiryDate.getDate();
|
|
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
var monthName = monthNames[expiryDate.getMonth()];
|
|
var year = expiryDate.getFullYear();
|
|
var expiryStatus = day + ' ' + monthName + ' ' + year;
|
|
$("#site_link_https").html(`<a href="https://${currentDomain}" target="_blank" class="btn btn-primary d-flex align-items-center gap-2">https://${currentDomain} <i class="bi bi-box-arrow-up-right"></i></a>`);
|
|
$("#https_link").html(`<a href="https://${currentDomain}" target="_blank"><img id="screenshot-image" style="width: 700px;" src="/screenshot/{{ current_domain }}" alt="Screenshot of {{ current_domain }}" class="img-fluid"></a>`);
|
|
|
|
|
|
sslButton = `<a href="/ssl" data-bs-toggle="tooltip" data-bs-placement="top" title="{{ _('Expires on:') }} ${expiryStatus}"><span style="color:green;"> {{ _('Valid SSL') }}</span></a>`;
|
|
} else {
|
|
sslButton = '<a href="/ssl"><span style="color:red;"> {{ _("SSL not detected") }}</span></a>';
|
|
}
|
|
|
|
// Set the HTML content including SSL status and tooltip
|
|
$("#site-ssl-status").html(sslButton);
|
|
|
|
$("#database-host").text(databaseHost);
|
|
$("#database-name").text(databaseName);
|
|
$("#database-password").text(databasePassword);
|
|
$("#database-table-prefix").text(databaseTablePrefix);
|
|
$("#database-user").text(databaseUser);
|
|
$("#mysql-version").text(mysqlVersion);
|
|
$("#php-version").text(phpVersion);
|
|
$("#flarum-version").text(flarumVersion);
|
|
$("#phpmyadminlink").attr("href", `/phpmyadmin?route=/database/structure&server=1&db=${databaseName}`);
|
|
|
|
|
|
},
|
|
error: function(error) {
|
|
// Handle any errors here
|
|
console.error(error);
|
|
}
|
|
});
|
|
|
|
$('#action_description p').hide();
|
|
|
|
// Show corresponding description on hover
|
|
$('.btn').hover(function() {
|
|
var descriptionId = $(this).data('bs-description') + '-description';
|
|
$('#' + descriptionId).show();
|
|
}, function() {
|
|
var descriptionId = $(this).data('bs-description') + '-description';
|
|
$('#' + descriptionId).hide();
|
|
});
|
|
|
|
};
|
|
|
|
GetWPSiteInfo();
|
|
</script>
|
|
|
|
|
|
<hr>
|
|
|
|
<div class="row mt-3">
|
|
|
|
{% include 'partials/pagespeed.html' %}
|
|
|
|
<div class="col-md-9">
|
|
<div class="row">
|
|
|
|
|
|
<div class="col-md-2">
|
|
<a style="text-decoration: none;" href="/files/{{ current_domain }}" target="_blank"><div class="card" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ _('Open website folder in FileManager') }}"">
|
|
<div class="card-body ikona text-center">
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<svg version="1.1" id="filemanager" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
viewBox="0 0 58 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 58 58;" xml:space="preserve">
|
|
<style type="text/css">
|
|
.st0{fill:#BFCCE0;}
|
|
.st1{fill:#192030;}
|
|
</style>
|
|
<path class="st0" d="M52,14H6c-3.3,0-6,2.7000008-6,6v26c0,6.5999985,5.4000001,12,12,12h34c6.5999985,0,12-5.4000015,12-12V20
|
|
C58,16.7000008,55.2999992,14,52,14z"/>
|
|
<path class="st1" d="M36.0000038,42H21.9999981C20.8999996,42,20,41.1000023,20,40.0000038v-0.0000076
|
|
C20,38.8999977,20.8999996,38,21.9999981,38h14.0000057C37.1000023,38,38,38.8999977,38,39.9999962v0.0000076
|
|
C38,41.1000023,37.1000023,42,36.0000038,42z"/>
|
|
<path class="st1" d="M36.0000038,34H21.9999981C20.8999996,34,20,33.1000023,20,32.0000038v-0.0000057
|
|
C20,30.8999996,20.8999996,30,21.9999981,30h14.0000057C37.1000023,30,38,30.8999996,38,31.9999981v0.0000057
|
|
C38,33.1000023,37.1000023,34,36.0000038,34z"/>
|
|
<path class="st1" d="M6,14h46c0.3412476,0,0.6739502,0.0354614,1,0.0908813V14v-1V6c0-3.2999878-2.7000122-6-6-6H35
|
|
c-3.2999878,0-6,2.7000122-6,6v1H11c-3.2999878,0-6,2.7000122-6,6v1.0908813C5.3260498,14.0354614,5.6587524,14,6,14z"/>
|
|
</svg>
|
|
|
|
<h6 class="card-title">{{ _('File Manager') }}</h6>
|
|
</div>
|
|
</div></a>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-2">
|
|
|
|
|
|
<a style="text-decoration: none;" id="phpmyadminlink" href="/phpmyadmin" target="_blank">
|
|
|
|
<div class="card" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ _('Open database in phpMyAdmin') }}">
|
|
<div class="card-body ikona text-center">
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<svg version="1.1" id="DB" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
viewBox="0 0 58 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 58 58;" xml:space="preserve">
|
|
<style type="text/css">
|
|
.st0{fill:#BFCCE0;}
|
|
.st1{fill:#192030;}
|
|
</style>
|
|
<path class="st0" d="M52,16H6c-3.3,0-6-2.6999998-6-6V6c0-3.3,2.7-6,6-6h46c3.2999992,0,6,2.7,6,6v4
|
|
C58,13.3000002,55.2999992,16,52,16z"/>
|
|
<path class="st1" d="M29.0000019,10H16.9999981C15.8999987,10,15,9.1000013,15,8.0000019V7.9999981
|
|
C15,6.8999991,15.8999987,6,16.9999981,6h12.0000038C30.1000004,6,31,6.8999991,31,7.9999981v0.0000038
|
|
C31,9.1000013,30.1000004,10,29.0000019,10z"/>
|
|
<circle class="st1" cx="8" cy="8" r="2"/>
|
|
<path class="st0" d="M52,37H6c-3.3,0-6-2.7000008-6-6v-4c0-3.2999992,2.7-6,6-6h46c3.2999992,0,6,2.7000008,6,6v4
|
|
C58,34.2999992,55.2999992,37,52,37z"/>
|
|
<path class="st1" d="M29.0000019,31H16.9999981C15.8999987,31,15,30.1000004,15,29.0000019v-0.0000038
|
|
C15,27.8999996,15.8999987,27,16.9999981,27h12.0000038C30.1000004,27,31,27.8999996,31,28.9999981v0.0000038
|
|
C31,30.1000004,30.1000004,31,29.0000019,31z"/>
|
|
<circle class="st1" cx="8" cy="29" r="2"/>
|
|
<path class="st0" d="M52,58H6c-3.3,0-6-2.7000008-6-6v-4c0-3.2999992,2.7-6,6-6h46c3.2999992,0,6,2.7000008,6,6v4
|
|
C58,55.2999992,55.2999992,58,52,58z"/>
|
|
<path class="st1" d="M29.0000019,52H16.9999981C15.8999987,52,15,51.1000023,15,50.0000038v-0.0000076
|
|
C15,48.8999977,15.8999987,48,16.9999981,48h12.0000038C30.1000004,48,31,48.8999977,31,49.9999962v0.0000076
|
|
C31,51.1000023,30.1000004,52,29.0000019,52z"/>
|
|
<circle class="st1" cx="8" cy="50" r="2"/>
|
|
</svg>
|
|
|
|
<h6 class="card-title">{{ _('phpMyAdmin') }}</h6>
|
|
</div>
|
|
</div></a>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-2">
|
|
<div class="card" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ _('View SSL Certificates') }}">
|
|
<a style="text-decoration: none;" href="/ssl" target="_blank">
|
|
<div class="card-body ikona text-center">
|
|
|
|
|
|
<svg version="1.1" id="katanac" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 58 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 58 58;" xml:space="preserve">
|
|
<style type="text/css">
|
|
.st0{fill:#BFCCE0;}
|
|
.st1{fill:#192030;}
|
|
</style>
|
|
<path class="st0" d="M38,58H12C5.4,58,0,52.6,0,46V32c0-6.6,5.4-12,12-12h26c6.6,0,12,5.4,12,12v14C50,52.6,44.6,58,38,58z"/>
|
|
<path class="st1" d="M25,46L25,46c-1.1,0-2-0.9-2-2V34c0-1.1,0.9-2,2-2h0c1.1,0,2,0.9,2,2v10C27,45.1,26.1,46,25,46z"/>
|
|
<path class="st1" d="M12,20h1v-6c0-5.5,4.5-10,10-10h4c5.5,0,10,4.5,10,10v6h1c1,0,2,0.1,3,0.4V14c0-7.7-6.3-14-14-14h-4
|
|
C15.3,0,9,6.3,9,14v6.4C10,20.1,11,20,12,20z"/>
|
|
</svg>
|
|
|
|
<h6 class="card-title">
|
|
<span id="site-ssl-status">
|
|
<div class="spinner-border spinner-border-sm" role="status"></div>{{ _('Checking SSL status..') }}</span>
|
|
</h6>
|
|
</div></a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="col-md-2">
|
|
<div class="card" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ _('Change PHP version for domain') }}">
|
|
<a style="text-decoration: none;" href="/php-version" target="_blank"> <div class="card-body ikona text-center">
|
|
<svg version="1.1" id="PHP" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
viewBox="0 0 58 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 58 58;" xml:space="preserve">
|
|
<style type="text/css">
|
|
.st0{fill:#BFCCE0;}
|
|
.st1{fill:#192030;}
|
|
</style>
|
|
<path class="st0" d="M40,58H18C8.1000004,58,0,49.9000015,0,40V18C0,8.1000004,8.1000004,0,18,0h22c9.9000015,0,18,8.1000004,18,18
|
|
v22C58,49.9000015,49.9000015,58,40,58z"/>
|
|
<path class="st1" d="M12.1653051,23.2070484h5.9321814c1.741148,0.0145454,3.0028439,0.5140896,3.7850857,1.4977989
|
|
c0.7822437,0.9837074,1.0403461,2.3273201,0.774725,4.0308342c-0.103159,0.7784061-0.3320255,1.541853-0.6861839,2.2907505
|
|
c-0.3395443,0.7488995-0.8114796,1.4242363-1.4166412,2.026432c-0.7379723,0.763443-1.5273151,1.248024-2.3684444,1.453743
|
|
c-0.8411312,0.205719-1.7119141,0.3083687-2.6119308,0.3083687h-2.6562004L12.076766,39H9L12.1653051,23.2070484
|
|
L12.1653051,23.2070484 M14.7551003,25.7180614l-1.3280993,6.6079311c0.0885391,0.0145454,0.1770802,0.0220261,0.2656193,0.0220261
|
|
c0.103157,0,0.2067337,0,0.3098907,0c1.4166393,0.0145454,2.597312-0.1246796,3.5416002-0.4185028
|
|
c0.9442883-0.3083687,1.5791016-1.3801823,1.9036102-3.2158585c0.2656212-1.5418491,0-2.4303875-0.7968597-2.6651974
|
|
c-0.7822418-0.2348118-1.7632828-0.3449421-2.9439545-0.3303967c-0.1770802,0.0145454-0.3466434,0.022028-0.5091057,0.022028
|
|
c-0.1474276,0-0.302372,0-0.4648342,0l0.0221348-0.022028"/>
|
|
<path class="st1" d="M26.1621437,19h3.0546284l-0.8632622,4.2070484h2.7447376
|
|
c1.5051804,0.0295067,2.6265488,0.3378773,3.364521,0.925108c0.7525902,0.5872364,0.973938,1.703516,0.6640511,3.3480186
|
|
l-1.4830475,7.3348007h-3.0988979l1.4166393-7.0044041c0.1474304-0.7343502,0.1031609-1.2555065-0.1328087-1.5638752
|
|
c-0.2359695-0.3083706-0.7450733-0.4625568-1.527319-0.4625568l-2.4569836-0.0220242l-1.8150711,9.0528603h-3.0546284L26.1621437,19
|
|
L26.1621437,19"/>
|
|
<path class="st1" d="M38.4069786,23.2070484h5.9321823c1.7411461,0.0145454,3.0028419,0.5140896,3.7850838,1.4977989
|
|
c0.7822418,0.9837074,1.0403442,2.3273201,0.7747269,4.0308342c-0.1031609,0.7784061-0.3320274,1.541853-0.6861839,2.2907505
|
|
c-0.3395462,0.7488995-0.8114777,1.4242363-1.4166412,2.026432c-0.7379684,0.763443-1.5273132,1.248024-2.3684425,1.453743
|
|
s-1.7119141,0.3083687-2.6119308,0.3083687h-2.6562004L38.3184433,39h-3.076767l3.1653061-15.7929516l0,0 M40.9967766,25.7180614
|
|
l-1.3281021,6.6079311c0.0885391,0.0145454,0.1770821,0.0220261,0.2656212,0.0220261c0.103157,0,0.2067337,0,0.3098907,0
|
|
c1.4166374,0.0145454,2.5973129-0.1246796,3.5415955-0.4185028c0.9442902-0.3083687,1.5791016-1.3801823,1.9036102-3.2158585
|
|
c0.2656212-1.5418491,0-2.4303875-0.7968559-2.6651974c-0.7822456-0.2348118-1.7632828-0.3449421-2.9439583-0.3303967
|
|
c-0.1770821,0.0145454-0.3466454,0.022028-0.5091057,0.022028c-0.1474266,0-0.302372,0-0.4648361,0l0.0221367-0.022028"/>
|
|
</svg>
|
|
|
|
<h6 class="card-title">{{ _('PHP Settings') }}</h6>
|
|
</div></a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-2">
|
|
<a style="text-decoration: none;" href="/cronjobs" target="_blank"> <div class="card" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="{{ _('Manage cronjobs') }}">
|
|
<div class="card-body ikona text-center">
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<svg version="1.1" id="cronovi" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
viewBox="0 0 54 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 54 58;" xml:space="preserve">
|
|
<style type="text/css">
|
|
.st0{fill:#BFCCE0;}
|
|
.st1{fill:#192030;}
|
|
</style>
|
|
<path class="st0" d="M42,58H12C5.4000001,58,0,52.5999985,0,46V21h54v25C54,52.5999985,48.5999985,58,42,58z"/>
|
|
<path class="st1" d="M54,21H0v-3C0,11.3999996,5.4000001,6,12,6h30c6.5999985,0,12,5.3999996,12,12V21z"/>
|
|
<path class="st0" d="M13.0000019,12h-0.0000038C11.8999987,12,11,11.1000013,11,10.0000019V1.999998
|
|
C11,0.8999991,11.8999987,0,12.9999981,0h0.0000038C14.1000013,0,15,0.8999991,15,1.999998v8.0000038
|
|
C15,11.1000013,14.1000013,12,13.0000019,12z"/>
|
|
<path class="st0" d="M41.0000038,12h-0.0000076C39.8999977,12,39,11.1000013,39,10.0000019V1.999998
|
|
C39,0.8999991,39.8999977,0,40.9999962,0h0.0000076C42.1000023,0,43,0.8999991,43,1.999998v8.0000038
|
|
C43,11.1000013,42.1000023,12,41.0000038,12z"/>
|
|
<path class="st1" d="M28.0000019,35h-2.0000038C24.8999996,35,24,34.1000023,24,33.0000038v-0.0000076
|
|
C24,31.8999996,24.8999996,31,25.9999981,31h2.0000038C29.1000004,31,30,31.8999996,30,32.9999962v0.0000076
|
|
C30,34.1000023,29.1000004,35,28.0000019,35z"/>
|
|
<path class="st1" d="M15.0000019,35h-2.0000038C11.8999987,35,11,34.1000023,11,33.0000038v-0.0000076
|
|
C11,31.8999996,11.8999987,31,12.9999981,31h2.0000038C16.1000004,31,17,31.8999996,17,32.9999962v0.0000076
|
|
C17,34.1000023,16.1000004,35,15.0000019,35z"/>
|
|
<path class="st1" d="M41.0000038,35h-2.0000076C37.8999977,35,37,34.1000023,37,33.0000038v-0.0000076
|
|
C37,31.8999996,37.8999977,31,38.9999962,31h2.0000076C42.1000023,31,43,31.8999996,43,32.9999962v0.0000076
|
|
C43,34.1000023,42.1000023,35,41.0000038,35z"/>
|
|
<path class="st1" d="M28.0000019,47h-2.0000038C24.8999996,47,24,46.1000023,24,45.0000038v-0.0000076
|
|
C24,43.8999977,24.8999996,43,25.9999981,43h2.0000038C29.1000004,43,30,43.8999977,30,44.9999962v0.0000076
|
|
C30,46.1000023,29.1000004,47,28.0000019,47z"/>
|
|
<path class="st1" d="M15.0000019,47h-2.0000038C11.8999987,47,11,46.1000023,11,45.0000038v-0.0000076
|
|
C11,43.8999977,11.8999987,43,12.9999981,43h2.0000038C16.1000004,43,17,43.8999977,17,44.9999962v0.0000076
|
|
C17,46.1000023,16.1000004,47,15.0000019,47z"/>
|
|
<path class="st1" d="M41.0000038,47h-2.0000076C37.8999977,47,37,46.1000023,37,45.0000038v-0.0000076
|
|
C37,43.8999977,37.8999977,43,38.9999962,43h2.0000076C42.1000023,43,43,43.8999977,43,44.9999962v0.0000076
|
|
C43,46.1000023,42.1000023,47,41.0000038,47z"/>
|
|
</svg>
|
|
|
|
|
|
<h6 class="card-title">{{ _('Cronjobs') }}</h6>
|
|
</div>
|
|
</div></a>
|
|
</div>
|
|
|
|
|
|
{% include 'partials/phpmyadmin_link.html' %}
|
|
|
|
{% if 'malware_scan' in enabled_modules %}
|
|
<div class="col-md-2">
|
|
<div class="card">
|
|
<a style="text-decoration: none;" href="/malware-scanner?path=/home/{{current_username}}/{{ current_domain }}" target="_blank" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Scan website files with ClamAV">
|
|
<div class="card-body ikona text-center">
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="scanner" x="0px" y="0px" viewBox="0 0 58 58" style="width:50px; padding-bottom:1em; enable-background:new 0 0 58 58;" xml:space="preserve"> <style type="text/css"> .st0{fill:#414954;} .st1{fill:#EBF3FF;} </style> <g> <path class="st0" d="M12,37v1c0,5.5,4.5,10,10,10h14c5.5,0,10-4.5,10-10v-1H12z"/> <path class="st0" d="M46,27v-7c0-5.5-4.5-10-10-10H22c-5.5,0-10,4.5-10,10v7H46z"/> </g> <g> <path class="st1" d="M2,14c-1.1,0-2-0.9-2-2C0,5.4,5.4,0,12,0c1.1,0,2,0.9,2,2s-0.9,2-2,2c-4.4,0-8,3.6-8,8C4,13.1,3.1,14,2,14z"/> </g> <g> <path class="st1" d="M12,58C5.4,58,0,52.6,0,46c0-1.1,0.9-2,2-2s2,0.9,2,2c0,4.4,3.6,8,8,8c1.1,0,2,0.9,2,2S13.1,58,12,58z"/> </g> <g> <path class="st1" d="M46,58c-1.1,0-2-0.9-2-2s0.9-2,2-2c4.4,0,8-3.6,8-8c0-1.1,0.9-2,2-2s2,0.9,2,2C58,52.6,52.6,58,46,58z"/> </g> <g> <path class="st1" d="M56,14c-1.1,0-2-0.9-2-2c0-4.4-3.6-8-8-8c-1.1,0-2-0.9-2-2s0.9-2,2-2c6.6,0,12,5.4,12,12 C58,13.1,57.1,14,56,14z"/> </g> <path class="st1" d="M56,34H2c-1.1,0-2-0.9-2-2v0c0-1.1,0.9-2,2-2h54c1.1,0,2,0.9,2,2v0C58,33.1,57.1,34,56,34z"/> </svg>
|
|
<h6 class="card-title">{{ _('Scanning') }}</h6>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
// Function to confirm removal
|
|
function confirmRemoveforWP(Id) {
|
|
// Send an AJAX request to the server to remove flarum
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/flarum/remove', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
// Redirect to wp manager page
|
|
window.location.href = '/flarum';
|
|
}
|
|
};
|
|
xhr.send('id=' + Id);
|
|
}
|
|
|
|
// Function to confirm detachment
|
|
function confirmDetach(Id) {
|
|
// Send an AJAX request to the server to remove flarum
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/flarum/detach', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
if (xhr.status === 200) {
|
|
// Redirect to wp manager page
|
|
window.location.href = '/flarum';
|
|
} else {
|
|
alert("{{ _('An error occurred while detaching flarum.') }}");
|
|
}
|
|
}
|
|
};
|
|
xhr.send('id=' + Id);
|
|
}
|
|
</script>
|
|
|
|
|
|
<div class="modal fade" id="removeModal{{ container.id }}" tabindex="-1" role="dialog" aria-labelledby="removeModalLabel{{ container.id }}" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="removeModalLabel{{ container.id }}">{{ _('Confirm Flarum Uninstall') }}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{{ _('Close') }}"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
{{ _('Are you sure you want to permanently remove the Flarum installation for') }} {{ container.website_name }} (http://{{ current_domain }})?
|
|
<br><br>
|
|
<p class="text-danger">{{ _('This will permanently delete all website files and the database.') }}</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ _('Cancel') }}</button>
|
|
<button type="button" class="btn btn-danger" onclick="confirmRemoveforWP('{{ container.id }}')">{{ _('Confirm Uninstall') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="detachModal{{ container.id }}" tabindex="-1" role="dialog" aria-labelledby="detachModalLabel{{ container.id }}" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="detachModalLabel{{ container.id }}">{{ _('Confirm Flarum Detach from SiteManager') }}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
{{ _('Are you sure you want to detach the Flarum installation for') }} {{ container.website_name }} (http://{{ current_domain }}) {{ _('from the manager?') }}
|
|
<br><br>
|
|
<p class="text-danger">{{ _('This will only remove the website from the SiteManager without affecting the files or database') }}.</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="button" class="btn btn-danger" onclick="confirmDetach('{{ container.id }}')">{{ _('Remove') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="backupModal" data-selected-domain="{{ current_domain }}" tabindex="-1" role="dialog" aria-labelledby="backupModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="backupModalLabel">{{ _('Backup') }} {{ current_domain }}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<label class="checkbox-inline">
|
|
<input type="checkbox" id="backupDatabase" checked> {{ _('Backup Database') }}
|
|
</label>
|
|
<br>
|
|
<label class="checkbox-inline">
|
|
<input type="checkbox" id="backupFiles" checked> {{ _('Backup Files') }}
|
|
</label>
|
|
</div>
|
|
<div id="backupResultMessage" class="mt-3 text-center"></div> <!-- Result message will be displayed here -->
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ _('Cancel') }}</button>
|
|
<button type="button" class="btn btn-primary" id="runBackup">{{ _('Run Backup') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="restoreModal" data-selected-domain="{{ current_domain }}" tabindex="-1" role="dialog" aria-labelledby="restoreModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="restoreModalLabel">{{ _('Restore Backup') }}</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>{{ _('Select a backup date to restore') }} {{ current_domain }}:</p>
|
|
<!-- List of available backup dates -->
|
|
<select class="form-control" id="restoreBackupDate">
|
|
</select>
|
|
<!-- Restore status -->
|
|
<div id="restoreStatus" class="mt-3"></div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" id="cancelRestore" data-bs-dismiss="modal">{{ _('Cancel') }}</button>
|
|
<button type="button" class="btn btn-primary" id="confirmRestore">{{ _('Restore') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/punycode/2.1.1/punycode.min.js"></script>
|
|
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
var punycodeElements = document.querySelectorAll(".punycode");
|
|
punycodeElements.forEach(function(element) {
|
|
element.textContent = punycode.toUnicode(element.textContent);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const domainElement = document.querySelector('.card-text .punycode.nije-link');
|
|
const faviconElement = document.getElementById('favicon');
|
|
const currentDomain = '{{ current_domain }}';
|
|
|
|
// Create the URL to the favicon
|
|
const faviconUrl = `https://www.google.com/s2/favicons?domain=${currentDomain}`;
|
|
|
|
// Create an img element and set its src to the favicon URL
|
|
const img = document.createElement('img');
|
|
img.src = faviconUrl;
|
|
img.alt = 'Favicon';
|
|
img.style.width = '16px'; // Optional: set the size of the favicon
|
|
img.style.height = '16px'; // Optional: set the size of the favicon
|
|
|
|
// Append the img element to the favicon span
|
|
faviconElement.appendChild(img);
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function GetWPdbSize() {
|
|
const databaseSizeSpan = document.getElementById("databaseSize");
|
|
const filesSizeSpan = document.getElementById("filesSize");
|
|
const databaseName = $("#database-name").text();
|
|
const destinationPath = "/home/{{current_username}}";
|
|
const currentDomain = "{{current_domain}}";
|
|
|
|
fetch(`/get-files-size?selected_domain=${encodeURIComponent(currentDomain)}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
filesSizeSpan.textContent = `(${data.size})`;
|
|
})
|
|
.catch(error => {
|
|
console.error("An error occurred:", error);
|
|
});
|
|
|
|
const restoreButton = document.querySelector('[data-bs-description="restore"]');
|
|
const restoreModal = document.getElementById("restoreModal");
|
|
const restoreBackupDateSelect = document.getElementById("restoreBackupDate");
|
|
const confirmRestoreButton = document.getElementById("confirmRestore");
|
|
const cancelButton = document.getElementById("cancelRestore"); // Cancel button
|
|
|
|
const restoreDomain = '{{ current_domain }}';
|
|
let restoreConfirmed = false; // Flag to track double confirmation
|
|
|
|
restoreButton.addEventListener("click", function () {
|
|
// Fetch available backup dates and populate the select element
|
|
fetch(`/flarum/backup/get_dates/${restoreDomain}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
restoreBackupDateSelect.innerHTML = ""; // Clear previous options
|
|
data.forEach(dateInfo => {
|
|
const { date, hasDbBackup, hasFilesBackup } = dateInfo;
|
|
|
|
const option = document.createElement("option");
|
|
option.value = date;
|
|
option.textContent = `${date} (${getBackupTypeLabel(hasDbBackup, hasFilesBackup)})`;
|
|
restoreBackupDateSelect.appendChild(option);
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
confirmRestoreButton.addEventListener("click", function () {
|
|
if (!restoreConfirmed) {
|
|
// First click, ask for confirmation
|
|
confirmRestoreButton.textContent = "{{ _('Confirm Restore (Click Again)') }}";
|
|
confirmRestoreButton.classList.remove("btn-primary");
|
|
confirmRestoreButton.classList.add("btn-danger");
|
|
cancelButton.style.display = "none";
|
|
confirmRestoreButton.style.width = "100%";
|
|
restoreConfirmed = true;
|
|
} else {
|
|
// Double confirmation, proceed with restore
|
|
const selectedDate = restoreBackupDateSelect.value;
|
|
|
|
cancelButton.click();
|
|
|
|
// Display restore status
|
|
const toastMessage = "{{ _('Restoring backup... Please wait.') }}";
|
|
const toastInitiation = toaster({
|
|
body: toastMessage,
|
|
className: 'border-0 text-white bg-primary',
|
|
});
|
|
|
|
// Send request to restore backup
|
|
fetch(`/flarum/backup/restore/${restoreDomain}?backup_date=${selectedDate}`)
|
|
.then(response => {
|
|
if (response.ok) {
|
|
return response.text();
|
|
}
|
|
throw new Error("{{ _('Restore request failed.') }}");
|
|
})
|
|
.then(result => {
|
|
// Show success message
|
|
const toastSuccess = toaster({
|
|
body: `${result}`,
|
|
className: 'border-0 text-white bg-success',
|
|
});
|
|
|
|
setTimeout(() => {
|
|
restoreConfirmed = false;
|
|
confirmRestoreButton.textContent = "{{ _('Restore') }}";
|
|
confirmRestoreButton.classList.remove("btn-danger");
|
|
confirmRestoreButton.classList.add("btn-primary");
|
|
cancelButton.style.display = "block";
|
|
confirmRestoreButton.style.width = "";
|
|
}, 5000); // Reset button after 5 seconds
|
|
})
|
|
.catch(error => {
|
|
console.error("Error during restore:", error);
|
|
// Show error message
|
|
const toastError = toaster({
|
|
body: `${error.message}`,
|
|
className: 'border-0 text-white bg-danger',
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Function to get the backup type label based on hasDbBackup and hasFilesBackup
|
|
function getBackupTypeLabel(hasDbBackup, hasFilesBackup) {
|
|
if (hasDbBackup && hasFilesBackup) {
|
|
return "{{ _('Database and Files Backup') }}";
|
|
} else if (hasDbBackup) {
|
|
return "{{ _('Database Backup') }}";
|
|
} else if (hasFilesBackup) {
|
|
return "{{ _('Files Backup') }}";
|
|
}
|
|
return "{{ _('Unknown Backup Type') }}";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const runBackupButton = document.getElementById("runBackup");
|
|
const backupDatabaseCheckbox = document.getElementById("backupDatabase");
|
|
const backupFilesCheckbox = document.getElementById("backupFiles");
|
|
const backupResultMessage = document.getElementById("backupResultMessage");
|
|
|
|
const backupModal = document.getElementById("backupModal");
|
|
const modalFooter = backupModal.querySelector(".modal-footer");
|
|
const backupDomain = backupModal.getAttribute("data-selected-domain");
|
|
const closeBtn = backupModal.querySelector(".btn-close");
|
|
|
|
runBackupButton.addEventListener("click", function () {
|
|
const backupDatabase = backupDatabaseCheckbox.checked;
|
|
const backupFiles = backupFilesCheckbox.checked;
|
|
|
|
let btnClass, toastMessage;
|
|
|
|
// Determine the action based on the button's ID
|
|
if (runBackupButton.id === 'runBackup') {
|
|
btnClass = 'primary';
|
|
toastMessage = "{{ _('Generating website backup...') }}";
|
|
closeBtn.click();
|
|
}
|
|
|
|
// Display toast message for backup initiation
|
|
const toastInitiation = toaster({
|
|
body: toastMessage,
|
|
className: `border-0 text-white bg-${btnClass}`,
|
|
});
|
|
|
|
fetch(`/flarum/backup/run/${backupDomain}?backup_database=${backupDatabase}&backup_files=${backupFiles}`)
|
|
.then(response => {
|
|
if (response.ok) {
|
|
return response.text();
|
|
}
|
|
throw new Error("{{ _('Backup request failed.') }}");
|
|
})
|
|
.then(result => {
|
|
// Display toast message for successful backup
|
|
const toastSuccess = toaster({
|
|
body: `${result}`,
|
|
className: 'border-0 text-white bg-success',
|
|
});
|
|
})
|
|
.catch(error => {
|
|
// Display toast message for backup error
|
|
const toastError = toaster({
|
|
body: `${error.message}`,
|
|
className: 'border-0 text-white bg-danger',
|
|
});
|
|
console.error("Error during backup:", error);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
var createdDate = document.getElementById('created_date').textContent;
|
|
var date = new Date(createdDate);
|
|
var currentDate = new Date();
|
|
var timeDiff = currentDate.getTime() - date.getTime();
|
|
|
|
var secondsAgo = Math.floor(timeDiff / 1000);
|
|
var minutesAgo = Math.floor(timeDiff / (1000 * 60));
|
|
var hoursAgo = Math.floor(timeDiff / (1000 * 3600));
|
|
var daysAgo = Math.floor(timeDiff / (1000 * 3600 * 24));
|
|
var monthsAgo = Math.floor(timeDiff / (1000 * 3600 * 24 * 30));
|
|
var yearsAgo = Math.floor(timeDiff / (1000 * 3600 * 24 * 360));
|
|
|
|
var content;
|
|
if (yearsAgo > 0) {
|
|
content = yearsAgo + (yearsAgo === 1 ? ' year' : ' years') + ' ago';
|
|
} else if (monthsAgo > 0) {
|
|
content = monthsAgo + (monthsAgo === 1 ? ' month' : ' months') + ' ago';
|
|
} else if (daysAgo > 0) {
|
|
content = daysAgo + (daysAgo === 1 ? ' day' : ' days') + ' ago';
|
|
} else if (hoursAgo > 0) {
|
|
content = hoursAgo + (hoursAgo === 1 ? ' hour' : ' hours') + ' ago';
|
|
} else if (minutesAgo > 0) {
|
|
content = minutesAgo + (minutesAgo === 1 ? ' minute' : ' minutes') + ' ago';
|
|
} else {
|
|
content = secondsAgo + (secondsAgo === 1 ? ' second' : ' seconds') + ' ago';
|
|
}
|
|
|
|
document.getElementById('created_date').textContent = content;
|
|
|
|
};
|
|
|
|
GetWPdbSize()
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|