From 56654e1ff460aa8580f9dec3e046a8baf515a870 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 22 Dec 2018 15:56:34 +0100 Subject: [PATCH] updated readme and added write checks on upload --- README.md | 11 ++++++++++- api/upload.php | 4 ++++ controllers/video/video.controller.php | 9 --------- inc/core.php | 5 +++++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3b982db..1d0b919 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,13 @@ PictShare is a selfhostable, open source image, video and text hosting as well as URL shortening service with a simple API. --- -[![Apache License](https://img.shields.io/badge/license-Apache-blue.svg?style=flat)](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE) \ No newline at end of file +[![Apache License](https://img.shields.io/badge/license-Apache-blue.svg?style=flat)](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE) + +# This is the development branch for Version 2 do not use in production + +## New Features in v2: + +- Added text hosting (like pastebin) +- Added URL shortening +- Added WebP to images (and conversion from jpg,png to webp) +- Massive code rework. Actually we designed it from the ground up to be more modular and easier to debug \ No newline at end of file diff --git a/api/upload.php b/api/upload.php index 55427df..632c540 100644 --- a/api/upload.php +++ b/api/upload.php @@ -15,6 +15,10 @@ require_once(ROOT . DS . 'controllers' . DS. 'text'. DS . 'text.controller.php') require_once(ROOT . DS . 'controllers' . DS. 'url'. DS . 'url.controller.php'); require_once(ROOT . DS . 'controllers' . DS. 'video'. DS . 'video.controller.php'); +if(!isFolderWritable(ROOT.DS.'data')) + exit(json_encode(array('status'=>'err','reason'=>'Data directory not writable'))); +else if(!isFolderWritable(ROOT.DS.'tmp')) + exit(json_encode(array('status'=>'err','reason'=>'Temp directory not writable'))); // check for POST upload if ($_FILES['file']["error"] == UPLOAD_ERR_OK) diff --git a/controllers/video/video.controller.php b/controllers/video/video.controller.php index 5755974..f0c6877 100644 --- a/controllers/video/video.controller.php +++ b/controllers/video/video.controller.php @@ -37,26 +37,17 @@ class VideoController public function handleUpload($tmpfile,$hash=false) { - $fh = fopen(ROOT.DS.'log'.DS.'video.log', 'a'); ////// - fwrite($fh, "[1] $tmpfile was uploaded\n"); - if($hash===false) $hash = getNewHash('mp4',6); - fwrite($fh, "[2] $tmpfile got the hash $hash\n"); - mkdir(ROOT.DS.'data'.DS.$hash); $file = ROOT.DS.'data'.DS.$hash.DS.$hash; move_uploaded_file($tmpfile, $file); - fwrite($fh, "[3] Was it already correclty encoded? ".($this->rightEncodedMP4($file)?'yes':'no')); - if(!$this->rightEncodedMP4($file)) system("nohup php ".ROOT.DS.'tools'.DS.'re-encode_mp4.php force '.$hash." > /dev/null 2> /dev/null &"); - fclose($fh); - if(defined('ALT_FOLDER') && ALT_FOLDER) { $altname=ALT_FOLDER.DS.$hash; diff --git a/inc/core.php b/inc/core.php index aa9b240..1ef82e9 100644 --- a/inc/core.php +++ b/inc/core.php @@ -298,4 +298,9 @@ function getUserIP() $ip = $remote; } return $ip; +} + +function isFolderWritable($dir) +{ + return is_writable($dir); } \ No newline at end of file