mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
incrementing version number, updating docs
This commit is contained in:
parent
a41d0ca4dd
commit
608605cd54
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,12 +1,29 @@
|
||||||
# ZeroBin version history #
|
# ZeroBin version history #
|
||||||
|
|
||||||
|
* **0.21 (2015-09-19)**:
|
||||||
|
* ADDED: Translations for German, French and Polish, language selection menu (optional)
|
||||||
|
* ADDED: File upload and image display support (optional)
|
||||||
|
* ADDED: Markdown format support
|
||||||
|
* ADDED: "bootstrap-compact" template that hides some of the options in a drop down menu to ensure the nav bar fitting on one line on smaller screen sizes
|
||||||
|
* FIXING: Various usability issues with different screen sizes / device types in the "bootstrap" template
|
||||||
|
* CHANGED: Instead of having different options to enable and preselect certain formats there is now a generic `[formatter_options]` section where formats can be added to the displayed format drop down menu. A `defaultformatter` can be set, it defaults to "plaintext". The `syntaxhighlighting` configuration got deprecated.
|
||||||
|
* `zerobin.js` got a major refactoring:
|
||||||
|
* moved from global namespace into anonymous function
|
||||||
|
* events are no longer set via "onclick" attributes in the templates, but bound by from JS side
|
||||||
|
* for simpler maintenance the functions were grouped into objects: zerobin (display logic, event handling), filter (compression,
|
||||||
|
encryption), i18n (translation, counterpart of i18n.php) and helper (stateless utilities)
|
||||||
|
* Wiki pages were added to address common topics:
|
||||||
|
* [Upgrading from ZeroBin 0.19 Alpha](https://github.com/elrido/ZeroBin/wiki/Upgrading-from-ZeroBin-0.19-Alpha)
|
||||||
|
* [ZeroBin Directory of public servers](https://github.com/elrido/ZeroBin/wiki/ZeroBin-Directory)
|
||||||
|
* [Translation](https://github.com/elrido/ZeroBin/wiki/Translation)
|
||||||
|
* [Templates](https://github.com/elrido/ZeroBin/wiki/Templates)
|
||||||
* **0.20 (2015-09-03)**:
|
* **0.20 (2015-09-03)**:
|
||||||
* ADDED: Password protected pastes (optional)
|
* ADDED: Password protected pastes (optional)
|
||||||
* ADDED: configuration options for highlighting, password, discussions, expiration times, rate limiting
|
* ADDED: configuration options for highlighting, password, discussions, expiration times, rate limiting
|
||||||
* ADDED: JSON-only retrieval of paste incl. discussion, used to be able to refresh paste when posting a comment
|
* ADDED: JSON-only retrieval of paste incl. discussion, used to be able to refresh paste when posting a comment
|
||||||
* ADDED: bootstrap CSS based template
|
* ADDED: bootstrap CSS based template
|
||||||
* CHANGE: "Burn after reading" pastes are now deleted only after the paste was successfully decrypted via callback. This prevents accidental deletion by chatbots following URLs and the like. Usage of a password is suggested to ensure only the desired recipient is able to encrypt it.
|
* CHANGED: "Burn after reading" pastes are now deleted only after the paste was successfully decrypted via callback. This prevents accidental deletion by chatbots following URLs and the like. Usage of a password is suggested to ensure only the desired recipient is able to encrypt it.
|
||||||
* CHANGE: the "opendiscussion" option now only controls if the discussion checkbox is preselected. Use "discussion = false" to disable the discussion feature completely (which also removes the checkbox from the template).
|
* CHANGED: the "opendiscussion" option now only controls if the discussion checkbox is preselected. Use "discussion = false" to disable the discussion feature completely (which also removes the checkbox from the template).
|
||||||
* FIXING: Behaviour of several conflicting configuration options. As a general measure unit tests for 9 of the options and all their possible configurations were added via a unit test generator.
|
* FIXING: Behaviour of several conflicting configuration options. As a general measure unit tests for 9 of the options and all their possible configurations were added via a unit test generator.
|
||||||
* updated JS libraries: jquery to 1.11.3, sjcl to 1.0.2, base64.js to 2.1.9, deflate to 0.5, inflate to 0.3 and prettify to latest
|
* updated JS libraries: jquery to 1.11.3, sjcl to 1.0.2, base64.js to 2.1.9, deflate to 0.5, inflate to 0.3 and prettify to latest
|
||||||
* generally improved documentation, both inline phpdoc / JSdoc source code documentation, as well as Wiki pages on installation, configuration, development and JSON-API
|
* generally improved documentation, both inline phpdoc / JSdoc source code documentation, as well as Wiki pages on installation, configuration, development and JSON-API
|
||||||
|
|
|
@ -5,7 +5,7 @@ Sébastien Sauvage - original idea and main developer
|
||||||
Alexey Gladkov - syntax highlighting
|
Alexey Gladkov - syntax highlighting
|
||||||
Greg Knaddison - robots.txt
|
Greg Knaddison - robots.txt
|
||||||
MrKooky - HTML5 markup, CSS cleanup
|
MrKooky - HTML5 markup, CSS cleanup
|
||||||
Simon Rupf - MVC refactoring, configuration support and unit tests
|
Simon Rupf - MVC refactoring, configuration, i18n and unit tests
|
||||||
Hexalyse - Password protection
|
Hexalyse - Password protection
|
||||||
Viktor Stanchev - File upload support
|
Viktor Stanchev - File upload support
|
||||||
|
|
||||||
|
|
114
INSTALL.md
114
INSTALL.md
|
@ -1,20 +1,47 @@
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
For Administrators
|
## Basic installation
|
||||||
------------------
|
|
||||||
|
|
||||||
In the index.php in the main folder you can define a different PATH. This is
|
**TL;DR:** Download the [latest release archive](https://github.com/elrido/ZeroBin/releases/latest)
|
||||||
useful if you want to secure your installation and want to move the
|
and extract it in your web hosts folder were you want to install your ZeroBin instance.
|
||||||
configuration, data files, templates and PHP libraries (directories cfg, data,
|
|
||||||
lib, tpl and tst) outside of your document root. This new location must still
|
|
||||||
be accessible to your webserver / PHP process.
|
|
||||||
|
|
||||||
> ### PATH Example ###
|
### Requirements
|
||||||
|
|
||||||
|
- PHP version 5.2.6 or above
|
||||||
|
- GD extension
|
||||||
|
- mcrypt extension (recommended)
|
||||||
|
- some disk space or (optional) a database supported by PDO
|
||||||
|
- A web browser with javascript support
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
In the file `cfg/conf.ini` you can configure ZeroBin. The config file is divided
|
||||||
|
into multiple sections, which are enclosed in square brackets.
|
||||||
|
|
||||||
|
In the `[main]` section you can enable or disable the discussion feature, set the
|
||||||
|
limit of stored pastes and comments in bytes. The `[traffic]` section lets you
|
||||||
|
set a time limit in seconds. Users may not post more often then this limit to
|
||||||
|
your ZeroBin installation.
|
||||||
|
|
||||||
|
More details can be found in the
|
||||||
|
[configuration documentation](https://github.com/elrido/ZeroBin/wiki/Configuration).
|
||||||
|
|
||||||
|
## Advanced installation
|
||||||
|
|
||||||
|
### Changing the path
|
||||||
|
|
||||||
|
In the index.php you can define a different `PATH`. This is useful to secure your
|
||||||
|
installation. You can move the configuration, data files, templates and PHP
|
||||||
|
libraries (directories cfg, data, lib, tpl, tmp and tst) outside of your document
|
||||||
|
root. This new location must still be accessible to your webserver / PHP process
|
||||||
|
([open_basedir setting](http://php.net/manual/en/ini.core.php#ini.open-basedir)).
|
||||||
|
|
||||||
|
> #### PATH Example
|
||||||
> Your zerobin installation lives in a subfolder called "paste" inside of your
|
> Your zerobin installation lives in a subfolder called "paste" inside of your
|
||||||
> document root. The URL looks like this:
|
> document root. The URL looks like this:
|
||||||
> http://example.com/paste/
|
> http://example.com/paste/
|
||||||
> The ZeroBin folder on your webserver is really:
|
> The full path of ZeroBin on your webserver is:
|
||||||
> /home/example.com/htdocs/paste
|
> /home/example.com/htdocs/paste
|
||||||
>
|
>
|
||||||
> When setting the path like this:
|
> When setting the path like this:
|
||||||
|
@ -22,29 +49,27 @@ be accessible to your webserver / PHP process.
|
||||||
> ZeroBin will look for your includes here:
|
> ZeroBin will look for your includes here:
|
||||||
> /home/example.com/secret/zerobin
|
> /home/example.com/secret/zerobin
|
||||||
|
|
||||||
In the file "cfg/conf.ini" you can configure ZeroBin. The config file is
|
### Using a database instead of flat files
|
||||||
divided into multiple sections, which are enclosed in square brackets. In the
|
|
||||||
"[main]" section you can enable or disable the discussion feature, set the
|
|
||||||
limit of stored pastes and comments in bytes. The "[traffic]" section lets you
|
|
||||||
set a time limit in seconds. Users may not post more often then this limit to
|
|
||||||
your ZeroBin.
|
|
||||||
|
|
||||||
Finally the "[model]" and "[model_options]" sections let you configure your
|
In the configuration file the `[model]` and `[model_options]` sections let you
|
||||||
favourite way of storing the pastes and discussions on your server.
|
configure your favourite way of storing the pastes and discussions on your server.
|
||||||
"zerobin_data" is the default model, which stores everything in files in the
|
|
||||||
data folder. This is the recommended setup for low traffic sites. Under high
|
|
||||||
load, in distributed setups or if you are not allowed to store files locally,
|
|
||||||
you might want to switch to the "zerobin_db" model. This lets you store your
|
|
||||||
data in a database. Basically all databases that are supported by PDO (PHP
|
|
||||||
data objects) may be used. Automatic table creation is provided for pdo_ibm,
|
|
||||||
pdo_informix, pdo_mssql, pdo_mysql, pdo_oci, pdo_pgsql and pdo_sqlite. You may
|
|
||||||
want to provide a table prefix, if you have to share the zerobin database with
|
|
||||||
another application. The table prefix option is called "tbl".
|
|
||||||
|
|
||||||
> ### Note ###
|
`zerobin_data` is the default model, which stores everything in files in the data
|
||||||
> The "zerobin_db" model has only been tested with SQLite and MySQL, although
|
folder. This is the recommended setup for most sites.
|
||||||
> it would not be recommended to use SQLite in a production environment. If you
|
|
||||||
> gain any experience running ZeroBin on other RDBMS, please let us know.
|
Under high load, in distributed setups or if you are not allowed to store files
|
||||||
|
locally, you might want to switch to the `zerobin_db` model. This lets you store
|
||||||
|
your data in a database. Basically all databases that are supported by
|
||||||
|
[PDO](http://php.net/manual/en/book.pdo.php) may be used. Automatic table
|
||||||
|
creation is provided for `pdo_ibm`, `pdo_informix`, `pdo_mssql`, `pdo_mysql`,
|
||||||
|
`pdo_oci`, `pdo_pgsql` and `pdo_sqlite`. You may want to provide a table prefix,
|
||||||
|
if you have to share the zerobin database with another application. The table
|
||||||
|
prefix option is called `tbl`.
|
||||||
|
|
||||||
|
> #### Note
|
||||||
|
> The "zerobin_db" model has only been tested with SQLite and MySQL, although it
|
||||||
|
would not be recommended to use SQLite in a production environment. If you gain
|
||||||
|
any experience running ZeroBin on other RDBMS, please let us know.
|
||||||
|
|
||||||
For reference or if you want to create the table schema for yourself:
|
For reference or if you want to create the table schema for yourself:
|
||||||
|
|
||||||
|
@ -66,32 +91,3 @@ For reference or if you want to create the table schema for yourself:
|
||||||
vizhash TEXT,
|
vizhash TEXT,
|
||||||
postdate INT
|
postdate INT
|
||||||
);
|
);
|
||||||
|
|
||||||
For Developers
|
|
||||||
--------------
|
|
||||||
If you want to create your own data models, you might want to know how the
|
|
||||||
arrays, that you have to store, look like:
|
|
||||||
|
|
||||||
public function create($pasteid, $paste)
|
|
||||||
{
|
|
||||||
$pasteid = substr(hash('md5', $paste['data']), 0, 16);
|
|
||||||
|
|
||||||
$paste['data'] // text
|
|
||||||
$paste['meta']['postdate'] // int UNIX timestamp
|
|
||||||
$paste['meta']['expire_date'] // int UNIX timestamp
|
|
||||||
$paste['meta']['opendiscussion'] // true (if false it is unset)
|
|
||||||
$paste['meta']['burnafterreading'] // true (if false it is unset; if true, then opendiscussion is unset)
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createComment($pasteid, $parentid, $commentid, $comment)
|
|
||||||
{
|
|
||||||
$pasteid // the id of the paste this comment belongs to
|
|
||||||
$parentid // the id of the parent of this comment, may be the paste id itself
|
|
||||||
$commentid = substr(hash('md5', $paste['data']), 0, 16);
|
|
||||||
|
|
||||||
$comment['data'] // text
|
|
||||||
$comment['meta']['nickname'] // text or null (if anonymous)
|
|
||||||
$comment['meta']['vizhash'] // text or null (if anonymous)
|
|
||||||
$comment['meta']['postdate'] // int UNIX timestamp
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
68
README.md
68
README.md
|
@ -1,4 +1,4 @@
|
||||||
# ZeroBin 0.20
|
# ZeroBin 0.21
|
||||||
|
|
||||||
ZeroBin is a minimalist, opensource online pastebin where the server has zero
|
ZeroBin is a minimalist, opensource online pastebin where the server has zero
|
||||||
knowledge of pasted data.
|
knowledge of pasted data.
|
||||||
|
@ -12,16 +12,16 @@ without loosing any data.
|
||||||
|
|
||||||
## What ZeroBin provides
|
## What ZeroBin provides
|
||||||
|
|
||||||
- As a server administrator you don't have to worry if your users post content
|
+ As a server administrator you don't have to worry if your users post content
|
||||||
that is considered illegal in your country. You have no knowledge of any
|
that is considered illegal in your country. You have no knowledge of any
|
||||||
pastes content. If requested or enforced, you can delete any paste from your
|
of the pastes content. If requested or enforced, you can delete any paste from
|
||||||
system.
|
your system.
|
||||||
|
|
||||||
- Pastebin like system to store text documents, code samples, etc.
|
+ Pastebin-like system to store text documents, code samples, etc.
|
||||||
|
|
||||||
- Encryption of data sent to server, even if it does not provide HTTPS.
|
+ Encryption of data sent to server, even if it does not provide HTTPS.
|
||||||
|
|
||||||
- Possibility to set a password which is required to read the paste. It further
|
+ Possibility to set a password which is required to read the paste. It further
|
||||||
protects a paste and prevents people stumbling upon your paste's link
|
protects a paste and prevents people stumbling upon your paste's link
|
||||||
from being able to read it without the password.
|
from being able to read it without the password.
|
||||||
|
|
||||||
|
@ -43,48 +43,38 @@ without loosing any data.
|
||||||
Some features are optional and can be enabled or disabled in the [configuration
|
Some features are optional and can be enabled or disabled in the [configuration
|
||||||
file](https://github.com/elrido/ZeroBin/wiki/Configuration):
|
file](https://github.com/elrido/ZeroBin/wiki/Configuration):
|
||||||
|
|
||||||
- Password protection
|
* Password protection
|
||||||
|
|
||||||
- Discussions
|
* Discussions
|
||||||
|
|
||||||
- Expiration times, including a "forever" and "burn after reading" option
|
* Expiration times, including a "forever" and "burn after reading" option
|
||||||
|
|
||||||
- Syntax highlighting using prettify.js, including 4 prettify themes
|
* Markdown format support for HTML formatted pastes
|
||||||
|
|
||||||
- Templates: By default there is a bootstrap based and a "classic ZeroBin" theme
|
* Syntax highlighting for source code using prettify.js, including 4 prettify themes
|
||||||
|
|
||||||
|
* File upload support, images get displayed (disabled by default, possibility to adjust size limit)
|
||||||
|
|
||||||
|
* Templates: By default there is a bootstrap CSS and a "classic ZeroBin" theme
|
||||||
and it is easy to adapt these to your own websites layout or create your own.
|
and it is easy to adapt these to your own websites layout or create your own.
|
||||||
|
|
||||||
|
* Translation system and automatic browser language detection (if enabled in browser)
|
||||||
|
|
||||||
|
* Language selection (disabled by default, as it uses a session cookie)
|
||||||
|
|
||||||
## Further resources
|
## Further resources
|
||||||
|
|
||||||
- [Installation guide](https://github.com/elrido/ZeroBin/wiki/Installation)
|
* [Installation guide](https://github.com/elrido/ZeroBin/wiki/Installation)
|
||||||
|
|
||||||
- [Configuration guide](https://github.com/elrido/ZeroBin/wiki/Configuration)
|
* [Upgrading from 0.19 Alpha](https://github.com/elrido/ZeroBin/wiki/Upgrading-from-ZeroBin-0.19-Alpha)
|
||||||
|
|
||||||
- [Developer guide](https://github.com/elrido/ZeroBin/wiki/Development)
|
* [Configuration guide](https://github.com/elrido/ZeroBin/wiki/Configuration)
|
||||||
|
|
||||||
|
* [Templates](https://github.com/elrido/ZeroBin/wiki/Templates)
|
||||||
|
|
||||||
|
* [Translation guide](https://github.com/elrido/ZeroBin/wiki/Translation)
|
||||||
|
|
||||||
|
* [Developer guide](https://github.com/elrido/ZeroBin/wiki/Development)
|
||||||
|
|
||||||
Run into any issues? Have ideas for further developments? Please
|
Run into any issues? Have ideas for further developments? Please
|
||||||
[report](https://github.com/elrido/ZeroBin/issues) them!
|
[report](https://github.com/elrido/ZeroBin/issues) them!
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2012 Sébastien SAUVAGE (sebsauvage.net)
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
In no event will the authors be held liable for any damages arising from
|
|
||||||
the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must
|
|
||||||
not claim that you wrote the original software. If you use this
|
|
||||||
software in a product, an acknowledgment in the product documentation
|
|
||||||
would be appreciated but is not required.
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and must
|
|
||||||
not be misrepresented as being the original software.
|
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
; @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
; @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
; @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
; @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
; @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
; @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
; @version 0.20
|
; @version 0.21
|
||||||
|
|
||||||
[main]
|
[main]
|
||||||
; enable or disable the discussion feature, defaults to true
|
; enable or disable the discussion feature, defaults to true
|
||||||
|
@ -109,4 +109,3 @@ dir = PATH "data"
|
||||||
;usr = null
|
;usr = null
|
||||||
;pwd = null
|
;pwd = null
|
||||||
;opt[12] = true ; PDO::ATTR_PERSISTENT
|
;opt[12] = true ; PDO::ATTR_PERSISTENT
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* ZeroBin 0.20 - http://sebsauvage.net/wiki/doku.php?id=php:zerobin */
|
/* ZeroBin 0.21 - http://sebsauvage.net/wiki/doku.php?id=php:zerobin */
|
||||||
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* ZeroBin 0.20 - http://sebsauvage.net/wiki/doku.php?id=php:zerobin */
|
/* ZeroBin 0.21 - http://sebsauvage.net/wiki/doku.php?id=php:zerobin */
|
||||||
|
|
||||||
|
|
||||||
/* CSS Reset from YUI 3.4.1 (build 4118) - Copyright 2011 Yahoo! Inc. All rights reserved.
|
/* CSS Reset from YUI 3.4.1 (build 4118) - Copyright 2011 Yahoo! Inc. All rights reserved.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// change this, if your php files and data is outside of your webservers document root
|
// change this, if your php files and data is outside of your webservers document root
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -1162,7 +1162,16 @@ class RainTpl_SyntaxException extends RainTpl_Exception{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// shorthand translate function for use in templates
|
/**
|
||||||
|
* shorthand translate function for use in templates
|
||||||
|
*
|
||||||
|
* alias for i18n::translate()
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $messageId
|
||||||
|
* @param mixed $args one or multiple parameters injected into placeholders
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function t() {
|
function t() {
|
||||||
return call_user_func_array(array('i18n', 'translate'), func_get_args());
|
return call_user_func_array(array('i18n', 'translate'), func_get_args());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spl_autoload_register('auto::loader');
|
spl_autoload_register('auto::loader');
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:vizhash_gd
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:vizhash_gd
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.0.4 beta ZeroBin 0.20
|
* @version 0.0.4 beta ZeroBin 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@ class zerobin
|
||||||
*
|
*
|
||||||
* @const string
|
* @const string
|
||||||
*/
|
*/
|
||||||
const VERSION = '0.20';
|
const VERSION = '0.21';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show the same error message if the paste expired or does not exist
|
* show the same error message if the paste expired or does not exist
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
* @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
|
||||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||||
* @version 0.20
|
* @version 0.21
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,6 +41,8 @@ class RainTPLTest extends PHPUnit_Framework_TestCase
|
||||||
$page->assign('FILEUPLOAD', false);
|
$page->assign('FILEUPLOAD', false);
|
||||||
$page->assign('BASE64JSVERSION', '2.1.9');
|
$page->assign('BASE64JSVERSION', '2.1.9');
|
||||||
$page->assign('NOTICE', 'example');
|
$page->assign('NOTICE', 'example');
|
||||||
|
$page->assign('LANGUAGESELECTION', '');
|
||||||
|
$page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
|
||||||
$page->assign('EXPIRE', self::$expire);
|
$page->assign('EXPIRE', self::$expire);
|
||||||
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
12
tst/i18n.php
12
tst/i18n.php
|
@ -25,6 +25,16 @@ class i18nTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals($messageId, i18n::_($messageId), 'fallback to en');
|
$this->assertEquals($messageId, i18n::_($messageId), 'fallback to en');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCookieLanguageDeDetection()
|
||||||
|
{
|
||||||
|
$_COOKIE['lang'] = 'de';
|
||||||
|
i18n::loadTranslations();
|
||||||
|
$this->assertEquals($this->_translations['en'], i18n::_('en'), 'browser language de');
|
||||||
|
$this->assertEquals('0 Stunden', i18n::_('%d hours', 0), '0 hours in german');
|
||||||
|
$this->assertEquals('1 Stunde', i18n::_('%d hours', 1), '1 hour in german');
|
||||||
|
$this->assertEquals('2 Stunden', i18n::_('%d hours', 2), '2 hours in french');
|
||||||
|
}
|
||||||
|
|
||||||
public function testBrowserLanguageDeDetection()
|
public function testBrowserLanguageDeDetection()
|
||||||
{
|
{
|
||||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-CH,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-CH,de;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||||
|
@ -64,6 +74,6 @@ class i18nTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'foobar';
|
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'foobar';
|
||||||
i18n::loadTranslations();
|
i18n::loadTranslations();
|
||||||
$this->assertEquals('some string + 1', i18n::_('some %s + %d', 'string', 1), 'browser language de');
|
$this->assertEquals('some string + 1', i18n::_('some %s + %d', 'string', 1), 'browser language en');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
124
tst/zerobin.php
124
tst/zerobin.php
|
@ -71,6 +71,31 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testViewLanguageSelection()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$options = parse_ini_file($this->_conf, true);
|
||||||
|
$options['main']['languageselection'] = true;
|
||||||
|
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||||
|
rename($this->_conf, $this->_conf . '.bak');
|
||||||
|
helper::createIniFile($this->_conf, $options);
|
||||||
|
$_COOKIE['lang'] = 'de';
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$this->assertTag(
|
||||||
|
array(
|
||||||
|
'tag' => 'title',
|
||||||
|
'content' => 'ZeroBin'
|
||||||
|
),
|
||||||
|
$content,
|
||||||
|
'outputs title correctly'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
|
@ -168,6 +193,27 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testCreateProxyHeader()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$options = parse_ini_file($this->_conf, true);
|
||||||
|
$options['traffic']['header'] = 'X_FORWARDED_FOR';
|
||||||
|
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||||
|
rename($this->_conf, $this->_conf . '.bak');
|
||||||
|
helper::createIniFile($this->_conf, $options);
|
||||||
|
$_POST = self::$paste;
|
||||||
|
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::1';
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$response = json_decode($content, true);
|
||||||
|
$this->assertEquals(1, $response['status'], 'outputs error status');
|
||||||
|
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
|
@ -289,6 +335,35 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
$this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testCreateAttachment()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$options = parse_ini_file($this->_conf, true);
|
||||||
|
$options['traffic']['limit'] = 0;
|
||||||
|
$options['main']['fileupload'] = true;
|
||||||
|
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
|
||||||
|
rename($this->_conf, $this->_conf . '.bak');
|
||||||
|
helper::createIniFile($this->_conf, $options);
|
||||||
|
$_POST = self::$paste;
|
||||||
|
$_POST['attachment'] = self::$comment['data'];
|
||||||
|
$_POST['attachmentname'] = self::$comment['meta']['nickname'];
|
||||||
|
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$response = json_decode($content, true);
|
||||||
|
$this->assertEquals(0, $response['status'], 'outputs status');
|
||||||
|
$this->assertEquals(
|
||||||
|
hash_hmac('sha1', $response['id'], serversalt::get()),
|
||||||
|
$response['deletetoken'],
|
||||||
|
'outputs valid delete token'
|
||||||
|
);
|
||||||
|
$this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
|
@ -598,6 +673,55 @@ class zerobinTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(1, $response['status'], 'outputs error status');
|
$this->assertEquals(1, $response['status'], 'outputs error status');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testReadOldSyntax()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$oldPaste = self::$paste;
|
||||||
|
$oldPaste['meta']['syntaxcoloring'] = true;
|
||||||
|
unset($oldPaste['meta']['formatter']);
|
||||||
|
$this->_model->create(self::$pasteid, $oldPaste);
|
||||||
|
$_SERVER['QUERY_STRING'] = self::$pasteid;
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$oldPaste['meta']['formatter'] = 'syntaxhighlighting';
|
||||||
|
$this->assertTag(
|
||||||
|
array(
|
||||||
|
'id' => 'cipherdata',
|
||||||
|
'content' => htmlspecialchars(json_encode($oldPaste), ENT_NOQUOTES)
|
||||||
|
),
|
||||||
|
$content,
|
||||||
|
'outputs data correctly'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
|
public function testReadOldFormat()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$oldPaste = self::$paste;
|
||||||
|
unset($oldPaste['meta']['formatter']);
|
||||||
|
$this->_model->create(self::$pasteid, $oldPaste);
|
||||||
|
$_SERVER['QUERY_STRING'] = self::$pasteid;
|
||||||
|
ob_start();
|
||||||
|
new zerobin;
|
||||||
|
$content = ob_get_contents();
|
||||||
|
$oldPaste['meta']['formatter'] = 'plaintext';
|
||||||
|
$this->assertTag(
|
||||||
|
array(
|
||||||
|
'id' => 'cipherdata',
|
||||||
|
'content' => htmlspecialchars(json_encode($oldPaste), ENT_NOQUOTES)
|
||||||
|
),
|
||||||
|
$content,
|
||||||
|
'outputs data correctly'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user