Merge branch 'v2.3.2-dev' of github.com:usmannasir/cyberpanel into v2.3.2-dev

This commit is contained in:
Usman Nasir
2022-06-16 14:36:31 +05:00
4 changed files with 202 additions and 219 deletions

View File

@@ -3345,62 +3345,10 @@ $parameters = array(
except: except:
####Website found --> WPsite Found --> Final URL Not Match ####Website found --> WPsite Found --> Final URL Not Match
####Create new obj and call wordpressnew ####Create new obj and call wordpressnew
DataToPass = {} Newurl = wpsite.FinalURL
WPpath = wpsite.path
DataToPass['title'] = config['WPtitle'] VHuser = wpsite.owner.externalApp
DataToPass['WPVersion'] = "6.0" PhpVersion = wpsite.owner.phpSelection
DataToPass['adminUser'] = config['WebVHuser']
DataToPass['Email'] = config['WebadminEmail']
DataToPass['PasswordByPass'] = config['DatabaseUser']
DataToPass['AutomaticUpdates'] = config['WPAutoUpdates']
DataToPass['Plugins'] = config['WPPluginUpdates']
DataToPass['Themes'] = config['WPThemeUpdates']
DataToPass['websiteOwner'] = WebOwner
DataToPass['package'] = packegs
# create path
try:
abc = config['WPsitepath'].split("/")
wppamndath = abc[4]
home = "0"
except:
abc = config['WPsitepath'].split("/")
wppamndath = abc[3]
home = "1"
DataToPass['domain'] = webobj.domain
DataToPass['path'] = wppamndath
DataToPass['home'] = home
Furlofnewp = "%s/%s" % (webobj.domain, wppamndath)
try:
website = Websites.objects.get(domain=DomainName)
logging.statusWriter(self.tempStatusPath, 'Web Site Already Exist.[404]')
except:
ab = WebsiteManager()
coreResult = ab.submitWorpressCreation(userID, DataToPass)
coreResult1 = json.loads((coreResult).content)
logging.writeToFile("WP Creating website result....%s" % coreResult1)
reutrntempath = coreResult1['tempStatusPath']
while (1):
lastLine = open(reutrntempath, 'r').read()
logging.writeToFile("Error WP creating lastline ....... %s" % lastLine)
if lastLine.find('[200]') > -1:
break
elif lastLine.find('[404]') > -1:
logging.statusWriter(self.tempStatusPath,
'Failed to WordPress: error: %s. [404]' % lastLine)
return 0
else:
logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20')
time.sleep(2)
##### Now resting start
newWPobj = WPSites.objects.get(FinalURL=Furlofnewp)
## get WPsite Database name and usr
Newurl = newWPobj.FinalURL
WPpath = newWPobj.path
VHuser = newWPobj.owner.externalApp
PhpVersion = newWPobj.owner.phpSelection
php = PHPManager.getPHPString(PhpVersion) php = PHPManager.getPHPString(PhpVersion)
FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php) FinalPHPPath = '/usr/local/lsws/lsphp%s/bin/php' % (php)
@@ -3449,7 +3397,7 @@ $parameters = array(
if result == 0: if result == 0:
raise BaseException(stdout) raise BaseException(stdout)
command = f'chown -R {newWPobj.owner.externalApp}:{newWPobj.owner.externalApp} {self.tempPath}' command = f'chown -R {wpsite.owner.externalApp}:{wpsite.owner.externalApp} {self.tempPath}'
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
if result == 0: if result == 0:
@@ -3544,12 +3492,16 @@ $parameters = array(
if stdout.find('Error:') > -1: if stdout.find('Error:') > -1:
raise BaseException(stdout) raise BaseException(stdout)
# ##Remove temppath # # ##Remove temppath
command = f'rm -rf {self.tempPath}' # command = f'rm -rf {self.tempPath}'
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) # result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)
#
# if result == 0:
# raise BaseException(stdout)
if result == 0:
raise BaseException(stdout)
#################################################################
@@ -3822,6 +3774,7 @@ $parameters = array(
elif(DomainName != "" and int(self.extraArgs['DesSiteID']) == -1): elif(DomainName != "" and int(self.extraArgs['DesSiteID']) == -1):
###############Create New WordPressSite First ###############Create New WordPressSite First
# logging.writeToFile("New Website Domain ....... %s" % str(DomainName)) # logging.writeToFile("New Website Domain ....... %s" % str(DomainName))
# logging.writeToFile("New Website Domain path....... %s" % str(self.extraArgs['path']))
DataToPass = {} DataToPass = {}
DataToPass['title'] = config['WPtitle'] DataToPass['title'] = config['WPtitle']
@@ -3839,24 +3792,19 @@ $parameters = array(
oldpath = config['WPsitepath'] oldpath = config['WPsitepath']
abc = oldpath.split("/") abc = oldpath.split("/")
newpath = abc[4] newpath = abc[4]
if newpath != "": oldhome = "0"
newurl = "%s/%s"%(DomainName,newpath)
else:
newurl = DomainName
home = "0"
except BaseException as msg: except BaseException as msg:
newpath = "" oldhome = "1"
if self.extraArgs['path'] == '':
newurl = DomainName newurl = DomainName
home = "1" else:
newurl = "%s/%s"%(DomainName, self.extraArgs['path'])
DataToPass['path'] = newpath DataToPass['path'] = self.extraArgs['path']
DataToPass['home'] = home DataToPass['home'] = self.extraArgs['home']
try:
website = Websites.objects.get(domain=DomainName)
logging.statusWriter(self.tempStatusPath, 'Web Site Already Exist.[404]')
except:
ab = WebsiteManager() ab = WebsiteManager()
coreResult = ab.submitWorpressCreation(userID, DataToPass) coreResult = ab.submitWorpressCreation(userID, DataToPass)
coreResult1 = json.loads((coreResult).content) coreResult1 = json.loads((coreResult).content)
@@ -3868,7 +3816,8 @@ $parameters = array(
if lastLine.find('[200]') > -1: if lastLine.find('[200]') > -1:
break break
elif lastLine.find('[404]') > -1: elif lastLine.find('[404]') > -1:
logging.statusWriter(self.tempStatusPath, 'Failed to Create WordPress: error: %s. [404]'% lastLine) logging.statusWriter(self.tempStatusPath,
'Failed to Create WordPress: error: %s. [404]' % lastLine)
return 0 return 0
else: else:
logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20') logging.statusWriter(self.tempStatusPath, 'Creating WordPress....,20')
@@ -3880,8 +3829,6 @@ $parameters = array(
PhpVersion = NewWPsite.owner.phpSelection PhpVersion = NewWPsite.owner.phpSelection
newWPpath = NewWPsite.path newWPpath = NewWPsite.path
###### Same code already used in Existing site ###### Same code already used in Existing site
### get WPsite Database name and usr ### get WPsite Database name and usr
@@ -3962,10 +3909,9 @@ $parameters = array(
if result == 0: if result == 0:
raise BaseException(stdout) raise BaseException(stdout)
logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60') logging.statusWriter(self.tempStatusPath, 'Copying Data File...,60')
###Copy backup content to newsite ###Copy backup content to newsite
if home == "0": if oldhome == "0":
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath) unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/" % (self.tempPath, oldtemppath)
else: else:
unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (self.tempPath, oldtemppath) unzippath = "%s/ab/usr/local/CyberCP/tmp/%s/public_html/public_html/" % (self.tempPath, oldtemppath)
@@ -3976,7 +3922,6 @@ $parameters = array(
if result == 0: if result == 0:
raise BaseException(stdout) raise BaseException(stdout)
command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, newWPpath) command = "sudo -u %s cp -R %s.[^.]* %s" % (VHuser, unzippath, newWPpath)
result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1) result, stdout = ProcessUtilities.outputExecutioner(command, None, None, None, 1)

View File

@@ -1556,19 +1556,31 @@ app.controller('RestoreWPBackup', function ($scope, $http, $timeout, $window) {
$scope.goBackDisable = true; $scope.goBackDisable = true;
$scope.currentStatus = "Start Restoring WordPress.."; $scope.currentStatus = "Start Restoring WordPress..";
var Domain = $scope.domainNameCreate;
var path = $('#wprestoresubdirpath').val()
var home = "1";
if (typeof path != 'undefined' || path != '') {
home = "0";
}
var backuptype = $('#backuptype').html(); var backuptype = $('#backuptype').html();
var data; var data;
if (backuptype == "DataBase Backup") { if (backuptype == "DataBase Backup") {
data = { data = {
backupid: $('#backupid').html(), backupid: $('#backupid').html(),
DesSite: $('#DesSite').children("option:selected").val(), DesSite: $('#DesSite').children("option:selected").val(),
Domain: '' Domain: '',
path: path,
home: home,
} }
} else { } else {
data = { data = {
backupid: $('#backupid').html(), backupid: $('#backupid').html(),
DesSite: $('#DesSite').children("option:selected").val(), DesSite: $('#DesSite').children("option:selected").val(),
Domain: $("input[name=Newdomain]").val() Domain: Domain,
path: path,
home: home,
} }
} }

View File

@@ -68,17 +68,39 @@
</div> </div>
</div> </div>
<div id="Newsitediv" ng-hide="installationDetailsForm" style="display: none" <div id="Newsitediv" ng-hide="installationDetailsForm" style="display: none" class="form-group">
class="form-group"> <label class="col-sm-2 control-label">{% trans "Domain Name" %}</label>
<label class="col-sm-2 control-label">{% trans "Website Domain" %}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input name="Newdomain" id="Newdomain" type="url" <div class="input-group bootstrap-touchspin">
placeholder="Enter New Website Domain for Restoring Website " <span
class="form-control" required> class="input-group-addon bootstrap-touchspin-prefix"
style="display: none;"></span>
<input ng-model="domainNameCreate" id="touchspin-demo-1" class="form-control"
type="text" value="55"
name="touchspin-demo-1"
style="display: block;"
placeholder="{% trans "Do not enter WWW, it will be auto created!" %}">
<span class="input-group-addon bootstrap-touchspin-postfix">/</span>
<span style="width: 25%" class="input-group-btn">
<input id="wprestoresubdirpath" class="form-control"
placeholder="{% trans "Leave empty for default" %}"
type="text" value="Leave empty for default"
name="wprestoresubdirpath" ng-model="installPath"
style="display: block;"></span></div>
</div> </div>
</div> </div>
{# <div id="Newsitediv" ng-hide="installationDetailsForm" style="display: none"#}
{# class="form-group">#}
{# <label class="col-sm-2 control-label">{% trans "Website Domain" %}</label>#}
{# <div class="col-sm-10">#}
{# <input name="Newdomain" id="Newdomain" type="url"#}
{# placeholder="Enter New Website Domain for Restoring Website "#}
{# class="form-control" required>#}
{# </div>#}
{# </div>#}
{% endif %} {% endif %}
<div ng-model="installationDetailsForm" class="col-sm-12 center-div"> <div ng-model="installationDetailsForm" class="col-sm-12 center-div" class="form-control">
<button id="RestoreWPbackupNow" type="button" <button id="RestoreWPbackupNow" type="button"
ng-click="RestoreWPbackupNow()" ng-click="RestoreWPbackupNow()"
class="btn btn-primary btn-lg center-div">{% trans "Restore Backup Now" %}</button> class="btn btn-primary btn-lg center-div">{% trans "Restore Backup Now" %}</button>

View File

@@ -185,15 +185,17 @@ class WebsiteManager:
try: try:
wpsite = WPSites.objects.get(pk=sub.WPSiteID) wpsite = WPSites.objects.get(pk=sub.WPSiteID)
web = wpsite.title web = wpsite.title
except:
web = "Website Not Found"
try:
config = sub.config config = sub.config
conf = json.loads(config) conf = json.loads(config)
Backuptype = conf['Backuptype'] Backuptype = conf['Backuptype']
except: except:
web = "Website Not Found"
Backuptype = "Backup type not exists" Backuptype = "Backup type not exists"
Data['job'].append({ Data['job'].append({
'id': sub.id, 'id': sub.id,
'title': web, 'title': web,
@@ -810,14 +812,16 @@ class WebsiteManager:
backupid = data['backupid'] backupid = data['backupid']
DesSiteID = data['DesSite'] DesSiteID = data['DesSite']
logging.CyberCPLogFileWriter.writeToFile("Error WP ChangeStatusThemes ....... %s"%data)
Domain = data['Domain'] Domain = data['Domain']
extraArgs = {} extraArgs = {}
extraArgs['adminID'] = admin.pk extraArgs['adminID'] = admin.pk
extraArgs['backupid'] = backupid extraArgs['backupid'] = backupid
extraArgs['DesSiteID'] = DesSiteID extraArgs['DesSiteID'] = DesSiteID
extraArgs['Domain'] = Domain extraArgs['Domain'] = Domain
extraArgs['path'] = data['path']
extraArgs['home'] = data['home']
extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))