Skip to content

Commit

Permalink
bug fix: fetch dynamic php versions for apache on ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 27, 2024
1 parent 891ca84 commit ccf968e
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions managePHP/phpManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,46 @@ def findApachePHPVersions():
from ApachController.ApacheController import ApacheController as ApachController
result = ProcessUtilities.outputExecutioner(f'ls -la {ApachController.phpBasepath}')

# Get the lines containing 'lsphp' in the output
lsphp_lines = [line for line in result.split('\n') if 'php' in line]
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]

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
version = entry.split('php')[1]
# Format version as PHP X.Y
formatted_version = f"PHP {version[0]}.{version[1]}"
php_versions.append(formatted_version)
else:

if os.path.exists(ProcessUtilities.debugPath):
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Found PHP lines in findApachePHPVersions: {lsphp_lines}')
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

# 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
version = entry.split('php')[1]
# Format version as PHP X.Y
formatted_version = f"PHP {version[0]}.{version[1]}"
php_versions.append(formatted_version)



Expand Down

0 comments on commit ccf968e

Please sign in to comment.