<?php
abstract class Checkrights{
public $files;
public $app;
public function __construct(\Slim\Slim &$app, $files){
$this->app = $app;
$this->files = $files;
}
public function GerFiles(){
$this->cookieUser=$this->app->getCookie('username');
$obj = new Files();
$obj->parseFile($this->files);
$obj->CheckFormat();
$this->cookieDB = $obj->cookie;
$this->cookieUser=$this->app->getCookie('username');
$this->public=$obj->public;
$obj->path = $this->preview;
}
abstract function Render();
}
class RenderPublic extends Checkrights{
public function __construct(\Slim\Slim &$app, $files){
parent::__construct(\Slim\Slim &$app, $files);
}
public function GerFiles() { parent::GetFiles(); }
function Render(){
if($this->cookieUser==$this->cookieDB){
$this->app->render('File.php', ['files'=>$this->files, 'filesize'=>$this->filesize]); }
elseif($this->public==0) {
$this->app->render('Public.php', ['files'=>$this->files, 'filesize'=>$this->filesize]); }
else {
$this->app->notFound();
}
}
}
class RenderPreview extends Checkrights{
public function __construct(\Slim\Slim &$app, $files){
parent::__construct(\Slim\Slim &$app, $files);
}
public function GerFiles() { parent::GetFiles(); }
function Render($preview){
$this->preview = $preview;
if($this->cookieUser==$this->cookieDB){
$this->app->render('Preview.php',['files'=>$this->files]);
}
elseif($this->public==0) {
$this->app->render('Public.php', ['files'=>$this->files]);
}
else {
$this->app->notFound();
}
}
}
PD9waHAKCmFic3RyYWN0IGNsYXNzIENoZWNrcmlnaHRzewpwdWJsaWMgJGZpbGVzOwpwdWJsaWMgJGFwcDsKCnB1YmxpYyBmdW5jdGlvbiBfX2NvbnN0cnVjdChcU2xpbVxTbGltICYkYXBwLCAkZmlsZXMpewogICAgJHRoaXMtPmFwcCA9ICRhcHA7CiAgICAkdGhpcy0+ZmlsZXMgPSAkZmlsZXM7Cn0KcHVibGljIGZ1bmN0aW9uIEdlckZpbGVzKCl7CiAgICAgJHRoaXMtPmNvb2tpZVVzZXI9JHRoaXMtPmFwcC0+Z2V0Q29va2llKCd1c2VybmFtZScpOwogICAgICAgICAgICAKICAgICAgICAgICAgJG9iaiA9IG5ldyBGaWxlcygpOwogICAgICA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