mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-11-27 23:36:38 +00:00
Merge pull request #4 from nonumber/master
Changed rules htmlindexes and jexec
This commit is contained in:
commit
1bf912de15
@ -13,8 +13,9 @@ class jedcheckerRulesHtmlindexes {
|
|||||||
public $folders = array();
|
public $folders = array();
|
||||||
public $indexes = array();
|
public $indexes = array();
|
||||||
|
|
||||||
public function check($startFolder){
|
public function check($startFolder)
|
||||||
$this->findHtml($startFolder);
|
{
|
||||||
|
$this->findHtml($startFolder, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* let us "merge" the 2 arrays
|
* let us "merge" the 2 arrays
|
||||||
@ -42,30 +43,58 @@ class jedcheckerRulesHtmlindexes {
|
|||||||
* + it also saves all folders names in the folders array (folder_name => false)
|
* + it also saves all folders names in the folders array (folder_name => false)
|
||||||
* @param $start
|
* @param $start
|
||||||
*/
|
*/
|
||||||
public function findHtml($start) {
|
public function findHtml($start, $root = 0)
|
||||||
$iterator = new RecursiveDirectoryIterator($start);
|
{
|
||||||
|
|
||||||
// there should be a better way to find out if the main directory has an index.html file...
|
// array of system folders (regex)
|
||||||
if(file_exists($start.'/index.html')) {
|
// will match paths ending with these folders
|
||||||
$this->folders[$start] = true;
|
$system_folders = array(
|
||||||
} else {
|
'administrator',
|
||||||
$this->folders[$start] = false;
|
'components',
|
||||||
}
|
'language',
|
||||||
|
'language/.*',
|
||||||
|
'media',
|
||||||
|
'modules',
|
||||||
|
'plugins',
|
||||||
|
'plugins/content',
|
||||||
|
'plugins/editors',
|
||||||
|
'plugins/editors-xtd',
|
||||||
|
'plugins/finder',
|
||||||
|
'plugins/search',
|
||||||
|
'plugins/system',
|
||||||
|
'plugins/user'
|
||||||
|
);
|
||||||
|
|
||||||
|
$iterator = new DirectoryIterator($start);
|
||||||
|
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
if ($file->isFile()) {
|
if ($file->isFile()) {
|
||||||
if($file->getFileName() == 'index.html') {
|
continue;
|
||||||
// fill an array with the tables that contain an index.html file
|
}
|
||||||
$this->indexes[$file->getPath()] = true;
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 {
|
} else {
|
||||||
//let us save all folders in an array
|
// set parent to true too
|
||||||
$this->folders[$file->getPathname()] = false;
|
$this->folders[dirname($path)] = true;
|
||||||
$this->findHtml($file->getPathname());
|
}
|
||||||
|
// search in subfolders if not same as start
|
||||||
|
if ($path != $start) {
|
||||||
|
$this->findHtml($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -68,35 +68,45 @@ class jedcheckerRulesJexec
|
|||||||
{
|
{
|
||||||
$content = (array) file($file);
|
$content = (array) file($file);
|
||||||
|
|
||||||
|
$defines = array(
|
||||||
|
'_JEXEC',
|
||||||
|
'JPATH_PLATFORM',
|
||||||
|
'JPATH_BASE',
|
||||||
|
'AKEEBAENGINE',
|
||||||
|
'WF_EDITOR'
|
||||||
|
);
|
||||||
|
|
||||||
foreach($content AS $line)
|
foreach($content AS $line)
|
||||||
{
|
{
|
||||||
$pos_2 = strpos($line, '_JEXEC');
|
foreach ($defines AS $define)
|
||||||
|
{
|
||||||
// Skip the line if _JEXEC is not found
|
// Search for "defined"
|
||||||
if($pos_2 === false) {
|
|
||||||
// Alternatively search for JPATH_PLATFORM
|
|
||||||
$pos_2 = strpos($line, 'JPATH_PLATFORM');
|
|
||||||
|
|
||||||
// Nothing found, skip the line
|
|
||||||
if($pos_2 === false) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for "defined" and "die". "or" may not be present
|
|
||||||
// depending on syntax
|
|
||||||
$pos_1 = stripos($line, 'defined');
|
$pos_1 = stripos($line, 'defined');
|
||||||
$pos_3 = stripos($line, 'die');
|
// Skip the line if "defined" is not found
|
||||||
|
if ($pos_1 === false) {
|
||||||
// Both words must be present
|
|
||||||
if($pos_1 === false || $pos_3 === false) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search for "die".
|
||||||
|
// "or" may not be present depending on syntax
|
||||||
|
$pos_3 = stripos($line, 'die');
|
||||||
|
// Skip the line if "die" is not found
|
||||||
|
if ($pos_3 === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search for the define
|
||||||
|
$pos_2 = strpos($line, $define);
|
||||||
|
// Skip the line if the define is not found
|
||||||
|
if($pos_2 === false) continue;
|
||||||
|
|
||||||
// Check the position of the words
|
// Check the position of the words
|
||||||
if($pos_2 > $pos_1 && $pos_3 > $pos_2) {
|
if($pos_2 > $pos_1 && $pos_3 > $pos_2) {
|
||||||
unset($content);
|
unset($content);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unset($content);
|
unset($content);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user