2012-04-29 17:15:06 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ZeroBin
|
|
|
|
*
|
|
|
|
* a zero-knowledge paste bin
|
|
|
|
*
|
|
|
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
|
|
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
|
|
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
2015-09-21 20:43:00 +00:00
|
|
|
* @version 0.21.1
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zerobin
|
|
|
|
*
|
|
|
|
* Controller, puts it all together.
|
|
|
|
*/
|
|
|
|
class zerobin
|
|
|
|
{
|
2015-08-16 13:55:31 +00:00
|
|
|
/**
|
|
|
|
* version
|
|
|
|
*
|
|
|
|
* @const string
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
2015-09-21 20:43:00 +00:00
|
|
|
const VERSION = '0.21.1';
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-08-31 20:10:41 +00:00
|
|
|
/**
|
|
|
|
* show the same error message if the paste expired or does not exist
|
|
|
|
*
|
|
|
|
* @const string
|
|
|
|
*/
|
|
|
|
const GENERIC_ERROR = 'Paste does not exist, has expired or has been deleted.';
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
/**
|
2015-09-22 21:21:31 +00:00
|
|
|
* configuration
|
2015-08-16 13:55:31 +00:00
|
|
|
*
|
2012-04-29 17:15:06 +00:00
|
|
|
* @access private
|
2015-09-22 21:21:31 +00:00
|
|
|
* @var configuration
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
2015-09-22 21:21:31 +00:00
|
|
|
private $_conf;
|
2012-04-29 17:15:06 +00:00
|
|
|
|
|
|
|
/**
|
2015-08-16 13:55:31 +00:00
|
|
|
* data
|
|
|
|
*
|
2012-04-29 17:15:06 +00:00
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_data = '';
|
|
|
|
|
2015-09-12 15:33:16 +00:00
|
|
|
/**
|
|
|
|
* formatter
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_formatter = 'plaintext';
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
/**
|
2015-08-16 13:55:31 +00:00
|
|
|
* error message
|
|
|
|
*
|
2012-04-29 17:15:06 +00:00
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_error = '';
|
|
|
|
|
2013-11-01 00:15:14 +00:00
|
|
|
/**
|
2015-08-16 13:55:31 +00:00
|
|
|
* status message
|
|
|
|
*
|
2013-11-01 00:15:14 +00:00
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_status = '';
|
|
|
|
|
2015-09-01 20:33:07 +00:00
|
|
|
/**
|
|
|
|
* JSON message
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_json = '';
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
/**
|
2015-09-27 01:03:55 +00:00
|
|
|
* Factory of instance models
|
2015-08-16 13:55:31 +00:00
|
|
|
*
|
2012-04-29 17:15:06 +00:00
|
|
|
* @access private
|
2015-09-27 01:03:55 +00:00
|
|
|
* @var model
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
|
|
|
private $_model;
|
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
/**
|
|
|
|
* request
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @var request
|
|
|
|
*/
|
|
|
|
private $_request;
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* initializes and runs ZeroBin
|
|
|
|
*
|
|
|
|
* @access public
|
2015-08-16 13:55:31 +00:00
|
|
|
* @return void
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
if (version_compare(PHP_VERSION, '5.2.6') < 0)
|
2015-09-01 20:33:07 +00:00
|
|
|
{
|
2015-09-05 00:24:56 +00:00
|
|
|
throw new Exception(i18n::_('ZeroBin requires php 5.2.6 or above to work. Sorry.'), 1);
|
2015-09-01 20:33:07 +00:00
|
|
|
}
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2013-11-01 00:15:14 +00:00
|
|
|
// load config from ini file
|
2012-04-29 17:15:06 +00:00
|
|
|
$this->_init();
|
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
switch ($this->_request->getOperation())
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 18:34:39 +00:00
|
|
|
case 'create':
|
|
|
|
$this->_create();
|
|
|
|
break;
|
|
|
|
case 'delete':
|
|
|
|
$this->_delete(
|
|
|
|
$this->_request->getParam('pasteid'),
|
|
|
|
$this->_request->getParam('deletetoken')
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'read':
|
|
|
|
$this->_read($this->_request->getParam('pasteid'));
|
|
|
|
break;
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
2015-09-01 20:33:07 +00:00
|
|
|
// output JSON or HTML
|
2015-09-27 18:34:39 +00:00
|
|
|
if ($this->_request->isJsonApiCall())
|
2015-09-01 20:33:07 +00:00
|
|
|
{
|
|
|
|
header('Content-type: application/json');
|
|
|
|
echo $this->_json;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->_view();
|
|
|
|
}
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize zerobin
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _init()
|
|
|
|
{
|
2012-04-30 11:58:29 +00:00
|
|
|
foreach (array('cfg', 'lib') as $dir)
|
|
|
|
{
|
2015-08-28 23:26:48 +00:00
|
|
|
if (!is_file(PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess')) file_put_contents(
|
|
|
|
PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess',
|
2012-04-30 11:58:29 +00:00
|
|
|
'Allow from none' . PHP_EOL .
|
2015-08-16 10:27:06 +00:00
|
|
|
'Deny from all'. PHP_EOL,
|
|
|
|
LOCK_EX
|
2012-04-30 11:58:29 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-09-22 21:21:31 +00:00
|
|
|
$this->_conf = new configuration;
|
2015-09-27 01:03:55 +00:00
|
|
|
$this->_model = new model($this->_conf);
|
2015-09-27 18:34:39 +00:00
|
|
|
$this->_request = new request;
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-11-01 00:15:14 +00:00
|
|
|
* Store new paste or comment
|
2012-04-29 17:15:06 +00:00
|
|
|
*
|
2015-09-16 20:51:48 +00:00
|
|
|
* POST contains one or both:
|
|
|
|
* data = json encoded SJCL encrypted text (containing keys: iv,v,iter,ks,ts,mode,adata,cipher,salt,ct)
|
|
|
|
* attachment = json encoded SJCL encrypted text (containing keys: iv,v,iter,ks,ts,mode,adata,cipher,salt,ct)
|
2012-04-29 17:15:06 +00:00
|
|
|
*
|
|
|
|
* All optional data will go to meta information:
|
2012-05-19 21:59:41 +00:00
|
|
|
* expire (optional) = expiration delay (never,5min,10min,1hour,1day,1week,1month,1year,burn) (default:never)
|
2015-09-16 20:51:48 +00:00
|
|
|
* formatter (optional) = format to display the paste as (plaintext,syntaxhighlighting,markdown) (default:syntaxhighlighting)
|
|
|
|
* burnafterreading (optional) = if this paste may only viewed once ? (0/1) (default:0)
|
2012-04-29 17:15:06 +00:00
|
|
|
* opendiscusssion (optional) = is the discussion allowed on this paste ? (0/1) (default:0)
|
2015-09-21 20:32:52 +00:00
|
|
|
* attachmentname = json encoded SJCL encrypted text (containing keys: iv,v,iter,ks,ts,mode,adata,cipher,salt,ct)
|
2015-09-05 00:24:56 +00:00
|
|
|
* nickname (optional) = in discussion, encoded SJCL encrypted text nickname of author of comment (containing keys: iv,v,iter,ks,ts,mode,adata,cipher,salt,ct)
|
2012-04-29 17:15:06 +00:00
|
|
|
* parentid (optional) = in discussion, which comment this comment replies to.
|
|
|
|
* pasteid (optional) = in discussion, which paste this comment belongs to.
|
|
|
|
*
|
|
|
|
* @access private
|
2015-08-27 21:58:56 +00:00
|
|
|
* @return string
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
2015-09-16 20:51:48 +00:00
|
|
|
private function _create()
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
|
|
|
$error = false;
|
|
|
|
|
2015-09-27 01:03:55 +00:00
|
|
|
// Ensure last paste from visitors IP address was more than configured amount of seconds ago.
|
2015-09-26 15:57:46 +00:00
|
|
|
trafficlimiter::setConfiguration($this->_conf);
|
|
|
|
if (!trafficlimiter::canPass()) return $this->_return_message(
|
2015-09-27 01:03:55 +00:00
|
|
|
1, i18n::_(
|
2015-09-19 12:22:29 +00:00
|
|
|
'Please wait %d seconds between each post.',
|
2015-09-22 21:21:31 +00:00
|
|
|
$this->_conf->getKey('limit', 'traffic')
|
2015-09-19 12:22:29 +00:00
|
|
|
)
|
|
|
|
);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$data = $this->_request->getParam('data');
|
|
|
|
$attachment = $this->_request->getParam('attachment');
|
|
|
|
$attachmentname = $this->_request->getParam('attachmentname');
|
2015-09-27 01:03:55 +00:00
|
|
|
|
|
|
|
// Ensure content is not too big.
|
2015-09-22 21:21:31 +00:00
|
|
|
$sizelimit = $this->_conf->getKey('sizelimit');
|
2015-09-19 12:22:29 +00:00
|
|
|
if (
|
|
|
|
strlen($data) + strlen($attachment) + strlen($attachmentname) > $sizelimit
|
|
|
|
) return $this->_return_message(
|
|
|
|
1,
|
|
|
|
i18n::_(
|
|
|
|
'Paste is limited to %s of encrypted data.',
|
|
|
|
filter::size_humanreadable($sizelimit)
|
|
|
|
)
|
|
|
|
);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 01:03:55 +00:00
|
|
|
// The user posts a comment.
|
2015-09-27 18:34:39 +00:00
|
|
|
$pasteid = $this->_request->getParam('pasteid');
|
|
|
|
$parentid = $this->_request->getParam('parentid');
|
|
|
|
if (!empty($pasteid) && !empty($parentid))
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 18:34:39 +00:00
|
|
|
$paste = $this->_model->getPaste($pasteid);
|
2015-09-27 01:03:55 +00:00
|
|
|
if ($paste->exists()) {
|
|
|
|
try {
|
2015-09-27 18:34:39 +00:00
|
|
|
$comment = $paste->getComment($parentid);
|
2015-09-27 01:03:55 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$nickname = $this->_request->getParam('nickname');
|
|
|
|
if (!empty($nickname)) $comment->setNickname($nickname);
|
2015-09-27 01:03:55 +00:00
|
|
|
|
|
|
|
$comment->setData($data);
|
|
|
|
$comment->store();
|
|
|
|
} catch(Exception $e) {
|
|
|
|
return $this->_return_message(1, $e->getMessage());
|
|
|
|
}
|
|
|
|
$this->_return_message(0, $comment->getId());
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
2015-09-27 01:03:55 +00:00
|
|
|
else
|
2015-09-12 15:33:16 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
$this->_return_message(1, 'Invalid data.');
|
2015-09-12 15:33:16 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-27 01:03:55 +00:00
|
|
|
// The user posts a standard paste.
|
|
|
|
else
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
$paste = $this->_model->getPaste();
|
|
|
|
try {
|
2015-10-03 15:54:18 +00:00
|
|
|
$paste->setData($data);
|
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
if (!empty($attachment))
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
$paste->setAttachment($attachment);
|
2015-09-27 18:34:39 +00:00
|
|
|
if (!empty($attachmentname))
|
2015-09-27 01:03:55 +00:00
|
|
|
$paste->setAttachmentName($attachmentname);
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$expire = $this->_request->getParam('expire');
|
|
|
|
if (!empty($expire)) $paste->setExpiration($expire);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$burnafterreading = $this->_request->getParam('burnafterreading');
|
|
|
|
if (!empty($burnafterreading)) $paste->setBurnafterreading($burnafterreading);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$opendiscussion = $this->_request->getParam('opendiscussion');
|
|
|
|
if (!empty($opendiscussion)) $paste->setOpendiscussion($opendiscussion);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
$formatter = $this->_request->getParam('formatter');
|
|
|
|
if (!empty($formatter)) $paste->setFormatter($formatter);
|
2012-04-29 17:15:06 +00:00
|
|
|
|
2015-09-27 01:03:55 +00:00
|
|
|
$paste->store();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
return $this->_return_message(1, $e->getMessage());
|
|
|
|
}
|
|
|
|
$this->_return_message(0, $paste->getId(), array('deletetoken' => $paste->getDeleteToken()));
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-24 13:33:51 +00:00
|
|
|
/**
|
|
|
|
* Delete an existing paste
|
|
|
|
*
|
|
|
|
* @access private
|
2013-11-01 00:15:14 +00:00
|
|
|
* @param string $dataid
|
|
|
|
* @param string $deletetoken
|
2015-09-01 20:33:07 +00:00
|
|
|
* @return void
|
2013-02-24 13:33:51 +00:00
|
|
|
*/
|
|
|
|
private function _delete($dataid, $deletetoken)
|
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
try {
|
|
|
|
$paste = $this->_model->getPaste($dataid);
|
|
|
|
if ($paste->exists())
|
2015-08-31 20:10:41 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
// accessing this property ensures that the paste would be
|
|
|
|
// deleted if it has already expired
|
|
|
|
$burnafterreading = $paste->isBurnafterreading();
|
|
|
|
if ($deletetoken == 'burnafterreading')
|
|
|
|
{
|
|
|
|
if ($burnafterreading)
|
|
|
|
{
|
|
|
|
$paste->delete();
|
|
|
|
$this->_return_message(0, $dataid);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->_return_message(1, 'Paste is not of burn-after-reading type.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Make sure the token is valid.
|
|
|
|
serversalt::setPath($this->_conf->getKey('dir', 'traffic'));
|
|
|
|
if (filter::slow_equals($deletetoken, $paste->getDeleteToken()))
|
|
|
|
{
|
|
|
|
// Paste exists and deletion token is valid: Delete the paste.
|
|
|
|
$paste->delete();
|
|
|
|
$this->_status = 'Paste was properly deleted.';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->_error = 'Wrong deletion token. Paste was not deleted.';
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 20:33:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
$this->_error = self::GENERIC_ERROR;
|
2015-08-31 20:10:41 +00:00
|
|
|
}
|
2015-09-27 01:03:55 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
$this->_error = $e->getMessage();
|
2013-11-01 00:15:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
/**
|
2013-11-01 00:15:14 +00:00
|
|
|
* Read an existing paste or comment
|
2012-04-29 17:15:06 +00:00
|
|
|
*
|
|
|
|
* @access private
|
2013-11-01 00:15:14 +00:00
|
|
|
* @param string $dataid
|
2012-04-29 17:15:06 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2013-11-01 00:15:14 +00:00
|
|
|
private function _read($dataid)
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
try {
|
|
|
|
$paste = $this->_model->getPaste($dataid);
|
|
|
|
if ($paste->exists())
|
2014-02-06 21:52:17 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
// The paste itself is the first in the list of encrypted messages.
|
|
|
|
$messages = array_merge(
|
|
|
|
array($paste->get()),
|
|
|
|
$paste->getComments()
|
|
|
|
);
|
|
|
|
$this->_data = json_encode($messages);
|
2014-02-06 21:52:17 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
2015-09-27 01:03:55 +00:00
|
|
|
$this->_error = self::GENERIC_ERROR;
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
2015-09-27 01:03:55 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
$this->_error = $e->getMessage();
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
2015-09-27 01:03:55 +00:00
|
|
|
|
2015-09-27 18:34:39 +00:00
|
|
|
if ($this->_request->isJsonApiCall())
|
2015-09-01 20:33:07 +00:00
|
|
|
{
|
|
|
|
if (strlen($this->_error))
|
|
|
|
{
|
|
|
|
$this->_return_message(1, $this->_error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->_return_message(0, $dataid, array('messages' => $messages));
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display ZeroBin frontend.
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _view()
|
|
|
|
{
|
2012-08-28 21:28:41 +00:00
|
|
|
// set headers to disable caching
|
2013-02-24 13:33:51 +00:00
|
|
|
$time = gmdate('D, d M Y H:i:s \G\M\T');
|
|
|
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
|
|
|
header('Pragma: no-cache');
|
|
|
|
header('Expires: ' . $time);
|
|
|
|
header('Last-Modified: ' . $time);
|
|
|
|
header('Vary: Accept');
|
2012-08-25 22:49:11 +00:00
|
|
|
|
2013-10-30 22:54:42 +00:00
|
|
|
// label all the expiration options
|
|
|
|
$expire = array();
|
2015-09-22 21:21:31 +00:00
|
|
|
foreach ($this->_conf->getSection('expire_options') as $time => $seconds)
|
2015-09-12 15:33:16 +00:00
|
|
|
{
|
2015-09-06 17:21:17 +00:00
|
|
|
$expire[$time] = ($seconds == 0) ? i18n::_(ucfirst($time)): filter::time_humanreadable($time);
|
2013-10-30 22:54:42 +00:00
|
|
|
}
|
|
|
|
|
2015-09-12 15:33:16 +00:00
|
|
|
// translate all the formatter options
|
2015-09-22 21:21:31 +00:00
|
|
|
$formatters = array_map(array('i18n', 'translate'), $this->_conf->getSection('formatter_options'));
|
2015-09-12 15:33:16 +00:00
|
|
|
|
2015-09-19 09:21:13 +00:00
|
|
|
// set language cookie if that functionality was enabled
|
|
|
|
$languageselection = '';
|
2015-09-22 21:21:31 +00:00
|
|
|
if ($this->_conf->getKey('languageselection'))
|
2015-09-19 09:21:13 +00:00
|
|
|
{
|
|
|
|
$languageselection = i18n::getLanguage();
|
|
|
|
setcookie('lang', $languageselection);
|
|
|
|
}
|
|
|
|
|
2012-04-29 17:15:06 +00:00
|
|
|
$page = new RainTPL;
|
2015-08-16 10:27:06 +00:00
|
|
|
$page::$path_replace = false;
|
2013-10-30 22:54:42 +00:00
|
|
|
// we escape it here because ENT_NOQUOTES can't be used in RainTPL templates
|
2012-04-29 17:15:06 +00:00
|
|
|
$page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
|
2015-09-05 00:24:56 +00:00
|
|
|
$page->assign('ERROR', i18n::_($this->_error));
|
|
|
|
$page->assign('STATUS', i18n::_($this->_status));
|
2012-04-29 17:15:06 +00:00
|
|
|
$page->assign('VERSION', self::VERSION);
|
2015-09-22 21:21:31 +00:00
|
|
|
$page->assign('DISCUSSION', $this->_conf->getKey('discussion'));
|
|
|
|
$page->assign('OPENDISCUSSION', $this->_conf->getKey('opendiscussion'));
|
2015-09-12 15:33:16 +00:00
|
|
|
$page->assign('MARKDOWN', array_key_exists('markdown', $formatters));
|
|
|
|
$page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters));
|
2015-09-22 21:21:31 +00:00
|
|
|
$page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_conf->getKey('syntaxhighlightingtheme'));
|
2015-09-12 15:33:16 +00:00
|
|
|
$page->assign('FORMATTER', $formatters);
|
2015-09-22 21:21:31 +00:00
|
|
|
$page->assign('FORMATTERDEFAULT', $this->_conf->getKey('defaultformatter'));
|
|
|
|
$page->assign('NOTICE', i18n::_($this->_conf->getKey('notice')));
|
|
|
|
$page->assign('BURNAFTERREADINGSELECTED', $this->_conf->getKey('burnafterreadingselected'));
|
|
|
|
$page->assign('PASSWORD', $this->_conf->getKey('password'));
|
|
|
|
$page->assign('FILEUPLOAD', $this->_conf->getKey('fileupload'));
|
|
|
|
$page->assign('BASE64JSVERSION', $this->_conf->getKey('base64version'));
|
2015-09-19 09:21:13 +00:00
|
|
|
$page->assign('LANGUAGESELECTION', $languageselection);
|
|
|
|
$page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
|
2013-10-30 22:54:42 +00:00
|
|
|
$page->assign('EXPIRE', $expire);
|
2015-09-22 21:21:31 +00:00
|
|
|
$page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
|
|
|
|
$page->draw($this->_conf->getKey('template'));
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* return JSON encoded message and exit
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @param bool $status
|
|
|
|
* @param string $message
|
2013-11-01 00:15:14 +00:00
|
|
|
* @param array $other
|
2015-09-01 20:33:07 +00:00
|
|
|
* @return void
|
2012-04-29 17:15:06 +00:00
|
|
|
*/
|
2013-11-01 00:15:14 +00:00
|
|
|
private function _return_message($status, $message, $other = array())
|
2012-04-29 17:15:06 +00:00
|
|
|
{
|
|
|
|
$result = array('status' => $status);
|
|
|
|
if ($status)
|
|
|
|
{
|
2015-09-05 00:24:56 +00:00
|
|
|
$result['message'] = i18n::_($message);
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result['id'] = $message;
|
2015-10-11 19:22:00 +00:00
|
|
|
$result['url'] = (
|
|
|
|
array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : '/'
|
|
|
|
) . '?' . $message;
|
|
|
|
$result['@context'] = 'js/paste.jsonld';
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
2013-11-01 00:15:14 +00:00
|
|
|
$result += $other;
|
2015-09-01 20:33:07 +00:00
|
|
|
$this->_json = json_encode($result);
|
2012-04-29 17:15:06 +00:00
|
|
|
}
|
|
|
|
}
|