1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

File Inspector now shows the old e107 version of core files

Bugfixes related to this change:

* e_file_inspector: During validation, the checksum is now calculated,
  even if the file is old.
* e_file_inspector_json: Strip the "v" from the beginning of version
  numbers in the database to make them proper PHP-standardized versions.
This commit is contained in:
Nick Liu
2020-03-27 16:00:39 -05:00
parent 09d3d2b166
commit b4f55049f8
3 changed files with 32 additions and 1 deletions

View File

@@ -618,6 +618,7 @@ class file_inspector {
if ($level === 0) $relativePath = '';
$rowId = str_replace(" ", "%20", $relativePath);
list($icon, $title) = $this->getGlyphForValidationCode($validationCode);
$oldVersion = $this->getOldVersionOfPath($relativePath, $validationCode);
$html .= "<div class=\"d\" title=\"$title\" style=\"margin-left: " . ($level * 8) . "px\">";
$html .= "<span onclick=\"ec('$rowId')\">";
$html .= $this->getTreeActionImageForFile($tree, $fileName, $rowId, $hide);
@@ -634,6 +635,7 @@ class file_inspector {
{
$html .= '<span style="float:right">';
$html .= isset($this->fileSizes[$relativePath]) ? $this->parsesize($this->fileSizes[$relativePath]) : '';
$html .= $oldVersion ? " (v$oldVersion)" : "";
$html .= '</span>';
}
$html .= "</div>";
@@ -1008,6 +1010,8 @@ class file_inspector {
$text .= htmlspecialchars($relativePath);
$text .= '</td><td class="s">';
$text .= isset($this->fileSizes[$relativePath]) ? $this->parsesize($this->fileSizes[$relativePath]) : '';
$oldVersion = $this->getOldVersionOfPath($relativePath, $validation);
$text .= $oldVersion ? " (v$oldVersion)" : "";
$text .= '</td>';
$text .= '</tr>';
}
@@ -1333,6 +1337,27 @@ i.fa-folder-open-o, i.fa-times-circle-o { cursor:pointer }
echo $text;
}
/**
* Get the PHP-standard version of the hash of the relative path
*
* @todo FIXME performance: This method checksums old files a second time.
* @param string $relativePath Relative path to checksum
* @param int $validationCode e_file_inspector validation bits
* @return false|string
*/
private function getOldVersionOfPath($relativePath, $validationCode)
{
$oldVersion = false;
if (($validationCode & e_file_inspector::VALIDATED_HASH_EXISTS) &&
!($validationCode & e_file_inspector::VALIDATED_HASH_CURRENT))
{
$dbChecksums = $this->coreImage->getChecksums($relativePath);
$actualChecksum = $this->coreImage->checksumPath(e_BASE . $relativePath);
$oldVersion = array_search($actualChecksum, $dbChecksums);
}
return $oldVersion;
}
}
function fileinspector_adminmenu() //FIXME - has problems when navigation is on the LEFT instead of the right.