1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

ability for plugins to create file inspector image snapshots added

This commit is contained in:
sweetas
2006-12-19 18:00:20 +00:00
parent e52b79f2b5
commit e80feb96e9

View File

@@ -11,8 +11,8 @@
| 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.5 $ | $Revision: 1.6 $
| $Date: 2006-12-19 13:49:29 $ | $Date: 2006-12-19 18:00:20 $
| $Author: sweetas $ | $Author: sweetas $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -37,6 +37,20 @@ foreach ($maindirs as $maindirs_key => $maindirs_value) {
require_once('core_image.php'); require_once('core_image.php');
$handle = opendir(e_PLUGIN);
while (false !== ($readdir = readdir($handle))) {
if ($readdir != '.' && $readdir != '..' && $readdir != '/' && $readdir != 'CVS' && $readdir != 'Thumbs.db' && (strpos('._', $readdir) === FALSE)) {
if (is_dir(e_PLUGIN.$readdir)) {
if (is_readable(e_PLUGIN.$readdir.'/e_inspect.php')) {
include_once(e_PLUGIN.$readdir.'/e_inspect.php');
}
}
}
}
closedir($handle);
ksort($core_image[$coredir['plugins']]);
if (e_QUERY) { if (e_QUERY) {
$fi -> snapshot_interface(); $fi -> snapshot_interface();
} else if (isset($_POST['scan'])) { } else if (isset($_POST['scan'])) {
@@ -287,7 +301,7 @@ class file_inspector {
} else { } else {
//if (strpos($dir.'/'.$key, 'htmlarea') === false) { //if (strpos($dir.'/'.$key, 'htmlarea') === false) {
if ($_POST['integrity']) { if ($_POST['integrity']) {
if ($dir.'/'.$key != $this -> root_dir.'/'.$coredir['admin'].'/core_image.php' && $dir.'/'.$key != $this -> root_dir.'/e107_config.php') { 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) { 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'];
@@ -615,8 +629,12 @@ class file_inspector {
$ns -> tablerender(FR_LAN_1.'...', $text); $ns -> tablerender(FR_LAN_1.'...', $text);
} }
function create_image($dir) { function create_image($dir, $plugin) {
global $core_image, $deprecated_image, $coredir; global $core_image, $deprecated_image, $coredir, $plugin_image, $plugin_deprecated_image, $PLUGINS_DIRECTORY;
if ($plugin && $plugin !='off') {
$dir = $dir.'/'.$PLUGINS_DIRECTORY.$plugin;
}
foreach ($coredir as $trim_key => $trim_dirs) { foreach ($coredir as $trim_key => $trim_dirs) {
$search[$trim_key] = "'".$trim_dirs."'"; $search[$trim_key] = "'".$trim_dirs."'";
@@ -624,6 +642,8 @@ class file_inspector {
} }
$data = "<?php\n"; $data = "<?php\n";
if (!$plugin || $plugin == 'off') {
$data .= "/*\n"; $data .= "/*\n";
$data .= "+ ----------------------------------------------------------------------------+\n"; $data .= "+ ----------------------------------------------------------------------------+\n";
$data .= "| e107 website system\n"; $data .= "| e107 website system\n";
@@ -636,25 +656,42 @@ 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.5 $\n"; $data .= "| \$Revision: 1.6 $\n";
$data .= "| \$Date: 2006-12-19 13:49:29 $\n"; $data .= "| \$Date: 2006-12-19 18:00:20 $\n";
$data .= "| \$Author: sweetas $\n"; $data .= "| \$Author: sweetas $\n";
$data .= "+----------------------------------------------------------------------------+\n"; $data .= "+----------------------------------------------------------------------------+\n";
$data .= "*/\n\n"; $data .= "*/\n\n";
}
$data .= "if (!defined('e107_INIT')) { exit; }\n\n"; $data .= "if (!defined('e107_INIT')) { exit; }\n\n";
if ($plugin && $plugin !='off') {
$scan_current = ($_POST['snaptype'] == 'current') ? $this -> scan($dir) : $core_image[$coredir['plugins']][$plugin];
$image_array = var_export($scan_current, true);
$data .= "\$core_image[\$coredir['plugins']]['".$plugin."'] = ".$image_array.";\n\n";
} else {
$scan_current = ($_POST['snaptype'] == 'current') ? $this -> scan($dir) : $core_image; $scan_current = ($_POST['snaptype'] == 'current') ? $this -> scan($dir) : $core_image;
$image_array = var_export($scan_current, true); $image_array = var_export($scan_current, true);
$image_array = str_replace($search, $replace, $image_array); $image_array = str_replace($search, $replace, $image_array);
$data .= "\$core_image = ".$image_array.";\n\n"; $data .= "\$core_image = ".$image_array.";\n\n";
}
if ($plugin && $plugin !='off') {
$scan_deprecated = ($_POST['snaptype'] == 'deprecated') ? $this -> scan($dir, $core_image) : $deprecated_image[$coredir['plugins']]['".$plugin."'];
$image_array = var_export($scan_deprecated, true);
$data .= "\$deprecated_image[\$coredir['plugins']]['".$plugin."'] = ".$image_array.";\n\n";
} else {
$scan_deprecated = ($_POST['snaptype'] == 'deprecated') ? $this -> scan($dir, $core_image) : $deprecated_image; $scan_deprecated = ($_POST['snaptype'] == 'deprecated') ? $this -> scan($dir, $core_image) : $deprecated_image;
$image_array = var_export($scan_deprecated, true); $image_array = var_export($scan_deprecated, true);
$image_array = str_replace($search, $replace, $image_array); $image_array = str_replace($search, $replace, $image_array);
$data .= "\$deprecated_image = ".$image_array.";\n\n"; $data .= "\$deprecated_image = ".$image_array.";\n\n";
}
$data .= "?>"; $data .= "?>";
if ($plugin && $plugin !='off') {
$fp = fopen(e_PLUGIN.$plugin .'/e_inspect.php', 'w');
} else {
$fp = fopen(e_ADMIN.'core_image.php', 'w'); $fp = fopen(e_ADMIN.'core_image.php', 'w');
}
fwrite($fp, $data); fwrite($fp, $data);
} }
@@ -662,7 +699,7 @@ class file_inspector {
global $ns, $rs; global $ns, $rs;
$text = ""; $text = "";
if (isset($_POST['create_snapshot'])) { if (isset($_POST['create_snapshot'])) {
$this -> create_image($_POST['snapshot_path']); $this -> create_image($_POST['snapshot_path'], $_POST['plugin']);
$text = "<div style='text-align:center'> $text = "<div style='text-align:center'>
<form action='".e_SELF."' method='post' id='main_page'> <form action='".e_SELF."' method='post' id='main_page'>
<table style='".ADMIN_WIDTH."' class='fborder'> <table style='".ADMIN_WIDTH."' class='fborder'>
@@ -672,7 +709,7 @@ class file_inspector {
$text .= "<tr> $text .= "<tr>
<td class='forumheader3' style='text-align:center'> <td class='forumheader3' style='text-align:center'>
The snapshot (".e_ADMIN."core_image.php) was successfully created. The snapshot was successfully created.
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -700,7 +737,32 @@ class file_inspector {
<tr> <tr>
<td class='forumheader3' style='width: 35%'> <td class='forumheader3' style='width: 35%'>
Create snapshot of current or deprecated core files: Create snapshot for plugin:
</td>
<td colspan='2' class='forumheader3' style='width: 65%'>
<select name='plugin' class='tbox'>
<option value='off' ".($_POST['plugin'] == 'off' ? "selected='selected'" : "").">Select...</option>";
$handle = opendir(e_PLUGIN);
while (false !== ($readdir = readdir($handle))) {
if ($readdir != '.' && $readdir != '..' && $readdir != '/' && $readdir != 'CVS' && $readdir != 'Thumbs.db' && (strpos('._', $readdir) === FALSE)) {
if (is_dir(e_PLUGIN.$readdir)) {
if (is_readable(e_PLUGIN.$readdir.'/e_inspect.php')) {
// $text .= e_PLUGIN.$readdir.'/e_inspect.php';
$text .= "<option value='".$readdir."' ".($_POST['plugin'] == $readdir ? "selected='selected'" : "").">".$readdir."</option>";
}
}
}
}
closedir($handle);
$text .= "</select>
</td>
</tr>
<tr>
<td class='forumheader3' style='width: 35%'>
Create snapshot of current or deprecated files:
</td> </td>
<td colspan='2' class='forumheader3' style='width: 65%'> <td colspan='2' class='forumheader3' style='width: 65%'>
<input type='radio' name='snaptype' value='current'".($_POST['snaptype'] == 'current' || !isset($_POST['snaptype']) ? " checked='checked'" : "")." /> Current&nbsp;&nbsp; <input type='radio' name='snaptype' value='current'".($_POST['snaptype'] == 'current' || !isset($_POST['snaptype']) ? " checked='checked'" : "")." /> Current&nbsp;&nbsp;
@@ -708,6 +770,7 @@ class file_inspector {
</td> </td>
</tr> </tr>
<tr> <tr>
<td class='forumheader' style='text-align:center' colspan='2'>".$rs -> form_button('submit', 'create_snapshot', 'Create Snapshot')."</td> <td class='forumheader' style='text-align:center' colspan='2'>".$rs -> form_button('submit', 'create_snapshot', 'Create Snapshot')."</td>
</tr> </tr>