1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

Bugtracker #3647 - don't report errors in filetypes.php and similar

This commit is contained in:
e107steved
2007-09-27 20:11:40 +00:00
parent 888d2aa14e
commit 8306769aca

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $
| $Revision: 1.9 $ | $Revision: 1.10 $
| $Date: 2007-03-19 17:33:49 $ | $Date: 2007-09-27 20:11:40 $
| $Author: sweetas $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once('../class2.php'); require_once('../class2.php');
@@ -248,112 +248,195 @@ class file_inspector {
return $list; return $list;
} }
function inspect($list, $deprecated, $level, $dir, &$tree_end, &$parent_expand) {
global $coredir, $imode;
unset ($childOut);
$parent_expand = false;
if (substr($dir, -1) == '/') {
$dir = substr($dir, 0, -1);
}
$dir_id = dechex(crc32($dir));
$this -> files[$dir_id]['.']['level'] = $level;
$this -> files[$dir_id]['.']['parent'] = $this -> parent;
$this -> files[$dir_id]['.']['file'] = $dir;
$directory = $level ? basename($dir) : SITENAME;
$level++;
foreach ($list as $key => $value) { // Given a full path and filename, looks it up in the list to determine valid actions; returns:
$this -> parent = $dir_id; // 'check' - file is expected to be present, and validity is to be checked
if (is_array($value)) { // 'ignore' - file may or may not be present - check its validity if found, but not an error if missing
$path = $dir.'/'.$key; // 'uncalc' - file must be present, but its integrity cannot be checked.
$child_open = false; // 'nocalc' - file may be present, but its integrity cannot be checked. Not an error if missing
$child_end = true; function check_action($dir, $name)
$sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand); {
$tree_end = false; global $coredir;
if ($child_expand) {
$parent_expand = true; if ($name == 'e_inspect.php') return 'nocalc'; // Special case for plugin integrity checking
$last_expand = true;
} $filename = $dir.'/'.$name;
} else { $admin_dir = $this -> root_dir.'/'.$coredir['admin'].'/';
$path = $dir.'/'.$key; $image_dir = $this -> root_dir.'/'.$coredir['images'].'/';
$fid = strtolower($key); $test_list = array(
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; $admin_dir.'core_image.php' => 'uncalc',
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { $admin_dir.'filetypes.php' => 'uncalc',
if ($_POST['core'] != 'none') { $admin_dir.'filetypes_.php' => 'ignore',
$this -> count['core']['num']++; $admin_dir.'admin_filetypes.php' => 'nocalc',
$this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> root_dir.'/e107_config.php' => 'uncalc',
if ($_POST['regex']) { $this -> root_dir.'/e107.htaccess' => 'ignore',
$file_content = file($path); $this -> root_dir.'/install.php' => 'ignore',
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { $image_dir.'adminlogo.png' => 'uncalc', // Users often change logo
if ($this -> files[$dir_id][$fid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)){ $image_dir.'logo.png' => 'uncalc'
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; );
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png'; if (isset($test_list[$filename])) return $test_list[$filename];
$dir_icon = 'fileinspector.png'; return 'check';
$parent_expand = TRUE; }
$this -> results++;
$this -> line_results += count($this -> files[$dir_id][$fid]['lines']);
} else { // This function does the real work
unset($this -> files[$dir_id][$fid]); // $list -
$known[$dir_id][$fid] = true; // $deprecated
$dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png'; // $level
} // $dir
} // &$tree_end
} else { // &$parent_expand
//if (strpos($dir.'/'.$key, 'htmlarea') === false) { function inspect($list, $deprecated, $level, $dir, &$tree_end, &$parent_expand)
if ($_POST['integrity']) { {
if ($dir.'/'.$key != $this -> root_dir.'/'.$coredir['admin'].'/core_image.php' && $key != 'e_inspect.php' && $dir.'/'.$key != $this -> root_dir.'/e107_config.php') { global $coredir, $imode;
if ($this -> checksum($path) != $value) {
$this -> count['fail']['num']++; unset ($childOut);
$this -> count['fail']['size'] += $this -> files[$dir_id][$fid]['size']; $parent_expand = false;
$this -> files[$dir_id][$fid]['icon'] = 'file_fail.png'; if (substr($dir, -1) == '/')
$dir_icon = 'folder_fail.png'; {
$parent_expand = TRUE; $dir = substr($dir, 0, -1);
} else { }
$this -> count['pass']['num']++; $dir_id = dechex(crc32($dir));
$this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> files[$dir_id]['.']['level'] = $level;
if ($_POST['core'] != 'fail') { $this -> files[$dir_id]['.']['parent'] = $this -> parent;
$this -> files[$dir_id][$fid]['icon'] = 'file_check.png'; $this -> files[$dir_id]['.']['file'] = $dir;
$dir_icon = ($dir_icon == 'folder_fail.png' || $dir_icon == 'folder_missing.png') ? $dir_icon : 'folder_check.png'; $directory = $level ? basename($dir) : SITENAME;
} else { $level++;
unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true; foreach ($list as $key => $value)
} {
} $this -> parent = $dir_id;
} else { if (is_array($value))
$this -> count['uncalculable']['num']++; { // Entry is a subdirectory - recurse another level
$this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size']; $path = $dir.'/'.$key;
if ($_POST['core'] != 'fail') { $child_open = false;
$this -> files[$dir_id][$fid]['icon'] = 'file_uncalc.png'; $child_end = true;
} else { $sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand);
unset($this -> files[$dir_id][$fid]); $tree_end = false;
$known[$dir_id][$fid] = true; if ($child_expand)
} {
} $parent_expand = true;
} else { $last_expand = true;
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png'; }
}
//} else {
// $this -> count['warning']['num']++;
// $this -> count['warning']['size'] += $this -> files[$dir_id][$fid]['size'];
// $this -> files[$dir_id][$fid]['icon'] = 'file_warning.png';
// $dir_icon = 'folder_warning.png';
// $parent_expand = TRUE;
//}
}
} else {
unset ($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
}
} else if ($_POST['missing']) {
$this -> count['missing']['num']++;
$this -> files[$dir_id][$fid]['icon'] = 'file_missing.png';
$dir_icon = ($dir_icon == 'folder_fail.png') ? $dir_icon : 'folder_missing.png';
$parent_expand = TRUE;
} else {
unset ($this -> files[$dir_id][$fid]);
}
}
} }
else
{
$path = $dir.'/'.$key;
$fid = strtolower($key);
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path;
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE)
{ // We're checking a file here
if ($_POST['core'] != 'none')
{ // Look at core files
$this -> count['core']['num']++;
$this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['regex'])
{ // Developer prefs activated - search file contents according to regex
$file_content = file($path); // Get contents of file
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE)
{
if ($this -> files[$dir_id][$fid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content))
{ // Search string found - add file to list
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path;
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png';
$dir_icon = 'fileinspector.png';
$parent_expand = TRUE;
$this -> results++;
$this -> line_results += count($this -> files[$dir_id][$fid]['lines']);
}
else
{ // Search string not found - discard from list
unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
$dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png';
}
}
}
else
{
if ($_POST['integrity'])
{ // Actually check file integrity
switch ($this_action = $this->check_action($dir,$key))
{
case 'ignore' :
case 'check' :
if ($this -> checksum($path) != $value)
{
$this -> count['fail']['num']++;
$this -> count['fail']['size'] += $this -> files[$dir_id][$fid]['size'];
$this -> files[$dir_id][$fid]['icon'] = 'file_fail.png';
$dir_icon = 'folder_fail.png';
$parent_expand = TRUE;
}
else
{
$this -> count['pass']['num']++;
$this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['core'] != 'fail')
{
$this -> files[$dir_id][$fid]['icon'] = 'file_check.png';
$dir_icon = ($dir_icon == 'folder_fail.png' || $dir_icon == 'folder_missing.png') ? $dir_icon : 'folder_check.png';
}
else
{
unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
}
}
break;
case 'uncalc' :
case 'nocalc' :
$this -> count['uncalculable']['num']++;
$this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['core'] != 'fail')
{
$this -> files[$dir_id][$fid]['icon'] = 'file_uncalc.png';
}
else
{
unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
}
break;
}
}
else
{ // Just identify as core file
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png';
}
}
}
else
{
unset ($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
}
}
else if ($_POST['missing'])
{
switch ($this_action = $this->check_action($dir,$key))
{
case 'check' :
case 'uncalc' :
$this -> count['missing']['num']++;
$this -> files[$dir_id][$fid]['icon'] = 'file_missing.png';
$dir_icon = ($dir_icon == 'folder_fail.png') ? $dir_icon : 'folder_missing.png';
$parent_expand = TRUE;
break;
case 'ignore' :
case 'nocalc' :
// These files can be missing without error - delete from the list
unset ($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true;
break;
}
}
else
{
unset ($this -> files[$dir_id][$fid]);
}
}
}
if ($_POST['noncore'] || $_POST['oldcore']) { if ($_POST['noncore'] || $_POST['oldcore']) {
$handle = opendir($dir.'/'); $handle = opendir($dir.'/');
@@ -656,9 +739,9 @@ class file_inspector {
$data .= "| GNU General Public License (http://gnu.org).\n"; $data .= "| GNU General Public License (http://gnu.org).\n";
$data .= "|\n"; $data .= "|\n";
$data .= "| \$Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $\n"; $data .= "| \$Source: /cvs_backup/e107_0.8/e107_admin/fileinspector.php,v $\n";
$data .= "| \$Revision: 1.9 $\n"; $data .= "| \$Revision: 1.10 $\n";
$data .= "| \$Date: 2007-03-19 17:33:49 $\n"; $data .= "| \$Date: 2007-09-27 20:11:40 $\n";
$data .= "| \$Author: sweetas $\n"; $data .= "| \$Author: e107steved $\n";
$data .= "+----------------------------------------------------------------------------+\n"; $data .= "+----------------------------------------------------------------------------+\n";
$data .= "*/\n\n"; $data .= "*/\n\n";
} }