bug fixes in wp manager

This commit is contained in:
Usman Nasir
2022-06-05 12:46:02 +05:00
parent 9c9a0eb214
commit 7ae3856e32
11 changed files with 187 additions and 99 deletions

View File

@@ -275,6 +275,10 @@
{# </div>#}
{# </div>#}
{# </div>#}
<a class="header-btn" target="_blank" href="https://www.youtube.com/channel/UCS6sgUWEhaFl1TO238Ck0xw?sub_confirmation=1"
title="{% trans 'Youtube Channel' %}">
<i class="glyph-icon icon-youtube"></i>
</a>
<a class="header-btn" target="_blank" href="https://go.cyberpanel.net/community"
title="{% trans 'Community' %}">
<i class="glyph-icon icon-comments"></i>

View File

@@ -18,6 +18,7 @@ from shlex import split
from .CyberCPLogFileWriter import CyberCPLogFileWriter as logging
from dockerManager.models import Containers
from re import compile
class ACLManager:
@@ -917,4 +918,16 @@ class ACLManager:
else:
dic['dnsAsWhole'] = 0
@staticmethod
def GetALLWPObjects(currentACL, userID):
from websiteFunctions.models import WPSites
wpsites = WPSites.objects.none()
websites = ACLManager.findWebsiteObjects(currentACL, userID)
for website in websites:
wpsites |= website.wpsites_set.all()
return wpsites

View File

@@ -1689,6 +1689,15 @@ $parameters = array(
DataToPass['mailDomain'] = 0
UserID = self.data['adminID']
try:
website = Websites.objects.get(domain=DataToPass['domainName'])
if ACLManager.checkOwnership(website.domain, self.extraArgs['adminID'], self.extraArgs['currentACL']) == 0:
statusFile = open(tempStatusPath, 'w')
statusFile.writelines('You dont own this site.[404]')
statusFile.close()
except:
ab = WebsiteManager()
coreResult = ab.submitWebsiteCreation(UserID, DataToPass)
coreResult1 = json.loads((coreResult).content)

View File

@@ -50,8 +50,10 @@ function FinalDeletePluginBuucket() {
var SPVal;
app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window, $compile) {
$scope.webSiteCreationLoading = true;
$scope.SearchPluginName = function (val) {
$scope.webSiteCreationLoading = false;
SPVal = val;
url = "/websites/SearchOnkeyupPlugin";
@@ -72,6 +74,7 @@ app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window, $co
function ListInitialDatas(response) {
$scope.webSiteCreationLoading = true;
if (response.data.status === 1) {
if (SPVal == 'add') {
@@ -138,12 +141,19 @@ app.controller('WPAddNewPlugin', function ($scope, $http, $timeout, $window, $co
function ListInitialDatas(response) {
if (response.data.status === 1) {
alert("added..........");
new PNotify({
title: 'Success!',
text: 'Bucket created.',
type: 'success'
});
location.reload();
} else {
// $scope.errorMessage = response.data.error_message;
alert("Status not = 1: Error..." + response.data.error_message)
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
@@ -275,7 +285,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
var adminEmail = $scope.adminEmail;
var WPPassword = $scope.WPPassword;
var WPVersions = $scope.WPVersions;
var pluginbucket = $('#pliginbucket').val();
var pluginbucket = $scope.pluginbucket;
var autoupdates = $scope.autoupdates;
var pluginupdates = $scope.pluginupdates;
var themeupdates = $scope.themeupdates;
@@ -305,7 +315,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
function ListInitialDatas(response) {
$scope.webSiteCreationLoading = true;
if (response.data.status === 1) {
statusFile = response.data.tempStatusPath;
getCreationStatus();
@@ -338,7 +348,6 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
$scope.goBackDisable = true;
$("#installProgress").css("width", "0%");
};
function getCreationStatus() {
url = "/websites/installWordpressStatus";
@@ -359,7 +368,6 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
function ListInitialDatas(response) {
if (response.data.abort === 1) {
if (response.data.installStatus === 1) {
@@ -377,7 +385,8 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
$scope.currentStatus = response.data.currentStatus;
$timeout.cancel();
} else {
}
else {
$scope.webSiteCreationLoading = true;
$scope.installationDetailsForm = true;
@@ -396,6 +405,7 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
}
} else {
$scope.webSiteCreationLoading = false;
$("#installProgress").css("width", response.data.installationProgress + "%");
$scope.installPercentage = response.data.installationProgress;
$scope.currentStatus = response.data.currentStatus;

View File

@@ -20,19 +20,18 @@
<form name="websiteCreationForm" action="/" id="createPackages"
class="form-horizontal bordered-row panel-body">
<label>{% trans "Plugin Bucket Name" %}</label>
<label>{% trans "Plugin Bucket Name" %} <img ng-hide="webSiteCreationLoading"
src="{% static 'images/loading.gif' %}"></label>
<input name="PluginbucketName" type="text" class="form-control"
ng-model="PluginbucketName"
required>
<label style="margin-top: 15px;">{% trans "Search Plugin Name" %}</label>
<input name="searchcontent" type="text" class="form-control" ng-model="searchcontent"
ng-keyup="SearchPluginName('add')"
ng-keyup="$event.keyCode == 13 ? SearchPluginName('add') : null"
placeholder="{% trans "Search Plugin...." %}" required>
<div id="mysearch" class="col-lg-12" style="display: none; border-top: none!important;
@@ -42,7 +41,6 @@
</div>
<h3 style="margin-top: 20px;">Selected Plugin</h3>
<div id="selJS" style="display: none; display: flex; flex-direction: row; margin-top: 10px;">

View File

@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "plugin - CyberPanel" %}{% endblock %}
{% block title %}{% trans "Create Plugin Buckets - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}

View File

@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Create New WordPress - CyberPanel" %}{% endblock %}
{% block title %}{% trans "Deploy WordPress - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
@@ -106,7 +106,7 @@
<div ng-hide="installationDetailsForm" class="form-group">
<label class="col-sm-3 control-label">{% trans "Plugin/Theme" %}</label>
<div class="col-sm-6">
<select id="pliginbucket" ng-model="pluginbucket" class="form-control">
<select ng-model="pluginbucket" class="form-control">
<option value="-1" selected>Select Plugin Bucket</option>
{% for wp in Plugins %}
<option value="{{ wp.id }}">{{ wp.Name }}</option>

View File

@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "plugin - CyberPanel" %}{% endblock %}
{% block title %}{% trans "Edit Plugin Bucket - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}

View File

@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Worpress Manager - CyberPanel" %}{% endblock %}
{% block title %}{% trans "WordPress Manager - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}

View File

@@ -1,6 +1,6 @@
{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "WordPress List - CyberPanel" %}{% endblock %}
{% block title %}{% trans "WordPress Sites - CyberPanel" %}{% endblock %}
{% block content %}
{% load static %}
@@ -150,7 +150,7 @@
<div class="modal-body">
<form name="DeleteDocumentRootForm" action="/" class="form-horizontal">
<span>Do you want to delete the site??</span>
<span>Do you want to delete the site?</span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary"
@@ -158,7 +158,7 @@
</button>
<button type="button" ng-disabled="savingSettings"
class="btn btn-default" data-dismiss="modal">
NOt
Cancel
</button>
</div>
</div>

View File

@@ -63,9 +63,7 @@ class WebsiteManager:
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
packagesName = ACLManager.loadPackages(userID, currentACL)
phps = PHPManager.findPHPVersions()
FinalVersions = []
#logging.CyberCPLogFileWriter.writeToFile("jassssssssss...............")
userobj = Administrator.objects.get(pk=userID)
counter = 0
try:
@@ -78,14 +76,11 @@ class WebsiteManager:
if versions['current'] not in FinalVersions:
FinalVersions.append(versions['current'])
counter = counter + 1
except:
FinalVersions = ['5.6', '5.5.3', '5.5.2']
Plugins = wpplugins.objects.filter(owner=userobj)
# logging.CyberCPLogFileWriter.writeToFile("FinalVersions:%s"+str(FinalVersions))
Data = {'packageList': packagesName, "owernList": adminNames, 'WPVersions': FinalVersions, 'Plugins': Plugins }
proc = httpProc(request, 'websiteFunctions/WPCreate.html',
Data, 'createWebsite')
@@ -94,16 +89,17 @@ class WebsiteManager:
def ListWPSites(self, request=None, userID=None, DeleteID=None):
currentACL = ACLManager.loadedACL(userID)
userobj = Administrator.objects.get(pk=userID)
webobjs = Websites.objects.all()
admin = Administrator.objects.get(pk=userID)
tata = {}
tata['wp']=[]
tata['wpsites']=[]
tata['wp'] = WPSites.objects.all()
tata['wp'] = ACLManager.GetALLWPObjects(currentACL, userID)
try:
if DeleteID != None:
WPDelete = WPSites.objects.get(pk=DeleteID)
if ACLManager.checkOwnership(WPDelete.owner.domain, admin, currentACL) == 1:
WPDelete.delete()
except BaseException as msg:
@@ -115,8 +111,6 @@ class WebsiteManager:
'url': sub.FinalURL
})
proc = httpProc(request, 'websiteFunctions/WPsitesList.html',
{"wpsite": tata['wpsites']})
return proc.render()
@@ -125,6 +119,12 @@ class WebsiteManager:
Data = {}
currentACL = ACLManager.loadedACL(userID)
WPobj = WPSites.objects.get(pk=WPid)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
Data['wpsite'] = WPobj
@@ -132,11 +132,10 @@ class WebsiteManager:
DeleteID = request.GET.get('DeleteID', None)
if DeleteID != None:
wstagingDelete = WPStaging.objects.get(pk=DeleteID)
wstagingDelete = WPStaging.objects.get(pk=DeleteID, owner=WPobj)
wstagingDelete.delete()
except BaseException as msg:
da= str(msg)
proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
@@ -146,7 +145,14 @@ class WebsiteManager:
def AutoLogin(self, request=None, userID=None):
WPid = request.GET.get('id')
currentACL = ACLManager.loadedACL(userID)
WPobj = WPSites.objects.get(pk=WPid)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(WPobj.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
#php = VirtualHost.getPHPString(self.data['PHPVersion'])
#FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
@@ -176,27 +182,21 @@ class WebsiteManager:
data, 'createWebsite')
return proc.render()
def ConfigurePlugins(self, request=None, userID=None, data=None):
DataPass ={}
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
packagesName = ACLManager.loadPackages(userID, currentACL)
phps = PHPManager.findPHPVersions()
userobj = Administrator.objects.get(pk=userID)
Selectedplugins = wpplugins.objects.filter(owner = userobj)
#data['Selectedplugins'] = wpplugins.objects.filter(ProjectOwner=HostingCompany)
Data = {'packageList': packagesName, "owernList": adminNames, 'phps': phps, 'Selectedplugins' : Selectedplugins,}
Data = {'Selectedplugins' : Selectedplugins,}
proc = httpProc(request, 'websiteFunctions/WPConfigurePlugins.html',
Data, 'createWebsite')
return proc.render()
def Addnewplugin(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
adminNames = ACLManager.loadAllUsers(userID)
@@ -233,7 +233,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def AddNewpluginAjax(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -260,7 +259,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def EidtPlugin(self,request=None, userID=None, pluginbID=None):
Data ={}
currentACL = ACLManager.loadedACL(userID)
@@ -275,7 +273,6 @@ class WebsiteManager:
Data, 'createWebsite')
return proc.render()
def deletesPlgin(self, userID=None, data=None,):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -304,7 +301,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def Addplugineidt(self, userID=None, data=None,):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -343,7 +339,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def modifyWebsite(self, request=None, userID=None, data=None):
currentACL = ACLManager.loadedACL(userID)
@@ -429,7 +424,6 @@ class WebsiteManager:
})
return proc.render()
def FetchWPdata(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -437,20 +431,23 @@ class WebsiteManager:
WPManagerID = data['WPid']
wpsite = WPSites.objects.get(pk=WPManagerID)
path = wpsite.path
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
Vhuser = Webobj.externalApp
PHPVersion = Webobj.phpSelection
php = ACLManager.getPHPString(PHPVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
command = 'sudo -u %s %s -d error_reporting=0 /usr/bin/wp core version --skip-plugins --skip-themes --path=%s' % (Vhuser, FinalPHPPath, path)
version = ProcessUtilities.outputExecutioner(command)
@@ -506,7 +503,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def GetCurrentPlugins(self, userID=None, data=None):
try:
@@ -515,6 +511,12 @@ class WebsiteManager:
WPManagerID = data['WPid']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -540,7 +542,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def GetCurrentThemes(self, userID=None, data=None):
try:
@@ -549,6 +550,12 @@ class WebsiteManager:
WPManagerID = data['WPid']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -577,7 +584,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def fetchstaging(self, userID=None, data=None):
try:
@@ -587,6 +593,10 @@ class WebsiteManager:
WPManagerID = data['WPid']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
from plogical.phpUtilities import phpUtilities
@@ -604,8 +614,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def SaveUpdateConfig(self, userID=None, data=None):
try:
@@ -619,6 +627,11 @@ class WebsiteManager:
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
wpsite.AutoUpdates = AutomaticUpdates
wpsite.PluginUpdates = Plugins
wpsite.ThemeUpdates = Themes
@@ -634,7 +647,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def UpdatePlugins(self, userID=None, data=None):
try:
@@ -645,6 +657,12 @@ class WebsiteManager:
plugin = data['plugin']
pluginarray = data['pluginarray']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -679,7 +697,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def UpdateThemes(self, userID=None, data=None):
try:
@@ -691,6 +708,12 @@ class WebsiteManager:
Theme = data['Theme']
Themearray = data['Themearray']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -731,8 +754,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def DeletePlugins(self, userID=None, data=None):
try:
@@ -743,6 +764,12 @@ class WebsiteManager:
plugin = data['plugin']
pluginarray = data['pluginarray']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -776,7 +803,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def DeleteThemes(self, userID=None, data=None):
try:
@@ -791,6 +817,11 @@ class WebsiteManager:
Webobj= Websites.objects.get(pk=wpsite.owner_id)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
Vhuser = Webobj.externalApp
PHPVersion = Webobj.phpSelection
php = ACLManager.getPHPString(PHPVersion)
@@ -822,7 +853,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def ChangeStatus(self, userID=None, data=None):
try:
@@ -832,6 +862,12 @@ class WebsiteManager:
WPManagerID = data['WPid']
plugin = data['plugin']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -868,7 +904,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def ChangeStatusThemes(self, userID=None, data=None):
try:
# logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s")
@@ -878,6 +913,12 @@ class WebsiteManager:
WPManagerID = data['WPid']
Theme = data['theme']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -914,7 +955,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def CreateStagingNow(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
@@ -927,6 +967,13 @@ class WebsiteManager:
extraArgs['WPid'] = data['WPid']
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
wpsite = WPSites.objects.get(pk=data['WPid'])
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
background = ApplicationInstaller('CreateStagingNow', extraArgs)
background.start()
@@ -943,9 +990,6 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def UpdateWPSettings(self, userID=None, data=None):
try:
@@ -956,6 +1000,12 @@ class WebsiteManager:
setting = data['setting']
settingValue = data['settingValue']
wpsite = WPSites.objects.get(pk=WPManagerID)
if ACLManager.checkOwnership(wpsite.owner.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
path = wpsite.path
Webobj= Websites.objects.get(pk=wpsite.owner_id)
@@ -1047,18 +1097,22 @@ class WebsiteManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def submitWorpressCreation(self, userID=None, data=None):
try:
currentACL = ACLManager.loadedACL(userID)
admin = Administrator.objects.get(pk=userID)
extraArgs = {}
extraArgs['currentACL'] = currentACL
extraArgs['adminID'] = admin.pk
extraArgs['domainName'] = data['domain']
extraArgs['WPVersion'] = data['WPVersion']
extraArgs['blogTitle'] = data['title']
try:
extraArgs['pluginbucket'] = data['pluginbucket']
except:
extraArgs['pluginbucket'] = '-1'
extraArgs['adminUser'] = data['adminUser']
extraArgs['PasswordByPass'] = data['PasswordByPass']
extraArgs['adminPassword'] = data['PasswordByPass']