updated readme and added write checks on upload

This commit is contained in:
Chris
2018-12-22 15:56:34 +01:00
parent 24411dfe93
commit 56654e1ff4
4 changed files with 19 additions and 10 deletions

View File

@@ -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. 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) [![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

View File

@@ -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. 'url'. DS . 'url.controller.php');
require_once(ROOT . DS . 'controllers' . DS. 'video'. DS . 'video.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 // check for POST upload
if ($_FILES['file']["error"] == UPLOAD_ERR_OK) if ($_FILES['file']["error"] == UPLOAD_ERR_OK)

View File

@@ -37,26 +37,17 @@ class VideoController
public function handleUpload($tmpfile,$hash=false) 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) if($hash===false)
$hash = getNewHash('mp4',6); $hash = getNewHash('mp4',6);
fwrite($fh, "[2] $tmpfile got the hash $hash\n");
mkdir(ROOT.DS.'data'.DS.$hash); mkdir(ROOT.DS.'data'.DS.$hash);
$file = ROOT.DS.'data'.DS.$hash.DS.$hash; $file = ROOT.DS.'data'.DS.$hash.DS.$hash;
move_uploaded_file($tmpfile, $file); move_uploaded_file($tmpfile, $file);
fwrite($fh, "[3] Was it already correclty encoded? ".($this->rightEncodedMP4($file)?'yes':'no'));
if(!$this->rightEncodedMP4($file)) if(!$this->rightEncodedMP4($file))
system("nohup php ".ROOT.DS.'tools'.DS.'re-encode_mp4.php force '.$hash." > /dev/null 2> /dev/null &"); 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) if(defined('ALT_FOLDER') && ALT_FOLDER)
{ {
$altname=ALT_FOLDER.DS.$hash; $altname=ALT_FOLDER.DS.$hash;

View File

@@ -298,4 +298,9 @@ function getUserIP()
$ip = $remote; $ip = $remote;
} }
return $ip; return $ip;
}
function isFolderWritable($dir)
{
return is_writable($dir);
} }