diff --git a/CyberCP/secMiddleware.py b/CyberCP/secMiddleware.py index 7616412a5..b6de2c7ac 100755 --- a/CyberCP/secMiddleware.py +++ b/CyberCP/secMiddleware.py @@ -96,9 +96,14 @@ class secMiddleware: response = self.get_response(request) - #response['Strict-Transport-Security'] = "max-age=31536000; includeSubDomains; preload" response['X-XSS-Protection'] = "1; mode=block" + #response['Strict-Transport-Security'] = "max-age=31536000; includeSubDomains; preload" response['X-Frame-Options'] = "sameorigin" - response['Content-Security-Policy'] = "frame-ancestors jsdelivr.com" + response['Content-Security-Policy'] = "script-src 'self' https://www.jsdelivr.com" + response['Content-Security-Policy'] = "connect-src *;" + response['Content-Security-Policy'] = "font-src 'self' 'unsafe-inline' https://www.jsdelivr.com https://fonts.googleapis.com" + response['Content-Security-Policy'] = "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.jsdelivr.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net" + response['X-Content-Type-Options'] = "nosniff" + response['Referrer-Policy'] = "same-origin" - return response + return response \ No newline at end of file diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index a016aeb74..ac596f79c 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -1,7 +1,9 @@ #!/usr/local/CyberCP/bin/python2 -import os,sys +import os, sys + sys.path.append('/usr/local/CyberCP') import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") django.setup() import threading as multi @@ -17,6 +19,7 @@ import shutil from plogical.mailUtilities import mailUtilities from plogical.processUtilities import ProcessUtilities + class ApplicationInstaller(multi.Thread): def __init__(self, installApp, extraArgs): @@ -40,9 +43,11 @@ class ApplicationInstaller(multi.Thread): self.changeBranch() elif self.installApp == 'prestashop': self.installPrestaShop() + elif self.installApp == 'magento': + self.installMagento() except BaseException, msg: - logging.writeToFile( str(msg) + ' [ApplicationInstaller.run]') + logging.writeToFile(str(msg) + ' [ApplicationInstaller.run]') def installWPCLI(self): try: @@ -56,7 +61,7 @@ class ApplicationInstaller(multi.Thread): ProcessUtilities.executioner(command) except BaseException, msg: - logging.writeToFile( str(msg) + ' [ApplicationInstaller.installWPCLI]') + logging.writeToFile(str(msg) + ' [ApplicationInstaller.installWPCLI]') def dataLossCheck(self, finalPath, tempStatusPath): @@ -102,7 +107,7 @@ class ApplicationInstaller(multi.Thread): ProcessUtilities.executioner(command) except BaseException, msg: - logging.writeToFile( str(msg) + ' [ApplicationInstaller.installGit]') + logging.writeToFile(str(msg) + ' [ApplicationInstaller.installGit]') def dbCreation(self, tempStatusPath, website): try: @@ -182,7 +187,6 @@ class ApplicationInstaller(multi.Thread): else: finalPath = website.path - if website.master.package.dataBases > website.master.databases_set.all().count(): pass else: @@ -208,13 +212,12 @@ class ApplicationInstaller(multi.Thread): else: finalPath = "/home/" + domainName + "/public_html/" - if website.package.dataBases > website.databases_set.all().count(): pass else: statusFile = open(tempStatusPath, 'w') statusFile.writelines( - "Maximum database limit reached for this website." + " [404]") + "Maximum database limit reached for this website." + " [404]") statusFile.close() return 0 @@ -286,7 +289,6 @@ class ApplicationInstaller(multi.Thread): ## - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath ProcessUtilities.executioner(command, externalApp) @@ -303,7 +305,6 @@ class ApplicationInstaller(multi.Thread): homeDir = "/home/" + domainName + "/public_html" if not os.path.exists(homeDir): - command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir ProcessUtilities.executioner(command, externalApp) @@ -383,7 +384,7 @@ class ApplicationInstaller(multi.Thread): else: statusFile = open(tempStatusPath, 'w') statusFile.writelines( - "Maximum database limit reached for this website." + " [404]") + "Maximum database limit reached for this website." + " [404]") statusFile.close() return 0 @@ -416,7 +417,8 @@ class ApplicationInstaller(multi.Thread): statusFile.writelines('Downloading and extracting PrestaShop Core..,30') statusFile.close() - command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % (finalPath) + command = "sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip -P %s" % ( + finalPath) ProcessUtilities.executioner(command, externalApp) command = "sudo unzip -o %sprestashop_1.7.4.2.zip -d " % (finalPath) + finalPath @@ -433,7 +435,7 @@ class ApplicationInstaller(multi.Thread): if home == '0': path = self.extraArgs['path'] - #finalURL = domainName + '/' + path + # finalURL = domainName + '/' + path finalURL = domainName else: finalURL = domainName @@ -541,8 +543,6 @@ class ApplicationInstaller(multi.Thread): externalApp = website.externalApp finalPath = "/home/" + domainName + "/public_html/" - - ## Security Check if finalPath.find("..") > -1: @@ -551,7 +551,6 @@ class ApplicationInstaller(multi.Thread): statusFile.close() return 0 - command = 'sudo mkdir -p ' + finalPath ProcessUtilities.executioner(command, externalApp) @@ -567,11 +566,12 @@ class ApplicationInstaller(multi.Thread): statusFile.close() try: - command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath + command = 'git clone --depth 1 --no-single-branch git@' + defaultProvider + '.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath ProcessUtilities.executioner(command, externalApp) except subprocess.CalledProcessError, msg: statusFile = open(tempStatusPath, 'w') - statusFile.writelines('Failed to clone repository, make sure you deployed your key to repository. [404]') + statusFile.writelines( + 'Failed to clone repository, make sure you deployed your key to repository. [404]') statusFile.close() return 0 @@ -622,7 +622,7 @@ class ApplicationInstaller(multi.Thread): logging.writeToFile('Git is not setup for this website.') return 0 - command = 'sudo git --git-dir=' + finalPath + '.git --work-tree=' + finalPath +' pull' + command = 'sudo git --git-dir=' + finalPath + '.git --work-tree=' + finalPath + ' pull' ProcessUtilities.executioner(command, externalApp) ## @@ -637,7 +637,7 @@ class ApplicationInstaller(multi.Thread): except BaseException, msg: - logging.writeToFile(str(msg)+ " [ApplicationInstaller.gitPull]") + logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") return 0 def detachRepo(self): @@ -661,7 +661,6 @@ class ApplicationInstaller(multi.Thread): childDomain = ChildDomains.objects.get(domain=domain) finalPath = childDomain.path - command = 'sudo rm -rf ' + finalPath ProcessUtilities.executioner(command, website.externalApp) @@ -681,7 +680,7 @@ class ApplicationInstaller(multi.Thread): except BaseException, msg: - logging.writeToFile(str(msg)+ " [ApplicationInstaller.gitPull]") + logging.writeToFile(str(msg) + " [ApplicationInstaller.gitPull]") return 0 def installJoomla(self): @@ -871,9 +870,185 @@ class ApplicationInstaller(multi.Thread): command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch ProcessUtilities.executioner(command, externalApp) except subprocess.CalledProcessError, msg: - logging.writeToFile('Failed to change branch: ' + str(msg)) + logging.writeToFile('Failed to change branch: ' + str(msg)) return 0 return 0 except BaseException, msg: logging.writeToFile('Failed to change branch: ' + str(msg)) return 0 + + def installMagento(self): + try: + + username = self.extraArgs['username'] + domainName = self.extraArgs['domainName'] + home = self.extraArgs['home'] + firstName = self.extraArgs['firstName'] + lastName = self.extraArgs['lastName'] + email = self.extraArgs['email'] + password = self.extraArgs['password'] + tempStatusPath = self.extraArgs['tempStatusPath'] + sampleData = self.extraArgs['sampleData'] + + FNULL = open(os.devnull, 'w') + + ## Open Status File + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up paths,0') + statusFile.close() + + finalPath = '' + + try: + website = ChildDomains.objects.get(domain=domainName) + externalApp = website.master.externalApp + + if home == '0': + path = self.extraArgs['path'] + finalPath = website.path.rstrip('/') + "/" + path + "/" + else: + finalPath = website.path + "/" + + if website.master.package.dataBases > website.master.databases_set.all().count(): + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "Maximum database limit reached for this website." + " [404]") + statusFile.close() + return 0 + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up Database,20') + statusFile.close() + + dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master) + + except: + website = Websites.objects.get(domain=domainName) + externalApp = website.externalApp + + if home == '0': + path = self.extraArgs['path'] + finalPath = "/home/" + domainName + "/public_html/" + path + "/" + else: + finalPath = "/home/" + domainName + "/public_html/" + + if website.package.dataBases > website.databases_set.all().count(): + pass + else: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines( + "Maximum database limit reached for this website." + " [404]") + statusFile.close() + return 0 + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Setting up Database,20') + statusFile.close() + + dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website) + + ## Security Check + + if finalPath.find("..") > -1: + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Specified path must be inside virtual host home." + " [404]") + statusFile.close() + return 0 + + if not os.path.exists(finalPath): + command = 'sudo mkdir -p ' + finalPath + ProcessUtilities.executioner(command, externalApp) + + ## checking for directories/files + + if self.dataLossCheck(finalPath, tempStatusPath) == 0: + return 0 + + #### + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Downloading and extracting Magento Core..,30') + statusFile.close() + + if sampleData: + command = "sudo wget http://cyberpanelsh.b-cdn.net/latest-sample.tar.gz -P %s" % (finalPath) + else: + command = "sudo wget http://cyberpanelsh.b-cdn.net/latest.tar.gz -P %s" % (finalPath) + + ProcessUtilities.executioner(command, externalApp) + + if sampleData: + command = 'tar -xf %slatest-sample.tar.gz --directory %s' % (finalPath, finalPath) + else: + command = 'tar -xf %slatest.tar.gz --directory %s' % (finalPath, finalPath) + + ProcessUtilities.executioner(command, externalApp) + + ## + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Configuring the installation,40') + statusFile.close() + + if home == '0': + path = self.extraArgs['path'] + # finalURL = domainName + '/' + path + finalURL = domainName + else: + finalURL = domainName + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('Installing and configuring Magento..,60') + statusFile.close() + + command = '/usr/local/lsws/lsphp72/bin/php -d memory_limit=512M %sbin/magento setup:install --backend-frontname="admin" ' \ + '--db-host="localhost" --db-name="%s" --db-user="%s" --db-password="%s" ' \ + '--base-url="http://%s" --base-url-secure="https://%s/" --admin-user="%s" ' \ + '--admin-password="%s" --admin-email="%s" --admin-firstname="%s" --admin-lastname="%s"' \ + % (finalPath, dbName, dbUser, dbPassword, finalURL, finalURL, username, password, email, firstName, lastName) + result = ProcessUtilities.outputExecutioner(command, externalApp) + logging.writeToFile(result) + + ## + + if sampleData: + command = 'rm -rf %slatest-sample.tar.gz' % (finalPath) + else: + command = 'rm -rf %slatest.tar.gz' % (finalPath) + + ProcessUtilities.executioner(command, externalApp) + + ## + + command = "sudo chown -R " + externalApp + ":" + externalApp + " " + finalPath + ProcessUtilities.executioner(command, externalApp) + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines("Successfully Installed. [200]") + statusFile.close() + return 0 + + + except BaseException, msg: + # remove the downloaded files + + homeDir = "/home/" + domainName + "/public_html" + + if not os.path.exists(homeDir): + command = "sudo chown -R " + externalApp + ":" + externalApp + " " + homeDir + ProcessUtilities.executioner(command, externalApp) + + try: + mysqlUtilities.deleteDatabase(dbName, dbUser) + db = Databases.objects.get(dbName=dbName) + db.delete() + except: + pass + + statusFile = open(tempStatusPath, 'w') + statusFile.writelines(str(msg) + " [404]") + statusFile.close() + return 0 diff --git a/static/images/icons/magento.png b/static/images/icons/magento.png new file mode 100644 index 000000000..d32dfb558 Binary files /dev/null and b/static/images/icons/magento.png differ diff --git a/websiteFunctions/static/websiteFunctions/websiteFunctions.js b/websiteFunctions/static/websiteFunctions/websiteFunctions.js index 9f22ba41b..9700d7d3d 100755 --- a/websiteFunctions/static/websiteFunctions/websiteFunctions.js +++ b/websiteFunctions/static/websiteFunctions/websiteFunctions.js @@ -634,6 +634,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) { $scope.joomlaInstallURL = $("#domainNamePage").text() + "/joomlaInstall"; $scope.setupGit = $("#domainNamePage").text() + "/setupGit"; $scope.installPrestaURL = $("#domainNamePage").text() + "/installPrestaShop"; + $scope.installMagentoURL = $("#domainNamePage").text() + "/installMagento"; $scope.domainAliasURL = "/websites/" + $("#domainNamePage").text() + "/domainAlias"; $scope.previewUrl = "/preview/" + $("#domainNamePage").text() + "/"; @@ -3099,6 +3100,7 @@ app.controller('launchChild', function ($scope, $http) { $scope.joomlaInstallURL = "/websites/" + $("#childDomain").text() + "/joomlaInstall"; $scope.setupGit = "/websites/" + $("#childDomain").text() + "/setupGit"; $scope.installPrestaURL = "/websites/" + $("#childDomain").text() + "/installPrestaShop"; + $scope.installMagentoURL = "/websites/" + $("#childDomain").text() + "/installMagento"; var logType = 0; $scope.pageNumber = 1; @@ -5238,4 +5240,199 @@ app.controller('syncWebsite', function ($scope, $http, $timeout, $window) { } }); -/* Java script code to syncWebsite ends here */ \ No newline at end of file +/* Java script code to syncWebsite ends here */ + + +app.controller('installMagentoCTRL', function ($scope, $http, $timeout) { + + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.installationFailed = true; + $scope.installationSuccessfull = true; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = true; + $scope.goBackDisable = true; + + $scope.databasePrefix = 'ps_'; + + var statusFile; + var domain = $("#domainNamePage").text(); + var path; + + + $scope.goBack = function () { + $scope.installationDetailsForm = false; + $scope.installationProgress = true; + $scope.installationFailed = true; + $scope.installationSuccessfull = true; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = true; + $scope.goBackDisable = true; + $("#installProgress").css("width", "0%"); + }; + + function getInstallStatus() { + + url = "/websites/installWordpressStatus"; + + var data = { + statusFile: statusFile, + domainName: domain + }; + + 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.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.installationFailed = true; + $scope.installationSuccessfull = false; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = true; + $scope.goBackDisable = false; + + if (typeof path !== 'undefined') { + $scope.installationURL = "http://" + domain + "/" + path; + } else { + $scope.installationURL = domain; + } + + + $("#installProgress").css("width", "100%"); + $scope.installPercentage = "100"; + $scope.currentStatus = response.data.currentStatus; + $timeout.cancel(); + + } else { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.installationFailed = false; + $scope.installationSuccessfull = true; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + $("#installProgress").css("width", "0%"); + $scope.installPercentage = "0"; + + } + + } else { + $("#installProgress").css("width", response.data.installationProgress + "%"); + $scope.installPercentage = response.data.installationProgress; + $scope.currentStatus = response.data.currentStatus; + + $timeout(getInstallStatus, 1000); + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.canNotFetch = true; + $scope.couldNotConnect = false; + + + } + + + } + + $scope.installMagento = function () { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.installationFailed = true; + $scope.installationSuccessfull = true; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = false; + $scope.goBackDisable = true; + $scope.currentStatus = "Starting installation.."; + + path = $scope.installPath; + + + url = "/websites/magentoInstall"; + + var home = "1"; + + if (typeof path !== 'undefined') { + home = "0"; + } + var sampleData; + if ($scope.sampleData === true) { + sampleData = 1; + } else { + sampleData = 0 + } + + + var data = { + domain: domain, + home: home, + path: path, + firstName: $scope.firstName, + lastName: $scope.lastName, + username: $scope.username, + email: $scope.email, + passwordByPass: $scope.password, + sampleData: sampleData + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.installStatus === 1) { + statusFile = response.data.tempStatusPath; + getInstallStatus(); + } else { + + $scope.installationDetailsForm = true; + $scope.installationProgress = false; + $scope.installationFailed = false; + $scope.installationSuccessfull = true; + $scope.couldNotConnect = true; + $scope.wpInstallLoading = true; + $scope.goBackDisable = false; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + } + + }; + + +}); \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/installMagento.html b/websiteFunctions/templates/websiteFunctions/installMagento.html new file mode 100755 index 000000000..2235b8c82 --- /dev/null +++ b/websiteFunctions/templates/websiteFunctions/installMagento.html @@ -0,0 +1,160 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block title %}{% trans "Install Magento - CyberPanel" %}{% endblock %} +{% block content %} + + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + + +
+
+

{% trans "Install Magento" %}

+

{% trans "One-click Magento Install!" %}

+
+ + +
+
+

+ {{ domainName }} - {% trans "Installation Details" %} +

+
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+
+

+ LiteMage + Cache + Plugin {% trans "does not work on OpenLiteSpeed. It is highly recommended to use this installer with LiteSpeed Enterprise only." %} +

+
+
+
+ + + + + +
+ +
+ +
+
+ + +
+ +
+ +
+

{$ currentStatus $}

+
+ +
+
+ 70% Complete +
+
+ + +
+

{% trans "Installation failed. Error message:" %} {$ errorMessage $}

+
+ +
+

{% trans "Installation successful. Visit:" %} {$ installationURL $}

+
+ + +
+

{% trans "Could not connect to server. Please refresh this page." %}

+
+ + +
+
+ +
+ +
+ +
+
+ + +
+ +
+
+
+ + +
+ + +{% endblock %} \ No newline at end of file diff --git a/websiteFunctions/templates/websiteFunctions/launchChild.html b/websiteFunctions/templates/websiteFunctions/launchChild.html index 2fd80a79c..8015d430d 100755 --- a/websiteFunctions/templates/websiteFunctions/launchChild.html +++ b/websiteFunctions/templates/websiteFunctions/launchChild.html @@ -26,7 +26,10 @@

{% trans "Resource Usage" %} - {% trans "Copy/Sync to Master" %} + {% trans "Copy/Sync to Master" %}

@@ -716,6 +719,18 @@
+
+ + + + + {% trans "Magento" %} + +
+ + diff --git a/websiteFunctions/templates/websiteFunctions/website.html b/websiteFunctions/templates/websiteFunctions/website.html index 5db506f98..abd8ad9bc 100755 --- a/websiteFunctions/templates/websiteFunctions/website.html +++ b/websiteFunctions/templates/websiteFunctions/website.html @@ -1024,6 +1024,17 @@ +
+ + + + + {% trans "Magento" %} + +
+ diff --git a/websiteFunctions/urls.py b/websiteFunctions/urls.py index 08beb86e8..5441dddf2 100755 --- a/websiteFunctions/urls.py +++ b/websiteFunctions/urls.py @@ -88,6 +88,11 @@ urlpatterns = [ url(r'^prestaShopInstall$', views.prestaShopInstall, name='prestaShopInstall'), url(r'^(?P(.*))/installPrestaShop$', views.installPrestaShop, name='installPrestaShop'), + ## magento + + url(r'^(?P(.*))/installMagento$', views.installMagento, name='installMagento'), + url(r'^magentoInstall$', views.magentoInstall, name='magentoInstall'), + ## Git url(r'^(?P(.*))/setupGit$', views.setupGit, name='setupGit'), diff --git a/websiteFunctions/views.py b/websiteFunctions/views.py index 16c12fff5..0528ee6a7 100755 --- a/websiteFunctions/views.py +++ b/websiteFunctions/views.py @@ -606,6 +606,22 @@ def installPrestaShop(request, domain): except KeyError: return redirect(loadLoginPage) +def installMagento(request, domain): + try: + userID = request.session['userID'] + wm = WebsiteManager(domain) + return wm.installMagento(request, userID) + except KeyError: + return redirect(loadLoginPage) + +def magentoInstall(request): + try: + userID = request.session['userID'] + wm = WebsiteManager() + return wm.magentoInstall(userID, json.loads(request.body)) + except KeyError: + return redirect(loadLoginPage) + def prestaShopInstall(request): try: userID = request.session['userID'] diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 5496397e0..b3a32ec80 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -2020,6 +2020,68 @@ StrictHostKeyChecking no except BaseException, msg: return HttpResponse(str(msg)) + def installMagento(self, request=None, userID=None, data=None): + try: + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + + if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1: + pass + else: + return ACLManager.loadError() + + return render(request, 'websiteFunctions/installMagento.html', {'domainName': self.domain}) + except BaseException, msg: + return HttpResponse(str(msg)) + + + def magentoInstall(self, userID=None, data=None): + try: + + currentACL = ACLManager.loadedACL(userID) + admin = Administrator.objects.get(pk=userID) + + self.domain = data['domain'] + + if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('installStatus', 0) + + mailUtilities.checkHome() + + extraArgs = {} + extraArgs['admin'] = admin + extraArgs['domainName'] = data['domain'] + extraArgs['home'] = data['home'] + extraArgs['firstName'] = data['firstName'] + extraArgs['lastName'] = data['lastName'] + extraArgs['username'] = data['username'] + extraArgs['email'] = data['email'] + extraArgs['password'] = data['passwordByPass'] + extraArgs['sampleData'] = data['sampleData'] + extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999)) + + if data['home'] == '0': + extraArgs['path'] = data['path'] + + background = ApplicationInstaller('magento', 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) + + ## Installation ends + + except BaseException, msg: + data_ret = {'status': 0, 'installStatus': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + def prestaShopInstall(self, userID=None, data=None): try: @@ -2086,6 +2148,11 @@ StrictHostKeyChecking no except: websitesLimit = 1 + try: + apiACL = data['acl'] + except: + apiACL = 'user' + admin = Administrator.objects.get(userName=adminUser) if hashPassword.check_password(admin.password, adminPass): @@ -2094,7 +2161,7 @@ StrictHostKeyChecking no data['adminEmail'] = "usman@cyberpersons.com" try: - acl = ACL.objects.get(name='user') + acl = ACL.objects.get(name=apiACL) websiteOwn = Administrator(userName=websiteOwner, password=hashPassword.hash_password(ownerPassword), email=adminEmail, type=3, owner=admin.pk,