Skip to content

Commit

Permalink
Merge pull request #237 from joomla-extensions/develop
Browse files Browse the repository at this point in the history
Sync with 2.4.3 in developer branch
  • Loading branch information
dryabov authored Sep 21, 2023
2 parents f13a5f7 + 5821e26 commit 2da2f0f
Show file tree
Hide file tree
Showing 86 changed files with 1,125 additions and 360 deletions.
4 changes: 3 additions & 1 deletion administrator/components/com_jedchecker/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\MVC\Controller\BaseController;

/**
* Class JedcheckerController
*
* @since 1.0
*/
class JedcheckerController extends JControllerLegacy
class JedcheckerController extends BaseController
{
}
29 changes: 15 additions & 14 deletions administrator/components/com_jedchecker/controllers/police.raw.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@

defined('_JEXEC') or die('Restricted access');


jimport('joomla.filesystem');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.archive');
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\MVC\Controller\BaseController;

/**
* Class jedcheckerControllerPolice
*
* @since 1.0
*/
class JedcheckerControllerPolice extends JControllerLegacy
class JedcheckerControllerPolice extends BaseController
{
/**
* Runs all the rules on the given directory
Expand All @@ -30,11 +31,11 @@ class JedcheckerControllerPolice extends JControllerLegacy
*/
public function check()
{
$rule = JFactory::getApplication()->input->get('rule');
$rule = Factory::getApplication()->input->get('rule');

JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');

$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$class = 'jedcheckerRules' . ucfirst($rule);

// Stop if the class does not exist
Expand Down Expand Up @@ -65,7 +66,7 @@ public function check()
protected function police($class, $folder)
{
// Prepare rule properties
$properties = array('basedir' => JPath::clean($folder));
$properties = array('basedir' => Path::clean($folder));

// Create instance of the rule
$police = new $class($properties);
Expand All @@ -89,8 +90,8 @@ protected function getFolders()
$folders = array();

// Add the folders in the "jed_checked/unzipped" folder
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$tmp_folders = JFolder::folders($path);
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
$tmp_folders = Folder::folders($path);

if (!empty($tmp_folders))
{
Expand All @@ -101,9 +102,9 @@ protected function getFolders()
}

// Parse the local.txt file and parse it
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
$local = Factory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';

if (JFile::exists($local))
if (File::exists($local))
{
$content = file_get_contents($local);

Expand All @@ -119,11 +120,11 @@ protected function getFolders()

if (!empty($line))
{
if (JFolder::exists(JPATH_ROOT . '/' . $line))
if (Folder::exists(JPATH_ROOT . '/' . $line))
{
$folders[] = JPATH_ROOT . '/' . $line;
}
elseif (JFolder::exists($line))
elseif (Folder::exists($line))
{
$folders[] = $line;
}
Expand Down
58 changes: 30 additions & 28 deletions administrator/components/com_jedchecker/controllers/uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@

defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.archive');

use Joomla\Archive\Archive;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Session\Session;

/**
* Class JedcheckerControllerUploads
*
* @since 1.0
*/
class JedcheckerControllerUploads extends JControllerLegacy
class JedcheckerControllerUploads extends BaseController
{
/** @var string */
public $path;
Expand All @@ -40,7 +42,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
*/
public function __construct()
{
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
$this->path = Factory::getConfig()->get('tmp_path') . '/jed_checker';
$this->pathArchive = $this->path . '/archives';
$this->pathUnzipped = $this->path . '/unzipped';
parent::__construct();
Expand All @@ -53,11 +55,11 @@ public function __construct()
*/
public function upload()
{
$appl = JFactory::getApplication();
$appl = Factory::getApplication();
$input = $appl->input;

// Check the sent token by the form
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

// Gets the uploaded file from the sent form
$file = $input->files->get('extension', null, 'raw');
Expand All @@ -67,18 +69,18 @@ public function upload()
$path = $this->pathArchive;

// If the archive folder doesn't exist - create it!
if (!JFolder::exists($path))
if (!Folder::exists($path))
{
JFolder::create($path);
Folder::create($path);
}
else
{
// Let us remove all previous uploads
$archiveFiles = JFolder::files($path);
$archiveFiles = Folder::files($path);

foreach ($archiveFiles as $archive)
{
if (!JFile::delete($this->pathArchive . '/' . $archive))
if (!File::delete($this->pathArchive . '/' . $archive))
{
echo 'could not delete' . $archive;
}
Expand All @@ -88,10 +90,10 @@ public function upload()
$file['filepath'] = $path . '/' . strtolower($file['name']);

// Let us try to upload
if (!JFile::upload($file['tmp_name'], $file['filepath'], false, true))
if (!File::upload($file['tmp_name'], $file['filepath'], false, true))
{
// Error in upload - redirect back with an error notice
$appl->enqueueMessage(JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$appl->enqueueMessage(Text::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$appl->redirect('index.php?option=com_jedchecker&view=uploads');

return false;
Expand Down Expand Up @@ -119,28 +121,28 @@ public function upload()
*/
public function unzip()
{
$appl = JFactory::getApplication();
$appl = Factory::getApplication();

// Form check token
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));

// If folder doesn't exist - create it!
if (!JFolder::exists($this->pathUnzipped))
if (!Folder::exists($this->pathUnzipped))
{
JFolder::create($this->pathUnzipped);
Folder::create($this->pathUnzipped);
}
else
{
// Let us remove all previous unzipped files
$folders = JFolder::folders($this->pathUnzipped);
$folders = Folder::folders($this->pathUnzipped);

foreach ($folders as $folder)
{
JFolder::delete($this->pathUnzipped . '/' . $folder);
Folder::delete($this->pathUnzipped . '/' . $folder);
}
}

$file = JFolder::files($this->pathArchive);
$file = Folder::files($this->pathArchive);

$origin = $this->pathArchive . DIRECTORY_SEPARATOR . $file[0];
$destination = $this->pathUnzipped . DIRECTORY_SEPARATOR . $file[0];
Expand All @@ -150,7 +152,7 @@ public function unzip()
$archive = new Archive;
$result = $archive->extract($origin, $destination);
}
catch (\Exception $e)
catch (Exception $e)
{
$result = false;
}
Expand All @@ -160,14 +162,14 @@ public function unzip()
// Scan unzipped folders if we find zip file -> unzip them as well
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
$appl->enqueueMessage(JText::_($message));
$appl->enqueueMessage(Text::_($message));
}
else
{
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
}

// $appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
// $appl->redirect('index.php?option=com_jedchecker&view=uploads', Text::_($message));
$message = 'COM_JEDCHECKER_UNZIP_FAILED';

return $message;
Expand Down Expand Up @@ -197,15 +199,15 @@ public function unzipAll($start)
$archive = new Archive;
$result = $archive->extract($file->getPathname(), $unzip);
}
catch (\Exception $e)
catch (Exception $e)
{
$result = false;
}

// Delete the archive once we extract it
if ($result)
{
JFile::delete($file->getPathname());
File::delete($file->getPathname());

// Now check the new extracted folder for archive files
$this->unzipAll($unzip);
Expand All @@ -228,7 +230,7 @@ public function clear()
{
if (file_exists($this->path))
{
$result = JFolder::delete($this->path);
$result = Folder::delete($this->path);

if (!$result)
{
Expand All @@ -238,7 +240,7 @@ public function clear()

$message = 'COM_JEDCHECKER_DELETE_SUCCESS';

// JFactory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
// Factory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', Text::_($message));
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
}
}
Expand Down
17 changes: 8 additions & 9 deletions administrator/components/com_jedchecker/jedchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@
*/

defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controllerlegacy');

if (!JFactory::getUser()->authorise('core.manage', 'com_jedchecker'))
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;

if (!Factory::getUser()->authorise('core.manage', 'com_jedchecker'))
{
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'));
}

// We'll need JFile and JFolder all through the component so let us load them here
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');

$input = JFactory::getApplication()->input;
$input = Factory::getApplication()->input;
$view = $input->getCmd('view', '');

if ($view === '' && $input->getCmd('task', '') === '')
{
$input->set('view', 'uploads');
}

$controller = JControllerLegacy::getInstance('jedchecker');
$controller = BaseController::getInstance('jedchecker');
$controller->execute($input->getCmd('task', ''));
$controller->redirect();
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,22 @@ COM_JEDCHECKER_ERROR_FRAMEWORK_BOM_FOUND="Die greepordemerk (BOM) word bespeur.
COM_JEDCHECKER_ERROR_FRAMEWORK_SHORT_PHP_TAG="Kort PHP merker gevind. Aangesien kort merkers in PHP gedeaktiveer kan word, word dit aanbeveel om slegs die normale merkers (<?php) te gebruik om pasbaarheid te maksimeer."
COM_JEDCHECKER_ERROR_FRAMEWORK_SUPERGLOBALS="Die gebruik van superglobale word ten sterkste ontmoedig"
COM_JEDCHECKER_ERROR_FRAMEWORK_DIRECTDB="Gebruik van direkte databasistoegang word ten sterkste ontmoedig"
COM_JEDCHECKER_RULE_FRAMEWORK_NOTINJ3="Opgeskorte funksies in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ3="opgeskort in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ4="verwyder in Joomla! 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ5="removed in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_DS="DS is opgeskort in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_JERR="JError is opgeskort, maak gebruik van JFactory::getApplication()->enqueueMessage();"
COM_JEDCHECKER_ERROR_FRAMEWORK_ERRORLOG="error_log en var_dump"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATED="JRequest is opgeskort, maak gebruik van JFactory::getApplication()->input;"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ4="opgeskort in Joomla! 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ5="deprecated in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_TODO="TODO stelling bespeur"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER="Oorblywende lêergids bespeur"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE="Oorblywende lêer bespeur"
COM_JEDCHECKER_ERROR_FRAMEWORK_STRICT="PHP Streng Standaarde: Slegs veranderlikes moet deur verwysing toegeken word"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES="Spasies aan die begin van PHP lêer bespeur (dit kan lei tot die 'Kan nie kopskrifinligting verander nie - kopskrifte reeds gestuur' waarskuwingsboodskap)"
COM_JEDCHECKER_ERROR_FRAMEWORK_J5LEGACY="removed in Joomla! 5 (available with the Backward Compatibility plugin only)"
COM_JEDCHECKER_ERROR_FRAMEWORK_INSTEAD_USE="Instead, use"
COM_JEDCHECKER_RULE_JAMSS="JAMSS - Joomla! Anti-Malware Scan Script"
COM_JEDCHECKER_RULE_JAMSS_DESC="JAMSS sal baie vlae lig vir die gebruik van potensieel gevaarlike metodes, en sal ook kyk vir sommige bekende aanvalshandtekeninge. Kom meer te wete op die <a href='https://github.com/btoplak/Joomla-Anti-Malware-Scan-Script' target='_blank'>Projek se tuisblad</a><br>JAMSS uitset is baie breedvoerig en baie nuttig, beweeg oor enige lyne om die besonderhede te sien."
COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME="Verdagte lêernaam gevind:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,22 @@ COM_JEDCHECKER_ERROR_FRAMEWORK_BOM_FOUND="تم الكشف عن علامة ترت
COM_JEDCHECKER_ERROR_FRAMEWORK_SHORT_PHP_TAG="تم العثور على علامة PHP قصيرة، ونظرًا لأنه يمكن تعطيل العلامات القصيرة في PHP، فمن المستحسن استخدام العلامات العادية فقط (&lt;?php) لزيادة التوافق."
COM_JEDCHECKER_ERROR_FRAMEWORK_SUPERGLOBALS="استخدام الاصدار غير المستقر محبط بشدة"
COM_JEDCHECKER_ERROR_FRAMEWORK_DIRECTDB="لا يشجع بشدة على استخدام الوصول المباشر إلى قاعدة البيانات"
COM_JEDCHECKER_RULE_FRAMEWORK_NOTINJ3="المهام المهملة في Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ3="مهمل في Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ4="تمت إزالته في جوملا 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ5="removed in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_DS="DS مهمل في Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_JERR="JError تم إهماله, يجب عليك استخدام JFactory::getApplication()->enqueueMessage();"
COM_JEDCHECKER_ERROR_FRAMEWORK_ERRORLOG="error_log و var_dump"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATED="JRequest مهمل, يجب عليك استخدام JFactory::getApplication()->input;"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ4="تم إيقافه في جوملا 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ5="deprecated in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_TODO="تم اكتشاف بيان TODO"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER="تم اكتشاف مجلد مهمل"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE="تم اكتشاف مِلف مهمل"
COM_JEDCHECKER_ERROR_FRAMEWORK_STRICT="معايير PHP الصارمة: يجب تعيين المتغيرات فقط بواسطة المرجع"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES="تم اكتشاف مسافات في بداية مِلف PHP (قد يؤدي ذلك إلى ظهور رسالة تحذير \"لا يمكن تعديل معلومات الرأس - الرؤوس أُرسلت بالفعل\")"
COM_JEDCHECKER_ERROR_FRAMEWORK_J5LEGACY="removed in Joomla! 5 (available with the Backward Compatibility plugin only)"
COM_JEDCHECKER_ERROR_FRAMEWORK_INSTEAD_USE="Instead, use"
COM_JEDCHECKER_RULE_JAMSS="JAMSS - Joomla! مضاد البرمجيات الخبيثة"
COM_JEDCHECKER_RULE_JAMSS_DESC="سيؤشر هذا النظام بالعديد من العلامات للاشارة الى الطرق التي تنطوي على خطر محتمل، بالإضافة إلى التحقق من بعض التوقيعات المعروفة على الهجمات. اعرف المزيد على <a href='https://github.com/btoplak/Joomla-Anti-Malware-Scan-Script' target='_blank'>الصفحة الرئيسية للمشروع</a><br>مخرجات JAMSS مفعمة جداً ومفيدة جداً، توجه بالمؤشر فوق أي سطر لرؤية التفاصيل."
COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME="تم العثور على اسم الملف المشبوه:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,22 @@ COM_JEDCHECKER_ERROR_FRAMEWORK_BOM_FOUND="The byte order mark (BOM) is detected.
COM_JEDCHECKER_ERROR_FRAMEWORK_SHORT_PHP_TAG="Short PHP tag found. As short tags can be disabled in PHP, it is recommended to only use the normal tags (&lt;?php) to maximise compatibility."
COM_JEDCHECKER_ERROR_FRAMEWORK_SUPERGLOBALS="Use of superglobals is strongly discouraged"
COM_JEDCHECKER_ERROR_FRAMEWORK_DIRECTDB="Use of direct database access is strongly discouraged"
COM_JEDCHECKER_RULE_FRAMEWORK_NOTINJ3="Functions deprecated in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ3="deprecated in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ4="removed in Joomla! 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_NOTINJ5="removed in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_DS="DS is deprecated in Joomla 3"
COM_JEDCHECKER_ERROR_FRAMEWORK_JERR="JError is deprecated, you should use JFactory::getApplication()->enqueueMessage();"
COM_JEDCHECKER_ERROR_FRAMEWORK_ERRORLOG="error_log and var_dump"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATED="JRequest is deprecated, you should use JFactory::getApplication()->input;"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ4="deprecated in Joomla! 4"
COM_JEDCHECKER_ERROR_FRAMEWORK_DEPRECATEDINJ5="deprecated in Joomla! 5"
COM_JEDCHECKER_ERROR_FRAMEWORK_TODO="TODO statement detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER="Leftover folder detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE="Leftover file detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_STRICT="PHP Strict Standards: Only variables should be assigned by reference"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES="Spaces at the beginning of PHP file detected (it might result in the 'Cannot modify header information - headers already sent' warning message)"
COM_JEDCHECKER_ERROR_FRAMEWORK_J5LEGACY="removed in Joomla! 5 (available with the Backward Compatibility plugin only)"
COM_JEDCHECKER_ERROR_FRAMEWORK_INSTEAD_USE="Instead, use"
COM_JEDCHECKER_RULE_JAMSS="JAMSS - Joomla! Anti-Malware Scan Script"
COM_JEDCHECKER_RULE_JAMSS_DESC="JAMSS will raise many flags for use of potentially dangerous methods, additionally checking for some known attack signatures. Find out more on the <a href='https://github.com/btoplak/Joomla-Anti-Malware-Scan-Script' target='_blank'>Project's homepage</a><br>JAMSS output is very verbose and very useful, hover over any lines to see the details."
COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME="Suspicious filename found :"
Expand Down
Loading

0 comments on commit 2da2f0f

Please sign in to comment.