mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-14 09:16:11 +01:00
added check for not-available php versions
This commit is contained in:
@@ -110,15 +110,15 @@ DATABASES = {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'cyberpanel',
|
||||
'USER': 'cyberpanel',
|
||||
'PASSWORD': 'a9AwLb7zY7ZwCd',
|
||||
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT':''
|
||||
'PORT':'3307'
|
||||
},
|
||||
'rootdb': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'mysql',
|
||||
'USER': 'root',
|
||||
'PASSWORD': '3bL8X7wGo0kT3b',
|
||||
'PASSWORD': 'sXm5VlRaAsXkDd',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '',
|
||||
},
|
||||
|
||||
@@ -32,6 +32,7 @@ def preDockerRun(function):
|
||||
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
||||
|
||||
# Check if docker is running and we are able to connect
|
||||
|
||||
try:
|
||||
client = docker.from_env()
|
||||
client.ping()
|
||||
|
||||
@@ -686,6 +686,10 @@ class vhost:
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
|
||||
print 0, 'This PHP version is not available on your CyberPanel.'
|
||||
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
|
||||
|
||||
writeDataToFile = open(vhFile, "w")
|
||||
|
||||
path = " path /usr/local/lsws/lsphp" + str(php) + "/bin/lsphp\n"
|
||||
@@ -704,15 +708,19 @@ class vhost:
|
||||
return 1,'None'
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [IO Error with per host config file [changePHP]]")
|
||||
str(msg) + " [IO Error with per host config file [changePHP]")
|
||||
print 0,str(msg)
|
||||
return [0, str(msg) + " [IO Error with per host config file [changePHP]]"]
|
||||
return [0, str(msg) + " [IO Error with per host config file [changePHP]"]
|
||||
else:
|
||||
try:
|
||||
data = open(vhFile, "r").readlines()
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if not os.path.exists("/usr/local/lsws/lsphp" + str(php) + "/bin/lsphp"):
|
||||
print 0, 'This PHP version is not available on your CyberPanel.'
|
||||
return [0, "[This PHP version is not available on your CyberPanel. [changePHP]"]
|
||||
|
||||
writeDataToFile = open(vhFile, "w")
|
||||
|
||||
finalString = ' AddHandler application/x-httpd-php' + str(php) + ' .php\n'
|
||||
|
||||
@@ -394,6 +394,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.status.litespeed) {
|
||||
$scope.olsStatus = "Running";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import render,redirect
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from loginSystem.views import loadLoginPage
|
||||
@@ -17,17 +17,19 @@ import time
|
||||
import serverStatusUtil
|
||||
from plogical.processUtilities import ProcessUtilities
|
||||
from plogical.httpProc import httpProc
|
||||
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def serverStatusHome(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
return render(request,'serverStatus/index.html')
|
||||
return render(request, 'serverStatus/index.html')
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def litespeedStatus(request):
|
||||
|
||||
def litespeedStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -58,24 +60,26 @@ def litespeedStatus(request):
|
||||
else:
|
||||
loadedModules.append(items)
|
||||
|
||||
except subprocess.CalledProcessError,msg:
|
||||
except subprocess.CalledProcessError, 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})
|
||||
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})
|
||||
|
||||
|
||||
if(processList!=0):
|
||||
if (processList != 0):
|
||||
dataForHtml = {"processList": processList, "lsversion": lsversion, "modules": modules,
|
||||
"loadedModules": loadedModules, 'OLS':OLS}
|
||||
return render(request,"serverStatus/litespeedStatus.html",dataForHtml)
|
||||
"loadedModules": loadedModules, 'OLS': OLS}
|
||||
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||
else:
|
||||
dataForHtml = {"lsversion": lsversion, "modules": modules,
|
||||
"loadedModules": loadedModules, 'OLS': OLS}
|
||||
return render(request, "serverStatus/litespeedStatus.html",dataForHtml)
|
||||
return render(request, "serverStatus/litespeedStatus.html", dataForHtml)
|
||||
|
||||
except KeyError,msg:
|
||||
except KeyError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def stopOrRestartLitespeed(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -91,16 +95,16 @@ def stopOrRestartLitespeed(request):
|
||||
|
||||
reboot = data['reboot']
|
||||
|
||||
if reboot==1:
|
||||
if reboot == 1:
|
||||
if ProcessUtilities.restartLitespeed() == 1:
|
||||
status = {"reboot":1,"shutdown":0}
|
||||
status = {"reboot": 1, "shutdown": 0}
|
||||
else:
|
||||
status = {"reboot": 0, "shutdown": 0, "error_message":"Please see CyberCP main log file."}
|
||||
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}
|
||||
else:
|
||||
if ProcessUtilities.stopLitespeed() == 1:
|
||||
status = {"reboot":0,"shutdown":1}
|
||||
status = {"reboot": 0, "shutdown": 1}
|
||||
else:
|
||||
status = {"reboot": 0, "shutdown": 0, "error_message":"Please see CyberCP main log file."}
|
||||
status = {"reboot": 0, "shutdown": 0, "error_message": "Please see CyberCP main log file."}
|
||||
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
@@ -109,8 +113,8 @@ def stopOrRestartLitespeed(request):
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[stopOrRestartLitespeed]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
def cyberCPMainLogFile(request):
|
||||
|
||||
def cyberCPMainLogFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
@@ -121,13 +125,13 @@ def cyberCPMainLogFile(request):
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
return render(request, 'serverStatus/cybercpmainlogfile.html')
|
||||
|
||||
return render(request,'serverStatus/cybercpmainlogfile.html')
|
||||
|
||||
except KeyError,msg:
|
||||
except KeyError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[cyberCPMainLogFile]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getFurtherDataFromLogFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -145,10 +149,12 @@ def getFurtherDataFromLogFile(request):
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except KeyError, msg:
|
||||
status = {"logstatus":0,"error":"Could not fetch data from log file, please see CyberCP main log file through command line."}
|
||||
status = {"logstatus": 0,
|
||||
"error": "Could not fetch data from log file, please see CyberCP main log file through command line."}
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
|
||||
return HttpResponse("Not Logged in as admin")
|
||||
|
||||
|
||||
def services(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -175,6 +181,7 @@ def services(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def servicesStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -263,6 +270,7 @@ def servicesStatus(request):
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def servicesAction(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -324,6 +332,7 @@ def servicesAction(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def switchTOLSWS(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -352,6 +361,7 @@ def switchTOLSWS(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def switchTOLSWSStatus(request):
|
||||
try:
|
||||
|
||||
@@ -376,6 +386,7 @@ def switchTOLSWSStatus(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def licenseStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -391,7 +402,6 @@ def licenseStatus(request):
|
||||
command = 'sudo cat /usr/local/lsws/conf/serial.no'
|
||||
serial = subprocess.check_output(shlex.split(command))
|
||||
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lshttpd -V'
|
||||
expiration = subprocess.check_output(shlex.split(command))
|
||||
|
||||
@@ -408,6 +418,7 @@ def licenseStatus(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def changeLicense(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -434,14 +445,12 @@ def changeLicense(request):
|
||||
command = 'sudo chown -R lsadm:lsadm /usr/local/lsws/conf'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lshttpd -r'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
command = 'sudo /usr/local/lsws/bin/lswsctrl restart'
|
||||
subprocess.call(shlex.split(command))
|
||||
|
||||
|
||||
final_dic = {'status': 1, "erroMessage": 'None'}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
@@ -455,6 +464,7 @@ def changeLicense(request):
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def topProcesses(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
@@ -469,10 +479,11 @@ def topProcesses(request):
|
||||
proc = httpProc(request, templateName)
|
||||
return proc.renderPre()
|
||||
|
||||
except KeyError,msg:
|
||||
except KeyError, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[litespeedStatus]")
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def topProcessesStatus(request):
|
||||
try:
|
||||
|
||||
@@ -491,7 +502,6 @@ def topProcessesStatus(request):
|
||||
loadNow = data[2].split(' ')
|
||||
loadNow = filter(lambda a: a != '', loadNow)
|
||||
|
||||
|
||||
memory = data[3].split(' ')
|
||||
memory = filter(lambda a: a != '', memory)
|
||||
|
||||
@@ -541,10 +551,10 @@ def topProcessesStatus(request):
|
||||
data['Softirqs'] = loadNow[13] + '%'
|
||||
|
||||
## Memory
|
||||
data['totalMemory'] = str(int(float(memory[3])/1024)) + 'MB'
|
||||
data['freeMemory'] = str(int(float(memory[5])/1024)) + 'MB'
|
||||
data['usedMemory'] = str(int(float(memory[7])/1024)) + 'MB'
|
||||
data['buffCache'] = str(int(float(memory[9])/1024)) + 'MB'
|
||||
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
|
||||
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
|
||||
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
|
||||
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
|
||||
|
||||
## Swap
|
||||
|
||||
@@ -589,6 +599,7 @@ def topProcessesStatus(request):
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
|
||||
def killProcess(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
|
||||
Reference in New Issue
Block a user