1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 05:07:27 +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; // Given a full path and filename, looks it up in the list to determine valid actions; returns:
unset ($childOut); // 'check' - file is expected to be present, and validity is to be checked
$parent_expand = false; // 'ignore' - file may or may not be present - check its validity if found, but not an error if missing
if (substr($dir, -1) == '/') { // 'uncalc' - file must be present, but its integrity cannot be checked.
$dir = substr($dir, 0, -1); // 'nocalc' - file may be present, but its integrity cannot be checked. Not an error if missing
} function check_action($dir, $name)
$dir_id = dechex(crc32($dir)); {
$this -> files[$dir_id]['.']['level'] = $level; global $coredir;
$this -> files[$dir_id]['.']['parent'] = $this -> parent;
$this -> files[$dir_id]['.']['file'] = $dir; if ($name == 'e_inspect.php') return 'nocalc'; // Special case for plugin integrity checking
$directory = $level ? basename($dir) : SITENAME;
$level++; $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;
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) { foreach ($list as $key => $value)
$this -> parent = $dir_id; {
if (is_array($value)) { $this -> parent = $dir_id;
$path = $dir.'/'.$key; if (is_array($value))
$child_open = false; { // Entry is a subdirectory - recurse another level
$child_end = true; $path = $dir.'/'.$key;
$sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand); $child_open = false;
$tree_end = false; $child_end = true;
if ($child_expand) { $sub_text .= $this -> inspect($value, $deprecated[$key], $level, $path, $child_end, $child_expand);
$parent_expand = true; $tree_end = false;
$last_expand = true; if ($child_expand)
} {
} else { $parent_expand = true;
$path = $dir.'/'.$key; $last_expand = true;
$fid = strtolower($key); }
}
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]['file'] = ($_POST['type'] == 'tree') ? $key : $path;
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { $this -> files[$dir_id][$fid]['icon'] = 'file_core.png';
if ($_POST['core'] != 'none') { $dir_icon = 'fileinspector.png';
$this -> count['core']['num']++; $parent_expand = TRUE;
$this -> count['core']['size'] += $this -> files[$dir_id][$fid]['size']; $this -> results++;
if ($_POST['regex']) { $this -> line_results += count($this -> files[$dir_id][$fid]['lines']);
$file_content = file($path); }
if (($this -> files[$dir_id][$fid]['size'] = filesize($path)) !== FALSE) { else
if ($this -> files[$dir_id][$fid]['lines'] = preg_grep("#".$_POST['regex']."#".$_POST['mod'], $file_content)){ { // Search string not found - discard from list
$this -> files[$dir_id][$fid]['file'] = ($_POST['type'] == 'tree') ? $key : $path; unset($this -> files[$dir_id][$fid]);
$this -> files[$dir_id][$fid]['icon'] = 'file_core.png'; $known[$dir_id][$fid] = true;
$dir_icon = 'fileinspector.png'; $dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png';
$parent_expand = TRUE; }
$this -> results++; }
$this -> line_results += count($this -> files[$dir_id][$fid]['lines']); }
} else { else
unset($this -> files[$dir_id][$fid]); {
$known[$dir_id][$fid] = true; if ($_POST['integrity'])
$dir_icon = ($dir_icon == 'fileinspector.png') ? $dir_icon : 'folder.png'; { // Actually check file integrity
} switch ($this_action = $this->check_action($dir,$key))
} {
} else { case 'ignore' :
//if (strpos($dir.'/'.$key, 'htmlarea') === false) { case 'check' :
if ($_POST['integrity']) { if ($this -> checksum($path) != $value)
if ($dir.'/'.$key != $this -> root_dir.'/'.$coredir['admin'].'/core_image.php' && $key != 'e_inspect.php' && $dir.'/'.$key != $this -> root_dir.'/e107_config.php') { {
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;
} 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;
}
}
} else {
$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;
}
}
} else {
$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; $parent_expand = TRUE;
} else { }
unset ($this -> files[$dir_id][$fid]); 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";
} }