mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-31 02:14:13 +02:00
358 lines
17 KiB
HTML
358 lines
17 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) {
|
|
$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.currentPage = 1;
|
|
$scope.recordsToShow = 10;
|
|
|
|
$scope.updatePagination = function() {
|
|
var filteredSites = $scope.wpSites;
|
|
if ($scope.searchText) {
|
|
filteredSites = $scope.wpSites.filter(function(site) {
|
|
return site.title.toLowerCase().includes($scope.searchText.toLowerCase()) ||
|
|
site.url.toLowerCase().includes($scope.searchText.toLowerCase());
|
|
});
|
|
}
|
|
$scope.totalPages = Math.ceil(filteredSites.length / $scope.recordsToShow);
|
|
if ($scope.currentPage > $scope.totalPages) {
|
|
$scope.currentPage = 1;
|
|
}
|
|
};
|
|
|
|
$scope.$watch('searchText', function() {
|
|
$scope.updatePagination();
|
|
});
|
|
|
|
$scope.$watch('recordsToShow', function() {
|
|
$scope.updatePagination();
|
|
});
|
|
|
|
$scope.updatePagination();
|
|
|
|
$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.owner.phpSelection;
|
|
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) {
|
|
console.log('Failed to fetch site data');
|
|
}
|
|
);
|
|
}
|
|
|
|
if ($scope.wpSites) {
|
|
$scope.wpSites.forEach(fetchSiteData);
|
|
}
|
|
});
|
|
|
|
// Add a range filter for pagination
|
|
angular.module('CyberCP').filter('range', function() {
|
|
return function(input, start, end) {
|
|
start = parseInt(start);
|
|
end = parseInt(end);
|
|
var direction = (start <= end) ? 1 : -1;
|
|
while (start != end) {
|
|
input.push(start);
|
|
start += direction;
|
|
}
|
|
input.push(end);
|
|
return input;
|
|
};
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container" ng-controller="listWordPressSites">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">
|
|
<div class="row">
|
|
<div class="col-sm-6">
|
|
<h3 class="panel-title">{% trans "WordPress Sites" %}</h3>
|
|
</div>
|
|
<div class="col-sm-6 text-right">
|
|
<a href="{% url 'createWordpress' %}" class="btn btn-success btn-sm">Install WordPress</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="row mb-3">
|
|
<div class="col-sm-10">
|
|
<input ng-model="searchText" placeholder="Search..." class="form-control">
|
|
</div>
|
|
<div class="col-sm-2">
|
|
<select ng-model="recordsToShow" class="form-control" ng-change="updatePagination()">
|
|
<option>10</option>
|
|
<option>50</option>
|
|
<option>100</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div ng-repeat="site in filteredSites = (wpSites | filter:searchText | limitTo:recordsToShow:(currentPage-1)*recordsToShow)" class="wp-site-item">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="wp-site-header">
|
|
<div class="row">
|
|
<div class="col-sm-8">
|
|
<h4>{$ site.title $}</h4>
|
|
</div>
|
|
<div class="col-sm-4 text-right">
|
|
<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>
|
|
<div class="wp-site-content">
|
|
<div class="row">
|
|
<div class="col-sm-3">
|
|
<img ng-src="https://api.microlink.io/?url={$ getFullUrl(site.url) $}&screenshot=true&meta=false&embed=screenshot.url"
|
|
alt="{$ site.title $}"
|
|
class="img-responsive"
|
|
style="max-width: 100%; margin-bottom: 10px;"
|
|
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-default btn-sm btn-block">Visit Site</a>
|
|
</div>
|
|
<div class="col-sm-9">
|
|
<div class="row">
|
|
<div class="col-sm-3">
|
|
<div class="info-box">
|
|
<label>WordPress</label>
|
|
<span>{$ site.version $}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-3">
|
|
<div class="info-box">
|
|
<label>PHP Version</label>
|
|
<span>{$ site.phpVersion || 'Loading...' $}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-3">
|
|
<div class="info-box">
|
|
<label>Theme</label>
|
|
<span>{$ site.activeTheme || 'twentytwentyfive' $}</span>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-3">
|
|
<div class="info-box">
|
|
<label>Plugins</label>
|
|
<span>{$ site.activePlugins || '1' $} active</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-3">
|
|
<div class="col-sm-6">
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" ng-model="site.searchIndex" ng-change="updateSetting(site, 'search-indexing')">
|
|
Search engine indexing
|
|
</label>
|
|
</div>
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" ng-model="site.debugging" ng-change="updateSetting(site, 'debugging')">
|
|
Debugging
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" ng-model="site.passwordProtection" ng-change="updateSetting(site, 'password-protection')">
|
|
Password protection
|
|
</label>
|
|
</div>
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" ng-model="site.maintenanceMode" ng-change="updateSetting(site, 'maintenance-mode')">
|
|
Maintenance mode
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin-top: 2%" class="row">
|
|
<div class="col-md-12">
|
|
<div class="row">
|
|
<div class="col-md-9">
|
|
<span>Showing {$ ((currentPage-1)*recordsToShow) + 1 $} to {$ ((currentPage-1)*recordsToShow) + filteredSites.length $} of {$ (wpSites | filter:searchText).length $} sites</span>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<select ng-model="currentPage" class="form-control" ng-options="page for page in [] | range:1:totalPages">
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.wp-site-item {
|
|
border: 1px solid #ddd;
|
|
margin-bottom: 20px;
|
|
border-radius: 4px;
|
|
}
|
|
.wp-site-header {
|
|
padding: 15px;
|
|
border-bottom: 1px solid #ddd;
|
|
background: #f5f5f5;
|
|
}
|
|
.wp-site-content {
|
|
padding: 15px;
|
|
}
|
|
.info-box {
|
|
margin-bottom: 15px;
|
|
}
|
|
.info-box label {
|
|
display: block;
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-bottom: 5px;
|
|
}
|
|
.info-box span {
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
}
|
|
.checkbox {
|
|
margin-bottom: 10px;
|
|
}
|
|
</style>
|
|
{% endblock content %}
|
|
|
|
|