This commit is contained in:
Krzysztof KrzysiekSiemv Smaga
2024-10-13 19:11:55 +02:00
parent eb805a994b
commit 619e221c61
18 changed files with 317 additions and 59 deletions
+13 -3
View File
@@ -18,10 +18,15 @@ namespace BlogEngine\Database {
public function Close($conn) { mysqli_close($conn); }
function Insert($into, $values){
function Insert($into, $values) : bool{
$conn = $this->Connection();
mysqli_query($conn, "INSERT INTO {$into} VALUES({$values})");
$this->Close($conn);
if(mysqli_query($conn, "INSERT INTO {$into} VALUES({$values})")){
$this->Close($conn);
return true;
} else {
$this->Close($conn);
return false;
}
}
function CreateTable($name, $columns){
@@ -194,5 +199,10 @@ namespace BlogEngine\Database {
error_log("Nie ma dostępnego folderu \"Tables\". Zatrzymywanie tworzenia bazy!");
}
}
function Log($content, $log_level = 'Information', $id_user = null){
$ip_address = file_get_contents("https://api.ipify.org");
$this->Insert("logs(ip_address, content, log_level, created_by)", "'$ip_address', '$content', '$log_level', $id_user");
}
}
}
+56
View File
@@ -419,5 +419,61 @@
"is_string": false
}
}
],
"logs": [
{
"column_name": "id_log",
"datatype": "INT",
"primary_key": true,
"auto_increment": true,
"not_null": true
},
{
"column_name": "ip_address",
"datatype": "VARCHAR",
"length": 15,
"not_null": true,
"default": {
"value": "127.0.0.1",
"is_string": true
}
},
{
"column_name": "content",
"datatype": "TEXT",
"not_null": true,
"default": {
"value": "Some unknown error",
"is_string": true
}
},
{
"column_name": "log_level",
"datatype": "ENUM",
"enum_data": ["Debug", "Information", "Warning", "Error", "Critical"],
"not_null": true,
"default": {
"value": "Warning",
"is_string": true
}
},
{
"column_name": "created_at",
"datatype": "DATETIME",
"not_null": true,
"default": {
"value": "NOW()",
"is_string": false
}
},
{
"column_name": "created_by",
"datatype": "INT",
"not_null": false,
"foreign_key": {
"references": "users",
"column": "id_user"
}
}
]
}