mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-14 12:08:01 +00:00
added pastebinit support and fixed small errors
This commit is contained in:
@@ -6,6 +6,7 @@ PictShare is a selfhostable, open source image, video and text hosting as well a
|
|||||||
[](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE)
|
[](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE)
|
||||||
|
|
||||||
# This is the development branch for Version 2 do not use in production
|
# This is the development branch for Version 2 do not use in production
|
||||||
|
Test site: https://dev.pictshare.net/ (only sometimes on)
|
||||||
|
|
||||||
## New Features in v2:
|
## New Features in v2:
|
||||||
|
|
||||||
|
|||||||
39
api/pastebin.php
Normal file
39
api/pastebin.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
// basic path definitions
|
||||||
|
define('DS', DIRECTORY_SEPARATOR);
|
||||||
|
define('ROOT', dirname(__FILE__).'/..');
|
||||||
|
|
||||||
|
//loading default settings if exist
|
||||||
|
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
|
||||||
|
exit('Rename /inc/example.config.inc.php to /inc/config.inc.php first!');
|
||||||
|
include_once(ROOT.DS.'inc'.DS.'config.inc.php');
|
||||||
|
|
||||||
|
//loading core and controllers
|
||||||
|
include_once(ROOT . DS . 'inc' . DS. 'core.php');
|
||||||
|
require_once(ROOT . DS . 'controllers' . DS. 'text'. DS . 'text.controller.php');
|
||||||
|
|
||||||
|
// check write permissions first
|
||||||
|
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 POSTed text
|
||||||
|
if($_REQUEST['api_paste_code'])
|
||||||
|
{
|
||||||
|
$hash = getNewHash('txt',$length=10);
|
||||||
|
$tmpfile = ROOT.DS.'tmp'.DS.$hash;
|
||||||
|
file_put_contents($tmpfile,$_REQUEST['api_paste_code']);
|
||||||
|
|
||||||
|
//check if this exact paste already exists
|
||||||
|
$sha1 = sha1_file($tmpfile);
|
||||||
|
$sha_hash = sha1Exists($sha1);
|
||||||
|
if($sha_hash)
|
||||||
|
exit(URL.$sha_hash);
|
||||||
|
|
||||||
|
$answer = (new TextController())->handleUpload($tmpfile,$hash);
|
||||||
|
if($answer['hash'])
|
||||||
|
addSha1($answer['hash'],$sha1);
|
||||||
|
|
||||||
|
echo URL.$hash;
|
||||||
|
}
|
||||||
@@ -53,7 +53,8 @@ class ImageController
|
|||||||
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);
|
copy($tmpfile, $file);
|
||||||
|
unlink($tmpfile);
|
||||||
|
|
||||||
if(defined('ALT_FOLDER') && ALT_FOLDER)
|
if(defined('ALT_FOLDER') && ALT_FOLDER)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class TextController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(!endswith($hash,'.txt'))
|
||||||
$hash.='.txt';
|
$hash.='.txt';
|
||||||
if(isExistingHash($hash))
|
if(isExistingHash($hash))
|
||||||
return array('status'=>'err','reason'=>'Custom hash already exists');
|
return array('status'=>'err','reason'=>'Custom hash already exists');
|
||||||
@@ -48,7 +49,8 @@ class TextController
|
|||||||
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);
|
copy($tmpfile, $file);
|
||||||
|
unlink($tmpfile);
|
||||||
|
|
||||||
if(defined('ALT_FOLDER') && ALT_FOLDER)
|
if(defined('ALT_FOLDER') && ALT_FOLDER)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ class VideoController
|
|||||||
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);
|
copy($tmpfile, $file);
|
||||||
|
unlink($tmpfile);
|
||||||
|
|
||||||
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 &");
|
||||||
|
|||||||
25
rtfm/PASTEBINIT.md
Normal file
25
rtfm/PASTEBINIT.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# How to use Pictshare text upload with pastebinit
|
||||||
|
|
||||||
|
1. Install [pastebinit](https://help.ubuntu.com/community/Pastebinit)
|
||||||
|
2. Create a file in /usr/share/pastebinit.d/ called "pictshare.net.conf"
|
||||||
|
3. Paste the following lines in this new file:
|
||||||
|
|
||||||
|
```
|
||||||
|
[pastebin]
|
||||||
|
basename = pictshare.net
|
||||||
|
regexp = https://pictshare.net
|
||||||
|
https = true
|
||||||
|
|
||||||
|
[format]
|
||||||
|
content = api_paste_code
|
||||||
|
page = page
|
||||||
|
regexp = regexp
|
||||||
|
|
||||||
|
[defaults]
|
||||||
|
page = /api/pastebin.php
|
||||||
|
regexp = (.*)
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you should be able to use pastebinit like this: ```echo "hello world" | pastebinit -b pictshare.net```
|
||||||
|
|
||||||
|
If you want to use pictshare as your default you can either make an alias or edit ```/usr/bin/pastebinit``` and set ```defaultPB = "pictshare.net"```
|
||||||
Reference in New Issue
Block a user