Bug fixes

This commit is contained in:
Collin 2024-09-21 14:39:27 +02:00
parent 7ebefccb28
commit a4d8cb524d
4 changed files with 4 additions and 9 deletions

0
run Normal file → Executable file
View File

View File

@ -1,7 +1,7 @@
<?php
return new class {
public function run($lona, $data, $client) : void {
public function run($LonaDB, $data, $client) : void {
if (empty($data['table']['name'])) {
$response = json_encode(["success" => false, "err" => "bad_table_name", "process" => $data['process']]);
socket_write($client, $response);
@ -11,14 +11,14 @@ return new class {
$tableName = $data['table']['name'];
if (!$lona->TableManager->GetTable($tableName)) {
if (!$LonaDB->TableManager->GetTable($tableName)) {
$response = json_encode(["success" => false, "err" => "table_missing", "process" => $data['process']]);
socket_write($client, $response);
socket_close($client);
return;
}
$table = $lona->TableManager->GetTable($tableName);
$table = $LonaDB->TableManager->GetTable($tableName);
if (!$table->CheckPermission($data['login']['name'], "write")) {
$response = json_encode(["success" => false, "err" => "missing_permissions", "process" => $data['process']]);

View File

@ -14,7 +14,7 @@ class PluginManager{
public function __construct(LonaDB $lonaDB) {
$this->LonaDB = $lonaDB;
$this->Tables = array();
$this->Plugins = array();
}
public function LoadPlugins () : void {

View File

@ -95,8 +95,6 @@ class Table{
}
public function CheckPermission(string $user, string $permission) : bool {
$this->LonaDB->Logger->Table("(".$this->file.") Checkin permission '".$permission."' for user '".$user."'");
if($user === $this->Owner) return true;
if($this->LonaDB->UserManager->GetRole($user) === "Administrator" || $this->LonaDB->UserManager->GetRole($user) === "Superuser") return true;
if($this->permissions[$user]["admin"]) return true;
@ -106,10 +104,7 @@ class Table{
}
public function CheckVariable(string $name, string $user) : bool {
$this->LonaDB->Logger->Table("(".$this->file.") Checkin if variable '".$name."' exists for user '".$user."'");
if(!$this->CheckPermission($user, 'read')) return false;
if(!$this->data[$name]) return false;
return true;
}