From f4bc0d131e3be7875065f971627897feea105c30 Mon Sep 17 00:00:00 2001
From: eaxs
Date: Tue, 26 Jun 2012 12:37:12 +0200
Subject: [PATCH] Added rule PH3 check
---
.../libraries/rules/xmllicense.php | 97 +++++++++++++++++++
.../views/uploads/tmpl/default.php | 6 ++
.../language/en-GB/en-GB.com_jedchecker.ini | 4 +-
3 files changed, 106 insertions(+), 1 deletion(-)
create mode 100644 source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
diff --git a/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php b/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
new file mode 100644
index 00000000..9287dbb1
--- /dev/null
+++ b/source/administrator/components/com_jedchecker/libraries/rules/xmllicense.php
@@ -0,0 +1,97 @@
+missing = array();
+ $files = JFolder::files($basedir, '.xml$', true, true);
+
+ // Iterate through all files in the package
+ foreach ($files as $file)
+ {
+ // Try to find the license in the file
+ if (!$this->find($file)) {
+ $this->missing[] = $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').'';
+ }
+
+ }
+
+
+ /**
+ * Reads a file and searches for the license
+ *
+ * @param string $file The path to the file
+ * @return boolean True if the license was found, otherwise False.
+ */
+ protected function find($file)
+ {
+ $xml = JFactory::getXML($file);
+
+ // Failed to parse the xml file.
+ // Assume that this is not a extension manifest
+ if (!$xml) return true;
+
+ // Check if this is an extension manifest
+ // 1.5 uses 'install', 1.6 uses 'extension'
+ if ($xml->getName() != 'install' && $xml->getName() != 'extension')
+ {
+ return true;
+ }
+
+ // Check if there's a license tag
+ if (!isset($xml->license)) return false;
+
+ // Check if the license is gpl
+ if (stripos($xml->license, 'gpl') === false &&
+ stripos($xml->license, 'general public license') === false)
+ {
+ return false;
+ }
+
+
+ // All checks passed. Return true
+ return true;
+ }
+}
diff --git a/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php b/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php
index 8b998ce8..d754d0d4 100644
--- a/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php
+++ b/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php
@@ -109,6 +109,12 @@
+
+
+
+
+
+
diff --git a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini
index 290cec06..fcd3aeed 100644
--- a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini
+++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini
@@ -11,7 +11,7 @@ COM_JEDCHECKER_STEP3="Click on check and review the results"
COM_JEDCHECKER_WALL_OF_HONOR="Wall of honor"
COM_JEDCHECKER_PEOPLE_THAT_HAVE_HELPED_WITH_THE_DEVELOPMENT="People that have helped with the development of this component"
COM_JEDCHECKER_HOW_TO_INTERPRET_RESULTS="How to interpret the results?"
-COM_JEDCHECKER_RULE_SE1="Rule:SE1 - Extension is missing index.html file in all folders"
+COM_JEDCHECKER_RULE_SE1="Rule SE1 - Extension is missing index.html file in all folders"
COM_JEDCHECKER_RULE_SE1_DESC="If you want your extension to be listed on the JED, then you should make sure that all your extension folders contain an index.html file. - Developers don't like this rule at all - it fills your package with index.html files, which in terms slows down the installation process etc. But index.html files provide protection for badly configured hosts (one could argue if we need to try to do anything for those), but as long the joomla CMS comes with those files the JED is going to require that extensions also have those."
COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING="The JEDchecker checks every single folder in your package for the presence of index.html files,but this doesn't mean that all folders need to have an index.html file. For example - language folders don't need to have an index.html file, because the joomla CMS has index.html files in those locations.If your package has the following structure:"
COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING1="Properly reading the JEDchecker results for SE1:"
@@ -20,6 +20,8 @@ COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING3="You actually need to worry only
COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING4="as those 2 folders won't have the index.html files when your component gets installed"
COM_JEDCHECKER_RULE_PH2="Rule PH2 - PHP Files missing JEXEC security"
COM_JEDCHECKER_RULE_PH2_DESC="All the PHP files in your extension needs to have a defined('_JEXEC') or die(); statement in the beginning of each file. This ensures that the file cannot be opened outside of the joomla installation and this way increases the security of your site."
+COM_JEDCHECKER_RULE_PH3="Rule PH3 - License tag missing or incorrect in XML install file"
+COM_JEDCHECKER_RULE_PH3_DESC="An install file should include the license information in a license-tag. The license must be GPL or GPL compatible."
COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE="Congrats! Everything seems to be fine with that rule!"
COM_JEDCHECKER_DEVELOPED_BY="JEDchecker is primary developed by compojoom.com"