mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-11-24 05:37:38 +00:00
adding an index.html check - yahoooo!!!
This commit is contained in:
parent
159ce452fa
commit
d41905a596
@ -0,0 +1,27 @@
|
||||
<?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');
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.filesystem');
|
||||
jimport('joomla.filesystem.archive');
|
||||
|
||||
class jedcheckerControllerPolice extends JController {
|
||||
public function check() {
|
||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/htmlindexes.php';
|
||||
$path = JPATH_COMPONENT_ADMINISTRATOR . '/tmp/';
|
||||
$police = new jedcheckerRulesHtmlindexes;
|
||||
$folders = JFolder::folders($path);
|
||||
|
||||
$police->check($path.$folders[0]);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?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();
|
||||
|
||||
public function check($startFolder){
|
||||
$this->findHtml($startFolder);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
echo 'those directories does not have an index file: <br />';
|
||||
foreach($indexes as $key => $index) {
|
||||
if(!$index) {
|
||||
echo $key . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function findHtml($start) {
|
||||
$iterator = new RecursiveDirectoryIterator($start);
|
||||
|
||||
// there should be a better way to find out if the main directory has an index.html file...
|
||||
if(file_exists($start.'/index.html')) {
|
||||
$this->folders[$start] = true;
|
||||
} else {
|
||||
$this->folders[$start] = false;
|
||||
}
|
||||
|
||||
foreach($iterator as $file){
|
||||
if($file->isFile()) {
|
||||
if($file->getFileName() == 'index.html') {
|
||||
// fill an array with the tables that contain an index.html file
|
||||
$this->indexes[$file->getPath()] = true;
|
||||
}
|
||||
} else {
|
||||
//let us save all folders in an array
|
||||
$this->folders[$file->getPathname()] = false;
|
||||
$this->findHtml($file->getPathname());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -20,5 +20,6 @@ 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user