diff --git a/source/administrator/components/com_jedchecker/controllers/police.raw.php b/source/administrator/components/com_jedchecker/controllers/police.raw.php
index c232e47..ad95d8e 100644
--- a/source/administrator/components/com_jedchecker/controllers/police.raw.php
+++ b/source/administrator/components/com_jedchecker/controllers/police.raw.php
@@ -9,22 +9,44 @@
defined('_JEXEC') or die('Restricted access');
-defined('_JEXEC') or die('Restricted access');
jimport('joomla.filesystem');
jimport('joomla.filesystem.archive');
-class jedcheckerControllerPolice extends JController {
- public function check() {
+
+class jedcheckerControllerPolice extends JController
+{
+ public function check()
+ {
$rule = JRequest::getString('rule');
+
JLoader::discover('jedcheckerRules',JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
-// require_once JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/'.$rule.'.php';
- $path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
- $class = 'jedcheckerRules'.ucfirst($rule);
- $police = new $class;
- $folders = JFolder::folders($path);
- $police->check($path.'/'.$folders[0]);
+ $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;
+ }
+
+ // Prepare rule properties
+ $folders = JFolder::folders($path);
+ $properties = array('basedir' => $path.'/'.$folders[0]);
+
+ // Create instance of the rule
+ $police = new $class($properties);
+
+ // Perform check
+ $police->check();
+
+ // Get the report and then print it
+ $report = $police->get('report');
+
+ echo ''
+ . JText::_('COM_JEDCHECKER_RULE') .' ' . JText::_($police->get('id'))
+ . ' - '. JText::_($police->get('title'))
+ . '
'
+ . $report->getHTML();
}
-}
\ No newline at end of file
+}
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.ini b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.ini
new file mode 100644
index 0000000..c675602
--- /dev/null
+++ b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.ini
@@ -0,0 +1,10 @@
+; This is the configuration file of the HTLM indexes rule.
+;
+; @author eaxs
+; @date 07/06/2012
+; @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
+; @license GNU General Public License version 2 or later; see LICENSE
+
+
+; Joomla system directories
+sysfolders = "administrator, components, language, language/.*, media, modules, plugins, plugins/content, plugins/editors, plugins/editors-xtd, plugins/finder, plugins/search, plugins/system, plugins/user"
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php
index 7f2ac54..9480c41 100644
--- a/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php
+++ b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php
@@ -1,7 +1,7 @@
findHtml($startFolder, 1);
+ $this->findHtml($this->basedir, 1);
/**
* let us "merge" the 2 arrays
@@ -23,18 +49,14 @@ class jedcheckerRulesHtmlindexes {
*/
$indexes = array_replace($this->folders, $this->indexes);
- echo ''.JText::_('COM_JEDCHECKER_RULE_SE1') . '
';
if(count($indexes) && in_array(false, $indexes)) {
- foreach($indexes as $key => $index) {
+ foreach($indexes as $key => $index)
+ {
if(!$index) {
- echo $key . '
';
+ $this->report->addError($key, 'COM_JEDCHECKER_ERROR_HTML_INDEX_NOT_FOUND');
}
}
- } else {
- echo ''.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'';
}
-
-
}
/**
@@ -45,25 +67,12 @@ class jedcheckerRulesHtmlindexes {
*/
public function findHtml($start, $root = 0)
{
-
// array of system folders (regex)
// will match paths ending with these folders
- $system_folders = array(
- 'administrator',
- 'components',
- 'language',
- 'language/.*',
- 'media',
- 'modules',
- 'plugins',
- 'plugins/content',
- 'plugins/editors',
- 'plugins/editors-xtd',
- 'plugins/finder',
- 'plugins/search',
- 'plugins/system',
- 'plugins/user'
- );
+ $system_folders = explode(',', $this->params->get('sysfolders'));
+
+ // Make sure there are no spaces
+ array_walk($system_folders, create_function('&$v', '$v = trim($v);'));
$iterator = new DirectoryIterator($start);
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/jexec.ini b/source/administrator/components/com_jedchecker/libraries/rules/jexec.ini
new file mode 100644
index 0000000..0b2d6eb
--- /dev/null
+++ b/source/administrator/components/com_jedchecker/libraries/rules/jexec.ini
@@ -0,0 +1,10 @@
+; This is the configuration file of the JEXEC rule.
+;
+; @author eaxs
+; @date 07/06/2012
+; @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
+; @license GNU General Public License version 2 or later; see LICENSE
+
+
+; The valid constants to search for
+constants ="_JEXEC, JPATH_PLATFORM, JPATH_BASE, AKEEBAENGINE, WF_EDITOR"
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/jexec.php b/source/administrator/components/com_jedchecker/libraries/rules/jexec.php
index aab0779..09a8028 100644
--- a/source/administrator/components/com_jedchecker/libraries/rules/jexec.php
+++ b/source/administrator/components/com_jedchecker/libraries/rules/jexec.php
@@ -1,7 +1,7 @@
missing = array();
- $files = JFolder::files($basedir, '.php', true, true);
+ // Find all php files of the extension
+ $files = JFolder::files($this->basedir, '.php$', true, true);
- // Iterate through all files in the package
+ // Iterate through all files
foreach($files as $file)
{
// Try to find the _JEXEC check in the file
- if(!$this->findJExec($file)) {
- $this->missing[] = $file;
+ if(!$this->find($file)) {
+ // Add as error to the report if it was not found
+ $this->report->addError($file, 'COM_JEDCHECKER_ERROR_JEXEC_NOT_FOUND');
}
}
-
-
- echo ''.JText::_('COM_JEDCHECKER_RULE_PH2') .'
';
- if(count($this->missing)) {
- // Echo all files which don't have the _JEXEC check
- foreach($this->missing AS $file)
- {
- echo $file.'
';
- }
- } else {
- echo ''.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'';
- }
-
}
@@ -64,36 +70,36 @@ class jedcheckerRulesJexec
* @param string $file The path to the file
* @return boolean True if the statement was found, otherwise False.
*/
- protected function findJexec($file)
+ protected function find($file)
{
$content = (array) file($file);
- $defines = array(
- '_JEXEC',
- 'JPATH_PLATFORM',
- 'JPATH_BASE',
- 'AKEEBAENGINE',
- 'WF_EDITOR'
- );
+ // Get the constants to look for
+ $defines = $this->params->get('constants');
+ $defines = explode(',', $defines);
- foreach($content AS $line)
+ foreach ($content AS $line)
{
+ // Search for "defined"
+ $pos_1 = stripos($line, 'defined');
+
+ // Skip the line if "defined" is not found
+ if ($pos_1 === false) {
+ continue;
+ }
+
+ // Search for "die".
+ // "or" may not be present depending on syntax
+ $pos_3 = stripos($line, 'die');
+ // Skip the line if "die" is not found
+ if ($pos_3 === false) {
+ continue;
+ }
+
+ // Search for the constant name
foreach ($defines AS $define)
{
- // Search for "defined"
- $pos_1 = stripos($line, 'defined');
- // Skip the line if "defined" is not found
- if ($pos_1 === false) {
- continue;
- }
-
- // Search for "die".
- // "or" may not be present depending on syntax
- $pos_3 = stripos($line, 'die');
- // Skip the line if "die" is not found
- if ($pos_3 === false) {
- continue;
- }
+ $define = trim($define);
// Search for the define
$pos_2 = strpos($line, $define);
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php b/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
index 9287dbb..7636695 100644
--- a/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
+++ b/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
@@ -1,7 +1,7 @@
missing = array();
- $files = JFolder::files($basedir, '.xml$', true, true);
+ // Find all XML files of the extension
+ $files = JFolder::files($this->basedir, '.xml$', true, true);
- // Iterate through all files in the package
+ // Iterate through all the xml files
foreach ($files as $file)
{
- // Try to find the license in the file
- if (!$this->find($file)) {
- $this->missing[] = $file;
- }
+ // Try to find the license
+ $this->find($file);
}
-
-
- echo ''.JText::_('COM_JEDCHECKER_RULE_PH3') .'
';
-
- // Echo all files which failed the check
- if (count($this->missing)) {
- foreach ($this->missing AS $file)
- {
- echo $file.'
';
- }
- }
- else {
- echo ''.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'';
- }
-
}
@@ -81,12 +82,16 @@ class jedcheckerRulesXMLlicense
}
// Check if there's a license tag
- if (!isset($xml->license)) return false;
+ if (!isset($xml->license)) {
+ $this->report->addError($file, 'COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_FOUND');
+ return false;
+ }
// Check if the license is gpl
if (stripos($xml->license, 'gpl') === false &&
stripos($xml->license, 'general public license') === false)
{
+ $this->report->addCompat($file, 'COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_GPL');
return false;
}
diff --git a/source/administrator/components/com_jedchecker/models/index.html b/source/administrator/components/com_jedchecker/models/index.html
new file mode 100644
index 0000000..fa6d84e
--- /dev/null
+++ b/source/administrator/components/com_jedchecker/models/index.html
@@ -0,0 +1 @@
+
#'.str_pad($num, 3, '0', STR_PAD_LEFT).' '; + $html[] = $item->location; + + // Add line information if given + if($item->line > 0) { + $html[] = ' '.JText::_('COM_JEDCHECKER_IN_LINE').': '.$item->line.''; + } + + $html[] = '
'; + + // Add text if given + if(!empty($item->text)) { + $html[] = ''.$item->text.''; + } + + $html[] = '
-
-
-
-
-
+ jsOptions['rules'] AS $rule)
+ {
+ $class = 'jedcheckerRules'.ucfirst($rule);
-
-
-
-
-
+ + get('id').' - '.JText::_($rule->get('title'));?> + +
get('description')); ?>
+ +