mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
wpmanager
This commit is contained in:
@@ -16,7 +16,7 @@ import threading as multi
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
import subprocess
|
||||
from websiteFunctions.models import ChildDomains, Websites, WPSites
|
||||
from websiteFunctions.models import ChildDomains, Websites, WPSites, WPStaging
|
||||
from plogical import randomPassword
|
||||
from plogical.mysqlUtilities import mysqlUtilities
|
||||
from databases.models import Databases
|
||||
@@ -74,6 +74,8 @@ class ApplicationInstaller(multi.Thread):
|
||||
self.DeletePlugins()
|
||||
elif self.installApp == 'ChangeStatusThemes':
|
||||
self.ChangeStatusThemes()
|
||||
elif self.installApp == 'CreateStagingNow':
|
||||
self.CreateStagingNow()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]')
|
||||
@@ -1880,6 +1882,176 @@ $parameters = array(
|
||||
stdoutput = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s" % str(msg))
|
||||
return 0
|
||||
|
||||
def CreateStagingNow(self):
|
||||
try:
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
import json
|
||||
tempStatusPath = self.data['tempStatusPath']
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating Website...,15')
|
||||
|
||||
statusFile.close()
|
||||
|
||||
wpobj = WPSites.objects.get(pk=self.data['WPid'])
|
||||
|
||||
DataToPass = {}
|
||||
|
||||
currentTemp = self.extraArgs['tempStatusPath']
|
||||
DataToPass['domainName'] = self.data['StagingDomain']
|
||||
DataToPass['adminEmail'] = wpobj.owner.adminEmail
|
||||
DataToPass['phpSelection'] = wpobj.owner.phpSelection
|
||||
DataToPass['websiteOwner'] = wpobj.owner.admin.userName
|
||||
DataToPass['package'] = 'Default'
|
||||
DataToPass['ssl'] = 1
|
||||
DataToPass['dkimCheck'] = 0
|
||||
DataToPass['openBasedir'] = 0
|
||||
DataToPass['mailDomain'] = 0
|
||||
UserID = self.data['adminID']
|
||||
|
||||
ab = WebsiteManager()
|
||||
coreResult = ab.submitWebsiteCreation(UserID, DataToPass)
|
||||
coreResult1 = json.loads((coreResult).content)
|
||||
logging.CyberCPLogFileWriter.writeToFile("Creating website result....%s" % coreResult1)
|
||||
reutrntempath = coreResult1['tempStatusPath']
|
||||
while (1):
|
||||
lastLine = open(reutrntempath, 'r').read()
|
||||
|
||||
if lastLine.find('[200]') > -1:
|
||||
break
|
||||
elif lastLine.find('[404]') > -1:
|
||||
statusFile = open(currentTemp, 'w')
|
||||
statusFile.writelines('Failed to Create Website: error: %s[404]' % lastLine)
|
||||
statusFile.close()
|
||||
return 0
|
||||
else:
|
||||
statusFile = open(currentTemp, 'w')
|
||||
statusFile.writelines('Creating Website....,20')
|
||||
statusFile.close()
|
||||
time.sleep(2)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Installing WordPress....')
|
||||
statusFile.close()
|
||||
|
||||
####No crreating DataBAse.............
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating DataBase....,30')
|
||||
statusFile.close()
|
||||
website = Websites.objects.get(domain=self.data['StagingDomain'])
|
||||
|
||||
dbNameRestore, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Creating Staging....,50')
|
||||
statusFile.close()
|
||||
|
||||
|
||||
masterDomain= wpobj.owner.domain
|
||||
domain = self.data['StagingDomain']
|
||||
|
||||
path= wpobj.path
|
||||
|
||||
Vhuser = website.externalApp
|
||||
PHPVersion = website.phpSelection
|
||||
php = ACLManager.getPHPString(PHPVersion)
|
||||
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp core config --dbname=%s --dbuser=%s --dbpass=%s --dbhost=%s:%s --path=%s' % (
|
||||
FinalPHPPath, dbNameRestore, dbUser, dbPassword, ApplicationInstaller.LOCALHOST, ApplicationInstaller.PORT, path)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
try:
|
||||
masterPath = '/home/%s/public_html/%s' % (masterDomain, path)
|
||||
replaceDomain = '%s/%s' % (masterDomain, path)
|
||||
except:
|
||||
masterPath = '/home/%s/public_html' % (masterDomain)
|
||||
replaceDomain = masterDomain
|
||||
|
||||
### Get table prefix of master site
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp config get table_prefix --allow-root --skip-plugins --skip-themes --path=%s' % (
|
||||
FinalPHPPath, masterPath)
|
||||
TablePrefix = ProcessUtilities.outputExecutioner(command).rstrip('\n')
|
||||
|
||||
### Set table prefix
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp config set table_prefix %s --path=%s' % (
|
||||
FinalPHPPath, TablePrefix, path)
|
||||
ProcessUtilities.executioner(command, website.externalApp)
|
||||
|
||||
## Exporting and importing database
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s db export %s/dbexport-stage.sql' % (
|
||||
FinalPHPPath, masterPath, path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Import
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp --allow-root --skip-plugins --skip-themes --path=%s --quiet db import %s/dbexport-stage.sql' % (
|
||||
FinalPHPPath, path, path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
try:
|
||||
command = 'rm -f %s/dbexport-stage.sql' % (path)
|
||||
ProcessUtilities.executioner(command)
|
||||
except:
|
||||
pass
|
||||
|
||||
## Sync WP-Content Folder
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp theme path --skip-plugins --skip-themes --allow-root --path=%s' % (FinalPHPPath, masterPath)
|
||||
WpContentPath = ProcessUtilities.outputExecutioner(command).splitlines()[-1].replace('themes', '')
|
||||
|
||||
command = 'cp -R %s %s/' % (WpContentPath, path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Copy htaccess
|
||||
|
||||
command = 'cp -f %s/.htaccess %s/' % (WpContentPath.replace('/wp-content/', ''), path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Search and replace url
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "%s" "%s"' % (FinalPHPPath, path, replaceDomain, domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "www.%s" "%s"' % (FinalPHPPath, path, domain, domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = '%s -d error_reporting=0 /usr/bin/wp search-replace --skip-plugins --skip-themes --allow-root --path=%s "https://%s" "http://%s"' % (
|
||||
FinalPHPPath, path, domain, domain)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(masterDomain)
|
||||
|
||||
from plogical.installUtilities import installUtilities
|
||||
installUtilities.reStartLiteSpeed()
|
||||
|
||||
|
||||
|
||||
wpsite = WPSites(owner=website, title=self.data['StagingName'],
|
||||
path ="/home/%s/public_html"%(self.extraArgs['StagingDomain']),
|
||||
FinalURL='%s' % (self.data['StagingDomain']))
|
||||
wpsite.save()
|
||||
|
||||
WPStaging(wpsite=wpsite, owner=wpobj).save()
|
||||
statusFile = open(currentTemp, 'w')
|
||||
statusFile.writelines('statging Created..,[200]')
|
||||
statusFile.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s" % str(msg))
|
||||
return 0
|
||||
|
||||
@@ -10,6 +10,9 @@ import os
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
import json
|
||||
from django.urls import reverse
|
||||
|
||||
class phpUtilities:
|
||||
|
||||
installLogPath = "/home/cyberpanel/phpExtensionRequestLog"
|
||||
@@ -182,6 +185,32 @@ class phpUtilities:
|
||||
print("0,"+str(msg))
|
||||
|
||||
|
||||
@staticmethod
|
||||
def GetStagingInJson(stagings):
|
||||
try:
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
counter = 1
|
||||
|
||||
for staging in stagings:
|
||||
dic = { 'id': staging.wpsite.id ,'name': staging.wpsite.title, 'Domain': staging.wpsite.owner.domain, 'path': staging.wpsite.path,
|
||||
#'url': reverse('WPHome', args=[staging.wpsite.owner.ProjectOwner.ProjectOwner.id, staging.wpsite.owner.ProjectOwner.id, staging.wpsite.id]),
|
||||
'deleteURL': '%s?ID=%s&DeleteID=%s' % (reverse('WPHome'), staging.owner.id, staging.id)
|
||||
}
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
counter = counter + 1
|
||||
|
||||
json_data = json_data + ']'
|
||||
return json_data
|
||||
except BaseException as msg:
|
||||
return msg
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
|
||||
@@ -422,6 +422,12 @@ app.controller('createWordpress', function ($scope, $http, $timeout, $compile, $
|
||||
|
||||
app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $window) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$(document).ready(function () {
|
||||
var checkstatus = document.getElementById("wordpresshome");
|
||||
if (checkstatus !== null) {
|
||||
@@ -1004,6 +1010,197 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
AppendToTable('#ThemeBody', temp)
|
||||
}
|
||||
|
||||
$scope.CreateStagingNow = function () {
|
||||
|
||||
$scope.wordpresshomeloading = false;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
|
||||
|
||||
$scope.currentStatus = "Starting creation Staging..";
|
||||
var data = {
|
||||
StagingName: $('#stagingName').val(),
|
||||
StagingDomain: $('#stagingDomain').val(),
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
var url = "/websites/CreateStagingNow";
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
getCreationStatus();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
alert(response)
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function getCreationStatus() {
|
||||
|
||||
url = "/websites/installWordpressStatus";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.abort === 1) {
|
||||
|
||||
if (response.data.installStatus === 1) {
|
||||
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = false;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$("#installProgress").css("width", "100%");
|
||||
$scope.installPercentage = "100";
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout.cancel();
|
||||
|
||||
} else {
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = false;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
|
||||
$("#installProgress").css("width", "0%");
|
||||
$scope.installPercentage = "0";
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$("#installProgress").css("width", response.data.installationProgress + "%");
|
||||
$scope.installPercentage = response.data.installationProgress;
|
||||
$scope.currentStatus = response.data.currentStatus;
|
||||
$timeout(getCreationStatus, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = true;
|
||||
$scope.installationProgress = false;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = false;
|
||||
$scope.goBackDisable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$scope.goBack = function () {
|
||||
$scope.wordpresshomeloading = true;
|
||||
$scope.stagingDetailsForm = false;
|
||||
$scope.installationProgress = true;
|
||||
$scope.errorMessageBox = true;
|
||||
$scope.success = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.goBackDisable = true;
|
||||
$("#installProgress").css("width", "0%");
|
||||
};
|
||||
|
||||
$scope.fetchstaging = function () {
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
var url = "/websites/fetchstaging";
|
||||
|
||||
var data = {
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
wordpresshomeloading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
|
||||
// $('#ThemeBody').html('');
|
||||
// var themes = JSON.parse(response.data.themes);
|
||||
// themes.forEach(AddThemes);
|
||||
|
||||
$('#StagingBody').html('');
|
||||
var staging = JSON.parse(response.data.wpsites);
|
||||
staging.forEach(AddStagings);
|
||||
|
||||
} else {
|
||||
alert("Error data.error_message:" + response.data.error_message)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
alert("Error"+response)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
$scope.autoLogin = function () {
|
||||
var url = "/websites/DeleteThemes";
|
||||
//window.open("/wpmanager/" + $('#HostingCompanyID').html() + "/manage/" + server + "/" + wordpress + "/AutoLogin");
|
||||
@@ -1011,8 +1208,76 @@ app.controller('WPsiteHome', function ($scope, $http, $timeout, $compile, $windo
|
||||
window.open("/websites/AutoLogin?WordPressID="+sub.id);
|
||||
}
|
||||
|
||||
$scope.SaveUpdateConfig =function () {
|
||||
var data = {
|
||||
AutomaticUpdates: $('#AutomaticUpdates').find(":selected").text(),
|
||||
Plugins: $('#Plugins').find(":selected").text(),
|
||||
Themes: $('#Themes').find(":selected").text(),
|
||||
WPid: $('#WPid').html(),
|
||||
}
|
||||
|
||||
$scope.wordpresshomeloading = false;
|
||||
|
||||
var url = "/websites/SaveUpdateConfig";
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.wordpresshomeloading = true;
|
||||
|
||||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Update Configurations Sucessfully!.',
|
||||
type: 'success'
|
||||
});
|
||||
$("#autoUpdateConfig").modal('hide');
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
function AddStagings(value, index, array) {
|
||||
var FinalMarkup = '<tr>'
|
||||
for (let x in value) {
|
||||
if (x === 'name') {
|
||||
FinalMarkup = FinalMarkup + '<td><a href="' + value.url + '">' + value[x] + '</a></td>';
|
||||
} else if (x !== 'url' && x !== 'deleteURL' && x !== 'id') {
|
||||
FinalMarkup = FinalMarkup + '<td>' + value[x] + "</td>";
|
||||
}
|
||||
}
|
||||
FinalMarkup = FinalMarkup + '<td><button onclick="DeployToProductionInitial(' + value.id + ')" data-toggle="modal" data-target="#DeployToProduction" style="margin-bottom: 2%; display: block" aria-label="" type="button" class="btn btn-outline-primary">Deploy to Production</button>' +
|
||||
'<a href="' + value.deleteURL + '"> <button aria-label="" class="btn btn-danger btn-icon-left m-b-10" type="button">Delete</button></a></td>'
|
||||
FinalMarkup = FinalMarkup + '</tr>'
|
||||
AppendToTable('#StagingBody', FinalMarkup);
|
||||
}
|
||||
|
||||
var PluginsList = [];
|
||||
|
||||
|
||||
|
||||
@@ -61,75 +61,69 @@
|
||||
<div id="autoUpdateConfig" class="modal fade" tabindex="-1" role="dialog"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="text-center mt-2 mb-4">
|
||||
</div>
|
||||
|
||||
<!-- Modal content-->
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×
|
||||
</button>
|
||||
<h4 class="modal-title">{% trans "Updates" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form>
|
||||
|
||||
|
||||
<h3 style="margin-top: 2%">UPDATES</h3>
|
||||
<p>Configure setting for automatic updates.</p>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Automatic Updates
|
||||
(Currently: {{ wpsite.AutoUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="AutomaticUpdates"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Disabled</option>
|
||||
<option>Minor and Security Updates</option>
|
||||
<option>All (minor and major)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Plugins
|
||||
(Currently: {{ wpsite.PluginUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="Plugins"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h5 class="font-arial">Themes
|
||||
(Currently: {{ wpsite.ThemeUpdates }})</h5>
|
||||
<div class="col-12">
|
||||
<select id="Themes"
|
||||
class="form-group form-group-default"
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row bg-dark"
|
||||
style="border-radius: 2%;margin-top: 1%">
|
||||
<div class="v-align-middle col-12 ">
|
||||
<button onclick="SaveAutoUpdateSettings()"
|
||||
aria-label=""
|
||||
type="button"
|
||||
class="v-align-middle btn bg-dark col-12"
|
||||
style="color: white; padding: 15px">
|
||||
Save Changes <img
|
||||
class="LPLoader"
|
||||
style="margin-left: 2%"
|
||||
src="{% static 'BaseTemplates/images/loader.gif' %}">
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<h4 style="margin: 2%">Configure setting for automatic updates.</h4>
|
||||
<div class="row">
|
||||
<label class="col-lg-6">Automatic Updates (Currently:
|
||||
{{ wpsite.AutoUpdates }})</label>
|
||||
<div class="col-lg-6">
|
||||
<select id="AutomaticUpdates"
|
||||
style="padding: 10px">
|
||||
<option>Disabled</option>
|
||||
<option>Minor and Security Updates</option>
|
||||
<option>All (minor and major)</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4">Plugins (Currently: {{ wpsite.PluginUpdates }})</label>
|
||||
<div class="col-lg-8">
|
||||
<select id="Plugins"
|
||||
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-lg-4">Themes (Currently: {{ wpsite.ThemeUpdates }})</label>
|
||||
<div class="col-lg-8">
|
||||
<select id="Themes"
|
||||
|
||||
style="padding: 10px">
|
||||
<option>Enabled</option>
|
||||
<option>Disabled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary"
|
||||
ng-click="SaveUpdateConfig()">Save
|
||||
</button>
|
||||
<button type="button" ng-disabled="savingSettings"
|
||||
class="btn btn-default" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
@@ -154,7 +148,8 @@
|
||||
data-toggle="tab">Plugins</a></li>
|
||||
<li class=""><a href="#tab3" ng-click="GetCurrentThemes()"
|
||||
data-toggle="tab">Themes</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab">Staging</a></li>
|
||||
<li><a href="#tab4" data-toggle="tab"
|
||||
ng-click="fetchstaging()">Staging</a></li>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
@@ -210,7 +205,7 @@
|
||||
Login
|
||||
</a>
|
||||
<a style="margin-left: 4%" target="_blank"
|
||||
href="/websites/{{ wpsite.owner.domain}}/manageGIT">
|
||||
href="/websites/{{ wpsite.owner.domain }}/manageGIT">
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
aria-hidden="true" focusable="false" width="1em"
|
||||
@@ -392,10 +387,90 @@
|
||||
</table>
|
||||
</div>
|
||||
<div class="tab-pane" id="tab4">
|
||||
<p>Howdy, I'm in Section 4.</p>
|
||||
<h2>Create Staging site</h2>
|
||||
<div ng-hide="stagingDetailsForm" class="form-group">
|
||||
<label style="margin-bottom: 2%!important; margin-top: 2%!important;"
|
||||
class="col-sm-2 control-label">Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input style="margin-bottom: 2%!important; margin-top: 2%!important;"
|
||||
type="text" class="form-control" id="stagingName">
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="stagingDetailsForm" class="form-group mt-5">
|
||||
<label style="margin-bottom: 2%!important;"
|
||||
class="col-sm-2 control-label">Domain Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input style="margin-bottom: 2%!important;"
|
||||
type="text" class="form-control" id="stagingDomain">
|
||||
</div>
|
||||
</div>
|
||||
<div ng-hide="stagingDetailsForm" class="center-div mt-5">
|
||||
<button ng-click="CreateStagingNow()"
|
||||
style="margin-bottom: 2%!important;"
|
||||
class="btn btn-alt btn-hover btn-blue-alt">
|
||||
<span>Create Now</span>
|
||||
<i class="glyph-icon icon-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-7">
|
||||
|
||||
<div class="alert alert-success text-center">
|
||||
<h2>{$ currentStatus $}</h2>
|
||||
</div>
|
||||
|
||||
<div class="progress">
|
||||
<div id="installProgress" class="progress-bar"
|
||||
role="progressbar" aria-valuenow="70"
|
||||
aria-valuemin="0" aria-valuemax="100"
|
||||
style="width:0%">
|
||||
<span class="sr-only">70% Complete</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="errorMessageBox" class="alert alert-danger">
|
||||
<p>{% trans "Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="success" class="alert alert-success">
|
||||
<p>{% trans "Website succesfully created." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="installationProgress" class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-disabled="goBackDisable"
|
||||
ng-click="goBack()"
|
||||
class="btn btn-primary btn-lg center-div">{% trans "Go Back" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h3>List staging site</h3>
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Domain</th>
|
||||
<th>Path</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="StagingBody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ urlpatterns = [
|
||||
url(r'^UpdateThemes', views.UpdateThemes, name='UpdateThemes'),
|
||||
url(r'^DeleteThemes', views.DeleteThemes, name='DeleteThemes'),
|
||||
url(r'^StatusThemes', views.StatusThemes, name='StatusThemes'),
|
||||
url(r'^CreateStagingNow', views.CreateStagingNow, name='CreateStagingNow'),
|
||||
url(r'^fetchstaging', views.fetchstaging, name='fetchstaging'),
|
||||
url(r'^SaveUpdateConfig', views.SaveUpdateConfig, name='SaveUpdateConfig'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ def WPHome(request):
|
||||
userID = request.session['userID']
|
||||
|
||||
WPid = request.GET.get('ID')
|
||||
DeleteID = request.GET.get('DeleteID')
|
||||
wm = WebsiteManager()
|
||||
return wm.WPHome(request, userID, WPid)
|
||||
return wm.WPHome(request, userID, WPid, DeleteID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
def AutoLogin(request):
|
||||
@@ -89,6 +90,9 @@ def Addnewplugin(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
|
||||
def SearchOnkeyupPlugin(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -243,6 +247,50 @@ def GetCurrentPlugins(request):
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.GetCurrentPlugins(userID, json.loads(request.body))
|
||||
# coreResult = wm.GetCsurrentPlugins(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def fetchstaging(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.fetchstaging(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def SaveUpdateConfig(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.SaveUpdateConfig(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
@@ -431,6 +479,28 @@ def StatusThemes(request):
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def CreateStagingNow(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
result = pluginManager.preWebsiteCreation(request)
|
||||
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
wm = WebsiteManager()
|
||||
coreResult = wm.CreateStagingNow(userID, json.loads(request.body))
|
||||
|
||||
result = pluginManager.postWebsiteCreation(request, coreResult)
|
||||
if result != 200:
|
||||
return result
|
||||
|
||||
return coreResult
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
def modifyWebsite(request):
|
||||
try:
|
||||
|
||||
@@ -12,7 +12,7 @@ django.setup()
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites
|
||||
from websiteFunctions.models import Websites, ChildDomains, GitLogs, wpplugins, WPSites, WPStaging
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
@@ -113,13 +113,23 @@ class WebsiteManager:
|
||||
{"wpsite": tata['wpsites']})
|
||||
return proc.render()
|
||||
|
||||
def WPHome(self, request=None, userID=None, WPid=None):
|
||||
def WPHome(self, request=None, userID=None, WPid=None, DeleteID=None):
|
||||
Data = {}
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
WPobj = WPSites.objects.get(pk=WPid)
|
||||
|
||||
Data['wpsite'] = WPobj
|
||||
|
||||
try:
|
||||
DeleteID = request.GET.get('DeleteID', None)
|
||||
|
||||
if DeleteID != None:
|
||||
wstagingDelete = WPStaging.objects.get(pk=DeleteID)
|
||||
wstagingDelete.delete()
|
||||
|
||||
except BaseException as msg:
|
||||
|
||||
da= str(msg)
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/WPsiteHome.html',
|
||||
Data, 'createWebsite')
|
||||
@@ -548,6 +558,63 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def fetchstaging(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
|
||||
from plogical.phpUtilities import phpUtilities
|
||||
|
||||
|
||||
json_data = phpUtilities.GetStagingInJson(wpsite.wpstaging_set.all().order_by('-id'))
|
||||
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None', 'wpsites': json_data}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
def SaveUpdateConfig(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
WPManagerID = data['WPid']
|
||||
Plugins = data['Plugins']
|
||||
Themes = data['Themes']
|
||||
AutomaticUpdates = data['AutomaticUpdates']
|
||||
|
||||
wpsite = WPSites.objects.get(pk=WPManagerID)
|
||||
|
||||
wpsite.AutoUpdates = AutomaticUpdates
|
||||
wpsite.PluginUpdates = Plugins
|
||||
wpsite.ThemeUpdates = Themes
|
||||
wpsite.save()
|
||||
|
||||
data_ret = {'status': 1, 'error_message': 'None',}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def UpdatePlugins(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
@@ -828,6 +895,35 @@ class WebsiteManager:
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def CreateStagingNow(self, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['adminID'] = admin.pk
|
||||
extraArgs['StagingDomain'] = data['StagingDomain']
|
||||
extraArgs['StagingName'] = data['StagingName']
|
||||
extraArgs['WPid'] = data['WPid']
|
||||
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
background = ApplicationInstaller('CreateStagingNow', extraArgs)
|
||||
background.start()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
data_ret = {'status': 1, 'installStatus': 1, 'error_message': 'None',
|
||||
'tempStatusPath': extraArgs['tempStatusPath']}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
|
||||
|
||||
def UpdateWPSettings(self, userID=None, data=None):
|
||||
|
||||
Reference in New Issue
Block a user