Skip to content

Commit

Permalink
Update script.install.php
Browse files Browse the repository at this point in the history
  • Loading branch information
conseilgouz committed Jan 5, 2025
1 parent 9a8fb53 commit d5e2974
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions script.install.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
// no direct access
defined('_JEXEC') or die;

use Joomla\CMS\Cache\CacheControllerFactoryInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Version;
use Joomla\Database\DatabaseInterface;
Expand Down Expand Up @@ -181,19 +181,20 @@ private function postInstall()
$this->htaccess_other_dirs(); // create htaccess file in media,images/administrator dir
}
}
private function htaccess_other_dirs() {
private function htaccess_other_dirs()
{
$source = JPATH_ROOT.self::CGPATH .'/txt/cgaccess_nophp.txt';
// media : block php
$f = JPATH_ROOT . '/media/.htaccess';
if (!@file_exists($f) ) { // .htaccess in media dir
if (!@file_exists($f)) { // .htaccess in media dir
$dest = JPATH_ROOT.'/media/.htaccess';
if (!copy($source, $dest)) {
Factory::getApplication()->enqueueMessage('CGSECURE : add HTACCESS in media error');
}
}
// images : block php
$f = JPATH_ROOT . '/images/.htaccess';
if (!@file_exists($f) ) { // .htaccess in images dir
if (!@file_exists($f)) { // .htaccess in images dir
$dest = JPATH_ROOT.'/images/.htaccess';
if (!copy($source, $dest)) {
Factory::getApplication()->enqueueMessage('CGSECURE : add HTACCESS in media error');
Expand All @@ -202,7 +203,7 @@ private function htaccess_other_dirs() {
// administrator : block protected directories
$source = JPATH_ROOT.self::CGPATH .'/txt/cgaccess_admin.txt';
$f = JPATH_ROOT . '/administrator/.htaccess';
if (!@file_exists($f) ) { // .htaccess in images dir
if (!@file_exists($f)) { // .htaccess in images dir
$dest = JPATH_ROOT.'/administrator/.htaccess';
if (!copy($source, $dest)) {
Factory::getApplication()->enqueueMessage('CGSECURE : add HTACCESS in media error');
Expand Down Expand Up @@ -246,11 +247,7 @@ private function forceHTAccess()
Factory::getApplication()->enqueueMessage('CGSECURE : Error during insert');
return;
}
// from https://www.php.net/manual/en/function.lcg-value.php#75562
private function random_float($min, $max)
{
return ($min + lcg_value() * (abs($max - $min)));
}

private function getServerConfigFile($file)
{
if (file_exists($this->getServerConfigFilePath($file))
Expand Down Expand Up @@ -538,7 +535,8 @@ private function installLibrary()
Factory::getApplication()->enqueueMessage(JText::_('ERROR_INSTALLATION_LIBRARY_FAILED'), 'error');
return false;
}
Factory::getCache()->clean('_system');
$cachecontroller = Factory::getContainer()->get(CacheControllerFactoryInterface::class)->createCacheController();
$cachecontroller->clean('_system');
return true;
}
private function uninstallInstaller()
Expand All @@ -558,7 +556,8 @@ private function uninstallInstaller()
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
Factory::getCache()->clean('_system');
$cachecontroller = Factory::getContainer()->get(CacheControllerFactoryInterface::class)->createCacheController();
$cachecontroller->clean('_system');
}

public function delete($files = [])
Expand Down

0 comments on commit d5e2974

Please sign in to comment.