| Current Path : /home/smartconb/www/armencom33/administrator/components/com_eyesite/helpers/ |
| Current File : /home/smartconb/www/armencom33/administrator/components/com_eyesite/helpers/env_check.php |
<?php
/********************************************************************
Product : Eyesite
Date : 1 December 2023
Copyright : Les Arbres Design 2009-2023
Contact : https://www.lesarbresdesign.info
Licence : GNU General Public License
*********************************************************************/
defined('_JEXEC') or die('Restricted Access');
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
class LAE_Env_check
{
// -------------------------------------------------------------------------------
// Check for various environmental issues that might cause trouble
// - all of these issues have cropped up multiple times
//
static function environment_check($config_model, $config_data)
{
$warnings = array();
$errors = array();
$app = Factory::getApplication();
// Check that the Joomla version is compatible
if (defined('JVERSION')) // JVERSION did not exist before Joomla 2.5
$joomla_version = JVERSION;
else
$joomla_version = '1.x';
if (version_compare($joomla_version,"3.4.8","<"))
$errors[] = "This version of Eyesite requires at least Joomla 3.4.8. Your version is $joomla_version";
if (substr($joomla_version,0,1) > "5")
$warnings[] = "This version of Eyesite has not been tested on this version of Joomla";
// Check if the tmp directory is writeable - we need it for the lock file
$tmp_dir = $app->get('tmp_path');
if (!is_writable($tmp_dir))
$errors[] = 'The Joomla tmp directory is not writeable. The scanner will not work.<br> '.$tmp_dir;
// check that the lock file exists or we can create it
$lock_file_path = $tmp_dir.'/eyesite.lock';
if (!file_exists($lock_file_path))
@touch($lock_file_path);
$handle = @fopen($lock_file_path, 'r');
if ($handle === false)
$errors[] = 'Unable to create the scanner lock file. Please fix your file permissions.<br> '.$lock_file_path;
@fclose($handle);
// Check that we have (at least) the en-GB language file
if (!file_exists(JPATH_ADMINISTRATOR.'/components/com_eyesite/language/en-GB/en-GB.com_eyesite.ini'))
$errors[] = 'Critical files are missing. Please re-install Eyesite.';
// check all language files for parse errors
$all_dirs = glob(JPATH_ADMINISTRATOR.'/components/com_eyesite/language/*',GLOB_ONLYDIR);
foreach ($all_dirs as $dir)
{
$files = glob($dir.'/*.ini');
foreach ($files as $file)
if (!self::parseIniFile($file))
$errors[] = "Language file has formatting errors: ".str_replace(JPATH_SITE,'',$file);
}
// The Admin Tools extension adds this to the .htaccess file, which prevents Ajax calls from working properly:
// RewriteCond %{QUERY_STRING} (^|&)tmpl=(component|system) [NC]
// RewriteRule .* - [L]
$htaccess = @file_get_contents(JPATH_SITE.'/.htaccess');
if (!empty($htaccess))
if (preg_match("/RewriteCond.*tmpl.*component/i", $htaccess))
$errors[] = "The scanner will not work because your .htaccess file has a RewriteRule that prevents the 'tmpl=component' URL parameter from working properly";
// do we have a transaction ID? (only show this once per install)
if (!file_exists(JPATH_ROOT.'/administrator/components/com_eyesite/tid_notice.txt'))
{
if ($config_model->get_plugin_tid() === true) // plugin installed but no TID stored
$warnings[] = Text::_('COM_EYESITE_PURCHASE_ID_CONFIG');
@file_put_contents(JPATH_ROOT.'/administrator/components/com_eyesite/tid_notice.txt', 'y');
}
// show any errors or warnings
if (!empty($warnings))
$app->enqueueMessage(implode('<br>',$warnings), 'notice');
if (!empty($errors))
$app->enqueueMessage(implode('<br>',$errors), 'error');
}
// -------------------------------------------------------------------------------
// Check that a language file will work in Joomla
//
static function parseIniFile($filename)
{
if (!is_file($filename))
return false;
$contents = file_get_contents($filename);
$contents = str_replace('_QQ_', '"\""', $contents);
$strings = @parse_ini_string($contents);
if ($strings === false)
return false;
unset($strings);
return true;
}
}