HEX
Server: Apache/2.4.67 (Debian)
System: Linux hosting103 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User: muzikaecom (1013)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/local/share/hostingplatform/scripts/detectCMS
#!/usr/bin/env php
<?php
require_once("/usr/local/share/hostingplatform/esrpc.php");

$server = new ESRPCConnection();
$worker = new Worker($server->get());
$server->setTarget($worker);
$server->connect();
$server->serve();

class Worker {
	var $api;

	function __construct($api) {
		$this->api = $api;
	}

	function detectCMS($packagename) {

		#############
		# Wordpress #
		#############

		$wordpress = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ | grep wp-includes/ | grep version\.php");
		$instances = explode("\n", $wordpress);
		$return = array();
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('$wp_version = \'')) == '$wp_version = \'') {
			            $version = str_replace("'", "", str_replace(";", "", substr($content_line,strlen('$wp_version = \''))));
			        }
			    }
			    $path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
			    $path = substr($path,0,strlen($path) - strlen("wp-includes/version.php"));
			    $return[] = array("type"    => "wordpress",
			                      "path"    => $path,
			                      "version" => $version);
			}
		}

		##################
		# Concrete 5.6.x #
		##################

		$concrete5_6 = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ | grep concrete/config/ | grep version\.php");
		$instances = explode("\n", $concrete5_6);
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('$APP_VERSION = \'')) == '$APP_VERSION = \'') {
			            $version = str_replace("'", "", str_replace(";", "", substr($content_line,strlen('$APP_VERSION = \''))));
			        }
			    }
			    $path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
			    $path = substr($path,0,strlen($path) - strlen("concrete/config/verrsion.php"));
			    $return[] = array("type"    => "concrete5",
			                      "path"    => $path,
			                      "version" => $version);
			}
		}

		##################
		# Concrete 5.8.x #
		##################

		$concrete5_8 = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ | grep concrete/config/concrete\.php");
		$instances = explode("\n", $concrete5_8);
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('\'version\' => \'')) == '\'version\' => \'') {
			            $version = str_replace(",", "", str_replace("'", "", str_replace(";", "", substr($content_line,strlen('\'version\' => \'')))));
			        }
			    }
			    $path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
			    $path = substr($path,0,strlen($path) - strlen("concrete/config/concrete.php"));
			    $return[] = array("type"    => "concrete5",
			                      "path"    => $path,
			                      "version" => $version);
			}
		}

		############################
		# Joomla! 2.5.x  +  3.3.x  #
		############################

		$joomla2_5 = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ | grep libraries/cms/version/version\.php");
		$instances = explode("\n", $joomla2_5);
		unset($version);
		unset($relaese);
		unset($dev_level);
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('public $RELEASE = \'')) == 'public $RELEASE = \'') {
			            $release = str_replace("'", "", str_replace(";", "", substr($content_line,strlen('public $RELEASE = \''))));
			        }
			        if(substr($content_line,0,strlen('public $DEV_LEVEL = \'')) == 'public $DEV_LEVEL = \'') {
			            $dev_level = str_replace("'", "", str_replace(";", "", substr($content_line,strlen('public $DEV_LEVEL = \''))));
			        }
			    }
			    if(!empty($release)) {
				$version = $release . "." . round($dev_level);
				$path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
				$path = substr($path,0,strlen($path) - strlen("libraries/cms/version/version.php"));
				$return[] = array("type"    => "joomla",
			                          "path"    => $path,
			                          "version" => $version);
			    }
			}
		}

		###########################
		# Joomla! 3.8.x  +  4.0.x #
		###########################

		$joomla3_8 = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ | grep libraries/src/Version\.php");
		$instances = explode("\n", $joomla3_8);
		unset($major_version);
		unset($minor_version);
		unset($patch_version);
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('const MAJOR_VERSION = ')) == 'const MAJOR_VERSION = ') {
			            $major_version = str_replace(";", "", substr($content_line,strlen('const MAJOR_VERSION = ')));
			        }
			        if(substr($content_line,0,strlen('const MINOR_VERSION = ')) == 'const MINOR_VERSION = ') {
			            $minor_version = str_replace(";", "", substr($content_line,strlen('const MINOR_VERSION = ')));
			        }
			        if(substr($content_line,0,strlen('const PATCH_VERSION = ')) == 'const PATCH_VERSION = ') {
			            $patch_version = str_replace(";", "", substr($content_line,strlen('const PATCH_VERSION = ')));
			        }
			    }
			    if(!empty($major_version)) {
				$version = round($major_version) . "." . round($minor_version) . "." . round($patch_version);
				$path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
				$path = substr($path,0,strlen($path) - strlen("libraries/src/Version.php"));
				$return[] = array("type"    => "joomla",
			                          "path"    => $path,
			                          "version" => $version);
			    }
			}
		}

		#########
		# CMSMS #
		#########

		$cmsms = shell_exec("find /home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename)) . "/ -type f -path \"*/lib/version.php\"");
		$instances = explode("\n", $cmsms);
		foreach($instances as $instance) {
			if(!empty($instance)) {
			    unset($version);
			    $content = file_get_contents($instance);
			    $content_lines = explode("\n", $content);
			    foreach($content_lines as $content_line) {
			        $content_line = trim(preg_replace('/\s+/', ' ', $content_line));
			        if(substr($content_line,0,strlen('$CMS_VERSION = \'')) == '$CMS_VERSION = \'') {
			            $version = str_replace("'", "", str_replace(";", "", substr($content_line,strlen('$CMS_VERSION = \''))));
			        }
			    }
			    $path = substr($instance,strlen("/home/" . escapeshellcmd(preg_replace('/\s+/', '', $packagename))));
			    $path = substr($path,0,strlen($path) - strlen("lib/version.php"));
			    if(!empty($path) && !empty($version)) {
				$return[] = array("type"    => "cmsms",
				                  "path"    => $path,
				                  "version" => $version);
			    }
			}
		}


		return $return;
	}
}