bug fix: fetch dynamic php versions for apache on ubuntu

This commit is contained in:
usmannasir
2024-09-27 17:03:54 +05:00
parent 891ca84a00
commit ccf968e06e

View File

@@ -75,6 +75,8 @@ class PHPManager:
from ApachController.ApacheController import ApacheController as ApachController
result = ProcessUtilities.outputExecutioner(f'ls -la {ApachController.phpBasepath}')
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
# Get the lines containing 'lsphp' in the output
lsphp_lines = [line for line in result.split('\n') if 'php' in line]
@@ -91,6 +93,28 @@ class PHPManager:
# Format version as PHP X.Y
formatted_version = f"PHP {version[0]}.{version[1]}"
php_versions.append(formatted_version)
else:
lsphp_lines = [line for line in result.split('\n')]
if os.path.exists(ProcessUtilities.debugPath):
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Found PHP lines in findApachePHPVersions: {lsphp_lines}')
# Extract the version from the lines and format it as 'PHP x.y'
# Extract and format PHP versions
php_versions = []
for entry in lsphp_lines:
# Find substring starting with 'php' and extract the version part
try:
version = entry.split('.')
# Format version as PHP X.Y
formatted_version = f"PHP {version[-2][-1]}.{version[-1]}"
if formatted_version != 'PHP .':
php_versions.append(formatted_version)
except:
pass