2012-04-29 19:15:06 +02: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
|
2013-02-24 17:41:32 +01:00
|
|
|
* @version 0.18
|
2012-04-29 19:15:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* zerobin
|
|
|
|
*
|
|
|
|
* Controller, puts it all together.
|
|
|
|
*/
|
|
|
|
class zerobin
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* @const string version
|
|
|
|
*/
|
2013-02-24 17:41:32 +01:00
|
|
|
const VERSION = 'Alpha 0.18';
|
2012-04-29 19:15:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @access private
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private $_conf = array(
|
|
|
|
'model' => 'zerobin_data',
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_data = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_error = '';
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
/**
|
|
|
|
* @access private
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_status = '';
|
|
|
|
|
2012-04-29 19:15:06 +02:00
|
|
|
/**
|
|
|
|
* @access private
|
|
|
|
* @var zerobin_data
|
|
|
|
*/
|
|
|
|
private $_model;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* initializes and runs ZeroBin
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
if (version_compare(PHP_VERSION, '5.2.6') < 0)
|
|
|
|
die('ZeroBin requires php 5.2.6 or above to work. Sorry.');
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
// in case stupid admin has left magic_quotes enabled in php.ini
|
2012-04-29 19:15:06 +02:00
|
|
|
if (get_magic_quotes_gpc())
|
|
|
|
{
|
|
|
|
$_POST = array_map('filter::stripslashes_deep', $_POST);
|
|
|
|
$_GET = array_map('filter::stripslashes_deep', $_GET);
|
|
|
|
$_COOKIE = array_map('filter::stripslashes_deep', $_COOKIE);
|
|
|
|
}
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
// load config from ini file
|
2012-04-29 19:15:06 +02:00
|
|
|
$this->_init();
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
// create new paste or comment
|
2012-04-29 19:15:06 +02:00
|
|
|
if (!empty($_POST['data']))
|
|
|
|
{
|
2013-11-01 01:15:14 +01:00
|
|
|
$this->_create($_POST['data']);
|
|
|
|
}
|
|
|
|
// delete an existing paste
|
|
|
|
elseif (!empty($_GET['deletetoken']) && !empty($_GET['pasteid']))
|
|
|
|
{
|
|
|
|
$this->_delete($_GET['pasteid'], $_GET['deletetoken']);
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
2013-11-01 01:15:14 +01:00
|
|
|
// display an existing paste
|
2012-04-29 19:15:06 +02:00
|
|
|
elseif (!empty($_SERVER['QUERY_STRING']))
|
|
|
|
{
|
2013-11-01 01:15:14 +01:00
|
|
|
$this->_read($_SERVER['QUERY_STRING']);
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
// display ZeroBin frontend
|
2012-04-29 19:15:06 +02:00
|
|
|
$this->_view();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize zerobin
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _init()
|
|
|
|
{
|
2012-04-30 13:58:29 +02:00
|
|
|
foreach (array('cfg', 'lib') as $dir)
|
|
|
|
{
|
|
|
|
if (!is_file(PATH . $dir . '/.htaccess')) file_put_contents(
|
|
|
|
PATH . $dir . '/.htaccess',
|
|
|
|
'Allow from none' . PHP_EOL .
|
|
|
|
'Deny from all'. PHP_EOL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-05-19 23:59:41 +02:00
|
|
|
$this->_conf = parse_ini_file(PATH . 'cfg/conf.ini', true);
|
|
|
|
$this->_model = $this->_conf['model']['class'];
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the model, create one if needed
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @return zerobin_data
|
|
|
|
*/
|
|
|
|
private function _model()
|
|
|
|
{
|
|
|
|
// if needed, initialize the model
|
|
|
|
if(is_string($this->_model)) {
|
2012-05-19 23:59:41 +02:00
|
|
|
$this->_model = forward_static_call(
|
|
|
|
array($this->_model, 'getInstance'),
|
|
|
|
$this->_conf['model_options']
|
|
|
|
);
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
return $this->_model;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-11-01 01:15:14 +01:00
|
|
|
* Store new paste or comment
|
2012-04-29 19:15:06 +02:00
|
|
|
*
|
|
|
|
* POST contains:
|
|
|
|
* data (mandatory) = json encoded SJCL encrypted text (containing keys: iv,salt,ct)
|
|
|
|
*
|
|
|
|
* All optional data will go to meta information:
|
2012-05-19 23:59:41 +02:00
|
|
|
* expire (optional) = expiration delay (never,5min,10min,1hour,1day,1week,1month,1year,burn) (default:never)
|
2012-04-29 19:15:06 +02:00
|
|
|
* opendiscusssion (optional) = is the discussion allowed on this paste ? (0/1) (default:0)
|
|
|
|
* nickname (optional) = in discussion, encoded SJCL encrypted text nickname of author of comment (containing keys: iv,salt,ct)
|
|
|
|
* parentid (optional) = in discussion, which comment this comment replies to.
|
|
|
|
* pasteid (optional) = in discussion, which paste this comment belongs to.
|
|
|
|
*
|
|
|
|
* @access private
|
2013-11-01 01:15:14 +01:00
|
|
|
* @param string $data
|
2012-04-29 19:15:06 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
2013-11-01 01:15:14 +01:00
|
|
|
private function _create($data)
|
2012-04-29 19:15:06 +02:00
|
|
|
{
|
|
|
|
header('Content-type: application/json');
|
|
|
|
$error = false;
|
|
|
|
|
2012-05-19 23:59:41 +02:00
|
|
|
// Make sure last paste from the IP address was more than X seconds ago.
|
|
|
|
trafficlimiter::setLimit($this->_conf['traffic']['limit']);
|
|
|
|
trafficlimiter::setPath($this->_conf['traffic']['dir']);
|
2012-04-29 19:15:06 +02:00
|
|
|
if (
|
2012-04-30 22:58:08 +02:00
|
|
|
!trafficlimiter::canPass($_SERVER['REMOTE_ADDR'])
|
2012-05-19 23:59:41 +02:00
|
|
|
) $this->_return_message(
|
|
|
|
1,
|
|
|
|
'Please wait ' .
|
|
|
|
$this->_conf['traffic']['limit'] .
|
|
|
|
' seconds between each post.'
|
|
|
|
);
|
2012-04-29 19:15:06 +02:00
|
|
|
|
|
|
|
// Make sure content is not too big.
|
|
|
|
if (
|
2012-05-19 23:59:41 +02:00
|
|
|
strlen($data) > $this->_conf['main']['sizelimit']
|
|
|
|
) $this->_return_message(
|
|
|
|
1,
|
|
|
|
'Paste is limited to ' .
|
|
|
|
$this->_conf['main']['sizelimit'] .
|
|
|
|
' ' .
|
|
|
|
filter::size_humanreadable($this->_conf['main']['sizelimit']) .
|
|
|
|
' of encrypted data.'
|
|
|
|
);
|
2012-04-29 19:15:06 +02:00
|
|
|
|
|
|
|
// Make sure format is correct.
|
|
|
|
if (!sjcl::isValid($data)) $this->_return_message(1, 'Invalid data.');
|
|
|
|
|
|
|
|
// Read additional meta-information.
|
|
|
|
$meta=array();
|
|
|
|
|
|
|
|
// Read expiration date
|
|
|
|
if (!empty($_POST['expire']))
|
|
|
|
{
|
2013-02-24 14:33:51 +01:00
|
|
|
if (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
|
|
|
|
$expire = $this->_conf['expire_options'][$_POST['expire']];
|
2013-10-30 23:54:42 +01:00
|
|
|
} else {
|
|
|
|
$expire = $this->_conf['expire_options'][$this->_conf['expire']['default']];
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
2013-10-30 23:54:42 +01:00
|
|
|
if ($expire > 0) $meta['expire_date'] = time() + $expire;
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
2013-02-24 14:33:51 +01:00
|
|
|
|
|
|
|
// Destroy the paste when it is read.
|
|
|
|
if (!empty($_POST['burnafterreading']))
|
|
|
|
{
|
|
|
|
$burnafterreading = $_POST['burnafterreading'];
|
|
|
|
if ($burnafterreading != '0')
|
|
|
|
{
|
|
|
|
if ($burnafterreading != '1') $error = true;
|
|
|
|
$meta['burnafterreading'] = true;
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 19:15:06 +02:00
|
|
|
|
|
|
|
// Read open discussion flag.
|
2012-05-19 23:59:41 +02:00
|
|
|
if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion']))
|
2012-04-29 19:15:06 +02:00
|
|
|
{
|
|
|
|
$opendiscussion = $_POST['opendiscussion'];
|
|
|
|
if ($opendiscussion != 0)
|
|
|
|
{
|
|
|
|
if ($opendiscussion != 1) $error = true;
|
|
|
|
$meta['opendiscussion'] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// You can't have an open discussion on a "Burn after reading" paste:
|
|
|
|
if (isset($meta['burnafterreading'])) unset($meta['opendiscussion']);
|
|
|
|
|
|
|
|
// Optional nickname for comments
|
|
|
|
if (!empty($_POST['nickname']))
|
|
|
|
{
|
|
|
|
// Generation of the anonymous avatar (Vizhash):
|
|
|
|
// If a nickname is provided, we generate a Vizhash.
|
|
|
|
// (We assume that if the user did not enter a nickname, he/she wants
|
|
|
|
// to be anonymous and we will not generate the vizhash.)
|
|
|
|
$nick = $_POST['nickname'];
|
|
|
|
if (!sjcl::isValid($nick))
|
|
|
|
{
|
|
|
|
$error = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$meta['nickname'] = $nick;
|
|
|
|
$vz = new vizhash16x16();
|
|
|
|
$pngdata = $vz->generate($_SERVER['REMOTE_ADDR']);
|
|
|
|
if ($pngdata != '')
|
|
|
|
{
|
|
|
|
$meta['vizhash'] = 'data:image/png;base64,' . base64_encode($pngdata);
|
|
|
|
}
|
|
|
|
// Once the avatar is generated, we do not keep the IP address, nor its hash.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($error) $this->_return_message(1, 'Invalid data.');
|
|
|
|
|
|
|
|
// Add post date to meta.
|
|
|
|
$meta['postdate'] = time();
|
|
|
|
|
|
|
|
// We just want a small hash to avoid collisions:
|
|
|
|
// Half-MD5 (64 bits) will do the trick
|
|
|
|
$dataid = substr(hash('md5', $data), 0, 16);
|
|
|
|
|
|
|
|
$storage = array('data' => $data);
|
|
|
|
|
|
|
|
// Add meta-information only if necessary.
|
|
|
|
if (count($meta)) $storage['meta'] = $meta;
|
|
|
|
|
|
|
|
// The user posts a comment.
|
|
|
|
if (
|
|
|
|
!empty($_POST['parentid']) &&
|
|
|
|
!empty($_POST['pasteid'])
|
|
|
|
)
|
|
|
|
{
|
|
|
|
$pasteid = $_POST['pasteid'];
|
|
|
|
$parentid = $_POST['parentid'];
|
|
|
|
if (
|
2013-11-01 01:15:14 +01:00
|
|
|
!preg_match('/\A[a-f\d]{16}\z/', $pasteid) ||
|
|
|
|
!preg_match('/\A[a-f\d]{16}\z/', $parentid)
|
2012-04-29 19:15:06 +02:00
|
|
|
) $this->_return_message(1, 'Invalid data.');
|
|
|
|
|
|
|
|
// Comments do not expire (it's the paste that expires)
|
|
|
|
unset($storage['expire_date']);
|
|
|
|
unset($storage['opendiscussion']);
|
|
|
|
|
|
|
|
// Make sure paste exists.
|
|
|
|
if (
|
|
|
|
!$this->_model()->exists($pasteid)
|
|
|
|
) $this->_return_message(1, 'Invalid data.');
|
|
|
|
|
|
|
|
// Make sure the discussion is opened in this paste.
|
|
|
|
$paste = $this->_model()->read($pasteid);
|
|
|
|
if (
|
|
|
|
!$paste->meta->opendiscussion
|
|
|
|
) $this->_return_message(1, 'Invalid data.');
|
|
|
|
|
|
|
|
// Check for improbable collision.
|
|
|
|
if (
|
|
|
|
$this->_model()->existsComment($pasteid, $parentid, $dataid)
|
|
|
|
) $this->_return_message(1, 'You are unlucky. Try again.');
|
|
|
|
|
|
|
|
// New comment
|
|
|
|
if (
|
|
|
|
$this->_model()->createComment($pasteid, $parentid, $dataid, $storage) === false
|
|
|
|
) $this->_return_message(1, 'Error saving comment. Sorry.');
|
|
|
|
|
|
|
|
// 0 = no error
|
|
|
|
$this->_return_message(0, $dataid);
|
|
|
|
}
|
|
|
|
// The user posts a standard paste.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Check for improbable collision.
|
|
|
|
if (
|
|
|
|
$this->_model()->exists($dataid)
|
|
|
|
) $this->_return_message(1, 'You are unlucky. Try again.');
|
|
|
|
|
|
|
|
// New paste
|
|
|
|
if (
|
|
|
|
$this->_model()->create($dataid, $storage) === false
|
|
|
|
) $this->_return_message(1, 'Error saving paste. Sorry.');
|
|
|
|
|
2013-11-01 01:15:14 +01:00
|
|
|
// Generate the "delete" token.
|
|
|
|
// The token is the hmac of the pasteid signed with the server salt.
|
|
|
|
// The paste can be delete by calling http://myserver.com/zerobin/?pasteid=<pasteid>&deletetoken=<deletetoken>
|
|
|
|
$deletetoken = hash_hmac('sha1', $dataid , serversalt::get());
|
|
|
|
|
2012-04-29 19:15:06 +02:00
|
|
|
// 0 = no error
|
2013-11-01 01:15:14 +01:00
|
|
|
$this->_return_message(0, $dataid, array('deletetoken' => $deletetoken));
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->_return_message(1, 'Server error.');
|
|
|
|
}
|
|
|
|
|
2013-02-24 14:33:51 +01:00
|
|
|
/**
|
|
|
|
* Delete an existing paste
|
|
|
|
*
|
|
|
|
* @access private
|
2013-11-01 01:15:14 +01:00
|
|
|
* @param string $dataid
|
|
|
|
* @param string $deletetoken
|
2013-02-24 14:33:51 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _delete($dataid, $deletetoken)
|
|
|
|
{
|
2013-11-01 01:15:14 +01:00
|
|
|
// Is this a valid paste identifier?
|
|
|
|
if (preg_match('\A[a-f\d]{16}\z', $dataid))
|
|
|
|
{
|
|
|
|
// Check that paste exists.
|
|
|
|
if (!$this->_model()->exists($dataid))
|
|
|
|
{
|
|
|
|
$this->_error = 'Paste does not exist, has expired or has been deleted.';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure token is valid.
|
|
|
|
if ($deletetoken != hash_hmac('sha1', $dataid , serversalt::get()))
|
|
|
|
{
|
|
|
|
$this->_error = 'Wrong deletion token. Paste was not deleted.';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paste exists and deletion token is valid: Delete the paste.
|
|
|
|
$this->_model()->delete($dataid);
|
|
|
|
$this->_status = 'Paste was properly deleted.';
|
|
|
|
}
|
|
|
|
|
2012-04-29 19:15:06 +02:00
|
|
|
/**
|
2013-11-01 01:15:14 +01:00
|
|
|
* Read an existing paste or comment
|
2012-04-29 19:15:06 +02:00
|
|
|
*
|
|
|
|
* @access private
|
2013-11-01 01:15:14 +01:00
|
|
|
* @param string $dataid
|
2012-04-29 19:15:06 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
2013-11-01 01:15:14 +01:00
|
|
|
private function _read($dataid)
|
2012-04-29 19:15:06 +02:00
|
|
|
{
|
|
|
|
// Is this a valid paste identifier?
|
2015-08-15 21:39:08 +02:00
|
|
|
if (preg_match('#\A[a-f\d]{16}\z#', $dataid))
|
2012-04-29 19:15:06 +02:00
|
|
|
{
|
|
|
|
// Check that paste exists.
|
|
|
|
if ($this->_model()->exists($dataid))
|
|
|
|
{
|
|
|
|
// Get the paste itself.
|
|
|
|
$paste = $this->_model()->read($dataid);
|
|
|
|
|
|
|
|
// See if paste has expired.
|
|
|
|
if (
|
|
|
|
isset($paste->meta->expire_date) &&
|
|
|
|
$paste->meta->expire_date < time()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Delete the paste
|
|
|
|
$this->_model()->delete($dataid);
|
2013-11-01 01:15:14 +01:00
|
|
|
$this->_error = 'Paste does not exist, has expired or has been deleted.';
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
// If no error, return the paste.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We kindly provide the remaining time before expiration (in seconds)
|
|
|
|
if (
|
|
|
|
property_exists($paste->meta, 'expire_date')
|
|
|
|
) $paste->meta->remaining_time = $paste->meta->expire_date - time();
|
|
|
|
|
|
|
|
// The paste itself is the first in the list of encrypted messages.
|
|
|
|
$messages = array($paste);
|
|
|
|
|
|
|
|
// If it's a discussion, get all comments.
|
|
|
|
if (
|
|
|
|
property_exists($paste->meta, 'opendiscussion') &&
|
|
|
|
$paste->meta->opendiscussion
|
|
|
|
)
|
|
|
|
{
|
|
|
|
$messages = array_merge(
|
|
|
|
$messages,
|
|
|
|
$this->_model()->readComments($dataid)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->_data = json_encode($messages);
|
|
|
|
|
|
|
|
// If the paste was meant to be read only once, delete it.
|
|
|
|
if (
|
|
|
|
property_exists($paste->meta, 'burnafterreading') &&
|
|
|
|
$paste->meta->burnafterreading
|
|
|
|
) $this->_model()->delete($dataid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->_error = 'Paste does not exist or has expired.';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display ZeroBin frontend.
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function _view()
|
|
|
|
{
|
2012-08-28 23:28:41 +02:00
|
|
|
// set headers to disable caching
|
2013-02-24 14:33:51 +01: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-26 00:49:11 +02:00
|
|
|
|
2013-10-30 23:54:42 +01:00
|
|
|
// label all the expiration options
|
|
|
|
$expire = array();
|
|
|
|
foreach ($this->_conf['expire_options'] as $key => $value) {
|
|
|
|
$expire[$key] = array_key_exists($key, $this->_conf['expire_labels']) ?
|
|
|
|
$this->_conf['expire_labels'][$key] :
|
|
|
|
$key;
|
|
|
|
}
|
|
|
|
|
2015-08-15 21:39:08 +02:00
|
|
|
RainTPL::$path_replace = false;
|
2012-04-29 19:15:06 +02:00
|
|
|
$page = new RainTPL;
|
2013-10-30 23:54:42 +01:00
|
|
|
// we escape it here because ENT_NOQUOTES can't be used in RainTPL templates
|
2012-04-29 19:15:06 +02:00
|
|
|
$page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
|
2013-11-01 01:15:14 +01:00
|
|
|
$page->assign('ERROR', $this->_error);
|
|
|
|
$page->assign('STATUS', $this->_status);
|
2012-04-29 19:15:06 +02:00
|
|
|
$page->assign('VERSION', self::VERSION);
|
2013-10-30 23:54:42 +01:00
|
|
|
$page->assign('BURNAFTERREADINGSELECTED', $this->_conf['main']['burnafterreadingselected']);
|
|
|
|
$page->assign('OPENDISCUSSION', $this->_conf['main']['opendiscussion']);
|
|
|
|
$page->assign('SYNTAXHIGHLIGHTING', $this->_conf['main']['syntaxhighlighting']);
|
|
|
|
$page->assign('EXPIRE', $expire);
|
|
|
|
$page->assign('EXPIREDEFAULT', $this->_conf['expire']['default']);
|
2013-10-31 22:24:40 +01:00
|
|
|
$page->draw($this->_conf['main']['template']);
|
2012-04-29 19:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* return JSON encoded message and exit
|
|
|
|
*
|
|
|
|
* @access private
|
|
|
|
* @param bool $status
|
|
|
|
* @param string $message
|
2013-11-01 01:15:14 +01:00
|
|
|
* @param array $other
|
2012-04-29 19:15:06 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
2013-11-01 01:15:14 +01:00
|
|
|
private function _return_message($status, $message, $other = array())
|
2012-04-29 19:15:06 +02:00
|
|
|
{
|
|
|
|
$result = array('status' => $status);
|
|
|
|
if ($status)
|
|
|
|
{
|
|
|
|
$result['message'] = $message;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result['id'] = $message;
|
|
|
|
}
|
2013-11-01 01:15:14 +01:00
|
|
|
$result += $other;
|
2012-04-29 19:15:06 +02:00
|
|
|
exit(json_encode($result));
|
|
|
|
}
|
|
|
|
}
|