2012-06-02 22:38:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Daniel Dimitrov - compojoom.com
|
|
|
|
* @date: 02.06.12
|
|
|
|
*
|
|
|
|
* @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');
|
|
|
|
|
|
|
|
class jedcheckerRulesHtmlindexes {
|
|
|
|
public $folders = array();
|
|
|
|
public $indexes = array();
|
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
public function check($startFolder)
|
|
|
|
{
|
|
|
|
$this->findHtml($startFolder, 1);
|
2012-06-02 22:38:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* let us "merge" the 2 arrays
|
|
|
|
* If a folder has an index.html file, then the value of the folders array will be true
|
|
|
|
*/
|
|
|
|
$indexes = array_replace($this->folders, $this->indexes);
|
|
|
|
|
2012-06-23 14:12:44 +00:00
|
|
|
echo '<span class="rule">'.JText::_('COM_JEDCHECKER_RULE_SE1') . '</span><br />';
|
2012-06-28 07:39:00 +00:00
|
|
|
if(count($indexes) && in_array(false, $indexes)) {
|
2012-06-23 14:12:44 +00:00
|
|
|
foreach($indexes as $key => $index) {
|
|
|
|
if(!$index) {
|
|
|
|
echo $key . '<br />';
|
|
|
|
}
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
2012-06-23 14:12:44 +00:00
|
|
|
} else {
|
|
|
|
echo '<span class="success">'.JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE').'</span>';
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 14:12:44 +00:00
|
|
|
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recursively checking if each folder in the package has index.html files
|
|
|
|
* if it has it saves the info the indexes array (folder_name => true)
|
|
|
|
* + it also saves all folders names in the folders array (folder_name => false)
|
|
|
|
* @param $start
|
|
|
|
*/
|
2012-06-27 14:08:33 +00:00
|
|
|
public function findHtml($start, $root = 0)
|
|
|
|
{
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
// 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'
|
|
|
|
);
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
$iterator = new DirectoryIterator($start);
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
foreach ($iterator as $file) {
|
|
|
|
if ($file->isFile()) {
|
|
|
|
continue;
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
$path = $file->getPathname();
|
|
|
|
|
|
|
|
// set the path to the root start path only for first time
|
|
|
|
if ($root && $file->getFileName() == '.') {
|
|
|
|
$path = $start;
|
|
|
|
} else if ($file->isDot()) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-06-02 22:38:07 +00:00
|
|
|
|
2012-06-27 14:08:33 +00:00
|
|
|
$this->folders[$path] = true;
|
|
|
|
// only check index.html in non-system folders
|
|
|
|
if (!preg_match('#/('.implode('|', $system_folders).')$#i', str_replace('\\', '/', $path))) {
|
|
|
|
if (!file_exists($path.'/index.html')) {
|
|
|
|
$this->folders[$path] = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// set parent to true too
|
|
|
|
$this->folders[dirname($path)] = true;
|
|
|
|
}
|
|
|
|
// search in subfolders if not same as start
|
|
|
|
if ($path != $start) {
|
|
|
|
$this->findHtml($path);
|
|
|
|
}
|
|
|
|
}
|
2012-06-02 22:38:07 +00:00
|
|
|
}
|
|
|
|
}
|