mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-14 04:04:01 +00:00
updated readme and added write checks on upload
This commit is contained in:
@@ -4,3 +4,12 @@ PictShare is a selfhostable, open source image, video and text hosting as well a
|
||||
|
||||
---
|
||||
[](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
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -299,3 +299,8 @@ function getUserIP()
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
|
||||
function isFolderWritable($dir)
|
||||
{
|
||||
return is_writable($dir);
|
||||
}
|
||||
Reference in New Issue
Block a user