Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lewmilburn committed Nov 13, 2024
1 parent e3169c2 commit 633d252
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
5 changes: 1 addition & 4 deletions Plugins/ControlPanel/Assets/ChkValues.php
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<?php

$Checksum['CoreSettings'] = '1016dd99a95446af7cbfc00b99ec8102c86d76da54515cbed96cccfa9c43d4167db5be5b234ddf82c4162d138545d5a0944b53c55f3ce3f1510b95c2eba2b25d';
$Checksum['CoreDeveloper'] = 'd8ac0d6566de0980d2853e6b8e403e533cc2b8dd3b37e54f2f2883300302973f887aefee47c12bd8c28533c6ca741bb82a018288c782a623f990698dd4455f88';
<?php $Checksum['CoreSettings'] = '314148be0badb39b367a23a0fc60aa6d16ca66f850f8e0e524c9f75d58480ee23f45d6ee34c034f73b5fd6822dc9493a84b13561de0150d6f98a5ae01662b9df';
55 changes: 52 additions & 3 deletions Plugins/ControlPanel/Checksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,73 @@

namespace ControlPanel;

use Exception;
use Saturn\ErrorHandler;

class Checksums
{
public function Validate()
public function Validate(): bool
{
$CoreSettings = hash_file('sha3-512', __DIR__.'/../../Settings/Settings.php');

require_once __DIR__.'/Assets/ChkValues.php';

if ($Checksum['CoreSettings'] !== $CoreSettings) {
return false;
}

return true;
}

public function Reset()
public function Reset(): void
{
$CoreSettings = hash_file('sha3-512', __DIR__.'/../../Settings/Settings.php');
$Data = '<?php $Checksum[\'CoreSettings\'] = \''.$CoreSettings.'\';';
file_put_contents(__DIR__.'/Assets/ChkValues.php', $Data);

if (is_writable(__DIR__.'/Assets/ChkValues.php')) {
try {
$fp = fopen(__DIR__ . '/Assets/ChkValues.php', 'w');
if (fwrite($fp, $Data) === FALSE) {
$Error = new ErrorHandler();
$Error->SaturnError(
'500',
'SAT-6',
'Error Resetting Checksums',
'There was a problem whilst resetting the checksums.',
SATSYS_DOCS_URL . '/troubleshooting/errors/saturn#sat-6'
);
}
fclose($fp);
} catch (Exception $e) {
$Error = new ErrorHandler();
$Error->SaturnError(
'500',
'SAT-6',
'Error Resetting Checksums',
'There was a problem whilst resetting the checksums. ' . $e->getMessage(),
SATSYS_DOCS_URL . '/troubleshooting/errors/saturn#sat-6'
);
}
} else {
if (!file_exists(__DIR__.'/Assets/ChkValues.php')) {
$Error = new ErrorHandler();
$Error->SaturnError(
'500',
'SAT-7',
'File is not writeable',
'DOES NOT EXIST: /Plugins/ControlPanel/Assets/ChkValues.php',
SATSYS_DOCS_URL . '/troubleshooting/errors/saturn#sat-7'
);
} else {
$Error = new ErrorHandler();
$Error->SaturnError(
'500',
'SAT-7',
'File is not writeable',
'NO PERMISSION: /Plugins/ControlPanel/Assets/ChkValues.php',
SATSYS_DOCS_URL . '/troubleshooting/errors/saturn#sat-7'
);
}
}
}
}
2 changes: 1 addition & 1 deletion Plugins/ControlPanel/Views/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="grid lg:grid-cols-3 gap-4">
<div class="lg:col-span-2 grid gap-4">
<div class="grid-item grid-padding">
Up No details for <?= $User->username; ?>.
No details for <?= $User->username; ?>.
</div>
</div>

Expand Down

0 comments on commit 633d252

Please sign in to comment.