cscg25 continues
This commit is contained in:
32
cscg25/web/canteenfood/challenge/models/AdminModel.php
Normal file
32
cscg25/web/canteenfood/challenge/models/AdminModel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION["admin"] === false){
|
||||
return "You're not welcome. This part is only for canteen workers.";
|
||||
}
|
||||
|
||||
|
||||
class AdminModel {
|
||||
public $filename;
|
||||
public $logcontent;
|
||||
|
||||
public function __construct($filename, $content) {
|
||||
$this->filename = $filename;
|
||||
$this->logcontent = $content;
|
||||
file_put_contents($filename, $content, FILE_APPEND);
|
||||
}
|
||||
|
||||
public function __wakeup() {
|
||||
new LogFile($this->filename, $this->logcontent);
|
||||
}
|
||||
|
||||
public static function read_logs($log) {
|
||||
$contents = file_get_contents($log);
|
||||
return $contents;
|
||||
}
|
||||
}
|
||||
|
||||
class LogFile {
|
||||
public function __construct($filename, $content) {
|
||||
file_put_contents($filename, $content, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user