2012-04-29 13:15:06 -04:00
< ? php
/**
2016-07-11 05:58:15 -04:00
* PrivateBin
2012-04-29 13:15:06 -04:00
*
* a zero - knowledge paste bin
*
2016-07-11 05:58:15 -04:00
* @ link https :// github . com / PrivateBin / PrivateBin
2012-04-29 13:15:06 -04:00
* @ copyright 2012 Sébastien SAUVAGE ( sebsauvage . net )
2016-07-19 07:56:52 -04:00
* @ license https :// www . opensource . org / licenses / zlib - license . php The zlib / libpng License
2015-11-09 15:39:42 -05:00
* @ version 0.22
2012-04-29 13:15:06 -04:00
*/
/**
2016-07-11 05:58:15 -04:00
* privatebin
2012-04-29 13:15:06 -04:00
*
* Controller , puts it all together .
*/
2016-07-11 05:58:15 -04:00
class privatebin
2012-04-29 13:15:06 -04:00
{
2015-08-16 09:55:31 -04:00
/**
* version
*
* @ const string
2012-04-29 13:15:06 -04:00
*/
2015-11-01 11:02:20 -05:00
const VERSION = '0.22' ;
2012-04-29 13:15:06 -04:00
2015-08-31 16:10:41 -04: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 13:15:06 -04:00
/**
2015-09-22 17:21:31 -04:00
* configuration
2015-08-16 09:55:31 -04:00
*
2012-04-29 13:15:06 -04:00
* @ access private
2015-09-22 17:21:31 -04:00
* @ var configuration
2012-04-29 13:15:06 -04:00
*/
2015-09-22 17:21:31 -04:00
private $_conf ;
2012-04-29 13:15:06 -04:00
/**
2015-08-16 09:55:31 -04:00
* data
*
2012-04-29 13:15:06 -04:00
* @ access private
* @ var string
*/
private $_data = '' ;
2015-10-18 11:56:45 -04:00
/**
* does the paste expire
*
* @ access private
* @ var bool
*/
private $_doesExpire = false ;
2012-04-29 13:15:06 -04:00
/**
2015-08-16 09:55:31 -04:00
* error message
*
2012-04-29 13:15:06 -04:00
* @ access private
* @ var string
*/
private $_error = '' ;
2013-10-31 20:15:14 -04:00
/**
2015-08-16 09:55:31 -04:00
* status message
*
2013-10-31 20:15:14 -04:00
* @ access private
* @ var string
*/
private $_status = '' ;
2015-09-01 16:33:07 -04:00
/**
* JSON message
*
* @ access private
* @ var string
*/
private $_json = '' ;
2012-04-29 13:15:06 -04:00
/**
2015-09-26 21:03:55 -04:00
* Factory of instance models
2015-08-16 09:55:31 -04:00
*
2012-04-29 13:15:06 -04:00
* @ access private
2015-09-26 21:03:55 -04:00
* @ var model
2012-04-29 13:15:06 -04:00
*/
private $_model ;
2015-09-27 14:34:39 -04:00
/**
* request
*
* @ access private
* @ var request
*/
private $_request ;
2015-10-18 08:37:58 -04:00
/**
* URL base
*
* @ access private
* @ var string
*/
private $_urlbase ;
2012-04-29 13:15:06 -04:00
/**
* constructor
*
2016-07-11 05:58:15 -04:00
* initializes and runs PrivateBin
2012-04-29 13:15:06 -04:00
*
* @ access public
2015-08-16 09:55:31 -04:00
* @ return void
2012-04-29 13:15:06 -04:00
*/
public function __construct ()
{
if ( version_compare ( PHP_VERSION , '5.2.6' ) < 0 )
2015-09-01 16:33:07 -04:00
{
2016-07-11 05:58:15 -04:00
throw new Exception ( i18n :: _ ( 'PrivateBin requires php 5.2.6 or above to work. Sorry.' ), 1 );
2015-09-01 16:33:07 -04:00
}
2012-04-29 13:15:06 -04:00
2013-10-31 20:15:14 -04:00
// load config from ini file
2012-04-29 13:15:06 -04:00
$this -> _init ();
2015-09-27 14:34:39 -04:00
switch ( $this -> _request -> getOperation ())
2012-04-29 13:15:06 -04:00
{
2015-09-27 14:34:39 -04: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 ;
2015-10-18 08:37:58 -04:00
case 'jsonld' :
$this -> _jsonld ( $this -> _request -> getParam ( 'jsonld' ));
return ;
2012-04-29 13:15:06 -04:00
}
2015-09-01 16:33:07 -04:00
// output JSON or HTML
2015-09-27 14:34:39 -04:00
if ( $this -> _request -> isJsonApiCall ())
2015-09-01 16:33:07 -04:00
{
2016-04-08 17:29:44 -04:00
header ( 'Content-type: ' . request :: MIME_JSON );
2015-10-18 08:37:58 -04:00
header ( 'Access-Control-Allow-Origin: *' );
header ( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE' );
header ( 'Access-Control-Allow-Headers: X-Requested-With, Content-Type' );
2015-09-01 16:33:07 -04:00
echo $this -> _json ;
}
else
{
$this -> _view ();
}
2012-04-29 13:15:06 -04:00
}
/**
2016-07-11 05:58:15 -04:00
* initialize privatebin
2012-04-29 13:15:06 -04:00
*
* @ access private
* @ return void
*/
private function _init ()
{
2012-04-30 07:58:29 -04:00
foreach ( array ( 'cfg' , 'lib' ) as $dir )
{
2015-08-28 19:26:48 -04:00
if ( ! is_file ( PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess' )) file_put_contents (
PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess' ,
2012-04-30 07:58:29 -04:00
'Allow from none' . PHP_EOL .
2015-08-16 06:27:06 -04:00
'Deny from all' . PHP_EOL ,
LOCK_EX
2012-04-30 07:58:29 -04:00
);
}
2015-09-22 17:21:31 -04:00
$this -> _conf = new configuration ;
2015-09-26 21:03:55 -04:00
$this -> _model = new model ( $this -> _conf );
2015-09-27 14:34:39 -04:00
$this -> _request = new request ;
2016-07-18 09:21:32 -04:00
$this -> _urlbase = array_key_exists ( 'REQUEST_URI' , $_SERVER ) ?
htmlspecialchars ( $_SERVER [ 'REQUEST_URI' ]) : '/' ;
2015-10-18 14:38:07 -04:00
// set default language
$lang = $this -> _conf -> getKey ( 'languagedefault' );
i18n :: setLanguageFallback ( $lang );
// force default language, if language selection is disabled and a default is set
if ( ! $this -> _conf -> getKey ( 'languageselection' ) && strlen ( $lang ) == 2 )
{
$_COOKIE [ 'lang' ] = $lang ;
setcookie ( 'lang' , $lang );
}
2012-04-29 13:15:06 -04:00
}
/**
2013-10-31 20:15:14 -04:00
* Store new paste or comment
2012-04-29 13:15:06 -04:00
*
2015-09-16 16:51:48 -04: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 13:15:06 -04:00
*
* All optional data will go to meta information :
2012-05-19 17:59:41 -04:00
* expire ( optional ) = expiration delay ( never , 5 min , 10 min , 1 hour , 1 day , 1 week , 1 month , 1 year , burn ) ( default : never )
2015-09-16 16:51:48 -04: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 13:15:06 -04:00
* opendiscusssion ( optional ) = is the discussion allowed on this paste ? ( 0 / 1 ) ( default : 0 )
2015-09-21 16:32:52 -04:00
* attachmentname = json encoded SJCL encrypted text ( containing keys : iv , v , iter , ks , ts , mode , adata , cipher , salt , ct )
2015-09-04 20:24:56 -04: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 13:15:06 -04: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 17:58:56 -04:00
* @ return string
2012-04-29 13:15:06 -04:00
*/
2015-09-16 16:51:48 -04:00
private function _create ()
2012-04-29 13:15:06 -04:00
{
2015-09-26 21:03:55 -04:00
// Ensure last paste from visitors IP address was more than configured amount of seconds ago.
2015-09-26 11:57:46 -04:00
trafficlimiter :: setConfiguration ( $this -> _conf );
if ( ! trafficlimiter :: canPass ()) return $this -> _return_message (
2015-09-26 21:03:55 -04:00
1 , i18n :: _ (
2015-09-19 08:22:29 -04:00
'Please wait %d seconds between each post.' ,
2015-09-22 17:21:31 -04:00
$this -> _conf -> getKey ( 'limit' , 'traffic' )
2015-09-19 08:22:29 -04:00
)
);
2012-04-29 13:15:06 -04:00
2015-09-27 14:34:39 -04:00
$data = $this -> _request -> getParam ( 'data' );
$attachment = $this -> _request -> getParam ( 'attachment' );
$attachmentname = $this -> _request -> getParam ( 'attachmentname' );
2015-09-26 21:03:55 -04:00
// Ensure content is not too big.
2015-09-22 17:21:31 -04:00
$sizelimit = $this -> _conf -> getKey ( 'sizelimit' );
2015-09-19 08:22:29 -04: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 13:15:06 -04:00
2016-07-19 09:26:41 -04:00
// Ensure attachment did not get lost due to webserver limits or Suhosin
if ( strlen ( $attachmentname ) > 0 && strlen ( $attachment ) == 0 )
{
return $this -> _return_message ( 1 , 'Attachment missing in data received by server. Please check your webserver or suhosin configuration for maximum POST parameter limitations.' );
}
2015-09-26 21:03:55 -04:00
// The user posts a comment.
2015-09-27 14:34:39 -04:00
$pasteid = $this -> _request -> getParam ( 'pasteid' );
$parentid = $this -> _request -> getParam ( 'parentid' );
if ( ! empty ( $pasteid ) && ! empty ( $parentid ))
2012-04-29 13:15:06 -04:00
{
2015-09-27 14:34:39 -04:00
$paste = $this -> _model -> getPaste ( $pasteid );
2015-09-26 21:03:55 -04:00
if ( $paste -> exists ()) {
try {
2015-09-27 14:34:39 -04:00
$comment = $paste -> getComment ( $parentid );
2015-09-26 21:03:55 -04:00
2015-09-27 14:34:39 -04:00
$nickname = $this -> _request -> getParam ( 'nickname' );
if ( ! empty ( $nickname )) $comment -> setNickname ( $nickname );
2015-09-26 21:03:55 -04: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 13:15:06 -04:00
}
2015-09-26 21:03:55 -04:00
else
2015-09-12 11:33:16 -04:00
{
2015-09-26 21:03:55 -04:00
$this -> _return_message ( 1 , 'Invalid data.' );
2015-09-12 11:33:16 -04:00
}
}
2015-09-26 21:03:55 -04:00
// The user posts a standard paste.
else
2012-04-29 13:15:06 -04:00
{
2016-07-15 11:02:59 -04:00
$this -> _model -> purge ();
2015-09-26 21:03:55 -04:00
$paste = $this -> _model -> getPaste ();
try {
2015-10-03 11:54:18 -04:00
$paste -> setData ( $data );
2015-09-27 14:34:39 -04:00
if ( ! empty ( $attachment ))
2012-04-29 13:15:06 -04:00
{
2015-09-26 21:03:55 -04:00
$paste -> setAttachment ( $attachment );
2015-09-27 14:34:39 -04:00
if ( ! empty ( $attachmentname ))
2015-09-26 21:03:55 -04:00
$paste -> setAttachmentName ( $attachmentname );
2012-04-29 13:15:06 -04:00
}
2015-09-27 14:34:39 -04:00
$expire = $this -> _request -> getParam ( 'expire' );
if ( ! empty ( $expire )) $paste -> setExpiration ( $expire );
2012-04-29 13:15:06 -04:00
2015-09-27 14:34:39 -04:00
$burnafterreading = $this -> _request -> getParam ( 'burnafterreading' );
if ( ! empty ( $burnafterreading )) $paste -> setBurnafterreading ( $burnafterreading );
2012-04-29 13:15:06 -04:00
2015-09-27 14:34:39 -04:00
$opendiscussion = $this -> _request -> getParam ( 'opendiscussion' );
if ( ! empty ( $opendiscussion )) $paste -> setOpendiscussion ( $opendiscussion );
2012-04-29 13:15:06 -04:00
2015-09-27 14:34:39 -04:00
$formatter = $this -> _request -> getParam ( 'formatter' );
if ( ! empty ( $formatter )) $paste -> setFormatter ( $formatter );
2012-04-29 13:15:06 -04:00
2015-09-26 21:03:55 -04: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 13:15:06 -04:00
}
}
2013-02-24 08:33:51 -05:00
/**
* Delete an existing paste
*
* @ access private
2013-10-31 20:15:14 -04:00
* @ param string $dataid
* @ param string $deletetoken
2015-09-01 16:33:07 -04:00
* @ return void
2013-02-24 08:33:51 -05:00
*/
private function _delete ( $dataid , $deletetoken )
{
2015-09-26 21:03:55 -04:00
try {
$paste = $this -> _model -> getPaste ( $dataid );
if ( $paste -> exists ())
2015-08-31 16:10:41 -04:00
{
2015-09-26 21:03:55 -04: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.
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 16:33:07 -04:00
}
else
{
2015-09-26 21:03:55 -04:00
$this -> _error = self :: GENERIC_ERROR ;
2015-08-31 16:10:41 -04:00
}
2015-09-26 21:03:55 -04:00
} catch ( Exception $e ) {
$this -> _error = $e -> getMessage ();
2013-10-31 20:15:14 -04:00
}
}
2012-04-29 13:15:06 -04:00
/**
2013-10-31 20:15:14 -04:00
* Read an existing paste or comment
2012-04-29 13:15:06 -04:00
*
* @ access private
2013-10-31 20:15:14 -04:00
* @ param string $dataid
2012-04-29 13:15:06 -04:00
* @ return void
*/
2013-10-31 20:15:14 -04:00
private function _read ( $dataid )
2012-04-29 13:15:06 -04:00
{
2015-09-26 21:03:55 -04:00
try {
$paste = $this -> _model -> getPaste ( $dataid );
if ( $paste -> exists ())
2014-02-06 16:52:17 -05:00
{
2015-10-18 11:56:45 -04:00
$data = $paste -> get ();
$this -> _doesExpire = property_exists ( $data , 'meta' ) && property_exists ( $data -> meta , 'expire_date' );
2016-07-06 05:37:13 -04:00
if ( property_exists ( $data -> meta , 'salt' )) unset ( $data -> meta -> salt );
2015-10-18 11:56:45 -04:00
$this -> _data = json_encode ( $data );
2014-02-06 16:52:17 -05:00
}
else
2012-04-29 13:15:06 -04:00
{
2015-09-26 21:03:55 -04:00
$this -> _error = self :: GENERIC_ERROR ;
2012-04-29 13:15:06 -04:00
}
2015-09-26 21:03:55 -04:00
} catch ( Exception $e ) {
$this -> _error = $e -> getMessage ();
2012-04-29 13:15:06 -04:00
}
2015-09-26 21:03:55 -04:00
2015-09-27 14:34:39 -04:00
if ( $this -> _request -> isJsonApiCall ())
2015-09-01 16:33:07 -04:00
{
if ( strlen ( $this -> _error ))
{
$this -> _return_message ( 1 , $this -> _error );
}
else
{
2015-10-18 05:08:28 -04:00
$this -> _return_message ( 0 , $dataid , json_decode ( $this -> _data , true ));
2015-09-01 16:33:07 -04:00
}
}
2012-04-29 13:15:06 -04:00
}
/**
2016-07-11 05:58:15 -04:00
* Display PrivateBin frontend .
2012-04-29 13:15:06 -04:00
*
* @ access private
* @ return void
*/
private function _view ()
{
2012-08-28 17:28:41 -04:00
// set headers to disable caching
2013-02-24 08:33:51 -05: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 18:49:11 -04:00
2013-10-30 18:54:42 -04:00
// label all the expiration options
$expire = array ();
2015-09-22 17:21:31 -04:00
foreach ( $this -> _conf -> getSection ( 'expire_options' ) as $time => $seconds )
2015-09-12 11:33:16 -04:00
{
2015-09-06 13:21:17 -04:00
$expire [ $time ] = ( $seconds == 0 ) ? i18n :: _ ( ucfirst ( $time )) : filter :: time_humanreadable ( $time );
2013-10-30 18:54:42 -04:00
}
2015-09-12 11:33:16 -04:00
// translate all the formatter options
2015-09-22 17:21:31 -04:00
$formatters = array_map ( array ( 'i18n' , 'translate' ), $this -> _conf -> getSection ( 'formatter_options' ));
2015-09-12 11:33:16 -04:00
2015-09-19 05:21:13 -04:00
// set language cookie if that functionality was enabled
$languageselection = '' ;
2015-09-22 17:21:31 -04:00
if ( $this -> _conf -> getKey ( 'languageselection' ))
2015-09-19 05:21:13 -04:00
{
$languageselection = i18n :: getLanguage ();
setcookie ( 'lang' , $languageselection );
}
2016-07-19 08:02:26 -04:00
$page = new view ;
$page -> assign ( 'CIPHERDATA' , $this -> _data );
2015-09-04 20:24:56 -04:00
$page -> assign ( 'ERROR' , i18n :: _ ( $this -> _error ));
$page -> assign ( 'STATUS' , i18n :: _ ( $this -> _status ));
2012-04-29 13:15:06 -04:00
$page -> assign ( 'VERSION' , self :: VERSION );
2015-09-22 17:21:31 -04:00
$page -> assign ( 'DISCUSSION' , $this -> _conf -> getKey ( 'discussion' ));
$page -> assign ( 'OPENDISCUSSION' , $this -> _conf -> getKey ( 'opendiscussion' ));
2015-09-12 11:33:16 -04:00
$page -> assign ( 'MARKDOWN' , array_key_exists ( 'markdown' , $formatters ));
$page -> assign ( 'SYNTAXHIGHLIGHTING' , array_key_exists ( 'syntaxhighlighting' , $formatters ));
2015-09-22 17:21:31 -04:00
$page -> assign ( 'SYNTAXHIGHLIGHTINGTHEME' , $this -> _conf -> getKey ( 'syntaxhighlightingtheme' ));
2015-09-12 11:33:16 -04:00
$page -> assign ( 'FORMATTER' , $formatters );
2015-09-22 17:21:31 -04: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' ));
2016-07-06 05:37:13 -04:00
$page -> assign ( 'BASE64JSVERSION' , $this -> _conf -> getKey ( 'zerobincompatibility' ) ? '1.7' : '2.1.9' );
2015-09-19 05:21:13 -04:00
$page -> assign ( 'LANGUAGESELECTION' , $languageselection );
$page -> assign ( 'LANGUAGES' , i18n :: getLanguageLabels ( i18n :: getAvailableLanguages ()));
2013-10-30 18:54:42 -04:00
$page -> assign ( 'EXPIRE' , $expire );
2015-09-22 17:21:31 -04:00
$page -> assign ( 'EXPIREDEFAULT' , $this -> _conf -> getKey ( 'default' , 'expire' ));
2015-10-18 11:56:45 -04:00
$page -> assign ( 'EXPIRECLONE' , ! $this -> _doesExpire || ( $this -> _doesExpire && $this -> _conf -> getKey ( 'clone' , 'expire' )));
2016-01-31 03:56:06 -05:00
$page -> assign ( 'URLSHORTENER' , $this -> _conf -> getKey ( 'urlshortener' ));
2015-09-22 17:21:31 -04:00
$page -> draw ( $this -> _conf -> getKey ( 'template' ));
2012-04-29 13:15:06 -04:00
}
2015-10-18 14:38:07 -04:00
/**
* outputs requested JSON - LD context
*
* @ access private
* @ param string $type
* @ return void
*/
2015-10-18 08:37:58 -04:00
private function _jsonld ( $type )
{
if (
$type !== 'paste' && $type !== 'comment' &&
$type !== 'pastemeta' && $type !== 'commentmeta'
)
{
$type = '' ;
}
$content = '{}' ;
$file = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $type . '.jsonld' ;
if ( is_readable ( $file ))
{
$content = str_replace (
'?jsonld=' ,
$this -> _urlbase . '?jsonld=' ,
file_get_contents ( $file )
);
}
header ( 'Content-type: application/ld+json' );
header ( 'Access-Control-Allow-Origin: *' );
header ( 'Access-Control-Allow-Methods: GET' );
echo $content ;
}
2012-04-29 13:15:06 -04:00
/**
2015-10-18 14:38:07 -04:00
* prepares JSON encoded status message
2012-04-29 13:15:06 -04:00
*
* @ access private
2016-07-06 08:12:14 -04:00
* @ param int $status
2012-04-29 13:15:06 -04:00
* @ param string $message
2013-10-31 20:15:14 -04:00
* @ param array $other
2015-09-01 16:33:07 -04:00
* @ return void
2012-04-29 13:15:06 -04:00
*/
2013-10-31 20:15:14 -04:00
private function _return_message ( $status , $message , $other = array ())
2012-04-29 13:15:06 -04:00
{
$result = array ( 'status' => $status );
if ( $status )
{
2015-09-04 20:24:56 -04:00
$result [ 'message' ] = i18n :: _ ( $message );
2012-04-29 13:15:06 -04:00
}
else
{
$result [ 'id' ] = $message ;
2015-10-18 08:37:58 -04:00
$result [ 'url' ] = $this -> _urlbase . '?' . $message ;
2012-04-29 13:15:06 -04:00
}
2013-10-31 20:15:14 -04:00
$result += $other ;
2015-09-01 16:33:07 -04:00
$this -> _json = json_encode ( $result );
2012-04-29 13:15:06 -04:00
}
}