Skip to content

Commit ca54d69

Browse files
author
Istiak Ferdous
committed
simplify getPHPString() & update php version for mail domain
1 parent dba466b commit ca54d69

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

managePHP/phpManager.py

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from xml.etree import ElementTree
88
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
99

10+
1011
class PHPManager:
1112

1213
@staticmethod
@@ -23,27 +24,9 @@ def findPHPVersions():
2324

2425
@staticmethod
2526
def getPHPString(phpVersion):
26-
27-
if phpVersion == "PHP 5.3":
28-
php = "53"
29-
elif phpVersion == "PHP 5.4":
30-
php = "54"
31-
elif phpVersion == "PHP 5.5":
32-
php = "55"
33-
elif phpVersion == "PHP 5.6":
34-
php = "56"
35-
elif phpVersion == "PHP 7.0":
36-
php = "70"
37-
elif phpVersion == "PHP 7.1":
38-
php = "71"
39-
elif phpVersion == "PHP 7.2":
40-
php = "72"
41-
elif phpVersion == "PHP 7.3":
42-
php = "73"
43-
elif phpVersion == "PHP 7.4":
44-
php = "74"
45-
elif phpVersion == "PHP 8.0":
46-
php = "80"
27+
# Ex: "PHP 5.3" type string, return Ex: "53" type string
28+
phpVersion = phpVersion.split()
29+
php = phpVersion[1].replace(".", "")
4730

4831
return php
4932

@@ -134,22 +117,22 @@ def savePHPConfigBasic(data):
134117
max_input_time = data['max_input_time']
135118
post_max_size = data['post_max_size']
136119

137-
if allow_url_fopen == True:
120+
if allow_url_fopen:
138121
allow_url_fopen = "allow_url_fopen = On"
139122
else:
140123
allow_url_fopen = "allow_url_fopen = Off"
141124

142-
if display_errors == True:
125+
if display_errors:
143126
display_errors = "display_errors = On"
144127
else:
145128
display_errors = "display_errors = Off"
146129

147-
if file_uploads == True:
130+
if file_uploads:
148131
file_uploads = "file_uploads = On"
149132
else:
150133
file_uploads = "file_uploads = Off"
151134

152-
if allow_url_include == True:
135+
if allow_url_include:
153136
allow_url_include = "allow_url_include = On"
154137
else:
155138
allow_url_include = "allow_url_include = Off"
@@ -303,7 +286,3 @@ def fetchPHPExtensions(data):
303286
json_data = json_data + ']'
304287
final_json = json.dumps({'status': 1, 'error_message': "None", "data": json_data})
305288
return HttpResponse(final_json)
306-
307-
308-
309-

plogical/virtualHostUtilities.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def setupAutoDiscover(mailDomain, tempStatusPath, virtualHostName, admin):
5858
childDomain = 'mail.%s' % (virtualHostName)
5959
childPath = '/home/%s/%s' % (virtualHostName, childDomain)
6060

61-
result = virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.2', childPath, 1, 0, 0,
61+
result = virtualHostUtilities.createDomain(virtualHostName, childDomain, 'PHP 7.3', childPath, 1, 0, 0,
6262
admin.userName, 0, "/home/cyberpanel/" + str(randint(1000, 9999)))
6363

6464
if result[0] == 0:
@@ -120,7 +120,7 @@ def setupAutoDiscover(mailDomain, tempStatusPath, virtualHostName, admin):
120120
@staticmethod
121121
def createVirtualHost(virtualHostName, administratorEmail, phpVersion, virtualHostUser, ssl,
122122
dkimCheck, openBasedir, websiteOwner, packageName, apache,
123-
tempStatusPath='/home/cyberpanel/fakePath', mailDomain = None, LimitsCheck = 1):
123+
tempStatusPath='/home/cyberpanel/fakePath', mailDomain=None, LimitsCheck=1):
124124
try:
125125

126126
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
@@ -505,7 +505,6 @@ def issueSSLForHostName(virtualHost, path):
505505
print("1,None")
506506
return 1, 'None'
507507

508-
509508
except BaseException as msg:
510509
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [issueSSLForHostName]")
511510
print("0," + str(msg))
@@ -929,7 +928,7 @@ def saveSSL(virtualHost, keyPath, certPath):
929928

930929
@staticmethod
931930
def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck, openBasedir, owner, apache,
932-
tempStatusPath='/home/cyberpanel/fakePath', LimitsCheck = 1):
931+
tempStatusPath='/home/cyberpanel/fakePath', LimitsCheck=1):
933932
try:
934933

935934
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Running some checks..,0')
@@ -957,7 +956,6 @@ def createDomain(masterDomain, virtualHostName, phpVersion, path, ssl, dkimCheck
957956
'This domain already exists as child domain. [404]')
958957
return 0, "This domain already exists as child domain."
959958

960-
961959
if ChildDomains.objects.filter(domain=virtualHostName.lstrip('www.')).count() > 0:
962960
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath,
963961
'This domain already exists as child domain. [404]')

0 commit comments

Comments
 (0)