33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-26 03:47:30 +00:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
eaxs 2012-06-25 20:38:40 +02:00
commit 9c517bc88a
25 changed files with 346 additions and 28 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/.idea /.idea
/builds/build.properties /builds/build.properties
/source/administrator/components/com_jedchecker/tmp /source/administrator/components/com_jedchecker/tmp
/tx.exe

16
.tx/config Normal file
View File

@ -0,0 +1,16 @@
[main]
host = compojoom
lang_map = af_ZA: af-ZA, am_ET: am-ET, ar_AE: ar-AE, ar_BH: ar-BH, ar_DZ: ar-DZ, ar_EG: ar-EG, ar_IQ: ar-IQ, ar_JO: ar-JO, ar_KW: ar-KW, ar_LB: ar-LB, ar_LY: ar-LY, ar_MA: ar-MA, ar_OM: ar-OM, ar_QA: ar-QA, ar_SA: ar-SA, ar_SY: ar-SY, ar_TN: ar-TN, ar_YE: ar-YE, arn_CL: arn-CL, as_IN: as-IN, az_AZ: az-AZ, ba_RU: ba-RU, be_BY: be-BY, bg_BG: bg-BG, bn_BD: bn-BD, bn_IN: bn-IN, bo_CN: bo-CN, br_FR: br-FR, bs_BA: bs-BA, ca_ES: ca-ES, co_FR: co-FR, cs_CZ: cs-CZ, cy_GB: cy-GB, da_DK: da-DK, de_AT: de-AT, de_CH: de-CH, de_DE: de-DE, de_LI: de-LI, de_LU: de-LU, dsb_DE: dsb-DE, dv_MV: dv-MV, el_GR: el-GR, en_AU: en-AU, en_BZ: en-BZ, en_CA: en-CA, en_GB: en-GB, en_IE: en-IE, en_IN: en-IN, en_JM: en-JM, en_MY: en-MY, en_NZ: en-NZ, en_PH: en-PH, en_SG: en-SG, en_TT: en-TT, en_US: en-US, en_ZA: en-ZA, en_ZW: en-ZW, es_AR: es-AR, es_BO: es-BO, es_CL: es-CL, es_CO: es-CO, es_CR: es-CR, es_DO: es-DO, es_EC: es-EC, es_ES: es-ES, es_GT: es-GT, es_HN: es-HN, es_MX: es-MX, es_NI: es-NI, es_PA: es-PA, es_PE: es-PE, es_PR: es-PR, es_PY: es-PY, es_SV: es-SV, es_US: es-US, es_UY: es-UY, es_VE: es-VE, et_EE: et-EE, eu_ES: eu-ES, fa_IR: fa-IR, fi_FI: fi-FI, fil_PH: fil-PH, fo_FO: fo-FO, fr_BE: fr-BE, fr_CA: fr-CA, fr_CH: fr-CH, fr_FR: fr-FR, fr_LU: fr-LU, fr_MC: fr-MC, fy_NL: fy-NL, ga_IE: ga-IE, gd_GB: gd-GB, gl_ES: gl-ES, gsw_FR: gsw-FR, gu_IN: gu-IN, ha_NG: ha-NG, he_IL: he-IL, hi_IN: hi-IN, hr_BA: hr-BA, hr_HR: hr-HR, hsb_DE: hsb-DE, hu_HU: hu-HU, hy_AM: hy-AM, id_ID: id-ID, ig_NG: ig-NG, ii_CN: ii-CN, is_IS: is-IS, it_CH: it-CH, it_IT: it-IT, iu_CA: iu-CA, ja_JP: ja-JP, ka_GE: ka-GE, kk_KZ: kk-KZ, kl_GL: kl-GL, km_KH: km-KH, kn_IN: kn-IN, ko_KR: ko-KR, kok_IN: kok-IN, ky_KG: ky-KG, lb_LU: lb-LU, lo_LA: lo-LA, lt_LT: lt-LT, lv_LV: lv-LV, mi_NZ: mi-NZ, mk_MK: mk-MK, ml_IN: ml-IN, mn_CN: mn-CN, mn_MN: mn-MN, moh_CA: moh-CA, mr_IN: mr-IN, ms_BN: ms-BN, ms_MY: ms-MY, mt_MT: mt-MT, nb_NO: nb-NO, ne_NP: ne-NP, nl_BE: nl-BE, nl_NL: nl-NL, nn_NO: nn-NO, nso_ZA: nso-ZA, oc_FR: oc-FR, or_IN: or-IN, pa_IN: pa-IN, pl_PL: pl-PL, prs_AF: prs-AF, ps_AF: ps-AF, pt_BR: pt-BR, pt_PT: pt-PT, qut_GT: qut-GT, quz_BO: quz-BO, quz_EC: quz-EC, quz_PE: quz-PE, rm_CH: rm-CH, ro_RO: ro-RO, ru_RU: ru-RU, rw_RW: rw-RW, sa_IN: sa-IN, sah_RU: sah-RU, se_FI: se-FI, se_NO: se-NO, se_SE: se-SE, si_LK: si-LK, sk_SK: sk-SK, sl_SI: sl-SI, sma_NO: sma-NO, sma_SE: sma-SE, smj_NO: smj-NO, smj_SE: smj-SE, smn_FI: smn-FI, sms_FI: sms-FI, sq_AL: sq-AL, sr_BA: sr-BA, sr_CS: sr-CS, sr_ME: sr-ME, sr_RS: sr-RS, sv_FI: sv-FI, sv_SE: sv-SE, sw_KE: sw-KE, syr_SY: syr-SY, ta_IN: ta-IN, te_IN: te-IN, tg_TJ: tg-TJ, th_TH: th-TH, tk_TM: tk-TM, tn_ZA: tn-ZA, tr_TR: tr-TR, tt_RU: tt-RU, tzm_DZ: tzm-DZ, ug_CN: ug-CN, uk_UA: uk-UA, ur_PK: ur-PK, uz_UZ: uz-UZ, vi_VN: vi-VN, wo_SN: wo-SN, xh_ZA: xh-ZA, yo_NG: yo-NG, zh_CN: zh-CN, zh_HK: zh-HK, zh_MO: zh-MO, zh_SG: zh-SG, zh_TW: zh-TW, zu_ZA: zu-ZA
type = INI
[compojoom-jedchecker.admin_com_jedchecker]
file_filter = source\administrator\language\<lang>\<lang>.com_jedchecker.ini
source_file = source\administrator\language\en-GB\en-GB.com_jedchecker.ini
source_lang = en_GB
minimum_perc = 100
[compojoom-jedchecker.admin_com_jedchecker_sys]
file_filter = source\administrator\language\<lang>\<lang>.com_jedchecker.sys.ini
source_file = source\administrator\language\en-GB\en-GB.com_jedchecker.sys.ini
source_lang = en_GB
minimum_perc = 100

16
README Normal file
View File

@ -0,0 +1,16 @@
JEDchecker
This extension is able to check your components, modules or plugins for common errors that will prevent you
from publishing your extension on the JED.
If you want to write a rule have a look a the library/rules folder.
You just need to add a new file with your rule. Example:
yourrule.php
"yourrule.php" needs to have a class jedcheckerRulesYourrule and that class needs to have a
function that accepts the basedir as parameter. This is all - the component will automatically call
your rule check function.
ZIP packages for installation in joomla can be found here:
https://compojoom.com/downloads/official-releases-stable/jedchecker

View File

@ -77,7 +77,7 @@
<copy todir="${destination.dir}/administrator/language/"> <copy todir="${destination.dir}/administrator/language/">
<fileset dir="${dirs.source}/administrator/language/"> <fileset dir="${dirs.source}/administrator/language/">
<include name="**/*.${component.name}.**"/> <include name="**/*.com_${component.name}.**"/>
</fileset> </fileset>
</copy> </copy>
@ -96,7 +96,7 @@
<then> <then>
<copy todir="${destination.dir}/language/"> <copy todir="${destination.dir}/language/">
<fileset dir="${dirs.source}/language/"> <fileset dir="${dirs.source}/language/">
<include name="**/*.${component.name}.ini"/> <include name="**/*.com_${component.name}.ini"/>
</fileset> </fileset>
</copy> </copy>
</then> </then>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -17,7 +17,7 @@ class jedcheckerControllerUploads extends JController
public function __construct() public function __construct()
{ {
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker'; $this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
$this->pathArchive = $this->path . '/arhives'; $this->pathArchive = $this->path . '/archives';
$this->pathUnzipped = $this->path . '/unzipped'; $this->pathUnzipped = $this->path . '/unzipped';
parent::__construct(); parent::__construct();
} }

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -22,12 +22,17 @@ class jedcheckerRulesHtmlindexes {
*/ */
$indexes = array_replace($this->folders, $this->indexes); $indexes = array_replace($this->folders, $this->indexes);
echo 'those directories does not have an index file: <br />'; echo '<span class="rule">'.JText::_('COM_JEDCHECKER_RULE_SE1') . '</span><br />';
if(count($indexes)) {
foreach($indexes as $key => $index) { foreach($indexes as $key => $index) {
if(!$index) { if(!$index) {
echo $key . '<br />'; echo $key . '<br />';
} }
} }
} else {
echo '<span class="success">'.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'</span>';
}
} }

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,99 @@
<?php
/**
* @author eaxs
* @date 06/08/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 files for the _JEXEC check
* which prevents direct file access.
*
*/
class jedcheckerRulesJexec
{
/**
* Holds all file names that failed to pass the check
* @var array
*/
protected $missing;
/**
* Initiates the file 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, '.php', true, true);
// Iterate through all files in the package
foreach($files as $file)
{
// Try to find the _JEXEC check in the file
if(!$this->findJExec($file)) {
$this->missing[] = $file;
}
}
echo '<span class="rule">'.JText::_('COM_JEDCHECKER_RULE_PH2') .'</span><br/>';
if(count($this->missing)) {
// Echo all files which don't have the _JEXEC check
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 _JEXEC statement
*
* @param string $file The path to the file
* @return boolean True if the statement was found, otherwise False.
*/
protected function findJexec($file)
{
$content = (array) file($file);
foreach($content AS $line)
{
$pos_2 = strpos($line, '_JEXEC');
// Skip the line if _JEXEC is not found
if($pos_2 === false) continue;
// Search for "defined" and "die". "or" may not be present
// depending on syntax
$pos_1 = stripos($line, 'defined');
$pos_3 = stripos($line, 'die');
// Both words must be present
if($pos_1 === false || $pos_3 === false) {
continue;
}
// Check the position of the words
if($pos_2 > $pos_1 && $pos_3 > $pos_2) {
unset($content);
return true;
}
}
unset($content);
return false;
}
}

View File

@ -1,8 +1,10 @@
<?php <?php
/** /**
* Created by JetBrains PhpStorm. * @author Daniel Dimitrov - compojoom.com
* User: Dq * @date: 02.06.12
* Date: 21/05/12 *
* Time: 10:40 * @copyright Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
* To change this template use File | Settings | File Templates. * @license GNU General Public License version 2 or later; see LICENSE
*/ */
defined('_JEXEC') or die('Restricted access');

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -26,15 +26,94 @@ JHtml::script('media/com_jedchecker/js/police.js');
} }
</script> </script>
<div class="fltlft width-60">
<form action="<?php echo JRoute::_('index.php?option=com_jedchecker&view=uploads'); ?>" <form action="<?php echo JRoute::_('index.php?option=com_jedchecker&view=uploads'); ?>"
method="post" class="form form-validate" name="adminForm" id="adminForm" enctype="multipart/form-data"> method="post" class="form form-validate" name="adminForm" id="adminForm" enctype="multipart/form-data">
<fieldset>
<p>
<?php echo JText::sprintf('COM_JEDCHECKER_CONGRATS', 'http://extensions.joomla.org/index.php?option=com_content&id=50'); ?>
</p>
<p>
<?php echo JText::sprintf('COM_JEDCHECKER_CODE_STANDARDS', 'http://developer.joomla.org/coding-standards.html', 'https://github.com/compojoom/jedchecker'); ?>
</p>
<p>
<?php echo JText::_('COM_JEDCHECKER_HOW_TO_USE'); ?>
</p>
<ol>
<li> 1. <?php echo JText::_('COM_JEDCHECKER_STEP1'); ?></li>
<li> 2. <?php echo JText::_('COM_JEDCHECKER_STEP2'); ?></li>
<li> 3. <?php echo JText::_('COM_JEDCHECKER_STEP3'); ?></li>
</ol>
<input type="file" name="extension" class="required"/> <input type="file" name="extension" class="required"/>
<button onclick="Joomla.submitbutton('uploads.upload')"> <button onclick="Joomla.submitbutton('uploads.upload')">
submit <?php echo JText::_('JSUBMIT'); ?>
</button> </button>
<input type="hidden" name="task" value=""/> <input type="hidden" name="task" value=""/>
<?php echo JHTML::_('form.token'); ?> <?php echo JHTML::_('form.token'); ?>
</fieldset>
</form> </form>
</div>
<div class="fltrt width-40">
<div class="help">
<h2><?php echo JText::_('COM_JEDCHECKER_WALL_OF_HONOR'); ?></h2>
<p><?php echo JText::_('COM_JEDCHECKER_PEOPLE_THAT_HAVE_HELPED_WITH_THE_DEVELOPMENT'); ?></p>
<ul>
<li>Tobias Kuhn (<a href="http://projectfork.com" target="_blank">projectfork</a>)</li>
</ul>
</div>
</div>
<div id="prison" style="display:none;">
<div class="fltlft width-60">
<div id="police-check-result"></div> <div id="police-check-result"></div>
</div>
<div class="fltrt width-40">
<div class="help">
<h2>
<?php echo JText::_('COM_JEDCHECKER_HOW_TO_INTERPRET_RESULTS'); ?>
</h2>
<ul>
<li>
<p>
<span class="rule"><?php echo JText::_('COM_JEDCHECKER_RULE_SE1'); ?></span><br />
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_DESC'); ?>
</p>
<p>
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING'); ?> <br />
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING1'); ?><br />
<i>administrator/components/your_component</i> <br/>
<i>components/your_component</i> <br/>
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING2'); ?><br />
<i>administrator</i><br/>
<i>administrator/components</i><br/>
<i>administrator/components/your_component</i><br/>
<i>components/</i><br/>
<i>components/your_component</i><br/>
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING3'); ?><br />
<i>administrator/components/your_component</i><br/>
<i>components/your_component</i><br/>
<?php echo JText::_('COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING4'); ?>
</p>
</li>
<li>
<p>
<span class="rule"><?php echo JText::_('COM_JEDCHECKER_RULE_PH2'); ?></span><br />
<?php echo JText::_('COM_JEDCHECKER_RULE_PH2_DESC'); ?>
</p>
</li>
</ul>
</div>
</div>
</div>
<div class="clr"></div>
<div class="copyright">
<?php echo JText::sprintf('COM_JEDCHECKER_DEVELOPED_BY', 'https://compojoom.com'); ?> :)
</div>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -34,7 +34,28 @@ class jedcheckerViewUploads extends JView
public function setToolbar() public function setToolbar()
{ {
if($this->filesExist('archives')) {
JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false); JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false);
}
if($this->filesExist('unzipped')) {
JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'check', false); JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'check', false);
} }
JToolBarHelper::title('JED checker');
}
/**
* Checks if folder + files exist in the jed_checker tmp path
* @param $type
* @return bool
*/
private function filesExist($type) {
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/'.$type;
if(JFolder::exists($path)) {
if(JFolder::folders($path, '.', false) || JFolder::files($path, '.', false)) {
return true;
}
}
return false;
}
} }

View File

@ -1,4 +1,26 @@
; Language files have to start with semicolon (;) otherwise we have problems with transifex ; Language files have to start with semicolon (;) otherwise we have problems with transifex
COM_JEDCHECKER_UPLOAD_WAS_SUCCESSFUL="Upload was successful" COM_JEDCHECKER_UPLOAD_WAS_SUCCESSFUL="Upload was successful"
COM_JEDCHECKER_UNZIP_SUCCESS="Unzip was successful! Now go ahead and click that check button!" COM_JEDCHECKER_UNZIP_SUCCESS="Unzip was successful! Now go ahead and click that check button!"
COM_JEDCHECKER_UNZIP_FAILED="Unzip failed"; COM_JEDCHECKER_UNZIP_FAILED="Unzip failed"
COM_JEDCHECKER_CONGRATS="Congratulations! If you use this component then you've most probably developed a Joomla!® extension! Now comes the &quot;hard&quot; part - getting it listed in the Joomla Extension Directory (JED). The JED has strict requirements to the extensions that get listed there. Those requirements can be found <a href='%s' target='_blank'>here</a>. Currently extensions are being manually tested for code problems. This component is an attempt to simplify your and the JED editors life's by automatically checking the code for common errors in extensions."
COM_JEDCHECKER_CODE_STANDARDS="However our goal is not only to test the extensions against common code errors that prevent it from getting listed in the JED. Our goal is to also have code standards checks such as the <a href='%s' target='_blank'>JPlatform has</a>. This would ensure that joomla extension developers are aware of the JPlatform coding standards and this could raise the quality bar in our Joomla community even higher! For this we will need you! Have a look at the <a href='%s' target='_blank'>github project page</a>. Fork the component! Add your code checks and send us your pull requests!"
COM_JEDCHECKER_HOW_TO_USE="So how to use this component???"
COM_JEDCHECKER_STEP1="Upload your component/plugin/module zip file by using the upload form below"
COM_JEDCHECKER_STEP2="Click on unzip"
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_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:"
COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING2="If the JEDchecker tells you that you have missing index.html in the following folders:"
COM_JEDCHECKER_RULE_SE1_MORE_INFO_INTERPRETING3="You actually need to worry only about"
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_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>"

View File

@ -0,0 +1,2 @@
; Language files have to start with semicolon (;) otherwise we have problems with transifex
COM_JEDCHECKER="JEDchecker"

View File

@ -4,3 +4,45 @@
.icon-32-police-check { .icon-32-police-check {
background-image: url(../icons/inspect.png); background-image: url(../icons/inspect.png);
} }
#adminForm {
background: #FFF;
}
#police-check-result {
background: #F6F6F6;
border: 1px solid #CCC;
}
#police-check-result div:nth-child(odd){
border-bottom: 1px solid #CCCCCC;
}
#police-check-result div:nth-child(even){
background: #EBF1F2;
}
#police-check-result div {
padding: 5px 10px 5px;
}
.help {
padding: 5px;
border: 1px solid #CCCCCC;
background: #FFF;
margin-left: 10px;
}
.copyright {
line-height: 160%;
margin: 10px;
text-align: center;
}
.rule {
font-weight: bold;
}
.success {
color: green;
font-weight: bold;
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -16,6 +16,7 @@ var police = new Class({
this.options.rules.each(function(rule){ this.options.rules.each(function(rule){
self.check(rule); self.check(rule);
}); });
new Fx.Scroll(window).toElement(document.id('police-check-result'));
}, },
check: function(rule) { check: function(rule) {
@ -28,6 +29,7 @@ var police = new Class({
html: result html: result
}); });
div.inject(document.id('police-check-result')); div.inject(document.id('police-check-result'));
document.id('prison').setStyle('display', 'block');
} }
}).send(); }).send();
} }