bug fix: sub folder wp manager installations

This commit is contained in:
Usman Nasir
2021-02-15 20:57:30 +05:00
parent b6c8f72517
commit e922b47a8c
4 changed files with 306 additions and 55 deletions

View File

@@ -1961,12 +1961,22 @@ class CloudManager:
## Get versopm ## Get versopm
website = Websites.objects.get(domain=domain) website = Websites.objects.get(domain=domain)
command = 'wp core version --path=/home/%s/public_html' % (domain)
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
command = 'wp core version --path=%s' % (path)
finalDic['version'] = ProcessUtilities.outputExecutioner(command, website.externalApp) finalDic['version'] = ProcessUtilities.outputExecutioner(command, website.externalApp)
## LSCache ## LSCache
command = 'wp plugin status litespeed-cache --path=/home/%s/public_html' % (domain) command = 'wp plugin status litespeed-cache --path=%s' % (path)
result = ProcessUtilities.outputExecutioner(command, website.externalApp) result = ProcessUtilities.outputExecutioner(command, website.externalApp)
if result.find('Status: Active') > -1: if result.find('Status: Active') > -1:
@@ -1976,7 +1986,7 @@ class CloudManager:
## Debug ## Debug
command = 'wp config list --path=/home/%s/public_html' % (domain) command = 'wp config list --path=%s' % (path)
result = ProcessUtilities.outputExecutioner(command, website.externalApp).split('\n') result = ProcessUtilities.outputExecutioner(command, website.externalApp).split('\n')
finalDic['debugging'] = 0 finalDic['debugging'] = 0
for items in result: for items in result:
@@ -1986,12 +1996,12 @@ class CloudManager:
## Search index ## Search index
command = 'wp option get blog_public --path=/home/%s/public_html' % (domain) command = 'wp option get blog_public --path=%s' % (path)
finalDic['searchIndex'] = int(ProcessUtilities.outputExecutioner(command, website.externalApp).rstrip('\n')) finalDic['searchIndex'] = int(ProcessUtilities.outputExecutioner(command, website.externalApp).rstrip('\n'))
## Maintenece mode ## Maintenece mode
command = 'wp maintenance-mode status --path=/home/%s/public_html' % (domain) command = 'wp maintenance-mode status --path=%s' % (path)
result = ProcessUtilities.outputExecutioner(command, website.externalApp) result = ProcessUtilities.outputExecutioner(command, website.externalApp)
if result.find('not active') > -1: if result.find('not active') > -1:
@@ -2001,7 +2011,7 @@ class CloudManager:
## Get title ## Get title
command = 'wp option get blogname --path=/home/%s/public_html' % (domain) command = 'wp option get blogname --path=%s' % (path)
finalDic['title'] = ProcessUtilities.outputExecutioner(command, website.externalApp) finalDic['title'] = ProcessUtilities.outputExecutioner(command, website.externalApp)
## ##
@@ -2019,15 +2029,24 @@ class CloudManager:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
## Get title ## Get title
import plogical.randomPassword as randomPassword import plogical.randomPassword as randomPassword
password = randomPassword.generate_pass(32) password = randomPassword.generate_pass(32)
command = 'wp user create cyberpanel support@cyberpanel.cloud --role=administrator --user_pass="%s" --path=/home/%s/public_html' % (password, self.data['domain']) command = 'wp user create cyberpanel support@cyberpanel.cloud --role=administrator --user_pass="%s" --path=%s' % (password, path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
command = 'wp user update cyberpanel --user_pass="%s" --path=/home/%s/public_html' % (password, self.data['domain']) command = 'wp user update cyberpanel --user_pass="%s" --path=%s' % (password, path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
finalDic = {'status': 1, 'password': password} finalDic = {'status': 1, 'password': password}
@@ -2044,20 +2063,30 @@ class CloudManager:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
domain = self.data['domain'] domain = self.data['domain']
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
if self.data['setting'] == 'lscache': if self.data['setting'] == 'lscache':
if self.data['settingValue']: if self.data['settingValue']:
command = "wp plugin install litespeed-cache --path=/home/%s/public_html" % (domain) command = "wp plugin install litespeed-cache --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
command = "wp plugin activate litespeed-cache --path=/home/%s/public_html" % (domain) command = "wp plugin activate litespeed-cache --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'} final_dic = {'status': 1, 'message': 'LSCache successfully installed and activated.'}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp plugin deactivate litespeed-cache --path=/home/%s/public_html' % (domain) command = 'wp plugin deactivate litespeed-cache --path=%s' % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'LSCache successfully deactivated.'} final_dic = {'status': 1, 'message': 'LSCache successfully deactivated.'}
@@ -2065,11 +2094,11 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
elif self.data['setting'] == 'debugging': elif self.data['setting'] == 'debugging':
command = "wp litespeed-purge all --path=/home/%s/public_html" % (domain) command = "wp litespeed-purge all --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
if self.data['settingValue']: if self.data['settingValue']:
command = "wp config set WP_DEBUG true --path=/home/%s/public_html" % (domain) command = "wp config set WP_DEBUG true --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'WordPress is now in debug mode.'} final_dic = {'status': 1, 'message': 'WordPress is now in debug mode.'}
@@ -2077,7 +2106,7 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = "wp config set WP_DEBUG false --path=/home/%s/public_html" % (domain) command = "wp config set WP_DEBUG false --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'WordPress debug mode turned off.'} final_dic = {'status': 1, 'message': 'WordPress debug mode turned off.'}
@@ -2085,11 +2114,11 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
elif self.data['setting'] == 'searchIndex': elif self.data['setting'] == 'searchIndex':
command = "wp litespeed-purge all --path=/home/%s/public_html" % (domain) command = "wp litespeed-purge all --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
if self.data['settingValue']: if self.data['settingValue']:
command = "wp option update blog_public 1 --path=/home/%s/public_html" % (domain) command = "wp option update blog_public 1 --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'Search Engine Indexing enabled.'} final_dic = {'status': 1, 'message': 'Search Engine Indexing enabled.'}
@@ -2097,7 +2126,7 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = "wp option update blog_public 0 --path=/home/%s/public_html" % (domain) command = "wp option update blog_public 0 --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'Search Engine Indexing disabled.'} final_dic = {'status': 1, 'message': 'Search Engine Indexing disabled.'}
@@ -2105,12 +2134,12 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
elif self.data['setting'] == 'maintenanceMode': elif self.data['setting'] == 'maintenanceMode':
command = "wp litespeed-purge all --path=/home/%s/public_html" % (domain) command = "wp litespeed-purge all --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
if self.data['settingValue']: if self.data['settingValue']:
command = "wp maintenance-mode activate --path=/home/%s/public_html" % (domain) command = "wp maintenance-mode activate --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'WordPress Maintenance mode turned on.'} final_dic = {'status': 1, 'message': 'WordPress Maintenance mode turned on.'}
@@ -2118,7 +2147,7 @@ class CloudManager:
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = "wp maintenance-mode deactivate --path=/home/%s/public_html" % (domain) command = "wp maintenance-mode deactivate --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_dic = {'status': 1, 'message': 'WordPress Maintenance mode turned off.'} final_dic = {'status': 1, 'message': 'WordPress Maintenance mode turned off.'}
@@ -2131,9 +2160,20 @@ class CloudManager:
def GetCurrentPlugins(self): def GetCurrentPlugins(self):
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
command = 'wp plugin list --format=json --path=/home/%s/public_html' % (self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
command = 'wp plugin list --format=json --path=%s' % (path)
json_data = ProcessUtilities.outputExecutioner(command, website.externalApp) json_data = ProcessUtilities.outputExecutioner(command, website.externalApp)
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
@@ -2144,14 +2184,23 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
if self.data['plugin'] == 'all': if self.data['plugin'] == 'all':
command = 'wp plugin update --all --path=/home/%s/public_html' % (self.data['domain']) command = 'wp plugin update --all --path=%s' % (path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
elif self.data['plugin'] == 'selected': elif self.data['plugin'] == 'selected':
if self.data['allPluginsChecked']: if self.data['allPluginsChecked']:
command = 'wp plugin update --all --path=/home/%s/public_html' % (self.data['domain']) command = 'wp plugin update --all --path=%s' % (path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."})
@@ -2162,13 +2211,13 @@ class CloudManager:
for plugin in self.data['plugins']: for plugin in self.data['plugins']:
pluginsList = '%s %s' % (pluginsList, plugin) pluginsList = '%s %s' % (pluginsList, plugin)
command = 'wp plugin update %s --path=/home/%s/public_html' % (pluginsList, self.data['domain']) command = 'wp plugin update %s --path=%s' % (pluginsList, path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp plugin update %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) command = 'wp plugin update %s --path=%s' % (self.data['plugin'], path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin updates started in the background."})
@@ -2183,25 +2232,32 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
command = 'wp plugin status %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
command = 'wp plugin status %s --path=%s' % (self.data['plugin'], path)
result = ProcessUtilities.outputExecutioner(command, website.externalApp) result = ProcessUtilities.outputExecutioner(command, website.externalApp)
if result.find('Status: Active') > -1: if result.find('Status: Active') > -1:
command = 'wp plugin deactivate %s --path=/home/%s/public_html' % ( command = 'wp plugin deactivate %s --path=%s' % (self.data['plugin'], path)
self.data['plugin'], self.data['domain'])
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully deactivated."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully deactivated."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp plugin activate %s --path=/home/%s/public_html' % ( command = 'wp plugin activate %s --path=%s' % (
self.data['plugin'], self.data['domain']) self.data['plugin'], path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully activated."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin successfully activated."})
return HttpResponse(final_json) return HttpResponse(final_json)
except BaseException as msg: except BaseException as msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
@@ -2211,19 +2267,28 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
if self.data['plugin'] == 'selected': if self.data['plugin'] == 'selected':
pluginsList = '' pluginsList = ''
for plugin in self.data['plugins']: for plugin in self.data['plugins']:
pluginsList = '%s %s' % (pluginsList, plugin) pluginsList = '%s %s' % (pluginsList, plugin)
command = 'wp plugin delete %s --path=/home/%s/public_html' % (pluginsList, self.data['domain']) command = 'wp plugin delete %s --path=%s' % (pluginsList, path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin deletion started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin deletion started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp plugin delete %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) command = 'wp plugin delete %s --path=%s' % (self.data['plugin'], path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin deletion started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin deletion started in the background."})
@@ -2236,8 +2301,19 @@ class CloudManager:
def GetCurrentThemes(self): def GetCurrentThemes(self):
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
command = 'wp theme list --format=json --path=/home/%s/public_html' % (self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
command = 'wp theme list --format=json --path=%s' % (path)
json_data = ProcessUtilities.outputExecutioner(command, website.externalApp) json_data = ProcessUtilities.outputExecutioner(command, website.externalApp)
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data})
return HttpResponse(final_json) return HttpResponse(final_json)
@@ -2250,14 +2326,23 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
if self.data['plugin'] == 'all': if self.data['plugin'] == 'all':
command = 'wp theme update --all --path=/home/%s/public_html' % (self.data['domain']) command = 'wp theme update --all --path=%s' % (path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
elif self.data['plugin'] == 'selected': elif self.data['plugin'] == 'selected':
if self.data['allPluginsChecked']: if self.data['allPluginsChecked']:
command = 'wp theme update --all --path=/home/%s/public_html' % (self.data['domain']) command = 'wp theme update --all --path=%s' % (path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."})
@@ -2268,13 +2353,13 @@ class CloudManager:
for plugin in self.data['plugins']: for plugin in self.data['plugins']:
pluginsList = '%s %s' % (pluginsList, plugin) pluginsList = '%s %s' % (pluginsList, plugin)
command = 'wp theme update %s --path=/home/%s/public_html' % (pluginsList, self.data['domain']) command = 'wp theme update %s --path=%s' % (pluginsList, path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp theme update %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) command = 'wp theme update %s --path=%s' % (self.data['plugin'], path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme updates started in the background."})
@@ -2289,19 +2374,28 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
command = 'wp theme status %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
command = 'wp theme status %s --path=%s' % (self.data['plugin'], path)
result = ProcessUtilities.outputExecutioner(command, website.externalApp) result = ProcessUtilities.outputExecutioner(command, website.externalApp)
if result.find('Status: Active') > -1: if result.find('Status: Active') > -1:
command = 'wp theme deactivate %s --path=/home/%s/public_html' % ( command = 'wp theme deactivate %s --path=%s' % (
self.data['plugin'], self.data['domain']) self.data['plugin'], path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme successfully deactivated."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme successfully deactivated."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp theme activate %s --path=/home/%s/public_html' % ( command = 'wp theme activate %s --path=%s' % (
self.data['plugin'], self.data['domain']) self.data['plugin'], path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme successfully activated."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme successfully activated."})
@@ -2317,19 +2411,28 @@ class CloudManager:
try: try:
website = Websites.objects.get(domain=self.data['domain']) website = Websites.objects.get(domain=self.data['domain'])
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
if self.data['plugin'] == 'selected': if self.data['plugin'] == 'selected':
pluginsList = '' pluginsList = ''
for plugin in self.data['plugins']: for plugin in self.data['plugins']:
pluginsList = '%s %s' % (pluginsList, plugin) pluginsList = '%s %s' % (pluginsList, plugin)
command = 'wp theme delete %s --path=/home/%s/public_html' % (pluginsList, self.data['domain']) command = 'wp theme delete %s --path=%s' % (pluginsList, path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Plugin Theme started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Plugin Theme started in the background."})
return HttpResponse(final_json) return HttpResponse(final_json)
else: else:
command = 'wp theme delete %s --path=/home/%s/public_html' % (self.data['plugin'], self.data['domain']) command = 'wp theme delete %s --path=%s' % (self.data['plugin'], path)
ProcessUtilities.popenExecutioner(command, website.externalApp) ProcessUtilities.popenExecutioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(
{'status': 1, 'fetchStatus': 1, 'message': "Theme deletion started in the background."}) {'status': 1, 'fetchStatus': 1, 'message': "Theme deletion started in the background."})
@@ -2411,6 +2514,15 @@ class CloudManager:
wpd = WPDeployments(owner=website) wpd = WPDeployments(owner=website)
config = {} config = {}
try:
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
path = '/home/%s/public_html/%s' % (self.data['domain'], path)
except:
path = '/home/%s/public_html' % (self.data['domain'])
config['updates'] = self.data['wpCore'] config['updates'] = self.data['wpCore']
config['pluginUpdates'] = self.data['plugins'] config['pluginUpdates'] = self.data['plugins']
config['themeUpdates'] = self.data['themes'] config['themeUpdates'] = self.data['themes']
@@ -2418,13 +2530,13 @@ class CloudManager:
wpd.save() wpd.save()
if self.data['wpCore'] == 'Disabled': if self.data['wpCore'] == 'Disabled':
command = "wp config set WP_AUTO_UPDATE_CORE false --raw --path=/home/%s/public_html" % (domainName) command = "wp config set WP_AUTO_UPDATE_CORE false --raw --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
elif self.data['wpCore'] == 'Minor and Security Updates': elif self.data['wpCore'] == 'Minor and Security Updates':
command = "wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=/home/%s/public_html" % (domainName) command = "wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
else: else:
command = "wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=/home/%s/public_html" % (domainName) command = "wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=%s" % (path)
ProcessUtilities.executioner(command, website.externalApp) ProcessUtilities.executioner(command, website.externalApp)
final_json = json.dumps( final_json = json.dumps(

View File

@@ -0,0 +1,111 @@
import requests
import re
import sys
import warnings
from flask import Flask, request, render_template, redirect, url_for
from io_parser import FormParser
from urllib3.exceptions import InsecureRequestWarning
warnings.simplefilter('ignore', InsecureRequestWarning)
app = Flask(__name__)
app.debug = True
app.config.update(
JSON_SORT_KEYS=False,
JSONIFY_PRETTYPRINT_REGULAR=True
)
view = 'index.html'
@app.route('/', methods=['GET'])
def explore():
error = {
'types': set(),
'input': [],
}
http = None
x_lsadc_cache, x_qc_cache, x_litespeed_cache, cf_cache_cache, browser_cache, cache_support, x_sucuri_cache = (
False,) * 7
fp = FormParser(host=request.args.get('host'), ip=request.args.get('ip'),
port=request.args.get('port'),
advanced=request.args.get('advanced'))
if not fp.host:
return render_template(view, form=fp.__dict__())
if fp.check_error():
error['types'].add('input')
error['input'] = fp.error_msgs
return render_template(view, form=fp.__dict__(), error=error)
form = fp.__dict__()
finalURL = ''
if form['url'].find('http') == -1:
finalURL = 'https://%s' % (form['url'])
else:
finalURL = form['url']
try:
resp = requests.get('' + (finalURL, form['ip'])[form['advanced']], headers={
'Host': form['host'],
'User-Agent': 'wget/http3check.net',
}, verify=False)
http = [key + ': ' + value for key, value in resp.headers.items() if key != 'Link']
http.insert(0, 'HTTP/1.1 {} {}'.format(resp.status_code, resp.reason))
for key, value in resp.headers.items():
key = key.lower()
value = value.lower()
if key == 'x-lsadc-cache':
if value == 'hit':
x_lsadc_cache = True
cache_support = True
elif key == 'x-qc-cache':
if value == 'hit':
x_qc_cache = True
cache_support = True
elif key == 'x-litespeed-cache':
if value == 'hit':
x_litespeed_cache = True
cache_support = True
elif key == 'cf-cache-status':
if value == 'hit':
cf_cache_cache = True
elif key == 'cache-control':
if 'no-cache' not in value and 'max-age=0' not in value:
browser_cache = True
elif key == 'x-sucuri-cache':
if value == 'hit':
x_sucuri_cache = True
finalHTTP = []
from flask import Markup
for items in http:
if items.lower().find('x-litespeed-cache:') > -1 or items.lower().find('x-lsadc-cache:') > -1 or items.lower().find(
'x-qc-cache:') > -1:
finalHTTP.append(Markup('<strong>%s</strong>' % (items)))
elif items.lower().find('link:') > -1:
pass
else:
finalHTTP.append(items)
return render_template(view, cache_support=cache_support, x_lsadc_cache=x_lsadc_cache, x_qc_cache=x_qc_cache,
x_litespeed_cache=x_litespeed_cache, cf_cache_cache=cf_cache_cache,
x_sucuri_cache=x_sucuri_cache,
browser_cache=browser_cache, form=form, http=finalHTTP)
except BaseException as msg:
return render_template(view, form={}, error=str(msg))
@app.route('/<page>', methods=['GET'])
def home(page):
if page == 'about' or page == 'about.html':
return render_template(view, about=True)
# return redirect("https://lscache.io/", code=302)
return redirect(url_for('explore'))
if __name__ == '__main__':
app.run(host= '0.0.0.0')

View File

@@ -36,7 +36,17 @@ class StagingSetup(multi.Thread):
website = Websites.objects.get(domain=masterDomain) website = Websites.objects.get(domain=masterDomain)
try:
import json
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=website)
path = json.loads(wpd.config)['path']
masterPath = '/home/%s/public_html/%s' % (masterDomain, path)
replaceDomain = '%s/%s' % (masterDomain, path)
except:
masterPath = '/home/%s/public_html' % (masterDomain) masterPath = '/home/%s/public_html' % (masterDomain)
replaceDomain = masterDomain
configPath = '%s/wp-config.php' % (masterPath) configPath = '%s/wp-config.php' % (masterPath)
## Check if WP Detected on Main Site ## Check if WP Detected on Main Site
@@ -114,10 +124,10 @@ class StagingSetup(multi.Thread):
## Search and replace url ## Search and replace url
command = 'wp search-replace --allow-root --path=%s "%s" "%s"' % (path, masterDomain, domain) command = 'wp search-replace --allow-root --path=%s "%s" "%s"' % (path, replaceDomain, domain)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
command = 'wp search-replace --allow-root --path=%s "www.%s" "%s"' % (path, masterDomain, domain) command = 'wp search-replace --allow-root --path=%s "www.%s" "%s"' % (path, replaceDomain, domain)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
logging.statusWriter(tempStatusPath, 'Fixing permissions..,90') logging.statusWriter(tempStatusPath, 'Fixing permissions..,90')
@@ -147,7 +157,17 @@ class StagingSetup(multi.Thread):
child = ChildDomains.objects.get(domain=childDomain) child = ChildDomains.objects.get(domain=childDomain)
try:
import json
from cloudAPI.models import WPDeployments
wpd = WPDeployments.objects.get(owner=child.master)
path = json.loads(wpd.config)['path']
masterPath = '/home/%s/public_html/%s' % (child.master.domain, path)
replaceDomain = '%s/%s' % (child.master.domain, path)
except:
masterPath = '/home/%s/public_html' % (child.master.domain) masterPath = '/home/%s/public_html' % (child.master.domain)
replaceDomain = child.master.domain
command = 'chmod 755 /home/%s/public_html' % (child.master.domain) command = 'chmod 755 /home/%s/public_html' % (child.master.domain)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
@@ -185,10 +205,10 @@ class StagingSetup(multi.Thread):
## Search and replace url ## Search and replace url
command = 'wp search-replace --allow-root --path=%s "%s" "%s"' % (masterPath, child.domain, child.master.domain) command = 'wp search-replace --allow-root --path=%s "%s" "%s"' % (masterPath, child.domain, replaceDomain)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
command = 'wp search-replace --allow-root --path=%s "www.%s" "%s"' % (masterPath, child.domain, child.master.domain) command = 'wp search-replace --allow-root --path=%s "www.%s" "%s"' % (masterPath, child.domain, replaceDomain)
ProcessUtilities.executioner(command) ProcessUtilities.executioner(command)
from filemanager.filemanager import FileManager from filemanager.filemanager import FileManager
@@ -201,6 +221,15 @@ class StagingSetup(multi.Thread):
logging.statusWriter(tempStatusPath, 'Completed,[200]') logging.statusWriter(tempStatusPath, 'Completed,[200]')
http = []
finalHTTP = []
for items in http:
if items.find('x-litespeed-cache') > -1 or items.find('x-lsadc-cache') > -1 or items.find('x-qc-cache') > -1:
finalHTTP.append('<strong>%s</strong>' % (items))
else:
finalHTTP.append(items)
return 0 return 0
except BaseException as msg: except BaseException as msg:
mesg = '%s. [404]' % (str(msg)) mesg = '%s. [404]' % (str(msg))

View File

@@ -2701,7 +2701,6 @@ StrictHostKeyChecking no
extraArgs['masterDomain'] = data['masterDomain'] extraArgs['masterDomain'] = data['masterDomain']
extraArgs['admin'] = admin extraArgs['admin'] = admin
tempStatusPath = "/tmp/" + str(randint(1000, 9999)) tempStatusPath = "/tmp/" + str(randint(1000, 9999))
writeToFile = open(tempStatusPath, 'a') writeToFile = open(tempStatusPath, 'a')
message = 'Cloning process has started..,5' message = 'Cloning process has started..,5'