diff --git a/.gitignore b/.gitignore index 29fbb2f..5f31a70 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /packages /.idea /builds/build.properties -/source/administrator/components/com_jedchecker/tmp \ No newline at end of file +/source/administrator/components/com_jedchecker/tmp +/tx.exe \ No newline at end of file diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..7dfea20 --- /dev/null +++ b/.tx/config @@ -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\\.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\\.com_jedchecker.sys.ini +source_file = source\administrator\language\en-GB\en-GB.com_jedchecker.sys.ini +source_lang = en_GB +minimum_perc = 100 diff --git a/README b/README new file mode 100644 index 0000000..3dec29f --- /dev/null +++ b/README @@ -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 \ No newline at end of file diff --git a/builds/component.xml b/builds/component.xml index 5423286..987d0b7 100644 --- a/builds/component.xml +++ b/builds/component.xml @@ -77,7 +77,7 @@ - + @@ -96,7 +96,7 @@ - + diff --git a/source/administrator/components/com_jedchecker/controllers/index.html b/source/administrator/components/com_jedchecker/controllers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/controllers/uploads.php b/source/administrator/components/com_jedchecker/controllers/uploads.php index c770488..23601f3 100644 --- a/source/administrator/components/com_jedchecker/controllers/uploads.php +++ b/source/administrator/components/com_jedchecker/controllers/uploads.php @@ -17,7 +17,7 @@ class jedcheckerControllerUploads extends JController public function __construct() { $this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker'; - $this->pathArchive = $this->path . '/arhives'; + $this->pathArchive = $this->path . '/archives'; $this->pathUnzipped = $this->path . '/unzipped'; parent::__construct(); } diff --git a/source/administrator/components/com_jedchecker/index.html b/source/administrator/components/com_jedchecker/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/libraries/index.html b/source/administrator/components/com_jedchecker/libraries/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/libraries/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php index c5087fd..7d00704 100644 --- a/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php +++ b/source/administrator/components/com_jedchecker/libraries/rules/htmlindexes.php @@ -22,13 +22,18 @@ class jedcheckerRulesHtmlindexes { */ $indexes = array_replace($this->folders, $this->indexes); - echo 'those directories does not have an index file:
'; - foreach($indexes as $key => $index) { - if(!$index) { - echo $key . '
'; + echo ''.JText::_('COM_JEDCHECKER_RULE_SE1') . '
'; + if(count($indexes)) { + foreach($indexes as $key => $index) { + if(!$index) { + echo $key . '
'; + } } + } else { + echo ''.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').''; } + } /** diff --git a/source/administrator/components/com_jedchecker/libraries/rules/index.html b/source/administrator/components/com_jedchecker/libraries/rules/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/libraries/rules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/libraries/rules/jexec.php b/source/administrator/components/com_jedchecker/libraries/rules/jexec.php new file mode 100644 index 0000000..70be4d4 --- /dev/null +++ b/source/administrator/components/com_jedchecker/libraries/rules/jexec.php @@ -0,0 +1,99 @@ +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 ''.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').''; + } + + } + + + /** + * 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; + } +} diff --git a/source/administrator/components/com_jedchecker/script.php b/source/administrator/components/com_jedchecker/script.php index 5b00a62..b5c9881 100644 --- a/source/administrator/components/com_jedchecker/script.php +++ b/source/administrator/components/com_jedchecker/script.php @@ -1,8 +1,10 @@ \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/views/uploads/index.html b/source/administrator/components/com_jedchecker/views/uploads/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/views/uploads/index.html @@ -0,0 +1 @@ + \ No newline at end of file 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 487149c..e79bd1d 100644 --- a/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php +++ b/source/administrator/components/com_jedchecker/views/uploads/tmpl/default.php @@ -16,7 +16,7 @@ JHtml::stylesheet('media/com_jedchecker/css/css.css'); JHtml::script('media/com_jedchecker/js/police.js'); ?> -
+
+ +
+

+ +

+

+ +

+

+ +

+
    +
  1. 1.
  2. +
  3. 2.
  4. +
  5. 3.
  6. +
- - - - - -
\ No newline at end of file + + + + +
+ +
+
+
+

+

+ +
+
+ +
+ diff --git a/source/administrator/components/com_jedchecker/views/uploads/tmpl/index.html b/source/administrator/components/com_jedchecker/views/uploads/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/administrator/components/com_jedchecker/views/uploads/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/administrator/components/com_jedchecker/views/uploads/view.html.php b/source/administrator/components/com_jedchecker/views/uploads/view.html.php index 1a29659..08b7c72 100644 --- a/source/administrator/components/com_jedchecker/views/uploads/view.html.php +++ b/source/administrator/components/com_jedchecker/views/uploads/view.html.php @@ -34,7 +34,28 @@ class jedcheckerViewUploads extends JView public function setToolbar() { - JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false); - JToolBarHelper::custom('police.check', 'police-check', 'police-check', 'check', false); + if($this->filesExist('archives')) { + JToolBarHelper::custom('uploads.unzip', 'unzip', 'unzip', 'unzip', false); + } + if($this->filesExist('unzipped')) { + 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; } } \ No newline at end of file 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 70acda3..290cec0 100644 --- a/source/administrator/language/en-GB/en-GB.com_jedchecker.ini +++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.ini @@ -1,4 +1,26 @@ ; Language files have to start with semicolon (;) otherwise we have problems with transifex 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_FAILED="Unzip failed"; \ No newline at end of file +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 "hard" 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 here. 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 JPlatform has. 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 github project page. 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 compojoom.com" + + diff --git a/source/administrator/language/en-GB/en-GB.com_jedchecker.sys.ini b/source/administrator/language/en-GB/en-GB.com_jedchecker.sys.ini new file mode 100644 index 0000000..8006706 --- /dev/null +++ b/source/administrator/language/en-GB/en-GB.com_jedchecker.sys.ini @@ -0,0 +1,2 @@ +; Language files have to start with semicolon (;) otherwise we have problems with transifex +COM_JEDCHECKER="JEDchecker" \ No newline at end of file diff --git a/source/media/com_jedchecker/css/css.css b/source/media/com_jedchecker/css/css.css index 32f078a..3d44544 100644 --- a/source/media/com_jedchecker/css/css.css +++ b/source/media/com_jedchecker/css/css.css @@ -3,4 +3,46 @@ } .icon-32-police-check { 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; } \ No newline at end of file diff --git a/source/media/com_jedchecker/css/index.html b/source/media/com_jedchecker/css/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/media/com_jedchecker/css/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/media/com_jedchecker/icons/index.html b/source/media/com_jedchecker/icons/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/media/com_jedchecker/icons/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/media/com_jedchecker/index.html b/source/media/com_jedchecker/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/media/com_jedchecker/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/media/com_jedchecker/js/index.html b/source/media/com_jedchecker/js/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/source/media/com_jedchecker/js/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/media/com_jedchecker/js/police.js b/source/media/com_jedchecker/js/police.js index 628db5a..b2a1410 100644 --- a/source/media/com_jedchecker/js/police.js +++ b/source/media/com_jedchecker/js/police.js @@ -16,6 +16,7 @@ var police = new Class({ this.options.rules.each(function(rule){ self.check(rule); }); + new Fx.Scroll(window).toElement(document.id('police-check-result')); }, check: function(rule) { @@ -28,6 +29,7 @@ var police = new Class({ html: result }); div.inject(document.id('police-check-result')); + document.id('prison').setStyle('display', 'block'); } }).send(); }