mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-06 21:35:55 +01:00
cloud api
This commit is contained in:
@@ -62,6 +62,7 @@ INSTALLED_APPS = [
|
|||||||
'pluginHolder',
|
'pluginHolder',
|
||||||
'emailPremium',
|
'emailPremium',
|
||||||
'emailMarketing',
|
'emailMarketing',
|
||||||
|
'cloudAPI',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
@@ -39,4 +39,5 @@ urlpatterns = [
|
|||||||
url(r'^manageservices/',include('manageServices.urls')),
|
url(r'^manageservices/',include('manageServices.urls')),
|
||||||
url(r'^plugins/',include('pluginHolder.urls')),
|
url(r'^plugins/',include('pluginHolder.urls')),
|
||||||
url(r'^emailMarketing/', include('emailMarketing.urls')),
|
url(r'^emailMarketing/', include('emailMarketing.urls')),
|
||||||
|
url(r'^cloudAPI/', include('cloudAPI.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ from plogical.mailUtilities import mailUtilities
|
|||||||
from plogical.website import WebsiteManager
|
from plogical.website import WebsiteManager
|
||||||
from loginSystem.models import ACL
|
from loginSystem.models import ACL
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
@@ -568,9 +567,8 @@ def changeAdminPassword(request):
|
|||||||
'error_message': "None"}
|
'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
os.remove(randomFile)
|
os.remove(randomFile)
|
||||||
admin = Administrator.objects.get(userName="admin")
|
admin = Administrator.objects.get(pk="admin")
|
||||||
admin.password = hashPassword.hash_password(adminPass)
|
admin.password = hashPassword.hash_password(adminPass)
|
||||||
admin.save()
|
admin.save()
|
||||||
data_ret = {"changed": 1,
|
data_ret = {"changed": 1,
|
||||||
@@ -589,9 +587,7 @@ def changeAdminPassword(request):
|
|||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {"changed": 0,
|
data_ret = {"changed": 0,
|
||||||
'error_message': "Failed to authorize access to change password!"}
|
'error_message': str(msg)}
|
||||||
|
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
0
cloudAPI/__init__.py
Normal file
0
cloudAPI/__init__.py
Normal file
6
cloudAPI/admin.py
Normal file
6
cloudAPI/admin.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
8
cloudAPI/apps.py
Normal file
8
cloudAPI/apps.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CloudapiConfig(AppConfig):
|
||||||
|
name = 'cloudAPI'
|
||||||
732
cloudAPI/cloudManager.py
Normal file
732
cloudAPI/cloudManager.py
Normal file
@@ -0,0 +1,732 @@
|
|||||||
|
from plogical import hashPassword
|
||||||
|
from loginSystem.models import Administrator
|
||||||
|
from django.shortcuts import HttpResponse
|
||||||
|
import json
|
||||||
|
from plogical.website import WebsiteManager
|
||||||
|
from plogical.acl import ACLManager
|
||||||
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||||
|
from websiteFunctions.models import Websites
|
||||||
|
import subprocess, shlex
|
||||||
|
from databases.databaseManager import DatabaseManager
|
||||||
|
from dns.dnsManager import DNSManager
|
||||||
|
from mailServer.mailserverManager import MailServerManager
|
||||||
|
from ftp.ftpManager import FTPManager
|
||||||
|
from manageSSL.views import issueSSL
|
||||||
|
from plogical.backupManager import BackupManager
|
||||||
|
|
||||||
|
class CloudManager:
|
||||||
|
|
||||||
|
def __init__(self, data = None):
|
||||||
|
self.data = data
|
||||||
|
|
||||||
|
def ajaxPre(self, status, errorMessage):
|
||||||
|
final_dic = {'status': status, 'error_message': errorMessage}
|
||||||
|
final_json = json.dumps(final_dic)
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
def verifyLogin(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return self.ajaxPre(1, None)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchWebsites(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.getFurtherAccounts(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitWebsiteDeletion(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.submitWebsiteDeletion(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitWebsiteCreation(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.submitWebsiteCreation(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchWebsiteDataJSON(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.fetchWebsiteDataJSON(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchWebsiteData(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
currentACL = ACLManager.loadedACL(admin.pk)
|
||||||
|
website = Websites.objects.get(domain=self.data['domainName'])
|
||||||
|
admin = Administrator.objects.get(pk=admin.pk)
|
||||||
|
|
||||||
|
if ACLManager.checkOwnership(self.data['domainName'], admin, currentACL) == 1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return ACLManager.loadErrorJson()
|
||||||
|
|
||||||
|
Data = {}
|
||||||
|
|
||||||
|
Data['ftpAllowed'] = website.package.ftpAccounts
|
||||||
|
Data['ftpUsed'] = website.users_set.all().count()
|
||||||
|
|
||||||
|
Data['dbUsed'] = website.databases_set.all().count()
|
||||||
|
Data['dbAllowed'] = website.package.dataBases
|
||||||
|
|
||||||
|
diskUsageDetails = virtualHostUtilities.getDiskUsage("/home/" + self.data['domainName'], website.package.diskSpace)
|
||||||
|
|
||||||
|
## bw usage calculation
|
||||||
|
|
||||||
|
try:
|
||||||
|
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||||
|
execPath = execPath + " findDomainBW --virtualHostName " + self.data['domainName'] + " --bandwidth " + str(
|
||||||
|
website.package.bandwidth)
|
||||||
|
|
||||||
|
output = subprocess.check_output(shlex.split(execPath))
|
||||||
|
bwData = output.split(",")
|
||||||
|
except BaseException:
|
||||||
|
bwData = [0, 0]
|
||||||
|
|
||||||
|
## bw usage calculations
|
||||||
|
|
||||||
|
Data['bwAllowed'] = website.package.bandwidth
|
||||||
|
Data['bwUsed'] = bwData[0]
|
||||||
|
Data['bwUsage'] = bwData[1]
|
||||||
|
|
||||||
|
if diskUsageDetails != None:
|
||||||
|
if diskUsageDetails[1] > 100:
|
||||||
|
diskUsageDetails[1] = 100
|
||||||
|
|
||||||
|
Data['diskUsage'] = diskUsageDetails[1]
|
||||||
|
Data['diskUsed'] = diskUsageDetails[0]
|
||||||
|
Data['diskAllowed'] = website.package.diskSpace
|
||||||
|
else:
|
||||||
|
Data['diskUsed'] = 0
|
||||||
|
Data['diskUsage'] = 0
|
||||||
|
Data['diskInMBTotal'] = website.package.diskSpace
|
||||||
|
|
||||||
|
Data['status'] = 1
|
||||||
|
final_json = json.dumps(Data)
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchModifyData(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.submitWebsiteModify(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def saveModifications(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.saveWebsiteChanges(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitDBCreation(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DatabaseManager()
|
||||||
|
return dm.submitDBCreation(admin.pk, self.data, 1)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchDatabases(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DatabaseManager()
|
||||||
|
return dm.fetchDatabases(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitDatabaseDeletion(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DatabaseManager()
|
||||||
|
return dm.submitDatabaseDeletion(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def changePassword(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DatabaseManager()
|
||||||
|
return dm.changePassword(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def getCurrentRecordsForDomain(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DNSManager()
|
||||||
|
return dm.getCurrentRecordsForDomain(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def deleteDNSRecord(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DNSManager()
|
||||||
|
return dm.deleteDNSRecord(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def addDNSRecord(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['password']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
dm = DNSManager()
|
||||||
|
return dm.addDNSRecord(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitEmailCreation(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.submitEmailCreation()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def getEmailsForDomain(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.getEmailsForDomain()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitEmailDeletion(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.submitEmailDeletion()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitPasswordChange(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.submitPasswordChange()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchCurrentForwardings(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.fetchCurrentForwardings()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitForwardDeletion(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.submitForwardDeletion()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitEmailForwardingCreation(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.submitEmailForwardingCreation()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchDKIMKeys(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.fetchDKIMKeys()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def generateDKIMKeys(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
msm = MailServerManager(request)
|
||||||
|
return msm.generateDKIMKeys()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitFTPCreation(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
fm = FTPManager(request)
|
||||||
|
return fm.submitFTPCreation()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def getAllFTPAccounts(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
fm = FTPManager(request)
|
||||||
|
return fm.getAllFTPAccounts()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitFTPDelete(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
fm = FTPManager(request)
|
||||||
|
return fm.submitFTPDelete()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def changeFTPPassword(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
fm = FTPManager(request)
|
||||||
|
return fm.changePassword()
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def issueSSL(self, request):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
request.session['userID'] = admin.pk
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
return issueSSL(request)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def statusFunc(self):
|
||||||
|
try:
|
||||||
|
statusFile = self.data['statusFile']
|
||||||
|
statusData = open(statusFile, 'r').readlines()
|
||||||
|
lastLine = statusData[-1]
|
||||||
|
|
||||||
|
if lastLine.find('[200]') > -1:
|
||||||
|
command = 'sudo rm -f ' + statusFile
|
||||||
|
subprocess.call(shlex.split(command))
|
||||||
|
data_ret = {'status': 1, 'abort': 1, 'installationProgress': "100", 'currentStatus': lastLine}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
elif lastLine.find('[404]') > -1:
|
||||||
|
data_ret = {'status': 0, 'abort': 1, 'installationProgress': "0", 'error_message': lastLine}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
else:
|
||||||
|
progress = lastLine.split(',')
|
||||||
|
currentStatus = progress[0]
|
||||||
|
try:
|
||||||
|
installationProgress = progress[1]
|
||||||
|
except:
|
||||||
|
installationProgress = 0
|
||||||
|
data_ret = {'status': 1, 'abort': 0, 'installationProgress': installationProgress, 'currentStatus': currentStatus}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
data_ret = {'status': 0,'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def submitDomainCreation(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.submitDomainCreation(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def fetchDomains(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.fetchDomains(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def submitDomainDeletion(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.submitDomainDeletion(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def changeOpenBasedir(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.changeOpenBasedir(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def changePHP(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
wm = WebsiteManager()
|
||||||
|
return wm.changePHP(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def backupStatusFunc(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
bm = BackupManager()
|
||||||
|
return bm.backupStatus(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
data_ret = {'status': 0,'abort': 0, 'installationProgress': "0", 'errorMessage': str(msg)}
|
||||||
|
json_data = json.dumps(data_ret)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def submitBackupCreation(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
bm = BackupManager()
|
||||||
|
return bm.submitBackupCreation(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def getCurrentBackups(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
bm = BackupManager()
|
||||||
|
return bm.getCurrentBackups(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
def deleteBackup(self):
|
||||||
|
try:
|
||||||
|
adminUser = self.data['userName']
|
||||||
|
adminPass = self.data['serverPassword']
|
||||||
|
|
||||||
|
admin = Administrator.objects.get(userName=adminUser)
|
||||||
|
|
||||||
|
if hashPassword.check_password(admin.password, adminPass):
|
||||||
|
bm = BackupManager()
|
||||||
|
return bm.deleteBackup(admin.pk, self.data)
|
||||||
|
else:
|
||||||
|
return self.ajaxPre(0, 'Invalid login information.')
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
return self.ajaxPre(0, str(msg))
|
||||||
|
|
||||||
|
|
||||||
0
cloudAPI/migrations/__init__.py
Normal file
0
cloudAPI/migrations/__init__.py
Normal file
6
cloudAPI/models.py
Normal file
6
cloudAPI/models.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
6
cloudAPI/tests.py
Normal file
6
cloudAPI/tests.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
6
cloudAPI/urls.py
Normal file
6
cloudAPI/urls.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.conf.urls import url
|
||||||
|
import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^$', views.router, name='router'),
|
||||||
|
]
|
||||||
95
cloudAPI/views.py
Normal file
95
cloudAPI/views.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from cloudManager import CloudManager
|
||||||
|
import json
|
||||||
|
|
||||||
|
def router(request):
|
||||||
|
try:
|
||||||
|
data = json.loads(request.body)
|
||||||
|
controller = data['controller']
|
||||||
|
|
||||||
|
cm = CloudManager(data)
|
||||||
|
|
||||||
|
if controller == 'verifyLogin':
|
||||||
|
return cm.verifyLogin()
|
||||||
|
elif controller == 'fetchWebsites':
|
||||||
|
return cm.fetchWebsites()
|
||||||
|
elif controller == 'fetchWebsiteDataJSON':
|
||||||
|
return cm.fetchWebsiteDataJSON()
|
||||||
|
elif controller == 'fetchWebsiteData':
|
||||||
|
return cm.fetchWebsiteData()
|
||||||
|
elif controller == 'submitWebsiteCreation':
|
||||||
|
return cm.submitWebsiteCreation()
|
||||||
|
elif controller == 'fetchModifyData':
|
||||||
|
return cm.fetchModifyData()
|
||||||
|
elif controller == 'saveModifications':
|
||||||
|
return cm.saveModifications()
|
||||||
|
elif controller == 'submitDBCreation':
|
||||||
|
return cm.submitDBCreation()
|
||||||
|
elif controller == 'fetchDatabases':
|
||||||
|
return cm.fetchDatabases()
|
||||||
|
elif controller == 'submitDatabaseDeletion':
|
||||||
|
return cm.submitDatabaseDeletion()
|
||||||
|
elif controller == 'changePassword':
|
||||||
|
return cm.changePassword()
|
||||||
|
elif controller == 'getCurrentRecordsForDomain':
|
||||||
|
return cm.getCurrentRecordsForDomain()
|
||||||
|
elif controller == 'deleteDNSRecord':
|
||||||
|
return cm.deleteDNSRecord()
|
||||||
|
elif controller == 'addDNSRecord':
|
||||||
|
return cm.addDNSRecord()
|
||||||
|
elif controller == 'submitEmailCreation':
|
||||||
|
return cm.submitEmailCreation(request)
|
||||||
|
elif controller == 'getEmailsForDomain':
|
||||||
|
return cm.getEmailsForDomain(request)
|
||||||
|
elif controller == 'submitEmailDeletion':
|
||||||
|
return cm.submitEmailDeletion(request)
|
||||||
|
elif controller == 'submitPasswordChange':
|
||||||
|
return cm.submitPasswordChange(request)
|
||||||
|
elif controller == 'fetchCurrentForwardings':
|
||||||
|
return cm.fetchCurrentForwardings(request)
|
||||||
|
elif controller == 'submitForwardDeletion':
|
||||||
|
return cm.submitForwardDeletion(request)
|
||||||
|
elif controller == 'submitEmailForwardingCreation':
|
||||||
|
return cm.submitEmailForwardingCreation(request)
|
||||||
|
elif controller == 'fetchDKIMKeys':
|
||||||
|
return cm.fetchDKIMKeys(request)
|
||||||
|
elif controller == 'generateDKIMKeys':
|
||||||
|
return cm.generateDKIMKeys(request)
|
||||||
|
elif controller == 'submitFTPCreation':
|
||||||
|
return cm.submitFTPCreation(request)
|
||||||
|
elif controller == 'getAllFTPAccounts':
|
||||||
|
return cm.getAllFTPAccounts(request)
|
||||||
|
elif controller == 'submitFTPDelete':
|
||||||
|
return cm.submitFTPDelete(request)
|
||||||
|
elif controller == 'changeFTPPassword':
|
||||||
|
return cm.changeFTPPassword(request)
|
||||||
|
elif controller == 'issueSSL':
|
||||||
|
return cm.issueSSL(request)
|
||||||
|
elif controller == 'submitWebsiteDeletion':
|
||||||
|
return cm.submitWebsiteDeletion(request)
|
||||||
|
elif controller == 'statusFunc':
|
||||||
|
return cm.statusFunc()
|
||||||
|
elif controller == 'submitDomainCreation':
|
||||||
|
return cm.submitDomainCreation()
|
||||||
|
elif controller == 'fetchDomains':
|
||||||
|
return cm.fetchDomains()
|
||||||
|
elif controller == 'submitDomainDeletion':
|
||||||
|
return cm.submitDomainDeletion()
|
||||||
|
elif controller == 'changeOpenBasedir':
|
||||||
|
return cm.changeOpenBasedir()
|
||||||
|
elif controller == 'changePHP':
|
||||||
|
return cm.changePHP()
|
||||||
|
elif controller == 'backupStatusFunc':
|
||||||
|
return cm.backupStatusFunc()
|
||||||
|
elif controller == 'submitBackupCreation':
|
||||||
|
return cm.submitBackupCreation()
|
||||||
|
elif controller == 'getCurrentBackups':
|
||||||
|
return cm.getCurrentBackups()
|
||||||
|
elif controller == 'deleteBackup':
|
||||||
|
return cm.deleteBackup()
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
cm = CloudManager(None)
|
||||||
|
return cm.ajaxPre(0, str(msg))
|
||||||
@@ -35,7 +35,7 @@ class DatabaseManager:
|
|||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
return HttpResponse(str(msg))
|
return HttpResponse(str(msg))
|
||||||
|
|
||||||
def submitDBCreation(self, userID = None, data = None):
|
def submitDBCreation(self, userID = None, data = None, rAPI = None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
@@ -48,21 +48,22 @@ class DatabaseManager:
|
|||||||
dbPassword = data['dbPassword']
|
dbPassword = data['dbPassword']
|
||||||
webUsername = data['webUserName']
|
webUsername = data['webUserName']
|
||||||
|
|
||||||
|
if rAPI == None:
|
||||||
dbName = webUsername + "_" + dbName
|
dbName = webUsername + "_" + dbName
|
||||||
dbUsername = webUsername + "_" + dbUsername
|
dbUsername = webUsername + "_" + dbUsername
|
||||||
|
|
||||||
result = mysqlUtilities.submitDBCreation(dbName, dbUsername, dbPassword, databaseWebsite)
|
result = mysqlUtilities.submitDBCreation(dbName, dbUsername, dbPassword, databaseWebsite)
|
||||||
|
|
||||||
if result[0] == 1:
|
if result[0] == 1:
|
||||||
data_ret = {'createDBStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'createDBStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
data_ret = {'createDBStatus': 0, 'error_message': result[1]}
|
data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': result[1]}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createDBStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createDBStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -108,12 +109,12 @@ class DatabaseManager:
|
|||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
|
|
||||||
final_json = json.dumps({'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, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
final_json = json.dumps({'fetchStatus': 0, 'error_message': str(msg)})
|
final_json = json.dumps({'status': 0, 'fetchStatus': 0, 'error_message': str(msg)})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
def submitDatabaseDeletion(self, userID = None, data = None):
|
def submitDatabaseDeletion(self, userID = None, data = None):
|
||||||
@@ -128,16 +129,16 @@ class DatabaseManager:
|
|||||||
result = mysqlUtilities.submitDBDeletion(dbName)
|
result = mysqlUtilities.submitDBDeletion(dbName)
|
||||||
|
|
||||||
if result[0] == 1:
|
if result[0] == 1:
|
||||||
data_ret = {'deleteStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'deleteStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
data_ret = {'deleteStatus': 0, 'error_message': result[1]}
|
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': result[1]}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'deleteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -176,15 +177,15 @@ class DatabaseManager:
|
|||||||
res = subprocess.call(cmd)
|
res = subprocess.call(cmd)
|
||||||
|
|
||||||
if res == 1:
|
if res == 1:
|
||||||
data_ret = {'changePasswordStatus': 0, 'error_message': "Please see CyberPanel main log file."}
|
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
data_ret = {'changePasswordStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'changePasswordStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -310,11 +310,11 @@ class DNSManager:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
final_json = json.dumps({'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, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'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)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -474,12 +474,12 @@ class DNSManager:
|
|||||||
recordContentCAA = data['recordContentCAA'] ## IP or ponting value
|
recordContentCAA = data['recordContentCAA'] ## IP or ponting value
|
||||||
DNS.createDNSRecord(zone, value, recordType, recordContentCAA, 0, ttl)
|
DNS.createDNSRecord(zone, value, recordType, recordContentCAA, 0, ttl)
|
||||||
|
|
||||||
final_dic = {'add_status': 1, 'error_message': "None"}
|
final_dic = {'status': 1, 'add_status': 1, 'error_message': "None"}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'add_status': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'add_status': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -495,12 +495,12 @@ class DNSManager:
|
|||||||
delRecord = Records.objects.get(id=id)
|
delRecord = Records.objects.get(id=id)
|
||||||
delRecord.delete()
|
delRecord.delete()
|
||||||
|
|
||||||
final_dic = {'delete_status': 1, 'error_message': "None"}
|
final_dic = {'status': 1, 'delete_status': 1, 'error_message': "None"}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'delete_status': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'delete_status': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ class FTPManager:
|
|||||||
path = data['path']
|
path = data['path']
|
||||||
domainName = data['ftpDomain']
|
domainName = data['ftpDomain']
|
||||||
|
|
||||||
|
try:
|
||||||
|
api = data['api']
|
||||||
|
except:
|
||||||
|
api = '0'
|
||||||
|
|
||||||
admin = Administrator.objects.get(id=userID)
|
admin = Administrator.objects.get(id=userID)
|
||||||
|
|
||||||
if len(path) > 0:
|
if len(path) > 0:
|
||||||
@@ -76,21 +81,21 @@ class FTPManager:
|
|||||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py"
|
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/ftpUtilities.py"
|
||||||
|
|
||||||
execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \
|
execPath = execPath + " submitFTPCreation --domainName " + domainName + " --userName " + userName \
|
||||||
+ " --password " + password + " --path " + path + " --owner " + admin.userName
|
+ " --password " + password + " --path " + path + " --owner " + admin.userName + ' --api ' + api
|
||||||
|
|
||||||
output = subprocess.check_output(shlex.split(execPath))
|
output = subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
data_ret = {'creatFTPStatus': 1, 'error_message': 'None'}
|
data_ret = {'status': 1, 'creatFTPStatus': 1, 'error_message': 'None'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
else:
|
else:
|
||||||
data_ret = {'creatFTPStatus': 0, 'error_message': output}
|
data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'creatFTPStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'creatFTPStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -162,11 +167,11 @@ class FTPManager:
|
|||||||
|
|
||||||
FTPUtilities.submitFTPDeletion(ftpUserName)
|
FTPUtilities.submitFTPDeletion(ftpUserName)
|
||||||
|
|
||||||
final_json = json.dumps({'deleteStatus': 1, 'error_message': "None"})
|
final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'deleteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -220,13 +225,12 @@ class FTPManager:
|
|||||||
json_data = json_data + ',' + json.dumps(dic)
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
final_json = json.dumps({'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, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'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)
|
||||||
|
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
def changePassword(self):
|
def changePassword(self):
|
||||||
@@ -243,10 +247,10 @@ class FTPManager:
|
|||||||
|
|
||||||
FTPUtilities.changeFTPPassword(userName, password)
|
FTPUtilities.changeFTPPassword(userName, password)
|
||||||
|
|
||||||
data_ret = {'changePasswordStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'changePasswordStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -4,5 +4,5 @@ import views
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.loadLoginPage, name='adminLogin'),
|
url(r'^$', views.loadLoginPage, name='adminLogin'),
|
||||||
url(r'^verifyLogin$', views.verifyLogin, name='verifyLogin'),
|
url(r'^verifyLogin$', views.verifyLogin, name='verifyLogin'),
|
||||||
url(r'^logout', views.logout, name='logout')
|
url(r'^logout$', views.logout, name='logout')
|
||||||
]
|
]
|
||||||
@@ -77,18 +77,17 @@ class MailServerManager:
|
|||||||
output = subprocess.check_output(shlex.split(execPath))
|
output = subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
|
data_ret = {'status': 1, 'createEmailStatus': 1, 'error_message': "None"}
|
||||||
data_ret = {'createEmailStatus': 1, 'error_message': "None"}
|
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data_ret = {'createEmailStatus': 0, 'error_message': output}
|
data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createEmailStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createEmailStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -126,22 +125,23 @@ class MailServerManager:
|
|||||||
try:
|
try:
|
||||||
domain = Domains.objects.get(domain=domain)
|
domain = Domains.objects.get(domain=domain)
|
||||||
except:
|
except:
|
||||||
final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exists!"}
|
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': "No email accounts exists!"}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
emails = domain.eusers_set.all()
|
emails = domain.eusers_set.all()
|
||||||
|
|
||||||
if emails.count() == 0:
|
if emails.count() == 0:
|
||||||
final_dic = {'fetchStatus': 0, 'error_message': "No email accounts exists!"}
|
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': "No email accounts exists!"}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
json_data = "["
|
json_data = "["
|
||||||
checker = 0
|
checker = 0
|
||||||
|
count = 1
|
||||||
for items in emails:
|
for items in emails:
|
||||||
dic = {'email': items.email}
|
dic = {'id': count, 'email': items.email}
|
||||||
|
count = count + 1
|
||||||
|
|
||||||
if checker == 0:
|
if checker == 0:
|
||||||
json_data = json_data + json.dumps(dic)
|
json_data = json_data + json.dumps(dic)
|
||||||
@@ -150,13 +150,13 @@ class MailServerManager:
|
|||||||
json_data = json_data + ',' + json.dumps(dic)
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
final_dic = {'fetchStatus': 1, 'error_message': "None", "data": json_data}
|
final_dic = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
|
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -173,12 +173,12 @@ class MailServerManager:
|
|||||||
email = data['email']
|
email = data['email']
|
||||||
|
|
||||||
mailUtilities.deleteEmailAccount(email)
|
mailUtilities.deleteEmailAccount(email)
|
||||||
data_ret = {'deleteEmailStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'deleteEmailStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'deleteEmailStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'deleteEmailStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -232,14 +232,14 @@ class MailServerManager:
|
|||||||
json_data = json_data + ',' + json.dumps(dic)
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
final_dic = {'fetchStatus': 1, 'error_message': "None", "data": json_data}
|
final_dic = {'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
|
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -257,13 +257,13 @@ class MailServerManager:
|
|||||||
forwarding = Forwardings.objects.get(destination=destination, source=source)
|
forwarding = Forwardings.objects.get(destination=destination, source=source)
|
||||||
forwarding.delete()
|
forwarding.delete()
|
||||||
|
|
||||||
data_ret = {'deleteForwardingStatus': 1, 'error_message': "None",
|
data_ret = {'status': 1, 'deleteForwardingStatus': 1, 'error_message': "None",
|
||||||
'successMessage': 'Successfully deleted!'}
|
'successMessage': 'Successfully deleted!'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'deleteForwardingStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'deleteForwardingStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ class MailServerManager:
|
|||||||
destination = data['destination']
|
destination = data['destination']
|
||||||
|
|
||||||
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
|
if Forwardings.objects.filter(source=source, destination=destination).count() > 0:
|
||||||
data_ret = {'createStatus': 0,
|
data_ret = {'status': 0, 'createStatus': 0,
|
||||||
'error_message': "You have already forwared to this destination."}
|
'error_message': "You have already forwared to this destination."}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -291,12 +291,12 @@ class MailServerManager:
|
|||||||
forwarding = Forwardings(source=source, destination=destination)
|
forwarding = Forwardings(source=source, destination=destination)
|
||||||
forwarding.save()
|
forwarding.save()
|
||||||
|
|
||||||
data_ret = {'createStatus': 1, 'error_message': "None", 'successMessage': 'Successfully Created!'}
|
data_ret = {'status': 1, 'createStatus': 1, 'error_message': "None", 'successMessage': 'Successfully Created!'}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -340,12 +340,12 @@ class MailServerManager:
|
|||||||
emailAcct = EUsers(emailOwner=dom, email=email, password=password)
|
emailAcct = EUsers(emailOwner=dom, email=email, password=password)
|
||||||
emailAcct.save()
|
emailAcct.save()
|
||||||
|
|
||||||
data_ret = {'passChangeStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'passChangeStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'passChangeStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'passChangeStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -397,19 +397,19 @@ class MailServerManager:
|
|||||||
command = "sudo cat " + path
|
command = "sudo cat " + path
|
||||||
privateKey = subprocess.check_output(shlex.split(command))
|
privateKey = subprocess.check_output(shlex.split(command))
|
||||||
|
|
||||||
data_ret = {'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
|
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 1, 'publicKey': output[leftIndex:rightIndex],
|
||||||
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
|
'privateKey': privateKey, 'dkimSuccessMessage': 'Keys successfully fetched!',
|
||||||
'error_message': "None"}
|
'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)}
|
data_ret = {'status': 1, 'fetchStatus': 1, 'keysAvailable': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'fetchStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -450,17 +450,17 @@ class MailServerManager:
|
|||||||
auth=1)
|
auth=1)
|
||||||
record.save()
|
record.save()
|
||||||
|
|
||||||
data_ret = {'generateStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'generateStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data_ret = {'generateStatus': 0, 'error_message': output}
|
data_ret = {'status': 0, 'generateStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'generateStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'generateStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import json
|
|||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
from plogical.acl import ACLManager
|
from plogical.acl import ACLManager
|
||||||
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
@@ -58,14 +59,14 @@ def issueSSL(request):
|
|||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
virtualHost = data['virtualHost']
|
virtualHost = data['virtualHost']
|
||||||
|
|
||||||
|
|
||||||
adminEmail = ""
|
adminEmail = ""
|
||||||
path = ""
|
path = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
website = ChildDomains.objects.get(domain=virtualHost)
|
website = ChildDomains.objects.get(domain=virtualHost)
|
||||||
adminEmail = website.master.adminEmail
|
adminEmail = website.master.adminEmail
|
||||||
path = data['path']
|
path = website.path
|
||||||
|
|
||||||
except:
|
except:
|
||||||
website = Websites.objects.get(domain=virtualHost)
|
website = Websites.objects.get(domain=virtualHost)
|
||||||
adminEmail = website.adminEmail
|
adminEmail = website.adminEmail
|
||||||
@@ -74,16 +75,13 @@ def issueSSL(request):
|
|||||||
## ssl issue
|
## ssl issue
|
||||||
|
|
||||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||||
|
|
||||||
execPath = execPath + " issueSSL --virtualHostName " + virtualHost + " --administratorEmail " + adminEmail + " --path " + path
|
execPath = execPath + " issueSSL --virtualHostName " + virtualHost + " --administratorEmail " + adminEmail + " --path " + path
|
||||||
|
|
||||||
output = subprocess.check_output(shlex.split(execPath))
|
output = subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data_ret = {"SSL": 0,
|
data_ret = {'status': 0 ,"SSL": 0,
|
||||||
'error_message': output}
|
'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
@@ -93,18 +91,18 @@ def issueSSL(request):
|
|||||||
website.ssl = 1
|
website.ssl = 1
|
||||||
website.save()
|
website.save()
|
||||||
|
|
||||||
data_ret = {"SSL": 1,
|
data_ret = {'status': 1, "SSL": 1,
|
||||||
'error_message': "None"}
|
'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException,msg:
|
except BaseException,msg:
|
||||||
data_ret = {"SSL": 0,
|
data_ret = {'status': 0, "SSL": 0,
|
||||||
'error_message': str(msg)}
|
'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data_ret = {"SSL": 0,
|
data_ret = {'status': 0, "SSL": 0,
|
||||||
'error_message': str(msg)}
|
'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from websiteFunctions.models import Websites, Backups, dest, backupSchedules
|
|||||||
from virtualHostUtilities import virtualHostUtilities
|
from virtualHostUtilities import virtualHostUtilities
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
from django.shortcuts import HttpResponse, render, redirect
|
from django.shortcuts import HttpResponse, render
|
||||||
from loginSystem.models import Administrator
|
from loginSystem.models import Administrator
|
||||||
from mailUtilities import mailUtilities
|
from mailUtilities import mailUtilities
|
||||||
from random import randint
|
from random import randint
|
||||||
@@ -110,10 +110,10 @@ class BackupManager:
|
|||||||
json_data = json_data + ',' + json.dumps(dic)
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
json_data = json_data + ']'
|
json_data = json_data + ']'
|
||||||
final_json = json.dumps({'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, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'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)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -148,12 +148,12 @@ class BackupManager:
|
|||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
final_json = json.dumps({'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath})
|
final_json = json.dumps({'status': 1, 'metaStatus': 1, 'error_message': "None", 'tempStorage': tempStoragePath})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||||
final_dic = {'metaStatus': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'metaStatus': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -272,10 +272,10 @@ class BackupManager:
|
|||||||
|
|
||||||
backup.delete()
|
backup.delete()
|
||||||
|
|
||||||
final_json = json.dumps({'deleteStatus': 1, 'error_message': "None", "status": 0})
|
final_json = json.dumps({'status': 1, 'deleteStatus': 1, 'error_message': "None"})
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'deleteStatus': 0, 'error_message': str(msg)}
|
final_dic = {'status': 0, 'deleteStatus': 0, 'error_message': str(msg)}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
|
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
@@ -1301,11 +1301,3 @@ class BackupManager:
|
|||||||
data = {'cancelStatus': 0, 'error_message': str(msg)}
|
data = {'cancelStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data)
|
json_data = json.dumps(data)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class FTPUtilities:
|
|||||||
return 0, str(msg)
|
return 0, str(msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def submitFTPCreation(domainName, userName, password, path, owner):
|
def submitFTPCreation(domainName, userName, password, path, owner, api = None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
## need to get gid and uid
|
## need to get gid and uid
|
||||||
@@ -290,8 +290,10 @@ class FTPUtilities:
|
|||||||
|
|
||||||
admin = Administrator.objects.get(userName=owner)
|
admin = Administrator.objects.get(userName=owner)
|
||||||
|
|
||||||
|
if api == '0':
|
||||||
userName = admin.userName + "_" + userName
|
userName = admin.userName + "_" + userName
|
||||||
|
|
||||||
|
|
||||||
if website.package.ftpAccounts == 0:
|
if website.package.ftpAccounts == 0:
|
||||||
user = Users(domain=website, user=userName, password=hash.hexdigest(), uid=uid, gid=gid,
|
user = Users(domain=website, user=userName, password=hash.hexdigest(), uid=uid, gid=gid,
|
||||||
dir=path,
|
dir=path,
|
||||||
@@ -302,7 +304,6 @@ class FTPUtilities:
|
|||||||
date=datetime.now())
|
date=datetime.now())
|
||||||
|
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
elif website.users_set.all().count() < website.package.ftpAccounts:
|
elif website.users_set.all().count() < website.package.ftpAccounts:
|
||||||
user = Users(domain=website, user=userName, password=hash.hexdigest(), uid=uid, gid=gid,
|
user = Users(domain=website, user=userName, password=hash.hexdigest(), uid=uid, gid=gid,
|
||||||
dir=path, quotasize=website.package.diskSpace,
|
dir=path, quotasize=website.package.diskSpace,
|
||||||
@@ -366,16 +367,16 @@ def main():
|
|||||||
parser.add_argument('--password', help='Password for FTP Account')
|
parser.add_argument('--password', help='Password for FTP Account')
|
||||||
parser.add_argument('--owner', help='FTP Account owner.')
|
parser.add_argument('--owner', help='FTP Account owner.')
|
||||||
parser.add_argument('--path', help='Path to ftp directory!')
|
parser.add_argument('--path', help='Path to ftp directory!')
|
||||||
|
parser.add_argument('--api', help='API Check!')
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.function == "submitFTPCreation":
|
if args.function == "submitFTPCreation":
|
||||||
FTPUtilities.submitFTPCreation(args.domainName,args.userName, args.password, args.path, args.owner)
|
FTPUtilities.submitFTPCreation(args.domainName,args.userName, args.password, args.path, args.owner, args.api)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -94,20 +94,7 @@ class WebsiteManager:
|
|||||||
def listWebsites(self, request = None, userID = None, data = None):
|
def listWebsites(self, request = None, userID = None, data = None):
|
||||||
try:
|
try:
|
||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
websites = ACLManager.findAllSites(currentACL, userID)
|
pagination = self.websitePagination(currentACL, userID)
|
||||||
|
|
||||||
pages = float(len(websites)) / float(10)
|
|
||||||
pagination = []
|
|
||||||
|
|
||||||
if pages <= 1.0:
|
|
||||||
pages = 1
|
|
||||||
pagination.append('<li><a href="\#"></a></li>')
|
|
||||||
else:
|
|
||||||
pages = ceil(pages)
|
|
||||||
finalPages = int(pages) + 1
|
|
||||||
|
|
||||||
for i in range(1, finalPages):
|
|
||||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
|
||||||
|
|
||||||
return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination})
|
return render(request, 'websiteFunctions/listWebsites.html', {"pagination": pagination})
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
@@ -173,13 +160,13 @@ class WebsiteManager:
|
|||||||
subprocess.Popen(shlex.split(execPath))
|
subprocess.Popen(shlex.split(execPath))
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
data_ret = {'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createWebSiteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'createWebSiteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -221,12 +208,12 @@ class WebsiteManager:
|
|||||||
subprocess.Popen(shlex.split(execPath))
|
subprocess.Popen(shlex.split(execPath))
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
data_ret = {'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
data_ret = {'status': 1, 'createWebSiteStatus': 1, 'error_message': "None", 'tempStatusPath': tempStatusPath}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'createWebSiteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0,'createWebSiteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -245,11 +232,11 @@ class WebsiteManager:
|
|||||||
cdManager = ChildDomainManager(masterDomain)
|
cdManager = ChildDomainManager(masterDomain)
|
||||||
json_data = cdManager.findChildDomainsJson()
|
json_data = cdManager.findChildDomainsJson()
|
||||||
|
|
||||||
final_json = json.dumps({'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, msg:
|
except BaseException, msg:
|
||||||
final_dic = {'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)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
@@ -258,11 +245,12 @@ class WebsiteManager:
|
|||||||
currentACL = ACLManager.loadedACL(userID)
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
pageNumber = int(data['page'])
|
pageNumber = int(data['page'])
|
||||||
json_data = self.findWebsitesJson(currentACL, userID, pageNumber)
|
json_data = self.findWebsitesJson(currentACL, userID, pageNumber)
|
||||||
final_dic = {'listWebSiteStatus': 1, 'error_message': "None", "data": json_data}
|
pagination = self.websitePagination(currentACL, userID)
|
||||||
|
final_dic = {'status': 1, 'listWebSiteStatus': 1, 'error_message': "None", "data": json_data, 'pagination': pagination}
|
||||||
final_json = json.dumps(final_dic)
|
final_json = json.dumps(final_dic)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
dic = {'listWebSiteStatus': 0, 'error_message': str(msg)}
|
dic = {'status': 1, 'listWebSiteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(dic)
|
json_data = json.dumps(dic)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -281,12 +269,12 @@ class WebsiteManager:
|
|||||||
execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName
|
execPath = execPath + " deleteVirtualHostConfigurations --virtualHostName " + websiteName
|
||||||
subprocess.check_output(shlex.split(execPath))
|
subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
data_ret = {'websiteDeleteStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -306,12 +294,12 @@ class WebsiteManager:
|
|||||||
execPath = execPath + " deleteDomain --virtualHostName " + websiteName
|
execPath = execPath + " deleteDomain --virtualHostName " + websiteName
|
||||||
subprocess.check_output(shlex.split(execPath))
|
subprocess.check_output(shlex.split(execPath))
|
||||||
|
|
||||||
data_ret = {'websiteDeleteStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'websiteDeleteStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'websiteDeleteStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'websiteDeleteStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -407,14 +395,66 @@ class WebsiteManager:
|
|||||||
currentPack = modifyWeb.package.packageName
|
currentPack = modifyWeb.package.packageName
|
||||||
owner = modifyWeb.admin.userName
|
owner = modifyWeb.admin.userName
|
||||||
|
|
||||||
data_ret = {'modifyStatus': 1, 'error_message': "None", "adminEmail": email,
|
data_ret = {'status': 1, 'modifyStatus': 1, 'error_message': "None", "adminEmail": email,
|
||||||
"packages": json_data, "current_pack": currentPack, "adminNames": admin_data,
|
"packages": json_data, "current_pack": currentPack, "adminNames": admin_data,
|
||||||
'currentAdmin': owner}
|
'currentAdmin': owner}
|
||||||
final_json = json.dumps(data_ret)
|
final_json = json.dumps(data_ret)
|
||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
dic = {'modifyStatus': 0, 'error_message': str(msg)}
|
dic = {'status': 0, 'modifyStatus': 0, 'error_message': str(msg)}
|
||||||
|
json_data = json.dumps(dic)
|
||||||
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
|
def fetchWebsiteDataJSON(self, userID = None, data = None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
currentACL = ACLManager.loadedACL(userID)
|
||||||
|
if ACLManager.currentContextPermission(currentACL, 'createWebsite') == 0:
|
||||||
|
return ACLManager.loadErrorJson('createWebSiteStatus', 0)
|
||||||
|
|
||||||
|
packs = ACLManager.loadPackages(userID, currentACL)
|
||||||
|
admins = ACLManager.loadAllUsers(userID)
|
||||||
|
|
||||||
|
## Get packs name
|
||||||
|
|
||||||
|
json_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in packs:
|
||||||
|
dic = {"pack": items}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
json_data = json_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
json_data = json_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
json_data = json_data + ']'
|
||||||
|
|
||||||
|
### Get admin names
|
||||||
|
|
||||||
|
admin_data = "["
|
||||||
|
checker = 0
|
||||||
|
|
||||||
|
for items in admins:
|
||||||
|
dic = {"adminNames": items}
|
||||||
|
|
||||||
|
if checker == 0:
|
||||||
|
admin_data = admin_data + json.dumps(dic)
|
||||||
|
checker = 1
|
||||||
|
else:
|
||||||
|
admin_data = admin_data + ',' + json.dumps(dic)
|
||||||
|
|
||||||
|
admin_data = admin_data + ']'
|
||||||
|
|
||||||
|
data_ret = {'status': 1, 'error_message': "None",
|
||||||
|
"packages": json_data, "adminNames": admin_data}
|
||||||
|
final_json = json.dumps(data_ret)
|
||||||
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
|
except BaseException, msg:
|
||||||
|
dic = {'status': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(dic)
|
json_data = json.dumps(dic)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -442,7 +482,7 @@ class WebsiteManager:
|
|||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': output}
|
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -460,12 +500,12 @@ class WebsiteManager:
|
|||||||
|
|
||||||
modifyWeb.save()
|
modifyWeb.save()
|
||||||
|
|
||||||
data_ret = {'saveStatus': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'saveStatus': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0, 'saveStatus': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -484,6 +524,7 @@ class WebsiteManager:
|
|||||||
return ACLManager.loadError()
|
return ACLManager.loadError()
|
||||||
|
|
||||||
Data = {}
|
Data = {}
|
||||||
|
|
||||||
marketingStatus = emACL.checkIfEMEnabled(admin.userName)
|
marketingStatus = emACL.checkIfEMEnabled(admin.userName)
|
||||||
|
|
||||||
Data['marketingStatus'] = marketingStatus
|
Data['marketingStatus'] = marketingStatus
|
||||||
@@ -917,11 +958,11 @@ class WebsiteManager:
|
|||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
data_ret = {'changePHP': 0, 'error_message': output}
|
data_ret = {'status': 1, 'changePHP': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
data_ret = {'changePHP': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'changePHP': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -1244,7 +1285,6 @@ class WebsiteManager:
|
|||||||
return HttpResponse(final_json)
|
return HttpResponse(final_json)
|
||||||
|
|
||||||
# Confirming that directory is read/writable
|
# Confirming that directory is read/writable
|
||||||
|
|
||||||
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
o = subprocess.call(['sudo', 'chown', 'cyberpanel:cyberpanel', tempPath])
|
||||||
if o is not 0:
|
if o is not 0:
|
||||||
data_ret = {'addNewCron': 0, 'error_message': 'Error Changing Permissions'}
|
data_ret = {'addNewCron': 0, 'error_message': 'Error Changing Permissions'}
|
||||||
@@ -1417,16 +1457,16 @@ class WebsiteManager:
|
|||||||
if output.find("1,None") > -1:
|
if output.find("1,None") > -1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
data_ret = {'changeOpenBasedir': 0, 'error_message': output}
|
data_ret = {'status': 0, 'changeOpenBasedir': 0, 'error_message': output}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
data_ret = {'changeOpenBasedir': 1, 'error_message': "None"}
|
data_ret = {'status': 1, 'changeOpenBasedir': 1, 'error_message': "None"}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
except BaseException, msg:
|
except BaseException, msg:
|
||||||
data_ret = {'changeOpenBasedir': 0, 'error_message': str(msg)}
|
data_ret = {'status': 0,'changeOpenBasedir': 0, 'error_message': str(msg)}
|
||||||
json_data = json.dumps(data_ret)
|
json_data = json.dumps(data_ret)
|
||||||
return HttpResponse(json_data)
|
return HttpResponse(json_data)
|
||||||
|
|
||||||
@@ -1986,10 +2026,20 @@ class WebsiteManager:
|
|||||||
|
|
||||||
return json_data
|
return json_data
|
||||||
|
|
||||||
|
def websitePagination(self, currentACL, userID):
|
||||||
|
websites = ACLManager.findAllSites(currentACL, userID)
|
||||||
|
|
||||||
|
pages = float(len(websites)) / float(10)
|
||||||
|
pagination = []
|
||||||
|
|
||||||
|
if pages <= 1.0:
|
||||||
|
pages = 1
|
||||||
|
pagination.append('<li><a href="\#"></a></li>')
|
||||||
|
else:
|
||||||
|
pages = ceil(pages)
|
||||||
|
finalPages = int(pages) + 1
|
||||||
|
|
||||||
|
for i in range(1, finalPages):
|
||||||
|
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||||
|
|
||||||
|
return pagination
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user