mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-16 19:46:48 +01:00
247 lines
12 KiB
HTML
247 lines
12 KiB
HTML
{% extends "baseTemplate/index.html" %}
|
|
{% load i18n %}
|
|
{% block title %}{% trans "WordPress Toolkit - CyberPanel" %}{% endblock %}
|
|
|
|
{% block header_scripts %}
|
|
<script>
|
|
// Create or get the CyberCP module
|
|
try {
|
|
angular.module('CyberCP');
|
|
} catch(err) {
|
|
angular.module('CyberCP', []);
|
|
}
|
|
|
|
// Now add our controller to the module
|
|
angular.module('CyberCP').controller('listWordPressSites', function($scope, $http) {
|
|
// Initialize scope variables with pre-serialized JSON
|
|
$scope.wpSites = {{ wpsite|safe }};
|
|
$scope.debug = {{ debug_info|safe }};
|
|
$scope.totalSites = {{ total_sites }};
|
|
$scope.userId = $scope.debug.user_id;
|
|
$scope.isAdmin = $scope.debug.is_admin;
|
|
$scope.wpSitesCount = $scope.debug.wp_sites_count;
|
|
|
|
$scope.getFullUrl = function(url) {
|
|
if (!url) return '';
|
|
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
return url;
|
|
}
|
|
return 'https://' + url;
|
|
};
|
|
|
|
$scope.deleteWPSite = function(site) {
|
|
if (confirm('Are you sure you want to delete this WordPress site? This action cannot be undone.')) {
|
|
window.location.href = "{% url 'ListWPSites' %}?DeleteID=" + site.id;
|
|
}
|
|
};
|
|
|
|
$scope.updateSetting = function(site, setting) {
|
|
var settingMap = {
|
|
'search-indexing': 'searchIndex',
|
|
'debugging': 'debugging',
|
|
'password-protection': 'passwordprotection',
|
|
'maintenance-mode': 'maintenanceMode'
|
|
};
|
|
|
|
var data = {
|
|
siteId: site.id,
|
|
setting: setting,
|
|
value: site[settingMap[setting]] ? 1 : 0
|
|
};
|
|
|
|
GLobalAjaxCall($http, "{% url 'UpdateWPSettings' %}", data,
|
|
function(response) {
|
|
if (!response.data.status) {
|
|
site[settingMap[setting]] = !site[settingMap[setting]];
|
|
new PNotify({
|
|
title: 'Operation Failed!',
|
|
text: response.data.error_message || 'Unknown error',
|
|
type: 'error'
|
|
});
|
|
} else {
|
|
new PNotify({
|
|
title: 'Success!',
|
|
text: 'Setting updated successfully.',
|
|
type: 'success'
|
|
});
|
|
}
|
|
},
|
|
function(response) {
|
|
site[settingMap[setting]] = !site[settingMap[setting]];
|
|
new PNotify({
|
|
title: 'Operation Failed!',
|
|
text: 'Could not connect to server, please try again.',
|
|
type: 'error'
|
|
});
|
|
}
|
|
);
|
|
};
|
|
|
|
// Function to fetch plugin data
|
|
function fetchPluginData(site) {
|
|
var data = { WPid: site.id };
|
|
GLobalAjaxCall($http, "{% url 'GetCurrentPlugins' %}", data,
|
|
function(response) {
|
|
if (response.data.status === 1) {
|
|
var plugins = JSON.parse(response.data.plugins);
|
|
site.activePlugins = plugins.filter(function(p) { return p.status === 'active'; }).length;
|
|
site.totalPlugins = plugins.length;
|
|
}
|
|
},
|
|
function(response) {
|
|
site.activePlugins = 'Error';
|
|
}
|
|
);
|
|
}
|
|
|
|
// Function to fetch theme data
|
|
function fetchThemeData(site) {
|
|
var data = { WPid: site.id };
|
|
GLobalAjaxCall($http, "{% url 'GetCurrentThemes' %}", data,
|
|
function(response) {
|
|
if (response.data.status === 1) {
|
|
var themes = JSON.parse(response.data.themes);
|
|
site.activeTheme = themes.find(function(t) { return t.status === 'active'; }).name;
|
|
site.totalThemes = themes.length;
|
|
}
|
|
},
|
|
function(response) {
|
|
site.activeTheme = 'Error';
|
|
}
|
|
);
|
|
}
|
|
|
|
// Fetch site data for each site
|
|
function fetchSiteData(site) {
|
|
var data = { WPid: site.id };
|
|
site.fullUrl = $scope.getFullUrl(site.url);
|
|
|
|
GLobalAjaxCall($http, "{% url 'FetchWPdata' %}", data,
|
|
function(response) {
|
|
if (response.data.status === 1) {
|
|
var data = response.data.ret_data;
|
|
site.version = data.version;
|
|
site.phpVersion = site.phpVersion || 'PHP ' + site.php_version;
|
|
site.searchIndex = data.searchIndex === 1;
|
|
site.debugging = data.debugging === 1;
|
|
site.passwordProtection = data.passwordprotection === 1;
|
|
site.maintenanceMode = data.maintenanceMode === 1;
|
|
fetchPluginData(site);
|
|
fetchThemeData(site);
|
|
}
|
|
},
|
|
function(response) {
|
|
new PNotify({
|
|
title: 'Operation Failed!',
|
|
text: 'Could not fetch site data, please refresh the page.',
|
|
type: 'error'
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
if ($scope.wpSites) {
|
|
$scope.wpSites.forEach(fetchSiteData);
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div ng-controller="listWordPressSites">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h3 class="card-title">WordPress Sites</h3>
|
|
</div>
|
|
<div class="col-md-6 text-right">
|
|
<input type="text" class="form-control-sm" ng-model="searchTerm" placeholder="Search WordPress installations...">
|
|
<a href="{% url 'createWordpress' %}" class="btn btn-success btn-sm">Install WordPress</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card" ng-repeat="site in wpSites">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div class="site-preview">
|
|
<img ng-src="https://api.microlink.io/?url={$ getFullUrl(site.url) $}&screenshot=true&meta=false&embed=screenshot.url"
|
|
alt="{$ site.title $}"
|
|
class="img-fluid"
|
|
loading="lazy"
|
|
onerror="this.onerror=null; this.src='https://s.wordpress.org/style/images/about/WordPress-logotype-standard.png';">
|
|
<a ng-href="{$ getFullUrl(site.url) $}" target="_blank" class="btn btn-outline-secondary btn-sm mt-2">
|
|
Visit Site
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-9">
|
|
<div class="d-flex justify-content-between">
|
|
<h4>{$ site.title $}</h4>
|
|
<div>
|
|
<a ng-href="{% url 'WPHome' %}?ID={$ site.id $}" class="btn btn-primary btn-sm">Manage</a>
|
|
<button class="btn btn-danger btn-sm" ng-click="deleteWPSite(site)">Delete</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-md-3">
|
|
<small>WordPress</small>
|
|
<div>{$ site.version $}</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<small>Plugins</small>
|
|
<div>{$ site.activePlugins || 0 $} active</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<small>Theme</small>
|
|
<div>{$ site.activeTheme || 'Loading...' $}</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<small>PHP Version</small>
|
|
<div>{$ site.phpVersion || 'Loading...' $}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mt-3">
|
|
<div class="col-md-6">
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="search-indexing-{$ site.id $}"
|
|
ng-model="site.searchIndex"
|
|
ng-change="updateSetting(site, 'search-indexing')">
|
|
<label class="custom-control-label" for="search-indexing-{$ site.id $}">Search engine indexing</label>
|
|
</div>
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="debugging-{$ site.id $}"
|
|
ng-model="site.debugging"
|
|
ng-change="updateSetting(site, 'debugging')">
|
|
<label class="custom-control-label" for="debugging-{$ site.id $}">Debugging</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="password-protection-{$ site.id $}"
|
|
ng-model="site.passwordProtection"
|
|
ng-change="updateSetting(site, 'password-protection')">
|
|
<label class="custom-control-label" for="password-protection-{$ site.id $}">Password protection</label>
|
|
</div>
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="maintenance-mode-{$ site.id $}"
|
|
ng-model="site.maintenanceMode"
|
|
ng-change="updateSetting(site, 'maintenance-mode')">
|
|
<label class="custom-control-label" for="maintenance-mode-{$ site.id $}">Maintenance mode</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock content %}
|
|
|
|
|