aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
Diffstat (limited to 'app/class')
-rw-r--r--app/class/controllermedia.php35
-rw-r--r--app/class/media.php12
-rw-r--r--app/class/modelmedia.php21
-rw-r--r--app/class/modelrender.php12
4 files changed, 47 insertions, 33 deletions
diff --git a/app/class/controllermedia.php b/app/class/controllermedia.php
index 26b58ff..f156b35 100644
--- a/app/class/controllermedia.php
+++ b/app/class/controllermedia.php
@@ -14,7 +14,7 @@ class Controllermedia extends Controller
public function desktop()
{
if($this->user->iseditor()) {
- $dir = $_GET['path'] ?? Model::MEDIA_DIR;
+ $dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR);
$medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR);
$faviconlist = $this->mediamanager->getlistermedia(Model::FAVICON_DIR);
@@ -22,38 +22,21 @@ class Controllermedia extends Controller
$dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR);
$this->showtemplate('media', ['medialist' => $medialist, 'faviconlist' => $faviconlist, 'dirlist' => $dirlist, 'dir' => $dir]);
+ } else {
+ $this->routedirect('home');
}
}
- public function addmedia()
- {
- echo $this->templates->render('media', ['interface' => 'addmedia']);
-
- //$message = $this->mediamanager->addmedia($_FILES, 2 ** 24, $_POST['id']);
-
- }
-
public function upload()
{
+ if($this->user->iseditor()) {
$target = $_POST['dir'] ?? Model::MEDIA_DIR;
- if($target[strlen($target)-1]!='/')
- $target=$target.'/';
- $count=0;
- foreach ($_FILES['file']['name'] as $filename)
- {
- $fileinfo = pathinfo($filename);
- $extension = idclean($fileinfo['extension']);
- $id = idclean($fileinfo['filename']);
-
- $temp=$target;
- $tmp=$_FILES['file']['tmp_name'][$count];
- $count=$count + 1;
- $temp .= $id .'.' .$extension;
- move_uploaded_file($tmp,$temp);
- $temp='';
- $tmp='';
- }
+
+ $this->mediamanager->upload($target);
$this->redirect($this->router->generate('media').'?path='.$target);
+ } else {
+ $this->routedirect('home');
+ }
}
diff --git a/app/class/media.php b/app/class/media.php
index 0cbbd89..01dfd55 100644
--- a/app/class/media.php
+++ b/app/class/media.php
@@ -56,7 +56,17 @@ class Media
public function getfullpath()
{
- return '/' . Config::basepath() . '/' . $this->path() . $this->id() . '.' . $this->extension();
+ $fullpath = '/' . Config::basepath() . '/'. $this->path() . $this->id() . '.' . $this->extension();
+ $fullpath = str_replace('\\', '/', $fullpath);
+ return $fullpath;
+ }
+
+ public function getincludepath()
+ {
+ $includepath = $this->path() . $this->id() . '.' . $this->extension();
+ $includepath = str_replace('\\', '/', $includepath);
+ $includepath = substr($includepath, 6);
+ return $includepath;
}
diff --git a/app/class/modelmedia.php b/app/class/modelmedia.php
index 89c253f..5706c26 100644
--- a/app/class/modelmedia.php
+++ b/app/class/modelmedia.php
@@ -132,6 +132,27 @@ class Modelmedia extends Model
}
+ public function upload(string $target)
+ {
+ if($target[strlen($target)-1] != DIRECTORY_SEPARATOR)
+ $target .= DIRECTORY_SEPARATOR;
+ $count=0;
+ foreach ($_FILES['file']['name'] as $filename)
+ {
+ $fileinfo = pathinfo($filename);
+ $extension = idclean($fileinfo['extension']);
+ $id = idclean($fileinfo['filename']);
+
+ $temp=$target;
+ $tmp=$_FILES['file']['tmp_name'][$count];
+ $count=$count + 1;
+ $temp .= $id .'.' .$extension;
+ move_uploaded_file($tmp,$temp);
+ $temp='';
+ $tmp='';
+ }
+ }
+
}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 7ef7e45..c76fa69 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -322,13 +322,13 @@ class Modelrender extends Modelart
foreach ($medialist as $media) {
$ul .= '<li>';
if($media->type() == 'image') {
- $ul .= '<img alt="'.$media->id().'" id="'.$media->id().'" src="'.$media->getfullpath().'" >';
+ $ul .= '<img alt="'.$media->id().'" id="'.$media->id().'" src="'.$media->getincludepath().'" >';
} elseif ($media->type() == 'sound') {
- $ul .= '<audio id="'.$media->id().'" controls src="'.$media->getfullpath().'" </audio>';
+ $ul .= '<audio id="'.$media->id().'" controls src="'.$media->getincludepath().'" </audio>';
} elseif ($media->type() == 'video') {
- $ul .= '<video controls><source src="'.$media->getfullpath().'" type="video/'.$media->extension().'"></video>';
+ $ul .= '<video controls><source src="'.$media->getincludepath().'" type="video/'.$media->extension().'"></video>';
} elseif ($media->type() == 'other') {
- $ul .= '<a href="'.$media->getfullpath().'" target="_blank" class="media" >'.$media->id().'.'.$media->extension().'</a>';
+ $ul .= '<a href="'.$media->getincludepath().'" target="_blank" class="media" >'.$media->id().'.'.$media->extension().'</a>';
}
$ul .= '</li>' . PHP_EOL;
}
@@ -337,7 +337,7 @@ class Modelrender extends Modelart
return $ul;
} else {
- return 'directory not founded';
+ return 'directory "'.$dir.'" not found';
}
}, $text);
@@ -402,7 +402,7 @@ class Modelrender extends Modelart
}
}
- $ul = '<ul id="' . $tag . '">' . PHP_EOL;
+ $ul = '<ul class="taglist" id="' . $tag . '">' . PHP_EOL;
$this->artlistsort($li, 'date', -1);
foreach ($li as $item) {
if ($item->id() === $this->art->id()) {