31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-05 23:10:47 +00:00

Added rule PH3 check

This commit is contained in:
eaxs 2012-06-26 12:37:12 +02:00
parent c43c77b9f4
commit f4bc0d131e
3 changed files with 106 additions and 1 deletions

View File

@ -0,0 +1,97 @@
<?php
/**
* @author eaxs
* @date 06/26/2012
* @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');
/**
* This class searches all xml manifestes for a valid license.
*
*/
class jedcheckerRulesXMLlicense
{
/**
* Holds all files that failed to pass the check
* @var array
*/
protected $missing;
/**
* Initiates the search and check
*
* @param string $basedir The base directory of the package to check
* @return void
*/
public function check($basedir)
{
$this->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 '<span class="rule">'.JText::_('COM_JEDCHECKER_RULE_PH3') .'</span><br/>';
// Echo all files which failed the check
if (count($this->missing)) {
foreach ($this->missing AS $file)
{
echo $file.'<br/>';
}
}
else {
echo '<span class="success">'.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'</span>';
}
}
/**
* 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;
}
}

View File

@ -109,6 +109,12 @@ JHtml::script('media/com_jedchecker/js/police.js');
</p>
</li>
<li>
<p>
<span class="rule"><?php echo JText::_('COM_JEDCHECKER_RULE_PH3'); ?></span><br />
<?php echo JText::_('COM_JEDCHECKER_RULE_PH3_DESC'); ?>
</p>
</li>
</ul>
</div>
</div>

View File

@ -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 <a href='%s'>compojoom.com</a>"