Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions doom-scroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function object_table_iter(?array $arr): string
foreach ($json_data['Hardware']['Storage'] as $disk) {
foreach ($disk['Partitions'] as $partNum => $part) {
if (isset($part['DirtyBitSet']) && $part['DirtyBitSet']) {
if (empty($part['PartitionLetter'])) {
if ($part['PartitionLetter'] === '') {
echo "
<li>
Dirty bit set on <span>partition $partNum ({$disk['DeviceName']})</span>
Expand Down Expand Up @@ -425,7 +425,7 @@ function object_table_iter(?array $arr): string

foreach ($json_data['System']['ChoiceRegistryValues'] as $regkey) {

if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']])) {
if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']], true)) {
echo "
<li>
Registry Value <span>{$regkey['Name']}</span> found set, value of <span>{$regkey['Value']}</span>
Expand Down Expand Up @@ -879,24 +879,24 @@ function(&$row) {
<h1>Storage</h1>
<?php
$drives_amount = safe_count($json_data['Hardware']['Storage']);
$driveKey = 0;

foreach ($json_data['Hardware']['Storage'] as $driveKey => $drive) {

foreach ($json_data['Hardware']['Storage'] as $drive) {
$drive_size_raw = $drive['DiskCapacity'];
$drive_free_raw = getDriveFree($drive);
$drive_taken_raw = $drive_size_raw - $drive_free_raw;
$drive_size = floor(bytesToGigabytes($drive_size_raw));
$drive_taken = floor(bytesToGigabytes($drive_taken_raw));
// the drive size can sometimes be z ero if the drive is failing
if ($drive_taken != 0 && $drive_size != 0) {
$drive_percentage = round((float)$drive_taken / (float)$drive_size * 100);
$drive_percentage = round($drive_taken / $drive_size * 100);
} else $drive_percentage = 0;

$letters = array_filter(
array_column($drive['Partitions'], 'PartitionLetter')
);
$lettersString = implode(", ", $letters);
$lettersStringDisplay = empty($lettersString) ? '' : "($lettersString)";
$lettersStringDisplay = ($lettersString === '') ? '' : "($lettersString)";

echo '
<h2 class="item-header">' . $drive['DeviceName'] . '</h2>
Expand Down Expand Up @@ -930,15 +930,15 @@ function(&$row) {
$part_size_mb = bytesToMegabytes($part_size);
$part_taken_mb = ceil(bytesToMegabytes($part_taken));
$part_display = "";
if (!empty($part['PartitionLabel'])) {
if ($part['PartitionLabel'] !== '') {
$part_display .= $part['PartitionLabel'];
if (isset($part['PartitionLetter'])) {
$part_display .= " ({$part['PartitionLetter']})";
}
} else if (isset($part['PartitionLetter'])) { // and not partition label
$part_display = $part['PartitionLetter'];
}
if (!empty($part_display))
if ($part_display !== '')
$part_display .= '<br/>';
$fs_display = $part['Filesystem'] ?? 'Unknown';

Expand Down Expand Up @@ -1145,7 +1145,7 @@ function(&$row) {
} else $default_browser = '';

foreach ($browser['Profiles'] as $profile):
$profile_key = array_search($profile, $browser['Profiles']);
$profile_key = array_search($profile, $browser['Profiles'], true);
?>
<h2 class="item-header"><?= $browser['Name'] ?> Profile
"<?= $profile['name'] /* This is lowercase in the json for some reason */ ?>"</h2>
Expand Down
2 changes: 1 addition & 1 deletion manualupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function check_keys_recursive($arr1, $arr2) {
$randomString = bin2hex($randomBytes);
$randomString = preg_replace('/[^A-Za-z0-9]/', '', substr($randomString, 0, 8));

if(in_array($file_ext,$extensions)== false){
if(in_array($file_ext,$extensions, true)== false){
$errors[]="Extension not allowed, please choose a Specify JSON file";
}

Expand Down
8 changes: 7 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
strictRules:
booleansInConditions: false

level: 0
paths:
- .

excludePaths:
- 'vendor/'
- 'vendor/'
- 'gesp-mode.php'
ignoreErrors:
- identifier: empty.notAllowed
2 changes: 1 addition & 1 deletion rudimentary.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function scan_dir($dir) {
$files = array(); //----------------------------------- create an empty files array to play with
foreach (scandir($dir) as $file) {
if ($file[0] === '.') continue; //----------------- ignores all files starting with '.'
if (in_array($file, $ignored)) continue; //-------- ignores all files given in $ignored
if (in_array($file, $ignored, true)) continue; //-------- ignores all files given in $ignored
$files[$file] = filemtime($dir . '/' . $file); //-- add to files list
}
arsort($files); //------------------------------------- sort file values (creation timestamps)
Expand Down
28 changes: 15 additions & 13 deletions viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,16 +874,18 @@
<div class="green">

<?php
// the displayed adapter is the first one which has an IP address, or if none have an IP, then the first physical adapter.
$adapterText = "Disconnected";

foreach ($json_data['Network']['Adapters'] as $adapter) {
if ((bool) $adapter['PhysicalAdapter'] && is_array($adapter['IPAddress']) && count($adapter['IPAddress']) > 0) {
$adapterText = $adapter['Description'];
$foundAdapter = true;
break;
}
};

if ($adapter == "") {
if (!$foundAdapter) {
foreach ($json_data['Network']['Adapters'] as $adapter) {
if ((bool) $adapter['PhysicalAdapter']) {
$adapterText = $adapter['Description'];
Expand Down Expand Up @@ -1204,15 +1206,15 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
$part_size = $part['PartitionCapacity'];
$part_taken = $part_size - $part['PartitionFree'];
$part_display = "";
if (!empty($part['PartitionLabel'])) {
if ($part['PartitionLabel'] !== '') {
$part_display .= $part['PartitionLabel'];
if (isset($part['PartitionLetter'])) {
$part_display .= " ({$part['PartitionLetter']})";
}
} else if (isset($part['PartitionLetter'])) { // and not partition label
$part_display = $part['PartitionLetter'];
}
if (!empty($part_display))
if ($part_display !== '')
$part_display .= '<br/>';
$fs_display = $part['Filesystem'] ?? 'Unknown';

Expand Down Expand Up @@ -1599,7 +1601,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
';
}

if (!empty($json_data['Hardware']['Batteries'])) {
if (count($json_data['Hardware']['Batteries']) > 0) {
foreach ($json_data['Hardware']['Batteries'] as $battery) {
$cap = floatval($battery["Remaining_Life_Percentage"]);
if (
Expand All @@ -1618,7 +1620,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
foreach ($json_data['Hardware']['Storage'] as $disk) {
foreach ($disk['Partitions'] as $partNum => $part) {
if (isset($part['DirtyBitSet']) && $part['DirtyBitSet']) {
if (empty($part['PartitionLetter'])) {
if ($part['PartitionLetter'] === '') {
$noteshtml .= "
<p>
Dirty bit set on <span>partition $partNum ({$disk['DeviceName']})</span>
Expand Down Expand Up @@ -1692,7 +1694,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>



if (!empty($noteshtml)) {
if ($noteshtml !== '') {
$noteshtml = '<br>' . $noteshtml;
echo $noteshtml;
}
Expand Down Expand Up @@ -1738,7 +1740,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
$driveKey += 1;
}

if (!empty($drivehtml)) {
if ($drivehtml !== '') {
$drivehtml = '<br> <h4 style="margin:5px; color:var(--meta-h4-color);">Drive / SMART Notes</h4>' . $drivehtml;
echo $drivehtml;
}
Expand All @@ -1757,7 +1759,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>

foreach ($json_data['System']['ChoiceRegistryValues'] as $regkey) {

if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']])){
if ($regkey['Value'] && !in_array($regkey['Value'], $defaultRegKeys[$regkey['Name']], true)){
$reghtml .= '
<p>
Registry Value <span>' . $regkey['Name'] . '</span> found set, value of <span>' . $regkey['Value'] . '</span>
Expand All @@ -1766,7 +1768,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>

}

if (!empty($reghtml)) {
if ($reghtml !== '') {
$reghtml = '<br> <h4 style="margin:5px; color:var(--meta-h4-color);">Notable Registry Changes</h4>' . $reghtml;
echo $reghtml;
}
Expand All @@ -1777,7 +1779,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
<?php
$puphtml = '';

if (!empty($pupsfoundInstalled)) {
if (count($pupsfoundInstalled) > 0) {

$puphtml .= '<h4>Notable Software found Installed</h4>';

Expand All @@ -1790,7 +1792,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
$puphtml .= '</table>';
}

if (!empty($pupsfoundRunning)) {
if (count($pupsfoundRunning) > 0) {

$puphtml .= '<h4>Notable Software found Running</h4>';

Expand All @@ -1803,7 +1805,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
$puphtml .= '</table>';
}

if (!empty($puphtml)) {
if ($puphtml !== '') {
echo $puphtml;
} else {
echo '<h4>No Notable Software found, yay!</h4>';
Expand Down Expand Up @@ -1904,7 +1906,7 @@ class="' . $flavor_color . '">' . (int)$drive_taken . ' GB</span>
</div>
<div class="modal-body" id="browser-container' . $browser['Name'] . '">';
foreach ($browser['Profiles'] as $browserprofile) {
$profileKey = array_search($browserprofile, $browser['Profiles']);
$profileKey = array_search($browserprofile, $browser['Profiles'], true);
echo '
<h2>' . $browser['Name'] . ' Profile "' . $browser['Profiles'][$profileKey]['name'] . '"</h2>
<table id="' . $browser['Name'] . 'Profile' . $profileKey . 'Table" class="table">
Expand Down
Loading