2012-06-02 22:38:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Daniel Dimitrov - compojoom.com
|
|
|
|
* @date: 02.06.12
|
|
|
|
*
|
|
|
|
* @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
|
|
|
|
|
|
jimport('joomla.filesystem');
|
2012-12-13 10:08:35 +00:00
|
|
|
jimport('joomla.filesystem.folder');
|
2012-06-02 22:38:07 +00:00
|
|
|
jimport('joomla.filesystem.archive');
|
|
|
|
|
2012-07-06 23:45:06 +00:00
|
|
|
|
2012-12-13 10:08:35 +00:00
|
|
|
class jedcheckerControllerPolice extends JControllerlegacy
|
2012-07-06 23:45:06 +00:00
|
|
|
{
|
|
|
|
public function check()
|
|
|
|
{
|
2012-06-09 13:34:32 +00:00
|
|
|
$rule = JRequest::getString('rule');
|
2012-07-06 23:45:06 +00:00
|
|
|
|
2012-06-09 13:34:32 +00:00
|
|
|
JLoader::discover('jedcheckerRules',JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-07-06 23:45:06 +00:00
|
|
|
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
|
|
|
|
$class = 'jedcheckerRules'.ucfirst($rule);
|
|
|
|
|
|
|
|
// Stop if the class does not exist
|
|
|
|
if(!class_exists($class)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-02-12 08:54:55 +00:00
|
|
|
// Loop through each folder and police it
|
|
|
|
$folders = $this->getFolders();
|
|
|
|
foreach ($folders as $folder) {
|
|
|
|
$this->police($class, $folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function police($class, $folder)
|
|
|
|
{
|
2012-07-06 23:45:06 +00:00
|
|
|
// Prepare rule properties
|
2013-02-12 08:54:55 +00:00
|
|
|
$properties = array('basedir' => $folder);
|
2012-07-06 23:45:06 +00:00
|
|
|
|
|
|
|
// Create instance of the rule
|
|
|
|
$police = new $class($properties);
|
|
|
|
|
|
|
|
// Perform check
|
|
|
|
$police->check();
|
|
|
|
|
|
|
|
// Get the report and then print it
|
|
|
|
$report = $police->get('report');
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-07-06 23:45:06 +00:00
|
|
|
echo '<span class="rule">'
|
|
|
|
. JText::_('COM_JEDCHECKER_RULE') .' ' . JText::_($police->get('id'))
|
|
|
|
. ' - '. JText::_($police->get('title'))
|
|
|
|
. '</span><br/>'
|
|
|
|
. $report->getHTML();
|
2013-02-12 08:54:55 +00:00
|
|
|
|
|
|
|
flush();
|
|
|
|
ob_flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (!empty($tmp_folders)) {
|
|
|
|
foreach ($tmp_folders as $tmp_folder) {
|
|
|
|
$folders[] = $path.'/'.$tmp_folder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the local.txt file and parse it
|
|
|
|
$local = JFactory::getConfig()->get('tmp_path') . '/com_jedchecker/local.txt';
|
|
|
|
if (JFile::exists($local)) {
|
|
|
|
$content = JFile::read($local);
|
|
|
|
if (!empty($content)) {
|
|
|
|
$lines = explode("\n", $content);
|
|
|
|
if (!empty($lines)) {
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
$line = trim($line);
|
|
|
|
if (!empty($line)) {
|
|
|
|
if (JFolder::exists(JPATH_ROOT.'/'.$line)) {
|
|
|
|
$folders[] = JPATH_ROOT.'/'.$line;
|
|
|
|
} elseif (JFolder::exists($line)) {
|
|
|
|
$folders[] = $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $folders;
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
2012-07-06 23:45:06 +00:00
|
|
|
}
|