| Server IP : 87.98.154.146 / Your IP : 216.73.216.101 Web Server : Apache System : Linux webm005.cluster126.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : bsiadvisil ( 110003) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/bsiadvisil/www/plugins/system/msframework/helper/ |
Upload File : |
<?php
/**
* MS Framework
*
* @package MS Framework Library
* @version 1.2.1.573
*
* @author Michael Snoeren
* @link https://snoerendevelopment.nl/
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
// Deny direct access
defined('_JEXEC') or die;
abstract class MSFrameworkInstall
{
/**
* Install a package
* @param String $path The path to the extension
* @access Public
* @return Boolean
*/
public static function install($path)
{
$installer = new JInstaller;
// Ignore empty installations
if (empty($path) || !JFolder::exists($path)) {
return false;
}
// Set the source path
$installer->setPath('source', $path);
// Get the manifest
$manifest = (array) $installer->getManifest();
// Check the manifest
if (!count($manifest) || !array_key_exists('name', $manifest) || !array_key_exists('version', $manifest)) {
return false;
}
if (self::isInstalled($manifest['name'])) {
if (version_compare(self::getVersion($manifest['name']), $manifest['version']) !== 1) {
return $installer->install($path) && self::clearMessageQueue();
}
JFactory::getApplication()->enqueueMessage(JText::_('PLG_MSFRAMEWORK_ERROR_OLDER_VERSION'), 'warning');
return false;
} else {
return $installer->install($path) && self::clearMessageQueue();
}
return false;
}
/**
* Check if an extension is installed yet
* @param String $name The extension name
* @access Public
* @return Boolean
*/
public static function isInstalled($name)
{
if (empty($name)) {
return false;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName('element'))
->from('#__extensions')
->where($db->quoteName('name') . ' = ' . $db->quote($name))
->setLimit(1);
$db->setQuery($query);
$db->execute();
return ($db->getNumRows() > 0);
}
/**
* Get the current version installed of an extension
* @param String $name The extension name
* @access Public
* @return String Empty if not found
*/
public static function getVersion($name)
{
if (!self::isInstalled($name)) {
return '';
}
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select($db->quoteName('manifest_cache'))
->from('#__extensions')
->where($db->quoteName('name') . ' = ' . $db->quote($name))
->setLimit(1);
$db->setQuery($query);
if (!$db->execute()) {
return '';
}
// Get only the cache
$data = $db->loadResult();
if (empty($data)) {
return '';
}
$json = @json_decode($data, true);
if (is_null($json) || !count($json) || !array_key_exists('version', $json)) {
return '';
}
return $json['version'];
}
/**
* Get the manifest from a path
* @param String $path The path to look in
* @access Public
* @return Mixed False is failed, array if succeeded
*/
public static function getManifest($path)
{
jimport('joomla.filesystem.folder');
if (empty($path) || !JFolder::exists($path)) {
return false;
}
$installer = new JInstaller;
// Set the source path
$installer->setPath('source', $path);
// Get the manifest
$manifest = (array) $installer->getManifest();
self::clearMessageQueue();
if (!count($manifest)) {
return false;
}
return $manifest;
}
/**
* Display a message
* @param String $msg The translatable message
* @access Public
* @return Void
*/
public static function showMessage($msg)
{
$app = JFactory::getApplication();
$input = $app->input;
$option = $input->getCmd('option', '');
$view = $input->getCmd('view', '');
if ($option === 'com_installer' && $view === 'update') {
$app->enqueueMessage(JText::_($msg));
}
}
/**
* Clear the message queue
* @access Public
* @return Boolean Always true
*/
public static function clearMessageQueue()
{
$session = JFactory::getSession();
$sessionQueue = $session->set('application.queue', null);
$queue = JFactory::getApplication()->getMessageQueue();
return true;
}
}