Merge branch 'v2.0.5-dev' into FIX/MasterSlaveDNS
This commit is contained in:
commit
622f43dfa6
|
|
@ -10,7 +10,7 @@ from django.shortcuts import HttpResponse
|
|||
from math import ceil
|
||||
from websiteFunctions.models import Websites
|
||||
from CLManager.models import CLPackages
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
class CLManagerMain(multi.Thread):
|
||||
|
||||
|
|
@ -27,29 +27,14 @@ class CLManagerMain(multi.Thread):
|
|||
self.submitCageFSInstall()
|
||||
elif self.function == 'enableOrDisable':
|
||||
self.enableOrDisable()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [ContainerManager.run]')
|
||||
|
||||
def renderC(self):
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
data = {}
|
||||
data['CL'] = 0
|
||||
data['activatedPath'] = 0
|
||||
data['ipAddress'] = ipAddress
|
||||
CLPath = '/etc/sysconfig/cloudlinux'
|
||||
activatedPath = '/home/cyberpanel/cloudlinux'
|
||||
|
||||
|
|
@ -60,11 +45,14 @@ class CLManagerMain(multi.Thread):
|
|||
data['activatedPath'] = 1
|
||||
|
||||
if data['CL'] == 0:
|
||||
return render(self.request, 'CLManager/notAvailable.html', data)
|
||||
proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin')
|
||||
return proc.render()
|
||||
elif data['activatedPath'] == 0:
|
||||
return render(self.request, 'CLManager/notAvailable.html', data)
|
||||
proc = httpProc(self.request, 'CLManager/notAvailable.html', data, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
return render(self.request, 'CLManager/cloudLinux.html', data)
|
||||
proc = httpProc(self.request, 'CLManager/cloudLinux.html', data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def submitCageFSInstall(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class CLMain():
|
|||
def __init__(self):
|
||||
self.path = '/usr/local/CyberCP/version.txt'
|
||||
#versionInfo = json.loads(open(self.path, 'r').read())
|
||||
self.version = '2.0'
|
||||
self.build = '3'
|
||||
self.version = '2.1'
|
||||
self.build = '1'
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import argparse
|
|||
import json
|
||||
from CLScript.CLMain import CLMain
|
||||
|
||||
|
||||
class CloudLinuxResellers(CLMain):
|
||||
|
||||
def __init__(self, id, name):
|
||||
|
|
@ -23,17 +22,26 @@ class CloudLinuxResellers(CLMain):
|
|||
self.name = name
|
||||
|
||||
def listAll(self, owner=None):
|
||||
import pwd
|
||||
users = []
|
||||
acl = ACL.objects.get(name='reseller')
|
||||
from plogical.vhost import vhost
|
||||
for items in Administrator.objects.filter(acl=acl):
|
||||
if self.name != None:
|
||||
if self.name != items.userName:
|
||||
continue
|
||||
|
||||
|
||||
try:
|
||||
uid = pwd.getpwnam(items.userName).pw_uid
|
||||
except:
|
||||
vhost.addUser(items.userName, '/home/%s' % (items.userName))
|
||||
uid = pwd.getpwnam(items.userName).pw_uid
|
||||
|
||||
user = {'name': items.userName,
|
||||
"locale_code": "EN_us",
|
||||
"email": items.email,
|
||||
"id": None
|
||||
"id": uid
|
||||
}
|
||||
|
||||
users.append(user)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class CloudLinuxUsers(CLMain):
|
|||
for webs in websites:
|
||||
try:
|
||||
itemPackage = webs.package
|
||||
package = {'name': itemPackage.packageName, 'owner': webs.externalApp}
|
||||
package = {'name': itemPackage.packageName, 'owner': webs.admin.userName}
|
||||
|
||||
user = {}
|
||||
|
||||
|
|
@ -92,7 +92,12 @@ class CloudLinuxUsers(CLMain):
|
|||
user['username'] = webs.externalApp
|
||||
|
||||
if self.ow:
|
||||
user['owner'] = webs.externalApp
|
||||
if webs.admin.owner == 1:
|
||||
user['owner'] = webs.admin.userName
|
||||
else:
|
||||
from loginSystem.models import Administrator
|
||||
oAdmin = Administrator.objects.get(pk=webs.admin.owner)
|
||||
user['owner'] = oAdmin.userName
|
||||
|
||||
if self.domain:
|
||||
user['domain'] = webs.domain
|
||||
|
|
@ -133,7 +138,11 @@ class CloudLinuxUsers(CLMain):
|
|||
if self.owner == None:
|
||||
websites = Websites.objects.all()
|
||||
else:
|
||||
websites = Websites.objects.filter(externalApp=self.owner)
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.acl import ACLManager
|
||||
oAdmin = Administrator.objects.get(userName=self.owner)
|
||||
currentACL = ACLManager.loadedACL(oAdmin.pk)
|
||||
websites = ACLManager.findWebsiteObjects(currentACL, oAdmin.pk)
|
||||
|
||||
if self.username != None:
|
||||
websites = websites.filter(externalApp=self.username)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,15 @@
|
|||
import getpass
|
||||
|
||||
def main():
|
||||
import pwd
|
||||
if getpass.getuser() == 'root':
|
||||
userType = "admin"
|
||||
else:
|
||||
userType = "user"
|
||||
try:
|
||||
uid = pwd.getpwnam(getpass.getuser()).pw_uid
|
||||
userType = 'reseller'
|
||||
except:
|
||||
userType = 'user'
|
||||
|
||||
data = """{
|
||||
"userName": "%s",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# coding=utf-8
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
import json
|
||||
from django.shortcuts import HttpResponse
|
||||
from django.shortcuts import HttpResponse, render
|
||||
import re
|
||||
from loginSystem.models import Administrator
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class secMiddleware:
|
|||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
if request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('filemanager') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
|
||||
if request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('filemanager') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
|
||||
continue
|
||||
if key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
|
||||
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \
|
||||
|
|
@ -96,17 +96,24 @@ class secMiddleware:
|
|||
logging.writeToFile(str(msg))
|
||||
response = self.get_response(request)
|
||||
return response
|
||||
|
||||
# else:
|
||||
# try:
|
||||
# if request.path.find('cloudAPI/') > -1 or request.path.find('api/') > -1:
|
||||
# pass
|
||||
# else:
|
||||
# uID = request.session['userID']
|
||||
# except:
|
||||
# return render(request, 'loginSystem/login.html', {})
|
||||
|
||||
response = self.get_response(request)
|
||||
|
||||
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'] = "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['Content-Security-Policy'] = "default-src 'self' cyberpanel.cloud *.cyberpanel.cloud"
|
||||
response['X-Content-Type-Options'] = "nosniff"
|
||||
response['Referrer-Policy'] = "same-origin"
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ DATABASES = {
|
|||
'USER': 'cyberpanel',
|
||||
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
||||
'HOST': 'localhost',
|
||||
'PORT':''
|
||||
'PORT': ''
|
||||
},
|
||||
'rootdb': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class IncBackupPath(Enum):
|
||||
SFTP = "/home/cyberpanel/sftp"
|
||||
AWS = "/home/cyberpanel/aws"
|
||||
# WASABI = "/home/cyberpanel/wasabi"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
from enum import Enum, auto
|
||||
|
||||
|
||||
class IncBackupProvider(Enum):
|
||||
LOCAL = auto()
|
||||
SFTP = auto()
|
||||
AWS = auto()
|
||||
# WASABI = auto()
|
||||
|
|
@ -83,9 +83,7 @@ class IncJobs(multi.Thread):
|
|||
result = self.getRemoteBackups()
|
||||
|
||||
activator = 0
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
json_data = []
|
||||
if result[0].find('unable to open config file') == -1:
|
||||
for items in reversed(result):
|
||||
|
||||
|
|
@ -98,20 +96,11 @@ class IncJobs(multi.Thread):
|
|||
|
||||
if activator:
|
||||
entry = items.split(' ')
|
||||
|
||||
dic = {'id': entry[0],
|
||||
'date': "%s %s" % (entry[2], entry[3]),
|
||||
'host': entry[5],
|
||||
'path': entry[-1]
|
||||
}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
json_data.append({'id': entry[0],
|
||||
'date': "%s %s" % (entry[2], entry[3]),
|
||||
'host': entry[5],
|
||||
'path': entry[-1]
|
||||
})
|
||||
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
|||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
@ -240,7 +240,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.jobs = JSON.parse(response.data.data);
|
||||
$scope.jobs = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -358,7 +358,7 @@ app.controller('incrementalDestinations', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -621,7 +621,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Destination successfully removed.',
|
||||
text: 'Operation successful.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
|
|
@ -668,12 +668,11 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
var parsed = JSON.parse(response.data.data);
|
||||
|
||||
for (var j = 0; j < parsed.length; j++) {
|
||||
websitesToBeBackedTemp.push(parsed[j].website);
|
||||
}
|
||||
let data = response.data.data;
|
||||
$scope.records = data;
|
||||
data.forEach(item => {
|
||||
websitesToBeBackedTemp.push(item.website)
|
||||
})
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -766,7 +765,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.websites = JSON.parse(response.data.data);
|
||||
$scope.websites = response.data.data;
|
||||
|
||||
if(response.data.websiteData === 1){
|
||||
$scope.websiteData = true;
|
||||
|
|
@ -1074,7 +1073,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
</div>
|
||||
|
||||
<div ng-hide="destination" class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||
<label class="col-sm-3 control-label">{% trans "Encrypted Backup Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" name="password" class="form-control" ng-model="password"
|
||||
required>
|
||||
|
|
|
|||
|
|
@ -2,24 +2,24 @@ from django.conf.urls import url
|
|||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^createBackup$', views.createBackup, name='createBackupInc'),
|
||||
url(r'^restoreRemoteBackups$', views.restoreRemoteBackups, name='restoreRemoteBackupsInc'),
|
||||
url(r'^backupDestinations$', views.backupDestinations, name='backupDestinationsInc'),
|
||||
url(r'^addDestination$', views.addDestination, name='addDestinationInc'),
|
||||
url(r'^populateCurrentRecords$', views.populateCurrentRecords, name='populateCurrentRecordsInc'),
|
||||
url(r'^removeDestination$', views.removeDestination, name='removeDestinationInc'),
|
||||
url(r'^fetchCurrentBackups$', views.fetchCurrentBackups, name='fetchCurrentBackupsInc'),
|
||||
url(r'^submitBackupCreation$', views.submitBackupCreation, name='submitBackupCreationInc'),
|
||||
url(r'^getBackupStatus$', views.getBackupStatus, name='getBackupStatusInc'),
|
||||
url(r'^deleteBackup$', views.deleteBackup, name='deleteBackupInc'),
|
||||
url(r'^fetchRestorePoints$', views.fetchRestorePoints, name='fetchRestorePointsInc'),
|
||||
url(r'^restorePoint$', views.restorePoint, name='restorePointInc'),
|
||||
url(r'^scheduleBackups$', views.scheduleBackups, name='scheduleBackupsInc'),
|
||||
url(r'^submitBackupSchedule$', views.submitBackupSchedule, name='submitBackupScheduleInc'),
|
||||
url(r'^scheduleDelete$', views.scheduleDelete, name='scheduleDeleteInc'),
|
||||
url(r'^getCurrentBackupSchedules$', views.getCurrentBackupSchedules, name='getCurrentBackupSchedulesInc'),
|
||||
url(r'^fetchSites$', views.fetchSites, name='fetchSites'),
|
||||
url(r'^saveChanges$', views.saveChanges, name='saveChanges'),
|
||||
url(r'^removeSite$', views.removeSite, name='removeSite'),
|
||||
url(r'^addWebsite$', views.addWebsite, name='addWebsite'),
|
||||
url(r'^createBackup$', views.create_backup, name='createBackupInc'),
|
||||
url(r'^restoreRemoteBackups$', views.restore_remote_backups, name='restoreRemoteBackupsInc'),
|
||||
url(r'^backupDestinations$', views.backup_destinations, name='backupDestinationsInc'),
|
||||
url(r'^addDestination$', views.add_destination, name='addDestinationInc'),
|
||||
url(r'^populateCurrentRecords$', views.populate_current_records, name='populateCurrentRecordsInc'),
|
||||
url(r'^removeDestination$', views.remove_destination, name='removeDestinationInc'),
|
||||
url(r'^fetchCurrentBackups$', views.fetch_current_backups, name='fetchCurrentBackupsInc'),
|
||||
url(r'^submitBackupCreation$', views.submit_backup_creation, name='submitBackupCreationInc'),
|
||||
url(r'^getBackupStatus$', views.get_backup_status, name='getBackupStatusInc'),
|
||||
url(r'^deleteBackup$', views.delete_backup, name='deleteBackupInc'),
|
||||
url(r'^fetchRestorePoints$', views.fetch_restore_points, name='fetchRestorePointsInc'),
|
||||
url(r'^restorePoint$', views.restore_point, name='restorePointInc'),
|
||||
url(r'^scheduleBackups$', views.schedule_backups, name='scheduleBackupsInc'),
|
||||
url(r'^submitBackupSchedule$', views.submit_backup_schedule, name='submitBackupScheduleInc'),
|
||||
url(r'^scheduleDelete$', views.schedule_delete, name='scheduleDeleteInc'),
|
||||
url(r'^getCurrentBackupSchedules$', views.get_current_backup_schedules, name='getCurrentBackupSchedulesInc'),
|
||||
url(r'^fetchSites$', views.fetch_sites, name='fetchSites'),
|
||||
url(r'^saveChanges$', views.save_changes, name='saveChanges'),
|
||||
url(r'^removeSite$', views.remove_site, name='removeSite'),
|
||||
url(r'^addWebsite$', views.add_website, name='addWebsite'),
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -26,6 +26,7 @@ Webhosting control panel that uses OpenLiteSpeed as web server.
|
|||
* PHP 7.2
|
||||
* PHP 7.3
|
||||
* PHP 7.4
|
||||
* PHP 8.0
|
||||
|
||||
# Installation Instructions
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
|||
from loginSystem.views import loadLoginPage
|
||||
from random import randint
|
||||
import os
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.firewallUtilities import FirewallUtilities
|
||||
from firewall.models import FirewallRules
|
||||
|
|
@ -16,44 +18,32 @@ import plogical.randomPassword
|
|||
# Create your views here.
|
||||
|
||||
def terminal(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
password = plogical.randomPassword.generate_pass()
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
verifyPath = "/home/cyberpanel/" + str(randint(100000, 999999))
|
||||
writeToFile = open(verifyPath, 'w')
|
||||
writeToFile.write(password)
|
||||
writeToFile.close()
|
||||
|
||||
password = plogical.randomPassword.generate_pass()
|
||||
## setting up ssh server
|
||||
path = '/etc/systemd/system/cpssh.service'
|
||||
curPath = '/usr/local/CyberCP/WebTerminal/cpssh.service'
|
||||
|
||||
verifyPath = "/home/cyberpanel/" + str(randint(100000, 999999))
|
||||
writeToFile = open(verifyPath, 'w')
|
||||
writeToFile.write(password)
|
||||
writeToFile.close()
|
||||
if not os.path.exists(path):
|
||||
command = 'mv %s %s' % (curPath, path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## setting up ssh server
|
||||
path = '/etc/systemd/system/cpssh.service'
|
||||
curPath = '/usr/local/CyberCP/WebTerminal/cpssh.service'
|
||||
command = 'systemctl start cpssh'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if not os.path.exists(path):
|
||||
command = 'mv %s %s' % (curPath, path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'systemctl start cpssh'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
FirewallUtilities.addRule('tcp', '5678', '0.0.0.0/0')
|
||||
|
||||
newFWRule = FirewallRules(name='terminal', proto='tcp', port='5678', ipAddress='0.0.0.0/0')
|
||||
newFWRule.save()
|
||||
|
||||
return render(request, 'WebTerminal/WebTerminal.html', {'verifyPath': verifyPath, 'password': password})
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg))
|
||||
return redirect(loadLoginPage)
|
||||
FirewallUtilities.addRule('tcp', '5678', '0.0.0.0/0')
|
||||
|
||||
newFWRule = FirewallRules(name='terminal', proto='tcp', port='5678', ipAddress='0.0.0.0/0')
|
||||
newFWRule.save()
|
||||
|
||||
proc = httpProc(request, 'WebTerminal/WebTerminal.html',
|
||||
{'verifyPath': verifyPath, 'password': password})
|
||||
return proc.render()
|
||||
|
||||
def restart(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import os.path
|
|||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
|
|
@ -39,43 +41,28 @@ class BackupManager:
|
|||
def loadBackupHome(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
return render(request, 'backup/index.html', currentACL)
|
||||
proc = httpProc(request, 'backup/index.html', currentACL)
|
||||
return proc.render()
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
def backupSite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
return render(request, 'backup/backup.html', {'websiteList': websitesName})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(request, 'backup/backup.html', {'websiteList': websitesName}, 'createBackup')
|
||||
return proc.render()
|
||||
|
||||
def gDrive(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'createBackup') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
gDriveAcctsList = []
|
||||
|
||||
gDriveAccts = admin.gdrive_set.all()
|
||||
|
||||
for items in gDriveAccts:
|
||||
gDriveAcctsList.append(items.name)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'backup/googleDrive.html', {'accounts': gDriveAcctsList, 'websites': websitesName})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
gDriveAcctsList = []
|
||||
gDriveAccts = admin.gdrive_set.all()
|
||||
for items in gDriveAccts:
|
||||
gDriveAcctsList.append(items.name)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(request, 'backup/googleDrive.html', {'accounts': gDriveAcctsList, 'websites': websitesName},
|
||||
'createBackup')
|
||||
return proc.render()
|
||||
|
||||
def gDriveSetup(self, userID=None, request=None):
|
||||
try:
|
||||
|
|
@ -356,32 +343,23 @@ class BackupManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def restoreSite(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
path = os.path.join("/home", "backup")
|
||||
if not os.path.exists(path):
|
||||
proc = httpProc(request, 'backup/restore.html', 'restoreBackup')
|
||||
return proc.render()
|
||||
else:
|
||||
all_files = []
|
||||
ext = ".tar.gz"
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'restoreBackup') == 0:
|
||||
return ACLManager.loadError()
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
|
||||
ACLManager.executeCall(command)
|
||||
|
||||
path = os.path.join("/home", "backup")
|
||||
|
||||
if not os.path.exists(path):
|
||||
return render(request, 'backup/restore.html')
|
||||
else:
|
||||
all_files = []
|
||||
ext = ".tar.gz"
|
||||
|
||||
command = 'sudo chown -R cyberpanel:cyberpanel ' + path
|
||||
ACLManager.executeCall(command)
|
||||
|
||||
files = os.listdir(path)
|
||||
for filename in files:
|
||||
if filename.endswith(ext):
|
||||
all_files.append(filename)
|
||||
|
||||
return render(request, 'backup/restore.html', {'backups': all_files})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
files = os.listdir(path)
|
||||
for filename in files:
|
||||
if filename.endswith(ext):
|
||||
all_files.append(filename)
|
||||
proc = httpProc(request, 'backup/restore.html', {'backups': all_files}, 'restoreBackup')
|
||||
return proc.render()
|
||||
|
||||
def getCurrentBackups(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
@ -695,16 +673,8 @@ class BackupManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def backupDestinations(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteDestinations') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'backup/backupDestinations.html', {})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'backup/backupDestinations.html', {}, 'addDeleteDestinations')
|
||||
return proc.render()
|
||||
|
||||
def submitDestinationCreation(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
@ -868,25 +838,15 @@ class BackupManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def scheduleBackup(self, request, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'scheDuleBackups') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
destinations = NormalBackupDests.objects.all()
|
||||
|
||||
dests = []
|
||||
|
||||
for dest in destinations:
|
||||
dests.append(dest.name)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'backup/backupSchedule.html', {'destinations': dests, 'websites': websitesName})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
destinations = NormalBackupDests.objects.all()
|
||||
dests = []
|
||||
for dest in destinations:
|
||||
dests.append(dest.name)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(request, 'backup/backupSchedule.html', {'destinations': dests, 'websites': websitesName},
|
||||
'scheDuleBackups')
|
||||
return proc.render()
|
||||
|
||||
def getCurrentBackupSchedules(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
@ -1009,16 +969,8 @@ class BackupManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def remoteBackups(self, request, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'remoteBackups') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'backup/remoteBackups.html')
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'backup/remoteBackups.html', 'remoteBackups')
|
||||
return proc.render()
|
||||
|
||||
def submitRemoteBackups(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
@ -1371,25 +1323,12 @@ class BackupManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def backupLogs(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
all_files = []
|
||||
|
||||
logFiles = BackupJob.objects.all().order_by('-id')
|
||||
|
||||
for logFile in logFiles:
|
||||
all_files.append(logFile.logFile)
|
||||
|
||||
return render(request, 'backup/backupLogs.html', {'backups': all_files})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
all_files = []
|
||||
logFiles = BackupJob.objects.all().order_by('-id')
|
||||
for logFile in logFiles:
|
||||
all_files.append(logFile.logFile)
|
||||
proc = httpProc(request, 'backup/backupLogs.html', {'backups': all_files}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchLogs(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,21 @@
|
|||
|
||||
app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".destinationHide").hide();
|
||||
$('#create-backup-select').select2();
|
||||
});
|
||||
|
||||
$('#create-backup-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.websiteToBeBacked = data.text;
|
||||
$(".destinationHide").show();
|
||||
getBackupStatus();
|
||||
populateCurrentRecords();
|
||||
$scope.destination = false;
|
||||
$scope.runningBackup = true;
|
||||
});
|
||||
|
||||
$scope.destination = true;
|
||||
$scope.backupButton = true;
|
||||
$scope.backupLoading = true;
|
||||
|
|
@ -43,7 +58,6 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
function getBackupStatus() {
|
||||
|
||||
$scope.backupLoadingBottom = false;
|
||||
|
|
@ -111,12 +125,10 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.destinationSelection = function () {
|
||||
$scope.backupButton = false;
|
||||
};
|
||||
|
||||
|
||||
function populateCurrentRecords() {
|
||||
|
||||
var websiteToBeBacked = $scope.websiteToBeBacked;
|
||||
|
|
@ -152,7 +164,6 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.createBackup = function () {
|
||||
|
||||
var websiteToBeBacked = $scope.websiteToBeBacked;
|
||||
|
|
@ -189,10 +200,8 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.deleteBackup = function (id) {
|
||||
|
||||
|
||||
url = "/backup/deleteBackup";
|
||||
|
||||
var data = {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchDetails()" ng-model="websiteToBeBacked" class="form-control">
|
||||
<select id="create-backup-select" ng-model="websiteToBeBacked" class="form-control">
|
||||
{% for items in websiteList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="destination" class="form-group">
|
||||
<div class="form-group destinationHide">
|
||||
<label class="col-sm-3 control-label">{% trans "Destination" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="destinationSelection()" ng-model="backupDestinations" class="form-control">
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
<!---- if Back up is running------>
|
||||
|
||||
<div ng-hide="backupButton" class="form-group">
|
||||
<div class="form-group destinationHide">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createBackup()" class="btn btn-primary btn-lg btn-block">{% trans "Create Back up" %}</button>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -98,6 +98,23 @@ app.filter('getwebsitename', function () {
|
|||
};
|
||||
});
|
||||
|
||||
function getWebsiteName(domain){
|
||||
if (domain !== undefined) {
|
||||
|
||||
domain = domain.replace(/-/g, '');
|
||||
|
||||
var domainName = domain.split(".");
|
||||
|
||||
var finalDomainName = domainName[0];
|
||||
|
||||
if (finalDomainName.length > 5) {
|
||||
finalDomainName = finalDomainName.substring(0, 4);
|
||||
}
|
||||
|
||||
return finalDomainName;
|
||||
}
|
||||
}
|
||||
|
||||
app.controller('systemStatusInfo', function ($scope, $http, $timeout) {
|
||||
|
||||
//getStuff();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Home - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Home" %}</h2>
|
||||
<p>{% trans "Use the tabs to navigate through the control panel." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<!--- Hide statistics for non-admins--->
|
||||
|
||||
<div class="mx-10 col-lg-9 panel col-md-push-50">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Something went wrong..." %}
|
||||
</h3>
|
||||
|
||||
<div class="example-box-wrapper mt-5">
|
||||
<div class="alert alert-danger">
|
||||
<h4 class="alert-title">Error</h4>
|
||||
<p>Error: {{ error_message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -4,29 +4,28 @@
|
|||
{% block content %}
|
||||
|
||||
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Home" %}</h2>
|
||||
<p>{% trans "Use the tabs to navigate through the control panel." %}</p>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Home" %}</h2>
|
||||
<p>{% trans "Use the tabs to navigate through the control panel." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<!--- Hide statistics for non-admins--->
|
||||
<div class="mx-10 col-lg-9 panel col-md-push-50">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Available Functions" %}
|
||||
</h3>
|
||||
|
||||
<!--- Hide statistics for non-admins--->
|
||||
|
||||
<div class="mx-10 col-lg-9 panel col-md-push-50">
|
||||
<div class="panel-body">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Available Functions" %}
|
||||
</h3>
|
||||
|
||||
<div class="example-box-wrapper mt-5">
|
||||
<div class="row mx-5">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadUsersHome' %}" title="{% trans 'User Functions' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="example-box-wrapper mt-5">
|
||||
<div class="row mx-5">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadUsersHome' %}" title="{% trans 'User Functions' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Users" %}
|
||||
</div>
|
||||
|
|
@ -34,10 +33,11 @@
|
|||
<i class="fa fa-users"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Website Functions' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadWebsitesHome' %}" title="{% trans 'Website Functions' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Websites" %}
|
||||
</div>
|
||||
|
|
@ -47,8 +47,9 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'packagesHome' %}" title="{% trans 'Add/Modify Packages' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'packagesHome' %}" title="{% trans 'Add/Modify Packages' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Packages" %}
|
||||
</div>
|
||||
|
|
@ -56,10 +57,11 @@
|
|||
<i class="fa fa-cubes"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadDatabaseHome' %}" title="{% trans 'Database Functions' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadDatabaseHome' %}" title="{% trans 'Database Functions' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Databases" %}
|
||||
</div>
|
||||
|
|
@ -67,10 +69,11 @@
|
|||
<i class="fa fa-database"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'dnsHome' %}" title="{% trans 'Control DNS' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'dnsHome' %}" title="{% trans 'Control DNS' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "DNS" %}
|
||||
</div>
|
||||
|
|
@ -78,10 +81,11 @@
|
|||
<i class="fa fa-sitemap"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadFTPHome' %}" title="{% trans 'FTP Functions' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadFTPHome' %}" title="{% trans 'FTP Functions' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "FTP" %}
|
||||
</div>
|
||||
|
|
@ -91,8 +95,9 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadBackupHome' %}" title="{% trans 'Back up' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadBackupHome' %}" title="{% trans 'Back up' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Back up" %}
|
||||
</div>
|
||||
|
|
@ -100,171 +105,175 @@
|
|||
<i class="fa fa-clone"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Emails' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadEmailHome' %}" title="{% trans 'Emails' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Emails" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-envelope"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadSSLHome' %}" title="{% trans 'SSL' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "SSL" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-expeditedssl"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% if admin %}
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'serverStatusHome' %}" title="{% trans 'Server Status' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Emails" %}
|
||||
{% trans "Status" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-envelope"></i>
|
||||
<i class="fa fa-server"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadSSLHome' %}" title="{% trans 'SSL' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP Configurations' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "SSL" %}
|
||||
{% trans "PHP" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-expeditedssl"></i>
|
||||
<i class="fa fa-code"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if admin %}
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'logsHome' %}" title="{% trans 'Logs' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-file"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'serverStatusHome' %}" title="{% trans 'Server Status' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Status" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-server"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'securityHome' %}" title="{% trans 'Security' %}"
|
||||
class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Security" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-shield"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'loadPHPHome' %}" title="{% trans 'PHP Configurations' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "PHP" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-code"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'logsHome' %}" title="{% trans 'Logs' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Logs" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-file"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<a href="{% url 'securityHome' %}" title="{% trans 'Security' %}" class="tile-box tile-box-shortcut btn-primary">
|
||||
<div class="tile-header">
|
||||
{% trans "Security" %}
|
||||
</div>
|
||||
<div class="tile-content-wrapper">
|
||||
<i class="fa fa-shield"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% if admin %}
|
||||
<div ng-controller="homePageStatus" class="">
|
||||
<div class="mx-10 col-md-2 panel panel-body col-md-pull-50">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Resources" %}
|
||||
</h3>
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div class="row mx-5">
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "CPU Usage" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="redcircle" class="c100 red cpu">
|
||||
<span>{$ cpuUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "Ram Usage" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="greencircle" class="c100 p0 green ram">
|
||||
<span>{$ ramUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "Disk Usage '/'" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="pinkcircle" class="c100 pink disk">
|
||||
<span>{$ diskUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if admin %}
|
||||
<div ng-controller="homePageStatus" class="">
|
||||
<div class="mx-10 col-md-2 panel panel-body col-md-pull-50">
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Resources" %}
|
||||
</h3>
|
||||
|
||||
<div class="example-box-wrapper">
|
||||
|
||||
<div class="row mx-5">
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "CPU Usage" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="redcircle" class="c100 red cpu">
|
||||
<span>{$ cpuUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "Ram Usage" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="greencircle" class="c100 p0 green ram">
|
||||
<span>{$ ramUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<div class="mb-10">
|
||||
<h3 class="title-hero clearfix text-center text-muted">
|
||||
{% trans "Disk Usage '/'" %}
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row flex">
|
||||
<div class="align-center">
|
||||
<div id="pinkcircle" class="c100 pink disk">
|
||||
<span>{$ diskUsage $}%</span>
|
||||
<div class="slice">
|
||||
<div class="bar"></div>
|
||||
<div class="fill"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from django.http import HttpResponse
|
||||
from plogical.getSystemInformation import SystemInformation
|
||||
|
|
@ -16,29 +14,20 @@ from plogical.acl import ACLManager
|
|||
from manageServices.models import PDNSStatus
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.httpProc import httpProc
|
||||
# Create your views here.
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
@ensure_csrf_cookie
|
||||
def renderBase(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
admin = 1
|
||||
else:
|
||||
admin = 0
|
||||
|
||||
cpuRamDisk = SystemInformation.cpuRamDisk()
|
||||
|
||||
finaData = {"admin": admin,'ramUsage':cpuRamDisk['ramUsage'],'cpuUsage':cpuRamDisk['cpuUsage'],'diskUsage':cpuRamDisk['diskUsage'] }
|
||||
|
||||
return render(request, 'baseTemplate/homePage.html', finaData)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
template = 'baseTemplate/homePage.html'
|
||||
cpuRamDisk = SystemInformation.cpuRamDisk()
|
||||
finaData = {'ramUsage': cpuRamDisk['ramUsage'], 'cpuUsage': cpuRamDisk['cpuUsage'],
|
||||
'diskUsage': cpuRamDisk['diskUsage']}
|
||||
proc = httpProc(request, template, finaData)
|
||||
return proc.render()
|
||||
|
||||
def getAdminStatus(request):
|
||||
try:
|
||||
|
|
@ -77,7 +66,6 @@ def getAdminStatus(request):
|
|||
|
||||
def getSystemStatus(request):
|
||||
try:
|
||||
|
||||
HTTPData = SystemInformation.getSystemInformation()
|
||||
json_data = json.dumps(HTTPData)
|
||||
return HttpResponse(json_data)
|
||||
|
|
@ -90,47 +78,30 @@ def getLoadAverage(request):
|
|||
one = loadAverage[0]
|
||||
two = loadAverage[1]
|
||||
three = loadAverage[2]
|
||||
|
||||
loadAvg = {"one": one, "two": two,"three": three}
|
||||
|
||||
json_data = json.dumps(loadAvg)
|
||||
|
||||
return HttpResponse(json_data)
|
||||
|
||||
@ensure_csrf_cookie
|
||||
def versionManagment(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
## Get latest version
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['versionManagement'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
||||
latest = getVersion.json()
|
||||
latestVersion = latest['version']
|
||||
latestBuild = latest['build']
|
||||
|
||||
## Get latest version
|
||||
## Get local version
|
||||
|
||||
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
||||
currentVersion = VERSION
|
||||
currentBuild = str(BUILD)
|
||||
|
||||
latest = getVersion.json()
|
||||
template = 'baseTemplate/versionManagment.html'
|
||||
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,
|
||||
'latestBuild': latestBuild}
|
||||
|
||||
latestVersion = latest['version']
|
||||
latestBuild = latest['build']
|
||||
|
||||
## Get local version
|
||||
|
||||
currentVersion = VERSION
|
||||
currentBuild = str(BUILD)
|
||||
|
||||
return render(request, 'baseTemplate/versionManagment.html', {'build': currentBuild,
|
||||
'currentVersion': currentVersion,
|
||||
'latestVersion': latestVersion,
|
||||
'latestBuild': latestBuild})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, template, finalData, 'versionManagement')
|
||||
return proc.render()
|
||||
|
||||
def upgrade(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class cliParser:
|
|||
parser.add_argument('--dkim', help='DKIM Signing')
|
||||
parser.add_argument('--openBasedir', help='To enable or disable open_basedir protection for domain.')
|
||||
parser.add_argument('--fileName', help='Complete path to a file that needs to be restored.')
|
||||
parser.add_argument('--backupPath', help='Backup path to use when generating a backup.')
|
||||
|
||||
## Package Arguments.
|
||||
|
||||
|
|
@ -69,4 +70,4 @@ class cliParser:
|
|||
parser.add_argument('--siteTitle', help='Site Title for application installers.')
|
||||
parser.add_argument('--path', help='Path for application installers.')
|
||||
|
||||
return parser.parse_args()
|
||||
return parser.parse_args()
|
||||
|
|
|
|||
|
|
@ -333,13 +333,22 @@ class cyberPanel:
|
|||
|
||||
## Backup Functions
|
||||
|
||||
def createBackup(self, virtualHostName):
|
||||
def createBackup(self, virtualHostName, backupPath=None):
|
||||
try:
|
||||
backupLogPath = "/usr/local/lscp/logs/backup_log."+time.strftime("%I-%M-%S-%a-%b-%Y")
|
||||
# Setup default backup path to /home/<domain name>/backup if not passed in
|
||||
if backupPath is None:
|
||||
backupPath = '/home/' + virtualHostName + '/backup'
|
||||
|
||||
# remove trailing slash in path
|
||||
backupPath = backupPath.rstrip("/")
|
||||
backuptime = time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
backupLogPath = "/usr/local/lscp/logs/backup_log." + backuptime
|
||||
|
||||
print('Backup logs to be generated in %s' % (backupLogPath))
|
||||
|
||||
backupSchedule.createLocalBackup(virtualHostName, backupLogPath)
|
||||
tempStoragePath = backupPath + '/backup-' + virtualHostName + '-' + backuptime
|
||||
backupName = 'backup-' + virtualHostName + '-' + backuptime
|
||||
backupDomain = virtualHostName
|
||||
backupUtilities.submitBackupCreation(tempStoragePath, backupName, backupPath, backupDomain)
|
||||
|
||||
except BaseException as msg:
|
||||
logger.writeforCLI(str(msg), "Error", stack()[0][3])
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.db import models
|
||||
|
||||
from websiteFunctions.models import Websites
|
||||
# Create your models here.
|
||||
class WPDeployments(models.Model):
|
||||
owner = models.ForeignKey(Websites, on_delete=models.CASCADE)
|
||||
config = models.TextField()
|
||||
|
|
@ -14,10 +14,14 @@ def router(request):
|
|||
controller = data['controller']
|
||||
|
||||
serverUserName = data['serverUserName']
|
||||
|
||||
admin = Administrator.objects.get(userName=serverUserName)
|
||||
|
||||
cm = CloudManager(data, admin)
|
||||
|
||||
if serverUserName != 'admin':
|
||||
return cm.ajaxPre(0, 'Only administrator can access API.')
|
||||
|
||||
if admin.api == 0:
|
||||
return cm.ajaxPre(0, 'API Access Disabled.')
|
||||
|
||||
|
|
@ -63,6 +67,38 @@ def router(request):
|
|||
return cm.deleteCloudBackup()
|
||||
elif controller == 'SubmitCloudBackupRestore':
|
||||
return cm.SubmitCloudBackupRestore()
|
||||
elif controller == 'DeployWordPress':
|
||||
return cm.DeployWordPress()
|
||||
elif controller == 'FetchWordPressDetails':
|
||||
return cm.FetchWordPressDetails()
|
||||
elif controller == 'AutoLogin':
|
||||
return cm.AutoLogin()
|
||||
elif controller == 'DeletePlugins':
|
||||
return cm.DeletePlugins()
|
||||
elif controller == 'GetCurrentThemes':
|
||||
return cm.GetCurrentThemes()
|
||||
elif controller == 'UpdateThemes':
|
||||
return cm.UpdateThemes()
|
||||
elif controller == 'ChangeStateThemes':
|
||||
return cm.ChangeStateThemes()
|
||||
elif controller == 'DeleteThemes':
|
||||
return cm.DeleteThemes()
|
||||
elif controller == 'GetServerPublicSSHkey':
|
||||
return cm.GetServerPublicSSHkey()
|
||||
elif controller == 'SubmitPublicKey':
|
||||
return cm.SubmitPublicKey()
|
||||
elif controller == 'UpdateWPSettings':
|
||||
return cm.UpdateWPSettings()
|
||||
elif controller == 'GetCurrentPlugins':
|
||||
return cm.GetCurrentPlugins()
|
||||
elif controller == 'UpdatePlugins':
|
||||
return cm.UpdatePlugins()
|
||||
elif controller == 'ChangeState':
|
||||
return cm.ChangeState()
|
||||
elif controller == 'saveWPSettings':
|
||||
return cm.saveWPSettings()
|
||||
elif controller == 'WPScan':
|
||||
return cm.WPScan()
|
||||
elif controller == 'getCurrentS3Backups':
|
||||
return cm.getCurrentS3Backups()
|
||||
elif controller == 'deleteS3Backup':
|
||||
|
|
@ -205,6 +241,16 @@ def router(request):
|
|||
return cm.getLogsFromFile(request)
|
||||
elif controller == 'serverSSL':
|
||||
return cm.serverSSL(request)
|
||||
elif controller == 'CreateStaging':
|
||||
return cm.CreateStaging(request)
|
||||
elif controller == 'startSync':
|
||||
return cm.startSync(request)
|
||||
elif controller == 'SaveAutoUpdateSettings':
|
||||
return cm.SaveAutoUpdateSettings()
|
||||
elif controller == 'fetchWPSettings':
|
||||
return cm.fetchWPSettings()
|
||||
elif controller == 'updateWPCLI':
|
||||
return cm.updateWPCLI()
|
||||
elif controller == 'setupNode':
|
||||
return cm.setupManager(request)
|
||||
elif controller == 'fetchManagerTokens':
|
||||
|
|
@ -348,7 +394,6 @@ def router(request):
|
|||
cm = CloudManager(None)
|
||||
return cm.ajaxPre(0, str(msg))
|
||||
|
||||
@csrf_exempt
|
||||
def access(request):
|
||||
try:
|
||||
serverUserName = request.GET.get('serverUserName')
|
||||
|
|
@ -361,6 +406,10 @@ def access(request):
|
|||
return HttpResponse('API Access Disabled.')
|
||||
|
||||
if token == admin.token.lstrip('Basic ').rstrip('='):
|
||||
try:
|
||||
del request.session['userID']
|
||||
except:
|
||||
pass
|
||||
request.session['userID'] = admin.pk
|
||||
from django.shortcuts import redirect
|
||||
from baseTemplate.views import renderBase
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
from django.shortcuts import render
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import threading as multi
|
||||
from plogical.acl import ACLManager
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
import os, stat
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
class ContainerManager(multi.Thread):
|
||||
defaultConf = """group {groupName}{
|
||||
|
|
@ -84,14 +83,6 @@ class ContainerManager(multi.Thread):
|
|||
|
||||
def renderC(self):
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
data = {}
|
||||
data['OLS'] = 0
|
||||
data['notInstalled'] = 0
|
||||
|
|
@ -99,17 +90,20 @@ class ContainerManager(multi.Thread):
|
|||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
data['OLS'] = 1
|
||||
data['notInstalled'] = 0
|
||||
return render(self.request, 'containerization/notAvailable.html', data)
|
||||
proc = httpProc(self.request, 'containerization/notAvailable.html', data, 'admin')
|
||||
return proc.render()
|
||||
elif not ProcessUtilities.containerCheck():
|
||||
data['OLS'] = 0
|
||||
data['notInstalled'] = 1
|
||||
return render(self.request, 'containerization/notAvailable.html', data)
|
||||
proc = httpProc(self.request, 'containerization/notAvailable.html', data, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
if self.data == None:
|
||||
self.data = {}
|
||||
self.data['OLS'] = 0
|
||||
self.data['notInstalled'] = 0
|
||||
return render(self.request, self.templateName, self.data)
|
||||
proc = httpProc(self.request, self.templateName, data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def submitContainerInstall(self):
|
||||
try:
|
||||
|
|
@ -165,7 +159,6 @@ class ContainerManager(multi.Thread):
|
|||
# self.data['classID']) + ' protocol ip prio 10 handle 1: cgroup'
|
||||
|
||||
command = 'sudo tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1: cgroup'
|
||||
#logging.CyberCPLogFileWriter.writeToFile(command)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
self.restartServices()
|
||||
|
|
|
|||
3246
cyberpanel.sh
3246
cyberpanel.sh
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -5,7 +5,6 @@ import django
|
|||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
from plogical.acl import ACLManager
|
||||
|
|
@ -16,34 +15,28 @@ from databases.models import Databases, DBMeta
|
|||
import argparse
|
||||
from loginSystem.models import Administrator
|
||||
import plogical.randomPassword as randomPassword
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
class DatabaseManager:
|
||||
|
||||
REMOTE_ACCESS = 'remote_access'
|
||||
|
||||
def loadDatabaseHome(self, request = None, userID = None):
|
||||
try:
|
||||
return render(request, 'databases/index.html')
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'databases/index.html'
|
||||
proc = httpProc(request, template, None, 'createDatabase')
|
||||
return proc.render()
|
||||
|
||||
def phpMyAdmin(self, request = None, userID = None):
|
||||
try:
|
||||
return render(request, 'databases/phpMyAdmin.html')
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'databases/phpMyAdmin.html'
|
||||
proc = httpProc(request, template, None, 'createDatabase')
|
||||
return proc.render()
|
||||
|
||||
def createDatabase(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'createDatabase') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'databases/createDatabase.html', {'websitesList': websitesName})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
template = 'databases/createDatabase.html'
|
||||
proc = httpProc(request, template, {'websitesList': websitesName}, 'createDatabase')
|
||||
return proc.render()
|
||||
|
||||
def submitDBCreation(self, userID = None, data = None, rAPI = None):
|
||||
try:
|
||||
|
|
@ -84,18 +77,11 @@ class DatabaseManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def deleteDatabase(self, request = None, userID = None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteDatabase') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'databases/deleteDatabase.html', {'websitesList': websitesName})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
template = 'databases/deleteDatabase.html'
|
||||
proc = httpProc(request, template, {'websitesList': websitesName}, 'deleteDatabase')
|
||||
return proc.render()
|
||||
|
||||
def fetchDatabases(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -171,16 +157,11 @@ class DatabaseManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def listDBs(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'databases/listDataBases.html', {'websiteList': websitesName})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
AllWebsites = ACLManager.findAllSites(currentACL, userID)
|
||||
template = 'databases/listDataBases.html'
|
||||
proc = httpProc(request, template, {'AllWebsites': AllWebsites}, 'listDatabases')
|
||||
return proc.render()
|
||||
|
||||
def changePassword(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -6,25 +6,31 @@
|
|||
/* Java script code to create database */
|
||||
app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.generatedPasswordView = true;
|
||||
$(document).ready(function () {
|
||||
$(".dbDetails").hide();
|
||||
$(".generatedPasswordDetails").hide();
|
||||
$('#create-database-select').select2();
|
||||
});
|
||||
|
||||
$('#create-database-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.databaseWebsite = data.text;
|
||||
$(".dbDetails").show();
|
||||
$("#domainDatabase").text(getWebsiteName(data.text));
|
||||
$("#domainUsername").text(getWebsiteName(data.text));
|
||||
});
|
||||
|
||||
|
||||
$scope.showDetailsBoxes = function () {
|
||||
$scope.dbDetails = false;
|
||||
};
|
||||
}
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
|
||||
$scope.createDatabase = function () {
|
||||
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
|
@ -65,26 +71,24 @@ app.controller('createDatabase', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.createDBStatus == 1) {
|
||||
if (response.data.createDBStatus === 1) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Database successfully created.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -96,21 +100,23 @@ app.controller('createDatabase', function ($scope, $http) {
|
|||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$(".generatedPasswordDetails").show();
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
$(".generatedPasswordDetails").hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -170,9 +176,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
|
|||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
|
|
@ -240,9 +244,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
|
|||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
|
|
@ -344,8 +346,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
|
|
@ -411,8 +412,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
|
|
@ -481,8 +481,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
|
||||
$scope.dbHost = response.data.dbHost;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
|
|
@ -537,8 +536,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
type: 'success'
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
|
|
@ -570,7 +568,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
|
||||
$scope.generateAccess = function() {
|
||||
$scope.generateAccess = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
|
|
@ -593,12 +591,14 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
|||
if (response.data.status === 1) {
|
||||
var rUrl = '/phpmyadmin/phpmyadminsignin.php?username=' + response.data.username + '&token=' + response.data.token;
|
||||
$window.location.href = rUrl;
|
||||
} else {
|
||||
}
|
||||
else {}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {$scope.cyberPanelLoading = true;}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="showDetailsBoxes()" ng-model="databaseWebsite" class="form-control">
|
||||
<select id="create-database-select" ng-model="databaseWebsite" class="form-control">
|
||||
{% for items in websitesList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
|
|
@ -35,24 +35,23 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<div ng-hide="dbDetails" class="form-group">
|
||||
<div class="form-group dbDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "Database Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="dom" type="text" class="form-control" ng-model="dbName" required>
|
||||
</div>
|
||||
<div class="current-pack">{$databaseWebsite|getwebsitename$}_{$ dbName $}</div>
|
||||
<div class="current-pack"><span id="domainDatabase"></span>_{$ dbName $}</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="dbDetails" class="form-group">
|
||||
<div class="form-group dbDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "User Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="email" class="form-control" ng-model="dbUsername" required>
|
||||
</div>
|
||||
<div class="current-pack">{$databaseWebsite|getwebsitename$}_{$ dbUsername $}</div>
|
||||
<div class="current-pack"><span id="domainUsername"></span>_{$ dbUsername $}</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="dbDetails" class="form-group">
|
||||
<div class="form-group dbDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" name="email" class="form-control" ng-model="dbPassword" required>
|
||||
|
|
@ -62,7 +61,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="generatedPasswordView" class="form-group">
|
||||
<div class="form-group generatedPasswordDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="email" class="form-control" ng-model="dbPassword" required>
|
||||
|
|
@ -73,37 +72,13 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div ng-hide="dbDetails" class="form-group">
|
||||
<div class="form-group dbDetails">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createDatabase()" class="btn btn-primary btn-lg">{% trans "Create Database" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<div ng-hide="databaseCreationFailed" class="alert alert-danger">
|
||||
<p>{% trans "Cannot create database. Error message:" %} {$ errorMessage $}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="databaseCreated" class="alert alert-success">
|
||||
<p>{% trans "Database created successfully." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
||||
<p>{% trans "Could not connect to server. Please refresh this page." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<label class="col-sm-3 control-label">{% trans "Select Domain" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="fetchDBs()" ng-model="selectedDomain" class="form-control">
|
||||
{% for items in websiteList %}
|
||||
{% for items in AllWebsites %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import errno
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
try:
|
||||
|
|
@ -24,6 +24,7 @@ import CloudFlare
|
|||
import re
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
class DNSManager:
|
||||
defaultNameServersPath = '/home/cyberpanel/defaultNameservers'
|
||||
|
|
@ -37,29 +38,23 @@ class DNSManager:
|
|||
self.email = data[0].rstrip('\n')
|
||||
self.key = data[1].rstrip('\n')
|
||||
|
||||
|
||||
def loadDNSHome(self, request = None, userID = None):
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
return render(request, 'dns/index.html', {"type": admin.type})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
template = 'dns/index.html'
|
||||
proc = httpProc(request, template, {"type": admin.type}, 'createDNSZone')
|
||||
return proc.render()
|
||||
|
||||
def createNameserver(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'createNameServer') == 0:
|
||||
return ACLManager.loadError()
|
||||
mailUtilities.checkHome()
|
||||
|
||||
mailUtilities.checkHome()
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
finalData = {"status": 1}
|
||||
else:
|
||||
finalData = {"status": 0}
|
||||
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, "dns/createNameServer.html", {"status": 1})
|
||||
else:
|
||||
return render(request, "dns/createNameServer.html", {"status": 0})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'dns/createNameServer.html'
|
||||
proc = httpProc(request, template, finalData, 'createNameServer')
|
||||
return proc.render()
|
||||
|
||||
def NSCreation(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -118,17 +113,15 @@ class DNSManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def createDNSZone(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'createDNSZone') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/createDNSZone.html', {"status": 1})
|
||||
else:
|
||||
return render(request, 'dns/createDNSZone.html', {"status": 0})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
if os.path.exists('/home/cyberpanel/powerdns'):
|
||||
finalData = {'status': 1}
|
||||
else:
|
||||
finalData = {'status': 0}
|
||||
|
||||
template = 'dns/createDNSZone.html'
|
||||
proc = httpProc(request, template, finalData, 'createDNSZone')
|
||||
return proc.render()
|
||||
|
||||
def zoneCreation(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -166,21 +159,17 @@ class DNSManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def addDeleteDNSRecords(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteRecords') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
finalData = {"status": 0}
|
||||
else:
|
||||
finalData = {"status": 1}
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
|
||||
|
||||
domainsList = ACLManager.findAllDomains(currentACL, userID)
|
||||
|
||||
return render(request, 'dns/addDeleteDNSRecords.html', {"domainsList": domainsList, "status": 1})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
finalData['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
|
||||
template = 'dns/addDeleteDNSRecords.html'
|
||||
proc = httpProc(request, template, finalData, 'addDeleteRecords')
|
||||
return proc.render()
|
||||
|
||||
def getCurrentRecordsForDomain(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -499,22 +488,16 @@ class DNSManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def deleteDNSZone(self, request = None, userID = None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
finalData = {"status": 0}
|
||||
else:
|
||||
finalData = {"status": 1}
|
||||
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteZone') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
|
||||
|
||||
domainsList = ACLManager.findAllDomains(currentACL, userID)
|
||||
|
||||
return render(request, 'dns/deleteDNSZone.html', {"domainsList": domainsList, "status": 1})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
finalData['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
|
||||
template = 'dns/deleteDNSZone.html'
|
||||
proc = httpProc(request, template, finalData, 'deleteZone')
|
||||
return proc.render()
|
||||
|
||||
def submitZoneDeletion(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -549,46 +532,36 @@ class DNSManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def configureDefaultNameServers(self, request=None, userID=None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
data = {"status": 0}
|
||||
else:
|
||||
data = {"status": 1}
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
data['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
|
||||
if os.path.exists(DNSManager.defaultNameServersPath):
|
||||
nsData = open(DNSManager.defaultNameServersPath, 'r').readlines()
|
||||
try:
|
||||
data['firstNS'] = nsData[0].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['secondNS'] = nsData[1].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['thirdNS'] = nsData[2].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['forthNS'] = nsData[3].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/addDeleteDNSRecords.html', {"status": 0})
|
||||
|
||||
data = {}
|
||||
data['domainsList'] = ACLManager.findAllDomains(currentACL, userID)
|
||||
data['status'] = 1
|
||||
|
||||
if os.path.exists(DNSManager.defaultNameServersPath):
|
||||
nsData = open(DNSManager.defaultNameServersPath, 'r').readlines()
|
||||
try:
|
||||
data['firstNS'] = nsData[0].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['secondNS'] = nsData[1].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['thirdNS'] = nsData[2].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
data['forthNS'] = nsData[3].rstrip('\n')
|
||||
except:
|
||||
pass
|
||||
|
||||
return render(request, 'dns/configureDefaultNameServers.html', data)
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
||||
template = 'dns/configureDefaultNameServers.html'
|
||||
proc = httpProc(request, template, data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def saveNSConfigurations(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -615,7 +588,6 @@ class DNSManager:
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
writeToFile = open(DNSManager.defaultNameServersPath, 'w')
|
||||
writeToFile.write(nsContent.rstrip('\n'))
|
||||
writeToFile.close()
|
||||
|
|
@ -631,35 +603,30 @@ class DNSManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def addDeleteDNSRecordsCloudFlare(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
status = 0
|
||||
else:
|
||||
status = 1
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ACLManager.currentContextPermission(currentACL, 'addDeleteRecords') == 0:
|
||||
return ACLManager.loadError()
|
||||
CloudFlare = 0
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/powerdns'):
|
||||
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html', {"status": 0})
|
||||
cfPath = '%s%s' % (DNS.CFPath, admin.userName)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if os.path.exists(cfPath):
|
||||
CloudFlare = 1
|
||||
domainsList = ACLManager.findAllDomains(currentACL, userID)
|
||||
self.admin = admin
|
||||
self.loadCFKeys()
|
||||
data = {"domainsList": domainsList, "status": status, 'CloudFlare': CloudFlare, 'cfEmail': self.email,
|
||||
'cfToken': self.key}
|
||||
else:
|
||||
data = {"status": status, 'CloudFlare': CloudFlare}
|
||||
|
||||
CloudFlare = 0
|
||||
|
||||
cfPath = '%s%s' %(DNS.CFPath, admin.userName)
|
||||
|
||||
if os.path.exists(cfPath):
|
||||
CloudFlare = 1
|
||||
domainsList = ACLManager.findAllDomains(currentACL, userID)
|
||||
|
||||
self.admin = admin
|
||||
self.loadCFKeys()
|
||||
|
||||
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html',
|
||||
{"domainsList": domainsList, "status": 1, 'CloudFlare': CloudFlare, 'cfEmail': self.email, 'cfToken': self.key})
|
||||
else:
|
||||
return render(request, 'dns/addDeleteDNSRecordsCloudFlare.html', {"status": 1, 'CloudFlare': CloudFlare})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'dns/addDeleteDNSRecordsCloudFlare.html'
|
||||
proc = httpProc(request, template, data, 'addDeleteRecords')
|
||||
return proc.render()
|
||||
|
||||
def saveCFConfigs(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
#!/usr/local/CyberCP/bin/python
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
import mimetypes
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
|
|
@ -25,7 +22,7 @@ import requests
|
|||
from plogical.processUtilities import ProcessUtilities
|
||||
from serverStatus.serverStatusUtil import ServerStatusUtil
|
||||
import threading as multi
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
# Use default socket to connect
|
||||
class ContainerManager(multi.Thread):
|
||||
|
|
@ -39,16 +36,8 @@ class ContainerManager(multi.Thread):
|
|||
self.data = data
|
||||
|
||||
def renderDM(self):
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(self.request, self.templateName, self.data)
|
||||
proc = httpProc(self.request, self.templateName, self.data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
|
|
@ -91,59 +80,54 @@ class ContainerManager(multi.Thread):
|
|||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def createContainer(self, request=None, userID=None, data=None):
|
||||
client = docker.from_env()
|
||||
dockerAPI = docker.APIClient()
|
||||
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
tag = request.GET.get('tag')
|
||||
image = request.GET.get('image')
|
||||
tag = tag.split(" (")[0]
|
||||
|
||||
if "/" in image:
|
||||
name = image.split("/")[0] + "." + image.split("/")[1]
|
||||
else:
|
||||
name = image
|
||||
|
||||
try:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if admin.acl.adminStatus != 1:
|
||||
return ACLManager.loadError()
|
||||
inspectImage = dockerAPI.inspect_image(image + ":" + tag)
|
||||
except docker.errors.ImageNotFound:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
proc = httpProc(request, 'dockerManager/images.html', {"type": admin.type,
|
||||
'image': image,
|
||||
'tag': tag})
|
||||
return proc.render()
|
||||
|
||||
client = docker.from_env()
|
||||
dockerAPI = docker.APIClient()
|
||||
envList = {};
|
||||
if 'Env' in inspectImage['Config']:
|
||||
for item in inspectImage['Config']['Env']:
|
||||
if '=' in item:
|
||||
splitedItem = item.split('=', 1)
|
||||
print(splitedItem)
|
||||
envList[splitedItem[0]] = splitedItem[1]
|
||||
else:
|
||||
envList[item] = ""
|
||||
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
tag = request.GET.get('tag')
|
||||
image = request.GET.get('image')
|
||||
tag = tag.split(" (")[0]
|
||||
portConfig = {};
|
||||
if 'ExposedPorts' in inspectImage['Config']:
|
||||
for item in inspectImage['Config']['ExposedPorts']:
|
||||
portDef = item.split('/')
|
||||
portConfig[portDef[0]] = portDef[1]
|
||||
|
||||
if "/" in image:
|
||||
name = image.split("/")[0] + "." + image.split("/")[1]
|
||||
else:
|
||||
name = image
|
||||
if image is None or image is '' or tag is None or tag is '':
|
||||
return redirect(loadImages)
|
||||
|
||||
try:
|
||||
inspectImage = dockerAPI.inspect_image(image + ":" + tag)
|
||||
except docker.errors.ImageNotFound:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
return render(request, 'dockerManager/images.html', {"type": admin.type,
|
||||
'image': image,
|
||||
'tag': tag})
|
||||
Data = {"ownerList": adminNames, "image": image, "name": name, "tag": tag, "portConfig": portConfig,
|
||||
"envList": envList}
|
||||
|
||||
envList = {};
|
||||
if 'Env' in inspectImage['Config']:
|
||||
for item in inspectImage['Config']['Env']:
|
||||
if '=' in item:
|
||||
splitedItem = item.split('=', 1)
|
||||
print(splitedItem)
|
||||
envList[splitedItem[0]] = splitedItem[1]
|
||||
else:
|
||||
envList[item] = ""
|
||||
|
||||
portConfig = {};
|
||||
if 'ExposedPorts' in inspectImage['Config']:
|
||||
for item in inspectImage['Config']['ExposedPorts']:
|
||||
portDef = item.split('/')
|
||||
portConfig[portDef[0]] = portDef[1]
|
||||
|
||||
if image is None or image is '' or tag is None or tag is '':
|
||||
return redirect(loadImages)
|
||||
|
||||
Data = {"ownerList": adminNames, "image": image, "name": name, "tag": tag, "portConfig": portConfig,
|
||||
"envList": envList}
|
||||
|
||||
return render(request, 'dockerManager/runContainer.html', Data)
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'dockerManager/runContainer.html'
|
||||
proc = httpProc(request, template, Data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def loadContainerHome(self, request=None, userID=None, data=None):
|
||||
name = self.name
|
||||
|
|
@ -196,51 +180,52 @@ class ContainerManager(multi.Thread):
|
|||
data['memoryUsage'] = 0
|
||||
data['cpuUsage'] = 0
|
||||
|
||||
return render(request, 'dockerManager/viewContainer.html', data)
|
||||
template = 'dockerManager/viewContainer.html'
|
||||
proc = httpProc(request, template, data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def listContainers(self, request=None, userID=None, data=None):
|
||||
try:
|
||||
client = docker.from_env()
|
||||
dockerAPI = docker.APIClient()
|
||||
client = docker.from_env()
|
||||
dockerAPI = docker.APIClient()
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
containers = ACLManager.findAllContainers(currentACL, userID)
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
containers = ACLManager.findAllContainers(currentACL, userID)
|
||||
|
||||
allContainers = client.containers.list()
|
||||
containersList = []
|
||||
showUnlistedContainer = True
|
||||
allContainers = client.containers.list()
|
||||
containersList = []
|
||||
showUnlistedContainer = True
|
||||
|
||||
# TODO: Add condition to show unlisted Containers only if user has admin level access
|
||||
# TODO: Add condition to show unlisted Containers only if user has admin level access
|
||||
|
||||
unlistedContainers = []
|
||||
for container in allContainers:
|
||||
if container.name not in containers:
|
||||
unlistedContainers.append(container)
|
||||
unlistedContainers = []
|
||||
for container in allContainers:
|
||||
if container.name not in containers:
|
||||
unlistedContainers.append(container)
|
||||
|
||||
if not unlistedContainers:
|
||||
showUnlistedContainer = False
|
||||
if not unlistedContainers:
|
||||
showUnlistedContainer = False
|
||||
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
adminNames = ACLManager.loadAllUsers(userID)
|
||||
|
||||
pages = float(len(containers)) / float(10)
|
||||
pagination = []
|
||||
pages = float(len(containers)) / float(10)
|
||||
pagination = []
|
||||
|
||||
if pages <= 1.0:
|
||||
pages = 1
|
||||
pagination.append('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
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>')
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
return render(request, 'dockerManager/listContainers.html', {"pagination": pagination,
|
||||
"unlistedContainers": unlistedContainers,
|
||||
"adminNames": adminNames,
|
||||
"showUnlistedContainer": showUnlistedContainer})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
template = 'dockerManager/listContainers.html'
|
||||
proc = httpProc(request, template, {"pagination": pagination,
|
||||
"unlistedContainers": unlistedContainers,
|
||||
"adminNames": adminNames,
|
||||
"showUnlistedContainer": showUnlistedContainer}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getContainerLogs(self, userID=None, data=None):
|
||||
try:
|
||||
|
|
@ -774,7 +759,9 @@ class ContainerManager(multi.Thread):
|
|||
except:
|
||||
continue
|
||||
|
||||
return render(request, 'dockerManager/images.html', {"images": images, "test": ''})
|
||||
template = 'dockerManager/images.html'
|
||||
proc = httpProc(request, template, {"images": images, "test": ''}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
|
@ -808,7 +795,9 @@ class ContainerManager(multi.Thread):
|
|||
except:
|
||||
continue
|
||||
|
||||
return render(request, 'dockerManager/manageImages.html', {"images": images})
|
||||
template = 'dockerManager/manageImages.html'
|
||||
proc = httpProc(request, template, {"images": images}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render, redirect, HttpResponse
|
||||
from django.shortcuts import redirect, HttpResponse
|
||||
from loginSystem.models import Administrator
|
||||
from loginSystem.views import loadLoginPage
|
||||
from plogical.httpProc import httpProc
|
||||
from .container import ContainerManager
|
||||
from .decorators import preDockerRun
|
||||
from plogical.acl import ACLManager
|
||||
|
|
@ -25,15 +26,11 @@ def dockerPermission(request, userID, context):
|
|||
|
||||
@preDockerRun
|
||||
def loadDockerHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
perm = dockerPermission(request, userID, 'loadDockerHome')
|
||||
if perm: return perm
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
return render(request,'dockerManager/index.html',{"type":admin.type})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
userID = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
template = 'dockerManager/index.html'
|
||||
proc = httpProc(request, template, {"type": admin.type}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def installDocker(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from loginSystem.views import loadLoginPage
|
|||
import json
|
||||
from random import randint
|
||||
import time
|
||||
from plogical.httpProc import httpProc
|
||||
from .models import EmailMarketing, EmailLists, EmailsInList, EmailJobs
|
||||
from websiteFunctions.models import Websites
|
||||
from .emailMarketing import emailMarketing as EM
|
||||
|
|
@ -12,7 +13,6 @@ import smtplib
|
|||
from .models import SMTPHosts, EmailTemplate
|
||||
from loginSystem.models import Administrator
|
||||
from .emACL import emACL
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
|
||||
class EmailMarketingManager:
|
||||
|
||||
|
|
@ -21,18 +21,8 @@ class EmailMarketingManager:
|
|||
self.domain = domain
|
||||
|
||||
def emailMarketing(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(self.request, 'emailMarketing/emailMarketing.html')
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'emailMarketing/emailMarketing.html', None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchUsers(self):
|
||||
try:
|
||||
|
|
@ -123,7 +113,8 @@ class EmailMarketingManager:
|
|||
if emACL.checkIfEMEnabled(admin.userName) == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(self.request, 'emailMarketing/createEmailList.html', {'domain': self.domain})
|
||||
proc = httpProc(self.request, 'emailMarketing/createEmailList.html', {'domain': self.domain})
|
||||
return proc.render()
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -168,6 +159,7 @@ class EmailMarketingManager:
|
|||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
|
|
@ -178,12 +170,15 @@ class EmailMarketingManager:
|
|||
|
||||
listNames = emACL.getEmailsLists(self.domain)
|
||||
|
||||
return render(self.request, 'emailMarketing/manageLists.html', {'listNames': listNames, 'domain': self.domain})
|
||||
proc = httpProc(self.request, 'emailMarketing/manageLists.html', {'listNames': listNames, 'domain': self.domain})
|
||||
return proc.render()
|
||||
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def configureVerify(self):
|
||||
try:
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
|
@ -196,7 +191,10 @@ class EmailMarketingManager:
|
|||
if emACL.checkIfEMEnabled(admin.userName) == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(self.request, 'emailMarketing/configureVerify.html', {'domain': self.domain})
|
||||
proc = httpProc(self.request, 'emailMarketing/configureVerify.html',
|
||||
{'domain': self.domain})
|
||||
return proc.render()
|
||||
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -490,7 +488,10 @@ class EmailMarketingManager:
|
|||
|
||||
for items in emailLists:
|
||||
listNames.append(items.listName)
|
||||
return render(self.request, 'emailMarketing/manageSMTPHosts.html', {'listNames': listNames, 'domain': self.domain})
|
||||
|
||||
proc = httpProc(self.request, 'emailMarketing/manageSMTPHosts.html',
|
||||
{'listNames': listNames, 'domain': self.domain})
|
||||
return proc.render()
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -657,7 +658,9 @@ class EmailMarketingManager:
|
|||
if emACL.checkIfEMEnabled(admin.userName) == 0:
|
||||
return ACLManager.loadErrorJson()
|
||||
|
||||
return render(self.request, 'emailMarketing/composeMessages.html')
|
||||
proc = httpProc(self.request, 'emailMarketing/composeMessages.html',
|
||||
None)
|
||||
return proc.render()
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -709,7 +712,11 @@ class EmailMarketingManager:
|
|||
Data['templateNames'] = templateNames
|
||||
Data['hostNames'] = hostNames
|
||||
Data['listNames'] = listNames
|
||||
return render(self.request, 'emailMarketing/sendEmails.html', Data)
|
||||
|
||||
proc = httpProc(self.request, 'emailMarketing/sendEmails.html',
|
||||
Data)
|
||||
return proc.render()
|
||||
|
||||
except KeyError as msg:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import redirect
|
||||
from django.http import HttpResponse
|
||||
from mailServer.models import Domains, EUsers
|
||||
# Create your views here.
|
||||
from loginSystem.models import Administrator
|
||||
from websiteFunctions.models import Websites
|
||||
from loginSystem.views import loadLoginPage
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
|
|
@ -13,31 +10,19 @@ import json
|
|||
from .models import DomainLimits, EmailLimits
|
||||
from math import ceil
|
||||
from postfixSenderPolicy.client import cacheClient
|
||||
import _thread
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from random import randint
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
# Create your views here.
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
## Email Policy Server
|
||||
|
||||
def emailPolicyServer(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'emailPremium/policyServer.html')
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/policyServer.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchPolicyServerStatus(request):
|
||||
try:
|
||||
|
|
@ -129,57 +114,43 @@ def savePolicyServerStatus(request):
|
|||
## Email Policy Server configs
|
||||
|
||||
def listDomains(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
websites = DomainLimits.objects.all()
|
||||
|
||||
try:
|
||||
websites = DomainLimits.objects.all()
|
||||
## Check if Policy Server is installed.
|
||||
|
||||
## Check if Policy Server is installed.
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
command = 'sudo cat /etc/postfix/main.cf'
|
||||
output = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
installCheck = 0
|
||||
|
||||
installCheck = 0
|
||||
for items in output:
|
||||
if items.find('check_policy_service unix:/var/log/policyServerSocket') > -1:
|
||||
installCheck = 1
|
||||
break
|
||||
|
||||
for items in output:
|
||||
if items.find('check_policy_service unix:/var/log/policyServerSocket') > -1:
|
||||
installCheck = 1
|
||||
break
|
||||
if installCheck == 0:
|
||||
proc = httpProc(request, 'emailPremium/listDomains.html', {"installCheck": installCheck}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
if installCheck == 0:
|
||||
return render(request, 'emailPremium/listDomains.html', {"installCheck": installCheck})
|
||||
###
|
||||
|
||||
###
|
||||
pages = float(len(websites)) / float(10)
|
||||
pagination = []
|
||||
|
||||
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
|
||||
|
||||
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>')
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
|
||||
return render(request,'emailPremium/listDomains.html',{"pagination":pagination, "installCheck": installCheck})
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/listDomains.html',
|
||||
{"pagination": pagination, "installCheck": installCheck}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getFurtherDomains(request):
|
||||
try:
|
||||
|
|
@ -304,57 +275,47 @@ def enableDisableEmailLimits(request):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def emailLimits(request,domain):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if Websites.objects.filter(domain=domain).exists():
|
||||
website = Websites.objects.get(domain=domain)
|
||||
domainEmail = Domains.objects.get(domainOwner=website)
|
||||
domainLimits = DomainLimits.objects.get(domain=domainEmail)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
Data = {}
|
||||
Data['domain'] = domain
|
||||
Data['monthlyLimit'] = domainLimits.monthlyLimit
|
||||
Data['monthlyUsed'] = domainLimits.monthlyUsed
|
||||
Data['emailAccounts'] = domainEmail.eusers_set.count()
|
||||
|
||||
if domainLimits.limitStatus == 1:
|
||||
Data['limitsOn'] = 1
|
||||
Data['limitsOff'] = 0
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
Data['limitsOn'] = 0
|
||||
Data['limitsOff'] = 1
|
||||
|
||||
## Pagination for emails
|
||||
|
||||
if Websites.objects.filter(domain=domain).exists():
|
||||
website = Websites.objects.get(domain=domain)
|
||||
domainEmail = Domains.objects.get(domainOwner=website)
|
||||
domainLimits = DomainLimits.objects.get(domain=domainEmail)
|
||||
pages = float(Data['emailAccounts']) / float(10)
|
||||
pagination = []
|
||||
|
||||
Data = {}
|
||||
Data['domain'] = domain
|
||||
Data['monthlyLimit'] = domainLimits.monthlyLimit
|
||||
Data['monthlyUsed'] = domainLimits.monthlyUsed
|
||||
Data['emailAccounts'] = domainEmail.eusers_set.count()
|
||||
|
||||
if domainLimits.limitStatus == 1:
|
||||
Data['limitsOn'] = 1
|
||||
Data['limitsOff'] = 0
|
||||
else:
|
||||
Data['limitsOn'] = 0
|
||||
Data['limitsOff'] = 1
|
||||
|
||||
## Pagination for emails
|
||||
|
||||
|
||||
pages = float(Data['emailAccounts']) / 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>')
|
||||
|
||||
Data['pagination'] = pagination
|
||||
|
||||
return render(request, 'emailPremium/emailLimits.html', Data)
|
||||
if pages <= 1.0:
|
||||
pages = 1
|
||||
pagination.append('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
return render(request, 'emailPremium/emailLimits.html', {"error":1,"domain": "This domain does not exists"})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
Data['pagination'] = pagination
|
||||
|
||||
proc = httpProc(request, 'emailPremium/emailLimits.html', Data, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
proc = httpProc(request, 'emailPremium/emailLimits.html', {"error": 1, "domain": "This domain does not exists"},
|
||||
'admin')
|
||||
return proc.render()
|
||||
|
||||
def changeDomainLimit(request):
|
||||
try:
|
||||
|
|
@ -495,39 +456,29 @@ def enableDisableIndividualEmailLimits(request):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def emailPage(request, emailAddress):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
Data = {}
|
||||
Data['emailAddress'] = emailAddress
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
email = EUsers.objects.get(email=emailAddress)
|
||||
logEntries = email.emaillogs_set.all().count()
|
||||
|
||||
Data = {}
|
||||
Data['emailAddress'] = emailAddress
|
||||
pages = float(logEntries) / float(10)
|
||||
pagination = []
|
||||
|
||||
email = EUsers.objects.get(email=emailAddress)
|
||||
logEntries = email.emaillogs_set.all().count()
|
||||
if pages <= 1.0:
|
||||
pages = 1
|
||||
pagination.append('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
|
||||
pages = float(logEntries) / float(10)
|
||||
pagination = []
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
if pages <= 1.0:
|
||||
pages = 1
|
||||
pagination.append('<li><a href="\#"></a></li>')
|
||||
else:
|
||||
pages = ceil(pages)
|
||||
finalPages = int(pages) + 1
|
||||
Data['pagination'] = pagination
|
||||
|
||||
for i in range(1, finalPages):
|
||||
pagination.append('<li><a href="\#">' + str(i) + '</a></li>')
|
||||
|
||||
Data['pagination'] = pagination
|
||||
|
||||
return render(request, 'emailPremium/emailPage.html', Data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/emailPage.html', Data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getEmailStats(request):
|
||||
try:
|
||||
|
|
@ -771,24 +722,14 @@ def flushEmailLogs(request):
|
|||
### SpamAssassin
|
||||
|
||||
def spamAssassinHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
checkIfSpamAssassinInstalled = 0
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
if mailUtilities.checkIfSpamAssassinInstalled() == 1:
|
||||
checkIfSpamAssassinInstalled = 1
|
||||
|
||||
checkIfSpamAssassinInstalled = 0
|
||||
|
||||
if mailUtilities.checkIfSpamAssassinInstalled() == 1:
|
||||
checkIfSpamAssassinInstalled = 1
|
||||
|
||||
return render(request, 'emailPremium/SpamAssassin.html',{'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/SpamAssassin.html',
|
||||
{'checkIfSpamAssassinInstalled': checkIfSpamAssassinInstalled}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def installSpamAssassin(request):
|
||||
try:
|
||||
|
|
@ -951,9 +892,6 @@ def fetchSpamAssassinSettings(request):
|
|||
final_dic = {'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
return render(request,'managePHP/editPHPConfig.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -1028,19 +966,9 @@ def saveSpamAssassinConfigurations(request):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def mailQueue(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'emailPremium/mailQueue.html')
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/mailQueue.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchMailQueue(request):
|
||||
try:
|
||||
|
|
@ -1176,29 +1104,19 @@ def delete(request):
|
|||
## MailScanner
|
||||
|
||||
def MailScanner(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
checkIfMailScannerInstalled = 0
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
checkIfMailScannerInstalled = 0
|
||||
if mailUtilities.checkIfMailScannerInstalled() == 1:
|
||||
checkIfMailScannerInstalled = 1
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
if mailUtilities.checkIfMailScannerInstalled() == 1:
|
||||
checkIfMailScannerInstalled = 1
|
||||
|
||||
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'emailPremium/MailScanner.html',
|
||||
{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def installMailScanner(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -546,12 +546,18 @@ class FileManager:
|
|||
if self.data['fileName'].find(self.data['home']) == -1 or self.data['fileName'].find('..') > -1:
|
||||
return self.ajaxPre(0, 'Not allowed to move in this path, please choose location inside home!')
|
||||
|
||||
command = 'stat -c "%%a" %s' % (self.returnPathEnclosed(self.data['fileName']))
|
||||
currentMode = ProcessUtilities.outputExecutioner(command).strip('\n')
|
||||
|
||||
command = 'mv ' + tempPath + ' ' + self.returnPathEnclosed(self.data['fileName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chown %s:%s %s' % (website.externalApp, website.externalApp, self.data['fileName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod %s %s' % (currentMode, self.returnPathEnclosed(self.data['fileName']))
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
self.changeOwner(self.data['fileName'])
|
||||
|
||||
json_data = json.dumps(finalData)
|
||||
|
|
@ -711,6 +717,9 @@ class FileManager:
|
|||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
command = 'chown %s:%s /home/%s' % (website.externalApp, website.externalApp, domainName)
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
|
||||
command = 'chown -R %s:%s /home/%s/public_html/*' % (externalApp, externalApp, domainName)
|
||||
ProcessUtilities.popenExecutioner(command)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import os
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
|
|
@ -31,30 +34,14 @@ class FirewallManager:
|
|||
self.request = request
|
||||
|
||||
def securityHome(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'firewall/index.html')
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'firewall/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def firewallHome(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'firewall/firewall.html')
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'firewall/firewall.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getCurrentRules(self, userID = None):
|
||||
try:
|
||||
|
|
@ -265,17 +252,9 @@ class FirewallManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def secureSSH(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'firewall/secureSSH.html')
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'firewall/secureSSH.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getSSHConfigs(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -487,34 +466,26 @@ class FirewallManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def loadModSecurityHome(self, request = None, userID = None):
|
||||
try:
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
OLS = 1
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
OLS = 1
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
modSecInstalled = 0
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).splitlines()
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
OLS = 0
|
||||
modSecInstalled = 1
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
OLS = 0
|
||||
modSecInstalled = 1
|
||||
|
||||
return render(request, 'firewall/modSecurity.html', {'modSecInstalled': modSecInstalled, 'OLS': OLS})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'firewall/modSecurity.html',
|
||||
{'modSecInstalled': modSecInstalled, 'OLS': OLS}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def installModSec(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -870,34 +841,24 @@ class FirewallManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def modSecRules(self, request = None, userID = None):
|
||||
try:
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
modSecInstalled = 0
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
modSecInstalled = 1
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
modSecInstalled = 1
|
||||
|
||||
return render(request, 'firewall/modSecurityRules.html', {'modSecInstalled': modSecInstalled})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(request, 'firewall/modSecurityRules.html',
|
||||
{'modSecInstalled': modSecInstalled}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchModSecRules(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -994,35 +955,25 @@ class FirewallManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def modSecRulesPacks(self, request = None, userID = None):
|
||||
try:
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
modSecInstalled = 0
|
||||
|
||||
confPath = os.path.join(virtualHostUtilities.Server_root, "conf/httpd_config.conf")
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
modSecInstalled = 1
|
||||
|
||||
command = "sudo cat " + confPath
|
||||
httpdConfig = ProcessUtilities.outputExecutioner(command).split('\n')
|
||||
|
||||
modSecInstalled = 0
|
||||
|
||||
for items in httpdConfig:
|
||||
if items.find('module mod_security') > -1:
|
||||
modSecInstalled = 1
|
||||
break
|
||||
else:
|
||||
modSecInstalled = 1
|
||||
|
||||
return render(request, 'firewall/modSecurityRulesPacks.html', {'modSecInstalled': modSecInstalled})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(msg)
|
||||
proc = httpProc(request, 'firewall/modSecurityRulesPacks.html',
|
||||
{'modSecInstalled': modSecInstalled}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getOWASPAndComodoStatus(self, userID = None, data = None):
|
||||
try:
|
||||
|
|
@ -1299,26 +1250,18 @@ class FirewallManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def csf(self):
|
||||
csfInstalled = 1
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
csfInstalled = 1
|
||||
try:
|
||||
command = 'csf -h'
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
if output.find("command not found") > -1:
|
||||
csfInstalled = 0
|
||||
except subprocess.CalledProcessError:
|
||||
command = 'csf -h'
|
||||
output = ProcessUtilities.outputExecutioner(command)
|
||||
if output.find("command not found") > -1:
|
||||
csfInstalled = 0
|
||||
return render(self.request,'firewall/csf.html', {'csfInstalled' : csfInstalled})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
except subprocess.CalledProcessError:
|
||||
csfInstalled = 0
|
||||
|
||||
proc = httpProc(self.request, 'firewall/csf.html',
|
||||
{'csfInstalled': csfInstalled}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def installCSF(self):
|
||||
try:
|
||||
|
|
@ -1548,45 +1491,35 @@ class FirewallManager:
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def imunify(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
data = {}
|
||||
data['ipAddress'] = fullAddress
|
||||
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
data['CL'] = 1
|
||||
|
||||
data = {}
|
||||
data['ipAddress'] = fullAddress
|
||||
if os.path.exists(FirewallManager.imunifyPath):
|
||||
data['imunify'] = 1
|
||||
else:
|
||||
data['imunify'] = 0
|
||||
|
||||
if os.path.exists(FirewallManager.CLPath):
|
||||
data['CL'] = 1
|
||||
else:
|
||||
data['CL'] = 0
|
||||
|
||||
if os.path.exists(FirewallManager.imunifyPath):
|
||||
data['imunify'] = 1
|
||||
else:
|
||||
data['imunify'] = 0
|
||||
|
||||
if data['CL'] == 0:
|
||||
return render(self.request, 'firewall/notAvailable.html', data)
|
||||
elif data['imunify'] == 0:
|
||||
return render(self.request, 'firewall/notAvailable.html', data)
|
||||
else:
|
||||
return render(self.request, 'firewall/imunify.html', data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
if data['CL'] == 0:
|
||||
proc = httpProc(self.request, 'firewall/notAvailable.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
elif data['imunify'] == 0:
|
||||
proc = httpProc(self.request, 'firewall/notAvailable.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
proc = httpProc(self.request, 'firewall/imunify.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def submitinstallImunify(self):
|
||||
try:
|
||||
|
|
@ -1615,40 +1548,29 @@ class FirewallManager:
|
|||
logging.CyberCPLogFileWriter.statusWriter(ServerStatusUtil.lswsInstallStatusPath, str(msg) + ' [404].', 1)
|
||||
|
||||
def imunifyAV(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
data = {}
|
||||
data['ipAddress'] = fullAddress
|
||||
|
||||
fullAddress = '%s:%s' % (ipAddress, ProcessUtilities.fetchCurrentPort())
|
||||
if os.path.exists(FirewallManager.imunifyAVPath):
|
||||
data['imunify'] = 1
|
||||
else:
|
||||
data['imunify'] = 0
|
||||
|
||||
data = {}
|
||||
data['ipAddress'] = fullAddress
|
||||
|
||||
|
||||
|
||||
if os.path.exists(FirewallManager.imunifyAVPath):
|
||||
data['imunify'] = 1
|
||||
else:
|
||||
data['imunify'] = 0
|
||||
|
||||
if data['imunify'] == 0:
|
||||
return render(self.request, 'firewall/notAvailableAV.html', data)
|
||||
else:
|
||||
return render(self.request, 'firewall/imunifyAV.html', data)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
if data['imunify'] == 0:
|
||||
proc = httpProc(self.request, 'firewall/notAvailableAV.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
proc = httpProc(self.request, 'firewall/imunifyAV.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def submitinstallImunifyAV(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
<p>{% trans "Imunify is now integrated via their new API. You can manage Imunify by clicking below. You can use your server root credentials to access Imunify." %}</p>
|
||||
<br>
|
||||
<a target="_blank" href="http://{{ ipAddress }}:8090/imunify">
|
||||
<a target="_blank" href="http://{{ ipAddress }}/imunify">
|
||||
<button class="btn btn-primary">Access Now
|
||||
</button>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
import json
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import redirect
|
||||
from django.http import HttpResponse
|
||||
try:
|
||||
from .models import Users
|
||||
|
|
@ -32,32 +35,26 @@ class FTPManager:
|
|||
self.extraArgs = extraArgs
|
||||
|
||||
def loadFTPHome(self):
|
||||
try:
|
||||
val = self.request.session['userID']
|
||||
return render(self.request, 'ftp/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'ftp/index.html',
|
||||
None, 'createFTPAccount')
|
||||
return proc.render()
|
||||
|
||||
def createFTPAccount(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'createFTPAccount') == 0:
|
||||
return ACLManager.loadError()
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
proc = httpProc(self.request, 'ftp/createFTPAccount.html',
|
||||
{"status": 0}, 'createFTPAccount')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
return render(self.request, "ftp/createFTPAccount.html", {"status": 0})
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(self.request, 'ftp/createFTPAccount.html',
|
||||
{'websiteList': websitesName, 'admin': admin.userName, "status": 1})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(self.request, 'ftp/createFTPAccount.html',
|
||||
{'websiteList': websitesName, 'OwnerFTP': admin.userName, "status": 1}, 'createFTPAccount')
|
||||
return proc.render()
|
||||
|
||||
def submitFTPCreation(self):
|
||||
try:
|
||||
|
|
@ -114,23 +111,19 @@ class FTPManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def deleteFTPAccount(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
proc = httpProc(self.request, 'ftp/deleteFTPAccount.html',
|
||||
{"status": 0}, 'deleteFTPAccount')
|
||||
return proc.render()
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteFTPAccount') == 0:
|
||||
return ACLManager.loadError()
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
return render(self.request, "ftp/deleteFTPAccount.html", {"status": 0})
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(self.request, 'ftp/deleteFTPAccount.html', {'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(self.request, 'ftp/deleteFTPAccount.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'deleteFTPAccount')
|
||||
return proc.render()
|
||||
|
||||
def fetchFTPAccounts(self):
|
||||
try:
|
||||
|
|
@ -204,22 +197,18 @@ class FTPManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def listFTPAccounts(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'listFTPAccounts') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
proc = httpProc(self.request, 'ftp/listFTPAccounts.html',
|
||||
{"status": 0}, 'listFTPAccounts')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/pureftpd'):
|
||||
return render(self.request, "ftp/listFTPAccounts.html", {"status": 0})
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(self.request, 'ftp/listFTPAccounts.html', {'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse(str(msg))
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(self.request, 'ftp/listFTPAccounts.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'listFTPAccounts')
|
||||
return proc.render()
|
||||
|
||||
def getAllFTPAccounts(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@
|
|||
/* Java script code to create account */
|
||||
app.controller('createFTPAccount', function ($scope, $http) {
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$( ".ftpDetails" ).hide();
|
||||
$( ".ftpPasswordView" ).hide();
|
||||
$('.create-ftp-acct-select').select2();
|
||||
});
|
||||
|
||||
$('.create-ftp-acct-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.ftpDomain = data.text;
|
||||
$( ".ftpDetails" ).show();
|
||||
|
||||
});
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = true;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.showFTPDetails = function () {
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.createFTPAccount = function () {
|
||||
|
||||
|
|
@ -62,37 +62,35 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.creatFTPStatus == 1) {
|
||||
|
||||
if (response.data.creatFTPStatus === 1) {
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'FTP account successfully created.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = false;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -109,15 +107,13 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
|||
|
||||
///
|
||||
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$( ".ftpPasswordView" ).show();
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
$(".ftpPasswordView" ).hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
|
||||
<div class="col-sm-6">
|
||||
<select ng-change="showFTPDetails()" ng-model="ftpDomain" class="form-control">
|
||||
<select class="create-ftp-acct-select" ng-model="ftpDomain" class="form-control">
|
||||
{% for items in websiteList %}
|
||||
<option>{{ items }}</option>
|
||||
{% endfor %}
|
||||
|
|
@ -53,17 +53,17 @@
|
|||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
|
||||
<div ng-hide="ftpDetails" class="form-group">
|
||||
<div class="form-group ftpDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "User Name" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input ng-change="hideFewDetails()" type="text" class="form-control"
|
||||
ng-model="ftpUserName" required>
|
||||
</div>
|
||||
<div class="current-pack">{{ admin }}_{$ ftpUserName $}</div>
|
||||
<div class="current-pack">{{ OwnerFTP }}_{$ ftpUserName $}</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div ng-hide="ftpDetails" class="form-group">
|
||||
<div class="form-group ftpDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "FTP Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" class="form-control" ng-model="ftpPassword" required>
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="generatedPasswordView" class="form-group">
|
||||
<div class="form-group ftpPasswordView">
|
||||
<label class="col-sm-3 control-label">{% trans "Generated Password" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="email" class="form-control" ng-model="ftpPassword"
|
||||
|
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-hide="ftpDetails" class="form-group">
|
||||
<div ng-hide="ftpDetails" class="form-group ftpDetails">
|
||||
<label class="col-sm-3 control-label">{% trans "Path (Relative)" %}</label>
|
||||
<div class="col-sm-6">
|
||||
<input placeholder="{% trans 'Leave empty to select default home directory.' %}"
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
<!------ Modification form that appears after a click --------------->
|
||||
|
||||
|
||||
<div ng-hide="ftpDetails" class="form-group">
|
||||
<div class="form-group dbDetails">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<button type="button" ng-click="createFTPAccount()"
|
||||
|
|
@ -106,29 +106,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-6">
|
||||
<div ng-hide="canNotCreate" class="alert alert-danger">
|
||||
<p>{% trans "Cannot create FTP account. Error message:" %} {$ errorMessage
|
||||
$}</p>
|
||||
</div>
|
||||
|
||||
<div ng-hide="successfullyCreated" class="alert alert-success">
|
||||
<p>{% trans "FTP Account with username:" %} {$ ftpUserName
|
||||
$} {% trans "is successfully created." %}</p>
|
||||
</div>
|
||||
<div ng-hide="couldNotConnect" class="alert alert-success">
|
||||
<p>{% trans "FTP Account with username:" %} {$ ftpUserName
|
||||
$} {% trans "is successfully created." %}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCR0LGYoTUe8ZBhH1D9q/QxbmKzKLQS7TMEyPMCv3NidL+LHy60B5upmflIfIf7oRtyDXWGlH564CFQB8YDnXJBrUgCxpRWtT7MYLWMu9WA8OTtJnGi6r10maLp4RJi7yzuOZ36n+IW/ZdxxVgKgfVeUAtaYXZjrsOLepD4YfXjw4D0MYD7VPcYUdPjRf3m5vClaawvmMtNXh2d2a2BFDJCzX3YgAJdbNe9rJeVrigSWUahU6fPVKxbqEdb7E+l8YIUzNtnpjaxcaaBtLKbc4GiAzLmNOdG01F09/y3GTnHcZJSORLGowioZMpB+T8Q9pvW9lJDSw3k7GbUitpfMHT cloud
|
||||
|
|
@ -14,8 +14,8 @@ from os.path import *
|
|||
from stat import *
|
||||
import stat
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
char_set = {'small': 'abcdefghijklmnopqrstuvwxyz',
|
||||
'nums': '0123456789',
|
||||
|
|
@ -446,7 +446,7 @@ class preFlightsChecks:
|
|||
command = "sed -i 's|root|%s|g' %s" % (self.mysqluser, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
command = "sed -i 's|'PORT':''|'PORT':'%s'|g' %s" % (self.mysqlport, path)
|
||||
command = "sed -i \"s|'PORT': ''|'PORT':'%s'|g\" %s" % (self.mysqlport, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
logging.InstallLog.writeToFile("settings.py updated!")
|
||||
|
|
@ -776,18 +776,11 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
command = 'debconf-set-selections ' + file_name
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
|
||||
|
||||
command = 'apt-get -y install postfix'
|
||||
command = 'apt-get -y install postfix postfix-mysql'
|
||||
# os.remove(file_name)
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro == centos or self.distro == cent8:
|
||||
pass
|
||||
else:
|
||||
command = 'apt-get -y install dovecot-imapd dovecot-pop3d postfix-mysql'
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
##
|
||||
|
||||
if self.distro == centos:
|
||||
|
|
@ -795,42 +788,42 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
elif self.distro == cent8:
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
|
||||
else:
|
||||
command = 'apt-get -y install dovecot-mysql'
|
||||
command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
|
||||
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro != centos:
|
||||
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
writeToFile = open(debPath, 'w')
|
||||
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
writeToFile.close()
|
||||
|
||||
try:
|
||||
command = 'apt update -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'dpkg --configure -a'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'apt --fix-broken install -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
# if self.distro != centos:
|
||||
# command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
# writeToFile = open(debPath, 'w')
|
||||
# writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
# writeToFile.close()
|
||||
#
|
||||
# try:
|
||||
# command = 'apt update -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
# except:
|
||||
# pass
|
||||
#
|
||||
# try:
|
||||
# command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'dpkg --configure -a'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'apt --fix-broken install -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
#
|
||||
# command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
# subprocess.call(command, shell=True)
|
||||
# except:
|
||||
# pass
|
||||
|
||||
except BaseException as msg:
|
||||
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_davecot]")
|
||||
|
|
@ -845,20 +838,14 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
|
||||
os.chdir(self.cwd)
|
||||
|
||||
if mysql == 'Two':
|
||||
mysql_virtual_domains = "email-configs/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "email-configs/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "email-configs/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "email-configs/mysql-virtual_email2email.cf"
|
||||
davecotmysql = "email-configs/dovecot-sql.conf.ext"
|
||||
else:
|
||||
mysql_virtual_domains = "email-configs-one/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf"
|
||||
davecotmysql = "email-configs-one/dovecot-sql.conf.ext"
|
||||
mysql_virtual_domains = "email-configs-one/mysql-virtual_domains.cf"
|
||||
mysql_virtual_forwardings = "email-configs-one/mysql-virtual_forwardings.cf"
|
||||
mysql_virtual_mailboxes = "email-configs-one/mysql-virtual_mailboxes.cf"
|
||||
mysql_virtual_email2email = "email-configs-one/mysql-virtual_email2email.cf"
|
||||
davecotmysql = "email-configs-one/dovecot-sql.conf.ext"
|
||||
|
||||
### update password:
|
||||
|
||||
### update password:
|
||||
|
||||
data = open(davecotmysql, "r").readlines()
|
||||
|
||||
|
|
@ -875,8 +862,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
|
|
@ -894,9 +879,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
|
@ -913,9 +895,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
|
@ -932,9 +911,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
### update password:
|
||||
|
|
@ -951,9 +927,6 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
# if self.distro == ubuntu:
|
||||
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
|
||||
|
|
@ -1060,37 +1033,24 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
|||
# Cleanup config files for ubuntu
|
||||
if self.distro == ubuntu:
|
||||
preFlightsChecks.stdOut("Cleanup postfix/dovecot config files", 1)
|
||||
if mysql == 'Two':
|
||||
self.centos_lib_dir_to_ubuntu("email-configs/master.cf", "/usr/libexec/", "/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("email-configs/main.cf", "/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
else:
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/master.cf", "/usr/libexec/", "/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/main.cf", "/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/master.cf", "/usr/libexec/", "/usr/lib/")
|
||||
self.centos_lib_dir_to_ubuntu("email-configs-one/main.cf", "/usr/libexec/postfix",
|
||||
"/usr/lib/postfix/sbin")
|
||||
|
||||
########### Copy config files
|
||||
|
||||
if mysql == 'Two':
|
||||
shutil.copy("email-configs/mysql-virtual_domains.cf", "/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_forwardings.cf", "/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_mailboxes.cf", "/etc/postfix/mysql-virtual_mailboxes.cf")
|
||||
shutil.copy("email-configs/mysql-virtual_email2email.cf", "/etc/postfix/mysql-virtual_email2email.cf")
|
||||
shutil.copy("email-configs/main.cf", main)
|
||||
shutil.copy("email-configs/master.cf", master)
|
||||
shutil.copy("email-configs/dovecot.conf", davecot)
|
||||
shutil.copy("email-configs/dovecot-sql.conf.ext", davecotmysql)
|
||||
else:
|
||||
shutil.copy("email-configs-one/mysql-virtual_domains.cf", "/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_forwardings.cf",
|
||||
"/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_mailboxes.cf", "/etc/postfix/mysql-virtual_mailboxes.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_email2email.cf",
|
||||
"/etc/postfix/mysql-virtual_email2email.cf")
|
||||
shutil.copy("email-configs-one/main.cf", main)
|
||||
shutil.copy("email-configs-one/master.cf", master)
|
||||
shutil.copy("email-configs-one/dovecot.conf", davecot)
|
||||
shutil.copy("email-configs-one/dovecot-sql.conf.ext", davecotmysql)
|
||||
shutil.copy("email-configs-one/mysql-virtual_domains.cf", "/etc/postfix/mysql-virtual_domains.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_forwardings.cf",
|
||||
"/etc/postfix/mysql-virtual_forwardings.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_mailboxes.cf", "/etc/postfix/mysql-virtual_mailboxes.cf")
|
||||
shutil.copy("email-configs-one/mysql-virtual_email2email.cf",
|
||||
"/etc/postfix/mysql-virtual_email2email.cf")
|
||||
shutil.copy("email-configs-one/main.cf", main)
|
||||
shutil.copy("email-configs-one/master.cf", master)
|
||||
shutil.copy("email-configs-one/dovecot.conf", davecot)
|
||||
shutil.copy("email-configs-one/dovecot-sql.conf.ext", davecotmysql)
|
||||
|
||||
|
||||
######################################## Permissions
|
||||
|
||||
|
|
@ -2197,7 +2157,7 @@ def main():
|
|||
parser.add_argument('--mysqlport', help='MySQL port if remote is chosen.')
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.InstallLog.writeToFile("Starting CyberPanel installation..")
|
||||
logging.InstallLog.writeToFile("Starting CyberPanel installation..,10")
|
||||
preFlightsChecks.stdOut("Starting CyberPanel installation..")
|
||||
|
||||
if args.ent == None:
|
||||
|
|
@ -2388,7 +2348,7 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
except:
|
||||
pass
|
||||
|
||||
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!")
|
||||
logging.InstallLog.writeToFile("CyberPanel installation successfully completed!,80")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -274,7 +274,6 @@ class InstallCyberPanel:
|
|||
|
||||
def changeMYSQLRootPassword(self):
|
||||
if self.remotemysql == 'OFF':
|
||||
|
||||
if self.distro == ubuntu:
|
||||
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';UPDATE user SET plugin='' WHERE User='root';flush privileges;" % (InstallCyberPanel.mysql_Root_password)
|
||||
else:
|
||||
|
|
@ -656,13 +655,16 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
|
|||
|
||||
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
|
||||
|
||||
logging.InstallLog.writeToFile('Installing LiteSpeed Web server,40')
|
||||
installer.installLiteSpeed()
|
||||
if ent == 0:
|
||||
installer.changePortTo80()
|
||||
logging.InstallLog.writeToFile('Installing Optimized PHPs..,50')
|
||||
installer.installAllPHPVersions()
|
||||
if ent == 0:
|
||||
installer.fix_ols_configs()
|
||||
|
||||
logging.InstallLog.writeToFile('Installing MySQL,60')
|
||||
installer.installMySQL(mysql)
|
||||
installer.changeMYSQLRootPassword()
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,22 @@ import time
|
|||
class InstallLog:
|
||||
fileName = "/var/log/installLogs.txt"
|
||||
|
||||
currentPercent = '10'
|
||||
|
||||
@staticmethod
|
||||
def writeToFile(message):
|
||||
|
||||
if message.find(',') == -1:
|
||||
message = '%s,%s' % (message, InstallLog.currentPercent)
|
||||
elif message.find('mount -o') > -1 or message.find('usermod -G lscpd,') > -1:
|
||||
message = '%s,%s' % (message.replace(',', '-'), InstallLog.currentPercent)
|
||||
else:
|
||||
try:
|
||||
InstallLog.currentPercent = message.split(',')[1]
|
||||
except:
|
||||
pass
|
||||
|
||||
file = open(InstallLog.fileName,'a')
|
||||
file.writelines("[" + time.strftime(
|
||||
"%m.%d.%Y_%H-%M-%S") + "] "+message + "\n")
|
||||
"%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")
|
||||
file.close()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ expires {
|
|||
enableExpires 1
|
||||
expiresByType image/*=A604800, text/css=A604800, application/x-javascript=A604800
|
||||
}
|
||||
autoLoadHtaccess 1
|
||||
|
||||
tuning {
|
||||
eventDispatcher best
|
||||
|
|
@ -199,4 +200,7 @@ include phpconfigs/php55.conf
|
|||
include phpconfigs/php56.conf
|
||||
include phpconfigs/php70.conf
|
||||
include phpconfigs/php71.conf
|
||||
|
||||
include phpconfigs/php72.conf
|
||||
include phpconfigs/php73.conf
|
||||
include phpconfigs/php74.conf
|
||||
include phpconfigs/php80.conf
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@ SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-A
|
|||
CacheRoot /home/lscache/
|
||||
</IfModule>
|
||||
|
||||
<VirtualHost *>
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /usr/local/lsws/DEFAULT/html
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
DocumentRoot /usr/local/lsws/DEFAULT/html
|
||||
</VirtualHost>
|
||||
Include /usr/local/lsws/conf/modsec.conf
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class mysqlUtilities:
|
|||
from json import loads
|
||||
mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read())
|
||||
|
||||
|
||||
initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword'])
|
||||
remote = 1
|
||||
except:
|
||||
|
|
@ -56,7 +55,26 @@ class mysqlUtilities:
|
|||
if res == 1:
|
||||
return 0
|
||||
else:
|
||||
|
||||
if remote:
|
||||
|
||||
### DO Check
|
||||
|
||||
if mysqlData['mysqlhost'].find('ondigitalocean') > -1:
|
||||
|
||||
alterUserPassword = "ALTER USER 'cyberpanel'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % (
|
||||
publicip, dbpassword)
|
||||
command = initCommand + alterUserPassword + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
## RDS Check
|
||||
|
||||
if mysqlData['mysqlhost'].find('rds.amazon') == -1:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ class ACL(models.Model):
|
|||
manageSSL = models.IntegerField(default=1)
|
||||
hostnameSSL = models.IntegerField(default=0)
|
||||
mailServerSSL = models.IntegerField(default=0)
|
||||
config = models.TextField(default='{}')
|
||||
|
||||
|
||||
|
||||
class Administrator(models.Model):
|
||||
userName = models.CharField(unique=True,max_length = 50)
|
||||
|
|
@ -93,6 +96,7 @@ class Administrator(models.Model):
|
|||
acl = models.ForeignKey(ACL, default=1, on_delete=models.PROTECT)
|
||||
twoFA = models.IntegerField(default=0)
|
||||
secretKey = models.CharField(max_length=50, default='None')
|
||||
config = models.TextField(default='{}')
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,249 +1,361 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<style>
|
||||
/* Loading Spinner */
|
||||
.spinner {
|
||||
margin: 0;
|
||||
width: 70px;
|
||||
height: 18px;
|
||||
margin: -35px 0 0 -9px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
text-align: center
|
||||
}
|
||||
<style>
|
||||
.d-flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.spinner > div {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
background-color: #333;
|
||||
border-radius: 100%;
|
||||
display: inline-block;
|
||||
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
|
||||
animation: bouncedelay 1.4s infinite ease-in-out;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both
|
||||
}
|
||||
.flex-column {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.spinner .bounce1 {
|
||||
-webkit-animation-delay: -.32s;
|
||||
animation-delay: -.32s
|
||||
}
|
||||
.justify-content-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.spinner .bounce2 {
|
||||
-webkit-animation-delay: -.16s;
|
||||
animation-delay: -.16s
|
||||
}
|
||||
.col-login {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@-webkit-keyframes bouncedelay {
|
||||
0%, 80%, 100% {
|
||||
-webkit-transform: scale(0.0)
|
||||
}
|
||||
40% {
|
||||
-webkit-transform: scale(1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bouncedelay {
|
||||
0%, 80%, 100% {
|
||||
transform: scale(0.0);
|
||||
-webkit-transform: scale(0.0)
|
||||
}
|
||||
40% {
|
||||
transform: scale(1.0);
|
||||
-webkit-transform: scale(1.0)
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
|
||||
<title> Login - CyberPanel </title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
.col-login-left {
|
||||
background: rgb(51, 204, 204);
|
||||
background: -moz-linear-gradient(0deg, rgba(51, 204, 204, 1) 0%, rgba(0, 0, 122, 1) 100%);
|
||||
background: -webkit-linear-gradient(0deg, rgba(51, 204, 204, 1) 0%, rgba(0, 0, 122, 1) 100%);
|
||||
background: linear-gradient(0deg, rgba(51, 204, 204, 1) 0%, rgba(0, 0, 122, 1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#33cccc", endColorstr="#00007a", GradientType=1);
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
<!-- Favicons -->
|
||||
{% load static %}
|
||||
.form-group .input-group select.form-control,
|
||||
.form-group .input-group input.form-control,
|
||||
button.btn.btn-login {
|
||||
height: 45px;
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalLoginPageCSS/allCss.css' %}">
|
||||
}
|
||||
button.btn.btn-login {
|
||||
background-color: rgb(51, 204, 204);
|
||||
box-shadow: 0 0 px 0px rgba(0, 0, 0, 0), 0 1px 2px rgba(0, 0, 0, 0);
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
}
|
||||
button.btn.btn-login:hover {
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
}
|
||||
|
||||
<!-- HELPERS -->
|
||||
.form-group .input-group select.form-control:focus,
|
||||
.form-group .input-group input.form-control:focus,
|
||||
button.btn.btn-login {
|
||||
border: 1px solid rgb(51, 204, 204);
|
||||
}
|
||||
|
||||
<!-- ELEMENTS -->
|
||||
.col-login-right {
|
||||
background: #ffffff;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
<!-- ICONS -->
|
||||
.col-login-right .login-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
}
|
||||
a.login-changelogs {
|
||||
border-top: 1px solid #fff;
|
||||
}
|
||||
|
||||
<!-- Admin theme -->
|
||||
.login-changelogs .card {
|
||||
padding: 1em;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
transition: all 0.3s cubic-bezier(.25, .8, .25, 1);
|
||||
}
|
||||
|
||||
<!-- Components theme -->
|
||||
.login-changelogs .card:hover {
|
||||
color: rgb(51, 204, 204);
|
||||
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16), 0 10px 10px rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
.card-body {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
<!-- JS Core -->
|
||||
.object-fit {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
<script type="text/javascript" src="{% static 'baseTemplate/assets/js-core/jquery-core.min.js' %}"></script>
|
||||
h4.card-learnmore {
|
||||
margin-top: 15px;
|
||||
position: relative;
|
||||
color: rgb(51, 204, 204);
|
||||
font-weight: 500;
|
||||
font-size: 1.2em;
|
||||
|
||||
<script type="text/javascript">
|
||||
$(window).load(function () {
|
||||
setTimeout(function () {
|
||||
$('#loading').fadeOut(400, "linear");
|
||||
}, 300);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
<!-- JS Ends -->
|
||||
h4.card-learnmore span {
|
||||
display: inline;
|
||||
padding-bottom: 4px;
|
||||
border-bottom: 1px solid rgb(51, 204, 204);
|
||||
}
|
||||
.alert.alert-danger {
|
||||
text-align: center;
|
||||
margin: 1em 2em 1em 2em;
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
background: #ffffff;
|
||||
}
|
||||
/* Loading Spinner */
|
||||
.spinner {
|
||||
margin: 0;
|
||||
width: 70px;
|
||||
height: 18px;
|
||||
margin: -35px 0 0 -9px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
</style>
|
||||
.spinner>div {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
background-color: #333;
|
||||
border-radius: 100%;
|
||||
display: inline-block;
|
||||
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
|
||||
animation: bouncedelay 1.4s infinite ease-in-out;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both
|
||||
}
|
||||
|
||||
.spinner .bounce1 {
|
||||
-webkit-animation-delay: -.32s;
|
||||
animation-delay: -.32s
|
||||
}
|
||||
|
||||
.spinner .bounce2 {
|
||||
-webkit-animation-delay: -.16s;
|
||||
animation-delay: -.16s
|
||||
}
|
||||
|
||||
@-webkit-keyframes bouncedelay {
|
||||
|
||||
0%,
|
||||
80%,
|
||||
100% {
|
||||
-webkit-transform: scale(0.0)
|
||||
}
|
||||
|
||||
40% {
|
||||
-webkit-transform: scale(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bouncedelay {
|
||||
|
||||
0%,
|
||||
80%,
|
||||
100% {
|
||||
transform: scale(0.0);
|
||||
-webkit-transform: scale(0.0)
|
||||
}
|
||||
|
||||
40% {
|
||||
transform: scale(1.0);
|
||||
-webkit-transform: scale(1.0)
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
|
||||
<title> Login - CyberPanel </title>
|
||||
<meta name="description" content="Login to your CypberPanel account">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<!-- Favicons -->
|
||||
{% load static %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/assets/finalLoginPageCSS/allCss.css' %}">
|
||||
|
||||
<!-- HELPERS -->
|
||||
|
||||
<!-- ELEMENTS -->
|
||||
|
||||
<!-- ICONS -->
|
||||
|
||||
<!-- Admin theme -->
|
||||
|
||||
<!-- Components theme -->
|
||||
|
||||
<!-- JS Core -->
|
||||
|
||||
<script type="text/javascript" src="{% static 'baseTemplate/assets/js-core/jquery-core.min.js' %}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(window).load(function() {
|
||||
setTimeout(function() {
|
||||
$('#loading').fadeOut(400, "linear");
|
||||
}, 300);
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- JS Ends -->
|
||||
|
||||
<style type="text/css">
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
background: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="loading">
|
||||
<div id="loading">
|
||||
<div class="spinner">
|
||||
<div class="bounce1"></div>
|
||||
<div class="bounce2"></div>
|
||||
<div class="bounce3"></div>
|
||||
<div class="bounce1"></div>
|
||||
<div class="bounce2"></div>
|
||||
<div class="bounce3"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class>
|
||||
<div class="col-md-6 col-sm-12 hidden-md" style="background: #00007A;">
|
||||
<div class="row panel-body style=" padding-bottom: 0px;>
|
||||
<div class>
|
||||
<div class="col-md-6 col-sm-12 hidden-md col-login col-login-left">
|
||||
<div class="row panel-body my-30" style="padding-bottom: 0px;">
|
||||
<div class="col-lg-6 col-md-12 panel-body">
|
||||
<h2 class="text-transform-upr text-white my-30 text-bold">WEB HOSTING CONTROL PANEL
|
||||
</br/>FOR EVERYONE
|
||||
<h2 class="text-transform-upr text-white my-30 text-bold">WEB HOSTING CONTROL PANEL
|
||||
</br />FOR EVERYONE
|
||||
|
||||
</h2>
|
||||
<h4 class="text-white">Powered By OpenLiteSpeed/LiteSpeed Enterprise. Built For Speed, Security and
|
||||
Reliability.</h4>
|
||||
</h2>
|
||||
<h4 class="text-white">Powered By OpenLiteSpeed/LiteSpeed Enterprise. Built For Speed, Security and
|
||||
Reliability.</h4>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-12 text-center panel-body">
|
||||
<img class="" src="/static/images/cyberpanel-banner-graphics.png" alt="" width="96%">
|
||||
<img class="" src="/static/images/cyberpanel-banner-graphics.png" alt="" width="96%">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row panel-body">
|
||||
</div>
|
||||
<div class="row panel-body">
|
||||
<div class="row panel-body">
|
||||
<ul class="reset-ul">
|
||||
<li class="row my-30">
|
||||
<div class="col-lg-3 col-md-12 text-center">
|
||||
<img class="img-thumbnail mb-20" src="/static/images/new-design-list-websites-square.png" alt=""
|
||||
width="150">
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-12 mb-20">
|
||||
<h3 class="text-white mb-5">
|
||||
Change Logs
|
||||
</h3>
|
||||
<p class="text-white mt-10">
|
||||
Learn about new releases and features.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-12 text-center">
|
||||
<a href="https://go.cyberpanel.net/updates"
|
||||
target='_blank'>
|
||||
<button type="button" class="btn btn-outline-light mb-30 rounded mt-5">
|
||||
Learn More
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-app="loginSystem" ng-controller="loginSystem" class="col-md-6 col-sm-12" style="background: #ffffff;">
|
||||
<br/>
|
||||
<div>
|
||||
<form id="loginForm" action="/" class="col-md-8 col-md-offset-2">
|
||||
<h1 class="text-transform-upr text-center panel-body text-bold"
|
||||
style="padding-bottom: 0px; color: #33CCCC;">
|
||||
<img class="center-block text-center my-20" src="{% static 'images/cyber-panel-logo.svg' %}">
|
||||
CyberPanel
|
||||
<span class="opacity-80">v 2.0</span>
|
||||
</h1>
|
||||
<h4 class="text-muted text-center mb-10">Web Hosting Control Panel</h4>
|
||||
<div class="">
|
||||
<div class="mx-30">
|
||||
<div class="content-box-wrapper panel-body my-10 mx-30">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-model="username" type="text" class="form-control" name="username"
|
||||
placeholder="Enter username" required style="height: 45px;">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-envelope-o"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-keypress="initiateLogin($event)" ng-model="password" type="password"
|
||||
class="form-control" id="password" placeholder="Password" required
|
||||
name="password">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-unlock-alt"></i>
|
||||
</span>
|
||||
</div>
|
||||
<img id="verifyingLogin" class="center-block"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</div>
|
||||
|
||||
<div ng-hide="verifyCode" class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-model="twofa" type="text" class="form-control" name="twofa"
|
||||
placeholder="Enter code from Google Authenticator" required style="height: 45px;">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-unlock-alt"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<select ng-model="languageSelection" ng-init="languageSelection='english'"
|
||||
class="form-control">
|
||||
<option value="english">English</option>
|
||||
<option>Bangla</option>
|
||||
<option>Bosnian</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Chinese</option>
|
||||
<option>French</option>
|
||||
<option>German</option>
|
||||
<option>Greek</option>
|
||||
<option>Italian</option>
|
||||
<option>Indonesian</option>
|
||||
<option>Japanese</option>
|
||||
<option>Polish</option>
|
||||
<option>Portuguese</option>
|
||||
<option>Russian</option>
|
||||
<option>Spanish</option>
|
||||
<option>Turkish</option>
|
||||
<option>Vietnamese</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="button" ng-click="verifyLoginCredentials()"
|
||||
class="btn btn-success btn-block">Sign In
|
||||
</button>
|
||||
</div>
|
||||
<a class=" login-changelogs" href="https://go.cyberpanel.net/updates" target='_blank'>
|
||||
<div class="card mb-3" style="max-width: 540px;">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-3">
|
||||
<img src="/static/images/new-design-list-websites-square.png" alt="..." class="object-fit">
|
||||
</div>
|
||||
<div class="col-md-8 ml-5">
|
||||
<div class="card-body d-flex flex-column justify-content-around">
|
||||
<h3 class="card-title mb-5 font-weight-bold">Change Logs</h3>
|
||||
<p class="card-text mt-10">Stay up to date about new releases and features.</p>
|
||||
<h4 class="card-learnmore">
|
||||
<span>
|
||||
Learn More
|
||||
<i>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" aria-hidden="true" focusable="false" data-icon="external-link-alt" role="img" viewBox="0 0 512 512">
|
||||
<path fill="currentColor"
|
||||
d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z" />
|
||||
</svg>
|
||||
</i>
|
||||
</span>
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-app="loginSystem" ng-controller="loginSystem" class="col-md-6 col-sm-12 col-login col-login-right" style="">
|
||||
<div class="login-wrapper">
|
||||
<form id="loginForm" action="/" class="col-md-8 col-md-offset-2">
|
||||
<h1 class="text-transform-upr text-center panel-body text-bold" style="padding-bottom: 0px; color: #33CCCC;">
|
||||
<img class="center-block text-center my-20" src="{% static 'images/cyber-panel-logo.svg' %}">
|
||||
CyberPanel
|
||||
<span class="opacity-80">v 2.1</span>
|
||||
</h1>
|
||||
<h4 class="text-muted text-center mb-10">Web Hosting Control Panel</h4>
|
||||
<div class="">
|
||||
<div class="mx-30">
|
||||
<div class="content-box-wrapper panel-body my-10 mx-30">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-model="username" type="text" class="form-control" name="username" placeholder="Enter username" required style="height: 45px;">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-envelope-o"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-keypress="initiateLogin($event)" ng-model="password" type="password" class="form-control" id="password" placeholder="Password" required name="password" style="height: 45px;">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-unlock-alt"></i>
|
||||
</span>
|
||||
</div>
|
||||
<img id="verifyingLogin" class="center-block" src="{% static 'images/loading.gif' %}">
|
||||
</div>
|
||||
|
||||
<div ng-hide="verifyCode" class="form-group">
|
||||
<div class="input-group">
|
||||
<input ng-model="twofa" type="text" class="form-control" name="twofa" placeholder="Enter code from Google Authenticator" required style="height: 45px;">
|
||||
<span class="input-group-addon bg-blue">
|
||||
<i class="glyph-icon icon-unlock-alt"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<select ng-model="languageSelection" ng-init="languageSelection='english'" class="form-control">
|
||||
<option value="english">English</option>
|
||||
<option>Bangla</option>
|
||||
<option>Bosnian</option>
|
||||
<option>Bulgarian</option>
|
||||
<option>Chinese</option>
|
||||
<option>French</option>
|
||||
<option>German</option>
|
||||
<option>Greek</option>
|
||||
<option>Italian</option>
|
||||
<option>Indonesian</option>
|
||||
<option>Japanese</option>
|
||||
<option>Polish</option>
|
||||
<option>Portuguese</option>
|
||||
<option>Russian</option>
|
||||
<option>Spanish</option>
|
||||
<option>Turkish</option>
|
||||
<option>Vietnamese</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="button" style="background-color: #33CCCC;" ng-click="verifyLoginCredentials()" class="btn btn-success btn-block btn-login">Sign In
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div id="loginFailed" class="alert alert-danger">
|
||||
<p>Could Not Login, Error message: {$ errorMessage $}</p>
|
||||
<p>Could Not Login, Error message: {$ errorMessage $}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.angularjs.org/1.6.5/angular.min.js"></script>
|
||||
<script src="https://code.angularjs.org/1.6.5/angular-route.min.js"></script>
|
||||
<script src="{% static 'loginSystem/login-systen.js' %}"></script>
|
||||
</div>
|
||||
<script src="https://code.angularjs.org/1.6.5/angular.min.js"></script>
|
||||
<script src="https://code.angularjs.org/1.6.5/angular-route.min.js"></script>
|
||||
<script src="{% static 'loginSystem/login-system.js' %}"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@
|
|||
|
||||
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>
|
||||
<script src="{% static 'loginSystem/login-systen.js' %}"></script>
|
||||
<script src="{% static 'loginSystem/login-system.js' %}"></script>
|
||||
|
||||
|
||||
|
||||
|
|
@ -356,4 +356,4 @@
|
|||
<script type="text/javascript" src="{% static 'baseTemplate/assets/widgets/theme-switcher/themeswitcher.js' %}"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ from django.http import HttpResponse
|
|||
from django.utils import translation
|
||||
# Create your views here.
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
def verifyLogin(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
|
|
@ -55,50 +58,42 @@ class MailServerManager(multi.Thread):
|
|||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + ' [MailServerManager.run]')
|
||||
|
||||
def loadEmailHome(self):
|
||||
try:
|
||||
val = self.request.session['userID']
|
||||
return render(self.request, 'mailServer/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/index.html',
|
||||
None, 'createEmail')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def createEmailAccount(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'createEmail') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
||||
{"status": 0}, 'createEmail')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
return render(self.request, "mailServer/createEmailAccount.html", {"status": 0})
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/createEmailAccount.html',
|
||||
{'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/createEmailAccount.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'createEmail')
|
||||
return proc.render()
|
||||
|
||||
def listEmails(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'listEmails') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
||||
{"status": 0}, 'listEmails')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
return render(self.request, "mailServer/listEmails.html", {"status": 0})
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/listEmails.html',
|
||||
{'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/listEmails.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'listEmails')
|
||||
return proc.render()
|
||||
|
||||
def submitEmailCreation(self):
|
||||
try:
|
||||
|
|
@ -142,24 +137,20 @@ class MailServerManager(multi.Thread):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def deleteEmailAccount(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
||||
{"status": 0}, 'deleteEmail')
|
||||
return proc.render()
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'deleteEmail') == 0:
|
||||
return ACLManager.loadError()
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
return render(self.request, "mailServer/deleteEmailAccount.html", {"status": 0})
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/deleteEmailAccount.html',
|
||||
{'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'deleteEmail')
|
||||
return proc.render()
|
||||
|
||||
def getEmailsForDomain(self):
|
||||
try:
|
||||
|
|
@ -284,22 +275,20 @@ class MailServerManager(multi.Thread):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def emailForwarding(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'emailForwarding') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
||||
{"status": 0}, 'emailForwarding')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
return render(self.request, "mailServer/emailForwarding.html", {"status": 0})
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/emailForwarding.html', {'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/emailForwarding.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'emailForwarding')
|
||||
return proc.render()
|
||||
|
||||
def fetchCurrentForwardings(self):
|
||||
try:
|
||||
|
|
@ -573,23 +562,20 @@ class MailServerManager(multi.Thread):
|
|||
#######
|
||||
|
||||
def changeEmailAccountPassword(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'changeEmailPassword') == 0:
|
||||
return ACLManager.loadError()
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
||||
{"status": 0}, 'changeEmailPassword')
|
||||
return proc.render()
|
||||
|
||||
if not os.path.exists('/home/cyberpanel/postfix'):
|
||||
return render(self.request, "mailServer/changeEmailPassword.html", {"status": 0})
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/changeEmailPassword.html',
|
||||
{'websiteList': websitesName, "status": 1})
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/changeEmailPassword.html',
|
||||
{'websiteList': websitesName, "status": 1}, 'changeEmailPassword')
|
||||
return proc.render()
|
||||
|
||||
def submitPasswordChange(self):
|
||||
try:
|
||||
|
|
@ -641,23 +627,17 @@ class MailServerManager(multi.Thread):
|
|||
#######
|
||||
|
||||
def dkimManager(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'dkimManager') == 0:
|
||||
return ACLManager.loadError()
|
||||
openDKIMInstalled = 1
|
||||
|
||||
openDKIMInstalled = 1
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(self.request, 'mailServer/dkimManager.html',
|
||||
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled})
|
||||
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(self.request, 'mailServer/dkimManager.html',
|
||||
{'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}, 'dkimManager')
|
||||
return proc.render()
|
||||
|
||||
def fetchDKIMKeys(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from xml.etree import ElementTree
|
|||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from .phpManager import PHPManager
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
|
@ -29,12 +30,10 @@ def loadPHPHome(request):
|
|||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
proc = httpProc(request, 'managePHP/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
return render(request, 'managePHP/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -43,11 +42,6 @@ def installExtensions(request):
|
|||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if PHP.objects.count() == 0:
|
||||
for i in range(3, 7):
|
||||
php = "php" + str(5) + str(i)
|
||||
|
|
@ -1247,7 +1241,10 @@ def installExtensions(request):
|
|||
except:
|
||||
pass
|
||||
|
||||
return render(request, 'managePHP/installExtensions.html', {'phps': PHPManager.findPHPVersions()})
|
||||
proc = httpProc(request, 'managePHP/installExtensions.html',
|
||||
{'phps': PHPManager.findPHPVersions()}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -1601,14 +1598,10 @@ def getRequestStatusApache(request):
|
|||
def editPHPConfigs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
proc = httpProc(request, 'managePHP/editPHPConfig.html',
|
||||
{'phps': PHPManager.findPHPVersions()}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'managePHP/editPHPConfig.html', {'phps': PHPManager.findPHPVersions()})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
@ -1695,7 +1688,9 @@ def getCurrentPHPConfig(request):
|
|||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
return render(request, 'managePHP/editPHPConfig.html')
|
||||
proc = httpProc(request, 'managePHP/editPHPConfig.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from loginSystem.views import loadLoginPage
|
||||
from plogical.httpProc import httpProc
|
||||
from websiteFunctions.models import Websites, ChildDomains
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
import shlex
|
||||
import subprocess
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def loadSSLHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
return render(request, 'manageSSL/index.html', currentACL)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
proc = httpProc(request, 'manageSSL/index.html',
|
||||
currentACL, 'admin')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def manageSSL(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['manageSSL'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
|
||||
return render(request, 'manageSSL/manageSSL.html', {'websiteList': websitesName})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
proc = httpProc(request, 'manageSSL/manageSSL.html',
|
||||
{'websiteList': websitesName}, 'manageSSL')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def issueSSL(request):
|
||||
|
|
@ -115,22 +97,12 @@ def issueSSL(request):
|
|||
|
||||
|
||||
def sslForHostName(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['hostnameSSL'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID, 1)
|
||||
|
||||
return render(request, 'manageSSL/sslForHostName.html', {'websiteList': websitesName})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID, 1)
|
||||
proc = httpProc(request, 'manageSSL/sslForHostName.html',
|
||||
{'websiteList': websitesName}, 'hostnameSSL')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def obtainHostNameSSL(request):
|
||||
|
|
@ -197,23 +169,15 @@ def obtainHostNameSSL(request):
|
|||
|
||||
|
||||
def sslForMailServer(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
elif currentACL['mailServerSSL'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
websitesName = websitesName + ACLManager.findChildDomains(websitesName)
|
||||
|
||||
return render(request, 'manageSSL/sslForMailServer.html', {'websiteList': websitesName})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'manageSSL/sslForMailServer.html',
|
||||
{'websiteList': websitesName}, 'mailServerSSL')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def obtainMailServerSSL(request):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import HttpResponse, redirect
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
import os
|
||||
import json
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.mailUtilities import mailUtilities
|
||||
from plogical.acl import ACLManager
|
||||
from .models import PDNSStatus, SlaveServers
|
||||
|
|
@ -14,84 +15,41 @@ from plogical.processUtilities import ProcessUtilities
|
|||
# Create your views here.
|
||||
|
||||
def managePowerDNS(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
data = {}
|
||||
data['status'] = 1
|
||||
|
||||
pdnsStatus = PDNSStatus.objects.get(pk=1)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
try:
|
||||
if pdnsStatus.type == 'MASTER':
|
||||
counter = 1
|
||||
|
||||
data = {}
|
||||
data['status'] = 1
|
||||
for items in SlaveServers.objects.all():
|
||||
|
||||
pdnsStatus = PDNSStatus.objects.get(pk=1)
|
||||
|
||||
if pdnsStatus.type == 'MASTER':
|
||||
counter = 1
|
||||
|
||||
for items in SlaveServers.objects.all():
|
||||
|
||||
if counter == 1:
|
||||
data['slaveServer'] = items.slaveServer
|
||||
data['slaveServerIP'] = items.slaveServerIP
|
||||
else:
|
||||
data['slaveServer%s' % (str(counter))] = items.slaveServer
|
||||
data['slaveServerIP%s' % (str(counter))] = items.slaveServerIP
|
||||
|
||||
counter = counter + 1
|
||||
if counter == 1:
|
||||
data['slaveServer'] = items.slaveServer
|
||||
data['slaveServerIP'] = items.slaveServerIP
|
||||
else:
|
||||
data['slaveServerNS'] = pdnsStatus.masterServer
|
||||
data['masterServerIP'] = pdnsStatus.masterIP
|
||||
data['slaveServer%s' % (str(counter))] = items.slaveServer
|
||||
data['slaveServerIP%s' % (str(counter))] = items.slaveServerIP
|
||||
|
||||
return render(request, 'manageServices/managePowerDNS.html', data)
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
counter = counter + 1
|
||||
else:
|
||||
data['slaveServerNS'] = pdnsStatus.masterServer
|
||||
data['masterServerIP'] = pdnsStatus.masterIP
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'manageServices/managePowerDNS.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def managePostfix(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
try:
|
||||
|
||||
return render(request, 'manageServices/managePostfix.html', {"status": 1})
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'manageServices/managePostfix.html',
|
||||
{"status": 1}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def managePureFtpd(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
try:
|
||||
return render(request, 'manageServices/managePureFtpd.html', {"status": 1})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'manageServices/managePureFtpd.html',
|
||||
{"status": 1}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchStatus(request):
|
||||
try:
|
||||
|
|
@ -301,46 +259,33 @@ def saveStatus(request):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def manageApplications(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
services = []
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
## ElasticSearch
|
||||
|
||||
services = []
|
||||
esPath = '/home/cyberpanel/elasticsearch'
|
||||
rPath = '/home/cyberpanel/redis'
|
||||
|
||||
## ElasticSearch
|
||||
if os.path.exists(esPath):
|
||||
installed = 'Installed'
|
||||
else:
|
||||
installed = 'Not-Installed'
|
||||
|
||||
esPath = '/home/cyberpanel/elasticsearch'
|
||||
rPath = '/home/cyberpanel/redis'
|
||||
if os.path.exists(rPath):
|
||||
rInstalled = 'Installed'
|
||||
else:
|
||||
rInstalled = 'Not-Installed'
|
||||
|
||||
if os.path.exists(esPath):
|
||||
installed = 'Installed'
|
||||
else:
|
||||
installed = 'Not-Installed'
|
||||
elasticSearch = {'image': '/static/manageServices/images/elastic-search.png', 'name': 'Elastic Search',
|
||||
'installed': installed}
|
||||
redis = {'image': '/static/manageServices/images/redis.png', 'name': 'Redis',
|
||||
'installed': rInstalled}
|
||||
services.append(elasticSearch)
|
||||
services.append(redis)
|
||||
|
||||
if os.path.exists(rPath):
|
||||
rInstalled = 'Installed'
|
||||
else:
|
||||
rInstalled = 'Not-Installed'
|
||||
|
||||
elasticSearch = {'image': '/static/manageServices/images/elastic-search.png', 'name': 'Elastic Search', 'installed': installed}
|
||||
redis = {'image': '/static/manageServices/images/redis.png', 'name': 'Redis',
|
||||
'installed': rInstalled}
|
||||
services.append(elasticSearch)
|
||||
services.append(redis)
|
||||
|
||||
try:
|
||||
return render(request, 'manageServices/applications.html', {'services': services})
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
return HttpResponse("See CyberCP main log file.")
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'manageServices/applications.html',
|
||||
{'services': services}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def removeInstall(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical import hashPassword
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import redirect
|
||||
from django.http import HttpResponse
|
||||
from loginSystem.views import loadLoginPage
|
||||
from loginSystem.models import Administrator
|
||||
|
|
@ -21,39 +19,24 @@ class PackagesManager:
|
|||
self.request = request
|
||||
|
||||
def packagesHome(self):
|
||||
try:
|
||||
val = self.request.session['userID']
|
||||
return render(self.request, 'packages/index.html', {})
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
proc = httpProc(self.request, 'packages/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def createPacakge(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'createPackage') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
return render(self.request, 'packages/createPackage.html', {"admin": admin.userName})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
userID = self.request.session['userID']
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
proc = httpProc(self.request, 'packages/createPackage.html',
|
||||
{"admin": admin.userName}, 'createPackage')
|
||||
return proc.render()
|
||||
|
||||
def deletePacakge(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'deletePackage') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
return render(self.request, 'packages/deletePackage.html', {"packageList": packageList})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
proc = httpProc(self.request, 'packages/deletePackage.html',
|
||||
{"packageList": packageList}, 'deletePackage')
|
||||
return proc.render()
|
||||
|
||||
def submitPackage(self):
|
||||
try:
|
||||
|
|
@ -134,18 +117,12 @@ class PackagesManager:
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def modifyPackage(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'modifyPackage') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
return render(self.request, 'packages/modifyPackage.html', {"packList": packageList})
|
||||
|
||||
except BaseException as msg:
|
||||
return HttpResponse(str(msg))
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
proc = httpProc(self.request, 'packages/modifyPackage.html',
|
||||
{"packList": packageList}, 'modifyPackage')
|
||||
return proc.render()
|
||||
|
||||
def submitModify(self):
|
||||
try:
|
||||
|
|
@ -225,18 +202,12 @@ class PackagesManager:
|
|||
|
||||
|
||||
def listPackages(self):
|
||||
try:
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if ACLManager.currentContextPermission(currentACL, 'listPackages') == 0:
|
||||
return ACLManager.loadError()
|
||||
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
return render(self.request, 'packages/listPackages.html', {"packList": packageList})
|
||||
|
||||
except BaseException as msg:
|
||||
return redirect(loadLoginPage)
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
packageList = ACLManager.loadPackages(userID, currentACL)
|
||||
proc = httpProc(self.request, 'packages/listPackages.html',
|
||||
{"packList": packageList}, 'listPackages')
|
||||
return proc.render()
|
||||
|
||||
def listPackagesAPI(self,data=None):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -335,7 +335,6 @@ class IncScheduler():
|
|||
message='Backup for %s successfully sent to Google Drive.' % (website.domain)).save()
|
||||
|
||||
os.remove(completeFileToSend)
|
||||
|
||||
except BaseException as msg:
|
||||
GDriveJobLogs(owner=items, status=backupSchedule.ERROR,
|
||||
message='[Site] Site backup failed, Error message: %s.' % (str(msg))).save()
|
||||
|
|
@ -625,11 +624,21 @@ Automatic backup failed for %s on %s.
|
|||
|
||||
ts = time.time()
|
||||
retentionSeconds = 86400 * plan.retention
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key
|
||||
)
|
||||
|
||||
if region.find('http') > -1:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
endpoint_url=region
|
||||
)
|
||||
else:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
)
|
||||
|
||||
bucket = s3.Bucket(plan.bucket)
|
||||
|
||||
for file in bucket.objects.all():
|
||||
|
|
@ -642,12 +651,19 @@ Automatic backup failed for %s on %s.
|
|||
|
||||
###
|
||||
|
||||
client = boto3.client(
|
||||
's3',
|
||||
aws_access_key_id = aws_access_key_id,
|
||||
aws_secret_access_key = aws_secret_access_key,
|
||||
#region_name=region
|
||||
)
|
||||
if region.find('http') > -1:
|
||||
client = boto3.client(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
endpoint_url=region
|
||||
)
|
||||
else:
|
||||
client = boto3.client(
|
||||
's3',
|
||||
aws_access_key_id = aws_access_key_id,
|
||||
aws_secret_access_key = aws_secret_access_key,
|
||||
)
|
||||
|
||||
##
|
||||
|
||||
|
|
@ -666,6 +682,10 @@ Automatic backup failed for %s on %s.
|
|||
extraArgs['data'] = int(PlanConfig['data'])
|
||||
extraArgs['emails'] = int(PlanConfig['emails'])
|
||||
extraArgs['databases'] = int(PlanConfig['databases'])
|
||||
extraArgs['port'] = '0'
|
||||
extraArgs['ip'] = '0'
|
||||
extraArgs['destinationDomain'] = 'None'
|
||||
extraArgs['path'] = '/home/cyberpanel/backups/%s/backup-' % (items.domain) + items.domain + "-" + time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
|
||||
bu = backupUtilities(extraArgs)
|
||||
result, fileName = bu.CloudBackups()
|
||||
|
|
@ -711,6 +731,61 @@ Automatic backup failed for %s on %s.
|
|||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg) + ' [S3Backups.runAWSBackups]')
|
||||
|
||||
@staticmethod
|
||||
def CalculateAndUpdateDiskUsage():
|
||||
for website in Websites.objects.all():
|
||||
try:
|
||||
try:
|
||||
config = json.loads(website.config)
|
||||
except:
|
||||
config = {}
|
||||
|
||||
config['DiskUsage'], config['DiskUsagePercentage'] = virtualHostUtilities.getDiskUsage("/home/" + website.domain, website.package.diskSpace)
|
||||
|
||||
## Calculate bw usage
|
||||
|
||||
from plogical.vhost import vhost
|
||||
config['bwInMB'], config['bwUsage'] = vhost.findDomainBW(website.domain, int(website.package.bandwidth))
|
||||
|
||||
website.config = json.dumps(config)
|
||||
website.save()
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile('%s. [CalculateAndUpdateDiskUsage:753]' % (str(msg)))
|
||||
|
||||
@staticmethod
|
||||
def WPUpdates():
|
||||
from cloudAPI.models import WPDeployments
|
||||
for wp in WPDeployments.objects.all():
|
||||
try:
|
||||
try:
|
||||
config = json.loads(wp.config)
|
||||
except:
|
||||
config = {}
|
||||
|
||||
### Core Updates
|
||||
|
||||
if config['updates'] == 'Minor and Security Updates':
|
||||
command = 'wp core update --minor --allow-root --path=/home/%s/public_html' % (config['domainName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
elif config['updates'] == 'All (minor and major)':
|
||||
command = 'wp core update --allow-root --path=/home/%s/public_html' % (config['domainName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### Plugins, for plugins we will do minor updates only.
|
||||
|
||||
if config['pluginUpdates'] == 'Enabled':
|
||||
command = 'wp plugin update --all --minor --allow-root --path=/home/%s/public_html' % (config['domainName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### Themes, for plugins we will do minor updates only.
|
||||
|
||||
if config['themeUpdates'] == 'Enabled':
|
||||
command = 'wp theme update --all --minor --allow-root --path=/home/%s/public_html' % (config['domainName'])
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException as msg:
|
||||
logging.writeToFile('%s. [WPUpdates:767]' % (str(msg)))
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -724,6 +799,8 @@ def main():
|
|||
IncScheduler.forceRunAWSBackup(args.planName)
|
||||
return 0
|
||||
|
||||
IncScheduler.CalculateAndUpdateDiskUsage()
|
||||
IncScheduler.WPUpdates()
|
||||
IncScheduler.startBackup(args.function)
|
||||
IncScheduler.runGoogleDriveBackups(args.function)
|
||||
IncScheduler.git(args.function)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,34 @@ from dockerManager.models import Containers
|
|||
from re import compile
|
||||
class ACLManager:
|
||||
|
||||
|
||||
AdminACL = '{"adminStatus":1, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser":1 , "resellerCenter": 1, ' \
|
||||
'"changeUserACL": 1, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
||||
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 1, "addDeleteDestinations": 1, "scheDuleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 1, "mailServerSSL": 1 }'
|
||||
|
||||
ResellerACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser": 1 , "resellerCenter": 1, ' \
|
||||
'"changeUserACL": 0, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
||||
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 1, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
||||
|
||||
UserACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 0, "listUsers": 0, "deleteUser": 0 , "resellerCenter": 0, ' \
|
||||
'"changeUserACL": 0, "createWebsite": 0, "modifyWebsite": 0, "suspendWebsite": 0, "deleteWebsite": 0, ' \
|
||||
'"createPackage": 0, "listPackages": 0, "deletePackage": 0, "modifyPackage": 0, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 0, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 0, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
||||
|
||||
@staticmethod
|
||||
def fetchIP():
|
||||
try:
|
||||
|
|
@ -71,78 +99,79 @@ class ACLManager:
|
|||
finalResponse['serverIPAddress'] = serverIPAddress
|
||||
finalResponse['adminName'] = admin.firstName
|
||||
|
||||
if admin.acl.adminStatus == 1:
|
||||
config = json.loads(admin.acl.config)
|
||||
|
||||
if config['adminStatus']:
|
||||
finalResponse['admin'] = 1
|
||||
else:
|
||||
finalResponse['admin'] = 0
|
||||
|
||||
acl = ACL.objects.get(name=admin.acl.name)
|
||||
finalResponse['versionManagement'] = acl.versionManagement
|
||||
finalResponse['versionManagement'] = config['versionManagement']
|
||||
|
||||
## User Management
|
||||
|
||||
finalResponse['createNewUser'] = acl.createNewUser
|
||||
finalResponse['listUsers'] = acl.listUsers
|
||||
finalResponse['deleteUser'] = acl.deleteUser
|
||||
finalResponse['changeUserACL'] = acl.changeUserACL
|
||||
finalResponse['resellerCenter'] = acl.resellerCenter
|
||||
finalResponse['createNewUser'] = config['createNewUser']
|
||||
finalResponse['listUsers'] = config['listUsers']
|
||||
finalResponse['deleteUser'] = config['deleteUser']
|
||||
finalResponse['changeUserACL'] = config['changeUserACL']
|
||||
finalResponse['resellerCenter'] = config['resellerCenter']
|
||||
|
||||
## Website Management
|
||||
|
||||
finalResponse['createWebsite'] = acl.createWebsite
|
||||
finalResponse['modifyWebsite'] = acl.modifyWebsite
|
||||
finalResponse['suspendWebsite'] = acl.suspendWebsite
|
||||
finalResponse['deleteWebsite'] = acl.deleteWebsite
|
||||
finalResponse['createWebsite'] = config['createWebsite']
|
||||
finalResponse['modifyWebsite'] = config['modifyWebsite']
|
||||
finalResponse['suspendWebsite'] = config['suspendWebsite']
|
||||
finalResponse['deleteWebsite'] = config['deleteWebsite']
|
||||
|
||||
## Package Management
|
||||
|
||||
|
||||
finalResponse['createPackage'] = acl.createPackage
|
||||
finalResponse['listPackages'] = acl.listPackages
|
||||
finalResponse['deletePackage'] = acl.deletePackage
|
||||
finalResponse['modifyPackage'] = acl.modifyPackage
|
||||
finalResponse['createPackage'] = config['createPackage']
|
||||
finalResponse['listPackages'] = config['listPackages']
|
||||
finalResponse['deletePackage'] = config['deletePackage']
|
||||
finalResponse['modifyPackage'] = config['modifyPackage']
|
||||
|
||||
## Database Management
|
||||
|
||||
finalResponse['createDatabase'] = acl.createDatabase
|
||||
finalResponse['deleteDatabase'] = acl.deleteDatabase
|
||||
finalResponse['listDatabases'] = acl.listDatabases
|
||||
finalResponse['createDatabase'] = config['createDatabase']
|
||||
finalResponse['deleteDatabase'] = config['deleteDatabase']
|
||||
finalResponse['listDatabases'] = config['listDatabases']
|
||||
|
||||
## DNS Management
|
||||
|
||||
finalResponse['createNameServer'] = acl.createNameServer
|
||||
finalResponse['createDNSZone'] = acl.createDNSZone
|
||||
finalResponse['deleteZone'] = acl.deleteZone
|
||||
finalResponse['addDeleteRecords'] = acl.addDeleteRecords
|
||||
finalResponse['createNameServer'] = config['createNameServer']
|
||||
finalResponse['createDNSZone'] = config['createDNSZone']
|
||||
finalResponse['deleteZone'] = config['deleteZone']
|
||||
finalResponse['addDeleteRecords'] = config['addDeleteRecords']
|
||||
|
||||
## Email Management
|
||||
|
||||
finalResponse['createEmail'] = acl.createEmail
|
||||
finalResponse['listEmails'] = acl.listEmails
|
||||
finalResponse['deleteEmail'] = acl.deleteEmail
|
||||
finalResponse['emailForwarding'] = acl.emailForwarding
|
||||
finalResponse['changeEmailPassword'] = acl.changeEmailPassword
|
||||
finalResponse['dkimManager'] = acl.dkimManager
|
||||
finalResponse['createEmail'] = config['createEmail']
|
||||
finalResponse['listEmails'] = config['listEmails']
|
||||
finalResponse['deleteEmail'] = config['deleteEmail']
|
||||
finalResponse['emailForwarding'] = config['emailForwarding']
|
||||
finalResponse['changeEmailPassword'] = config['changeEmailPassword']
|
||||
finalResponse['dkimManager'] = config['dkimManager']
|
||||
|
||||
## FTP Management
|
||||
|
||||
finalResponse['createFTPAccount'] = acl.createFTPAccount
|
||||
finalResponse['deleteFTPAccount'] = acl.deleteFTPAccount
|
||||
finalResponse['listFTPAccounts'] = acl.listFTPAccounts
|
||||
finalResponse['createFTPAccount'] = config['createFTPAccount']
|
||||
finalResponse['deleteFTPAccount'] = config['deleteFTPAccount']
|
||||
finalResponse['listFTPAccounts'] = config['listFTPAccounts']
|
||||
|
||||
## Backup Management
|
||||
|
||||
finalResponse['createBackup'] = acl.createBackup
|
||||
finalResponse['restoreBackup'] = acl.restoreBackup
|
||||
finalResponse['addDeleteDestinations'] = acl.addDeleteDestinations
|
||||
finalResponse['scheDuleBackups'] = acl.scheDuleBackups
|
||||
finalResponse['remoteBackups'] = acl.remoteBackups
|
||||
finalResponse['createBackup'] = config['createBackup']
|
||||
finalResponse['googleDriveBackups'] = config['googleDriveBackups']
|
||||
finalResponse['restoreBackup'] = config['restoreBackup']
|
||||
finalResponse['addDeleteDestinations'] = config['addDeleteDestinations']
|
||||
finalResponse['scheDuleBackups'] = config['scheDuleBackups']
|
||||
finalResponse['remoteBackups'] = config['remoteBackups']
|
||||
|
||||
## SSL Management
|
||||
|
||||
finalResponse['manageSSL'] = acl.manageSSL
|
||||
finalResponse['hostnameSSL'] = acl.hostnameSSL
|
||||
finalResponse['mailServerSSL'] = acl.mailServerSSL
|
||||
finalResponse['manageSSL'] = config['manageSSL']
|
||||
finalResponse['hostnameSSL'] = config['hostnameSSL']
|
||||
finalResponse['mailServerSSL'] = config['mailServerSSL']
|
||||
|
||||
return finalResponse
|
||||
|
||||
|
|
@ -175,7 +204,7 @@ class ACLManager:
|
|||
|
||||
## Admin ACL
|
||||
|
||||
newACL = ACL(name='admin', adminStatus=1)
|
||||
newACL = ACL(name='admin', adminStatus=1, config=ACLManager.AdminACL)
|
||||
newACL.save()
|
||||
|
||||
## Reseller ACL
|
||||
|
|
@ -193,11 +222,12 @@ class ACLManager:
|
|||
modifyPackage=1,
|
||||
createNameServer=1,
|
||||
restoreBackup=1,
|
||||
config=ACLManager.ResellerACL
|
||||
)
|
||||
newACL.save()
|
||||
|
||||
## User ACL
|
||||
newACL = ACL(name='user')
|
||||
newACL = ACL(name='user', config=ACLManager.UserACL)
|
||||
newACL.save()
|
||||
except:
|
||||
pass
|
||||
|
|
@ -409,35 +439,34 @@ class ACLManager:
|
|||
websiteNames = []
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
allWebsites = Websites.objects.all()
|
||||
allWebsites = Websites.objects.all().order_by('domain')
|
||||
|
||||
for items in allWebsites:
|
||||
websiteNames.append(items.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in items.childdomains_set.all():
|
||||
for child in items.childdomains_set.all().order_by('domain'):
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
else:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
websites = admin.websites_set.all()
|
||||
websites = admin.websites_set.all().order_by('domain')
|
||||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
|
||||
for items in websites:
|
||||
websiteNames.append(items.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in items.childdomains_set.all():
|
||||
for child in items.childdomains_set.all().order_by('domain'):
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
for items in admins:
|
||||
webs = items.websites_set.all()
|
||||
webs = items.websites_set.all().order_by('domain')
|
||||
for web in webs:
|
||||
websiteNames.append(web.domain)
|
||||
|
||||
if fetchChilds:
|
||||
for child in web.childdomains_set.all():
|
||||
for child in web.childdomains_set.all().order_by('domain'):
|
||||
websiteNames.append(child.domain)
|
||||
|
||||
|
||||
|
|
@ -469,13 +498,13 @@ class ACLManager:
|
|||
@staticmethod
|
||||
def findWebsiteObjects(currentACL, userID):
|
||||
if currentACL['admin'] == 1:
|
||||
return Websites.objects.all()
|
||||
return Websites.objects.all().order_by('domain')
|
||||
else:
|
||||
|
||||
websiteList = []
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
websites = admin.websites_set.all()
|
||||
websites = admin.websites_set.all().order_by('domain')
|
||||
|
||||
for items in websites:
|
||||
websiteList.append(items)
|
||||
|
|
@ -483,7 +512,7 @@ class ACLManager:
|
|||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
|
||||
for items in admins:
|
||||
webs = items.websites_set.all()
|
||||
webs = items.websites_set.all().order_by('domain')
|
||||
for web in webs:
|
||||
websiteList.append(web)
|
||||
|
||||
|
|
@ -494,12 +523,12 @@ class ACLManager:
|
|||
domainsList = []
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
domains = Websites.objects.all()
|
||||
domains = Websites.objects.all().order_by('domain')
|
||||
for items in domains:
|
||||
domainsList.append(items.domain)
|
||||
else:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
domains = admin.websites_set.all()
|
||||
domains = admin.websites_set.all().order_by('domain')
|
||||
|
||||
for items in domains:
|
||||
domainsList.append(items.domain)
|
||||
|
|
@ -507,7 +536,7 @@ class ACLManager:
|
|||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
|
||||
for items in admins:
|
||||
doms = items.websites_set.all()
|
||||
doms = items.websites_set.all().order_by('domain')
|
||||
for dom in doms:
|
||||
domainsList.append(dom.domain)
|
||||
|
||||
|
|
@ -518,12 +547,12 @@ class ACLManager:
|
|||
domainsList = []
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
domains = Websites.objects.order_by('domain').all()
|
||||
domains = Websites.objects.all().order_by('domain')
|
||||
for items in domains:
|
||||
domainsList.append(items.domain)
|
||||
else:
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
domains = admin.websites_set.all()
|
||||
domains = admin.websites_set.all().order_by('domain')
|
||||
|
||||
for items in domains:
|
||||
domainsList.append(items.domain)
|
||||
|
|
@ -531,7 +560,7 @@ class ACLManager:
|
|||
admins = Administrator.objects.filter(owner=admin.pk)
|
||||
|
||||
for items in admins:
|
||||
doms = items.websites_set.all()
|
||||
doms = items.websites_set.all().order_by('domain')
|
||||
for dom in doms:
|
||||
domainsList.append(dom.domain)
|
||||
return domainsList
|
||||
|
|
@ -675,7 +704,7 @@ class ACLManager:
|
|||
|
||||
for items in websiteNames:
|
||||
website = Websites.objects.get(domain = items)
|
||||
for childDomain in website.childdomains_set.all():
|
||||
for childDomain in website.childdomains_set.all().order_by('domain'):
|
||||
childDomains.append(childDomain.domain)
|
||||
|
||||
return childDomains
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ from plogical.acl import ACLManager
|
|||
from packages.models import Package
|
||||
from baseTemplate.models import version
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
if not os.geteuid() == 0:
|
||||
sys.exit("\nOnly root can run this script\n")
|
||||
|
|
@ -22,39 +22,54 @@ def main():
|
|||
|
||||
parser = argparse.ArgumentParser(description='Reset admin user password!')
|
||||
parser.add_argument('--password', help='New Password')
|
||||
parser.add_argument('--api', help='Enable/Disable API')
|
||||
args = parser.parse_args()
|
||||
|
||||
adminPass = args.password
|
||||
if args.api != None:
|
||||
if args.api == '1':
|
||||
admin = Administrator.objects.get(userName="admin")
|
||||
admin.api = 1
|
||||
admin.save()
|
||||
print("API Enabled.")
|
||||
else:
|
||||
admin = Administrator.objects.get(userName="admin")
|
||||
admin.api = 0
|
||||
admin.save()
|
||||
print("API Disabled.")
|
||||
else:
|
||||
|
||||
numberOfAdministrator = Administrator.objects.count()
|
||||
if numberOfAdministrator == 0:
|
||||
ACLManager.createDefaultACLs()
|
||||
acl = ACL.objects.get(name='admin')
|
||||
token = hashPassword.generateToken('admin', '1234567')
|
||||
adminPass = args.password
|
||||
|
||||
email = 'usman@cyberpersons.com'
|
||||
admin = Administrator(userName="admin", password=hashPassword.hash_password(adminPass), type=1, email=email,
|
||||
firstName="Cyber", lastName="Panel", acl=acl, token=token)
|
||||
numberOfAdministrator = Administrator.objects.count()
|
||||
if numberOfAdministrator == 0:
|
||||
ACLManager.createDefaultACLs()
|
||||
acl = ACL.objects.get(name='admin')
|
||||
token = hashPassword.generateToken('admin', '1234567')
|
||||
|
||||
email = 'usman@cyberpersons.com'
|
||||
admin = Administrator(userName="admin", password=hashPassword.hash_password(adminPass), type=1, email=email,
|
||||
firstName="Cyber", lastName="Panel", acl=acl, token=token)
|
||||
admin.save()
|
||||
|
||||
vers = version(currentVersion=VERSION, build=BUILD)
|
||||
vers.save()
|
||||
|
||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||
bandwidth=1000, ftpAccounts=1000, dataBases=1000,
|
||||
emailAccounts=1000, allowedDomains=20)
|
||||
package.save()
|
||||
|
||||
|
||||
print("Admin password successfully changed!")
|
||||
return 1
|
||||
|
||||
token = hashPassword.generateToken('admin', adminPass)
|
||||
admin = Administrator.objects.get(userName="admin")
|
||||
admin.password = hashPassword.hash_password(adminPass)
|
||||
admin.token = token
|
||||
admin.save()
|
||||
|
||||
vers = version(currentVersion=VERSION, build=BUILD)
|
||||
vers.save()
|
||||
|
||||
package = Package(admin=admin, packageName="Default", diskSpace=1000,
|
||||
bandwidth=1000, ftpAccounts=1000, dataBases=1000,
|
||||
emailAccounts=1000, allowedDomains=20)
|
||||
package.save()
|
||||
|
||||
print("Admin password successfully changed!")
|
||||
return 1
|
||||
|
||||
token = hashPassword.generateToken('admin', adminPass)
|
||||
admin = Administrator.objects.get(userName="admin")
|
||||
admin.password = hashPassword.hash_password(adminPass)
|
||||
admin.token = token
|
||||
admin.save()
|
||||
|
||||
print("Admin password successfully changed!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/local/CyberCP/bin/python
|
||||
import argparse
|
||||
import os, sys
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
|
|
@ -21,6 +22,8 @@ import hashlib
|
|||
class ApplicationInstaller(multi.Thread):
|
||||
|
||||
LOCALHOST = 'localhost'
|
||||
REMOTE = 0
|
||||
PORT = '3306'
|
||||
|
||||
def __init__(self, installApp, extraArgs):
|
||||
multi.Thread.__init__(self)
|
||||
|
|
@ -384,13 +387,10 @@ $parameters = array(
|
|||
|
||||
def installWPCLI(self):
|
||||
try:
|
||||
command = 'wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
command = 'wget -O /usr/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'chmod +x wp-cli.phar'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'mv wp-cli.phar /usr/bin/wp'
|
||||
command = 'chmod +x /usr/bin/wp'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
except BaseException as msg:
|
||||
|
|
@ -423,9 +423,10 @@ $parameters = array(
|
|||
try:
|
||||
import json
|
||||
jsonData = json.loads(open(passFile, 'r').read())
|
||||
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
ApplicationInstaller.LOCALHOST = mysqlhost
|
||||
ApplicationInstaller.REMOTE = 1
|
||||
ApplicationInstaller.PORT = jsonData['mysqlport']
|
||||
except:
|
||||
pass
|
||||
|
||||
|
|
@ -466,7 +467,6 @@ $parameters = array(
|
|||
def installWordPress(self):
|
||||
try:
|
||||
|
||||
admin = self.extraArgs['admin']
|
||||
domainName = self.extraArgs['domainName']
|
||||
home = self.extraArgs['home']
|
||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
|
|
@ -476,6 +476,7 @@ $parameters = array(
|
|||
adminPassword = self.extraArgs['adminPassword']
|
||||
adminEmail = self.extraArgs['adminEmail']
|
||||
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
### Check WP CLI
|
||||
|
|
@ -520,8 +521,8 @@ $parameters = array(
|
|||
|
||||
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
||||
self.permPath = website.path
|
||||
except BaseException as msg:
|
||||
|
||||
except:
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
externalApp = website.externalApp
|
||||
self.masterDomain = website.domain
|
||||
|
|
@ -544,6 +545,7 @@ $parameters = array(
|
|||
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
||||
self.permPath = '/home/%s/public_html' % (website.domain)
|
||||
|
||||
|
||||
## Security Check
|
||||
|
||||
command = 'chmod 755 %s' % (self.permPath)
|
||||
|
|
@ -567,8 +569,15 @@ $parameters = array(
|
|||
statusFile.writelines('Downloading WordPress Core,30')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp core download --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
try:
|
||||
command = "wp core download --allow-root --path=%s --version=%s" % (finalPath, self.extraArgs['version'])
|
||||
except:
|
||||
command = "wp core download --allow-root --path=" + finalPath
|
||||
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
##
|
||||
|
||||
|
|
@ -576,8 +585,11 @@ $parameters = array(
|
|||
statusFile.writelines('Configuring the installation,40')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST) + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
command = "wp core config --dbname=" + dbName + " --dbuser=" + dbUser + " --dbpass=" + dbPassword + " --dbhost=%s:%s --dbprefix=wp_ --allow-root --path=" % (ApplicationInstaller.LOCALHOST, ApplicationInstaller.PORT) + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
if home == '0':
|
||||
path = self.extraArgs['path']
|
||||
|
|
@ -586,7 +598,10 @@ $parameters = array(
|
|||
finalURL = domainName
|
||||
|
||||
command = 'wp core install --url="http://' + finalURL + '" --title="' + blogTitle + '" --admin_user="' + adminUser + '" --admin_password="' + adminPassword + '" --admin_email="' + adminEmail + '" --allow-root --path=' + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
##
|
||||
|
||||
|
|
@ -595,14 +610,84 @@ $parameters = array(
|
|||
statusFile.close()
|
||||
|
||||
command = "wp plugin install litespeed-cache --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Activating LSCache Plugin,90')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp plugin activate litespeed-cache --allow-root --path=" + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
try:
|
||||
if self.extraArgs['updates']:
|
||||
if self.extraArgs['updates'] == 'Disabled':
|
||||
command = "wp config set WP_AUTO_UPDATE_CORE false --raw --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
elif self.extraArgs['updates'] == 'Minor and Security Updates':
|
||||
command = "wp config set WP_AUTO_UPDATE_CORE minor --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
else:
|
||||
command = "wp config set WP_AUTO_UPDATE_CORE true --raw --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
if self.extraArgs['appsSet'] == 'WordPress + LSCache + Classic Editor':
|
||||
|
||||
command = "wp plugin install classic-editor --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Activating Classic Editor Plugin,90')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp plugin activate classic-editor --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
elif self.extraArgs['appsSet'] == 'WordPress + LSCache + WooCommerce':
|
||||
|
||||
command = "wp plugin install woocommerce --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Activating WooCommerce Plugin,90')
|
||||
statusFile.close()
|
||||
|
||||
command = "wp plugin activate woocommerce --allow-root --path=" + finalPath
|
||||
result = ProcessUtilities.outputExecutioner(command, externalApp)
|
||||
|
||||
if result.find('Success:') == -1:
|
||||
raise BaseException(result)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
##
|
||||
|
||||
|
|
@ -619,18 +704,10 @@ $parameters = array(
|
|||
|
||||
except BaseException as msg:
|
||||
# remove the downloaded files
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
if not os.path.exists(homeDir):
|
||||
command = "chown " + externalApp + ":" + groupName + " " + homeDir
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
from filemanager.filemanager import FileManager
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(self.masterDomain)
|
||||
|
||||
try:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
|
|
@ -639,10 +716,6 @@ $parameters = array(
|
|||
except:
|
||||
pass
|
||||
|
||||
command = 'chmod 750 %s' % (self.permPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
|
|
@ -1217,3 +1290,373 @@ $parameters = array(
|
|||
# statusFile.writelines(str(msg) + " [404]")
|
||||
# statusFile.close()
|
||||
# return 0
|
||||
|
||||
def DeployWordPress(self):
|
||||
try:
|
||||
|
||||
if self.extraArgs['createSite']:
|
||||
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Creating this application..,10')
|
||||
|
||||
## Create site
|
||||
|
||||
import re
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
externalApp = "".join(re.findall("[a-zA-Z]+", self.extraArgs['domain']))[:5] + str(randint(1000, 9999))
|
||||
|
||||
virtualHostUtilities.createVirtualHost(self.extraArgs['domain'], self.extraArgs['email'], 'PHP 7.4',
|
||||
externalApp, 1, 1, 0,
|
||||
'admin', 'Default', 0, tempStatusPath,
|
||||
0)
|
||||
result = open(tempStatusPath, 'r').read()
|
||||
if result.find('[404]') > -1:
|
||||
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Failed to create application. Error: %s [404]' % (result))
|
||||
return 0
|
||||
|
||||
## Install WordPress
|
||||
|
||||
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Installing WordPress.,50')
|
||||
|
||||
currentTemp = self.extraArgs['tempStatusPath']
|
||||
self.extraArgs['domainName'] = self.extraArgs['domain']
|
||||
self.extraArgs['tempStatusPath'] = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
self.extraArgs['blogTitle'] = self.extraArgs['title']
|
||||
self.extraArgs['adminUser'] = self.extraArgs['userName']
|
||||
self.extraArgs['adminPassword'] = self.extraArgs['password']
|
||||
self.extraArgs['adminEmail'] = self.extraArgs['email']
|
||||
|
||||
self.installWordPress()
|
||||
|
||||
result = open(self.extraArgs['tempStatusPath'], 'r').read()
|
||||
if result.find('[404]') > -1:
|
||||
self.extraArgs['tempStatusPath'] = currentTemp
|
||||
raise BaseException('Failed to install WordPress. Error: %s [404]' % (result))
|
||||
|
||||
self.extraArgs['tempStatusPath'] = currentTemp
|
||||
|
||||
|
||||
logging.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
||||
|
||||
try:
|
||||
### Save config in db
|
||||
|
||||
from cloudAPI.models import WPDeployments
|
||||
from websiteFunctions.models import Websites
|
||||
import json
|
||||
|
||||
website = Websites.objects.get(domain=self.extraArgs['domain'])
|
||||
del self.extraArgs['adminPassword']
|
||||
del self.extraArgs['password']
|
||||
del self.extraArgs['tempStatusPath']
|
||||
del self.extraArgs['domain']
|
||||
del self.extraArgs['adminEmail']
|
||||
del self.extraArgs['adminUser']
|
||||
del self.extraArgs['blogTitle']
|
||||
del self.extraArgs['appsSet']
|
||||
|
||||
wpDeploy = WPDeployments(owner=website, config=json.dumps(self.extraArgs))
|
||||
wpDeploy.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
## Set up cron if missing
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
localCronPath = "/var/spool/cron/root"
|
||||
else:
|
||||
localCronPath = "/var/spool/cron/crontabs/root"
|
||||
|
||||
cronData = open(localCronPath, 'r').read()
|
||||
|
||||
if cronData.find('WPAutoUpdates.py') == -1:
|
||||
writeToFile = open(localCronPath, 'a')
|
||||
writeToFile.write('0 12 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/WPAutoUpdates.py\n')
|
||||
writeToFile.close()
|
||||
|
||||
except BaseException as msg:
|
||||
self.extraArgs['websiteName'] = self.extraArgs['domain']
|
||||
from websiteFunctions.website import WebsiteManager
|
||||
wm = WebsiteManager()
|
||||
wm.submitWebsiteDeletion(1, self.extraArgs)
|
||||
logging.statusWriter(self.extraArgs['tempStatusPath'], '%s [404].' % (str(msg)))
|
||||
|
||||
def installWhmcs(self):
|
||||
try:
|
||||
|
||||
admin = self.extraArgs['admin']
|
||||
domainName = self.extraArgs['domainName']
|
||||
home = self.extraArgs['home']
|
||||
firstName = self.extraArgs['firstName']
|
||||
lastName = self.extraArgs['lastName']
|
||||
email = self.extraArgs['email']
|
||||
username = self.extraArgs['username']
|
||||
password = self.extraArgs['password']
|
||||
whmcs_installer = self.extraArgs['whmcsinstallerpath']
|
||||
whmcs_licensekey = self.extraArgs['whmcslicensekey']
|
||||
tempStatusPath = self.extraArgs['tempStatusPath']
|
||||
self.tempStatusPath = tempStatusPath
|
||||
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
## Open Status File
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up paths,0')
|
||||
statusFile.close()
|
||||
|
||||
finalPath = ''
|
||||
self.permPath = ''
|
||||
|
||||
try:
|
||||
website = ChildDomains.objects.get(domain=domainName)
|
||||
externalApp = website.master.externalApp
|
||||
self.masterDomain = website.master.domain
|
||||
|
||||
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:
|
||||
raise BaseException("Maximum database limit reached for this website.")
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up Database,20')
|
||||
statusFile.close()
|
||||
|
||||
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website.master)
|
||||
self.permPath = website.path
|
||||
|
||||
except:
|
||||
website = Websites.objects.get(domain=domainName)
|
||||
externalApp = website.externalApp
|
||||
self.masterDomain = website.domain
|
||||
|
||||
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:
|
||||
raise BaseException("Maximum database limit reached for this website.")
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Setting up Database,20')
|
||||
statusFile.close()
|
||||
|
||||
dbName, dbUser, dbPassword = self.dbCreation(tempStatusPath, website)
|
||||
self.permPath = '/home/%s/public_html' % (website.domain)
|
||||
|
||||
## Security Check
|
||||
|
||||
command = 'chmod 755 %s' % (self.permPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if finalPath.find("..") > -1:
|
||||
raise BaseException('Specified path must be inside virtual host home.')
|
||||
|
||||
if not os.path.exists(finalPath):
|
||||
command = 'mkdir -p ' + finalPath
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
## checking for directories/files
|
||||
|
||||
if self.dataLossCheck(finalPath, tempStatusPath) == 0:
|
||||
raise BaseException('Directory is not empty.')
|
||||
|
||||
####
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Extracting WHMCS Installer zip..,30')
|
||||
statusFile.close()
|
||||
command = "unzip -qq %s -d %s" % (whmcs_installer, 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 WHMCS..,60')
|
||||
statusFile.close()
|
||||
|
||||
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
# Walk through whmcs webinstaller via curl with all except errors hidden https://stackoverflow.com/a/49502232
|
||||
# Accept EULA and generate configuration.php
|
||||
command = "curl %s/install/install.php?step=2 --insecure --silent --output /dev/null --show-error --fail" % (finalURL)
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
command = "curl %s/install/install.php?step=2 --insecure --silent --output /dev/null --show-error --fail" % (finalURL)
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
command = "mv %s/configuration.php.new %s/configuration.php" % (finalPath, finalPath)
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
# Post database and license information to webinstaller form
|
||||
command = """
|
||||
curl %s/install/install.php?step=4" \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data "licenseKey=%s&databaseHost=localhost&databasePort=&databaseUsername=%s&databasePassword=%s&databaseName=%s" \
|
||||
--compressed \
|
||||
--insecure \
|
||||
--silent \
|
||||
--output /dev/null \
|
||||
--show-error \
|
||||
--fail
|
||||
""" % (whmcs_licensekey, dbUser, dbPassword, dbName)
|
||||
|
||||
# Post admin user and password information to webinstaller form
|
||||
command = """
|
||||
curl %s/install/install.php?step=5" \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data "firstName=%s&lastName=%s&email=%s&username=%s&password=%s&confirmPassword=%s" \
|
||||
--compressed \
|
||||
--insecure \
|
||||
--silent \
|
||||
--output /dev/null \
|
||||
--show-error \
|
||||
--fail
|
||||
""" % (firstName, lastName, email, username, password, password)
|
||||
|
||||
##
|
||||
|
||||
command = "rm -rf " + finalPath + "install"
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
|
||||
### Update whmcs urls to siteurl
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Update whmcs urls to siteurl..,70')
|
||||
statusFile.close()
|
||||
|
||||
try:
|
||||
|
||||
import MySQLdb.cursors as cursors
|
||||
import MySQLdb as mysql
|
||||
|
||||
conn = mysql.connect(host='localhost', user=dbUser, passwd=dbPassword, port=3306,
|
||||
cursorclass=cursors.SSCursor)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='SystemURL';" % (dbName, finalURL))
|
||||
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='Domain';" % (dbName, finalURL))
|
||||
cursor.execute("use %s;UPDATE tblconfiguration SET value='%s' WHERE setting='SystemSSLURL';" % (dbName, finalURL))
|
||||
|
||||
conn.close()
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg))
|
||||
|
||||
|
||||
|
||||
# Secure WHMCS configuration.php file : https://docs.whmcs.com/Further_Security_Steps#Secure_the_configuration.php_File
|
||||
command = "chmod 400 %s/configuration.php" % (finalPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
##
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
fm = FileManager(None, None)
|
||||
fm.fixPermissions(self.masterDomain)
|
||||
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines("Successfully Installed. [200]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
# remove the downloaded files
|
||||
|
||||
homeDir = "/home/" + domainName + "/public_html"
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
groupName = 'nobody'
|
||||
else:
|
||||
groupName = 'nogroup'
|
||||
|
||||
if not os.path.exists(homeDir):
|
||||
command = "chown -R " + externalApp + ":" + groupName + " " + homeDir
|
||||
ProcessUtilities.executioner(command, externalApp)
|
||||
|
||||
try:
|
||||
mysqlUtilities.deleteDatabase(dbName, dbUser)
|
||||
db = Databases.objects.get(dbName=dbName)
|
||||
db.delete()
|
||||
except:
|
||||
pass
|
||||
|
||||
command = 'chmod 750 %s' % (self.permPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
statusFile = open(self.tempStatusPath, 'w')
|
||||
statusFile.writelines(str(msg) + " [404]")
|
||||
statusFile.close()
|
||||
return 0
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Application Installer')
|
||||
parser.add_argument('function', help='Specify a function to call!')
|
||||
parser.add_argument('--tempStatusPath', help='')
|
||||
parser.add_argument('--appsSet', help='')
|
||||
parser.add_argument('--domain', help='')
|
||||
parser.add_argument('--email', help='')
|
||||
parser.add_argument('--password', help='')
|
||||
parser.add_argument('--pluginUpdates', help='')
|
||||
parser.add_argument('--themeUpdates', help='')
|
||||
parser.add_argument('--title', help='')
|
||||
parser.add_argument('--updates', help='')
|
||||
parser.add_argument('--userName', help='')
|
||||
parser.add_argument('--version', help='')
|
||||
parser.add_argument('--path', help='')
|
||||
parser.add_argument('--createSite', help='')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "DeployWordPress":
|
||||
|
||||
extraArgs = {}
|
||||
extraArgs['domain'] = args.domain
|
||||
extraArgs['tempStatusPath'] = args.tempStatusPath
|
||||
extraArgs['appsSet'] = args.appsSet
|
||||
extraArgs['email'] = args.email
|
||||
extraArgs['password'] = args.password
|
||||
extraArgs['pluginUpdates'] = args.pluginUpdates
|
||||
extraArgs['themeUpdates'] = args.themeUpdates
|
||||
extraArgs['title'] = args.title
|
||||
extraArgs['updates'] = args.updates
|
||||
extraArgs['userName'] = args.userName
|
||||
extraArgs['version'] = args.version
|
||||
extraArgs['createSite'] = int(args.createSite)
|
||||
|
||||
if args.path != None:
|
||||
extraArgs['path'] = args.path
|
||||
extraArgs['home'] = '0'
|
||||
else:
|
||||
extraArgs['home'] = '1'
|
||||
|
||||
ai = ApplicationInstaller(None, extraArgs)
|
||||
ai.DeployWordPress()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -48,8 +48,8 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
|
||||
## I am not the monster that you think I am..
|
||||
|
|
@ -1425,7 +1425,7 @@ class backupUtilities:
|
|||
self.cpu = backupUtilities.CPUDefault
|
||||
self.time = int(backupUtilities.time)
|
||||
|
||||
self.BackupPath = '/home/cyberpanel/backups/%s/backup-' % (self.extraArgs['domain']) + self.extraArgs['domain'] + "-" + time.strftime("%m.%d.%Y_%H-%M-%S")
|
||||
self.BackupPath = self.extraArgs['path']
|
||||
self.website = Websites.objects.get(domain=self.extraArgs['domain'])
|
||||
|
||||
command = 'mkdir -p %s' % (self.BackupPath)
|
||||
|
|
@ -1486,6 +1486,13 @@ class backupUtilities:
|
|||
command = 'chmod 600:600 %s' % (finalPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if self.extraArgs['port'] != 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Sending file to destination server..,90')
|
||||
|
||||
command = "scp -o StrictHostKeyChecking=no -P %s -i /root/.ssh/cyberpanel %s root@%s:/home/cyberpanel/backups/%s/" % (self.extraArgs['port'], finalPath, self.extraArgs['ip'], self.extraArgs['destinationDomain'])
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
||||
|
||||
return 1, self.BackupPath + '.tar.gz'
|
||||
|
|
@ -1548,9 +1555,14 @@ class backupUtilities:
|
|||
command = 'rm -rf %s' % (homePath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'mv %s/%s %s' % (self.dataPath, self.website.domain, '/home')
|
||||
if self.extraArgs['sourceDomain'] == 'None':
|
||||
command = 'mv %s/%s %s' % (self.dataPath, self.website.domain, '/home')
|
||||
else:
|
||||
command = 'mv %s/%s %s/%s' % (self.dataPath, self.extraArgs['sourceDomain'], '/home', self.extraArgs['domain'])
|
||||
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
from filemanager.filemanager import FileManager
|
||||
|
||||
fm = FileManager(None, None)
|
||||
|
|
@ -1614,6 +1626,34 @@ class backupUtilities:
|
|||
|
||||
mysqlUtilities.mysqlUtilities.restoreDatabaseBackup(db['databaseName'], self.databasesPath, db['password'])
|
||||
|
||||
if self.extraArgs['sourceDomain'] != 'None':
|
||||
if self.extraArgs['sourceDomain'] != self.extraArgs['domain']:
|
||||
|
||||
try:
|
||||
command = 'wp --info'
|
||||
outout = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if not outout.find('WP-CLI root dir:') > -1:
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
ai = ApplicationInstaller(None, None)
|
||||
ai.installWPCLI()
|
||||
except subprocess.CalledProcessError:
|
||||
from plogical.applicationInstaller import ApplicationInstaller
|
||||
ai = ApplicationInstaller(None, None)
|
||||
ai.installWPCLI()
|
||||
|
||||
path = '/home/%s/public_html' % (self.extraArgs['domain'])
|
||||
command = "wp search-replace '%s' '%s' --path=%s --allow-root" % (self.extraArgs['sourceDomain'], self.extraArgs['domain'], path)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
command = "wp search-replace 'www.%s' '%s' --path=%s --allow-root" % (
|
||||
self.extraArgs['sourceDomain'], self.extraArgs['domain'], path)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
command = "wp search-replace 'www.%s' '%s' --path=%s --allow-root" % (
|
||||
self.extraArgs['domain'], self.extraArgs['domain'], path)
|
||||
ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
|
||||
command = 'rm -rf %s' % (self.extractedPath)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
|
@ -1661,10 +1701,18 @@ class backupUtilities:
|
|||
|
||||
aws_access_key_id, aws_secret_access_key, region = self.fetchAWSKeys()
|
||||
|
||||
s3 = boto3.resource(
|
||||
if region.find('http') > -1:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
endpoint_url=region
|
||||
)
|
||||
else:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
)
|
||||
|
||||
self.BackupPath = '/home/cyberpanel/backups/%s/%s' % (self.extraArgs['domain'], self.extraArgs['backupFile'].split('/')[-1])
|
||||
|
|
@ -2030,6 +2078,10 @@ def main():
|
|||
parser.add_argument('--data', help='')
|
||||
parser.add_argument('--emails', help='')
|
||||
parser.add_argument('--databases', help='')
|
||||
parser.add_argument('--path', help='')
|
||||
parser.add_argument('--ip', help='')
|
||||
parser.add_argument('--sourceDomain', help='')
|
||||
parser.add_argument('--destinationDomain', help='')
|
||||
|
||||
## FOR S3
|
||||
|
||||
|
|
@ -2059,13 +2111,19 @@ def main():
|
|||
extraArgs['data'] = int(args.data)
|
||||
extraArgs['emails'] = int(args.emails)
|
||||
extraArgs['databases'] = int(args.databases)
|
||||
extraArgs['path'] = args.path
|
||||
extraArgs['port'] = args.port
|
||||
extraArgs['ip'] = args.ip
|
||||
extraArgs['destinationDomain'] = args.destinationDomain
|
||||
bu = backupUtilities(extraArgs)
|
||||
bu.CloudBackups()
|
||||
|
||||
elif args.function == 'SubmitCloudBackupRestore':
|
||||
extraArgs = {}
|
||||
extraArgs['domain'] = args.backupDomain
|
||||
extraArgs['tempStatusPath'] = args.tempStoragePath
|
||||
extraArgs['backupFile'] = args.backupFile
|
||||
extraArgs['sourceDomain'] = args.sourceDomain
|
||||
bu = backupUtilities(extraArgs)
|
||||
bu.SubmitCloudBackupRestore()
|
||||
elif args.function == 'SubmitS3BackupRestore':
|
||||
|
|
@ -2077,6 +2135,5 @@ def main():
|
|||
bu = backupUtilities(extraArgs)
|
||||
bu.SubmitS3BackupRestore()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -51,6 +51,33 @@ class cPanelImporter:
|
|||
self.mailFormat = 1
|
||||
self.externalApp = ''
|
||||
|
||||
## New
|
||||
|
||||
self.MainSite = []
|
||||
self.OtherDomains = []
|
||||
self.OtherDomainNames = []
|
||||
self.InheritPHP = ''
|
||||
|
||||
def LoadDomains(self):
|
||||
try:
|
||||
###
|
||||
CompletPathToExtractedArchive = cPanelImporter.mainBackupPath + self.fileName
|
||||
### Find Domain Name
|
||||
import json
|
||||
UserData = json.loads(open('%s/userdata/cache.json' % (CompletPathToExtractedArchive), 'r').read())
|
||||
|
||||
for key, value in UserData.items():
|
||||
if value[2] == 'main':
|
||||
self.MainSite = value
|
||||
self.PHPVersion = value[9]
|
||||
self.InheritPHP = self.PHPDecider()
|
||||
else:
|
||||
self.OtherDomainNames.append(key)
|
||||
self.OtherDomains.append(value)
|
||||
|
||||
except BaseException as msg:
|
||||
print(str(msg))
|
||||
|
||||
def PHPDecider(self):
|
||||
|
||||
if self.PHPVersion == 'inherit':
|
||||
|
|
@ -73,9 +100,13 @@ class cPanelImporter:
|
|||
self.PHPVersion = 'PHP 7.3'
|
||||
elif self.PHPVersion.find('74') > -1:
|
||||
self.PHPVersion = 'PHP 7.4'
|
||||
elif self.PHPVersion.find('80') > -1:
|
||||
self.PHPVersion = 'PHP 8.0'
|
||||
|
||||
if self.PHPVersion == '':
|
||||
self.PHPVersion = 'PHP 7.1'
|
||||
self.PHPVersion = self.InheritPHP
|
||||
|
||||
return self.PHPVersion
|
||||
|
||||
def SetupSSL(self, path, domain):
|
||||
|
||||
|
|
@ -153,19 +184,14 @@ class cPanelImporter:
|
|||
message = 'Creating main account from archive file: %s' % (self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
## Paths
|
||||
|
||||
DomainName = self.MainSite[3]
|
||||
self.mainDomain = DomainName
|
||||
CompletPathToExtractedArchive = cPanelImporter.mainBackupPath + self.fileName
|
||||
DomainMeta = '%s/userdata/%s' % (CompletPathToExtractedArchive, DomainName)
|
||||
|
||||
### Find Domain Name
|
||||
UserData = '%s/userdata/main' % (CompletPathToExtractedArchive)
|
||||
|
||||
data = open(UserData, 'r').readlines()
|
||||
DomainName = ''
|
||||
|
||||
for items in data:
|
||||
if items.find('main_domain') > -1:
|
||||
DomainName = items.split(' ')[-1].replace('\n', '')
|
||||
self.mainDomain = DomainName
|
||||
break
|
||||
|
||||
message = 'Detected main domain for this file is: %s.' % (DomainName)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
|
@ -175,20 +201,8 @@ class cPanelImporter:
|
|||
message = 'Finding PHP version for %s.' % (DomainName)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
DomainMeta = '%s/userdata/%s' % (CompletPathToExtractedArchive, DomainName)
|
||||
|
||||
data = open(DomainMeta, 'r').readlines()
|
||||
phpChecker = 1
|
||||
|
||||
for items in data:
|
||||
if items.find('phpversion') > -1:
|
||||
self.PHPVersion = items.split(' ')[-1].replace('\n', '')
|
||||
self.PHPDecider()
|
||||
phpChecker = 0
|
||||
break
|
||||
|
||||
if phpChecker:
|
||||
self.PHPDecider()
|
||||
self.PHPVersion = self.MainSite[9]
|
||||
self.PHPDecider()
|
||||
|
||||
message = 'PHP version of %s is %s.' % (DomainName, self.PHPVersion)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
|
@ -227,7 +241,7 @@ class cPanelImporter:
|
|||
time.sleep(2)
|
||||
|
||||
|
||||
result = virtualHostUtilities.createVirtualHost(DomainName, self.email, self.PHPVersion, self.externalApp, 0, 0,
|
||||
result = virtualHostUtilities.createVirtualHost(DomainName, self.email, self.PHPVersion, self.externalApp, 1, 0,
|
||||
0, 'admin', 'Default', 0)
|
||||
|
||||
if result[0] == 1:
|
||||
|
|
@ -262,32 +276,17 @@ class cPanelImporter:
|
|||
message = 'Restoring document root files for %s.' % (DomainName)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
data = open(DomainMeta, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('homedir') > -1:
|
||||
self.homeDir = items.split(' ')[-1].replace('\n', '')
|
||||
break
|
||||
|
||||
data = open(DomainMeta, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('documentroot') > -1:
|
||||
self.documentRoot = items.split(' ')[-1].replace('\n', '')
|
||||
break
|
||||
self.homeDir = self.MainSite[4].replace('/home/%s/' % (self.MainSite[0]), '')
|
||||
|
||||
nowPath = '/home/%s/public_html' % (DomainName)
|
||||
if os.path.exists(nowPath):
|
||||
shutil.rmtree(nowPath)
|
||||
|
||||
movePath = '%s/homedir/%s' % (
|
||||
CompletPathToExtractedArchive, self.documentRoot.replace(self.homeDir, '', 1).replace('/', ''))
|
||||
CompletPathToExtractedArchive, self.homeDir)
|
||||
|
||||
shutil.copytree(movePath, nowPath, symlinks=True)
|
||||
|
||||
command = 'chown -R %s:%s %s' % (self.externalApp, self.externalApp, nowPath)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
message = 'Main site %s created from archive file: %s' % (DomainName, self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
|
|
@ -312,51 +311,12 @@ class cPanelImporter:
|
|||
message = 'Finding Addon/Subdomains from backup file %s. Account main domain was %s.' % (self.backupFile, self.mainDomain)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
UserData = '%s/userdata/main' % (CompletPathToExtractedArchive)
|
||||
|
||||
data = open(UserData, 'r').readlines()
|
||||
Domains = []
|
||||
addonStatus = 0
|
||||
subDomainsStatus = 0
|
||||
|
||||
for items in data:
|
||||
if items.find('addon_domains') > -1:
|
||||
addonStatus = 1
|
||||
continue
|
||||
|
||||
if addonStatus == 1:
|
||||
if items.find('main_domain') > -1:
|
||||
addonStatus = 0
|
||||
continue
|
||||
else:
|
||||
cDomain = items.split(':')[0].replace(' ', '')
|
||||
if len(cDomain) < 2:
|
||||
continue
|
||||
Domains.append(ChildDomains(cDomain, 1))
|
||||
continue
|
||||
|
||||
##
|
||||
|
||||
if items.find('sub_domains') > -1:
|
||||
subDomainsStatus = 1
|
||||
continue
|
||||
|
||||
existCheck = 0
|
||||
if subDomainsStatus == 1:
|
||||
cDomain = items.split(' ')[-1].replace('\n', '')
|
||||
for items in Domains:
|
||||
if cDomain.find(items.domain) > -1:
|
||||
existCheck = 1
|
||||
if existCheck == 0:
|
||||
if len(cDomain) > 2:
|
||||
Domains.append(ChildDomains(cDomain, 0))
|
||||
|
||||
message = 'Following Addon/Subdomains found for backup file %s. Account main domain was %s.' % (
|
||||
self.backupFile, self.mainDomain)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
for items in Domains:
|
||||
print(items.domain)
|
||||
for items in self.OtherDomainNames:
|
||||
print(items)
|
||||
|
||||
## Starting Child-domains creation
|
||||
|
||||
|
|
@ -364,116 +324,87 @@ class cPanelImporter:
|
|||
self.backupFile, self.mainDomain)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
for items in Domains:
|
||||
counter = 0
|
||||
|
||||
for items in self.OtherDomainNames:
|
||||
|
||||
try:
|
||||
|
||||
message = 'Creating %s.' % (items.domain)
|
||||
message = 'Creating %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
path = '/home/' + self.mainDomain + '/public_html/' + items.domain
|
||||
path = '/home/' + self.mainDomain + '/' + items
|
||||
|
||||
## Find PHP Version
|
||||
|
||||
if items.addon == 1:
|
||||
DomainMeta = '%s/userdata/%s.%s' % (CompletPathToExtractedArchive, items.domain, self.mainDomain)
|
||||
else:
|
||||
DomainMeta = '%s/userdata/%s' % (CompletPathToExtractedArchive, items.domain)
|
||||
self.PHPVersion = self.OtherDomains[counter][9]
|
||||
self.PHPDecider()
|
||||
|
||||
data = open(DomainMeta, 'r').readlines()
|
||||
phpChecker = 1
|
||||
for it in data:
|
||||
if it.find('phpversion') > -1:
|
||||
self.PHPVersion = it.split(' ')[-1].replace('\n', '')
|
||||
self.PHPDecider()
|
||||
phpChecker = 0
|
||||
break
|
||||
|
||||
if phpChecker:
|
||||
self.PHPDecider()
|
||||
|
||||
message = 'Calling core to create %s.' % (items.domain)
|
||||
message = 'Calling core to create %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
result = virtualHostUtilities.createDomain(self.mainDomain, items.domain, self.PHPVersion, path, 0, 0,
|
||||
result = virtualHostUtilities.createDomain(self.mainDomain, items, self.PHPVersion, path, 1, 0,
|
||||
0, 'admin', 0)
|
||||
|
||||
if result[0] == 1:
|
||||
message = 'Child domain %s created from archive file: %s' % (items.domain, self.backupFile)
|
||||
message = 'Child domain %s created from archive file: %s' % (items, self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
else:
|
||||
message = 'Failed to create Child domain %s from archive file: %s' % (items.domain, self.backupFile)
|
||||
message = 'Failed to create Child domain %s from archive file: %s' % (items, self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
|
||||
|
||||
## Setup SSL
|
||||
|
||||
message = 'Detecting SSL for %s.' % (items.domain)
|
||||
message = 'Detecting SSL for %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
SSLPath = '%s/apache_tls/%s' % (CompletPathToExtractedArchive, items.domain)
|
||||
SSLPath = '%s/apache_tls/%s' % (CompletPathToExtractedArchive, items)
|
||||
|
||||
if os.path.exists(SSLPath):
|
||||
message = 'SSL found for %s, setting up.' % (items.domain)
|
||||
message = 'SSL found for %s, setting up.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
self.SetupSSL(SSLPath, items.domain)
|
||||
message = 'SSL set up OK for %s.' % (items.domain)
|
||||
self.SetupSSL(SSLPath, items)
|
||||
message = 'SSL set up OK for %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
else:
|
||||
SSLPath = '%s/apache_tls/%s.%s' % (CompletPathToExtractedArchive, items.domain, self.mainDomain)
|
||||
SSLPath = '%s/apache_tls/%s.%s' % (CompletPathToExtractedArchive, items, self.mainDomain)
|
||||
if os.path.exists(SSLPath):
|
||||
message = 'SSL found for %s, setting up.' % (items.domain)
|
||||
message = 'SSL found for %s, setting up.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
self.SetupSSL(SSLPath, items.domain)
|
||||
message = 'SSL set up OK for %s.' % (items.domain)
|
||||
self.SetupSSL(SSLPath, items)
|
||||
message = 'SSL set up OK for %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
else:
|
||||
message = 'SSL not detected for %s, you can later issue SSL from Manage SSL in CyberPanel.' % (
|
||||
items.domain)
|
||||
items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
|
||||
## Creating Document root for childs
|
||||
|
||||
message = 'Restoring document root files for %s.' % (items.domain)
|
||||
message = 'Restoring document root files for %s.' % (items)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
externalApp = "".join(re.findall("[a-zA-Z]+", self.mainDomain))[:7]
|
||||
|
||||
data = open(DomainMeta, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find('documentroot') > -1:
|
||||
ChildDocRoot = items.split(' ')[-1].replace('\n', '')
|
||||
break
|
||||
ChildDocRoot = self.OtherDomains[counter][4].replace('/home/%s/' % (self.MainSite[0]), '')
|
||||
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
movePath = '%s/homedir/public_html/%s' % (
|
||||
CompletPathToExtractedArchive, ChildDocRoot.replace(self.documentRoot, '', 1).replace('/', ''))
|
||||
movePath = '%s/homedir/%s' % (CompletPathToExtractedArchive, ChildDocRoot)
|
||||
logging.statusWriter(self.logFile, 'Document root in cPanel Backup for %s is %s' % (items, movePath), 1)
|
||||
|
||||
if os.path.exists(movePath):
|
||||
shutil.move(movePath, path)
|
||||
else:
|
||||
movePath = '%s/homedir/%s' % (
|
||||
CompletPathToExtractedArchive, ChildDocRoot.split('/')[-1].replace(self.documentRoot, '', 1).replace('/', ''))
|
||||
if os.path.exists(movePath):
|
||||
shutil.move(movePath, path)
|
||||
else:
|
||||
movePath = '%s/homedir/%s' % (
|
||||
CompletPathToExtractedArchive, items.domain)
|
||||
shutil.move(movePath, path)
|
||||
|
||||
command = 'chown -R %s:%s %s' % (externalApp, externalApp, path)
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
shutil.copytree(movePath, path)
|
||||
|
||||
message = 'Successfully created child domain.'
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
counter = counter + 1
|
||||
|
||||
except BaseException as msg:
|
||||
message = 'Failed to create child domain from backup file %s, error message: %s. Moving on..' % (
|
||||
self.backupFile, str(msg))
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
counter = counter + 1
|
||||
|
||||
return 1
|
||||
|
||||
|
|
@ -768,47 +699,6 @@ class cPanelImporter:
|
|||
logging.statusWriter(self.logFile, message, 1)
|
||||
return 0
|
||||
|
||||
def MainController(self):
|
||||
|
||||
if self.ExtractBackup():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.CreateMainWebsite():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.CreateChildDomains():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.CreateDNSRecords():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
if self.RestoreDatabases():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.createCronJobs():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
self.RestoreEmails()
|
||||
self.FixPermissions()
|
||||
|
||||
message = 'Backup file %s successfully restored.' % (self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
return 1
|
||||
|
||||
def DeleteSite(self):
|
||||
vhost.deleteVirtualHostConfigurations(self.mainDomain)
|
||||
|
||||
|
|
@ -936,6 +826,48 @@ class cPanelImporter:
|
|||
logging.statusWriter(self.logFile, message, 1)
|
||||
return 0
|
||||
|
||||
def MainController(self):
|
||||
|
||||
if self.ExtractBackup():
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
self.LoadDomains()
|
||||
|
||||
if self.CreateMainWebsite():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.CreateChildDomains():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.CreateDNSRecords():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.RestoreDatabases():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
if self.createCronJobs():
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
|
||||
self.RestoreEmails()
|
||||
self.FixPermissions()
|
||||
|
||||
message = 'Backup file %s successfully restored.' % (self.backupFile)
|
||||
logging.statusWriter(self.logFile, message, 1)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def main():
|
||||
LogFile = '/home/cyberpanel/%s' % (str(randint(1000, 9999)))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class DNS:
|
|||
self.status = data[2].rstrip('\n')
|
||||
return 1
|
||||
else:
|
||||
logging.CyberCPLogFileWriter.writeToFile('User %s does not have CoudFlare configured.' % (self.admin.userName))
|
||||
logging.CyberCPLogFileWriter.writeToFile('User %s does not have CloudFlare configured.' % (self.admin.userName))
|
||||
return 0
|
||||
|
||||
def cfTemplate(self, zoneDomain, admin, enableCheck=None):
|
||||
|
|
@ -637,8 +637,12 @@ class DNS:
|
|||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
command = 'ls -la /etc/systemd/system/multi-user.target.wants/pdns.service'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('No such file') == -1:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
return
|
||||
|
||||
|
|
@ -656,8 +660,12 @@ class DNS:
|
|||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
command = 'ls -la /etc/systemd/system/multi-user.target.wants/pdns.service'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('No such file') == -1:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
return
|
||||
|
||||
if type == 'MX':
|
||||
|
|
@ -673,8 +681,12 @@ class DNS:
|
|||
record.save()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
command = 'ls -la /etc/systemd/system/multi-user.target.wants/pdns.service'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('No such file') == -1:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
return
|
||||
|
||||
if Records.objects.filter(name=name, type=type).count() == 0:
|
||||
|
|
@ -689,8 +701,13 @@ class DNS:
|
|||
auth=1)
|
||||
record.save()
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'ls -la /etc/systemd/system/multi-user.target.wants/pdns.service'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('No such file') == -1:
|
||||
command = 'sudo systemctl restart pdns'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
## Add Record to CF if SYNC Enabled
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,45 @@ from django.shortcuts import render, HttpResponse
|
|||
import json
|
||||
|
||||
class httpProc:
|
||||
def __init__(self, request, templateName, data = None):
|
||||
def __init__(self, request, templateName, data = None, function = None):
|
||||
self.request = request
|
||||
self.templateName = templateName
|
||||
self.data = data
|
||||
self.function = function
|
||||
|
||||
|
||||
def render(self):
|
||||
try:
|
||||
from loginSystem.models import Administrator
|
||||
from plogical.acl import ACLManager
|
||||
userID = self.request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
### Permissions Check
|
||||
|
||||
if self.function != None:
|
||||
if not currentACL['admin']:
|
||||
if not currentACL[self.function]:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': 'You are not authorized to access %s' % (self.function)})
|
||||
|
||||
###
|
||||
|
||||
if self.data == None:
|
||||
self.data = {}
|
||||
|
||||
ipFile = "/etc/cyberpanel/machineIP"
|
||||
f = open(ipFile)
|
||||
ipData = f.read()
|
||||
ipAddress = ipData.split('\n', 1)[0]
|
||||
self.data['ipAddress'] = ipAddress
|
||||
|
||||
self.data.update(currentACL)
|
||||
|
||||
return render(self.request, self.templateName, self.data)
|
||||
except BaseException as msg:
|
||||
templateName = 'baseTemplate/error.html'
|
||||
return render(self.request, templateName, {'error_message': str(msg)})
|
||||
|
||||
def renderPre(self):
|
||||
if self.data == None:
|
||||
|
|
@ -42,3 +77,6 @@ class httpProc:
|
|||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class mysqlUtilities:
|
|||
|
||||
LOCALHOST = 'localhost'
|
||||
RDS = 0
|
||||
REMOTEHOST = ''
|
||||
|
||||
@staticmethod
|
||||
def getPagination(records, toShow):
|
||||
|
|
@ -67,6 +68,7 @@ class mysqlUtilities:
|
|||
mysqlpassword = jsonData['mysqlpassword']
|
||||
mysqlport = jsonData['mysqlport']
|
||||
mysqlhost = jsonData['mysqlhost']
|
||||
mysqlUtilities.REMOTEHOST = mysqlhost
|
||||
|
||||
if mysqlhost.find('rds.amazon') > -1:
|
||||
mysqlUtilities.RDS = 1
|
||||
|
|
@ -114,7 +116,15 @@ class mysqlUtilities:
|
|||
return 0
|
||||
|
||||
cursor.execute("CREATE DATABASE " + dbname)
|
||||
cursor.execute("CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (mysqlUtilities.LOCALHOST) + dbpassword+ "'")
|
||||
|
||||
if mysqlUtilities.REMOTEHOST.find('ondigitalocean') > -1:
|
||||
query = "CREATE USER '%s'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % (
|
||||
dbuser, mysqlUtilities.LOCALHOST, dbpassword)
|
||||
else:
|
||||
query = "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (
|
||||
mysqlUtilities.LOCALHOST) + dbpassword + "'"
|
||||
|
||||
cursor.execute(query)
|
||||
|
||||
if mysqlUtilities.RDS == 0:
|
||||
cursor.execute("GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (mysqlUtilities.LOCALHOST))
|
||||
|
|
@ -381,7 +391,9 @@ password=%s
|
|||
databaseToBeDeleted.delete()
|
||||
return 1,'None'
|
||||
else:
|
||||
return 0,result
|
||||
databaseToBeDeleted.delete()
|
||||
logging.CyberCPLogFileWriter.writeToFile('Deleted database with some errors. Error: %s' % (result))
|
||||
return 1,'None'
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
|
@ -960,6 +972,27 @@ skip-name-resolve
|
|||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[addUserToDB]")
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def UpdateWPTempPassword(dbname, password):
|
||||
try:
|
||||
|
||||
##
|
||||
|
||||
connection, cursor = mysqlUtilities.setupConnection()
|
||||
|
||||
if connection == 0:
|
||||
return 0
|
||||
|
||||
cursor.execute("use %s" % (dbname))
|
||||
cursor.execute("UPDATE `wp_users` SET `user_pass`= MD5('%s') WHERE `user_login`='usman'" % (password))
|
||||
connection.close()
|
||||
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[deleteDatabase]")
|
||||
return str(msg)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel')
|
||||
parser.add_argument('function', help='Specific a function to call!')
|
||||
|
|
|
|||
|
|
@ -64,6 +64,14 @@ class sslUtilities:
|
|||
|
||||
@staticmethod
|
||||
def installSSLForDomain(virtualHostName, adminEmail='usman@cyberpersons.com'):
|
||||
|
||||
try:
|
||||
website = Websites.objects.get(domain=virtualHostName)
|
||||
adminEmail = website.adminEmail
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile('%s [installSSLForDomain:72]' % (str(msg)))
|
||||
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
confPath = sslUtilities.Server_root + "/conf/vhosts/" + virtualHostName
|
||||
completePathToConfigFile = confPath + "/vhost.conf"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import os
|
|||
import os.path
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
import shlex
|
||||
|
|
@ -13,17 +14,50 @@ from CyberCP import settings
|
|||
import random
|
||||
import string
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
CENTOS7 = 0
|
||||
CENTOS8 = 1
|
||||
Ubuntu18 = 2
|
||||
Ubuntu20 = 3
|
||||
CloudLinux7 = 4
|
||||
CloudLinux8 = 5
|
||||
|
||||
|
||||
class Upgrade:
|
||||
logPath = "/usr/local/lscp/logs/upgradeLog"
|
||||
cdn = 'cdn.cyberpanel.sh'
|
||||
installedOutput = ''
|
||||
CentOSPath = '/etc/redhat-release'
|
||||
UbuntuPath = '/etc/lsb-release'
|
||||
|
||||
AdminACL = '{"adminStatus":1, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser":1 , "resellerCenter": 1, ' \
|
||||
'"changeUserACL": 1, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
||||
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 1, "addDeleteDestinations": 1, "scheDuleBackups": 1, "remoteBackups": 1, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 1, "mailServerSSL": 1 }'
|
||||
|
||||
ResellerACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 1, "listUsers": 1, "deleteUser": 1 , "resellerCenter": 1, ' \
|
||||
'"changeUserACL": 0, "createWebsite": 1, "modifyWebsite": 1, "suspendWebsite": 1, "deleteWebsite": 1, ' \
|
||||
'"createPackage": 1, "listPackages": 1, "deletePackage": 1, "modifyPackage": 1, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 1, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 1, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
||||
|
||||
UserACL = '{"adminStatus":0, "versionManagement": 1, "createNewUser": 0, "listUsers": 0, "deleteUser": 0 , "resellerCenter": 0, ' \
|
||||
'"changeUserACL": 0, "createWebsite": 0, "modifyWebsite": 0, "suspendWebsite": 0, "deleteWebsite": 0, ' \
|
||||
'"createPackage": 0, "listPackages": 0, "deletePackage": 0, "modifyPackage": 0, "createDatabase": 1, "deleteDatabase": 1, ' \
|
||||
'"listDatabases": 1, "createNameServer": 0, "createDNSZone": 1, "deleteZone": 1, "addDeleteRecords": 1, ' \
|
||||
'"createEmail": 1, "listEmails": 1, "deleteEmail": 1, "emailForwarding": 1, "changeEmailPassword": 1, ' \
|
||||
'"dkimManager": 1, "createFTPAccount": 1, "deleteFTPAccount": 1, "listFTPAccounts": 1, "createBackup": 1,' \
|
||||
' "restoreBackup": 0, "addDeleteDestinations": 0, "scheDuleBackups": 0, "remoteBackups": 0, "googleDriveBackups": 1, "manageSSL": 1, ' \
|
||||
'"hostnameSSL": 0, "mailServerSSL": 0 }'
|
||||
|
||||
@staticmethod
|
||||
def decideCentosVersion():
|
||||
|
|
@ -33,6 +67,25 @@ class Upgrade:
|
|||
else:
|
||||
return CENTOS7
|
||||
|
||||
@staticmethod
|
||||
def FindOperatingSytem():
|
||||
|
||||
if os.path.exists(Upgrade.CentOSPath):
|
||||
result = open(Upgrade.CentOSPath, 'r').read()
|
||||
|
||||
if result.find('CentOS Linux release 8') > -1 or result.find('CloudLinux release 8') > -1:
|
||||
return CENTOS8
|
||||
else:
|
||||
return CENTOS7
|
||||
else:
|
||||
result = open(Upgrade.UbuntuPath, 'r').read()
|
||||
|
||||
if result.find('20.04') > -1:
|
||||
return Ubuntu20
|
||||
else:
|
||||
return Ubuntu18
|
||||
|
||||
|
||||
@staticmethod
|
||||
def stdOut(message, do_exit=0):
|
||||
print("\n\n")
|
||||
|
|
@ -615,6 +668,28 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE loginSystem_acl ADD config longtext')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute("UPDATE loginSystem_acl SET config = '%s' where name = 'admin'" % (Upgrade.AdminACL))
|
||||
except BaseException as msg:
|
||||
print(str(msg))
|
||||
import sleep
|
||||
sleep(10)
|
||||
|
||||
try:
|
||||
cursor.execute("UPDATE loginSystem_acl SET config = '%s' where name = 'reseller'" % (Upgrade.ResellerACL))
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute("UPDATE loginSystem_acl SET config = '%s' where name = 'user'" % (Upgrade.UserACL))
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute("alter table loginSystem_administrator drop initUserAccountsLimit")
|
||||
except:
|
||||
|
|
@ -635,6 +710,11 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE websiteFunctions_websites ADD config longtext')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute("ALTER TABLE websiteFunctions_websites MODIFY externalApp varchar(30)")
|
||||
except:
|
||||
|
|
@ -655,7 +735,6 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
cursor.execute("ALTER TABLE loginSystem_acl ADD COLUMN listUsers INT DEFAULT 0;")
|
||||
except:
|
||||
|
|
@ -677,6 +756,19 @@ imap_folder_list_limit = 0
|
|||
`config` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)"""
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
pass
|
||||
|
||||
query = """CREATE TABLE `cloudAPI_wpdeployments` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`config` longtext NOT NULL,
|
||||
`owner_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cloudAPI_wpdeploymen_owner_id_506ddf01_fk_websiteFu` (`owner_id`),
|
||||
CONSTRAINT `cloudAPI_wpdeploymen_owner_id_506ddf01_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_websites` (`id`)
|
||||
)"""
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
|
|
@ -698,7 +790,6 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_normalbackupsites` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`domain_id` int(11) NOT NULL,
|
||||
|
|
@ -715,7 +806,6 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_normalbackupjoblogs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`status` int(11) NOT NULL,
|
||||
|
|
@ -1192,6 +1282,16 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE loginSystem_administrator ADD config longtext')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE loginSystem_acl ADD config longtext')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE dockerManager_containers ADD volumes longtext')
|
||||
except:
|
||||
|
|
@ -1302,6 +1402,11 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
cursor.execute('ALTER TABLE `manageServices_pdnsstatus` CHANGE `type` `type` VARCHAR(6) NULL;')
|
||||
except:
|
||||
pass
|
||||
|
||||
query = '''CREATE TABLE `databases_dbmeta` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`key` varchar(200) NOT NULL,
|
||||
|
|
@ -1461,7 +1566,6 @@ imap_folder_list_limit = 0
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
query = """CREATE TABLE `websiteFunctions_backupjoblogs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`message` longtext NOT NULL,
|
||||
|
|
@ -1607,7 +1711,8 @@ imap_folder_list_limit = 0
|
|||
command = 'git status'
|
||||
currentBranch = subprocess.check_output(shlex.split(command)).decode()
|
||||
|
||||
if currentBranch.find('On branch %s' % (branch)) > -1 and currentBranch.find('On branch %s-dev' % (branch)) == -1:
|
||||
if currentBranch.find('On branch %s' % (branch)) > -1 and currentBranch.find(
|
||||
'On branch %s-dev' % (branch)) == -1:
|
||||
|
||||
command = 'git stash'
|
||||
Upgrade.executioner(command, command, 1)
|
||||
|
|
@ -1641,7 +1746,6 @@ imap_folder_list_limit = 0
|
|||
command = 'git pull'
|
||||
Upgrade.executioner(command, command, 1)
|
||||
|
||||
|
||||
## Copy settings file
|
||||
|
||||
settingsData = open(settingsFile, 'r').readlines()
|
||||
|
|
@ -1883,9 +1987,12 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
command = 'chmod +x /usr/local/CyberCP/CLManager/CLPackages.py'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
clScripts = ['/usr/local/CyberCP/CLScript/panel_info.py', '/usr/local/CyberCP/CLScript/CloudLinuxPackages.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxUsers.py', '/usr/local/CyberCP/CLScript/CloudLinuxDomains.py'
|
||||
,'/usr/local/CyberCP/CLScript/CloudLinuxResellers.py', '/usr/local/CyberCP/CLScript/CloudLinuxAdmins.py',
|
||||
clScripts = ['/usr/local/CyberCP/CLScript/panel_info.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxPackages.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxUsers.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxDomains.py'
|
||||
, '/usr/local/CyberCP/CLScript/CloudLinuxResellers.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxAdmins.py',
|
||||
'/usr/local/CyberCP/CLScript/CloudLinuxDB.py', '/usr/local/CyberCP/CLScript/UserInfo.py']
|
||||
|
||||
for items in clScripts:
|
||||
|
|
@ -1914,7 +2021,6 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
command = '/usr/local/lsws/lsphp72/bin/php /usr/local/CyberCP/public/rainloop.php'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
|
||||
Upgrade.stdOut("Permissions updated.")
|
||||
|
||||
except BaseException as msg:
|
||||
|
|
@ -1993,7 +2099,7 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
command = 'cp -pR %s %s' % (postfixConfPath, configbackups)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
if os.path.exists(CentOSPath):
|
||||
if Upgrade.FindOperatingSytem() == CENTOS8 or Upgrade.FindOperatingSytem() == CENTOS7:
|
||||
|
||||
command = "yum makecache -y"
|
||||
Upgrade.executioner(command, 0)
|
||||
|
|
@ -2001,14 +2107,13 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
command = "yum update -y"
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
if Upgrade.decideCentosVersion() == CENTOS8:
|
||||
if Upgrade.FindOperatingSytem() == CENTOS8:
|
||||
command = 'dnf remove dovecot23 dovecot23-mysql -y'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
|
||||
import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
|
|
@ -2033,14 +2138,14 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
command = 'yum clean all'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
if Upgrade.decideCentosVersion() == CENTOS7:
|
||||
if Upgrade.FindOperatingSytem() == CENTOS7:
|
||||
command = 'yum makecache fast'
|
||||
else:
|
||||
command = 'yum makecache -y'
|
||||
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
if Upgrade.decideCentosVersion() == CENTOS7:
|
||||
if Upgrade.FindOperatingSytem() == CENTOS7:
|
||||
command = 'yum install --enablerepo=gf-plus -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre'
|
||||
else:
|
||||
command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y'
|
||||
|
|
@ -2057,97 +2162,38 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
|||
|
||||
## Restored
|
||||
|
||||
|
||||
command = 'systemctl restart postfix'
|
||||
Upgrade.executioner(command, 0)
|
||||
elif Upgrade.FindOperatingSytem() == Ubuntu20:
|
||||
|
||||
else:
|
||||
if Upgrade.installedOutput.find('dovecot-mysql/bionic,now 2:2.3.10-2') == -1:
|
||||
|
||||
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
writeToFile = open(debPath, 'w')
|
||||
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
||||
writeToFile.close()
|
||||
|
||||
try:
|
||||
command = 'apt update -y'
|
||||
Upgrade.executioner(command, 0)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'dpkg --configure -a'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'apt --fix-broken install -y'
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
||||
subprocess.call(command, shell=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
### Restore dovecot/postfix conf
|
||||
|
||||
command = 'cp -pR %s/dovecot/ /etc/' % (configbackups)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
command = 'cp -pR %s/postfix/ /etc/' % (configbackups)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
## Restored
|
||||
|
||||
## Remove Default Password Scheme
|
||||
|
||||
path = '/etc/dovecot/dovecot-sql.conf.ext'
|
||||
|
||||
data = open(path, 'r').readlines()
|
||||
|
||||
updatePasswords = 0
|
||||
|
||||
writeToFile = open(path, 'w')
|
||||
for items in data:
|
||||
if items.find('default_pass_scheme') > -1:
|
||||
updatePasswords = 1
|
||||
continue
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
debPath = '/etc/apt/sources.list.d/dovecot.list'
|
||||
writeToFile = open(debPath, 'w')
|
||||
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/focal focal main\n')
|
||||
writeToFile.close()
|
||||
|
||||
Upgrade.stdOut("Upgrading passwords...")
|
||||
command = "apt update -y"
|
||||
Upgrade.executioner(command, command)
|
||||
|
||||
command = 'dpkg --configure -a'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'apt --fix-broken install -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -y'
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
|
||||
import django
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from mailServer.models import EUsers
|
||||
|
||||
for items in EUsers.objects.all():
|
||||
if items.password.find('CRYPT') > -1:
|
||||
continue
|
||||
command = 'doveadm pw -p %s' % (items.password)
|
||||
items.password = subprocess.check_output(shlex.split(command)).decode("utf-8").strip('\n')
|
||||
items.save()
|
||||
|
||||
|
||||
command = "systemctl restart dovecot"
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
dovecotConf = '/etc/dovecot/dovecot.conf'
|
||||
|
||||
dovecotContent = open(dovecotConf, 'r').read()
|
||||
|
||||
if dovecotContent.find('service stats') == -1:
|
||||
writeToFile = open(dovecotConf, 'a')
|
||||
writeToFile = open(dovecotConf, 'a')
|
||||
|
||||
content = """\nservice stats {
|
||||
unix_listener stats-reader {
|
||||
|
|
@ -2233,7 +2279,6 @@ service_port = 9000
|
|||
writeToFile.write(content)
|
||||
writeToFile.close()
|
||||
|
||||
|
||||
command = 'mkdir -p /etc/cagefs/exclude'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
|
||||
|
|
@ -2324,6 +2369,30 @@ vmail
|
|||
command = 'chmod 600 %s' % (cronPath)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
@staticmethod
|
||||
def UpdateConfigOfCustomACL():
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
import django
|
||||
django.setup()
|
||||
from loginSystem.models import ACL
|
||||
for acl in ACL.objects.all():
|
||||
if acl.name == 'admin' or acl.name == 'reseller' or acl.name == 'user':
|
||||
continue
|
||||
elif acl.config == '{}':
|
||||
acl.config = '{"adminStatus":%s, "versionManagement": %s, "createNewUser": %s, "listUsers": %s, "deleteUser": %s, "resellerCenter": %s, "changeUserACL": %s, "createWebsite": %s, "modifyWebsite": %s, "suspendWebsite": %s, "deleteWebsite": %s, "createPackage": %s, "listPackages": %s, "deletePackage": %s, "modifyPackage": %s, "createDatabase": %s, "deleteDatabase": %s, "listDatabases": %s, "createNameServer": %s, "createDNSZone": %s, "deleteZone": %s, "addDeleteRecords": %s, "createEmail": %s, "listEmails": %s, "deleteEmail": %s, "emailForwarding": %s, "changeEmailPassword": %s, "dkimManager": %s, "createFTPAccount": %s, "deleteFTPAccount": %s, "listFTPAccounts": %s, "createBackup": %s, "restoreBackup": %s, "addDeleteDestinations": %s, "scheDuleBackups": %s, "remoteBackups": %s, "googleDriveBackups": %s, "manageSSL": %s, "hostnameSSL": %s, "mailServerSSL": %s }' \
|
||||
% (str(acl.adminStatus), str(acl.versionManagement), str(acl.createNewUser),
|
||||
str(acl.listUsers), str(acl.deleteUser), str(acl.resellerCenter), str(acl.changeUserACL),
|
||||
str(acl.createWebsite), str(acl.modifyWebsite), str(acl.suspendWebsite), str(acl.deleteWebsite),
|
||||
str(acl.createPackage), str(acl.listPackages), str(acl.deletePackage), str(acl.modifyPackage),
|
||||
str(acl.createDatabase), str(acl.deleteDatabase), str(acl.listDatabases), str(acl.createNameServer),
|
||||
str(acl.createDNSZone), str(acl.deleteZone), str(acl.addDeleteRecords), str(acl.createEmail),
|
||||
str(acl.listEmails), str(acl.deleteEmail), str(acl.emailForwarding), str(acl.changeEmailPassword),
|
||||
str(acl.dkimManager), str(acl.createFTPAccount), str(acl.deleteFTPAccount), str(acl.listFTPAccounts),
|
||||
str(acl.createBackup), str(acl.restoreBackup), str(acl.addDeleteDestinations), str(acl.scheDuleBackups), str(acl.remoteBackups), '1',
|
||||
str(acl.manageSSL), str(acl.hostnameSSL), str(acl.mailServerSSL))
|
||||
acl.save()
|
||||
|
||||
@staticmethod
|
||||
def upgrade(branch):
|
||||
|
||||
|
|
@ -2337,11 +2406,9 @@ vmail
|
|||
command = 'apt list'
|
||||
Upgrade.installedOutput = subprocess.check_output(shlex.split(command)).decode()
|
||||
|
||||
|
||||
command = 'systemctl stop cpssh'
|
||||
Upgrade.executioner(command, 'fix csf if there', 0)
|
||||
|
||||
|
||||
## Add LSPHP7.4 TO LSWS Ent configs
|
||||
|
||||
if not os.path.exists('/usr/local/lsws/bin/openlitespeed'):
|
||||
|
|
@ -2351,8 +2418,8 @@ vmail
|
|||
|
||||
command = 'wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/install/litespeed/httpd_config.xml'
|
||||
Upgrade.executioner(command, command, 0)
|
||||
#os.remove('/usr/local/lsws/conf/httpd_config.xml')
|
||||
#shutil.copy('httpd_config.xml', '/usr/local/lsws/conf/httpd_config.xml')
|
||||
# os.remove('/usr/local/lsws/conf/httpd_config.xml')
|
||||
# shutil.copy('httpd_config.xml', '/usr/local/lsws/conf/httpd_config.xml')
|
||||
|
||||
postfixPath = '/home/cyberpanel/postfix'
|
||||
pdns = '/home/cyberpanel/pdns'
|
||||
|
|
@ -2367,7 +2434,6 @@ vmail
|
|||
|
||||
## Current Version
|
||||
|
||||
|
||||
command = "systemctl stop lscpd"
|
||||
Upgrade.executioner(command, 'stop lscpd', 0)
|
||||
|
||||
|
|
@ -2402,11 +2468,16 @@ vmail
|
|||
|
||||
##
|
||||
|
||||
#Upgrade.setupVirtualEnv()
|
||||
# Upgrade.setupVirtualEnv()
|
||||
|
||||
##
|
||||
|
||||
Upgrade.applyLoginSystemMigrations()
|
||||
|
||||
## Put function here to update custom ACLs
|
||||
|
||||
Upgrade.UpdateConfigOfCustomACL()
|
||||
|
||||
Upgrade.s3BackupMigrations()
|
||||
Upgrade.containerMigrations()
|
||||
Upgrade.manageServiceMigrations()
|
||||
|
|
@ -2417,7 +2488,7 @@ vmail
|
|||
Upgrade.someDirectories()
|
||||
Upgrade.installLSCPD(branch)
|
||||
Upgrade.GeneralMigrations()
|
||||
#Upgrade.p3()
|
||||
# Upgrade.p3()
|
||||
|
||||
if os.path.exists(postfixPath):
|
||||
Upgrade.upgradeDovecot()
|
||||
|
|
@ -2444,14 +2515,12 @@ vmail
|
|||
command = 'cp /usr/local/lsws/lsphp73/bin/lsphp %s' % (phpPath)
|
||||
Upgrade.executioner(command, 0)
|
||||
|
||||
|
||||
try:
|
||||
command = "systemctl start lscpd"
|
||||
Upgrade.executioner(command, 'Start LSCPD', 0)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
command = 'csf -uf'
|
||||
Upgrade.executioner(command, 'fix csf if there', 0)
|
||||
command = 'systemctl start cpssh'
|
||||
|
|
@ -2477,6 +2546,7 @@ vmail
|
|||
Upgrade.stdOut("Upgrade Completed.")
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
parser.add_argument('branch', help='Install from branch name.')
|
||||
|
|
|
|||
|
|
@ -721,11 +721,13 @@ class vhost:
|
|||
|
||||
if not os.path.exists("/home/" + domainName + "/logs"):
|
||||
print("0,0")
|
||||
return 0,0
|
||||
|
||||
bwmeta = "/home/" + domainName + "/logs/bwmeta"
|
||||
|
||||
if not os.path.exists(path):
|
||||
print("0,0")
|
||||
return 0, 0
|
||||
|
||||
if os.path.exists(bwmeta):
|
||||
try:
|
||||
|
|
@ -741,19 +743,24 @@ class vhost:
|
|||
percentage = float(percentage) * float(inMB)
|
||||
except:
|
||||
print("0,0")
|
||||
return 0, 0
|
||||
|
||||
if percentage > 100.0:
|
||||
percentage = 100
|
||||
|
||||
print(str(inMB) + "," + str(percentage))
|
||||
return str(inMB), str(percentage)
|
||||
else:
|
||||
print("0,0")
|
||||
return 0, 0
|
||||
except OSError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
|
||||
print("0,0")
|
||||
return 0, 0
|
||||
except ValueError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [findDomainBW]")
|
||||
print("0,0")
|
||||
return 0, 0
|
||||
|
||||
@staticmethod
|
||||
def permissionControl(path):
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class virtualHostUtilities:
|
|||
CLPath = '/etc/sysconfig/cloudlinux'
|
||||
|
||||
if os.path.exists(CLPath):
|
||||
command = '/usr/share/cloudlinux/hooks/post_modify_user.py create --username %s --owner %s' % (virtualHostUser, virtualHostUser)
|
||||
command = '/usr/share/cloudlinux/hooks/post_modify_user.py create --username %s --owner %s' % (virtualHostUser, admin.userName)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
### For autodiscover of mail clients.
|
||||
|
|
@ -1222,12 +1222,17 @@ class virtualHostUtilities:
|
|||
return 0, str(msg)
|
||||
|
||||
@staticmethod
|
||||
def deleteDomain(virtualHostName):
|
||||
def deleteDomain(virtualHostName, DeleteDocRoot=0):
|
||||
try:
|
||||
|
||||
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
|
||||
vhost.deleteCoreConf(virtualHostName, numberOfWebsites)
|
||||
delWebsite = ChildDomains.objects.get(domain=virtualHostName)
|
||||
|
||||
if DeleteDocRoot:
|
||||
command = 'rm -rf %s' % (delWebsite.path)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
delWebsite.delete()
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
|
|
@ -1308,8 +1313,7 @@ class virtualHostUtilities:
|
|||
def getDiskUsage(path, totalAllowed):
|
||||
try:
|
||||
|
||||
totalUsageInMB = ProcessUtilities.outputExecutioner(["sudo", "du", "-hs", path, "--block-size=1M"]).split()[
|
||||
0]
|
||||
totalUsageInMB = subprocess.check_output('du -hs %s --block-size=1M' % (path), shell=True).decode("utf-8").split()[0]
|
||||
|
||||
percentage = float(100) / float(totalAllowed)
|
||||
|
||||
|
|
@ -1347,6 +1351,24 @@ class virtualHostUtilities:
|
|||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg))
|
||||
|
||||
@staticmethod
|
||||
def FindStats(website):
|
||||
|
||||
import json
|
||||
try:
|
||||
config = json.loads(website.config)
|
||||
DiskUsage = config['DiskUsage']
|
||||
DiskUsagePercentage = config['DiskUsagePercentage']
|
||||
bwInMB = config['bwInMB']
|
||||
bwUsage = config['bwUsage']
|
||||
except:
|
||||
DiskUsage = 0
|
||||
DiskUsagePercentage = 0
|
||||
bwInMB = 0
|
||||
bwUsage = 0
|
||||
|
||||
return DiskUsage, DiskUsagePercentage, bwInMB, bwUsage
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
|
|
@ -1415,6 +1437,10 @@ def main():
|
|||
|
||||
parser.add_argument('--server', help='Switch server parameter.')
|
||||
|
||||
## Doc root deletion for child domain
|
||||
|
||||
parser.add_argument('--DeleteDocRoot', help='Doc root deletion for child domain.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.function == "createVirtualHost":
|
||||
|
|
@ -1507,7 +1533,7 @@ def main():
|
|||
elif args.function == 'changeOpenBasedir':
|
||||
virtualHostUtilities.changeOpenBasedir(args.virtualHostName, args.openBasedirValue)
|
||||
elif args.function == 'deleteDomain':
|
||||
virtualHostUtilities.deleteDomain(args.virtualHostName)
|
||||
virtualHostUtilities.deleteDomain(args.virtualHostName, int(args.DeleteDocRoot))
|
||||
elif args.function == 'switchServer':
|
||||
virtualHostUtilities.switchServer(args.virtualHostName, args.phpVersion, int(args.server), args.tempStatusPath)
|
||||
|
||||
|
|
|
|||
2333
plogical/website.py
2333
plogical/website.py
File diff suppressed because it is too large
Load Diff
|
|
@ -148,15 +148,21 @@ class S3Backups(multi.Thread):
|
|||
if currentACL['admin'] == 0:
|
||||
return proc.ajax(0, 'Only administrators can use AWS S3 Backups.')
|
||||
|
||||
|
||||
aws_access_key_id, aws_secret_access_key, region = self.fetchAWSKeys()
|
||||
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id = aws_access_key_id,
|
||||
aws_secret_access_key = aws_secret_access_key,
|
||||
region_name=region
|
||||
)
|
||||
if region.find('http') > -1:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
endpoint_url=region,
|
||||
)
|
||||
else:
|
||||
s3 = boto3.resource(
|
||||
's3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key=aws_secret_access_key,
|
||||
)
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
|
|
|||
|
|
@ -1,117 +1,45 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from loginSystem.views import loadLoginPage
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.httpProc import httpProc
|
||||
from plogical.installUtilities import installUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
from plogical.acl import ACLManager
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
import os
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def logsHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
return render(request,'serverLogs/index.html')
|
||||
proc = httpProc(request, 'serverLogs/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def accessLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/accessLogs.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/accessLogs.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def errorLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
return render(request,'serverLogs/errorLogs.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/errorLogs.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def ftplogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/ftplogs.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/ftplogs.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def emailLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
|
||||
return render(request,'serverLogs/emailLogs.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/emailLogs.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def modSecAuditLogs(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'serverLogs/modSecAuditLog.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/modSecAuditLog.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getLogsFromFile(request):
|
||||
try:
|
||||
|
|
@ -205,30 +133,19 @@ def clearLogFile(request):
|
|||
return HttpResponse(json_data)
|
||||
|
||||
def serverMail(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
smtpPath = '/home/cyberpanel/smtpDetails'
|
||||
data = {}
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
if os.path.exists(smtpPath):
|
||||
mailSettings = json.loads(open(smtpPath, 'r').read())
|
||||
data['smtpHost'] = mailSettings['smtpHost']
|
||||
data['smtpPort'] = mailSettings['smtpPort']
|
||||
data['smtpUserName'] = mailSettings['smtpUserName']
|
||||
data['smtpPassword'] = mailSettings['smtpPassword']
|
||||
|
||||
smtpPath = '/home/cyberpanel/smtpDetails'
|
||||
data = {}
|
||||
|
||||
if os.path.exists(smtpPath):
|
||||
mailSettings = json.loads(open(smtpPath, 'r').read())
|
||||
data['smtpHost'] = mailSettings['smtpHost']
|
||||
data['smtpPort'] = mailSettings['smtpPort']
|
||||
data['smtpUserName'] = mailSettings['smtpUserName']
|
||||
data['smtpPassword'] = mailSettings['smtpPassword']
|
||||
|
||||
return render(request,'serverLogs/serverMail.html', data)
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[accessLogs]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverLogs/serverMail.html',
|
||||
data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def saveSMTPSettings(request):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@ SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-A
|
|||
CacheRoot /home/lscache/
|
||||
</IfModule>
|
||||
|
||||
<VirtualHost *>
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /usr/local/lsws/DEFAULT/html
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
DocumentRoot /usr/local/lsws/DEFAULT/html
|
||||
</VirtualHost>
|
||||
Include /usr/local/lsws/conf/modsec.conf
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
import json
|
||||
import subprocess, shlex
|
||||
import subprocess
|
||||
import psutil
|
||||
import socket
|
||||
from plogical.acl import ACLManager
|
||||
|
|
@ -18,7 +17,6 @@ from plogical.processUtilities import ProcessUtilities
|
|||
from plogical.httpProc import httpProc
|
||||
from plogical.installUtilities import installUtilities
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
NOTHING = 0
|
||||
|
|
@ -27,15 +25,13 @@ EXPIRE = 3
|
|||
|
||||
### Version
|
||||
|
||||
VERSION = '2.0'
|
||||
BUILD = 3
|
||||
VERSION = '2.1'
|
||||
BUILD = 1
|
||||
|
||||
def serverStatusHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
return render(request, 'serverStatus/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverStatus/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def litespeedStatus(request):
|
||||
|
|
@ -43,11 +39,6 @@ def litespeedStatus(request):
|
|||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
processList = ProcessUtilities.getLitespeedProcessNumber()
|
||||
|
||||
OLS = 0
|
||||
|
|
@ -82,17 +73,21 @@ def litespeedStatus(request):
|
|||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return render(request, "serverStatus/litespeedStatus.html", {"processList": processList,
|
||||
"liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.",
|
||||
'OLS': OLS , 'message': message})
|
||||
proc = httpProc(request, 'serverStatus/litespeedStatus.html',
|
||||
{"processList": processList,
|
||||
"liteSpeedVersionStatus": "For some reaons not able to load version details, see CyberCP main log file.",
|
||||
'OLS': OLS, 'message': message}, 'admin')
|
||||
return proc.render()
|
||||
if (processList != 0):
|
||||
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
|
||||
"loadedModules": loadedModules, 'OLS': OLS, 'message': message}
|
||||
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||
proc = httpProc(request, 'serverStatus/litespeedStatus.html', dataForHtml, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
dataForHtml = {"lsversion": lsversion, "modules": modules,
|
||||
"loadedModules": loadedModules, 'OLS': OLS, 'message': message}
|
||||
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||
proc = httpProc(request, 'serverStatus/litespeedStatus.html', dataForHtml, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
|
|
@ -132,21 +127,8 @@ def stopOrRestartLitespeed(request):
|
|||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
def cyberCPMainLogFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'serverStatus/cybercpmainlogfile.html')
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverStatus/cybercpmainlogfile.html', None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def getFurtherDataFromLogFile(request):
|
||||
try:
|
||||
|
|
@ -173,30 +155,21 @@ def getFurtherDataFromLogFile(request):
|
|||
|
||||
|
||||
def services(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
data = {}
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
data = {}
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
data['serverName'] = 'OpenLiteSpeed'
|
||||
else:
|
||||
data['serverName'] = 'LiteSpeed Ent'
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
data['serverName'] = 'OpenLiteSpeed'
|
||||
else:
|
||||
data['serverName'] = 'LiteSpeed Ent'
|
||||
dockerInstallPath = '/usr/bin/docker'
|
||||
if not os.path.exists(dockerInstallPath):
|
||||
data['isDocker'] = False
|
||||
else:
|
||||
data['isDocker'] = True
|
||||
|
||||
dockerInstallPath = '/usr/bin/docker'
|
||||
if not os.path.exists(dockerInstallPath):
|
||||
data['isDocker'] = False
|
||||
else:
|
||||
data['isDocker'] = True
|
||||
|
||||
return render(request, 'serverStatus/services.html', data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'serverStatus/services.html', data, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def servicesStatus(request):
|
||||
try:
|
||||
|
|
@ -536,22 +509,8 @@ def changeLicense(request):
|
|||
|
||||
|
||||
def topProcesses(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
templateName = "serverStatus/topProcesses.html"
|
||||
proc = httpProc(request, templateName)
|
||||
return proc.renderPre()
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, "serverStatus/topProcesses.html", None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def topProcessesStatus(request):
|
||||
try:
|
||||
|
|
@ -764,22 +723,8 @@ def killProcess(request):
|
|||
return HttpResponse(final_json)
|
||||
|
||||
def packageManager(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
templateName = "serverStatus/packageManager.html"
|
||||
proc = httpProc(request, templateName)
|
||||
return proc.renderPre()
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[packageManager]")
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, "serverStatus/packageManager.html", None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def fetchPackages(request):
|
||||
try:
|
||||
|
|
@ -1181,23 +1126,9 @@ def lockStatus(request):
|
|||
|
||||
|
||||
def CyberPanelPort(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
port = ProcessUtilities.fetchCurrentPort()
|
||||
|
||||
return render(request, 'serverStatus/changeCyberPanelPort.html', {'port': port})
|
||||
|
||||
except KeyError as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[CyberPanelPort]")
|
||||
return redirect(loadLoginPage)
|
||||
port = ProcessUtilities.fetchCurrentPort()
|
||||
proc = httpProc(request, "serverStatus/changeCyberPanelPort.html", {'port': port}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
|
||||
def submitPortChange(request):
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
|||
|
||||
function ListInitialDatas(response) {
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
@ -240,7 +240,7 @@ app.controller('createIncrementalBackups', function ($scope, $http, $timeout) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.jobs = JSON.parse(response.data.data);
|
||||
$scope.jobs = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -358,7 +358,7 @@ app.controller('incrementalDestinations', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -621,7 +621,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
if (response.data.status === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Destination successfully removed.',
|
||||
text: 'Operation successful.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
|
|
@ -668,12 +668,11 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
var parsed = JSON.parse(response.data.data);
|
||||
|
||||
for (var j = 0; j < parsed.length; j++) {
|
||||
websitesToBeBackedTemp.push(parsed[j].website);
|
||||
}
|
||||
let data = response.data.data;
|
||||
$scope.records = data;
|
||||
data.forEach(item => {
|
||||
websitesToBeBackedTemp.push(item.website)
|
||||
})
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
|
|
@ -766,7 +765,7 @@ app.controller('scheduleBackupInc', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.websites = JSON.parse(response.data.data);
|
||||
$scope.websites = response.data.data;
|
||||
|
||||
if(response.data.websiteData === 1){
|
||||
$scope.websiteData = true;
|
||||
|
|
@ -1074,7 +1073,7 @@ app.controller('restoreRemoteBackupsInc', function ($scope, $http, $timeout) {
|
|||
function ListInitialDatas(response) {
|
||||
$scope.cyberpanelLoading = true;
|
||||
if (response.data.status === 1) {
|
||||
$scope.records = JSON.parse(response.data.data);
|
||||
$scope.records = response.data.data;
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Error!',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,21 @@
|
|||
|
||||
app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".destinationHide").hide();
|
||||
$('#create-backup-select').select2();
|
||||
});
|
||||
|
||||
$('#create-backup-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.websiteToBeBacked = data.text;
|
||||
$(".destinationHide").show();
|
||||
getBackupStatus();
|
||||
populateCurrentRecords();
|
||||
$scope.destination = false;
|
||||
$scope.runningBackup = true;
|
||||
});
|
||||
|
||||
$scope.destination = true;
|
||||
$scope.backupButton = true;
|
||||
$scope.backupLoading = true;
|
||||
|
|
@ -43,7 +58,6 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
function getBackupStatus() {
|
||||
|
||||
$scope.backupLoadingBottom = false;
|
||||
|
|
@ -111,12 +125,10 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.destinationSelection = function () {
|
||||
$scope.backupButton = false;
|
||||
};
|
||||
|
||||
|
||||
function populateCurrentRecords() {
|
||||
|
||||
var websiteToBeBacked = $scope.websiteToBeBacked;
|
||||
|
|
@ -152,7 +164,6 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.createBackup = function () {
|
||||
|
||||
var websiteToBeBacked = $scope.websiteToBeBacked;
|
||||
|
|
@ -189,10 +200,8 @@ app.controller('backupWebsiteControl', function ($scope, $http, $timeout) {
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.deleteBackup = function (id) {
|
||||
|
||||
|
||||
url = "/backup/deleteBackup";
|
||||
|
||||
var data = {
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
|
|
@ -1642,4 +1642,4 @@ border-style: none;
|
|||
@media (max-width: 720px) {
|
||||
.text-center-sm {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,23 @@ app.filter('getwebsitename', function () {
|
|||
};
|
||||
});
|
||||
|
||||
function getWebsiteName(domain){
|
||||
if (domain !== undefined) {
|
||||
|
||||
domain = domain.replace(/-/g, '');
|
||||
|
||||
var domainName = domain.split(".");
|
||||
|
||||
var finalDomainName = domainName[0];
|
||||
|
||||
if (finalDomainName.length > 5) {
|
||||
finalDomainName = finalDomainName.substring(0, 4);
|
||||
}
|
||||
|
||||
return finalDomainName;
|
||||
}
|
||||
}
|
||||
|
||||
app.controller('systemStatusInfo', function ($scope, $http, $timeout) {
|
||||
|
||||
//getStuff();
|
||||
|
|
|
|||
|
|
@ -6,25 +6,31 @@
|
|||
/* Java script code to create database */
|
||||
app.controller('createDatabase', function ($scope, $http) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.generatedPasswordView = true;
|
||||
$(document).ready(function () {
|
||||
$(".dbDetails").hide();
|
||||
$(".generatedPasswordDetails").hide();
|
||||
$('#create-database-select').select2();
|
||||
});
|
||||
|
||||
$('#create-database-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.databaseWebsite = data.text;
|
||||
$(".dbDetails").show();
|
||||
$("#domainDatabase").text(getWebsiteName(data.text));
|
||||
$("#domainUsername").text(getWebsiteName(data.text));
|
||||
});
|
||||
|
||||
|
||||
$scope.showDetailsBoxes = function () {
|
||||
$scope.dbDetails = false;
|
||||
};
|
||||
}
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
|
||||
$scope.createDatabase = function () {
|
||||
|
||||
$scope.createDatabaseLoading = false;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
var databaseWebsite = $scope.databaseWebsite;
|
||||
|
|
@ -65,26 +71,24 @@ app.controller('createDatabase', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.createDBStatus == 1) {
|
||||
if (response.data.createDBStatus === 1) {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Database successfully created.',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = false;
|
||||
$scope.databaseCreationFailed = false;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -96,21 +100,23 @@ app.controller('createDatabase', function ($scope, $http) {
|
|||
|
||||
$scope.createDatabaseLoading = true;
|
||||
$scope.dbDetails = true;
|
||||
$scope.databaseCreationFailed = true;
|
||||
$scope.databaseCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$(".generatedPasswordDetails").show();
|
||||
$scope.dbPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
$(".generatedPasswordDetails").hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -170,9 +176,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
|
|||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
|
|
@ -240,9 +244,7 @@ app.controller('deleteDatabase', function ($scope, $http) {
|
|||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$scope.deleteDatabaseLoading = true;
|
||||
$scope.fetchedDatabases = true;
|
||||
$scope.databaseDeletionFailed = false;
|
||||
|
|
@ -344,8 +346,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
$scope.dbLoading = true;
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.notificationsBox = false;
|
||||
$scope.canNotChangePassword = false;
|
||||
$scope.dbLoading = true;
|
||||
|
|
@ -411,8 +412,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
|
||||
$scope.domainFeteched = $scope.selectedDomain;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.recordsFetched = true;
|
||||
$scope.passwordChanged = true;
|
||||
$scope.canNotChangePassword = true;
|
||||
|
|
@ -481,8 +481,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
|
||||
$scope.dbHost = response.data.dbHost;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
|
|
@ -537,8 +536,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
type: 'success'
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
|
|
@ -570,7 +568,7 @@ app.controller('listDBs', function ($scope, $http) {
|
|||
app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
|
||||
$scope.generateAccess = function() {
|
||||
$scope.generateAccess = function () {
|
||||
|
||||
$scope.cyberPanelLoading = false;
|
||||
|
||||
|
|
@ -593,12 +591,14 @@ app.controller('phpMyAdmin', function ($scope, $http, $window) {
|
|||
if (response.data.status === 1) {
|
||||
var rUrl = '/phpmyadmin/phpmyadminsignin.php?username=' + response.data.username + '&token=' + response.data.token;
|
||||
$window.location.href = rUrl;
|
||||
} else {
|
||||
}
|
||||
else {}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {$scope.cyberPanelLoading = true;}
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@
|
|||
/* Java script code to create account */
|
||||
app.controller('createFTPAccount', function ($scope, $http) {
|
||||
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$( ".ftpDetails" ).hide();
|
||||
$( ".ftpPasswordView" ).hide();
|
||||
$('.create-ftp-acct-select').select2();
|
||||
});
|
||||
|
||||
$('.create-ftp-acct-select').on('select2:select', function (e) {
|
||||
var data = e.params.data;
|
||||
$scope.ftpDomain = data.text;
|
||||
$( ".ftpDetails" ).show();
|
||||
|
||||
});
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = true;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.showFTPDetails = function () {
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.createFTPAccount = function () {
|
||||
|
||||
|
|
@ -62,37 +62,35 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
|||
function ListInitialDatas(response) {
|
||||
|
||||
|
||||
if (response.data.creatFTPStatus == 1) {
|
||||
|
||||
if (response.data.creatFTPStatus === 1) {
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = false;
|
||||
$scope.couldNotConnect = true;
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'FTP account successfully created.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = false;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = true;
|
||||
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
|
||||
$scope.ftpLoading = true;
|
||||
$scope.ftpDetails = false;
|
||||
$scope.canNotCreate = true;
|
||||
$scope.successfullyCreated = true;
|
||||
$scope.couldNotConnect = false;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -109,15 +107,13 @@ app.controller('createFTPAccount', function ($scope, $http) {
|
|||
|
||||
///
|
||||
|
||||
$scope.generatedPasswordView = true;
|
||||
|
||||
$scope.generatePassword = function () {
|
||||
$scope.generatedPasswordView = false;
|
||||
$( ".ftpPasswordView" ).show();
|
||||
$scope.ftpPassword = randomPassword(16);
|
||||
};
|
||||
|
||||
$scope.usePassword = function () {
|
||||
$scope.generatedPasswordView = true;
|
||||
$(".ftpPasswordView" ).hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Created by usman on 7/24/17.
|
||||
*/
|
||||
|
||||
/* Utilities */
|
||||
|
||||
|
||||
function getCookie(name) {
|
||||
var cookieValue = null;
|
||||
if (document.cookie && document.cookie !== '') {
|
||||
var cookies = document.cookie.split(';');
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = jQuery.trim(cookies[i]);
|
||||
// Does this cookie string begin with the name we want?
|
||||
if (cookie.substring(0, name.length + 1) === (name + '=')) {
|
||||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cookieValue;
|
||||
}
|
||||
|
||||
/* Utilities ends here */
|
||||
|
||||
|
||||
/* Java script code to Check Login status */
|
||||
$("#verifyingLogin").hide();
|
||||
$("#loginFailed").hide();
|
||||
|
||||
|
||||
var application = angular.module('loginSystem', []);
|
||||
|
||||
application.config(['$interpolateProvider',
|
||||
|
||||
function ($interpolateProvider) {
|
||||
$interpolateProvider.startSymbol('{$');
|
||||
$interpolateProvider.endSymbol('$}');
|
||||
}
|
||||
]);
|
||||
|
||||
application.controller('loginSystem', function ($scope, $http, $window) {
|
||||
|
||||
$scope.verifyCode = true;
|
||||
|
||||
$scope.verifyLoginCredentials = function () {
|
||||
|
||||
$("#verifyingLogin").show();
|
||||
|
||||
|
||||
var username = $scope.username;
|
||||
var password = $scope.password;
|
||||
var languageSelection = $scope.languageSelection;
|
||||
|
||||
|
||||
url = "/verifyLogin";
|
||||
|
||||
var data = {
|
||||
username: username,
|
||||
password: password,
|
||||
languageSelection: languageSelection,
|
||||
twofa: $scope.twofa
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
|
||||
if (response.data.loginStatus === 0) {
|
||||
$scope.errorMessage = response.data.error_message;
|
||||
$("#loginFailed").fadeIn();
|
||||
}else if(response.data.loginStatus === 2){
|
||||
$scope.verifyCode = false;
|
||||
}
|
||||
else {
|
||||
$("#loginFailed").hide();
|
||||
$window.location.href = '/base/';
|
||||
}
|
||||
|
||||
|
||||
$("#verifyingLogin").hide();
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.initiateLogin = function ($event) {
|
||||
var keyCode = $event.which || $event.keyCode;
|
||||
if (keyCode === 13) {
|
||||
$scope.verifyLoginCredentials();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
/* Java script code to to Check Login status ends here */
|
||||
|
|
@ -458,6 +458,7 @@ app.controller('deleteUser', function ($scope, $http) {
|
|||
|
||||
|
||||
/* Java script code to create acl */
|
||||
|
||||
app.controller('createACLCTRL', function ($scope, $http) {
|
||||
|
||||
$scope.aclLoading = true;
|
||||
|
|
@ -520,11 +521,13 @@ app.controller('createACLCTRL', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
$scope.createBackup = true;
|
||||
$scope.googleDriveBackups = true;
|
||||
$scope.restoreBackup = false;
|
||||
$scope.addDeleteDestinations = false;
|
||||
$scope.scheDuleBackups = false;
|
||||
$scope.remoteBackups = false;
|
||||
|
||||
|
||||
// SSL Management
|
||||
|
||||
$scope.manageSSL = true;
|
||||
|
|
@ -599,6 +602,7 @@ app.controller('createACLCTRL', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
createBackup: $scope.createBackup,
|
||||
googleDriveBackups: $scope.googleDriveBackups,
|
||||
restoreBackup: $scope.restoreBackup,
|
||||
addDeleteDestinations: $scope.addDeleteDestinations,
|
||||
scheDuleBackups: $scope.scheDuleBackups,
|
||||
|
|
@ -976,6 +980,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
$scope.createBackup = Boolean(response.data.createBackup);
|
||||
$scope.googleDriveBackups = Boolean(response.data.googleDriveBackups);
|
||||
$scope.restoreBackup = Boolean(response.data.restoreBackup);
|
||||
$scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations);
|
||||
$scope.scheDuleBackups = Boolean(response.data.scheDuleBackups);
|
||||
|
|
@ -1076,6 +1081,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
createBackup: $scope.createBackup,
|
||||
googleDriveBackups: $scope.googleDriveBackups,
|
||||
restoreBackup: $scope.restoreBackup,
|
||||
addDeleteDestinations: $scope.addDeleteDestinations,
|
||||
scheDuleBackups: $scope.scheDuleBackups,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ function getCookie(name) {
|
|||
return cookieValue;
|
||||
}
|
||||
|
||||
|
||||
/* Java script code to create account */
|
||||
app.controller('createWebsite', function ($scope, $http, $timeout, $window) {
|
||||
|
||||
|
|
@ -388,7 +389,6 @@ app.controller('listWebsites', function ($scope, $http) {
|
|||
|
||||
app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {
|
||||
|
||||
|
||||
$scope.currentPage = 1;
|
||||
$scope.recordsToShow = 10;
|
||||
|
||||
|
|
@ -700,7 +700,59 @@ app.controller('listChildDomainsMain', function ($scope, $http, $timeout) {
|
|||
|
||||
|
||||
}
|
||||
var DeleteDomain;
|
||||
$scope.deleteDomainInit = function (childDomainForDeletion){
|
||||
DeleteDomain = childDomainForDeletion;
|
||||
};
|
||||
|
||||
$scope.deleteChildDomain = function () {
|
||||
$scope.cyberPanelLoading = false;
|
||||
url = "/websites/submitDomainDeletion";
|
||||
|
||||
var data = {
|
||||
websiteName: DeleteDomain,
|
||||
DeleteDocRoot: $scope.DeleteDocRoot
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
if (response.data.websiteDeleteStatus === 1) {
|
||||
new PNotify({
|
||||
title: 'Success!',
|
||||
text: 'Child Domain successfully deleted.',
|
||||
type: 'success'
|
||||
});
|
||||
$scope.getFurtherWebsitesFromDB();
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialDatas(response) {
|
||||
$scope.cyberPanelLoading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page',
|
||||
type: 'error'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -2830,6 +2882,8 @@ app.controller('manageCronController', function ($scope, $http) {
|
|||
$("#cronEditSuccess").hide();
|
||||
$("#fetchCronFailure").hide();
|
||||
|
||||
$scope.websiteToBeModified = $("#domain").text();
|
||||
|
||||
$scope.fetchWebsites = function () {
|
||||
|
||||
$("#manageCronLoading").show();
|
||||
|
|
@ -2880,6 +2934,7 @@ app.controller('manageCronController', function ($scope, $http) {
|
|||
$("#cronEditSuccess").hide();
|
||||
}
|
||||
};
|
||||
$scope.fetchWebsites();
|
||||
|
||||
$scope.fetchCron = function (cronLine) {
|
||||
|
||||
|
|
@ -3033,7 +3088,6 @@ app.controller('manageCronController', function ($scope, $http) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
$scope.removeCron = function (line) {
|
||||
|
||||
$("#manageCronLoading").show();
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
import os.path
|
||||
import sys
|
||||
import django
|
||||
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import redirect
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
|
|
@ -18,52 +21,28 @@ from plogical.processUtilities import ProcessUtilities
|
|||
|
||||
class tuningManager:
|
||||
def loadTuningHome(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'tuning/index.html', {})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'tuning/index.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def liteSpeedTuning(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
return render(request, 'tuning/liteSpeedTuning.html', {})
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
proc = httpProc(request, 'tuning/liteSpeedTuning.html',
|
||||
None, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def phpTuning(self, request, userID):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
OLS = 1
|
||||
return render(request, 'tuning/phpTuning.html', {'websiteList': websitesName, 'OLS': OLS})
|
||||
else:
|
||||
OLS = 0
|
||||
return render(request, 'tuning/phpTuning.html', {'OLS': OLS})
|
||||
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
websitesName = ACLManager.findAllSites(currentACL, userID)
|
||||
OLS = 1
|
||||
proc = httpProc(request, 'tuning/phpTuning.html',
|
||||
{'websiteList': websitesName, 'OLS': OLS}, 'admin')
|
||||
return proc.render()
|
||||
else:
|
||||
OLS = 0
|
||||
proc = httpProc(request, 'tuning/phpTuning.html',
|
||||
{'OLS': OLS}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
def tuneLitespeed(self, userID, data):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
from django.shortcuts import redirect
|
||||
import json
|
||||
from loginSystem.views import loadLoginPage
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ app.controller('deleteUser', function ($scope, $http) {
|
|||
|
||||
|
||||
/* Java script code to create acl */
|
||||
|
||||
app.controller('createACLCTRL', function ($scope, $http) {
|
||||
|
||||
$scope.aclLoading = true;
|
||||
|
|
@ -520,11 +521,13 @@ app.controller('createACLCTRL', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
$scope.createBackup = true;
|
||||
$scope.googleDriveBackups = true;
|
||||
$scope.restoreBackup = false;
|
||||
$scope.addDeleteDestinations = false;
|
||||
$scope.scheDuleBackups = false;
|
||||
$scope.remoteBackups = false;
|
||||
|
||||
|
||||
// SSL Management
|
||||
|
||||
$scope.manageSSL = true;
|
||||
|
|
@ -599,6 +602,7 @@ app.controller('createACLCTRL', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
createBackup: $scope.createBackup,
|
||||
googleDriveBackups: $scope.googleDriveBackups,
|
||||
restoreBackup: $scope.restoreBackup,
|
||||
addDeleteDestinations: $scope.addDeleteDestinations,
|
||||
scheDuleBackups: $scope.scheDuleBackups,
|
||||
|
|
@ -976,6 +980,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
$scope.createBackup = Boolean(response.data.createBackup);
|
||||
$scope.googleDriveBackups = Boolean(response.data.googleDriveBackups);
|
||||
$scope.restoreBackup = Boolean(response.data.restoreBackup);
|
||||
$scope.addDeleteDestinations = Boolean(response.data.addDeleteDestinations);
|
||||
$scope.scheDuleBackups = Boolean(response.data.scheDuleBackups);
|
||||
|
|
@ -1076,6 +1081,7 @@ app.controller('modifyACLCtrl', function ($scope, $http) {
|
|||
// Backup Management
|
||||
|
||||
createBackup: $scope.createBackup,
|
||||
googleDriveBackups: $scope.googleDriveBackups,
|
||||
restoreBackup: $scope.restoreBackup,
|
||||
addDeleteDestinations: $scope.addDeleteDestinations,
|
||||
scheDuleBackups: $scope.scheDuleBackups,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue