mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
ACL Manager
This commit is contained in:
@@ -17,35 +17,35 @@ from loginSystem.models import Administrator
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from random import randint
|
||||
from xml.etree import ElementTree
|
||||
from plogical.acl import ACLManager
|
||||
# Create your views here.
|
||||
|
||||
|
||||
def loadPHPHome(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough priviliges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'managePHP/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
def installExtensions(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough priviliges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
if PHP.objects.count() == 0:
|
||||
for i in range(3, 7):
|
||||
@@ -1757,66 +1757,66 @@ def installExtensions(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getExtensionsInformation(request):
|
||||
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetchStatus', 0)
|
||||
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
|
||||
php = PHP.objects.get(phpVers=phpVers)
|
||||
php = PHP.objects.get(phpVers=phpVers)
|
||||
|
||||
records = php.installedpackages_set.all()
|
||||
records = php.installedpackages_set.all()
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
for items in records:
|
||||
for items in records:
|
||||
|
||||
if items.status == 0:
|
||||
status = "Not-Installed"
|
||||
else:
|
||||
status = "Installed"
|
||||
if items.status == 0:
|
||||
status = "Not-Installed"
|
||||
else:
|
||||
status = "Installed"
|
||||
|
||||
dic = {'id': items.id,
|
||||
'phpVers': items.phpVers.phpVers,
|
||||
'extensionName': items.extensionName,
|
||||
'description': items.description,
|
||||
'status': status
|
||||
}
|
||||
dic = {'id': items.id,
|
||||
'phpVers': items.phpVers.phpVers,
|
||||
'extensionName': items.extensionName,
|
||||
'description': items.description,
|
||||
'status': status
|
||||
}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_json = json.dumps({'fetchStatus': 0, 'error_message': "Not enough privileges."})
|
||||
json_data = json_data + ']'
|
||||
final_json = json.dumps({'fetchStatus': 1, 'error_message': "None", "data": json_data})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException,msg:
|
||||
@@ -1829,31 +1829,29 @@ def getExtensionsInformation(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def submitExtensionRequest(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('extensionRequestStatus', 0)
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
extensionName = data['extensionName']
|
||||
type = data['type']
|
||||
data = json.loads(request.body)
|
||||
extensionName = data['extensionName']
|
||||
type = data['type']
|
||||
|
||||
if type == "install":
|
||||
phpUtilities.initiateInstall(extensionName)
|
||||
|
||||
else:
|
||||
phpUtilities.initiateRemoval(extensionName)
|
||||
|
||||
if type=="install":
|
||||
phpUtilities.initiateInstall(extensionName)
|
||||
|
||||
else:
|
||||
phpUtilities.initiateRemoval(extensionName)
|
||||
|
||||
final_json = json.dumps({'extensionRequestStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_json = json.dumps({'extensionRequestStatus': 0, 'error_message': "Not enough privileges."})
|
||||
final_json = json.dumps({'extensionRequestStatus': 1, 'error_message': "None"})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException,msg:
|
||||
@@ -1866,101 +1864,98 @@ def submitExtensionRequest(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def getRequestStatus(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin= Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('extensionRequestStatus', 0)
|
||||
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
size = data['size']
|
||||
extensionName = data['extensionName']
|
||||
if request.method == 'POST':
|
||||
data = json.loads(request.body)
|
||||
size = data['size']
|
||||
extensionName = data['extensionName']
|
||||
|
||||
requestStatus = unicode(open(phpUtilities.installLogPath, "r").read())
|
||||
requestStatusSize = len(requestStatus)
|
||||
|
||||
requestStatus = unicode(open(phpUtilities.installLogPath, "r").read())
|
||||
requestStatusSize = len(requestStatus)
|
||||
|
||||
if requestStatus.find("PHP Extension Installed")>-1:
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("Can not be installed") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("Can not un-install Extension") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("PHP Extension Removed") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
if requestStatus.find("PHP Extension Installed") > -1:
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
final_json = json.dumps({'finished': 0, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
else:
|
||||
final_json = json.dumps({'finished': 0, 'extensionRequestStatus': 0,
|
||||
'error_message': "Not enough privileges."})
|
||||
return HttpResponse(final_json)
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("Can not be installed") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("Can not un-install Extension") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
elif requestStatus.find("PHP Extension Removed") > -1:
|
||||
|
||||
if subprocess.check_output(["yum", "list", "installed"]).find(extensionName) > -1:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 1
|
||||
ext.save()
|
||||
else:
|
||||
ext = installedPackages.objects.get(extensionName=extensionName)
|
||||
ext.status = 0
|
||||
ext.save()
|
||||
|
||||
installUtilities.reStartLiteSpeed()
|
||||
final_json = json.dumps({'finished': 1, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_json = json.dumps({'finished': 0, 'extensionRequestStatus': 1,
|
||||
'error_message': "None",
|
||||
'requestStatus': requestStatus,
|
||||
'size': requestStatusSize})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
|
||||
@@ -1973,105 +1968,97 @@ def getRequestStatus(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
|
||||
def editPHPConfigs(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
|
||||
if admin.type == 3:
|
||||
return HttpResponse("You don't have enough privileges to access this page.")
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request,'managePHP/editPHPConfig.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getCurrentPHPConfig(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetchStatus', 0)
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
|
||||
path = "/usr/local/lsws/ls"+phpVers+"/etc/php.ini"
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
|
||||
allow_url_fopen = "0"
|
||||
display_errors = "0"
|
||||
file_uploads = "0"
|
||||
allow_url_include = "0"
|
||||
memory_limit = ""
|
||||
max_execution_time = ""
|
||||
upload_max_filesize = ""
|
||||
max_input_time = ""
|
||||
allow_url_fopen = "0"
|
||||
display_errors = "0"
|
||||
file_uploads = "0"
|
||||
allow_url_include = "0"
|
||||
memory_limit = ""
|
||||
max_execution_time = ""
|
||||
upload_max_filesize = ""
|
||||
max_input_time = ""
|
||||
|
||||
data = open(path,'r').readlines()
|
||||
data = open(path, 'r').readlines()
|
||||
|
||||
for items in data:
|
||||
if items.find("allow_url_fopen")>-1 and items.find("=")>-1:
|
||||
if items.find("On") > -1:
|
||||
allow_url_fopen = "1"
|
||||
if items.find("display_errors")>-1 and items.find("=")>-1:
|
||||
if items.find("On") > -1:
|
||||
display_errors = "1"
|
||||
if items.find("file_uploads")>-1 and items.find("=")>-1:
|
||||
if items.find("On") > -1:
|
||||
file_uploads = "1"
|
||||
if items.find("allow_url_include")>-1 and items.find("=")>-1:
|
||||
if items.find("On") > -1:
|
||||
allow_url_include = "1"
|
||||
if items.find("memory_limit")>-1 and items.find("=")>-1:
|
||||
memory_limit = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("max_execution_time")>-1 and items.find("=")>-1:
|
||||
max_execution_time = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("upload_max_filesize")>-1 and items.find("=")>-1:
|
||||
upload_max_filesize = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("max_input_time")>-1 and items.find("=")>-1:
|
||||
max_input_time = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("post_max_size") > -1 and items.find("=") > -1:
|
||||
post_max_size = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
for items in data:
|
||||
if items.find("allow_url_fopen") > -1 and items.find("=") > -1:
|
||||
if items.find("On") > -1:
|
||||
allow_url_fopen = "1"
|
||||
if items.find("display_errors") > -1 and items.find("=") > -1:
|
||||
if items.find("On") > -1:
|
||||
display_errors = "1"
|
||||
if items.find("file_uploads") > -1 and items.find("=") > -1:
|
||||
if items.find("On") > -1:
|
||||
file_uploads = "1"
|
||||
if items.find("allow_url_include") > -1 and items.find("=") > -1:
|
||||
if items.find("On") > -1:
|
||||
allow_url_include = "1"
|
||||
if items.find("memory_limit") > -1 and items.find("=") > -1:
|
||||
memory_limit = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("max_execution_time") > -1 and items.find("=") > -1:
|
||||
max_execution_time = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("upload_max_filesize") > -1 and items.find("=") > -1:
|
||||
upload_max_filesize = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("max_input_time") > -1 and items.find("=") > -1:
|
||||
max_input_time = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
if items.find("post_max_size") > -1 and items.find("=") > -1:
|
||||
post_max_size = re.findall(r"[A-Za-z0-9_]+", items)[1]
|
||||
|
||||
|
||||
|
||||
final_dic = {'fetchStatus': 1,
|
||||
'allow_url_fopen': allow_url_fopen,
|
||||
'display_errors': display_errors,
|
||||
'file_uploads': file_uploads,
|
||||
'allow_url_include': allow_url_include,
|
||||
'memory_limit': memory_limit,
|
||||
'max_execution_time': max_execution_time,
|
||||
'upload_max_filesize': upload_max_filesize,
|
||||
'max_input_time': max_input_time,
|
||||
'post_max_size':post_max_size}
|
||||
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'fetchStatus': 0,
|
||||
'error_message': 'Not enough privileges.'
|
||||
}
|
||||
final_dic = {'fetchStatus': 1,
|
||||
'allow_url_fopen': allow_url_fopen,
|
||||
'display_errors': display_errors,
|
||||
'file_uploads': file_uploads,
|
||||
'allow_url_include': allow_url_include,
|
||||
'memory_limit': memory_limit,
|
||||
'max_execution_time': max_execution_time,
|
||||
'upload_max_filesize': upload_max_filesize,
|
||||
'max_input_time': max_input_time,
|
||||
'post_max_size': post_max_size}
|
||||
|
||||
final_json = json.dumps(final_dic)
|
||||
|
||||
@@ -2088,87 +2075,81 @@ def getCurrentPHPConfig(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def savePHPConfigBasic(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(id=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('saveStatus', 0)
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
allow_url_fopen = data['allow_url_fopen']
|
||||
display_errors = data['display_errors']
|
||||
file_uploads = data['file_uploads']
|
||||
allow_url_include = data['allow_url_include']
|
||||
memory_limit = data['memory_limit']
|
||||
max_execution_time = data['max_execution_time']
|
||||
upload_max_filesize = data['upload_max_filesize']
|
||||
max_input_time = data['max_input_time']
|
||||
post_max_size = data['post_max_size']
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
allow_url_fopen = data['allow_url_fopen']
|
||||
display_errors = data['display_errors']
|
||||
file_uploads = data['file_uploads']
|
||||
allow_url_include = data['allow_url_include']
|
||||
memory_limit = data['memory_limit']
|
||||
max_execution_time = data['max_execution_time']
|
||||
upload_max_filesize = data['upload_max_filesize']
|
||||
max_input_time = data['max_input_time']
|
||||
post_max_size = data['post_max_size']
|
||||
|
||||
if allow_url_fopen == True:
|
||||
allow_url_fopen = "allow_url_fopen = On"
|
||||
else:
|
||||
allow_url_fopen = "allow_url_fopen = Off"
|
||||
if allow_url_fopen == True:
|
||||
allow_url_fopen = "allow_url_fopen = On"
|
||||
else:
|
||||
allow_url_fopen = "allow_url_fopen = Off"
|
||||
|
||||
if display_errors == True:
|
||||
display_errors = "display_errors = On"
|
||||
else:
|
||||
display_errors = "display_errors = Off"
|
||||
if display_errors == True:
|
||||
display_errors = "display_errors = On"
|
||||
else:
|
||||
display_errors = "display_errors = Off"
|
||||
|
||||
if file_uploads == True:
|
||||
file_uploads = "file_uploads = On"
|
||||
else:
|
||||
file_uploads = "file_uploads = Off"
|
||||
|
||||
if file_uploads == True:
|
||||
file_uploads = "file_uploads = On"
|
||||
else:
|
||||
file_uploads = "file_uploads = Off"
|
||||
if allow_url_include == True:
|
||||
allow_url_include = "allow_url_include = On"
|
||||
else:
|
||||
allow_url_include = "allow_url_include = Off"
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
|
||||
if allow_url_include == True:
|
||||
allow_url_include = "allow_url_include = On"
|
||||
else:
|
||||
allow_url_include = "allow_url_include = Off"
|
||||
##
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
|
||||
##
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit+ " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size
|
||||
|
||||
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'saveStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'saveStatus': 0, 'error_message': output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
final_dic = {'saveStatus': 0, 'error_message': 'Not enough privileges.'}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
if output.find("1,None") > -1:
|
||||
data_ret = {'saveStatus': 1}
|
||||
final_json = json.dumps(data_ret)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'saveStatus': 0, 'error_message': output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException,msg:
|
||||
final_dic = {'saveStatus': 0, 'error_message': str(msg)}
|
||||
@@ -2177,48 +2158,43 @@ def savePHPConfigBasic(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
|
||||
#### Get Advance PHP Configs
|
||||
|
||||
|
||||
|
||||
def getCurrentAdvancedPHPConfig(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(id=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('fetchStatus', 0)
|
||||
try:
|
||||
if admin.type == 1:
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
|
||||
path = "/usr/local/lsws/ls"+phpVers+"/etc/php.ini"
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
|
||||
configData = open(path, "r").read()
|
||||
configData = open(path, "r").read()
|
||||
|
||||
status = {"fetchStatus": 1, "configData": configData}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
else:
|
||||
status = {"fetchStatus": 1, "error_message": 'Not enough privileges.'}
|
||||
status = {"fetchStatus": 1, "configData": configData}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
@@ -2230,69 +2206,65 @@ def getCurrentAdvancedPHPConfig(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def savePHPConfigAdvance(request):
|
||||
try:
|
||||
val = request.session['userID']
|
||||
admin = Administrator.objects.get(pk=val)
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if admin.type == 1:
|
||||
if currentACL['admin'] == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadErrorJson('saveStatus', 0)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
phpVers = data['phpSelection']
|
||||
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
if phpVers == "PHP 5.3":
|
||||
phpVers = "php53"
|
||||
elif phpVers == "PHP 5.4":
|
||||
phpVers = "php54"
|
||||
elif phpVers == "PHP 5.5":
|
||||
phpVers = "php55"
|
||||
elif phpVers == "PHP 5.6":
|
||||
phpVers = "php56"
|
||||
elif phpVers == "PHP 7.0":
|
||||
phpVers = "php70"
|
||||
elif phpVers == "PHP 7.1":
|
||||
phpVers = "php71"
|
||||
elif phpVers == "PHP 7.2":
|
||||
phpVers = "php72"
|
||||
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
vhost = open(tempPath, "w")
|
||||
vhost = open(tempPath, "w")
|
||||
|
||||
vhost.write(data['configData'])
|
||||
vhost.write(data['configData'])
|
||||
|
||||
vhost.close()
|
||||
vhost.close()
|
||||
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
execPath = "sudo python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
|
||||
execPath = execPath + " savePHPConfigAdvance --phpVers " + path + " --tempPath " + tempPath
|
||||
execPath = execPath + " savePHPConfigAdvance --phpVers " + path + " --tempPath " + tempPath
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
|
||||
output = subprocess.check_output(shlex.split(execPath))
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
status = {"saveStatus": 1, "configData": data['configData']}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'saveStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
||||
if output.find("1,None") > -1:
|
||||
status = {"saveStatus": 1, "configData": data['configData']}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
data_ret = {'saveStatus': 0, 'error_message': output}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
else:
|
||||
data_ret = {'saveStatus': 0, 'error_message': 'Not enough privileges.'}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except BaseException, msg:
|
||||
data_ret = {'saveStatus': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
except KeyError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[saveConfigsToFile]")
|
||||
|
||||
Reference in New Issue
Block a user