diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index bcef61d53..92f2e606c 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -1059,18 +1059,42 @@ class ApplicationInstaller(multi.Thread): if self.dataLossCheck(finalPath, tempStatusPath, externalApp) == 0: raise BaseException('Directory is not empty.') + ### lets first find php path + + from plogical.phpUtilities import phpUtilities + + vhFile = f'/usr/local/lsws/conf/vhosts/{domainName}/vhost.conf' + + phpPath = phpUtilities.GetPHPVersionFromFile(vhFile, domainName) + + ### basically for now php 8.3 is being checked + + if not os.path.exists(phpPath): + statusFile = open(tempStatusPath, 'w') + statusFile.writelines('PHP 8.3 missing installing now..,20') + statusFile.close() + phpUtilities.InstallSaidPHP('83') + #### + finalConfPath = ApacheVhost.configBasePath + domainName + '.conf' + if not os.path.exists(finalConfPath) and ProcessUtilities.decideServer() == ProcessUtilities.OLS: + statusFile = open(self.tempStatusPath, 'w') + statusFile.writelines('Your server is currently using OpenLiteSpeed, please switch your website to use Apache otherwise Prestashop installation will not work.' + " [404]") + statusFile.close() + return 0 + + statusFile = open(tempStatusPath, 'w') statusFile.writelines('Downloading and extracting PrestaShop Core..,30') statusFile.close() - command = "wget https://download.prestashop.com/download/releases/prestashop_%s.zip -P %s" % ( - ApplicationInstaller.PrestaVersion, - finalPath) + pVersion = ProcessUtilities.fetch_latest_prestashop_version() + + command = f"wget https://github.com/PrestaShop/PrestaShop/releases/download/{pVersion}/prestashop_{pVersion}.zip -P {finalPath}" ProcessUtilities.executioner(command, externalApp) - command = "unzip -o %sprestashop_%s.zip -d " % (finalPath, ApplicationInstaller.PrestaVersion) + finalPath + command = "unzip -o %sprestashop_%s.zip -d " % (finalPath, pVersion) + finalPath ProcessUtilities.executioner(command, externalApp) command = "unzip -o %sprestashop.zip -d " % (finalPath) + finalPath @@ -1093,7 +1117,7 @@ class ApplicationInstaller(multi.Thread): statusFile.writelines('Installing and configuring PrestaShop..,60') statusFile.close() - command = "php " + finalPath + "install/index_cli.php --domain=" + finalURL + \ + command = f"{phpPath} " + finalPath + "install/index_cli.php --domain=" + finalURL + \ " --db_server=localhost --db_name=" + dbName + " --db_user=" + dbUser + " --db_password=" + dbPassword \ + " --name='" + shopName + "' --firstname=" + firstName + " --lastname=" + lastName + \ " --email=" + email + " --password=" + password diff --git a/plogical/processUtilities.py b/plogical/processUtilities.py index 4dd4a2b41..9ff1d5217 100755 --- a/plogical/processUtilities.py +++ b/plogical/processUtilities.py @@ -403,5 +403,22 @@ class ProcessUtilities(multi.Thread): print("An error occurred:", e) return None + @staticmethod + def fetch_latest_prestashop_version(): + import requests + url = "https://api.github.com/repos/PrestaShop/PrestaShop/releases" + try: + response = requests.get(url) + if response.status_code == 200: + releases = response.json() + return releases[0].get('tag_name') + else: + logging.writeToFile(f"Failed to fetch releases. Status code: {response.status_code}" ) + print("[fetch_latest_prestashop_version] Failed to fetch releases. Status code:", response.status_code) + except Exception as e: + print("An error occurred:", e) + logging.writeToFile(f"[fetch_latest_prestashop_version] An error occurred: {str(e)}") + return None + diff --git a/plogical/test.py b/plogical/test.py index f057886c2..e69de29bb 100644 --- a/plogical/test.py +++ b/plogical/test.py @@ -1,9 +0,0 @@ -import urllib.parse - -# Encoded content from your example -encoded_content = '%0A%5Bmysqld%5D%0A%0A%23%20GENERAL%20%23%0Auser%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20mysql%0Adefault-storage-engine%20%20%20%20%20%20%20%20%20%3D%20InnoDB%0A%23socket%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%2Fvar%2Flib%2Fmysql%2Fmysql.sock%0A%23pid-file%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%2Fvar%2Flib%2Fmysql%2Fmysqld.pid%0A%0A%23%20MyISAM%20%23%0A%23%20key-buffer-size%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2032M%0A%23%20myisam-recover%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20FORCE%2CBACKUP%0A%0A%23%20SAFETY%20%23%0Amax-allowed-packet%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2016M%0Amax-connect-errors%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%201000000%0Asql-mode%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20NO_ENGINE_SUBSTITUTION%2CNO_AUTO_CREATE_USER%0Asysdate-is-now%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%201%0Ainnodb-strict-mode%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%201%0A%0A%23%20DATA%20STORAGE%20%23%0Adatadir%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%2Fvar%2Flib%2Fmysql%0A%0A%23%20SERVER%20ID%20%23%20%0Aserver-id%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20747931%0A%0A%23%20CACHES%20AND%20LIMITS%20%23%0Amax-connections%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20500%0Atmp-table-size%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2032M%0Amax-heap-table-size%20%20%20%20%20%20%20%20%20%20%20%20%3D%2032M%0Aquery-cache-type%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%200%0Aquery-cache-size%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%200%0Athread-cache-size%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2050%0Aopen-files-limit%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2065535%0Atable-definition-cache%20%20%20%20%20%20%20%20%20%3D%201024%0Atable-open-cache%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%202048%0A%0A%23%20INNODB%20%23%0Ainnodb-flush-method%20%20%20%20%20%20%20%20%20%20%20%20%3D%20O_DIRECT%0Ainnodb-log-files-in-group%20%20%20%20%20%20%3D%202%0Ainnodb-log-file-size%20%20%20%20%20%20%20%20%20%20%20%3D%20128M%0Ainnodb-flush-log-at-trx-commit%20%3D%201%0Ainnodb-file-per-table%20%20%20%20%20%20%20%20%20%20%3D%201%0Ainnodb-buffer-pool-size%20%20%20%20%20%20%20%20%3D%201228M%0A%0A%23%20LOGGING%20%23%0Alog-error%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%2Fvar%2Flib%2Fmysql%2Fmysqld.log%0Aslow-query-log%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%201%0Aslow-query-log-file%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%2Fvar%2Flib%2Fmysql%2Fmysqld-slow.log%0Alog-queries-not-using-indexes%20%20%3D%20OFF%0Along_query_time%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2030%0A%0A%5Bmysqldump%5D%0Amax-allowed-packet%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2016M%0A%0A!includedir%20%2Fetc%2Fmysql%2Fconf.d%2F%0A!includedir%20%2Fetc%2Fmysql%2Fmariadb.conf.d%2F%0A%' - -# Decoding it -decoded_content = urllib.parse.unquote(encoded_content) - -print(decoded_content) \ No newline at end of file diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 26ec9f2af..1d583df69 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -4521,6 +4521,14 @@ StrictHostKeyChecking no if data['home'] == '0': extraArgs['path'] = data['path'] + #### Before installing Prestashop change php to 8.3 + + completePathToConfigFile = f'/usr/local/lsws/conf/vhosts/{self.domain}/vhost.conf' + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = execPath + " changePHP --phpVersion 'PHP 8.3' --path " + completePathToConfigFile + ProcessUtilities.executioner(execPath) + background = ApplicationInstaller('prestashop', extraArgs) background.start() @@ -4550,7 +4558,12 @@ StrictHostKeyChecking no data['dkimCheck'] = 1 data['openBasedir'] = 1 data['adminEmail'] = data['ownerEmail'] - data['phpSelection'] = "PHP 7.4" + + try: + data['phpSelection'] = data['phpSelection'] + except: + data['phpSelection'] = "PHP 7.4" + data['package'] = data['packageName'] try: websitesLimit = data['websitesLimit']