1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +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,11 +248,52 @@ class file_inspector {
return $list; return $list;
} }
function inspect($list, $deprecated, $level, $dir, &$tree_end, &$parent_expand) {
// Given a full path and filename, looks it up in the list to determine valid actions; returns:
// 'check' - file is expected to be present, and validity is to be checked
// 'ignore' - file may or may not be present - check its validity if found, but not an error if missing
// 'uncalc' - file must be present, but its integrity cannot be checked.
// 'nocalc' - file may be present, but its integrity cannot be checked. Not an error if missing
function check_action($dir, $name)
{
global $coredir;
if ($name == 'e_inspect.php') return 'nocalc'; // Special case for plugin integrity checking
$filename = $dir.'/'.$name;
$admin_dir = $this -> root_dir.'/'.$coredir['admin'].'/';
$image_dir = $this -> root_dir.'/'.$coredir['images'].'/';
$test_list = array(
$admin_dir.'core_image.php' => 'uncalc',
$admin_dir.'filetypes.php' => 'uncalc',
$admin_dir.'filetypes_.php' => 'ignore',
$admin_dir.'admin_filetypes.php' => 'nocalc',
$this -> root_dir.'/e107_config.php' => 'uncalc',
$this -> root_dir.'/e107.htaccess' => 'ignore',
$this -> root_dir.'/install.php' => 'ignore',
$image_dir.'adminlogo.png' => 'uncalc', // Users often change logo
$image_dir.'logo.png' => 'uncalc'
);
if (isset($test_list[$filename])) return $test_list[$filename];
return 'check';
}
// This function does the real work
// $list -
// $deprecated
// $level
// $dir
// &$tree_end
// &$parent_expand
function inspect($list, $deprecated, $level, $dir, &$tree_end, &$parent_expand)
{
global $coredir, $imode; global $coredir, $imode;
unset ($childOut); unset ($childOut);
$parent_expand = false; $parent_expand = false;
if (substr($dir, -1) == '/') { if (substr($dir, -1) == '/')
{
$dir = substr($dir, 0, -1); $dir = substr($dir, 0, -1);
} }
$dir_id = dechex(crc32($dir)); $dir_id = dechex(crc32($dir));
@@ -262,94 +303,136 @@ class file_inspector {
$directory = $level ? basename($dir) : SITENAME; $directory = $level ? basename($dir) : SITENAME;
$level++; $level++;
foreach ($list as $key => $value) { foreach ($list as $key => $value)
{
$this -> parent = $dir_id; $this -> parent = $dir_id;
if (is_array($value)) { if (is_array($value))
{ // Entry is a subdirectory - recurse another level
$path = $dir.'/'.$key; $path = $dir.'/'.$key;
$child_open = false; $child_open = false;
$child_end = true; $child_end = true;
$sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand); $sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand);
$tree_end = false; $tree_end = false;
if ($child_expand) { if ($child_expand)
{
$parent_expand = true; $parent_expand = true;
$last_expand = true; $last_expand = true;
} }
} else { }
else
{
$path = $dir.'/'.$key; $path = $dir.'/'.$key;
$fid = strtolower($key); $fid = strtolower($key);
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; $this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path;
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE)
if ($_POST['core'] != 'none') { { // We're checking a file here
if ($_POST['core'] != 'none')
{ // Look at core files
$this -> count['core']['num']++; $this -> count['core']['num']++;
$this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['regex']) { if ($_POST['regex'])
$file_content = file($path); { // Developer prefs activated - search file contents according to regex
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { $file_content = file($path); // Get contents of file
if ($this -> files[$dir_id][$fid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)){ 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]['file'] = ($_POST['type'] == 'tree') ? $key : $path;
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png'; $this -> files[$dir_id][$fid]['icon'] = 'file_core.png';
$dir_icon = 'fileinspector.png'; $dir_icon = 'fileinspector.png';
$parent_expand = TRUE; $parent_expand = TRUE;
$this -> results++; $this -> results++;
$this -> line_results += count($this -> files[$dir_id][$fid]['lines']); $this -> line_results += count($this -> files[$dir_id][$fid]['lines']);
} else { }
else
{ // Search string not found - discard from list
unset($this -> files[$dir_id][$fid]); unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true; $known[$dir_id][$fid] = true;
$dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png'; $dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png';
} }
} }
} else { }
//if (strpos($dir.'/'.$key, 'htmlarea') === false) { else
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') { if ($_POST['integrity'])
if ($this -> checksum($path) != $value) { { // 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']['num']++;
$this -> count['fail']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> count['fail']['size'] += $this -> files[$dir_id][$fid]['size'];
$this -> files[$dir_id][$fid]['icon'] = 'file_fail.png'; $this -> files[$dir_id][$fid]['icon'] = 'file_fail.png';
$dir_icon = 'folder_fail.png'; $dir_icon = 'folder_fail.png';
$parent_expand = TRUE; $parent_expand = TRUE;
} else { }
else
{
$this -> count['pass']['num']++; $this -> count['pass']['num']++;
$this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> count['pass']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['core'] != 'fail') { if ($_POST['core'] != 'fail')
{
$this -> files[$dir_id][$fid]['icon'] = 'file_check.png'; $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'; $dir_icon = ($dir_icon == 'folder_fail.png' || $dir_icon == 'folder_missing.png') ? $dir_icon : 'folder_check.png';
} else { }
else
{
unset($this -> files[$dir_id][$fid]); unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true; $known[$dir_id][$fid] = true;
} }
} }
} else { break;
case 'uncalc' :
case 'nocalc' :
$this -> count['uncalculable']['num']++; $this -> count['uncalculable']['num']++;
$this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> count['uncalculable']['size'] += $this -> files[$dir_id][$fid]['size'];
if ($_POST['core'] != 'fail') { if ($_POST['core'] != 'fail')
{
$this -> files[$dir_id][$fid]['icon'] = 'file_uncalc.png'; $this -> files[$dir_id][$fid]['icon'] = 'file_uncalc.png';
} else { }
else
{
unset($this -> files[$dir_id][$fid]); unset($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true; $known[$dir_id][$fid] = true;
} }
break;
} }
} else { }
else
{ // Just identify as core file
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png'; $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 { }
else
{
unset ($this -> files[$dir_id][$fid]); unset ($this -> files[$dir_id][$fid]);
$known[$dir_id][$fid] = true; $known[$dir_id][$fid] = true;
} }
} else if ($_POST['missing']) { }
else if ($_POST['missing'])
{
switch ($this_action = $this->check_action($dir,$key))
{
case 'check' :
case 'uncalc' :
$this -> count['missing']['num']++; $this -> count['missing']['num']++;
$this -> files[$dir_id][$fid]['icon'] = 'file_missing.png'; $this -> files[$dir_id][$fid]['icon'] = 'file_missing.png';
$dir_icon = ($dir_icon == 'folder_fail.png') ? $dir_icon : 'folder_missing.png'; $dir_icon = ($dir_icon == 'folder_fail.png') ? $dir_icon : 'folder_missing.png';
$parent_expand = TRUE; $parent_expand = TRUE;
} else { 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]); unset ($this -> files[$dir_id][$fid]);
} }
} }
@@ -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";
} }