diff --git a/e107_admin/fileinspector.php b/e107_admin/fileinspector.php index 2f90ce306..6b970bf13 100644 --- a/e107_admin/fileinspector.php +++ b/e107_admin/fileinspector.php @@ -53,9 +53,10 @@ if(isset($_GET['scan'])) //header("Content-type: text/html; charset=".CHARSET, true); //$css_file = file_exists(e_THEME.$pref['admintheme'].'/'.$pref['admincss']) ? e_THEME.$pref['admintheme'].'/'.$pref['admincss'] : e_THEME.$pref['admintheme'].'/'.$pref['admincss']; - $fi = new file_inspector; +// $fi = new file_inspector; + + $fi = e107::getSingleton('file_inspector'); - echo " @@ -96,7 +97,8 @@ if(isset($_GET['scan'])) } else { - $fi = new file_inspector; + // $fi = new file_inspector; + $fi = e107::getSingleton('file_inspector'); @@ -149,12 +151,46 @@ class file_inspector { // private $icon = array(); private $iconTag = array(); + private $options = array( + 'core' => '', + 'type' =>'list', + 'missing' => 0, + 'noncore' => 9, + 'nolang' => 1, + 'oldcore' => 0, + 'integrity' => 1, + 'regex' => 0, + 'mod' => '', + 'num' => 0, + 'line' => 0 + ); + + + function setOptions($post) + { + foreach($this->options as $k=>$v) + { + if(isset($post[$k])) + { + $this->options[$k] = $post[$k]; + } + } + + } + + function __construct() { $lng = e107::getLanguage(); $langs = $lng->installed(); + if(isset($_GET['scan'])) + { + $this->setOptions($_GET); + } + + foreach($langs as $k=>$val) { if($val == "English") // Core release language, so ignore it. @@ -170,9 +206,6 @@ class file_inspector { $this->lang_short = $lang_short; - - - //TODO LAN $this->glyph = array( @@ -194,6 +227,7 @@ class file_inspector { 'folder_unknown' => array('', "Non-core Folder"), 'file_check' => array('', "Core File (Integrity Pass)"), + 'file_core' => array('', "Core File (Unchecked)"), 'file_fail' => array('', "Core File (Integrity Fail)"), 'file_missing' => array('', "Core File (Missing)"), 'file_old' => array('', "Core File (Old)"), @@ -219,15 +253,21 @@ class file_inspector { $this->countFiles($core_image); $this -> root_dir = $e107 -> file_path; - if (substr($this -> root_dir, -1) == '/') { + if (substr($this -> root_dir, -1) == '/') + { $this -> root_dir = substr($this -> root_dir, 0, -1); } - if ($_POST['core'] == 'fail') { + + if ($_POST['core'] == 'fail') + { $_POST['integrity'] = TRUE; } - if (MAGIC_QUOTES_GPC && vartrue($_POST['regex'])) { + + if (MAGIC_QUOTES_GPC && vartrue($_POST['regex'])) + { $_POST['regex'] = stripslashes($_POST['regex']); } + if ($_POST['regex']) { if ($_POST['core'] == 'fail') { $_POST['core'] = 'all'; @@ -236,7 +276,14 @@ class file_inspector { $_POST['integrity'] = 0; } } - + + + private function opt($key) + { + return $this->options[$key]; + } + + // Find the Total number of core files before scanning begins. function countFiles($array) { @@ -580,7 +627,7 @@ class file_inspector { if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== false) { // We're checking a file here - if ($_POST['core'] != 'none') + if ($this->opt('core') != 'none') { // Look at core files $this -> count['core']['num']++; $this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size']; @@ -609,7 +656,7 @@ class file_inspector { } else { - if ($_POST['integrity']) + if ($this->opt('integrity')) { // Actually check file integrity switch ($this_action = $this->check_action($dir,$key)) { @@ -628,7 +675,7 @@ class file_inspector { $this -> count['pass']['num']++; $this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size']; - if ($_POST['core'] != 'fail') + if ($this->opt('core') != 'fail') { $this -> files[$dir_id][$fid]['icon'] = 'file_check'; $dir_icon = ($dir_icon == 'folder_fail' || $dir_icon == 'folder_missing') ? $dir_icon : 'folder_check'; @@ -645,7 +692,7 @@ class file_inspector { case 'nocalc' : $this -> count['uncalculable']['num']++; $this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size']; - if ($_POST['core'] != 'fail') + if ($this->opt('core') != 'fail') { $this -> files[$dir_id][$fid]['icon'] = 'file_uncalc'; @@ -670,7 +717,7 @@ class file_inspector { $known[$dir_id][$fid] = true; } } - else if ($_POST['missing']) + else if ($this->opt('missing')) { switch ($this_action = $this->check_action($dir,$key)) { @@ -696,7 +743,7 @@ class file_inspector { } } - if (!empty($_POST['noncore']) || !empty($_POST['oldcore'])) + if ($this->opt('noncore') || $this->opt('oldcore')) { @@ -736,7 +783,7 @@ class file_inspector { - if($_POST['nolang'] && !empty($langs) && !empty($lang_short)) // Hide Non-core Languages. + if($this->opt('nolang') && !empty($langs) && !empty($lang_short)) // Hide Non-core Languages. { // PHP Lang files. @@ -769,7 +816,7 @@ class file_inspector { { if (isset($deprecated[$readdir])) { - if ($_POST['oldcore']) + if ($this->opt('oldcore')) { $this -> files[$dir_id][$aid]['file'] = ($_POST['type'] == 'tree') ? $readdir : $dir.'/'.$readdir; $this -> files[$dir_id][$aid]['size'] = filesize($dir.'/'.$readdir); @@ -781,7 +828,7 @@ class file_inspector { } else { - if ($_POST['noncore']) + if ($this->opt('noncore')) { $this -> files[$dir_id][$aid]['file'] = ($_POST['type'] == 'tree') ? $readdir : $dir.'/'.$readdir; $this -> files[$dir_id][$aid]['size'] = filesize($dir.'/'.$readdir); @@ -805,7 +852,7 @@ class file_inspector { $parent_expand = TRUE; } - if (!empty($_POST['regex'])) + if (!empty($this->opt('regex'))) { $file_content = file($dir.'/'.$readdir); if ($this -> files[$dir_id][$aid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)) @@ -824,7 +871,7 @@ class file_inspector { { if (isset($deprecated[$readdir])) { - if ($_POST['oldcore']) + if ($this->opt('oldcore')) { $dir_icon = ($dir_icon == 'folder_warning' || $dir_icon == 'folder_fail' || $dir_icon == 'folder_missing' ) ? $dir_icon : 'folder_old'; $parent_expand = TRUE; @@ -832,14 +879,14 @@ class file_inspector { } else { - if ($_POST['noncore']) + if ($this->opt('noncore')) { $dir_icon = ($dir_icon == 'folder_warning' || $dir_icon == 'folder_fail' || $dir_icon == 'folder_missing' || $dir_icon == 'folder_old' || $dir_icon == 'folder_old_dir') ? $dir_icon : 'folder_unknown'; $parent_expand = TRUE; } } } - } else if ($_POST['core'] == 'none') { + } else if ($this->opt('core') == 'none') { unset($this -> files[$dir_id][$aid]); } } @@ -894,7 +941,8 @@ class file_inspector { echo "
".FR_LAN_3." | root_dir))."')\"> @@ -936,21 +984,25 @@ class file_inspector { $text .= " |
---|---|
".FR_LAN_3." | |
".$this->iconTag['file_core']." ".FR_LAN_4.": ".($this -> count['core']['num'] ? $this -> count['core']['num'] : FR_LAN_21)." | ".$this -> parsesize($this -> count['core']['size'], 2)." |
".$this->iconTag['file_missing']." ".FR_LAN_22.": ".($this -> count['missing']['num'] ? $this -> count['missing']['num'] : FR_LAN_21)." | |
".$this->iconTag['file_unknown']." ".FR_LAN_5.": ".($this -> count['unknown']['num'] ? $this -> count['unknown']['num'] : FR_LAN_21)." | ".$this -> parsesize($this -> count['unknown']['size'], 2)." |
".$this->iconTag['file_old']." ".FR_LAN_24.": ".($this -> count['deprecated']['num'] ? $this -> count['deprecated']['num'] : FR_LAN_21)." | ".$this -> parsesize($this -> count['deprecated']['size'], 2)." |
".$this->iconTag['file']." ".FR_LAN_6.": ".($this -> count['core']['num'] + $this -> count['unknown']['num'] + $this -> count['deprecated']['num'])." | ".$this -> parsesize($this -> count['core']['size'] + $this -> count['unknown']['size'] + $this -> count['deprecated']['size'], 2)." |
".FR_LAN_27." | |
".FR_LAN_23." |
".FR_LAN_23." |