Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e505f8ab71 | ||
|
|
1426d4e371 | ||
|
|
1badd5e542 | ||
|
|
97cbcb0aab | ||
|
|
eca37c2184 | ||
|
|
f6b8ee3e20 | ||
|
|
577031cc1f | ||
|
|
3d6676eee8 | ||
|
|
ecd8a51137 | ||
|
|
fc874fe448 | ||
|
|
0506ac018d | ||
|
|
77f464f650 | ||
|
|
f45367fac2 | ||
|
|
aacfe8e5fa | ||
|
|
bbcc53f08e | ||
|
|
2847bbc45d | ||
|
|
ccba2f029f | ||
|
|
6ff5caf758 | ||
|
|
94aab2977d | ||
|
|
90e0bf6058 | ||
|
|
aab6bd83c9 | ||
|
|
08a34fda82 | ||
|
|
58bd603c7c | ||
|
|
8d73a81582 | ||
|
|
d6255f64e4 | ||
|
|
4a85ced4b1 | ||
|
|
ac53f0abdb | ||
|
|
0831ece7cd | ||
|
|
67094022dd | ||
|
|
124d1de3eb | ||
|
|
da10a761c4 | ||
|
|
61ee0ef7d3 | ||
|
|
658d5ae84d | ||
|
|
bdf1586539 | ||
|
|
f755a99ab8 | ||
|
|
b94d252421 | ||
|
|
3f2de319f3 | ||
|
|
0493cf4463 | ||
|
|
3f8d6a592b | ||
|
|
f7feff50d8 | ||
|
|
c2aa931392 | ||
|
|
70482a4fc0 | ||
|
|
9dcdb3172c | ||
|
|
f49927712a | ||
|
|
71a94271a7 | ||
|
|
1b0095b54a | ||
|
|
1c643191ce | ||
|
|
2c8a780c74 | ||
|
|
6544fc8a49 | ||
|
|
e8248020dd | ||
|
|
c916f33a83 | ||
|
|
c1ca5657b5 | ||
|
|
09fa46a651 | ||
|
|
0fbeefb199 | ||
|
|
bfe595e1a1 | ||
|
|
3b1eb64386 | ||
|
|
d6c445092f | ||
|
|
8619f4248b | ||
|
|
64e1e0d7c4 | ||
|
|
f9149595c9 | ||
|
|
f628ac78f8 | ||
|
|
b4293f5467 | ||
|
|
bd30ae419a | ||
|
|
375dac759f | ||
|
|
f093b05330 | ||
|
|
1f46823942 | ||
|
|
c8b1296929 | ||
|
|
7bbb273c1c | ||
|
|
5d822af5b1 | ||
|
|
b80665cc45 | ||
|
|
af824bbcd6 | ||
|
|
a714272286 | ||
|
|
3eea03954a | ||
|
|
eb77a01322 | ||
|
|
176d683d1c | ||
|
|
63a6ecb922 | ||
|
|
8619210c33 | ||
|
|
0a48c464b4 | ||
|
|
5639042d12 | ||
|
|
bc9bb7eeca | ||
|
|
c7c82c8305 | ||
|
|
f5813c959c | ||
|
|
cc637bd3f3 | ||
|
|
efffeddc25 | ||
|
|
2cd4717bd2 | ||
|
|
8cfcf1c9f5 | ||
|
|
ec7af3a738 | ||
|
|
8cb1a0a14d | ||
|
|
23febfc5ca | ||
|
|
1a159c973f | ||
|
|
b7184b92a3 | ||
|
|
7da4723112 | ||
|
|
8cb9e9d871 | ||
|
|
b11866a63b | ||
|
|
9ff74e8841 | ||
|
|
a13266a784 |
18
.dockerignore
Normal file
18
.dockerignore
Normal file
@@ -0,0 +1,18 @@
|
||||
# Documentation, might leak version number
|
||||
CHANGELOG.md
|
||||
LICENSE.md
|
||||
CREDITS.md
|
||||
INSTALL.md
|
||||
README.md
|
||||
doc/
|
||||
|
||||
# Dotfiles, pointless
|
||||
.codeclimate.yml
|
||||
.csslintrc
|
||||
.editorconfig
|
||||
.eslint*
|
||||
.git*
|
||||
.php_cs
|
||||
.styleci.yml
|
||||
.travis.yml
|
||||
.github
|
||||
@@ -38,6 +38,6 @@ indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[.travis.yml]
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
|
||||
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -2,6 +2,7 @@ doc/ export-ignore
|
||||
tst/ export-ignore
|
||||
.codeclimate.yml export-ignore
|
||||
.csslintrc export-ignore
|
||||
.dockerignore export-ignore
|
||||
.editorconfig export-ignore
|
||||
.eslintignore export-ignore
|
||||
.eslintrc export-ignore
|
||||
@@ -9,4 +10,6 @@ tst/ export-ignore
|
||||
.github export-ignore
|
||||
.gitignore export-ignore
|
||||
.php_cs export-ignore
|
||||
.styleci.yml export-ignore
|
||||
.travis.yml export-ignore
|
||||
Dockerfile export-ignore
|
||||
|
||||
18
.github/ISSUE_TEMPLATE.md
vendored
18
.github/ISSUE_TEMPLATE.md
vendored
@@ -3,8 +3,8 @@
|
||||
|
||||
## Steps to reproduce
|
||||
<!-- Tell us how to reproduce the problem. -->
|
||||
1.
|
||||
2.
|
||||
1.
|
||||
2.
|
||||
|
||||
### What happens
|
||||
|
||||
@@ -18,19 +18,21 @@ Here you can add screenshots. If the issue is e.g. a client-side issue (= an iss
|
||||
If you have access to the server log files, also copy them here.
|
||||
-->
|
||||
|
||||
* I can reproduce this issue on <https://privatebin.net>: Yes / No
|
||||
|
||||
## Basic information
|
||||
|
||||
<!-- If you use a public server (or a private server where you like to get more vists) enter the address of it here. -->
|
||||
**Server address**:
|
||||
<!-- If you use a public server enter the address of it here. -->
|
||||
**Server address**:
|
||||
|
||||
<!-- The Operation System of your server -->
|
||||
**Server OS:**
|
||||
**Server OS:**
|
||||
|
||||
<!-- The webserver running on your server, preferrably including the version -->
|
||||
**Webserver:**
|
||||
**Webserver:**
|
||||
|
||||
<!-- The version of your browser (when it is a client-side issue) -->
|
||||
**Browser:**
|
||||
**Browser:**
|
||||
|
||||
<!-- The version of PrivateBin, if you use an unstable version paste the commit hash or the GitHub link to the commit here (you can get it by running `git rev-parse HEAD`) -->
|
||||
**PrivateBin version:**
|
||||
**PrivateBin version:**
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -8,7 +8,7 @@
|
||||
-->
|
||||
|
||||
<!-- If your PR fixes an issue, mention it here. You can also just copy the URL - GitHub will convert it for you.
|
||||
If this PR fixes several issues, please prepend each issue url/number with the word "fix"/"fixes" or "close"/"closes" as this automatically closes the issues you metioned when the PR is merged.
|
||||
If this PR fixes several issues, please prepend each issue url/number with the word "fix"/"fixes" or "close"/"closes" as this automatically closes the issues you mentioned when the PR is merged.
|
||||
-->
|
||||
This PR fixes
|
||||
|
||||
|
||||
6
.php_cs
6
.php_cs
@@ -15,9 +15,9 @@ return Symfony\CS\Config\Config::create()
|
||||
->fixers(['concat_with_spaces', 'long_array_syntax', 'standardize_not_equal',
|
||||
'operators_spaces', 'duplicate_semicolon',
|
||||
'remove_leading_slash_use', 'align_equals',
|
||||
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_scalar',
|
||||
'phpdoc_to_comment', 'phpdoc_trim',
|
||||
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_order',
|
||||
'phpdoc_scalar', 'phpdoc_to_comment', 'phpdoc_trim',
|
||||
'phpdoc_types', 'print_to_echo', 'self_accessor', 'single_quote',
|
||||
'spaces_cast', 'ternary_spaces', 'phpdoc_order'])
|
||||
'spaces_cast', 'ternary_spaces'])
|
||||
->finder($finder)
|
||||
;
|
||||
|
||||
26
.styleci.yml
Normal file
26
.styleci.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
preset: recommended
|
||||
|
||||
risky: false
|
||||
|
||||
enabled:
|
||||
- no_empty_comment
|
||||
- align_equals
|
||||
- long_array_syntax
|
||||
- concat_with_spaces
|
||||
|
||||
disabled:
|
||||
- blank_line_after_opening_tag
|
||||
- blank_line_before_return
|
||||
- concat_without_spaces
|
||||
- declare_equal_normalize
|
||||
- heredoc_to_nowdoc
|
||||
- method_argument_space
|
||||
- new_with_braces
|
||||
- phpdoc_align
|
||||
- phpdoc_no_access
|
||||
- phpdoc_separation
|
||||
- phpdoc_single_line_var_spacing
|
||||
- phpdoc_summary
|
||||
- short_array_syntax
|
||||
- single_line_after_imports
|
||||
- unalign_equals
|
||||
@@ -1,5 +1,14 @@
|
||||
# PrivateBin version history
|
||||
|
||||
* **1.1 (2016-12-26)**
|
||||
* ADDED: Translations for Italian and Russian
|
||||
* ADDED: Loading message displayed until decryption succeeded for slower (in terms of CPU or network) systems
|
||||
* ADDED: Dockerfile for docker container creation
|
||||
* CHANGED: Using modal dialog to request password input instead of native JS input window (#69)
|
||||
* CHANGED: Suppressed referrer HTTP header sending when following links in a paste or comment (#96) and added additional HTTP headers for XSS mitigation (#91)
|
||||
* CHANGED: Updated random_compat and jQuery libraries
|
||||
* FIXED: XSS using JavaScript stored as markdown formatted paste, after clicking on Raw paste button (#137)
|
||||
* FIXED: Automatic purging deleting non-expiring pastes, when using database store (#149)
|
||||
* **1.0 (2016-08-25)**
|
||||
* ADDED: Translations for Slowene and Chinese
|
||||
* ADDED: re-introduced (optional) URL shortener support, which was removed back in version 0.16 for privacy concerns
|
||||
|
||||
21
CREDITS.md
21
CREDITS.md
@@ -1,7 +1,13 @@
|
||||
# Credits
|
||||
|
||||
Sébastien Sauvage - original idea and main developer
|
||||
Simon Rupf - current developer and maintainer
|
||||
## Active contributors
|
||||
|
||||
Simon Rupf - current developer and maintainer
|
||||
rugk - security review, doc improvment & various other stuff
|
||||
|
||||
## Past contributions
|
||||
|
||||
Sébastien Sauvage - original idea and main developer
|
||||
|
||||
* Alexey Gladkov - syntax highlighting
|
||||
* Greg Knaddison - robots.txt
|
||||
@@ -10,14 +16,19 @@ Simon Rupf - current developer and maintainer
|
||||
* Hexalyse - Password protection
|
||||
* Viktor Stanchev - File upload support
|
||||
* azlux - Tab character input support
|
||||
* Adam Fisher - Favicons
|
||||
* rugk - various stuff, logo and icons
|
||||
* Adam Fisher - old Favicons
|
||||
* rugk - new logo/icons
|
||||
* Sobak - PSR-4 and PSR-2 refactoring
|
||||
* Nathaniel Olsen - jQuery upgrade
|
||||
* Alexander Demenshin - modal password dialog
|
||||
* PunKeel - Dockerfile
|
||||
|
||||
Translations:
|
||||
## Translations
|
||||
* Hexalyse - French
|
||||
* Kuba Niewiarowski - Polish
|
||||
* Gabbalo - German
|
||||
* Draky50110 - French
|
||||
* Filip Muki Dobranić - Slovene
|
||||
* Jiawei Zhou - Chinese
|
||||
* Stefano Marty - Italian
|
||||
* R4SAS - Russian
|
||||
|
||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM php:apache
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
libpng12-dev \
|
||||
wget \
|
||||
zip \
|
||||
unzip; \
|
||||
# We install and enable php-gd
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/; \
|
||||
docker-php-ext-install -j$(nproc) gd; \
|
||||
|
||||
# We enable Apache's mod_rewrite
|
||||
a2enmod rewrite
|
||||
|
||||
COPY . .
|
||||
19
INSTALL.md
19
INSTALL.md
@@ -3,8 +3,8 @@
|
||||
**TL;DR:** Download the
|
||||
[latest release archive](https://github.com/PrivateBin/PrivateBin/releases/latest)
|
||||
and extract it in your web hosts folder where you want to install your PrivateBin
|
||||
instance. We try to provide a safe default configuration, but advise you to check
|
||||
the options and adjust them as you see fit.
|
||||
instance. We try to provide a safe default configuration, but we advise you to
|
||||
check the options and adjust them as you see fit.
|
||||
|
||||
## Basic installation
|
||||
|
||||
@@ -20,7 +20,7 @@ the options and adjust them as you see fit.
|
||||
|
||||
Mcrypt needs to be able to access `/dev/urandom`. This means if `open_basedir` is set, it must include this file.
|
||||
- GD extension
|
||||
- (optional) a database supported by [PDO](https://secure.php.net/manual/book.pdo.php)
|
||||
- some disk space or (optional) a database supported by [PDO](https://secure.php.net/manual/book.pdo.php)
|
||||
- ability to create files and folders in the installation directory and the PATH
|
||||
- A web browser with javascript support
|
||||
|
||||
@@ -39,6 +39,17 @@ to your PrivateBin installation.
|
||||
More details can be found in the
|
||||
[configuration documentation](https://github.com/PrivateBin/PrivateBin/wiki/Configuration).
|
||||
|
||||
## Further configuration
|
||||
|
||||
After (or before) setting up PrivateBin, also set up HTTPS, as without HTTPS
|
||||
PrivateBin is not secure. (
|
||||
[More information](https://github.com/PrivateBin/PrivateBin/wiki/FAQ#how-should-i-setup-https))
|
||||
|
||||
If you want to use PrivateBin behind Cloudflare, make sure you disabled Rocket
|
||||
loader and unchecked "Javascript" for Auto Minify, found in your domain settings,
|
||||
under "Speed". (More information
|
||||
[in this FAQ entry](https://github.com/PrivateBin/PrivateBin/wiki/FAQ#user-content-how-to-make-privatebin-work-when-using-cloudflare-for-ddos-protection))
|
||||
|
||||
## Advanced installation
|
||||
|
||||
### Changing the path
|
||||
@@ -134,4 +145,4 @@ For reference or if you want to create the table schema for yourself (replace
|
||||
CREATE TABLE prefix_config (
|
||||
id CHAR(16) NOT NULL, value TEXT, PRIMARY KEY (id)
|
||||
);
|
||||
INSERT INTO prefix_config VALUES('VERSION', '0.22');
|
||||
INSERT INTO prefix_config VALUES('VERSION', '1.1');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[](https://www.codacy.com/app/PrivateBin/PrivateBin)
|
||||
[](https://codeclimate.com/github/PrivateBin/PrivateBin/coverage) [](https://scrutinizer-ci.com/g/PrivateBin/PrivateBin/?branch=master)
|
||||
|
||||
*Current version: 1.0*
|
||||
*Current version: 1.1*
|
||||
|
||||
**PrivateBin** is a minimalist, open source online pastebin where the server has
|
||||
zero knowledge of pasted data.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
; config file for PrivateBin
|
||||
;
|
||||
;
|
||||
; An explanation of each setting can be find online at https://github.com/PrivateBin/PrivateBin/wiki/Configuration.
|
||||
|
||||
[main]
|
||||
@@ -60,7 +60,7 @@ languageselection = false
|
||||
; custom scripts from third-party domains to your templates, e.g. tracking
|
||||
; scripts or run your site behind certain DDoS-protection services.
|
||||
; Check the documentation at https://content-security-policy.com/
|
||||
cspheader = "default-src 'none'; connect-src *; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' data:;"
|
||||
; cspheader = "default-src 'none'; manifest-src 'self'; connect-src *; script-src 'self'; style-src 'self'; font-src 'self'; img-src 'self' data:; referrer no-referrer;"
|
||||
|
||||
; stay compatible with PrivateBin Alpha 0.19, less secure
|
||||
; if enabled will use base64.js version 1.7 instead of 2.1.9 and sha1 instead of
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
body {
|
||||
|
||||
15
css/noscript.css
Normal file
15
css/noscript.css
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* PrivateBin
|
||||
*
|
||||
* CSS file only loaded when no JavaScript available.
|
||||
*
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/* When there is no script at all other */
|
||||
.noscript-hide {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* PrivateBin
|
||||
*
|
||||
* a zero-knowledge paste bin
|
||||
* Main CSS file.
|
||||
*
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
/* CSS Reset from YUI 3.4.1 (build 4118) - Copyright 2011 Yahoo! Inc. All rights reserved.
|
||||
@@ -117,7 +117,7 @@ h3.title {
|
||||
#pasteresult {
|
||||
background-color: #1F2833;
|
||||
color: #fff;
|
||||
padding: 4px 12px;
|
||||
padding: 4px 12px;
|
||||
clear: both;
|
||||
-moz-box-shadow: inset 0 2px 2px #000;
|
||||
-webkit-box-shadow: inset 0 2px 2px #000;
|
||||
@@ -161,7 +161,7 @@ button, .button {
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
button:hover {
|
||||
background-image: linear-gradient(bottom, #424b57 0%, #61707e 100%);
|
||||
background-image: -o-linear-gradient(bottom, #424b57 0%, #61707e 100%);
|
||||
background-image: -moz-linear-gradient(bottom, #424b57 0%, #61707e 100%);
|
||||
@@ -193,8 +193,8 @@ button img {
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.button {
|
||||
background-color: #414d5a;
|
||||
.button {
|
||||
background-color: #414d5a;
|
||||
padding: 6px 8px;
|
||||
margin: 0 5px 0 0;
|
||||
position: relative;
|
||||
@@ -218,7 +218,7 @@ button img {
|
||||
}
|
||||
|
||||
#remainingtime, #password {
|
||||
color: #94a3b4;
|
||||
color: #94a3b4;
|
||||
display: inline;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
@@ -285,6 +285,10 @@ input {
|
||||
color:#ff0;
|
||||
}
|
||||
|
||||
.small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/* --- discussion related CSS ------- */
|
||||
|
||||
#discussion { /* Discussion container */
|
||||
@@ -298,7 +302,7 @@ h4.title {
|
||||
font-size: 1.2em;
|
||||
color: #94a3b4;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
margin-left: 30px;
|
||||
}
|
||||
@@ -356,7 +360,7 @@ h4.title {
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.comment button:hover {
|
||||
.comment button:hover {
|
||||
background-image: linear-gradient(bottom, #ccd 0, #fff 100%);
|
||||
background-image: -o-linear-gradient(bottom, #ccd 0, #fff 100%);
|
||||
background-image: -moz-linear-gradient(bottom, #ccd 0, #fff 100%);
|
||||
|
||||
17
i18n/de.json
17
i18n/de.json
@@ -31,8 +31,8 @@
|
||||
"PrivateBin ist ein minimalistischer, quelloffener \"Pastebin\"-artiger Dienst, bei dem der Server keinerlei Kenntnis der Inhalte hat. Die Daten werden <i>im Browser</i> mit 256 Bit AES ver- und entschlüsselt. Weitere Informationen sind auf der <a href=\"https://privatebin.info/\">Projektseite</a> zu finden.",
|
||||
"Because ignorance is bliss":
|
||||
"Unwissenheit ist ein Segen",
|
||||
"Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Javascript ist eine Voraussetzung, um PrivateBin zu nutzen.<br />Bitte entschuldige die Unannehmlichkeiten.",
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"JavaScript ist eine Voraussetzung, um PrivateBin zu nutzen.<br />Bitte entschuldige die Unannehmlichkeiten.",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin setzt einen modernen Browser voraus, um funktionieren zu können.",
|
||||
"Still using Internet Explorer? Do yourself a favor, switch to a modern browser:":
|
||||
@@ -67,7 +67,7 @@
|
||||
"Never":
|
||||
"Nie",
|
||||
"Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.":
|
||||
"Hinweis: Dies ist ein Versuchsdienst. Daten können jederzeit gelöscht werden. Kätzchen werden sterben wenn Du diesen Dienst missbrauchst.",
|
||||
"Hinweis: Dies ist ein Versuchsdienst. Daten können jederzeit gelöscht werden. Kätzchen werden sterben wenn du diesen Dienst missbrauchst.",
|
||||
"This document will expire in %d seconds.":
|
||||
["Dieses Dokument läuft in einer Sekunde ab.", "Dieses Dokument läuft in %d Sekunden ab."],
|
||||
"This document will expire in %d minutes.":
|
||||
@@ -123,7 +123,7 @@
|
||||
"Could not create paste: %s":
|
||||
"Konnte Text nicht erstellen: %s",
|
||||
"Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)":
|
||||
"Konnte Text nicht entschlüsseln: Der Schlüssel fehlt in der Adresse (Hast Du eine Umleitung oder einen URL-Verkürzer benutzt, der Teile der Adresse entfernt?)",
|
||||
"Konnte Text nicht entschlüsseln: Der Schlüssel fehlt in der Adresse (Hast du eine Umleitung oder einen URL-Verkürzer benutzt, der Teile der Adresse entfernt?)",
|
||||
"Format": "Format",
|
||||
"Plain Text": "Nur Text",
|
||||
"Source Code": "Quellcode",
|
||||
@@ -140,5 +140,12 @@
|
||||
"Editor": "Bearbeiten",
|
||||
"Preview": "Vorschau",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"Der PATH muss bei PrivateBin mit einem \"%s\" enden. Bitte passe Deinen PATH in Deiner index.php an."
|
||||
"Der PATH muss bei PrivateBin mit einem \"%s\" enden. Bitte passe Deinen PATH in Deiner index.php an.",
|
||||
"Decrypt":
|
||||
"Entschlüsseln",
|
||||
"Enter password":
|
||||
"Passwort eingeben",
|
||||
"Loading…": "Lädt…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"Wenn diese Nachricht nicht mehr verschwindet, schau bitte in <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">die FAQ</a> (englisch), um zu sehen, wie der Fehler behoben werden kann."
|
||||
}
|
||||
|
||||
21
i18n/fr.json
21
i18n/fr.json
@@ -30,9 +30,9 @@
|
||||
"PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted <i>in the browser</i> using 256 bits AES. More information on the <a href=\"https://privatebin.info/\">project page</a>.":
|
||||
"PrivateBin est un 'pastebin' (ou gestionnaire d'extraits de texte et de code source) minimaliste et open source, dans lequel le serveur n'a aucune connaissance des données envoyées. Les données sont chiffrées/déchiffrées <i>dans le navigateur</i> par un chiffrage AES 256 bits. Plus d'informations sur <a href=\"https://privatebin.info/\">la page du projet</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Parce que l'ignorance est le bonheur",
|
||||
"Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Javascript est requis pour faire fonctionner PrivateBin. <br />Désolé pour cet inconvénient.",
|
||||
"Parce que l'ignorance c'est le bonheur",
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"JavaScript est requis pour faire fonctionner PrivateBin. <br />Désolé pour cet inconvénient.",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin nécessite un navigateur moderne pour fonctionner.",
|
||||
"Still using Internet Explorer? Do yourself a favor, switch to a modern browser:":
|
||||
@@ -87,7 +87,7 @@
|
||||
"FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.":
|
||||
"POUR VOS YEUX UNIQUEMENT. Ne fermez pas cette fenêtre, ce paste ne pourra plus être affiché.",
|
||||
"Could not decrypt comment; Wrong key?":
|
||||
"Umpossible de déchiffrer le commentaire ; mauvaise clé ?",
|
||||
"Impossible de déchiffrer le commentaire ; mauvaise clé ?",
|
||||
"Reply":
|
||||
"Répondre",
|
||||
"Anonymous":
|
||||
@@ -146,8 +146,15 @@
|
||||
"Invalid attachment.": "Attachement invalide.",
|
||||
"Options": "Options",
|
||||
"Shorten URL": "Raccourcir URL",
|
||||
"Editor": "éditer",
|
||||
"Preview": "avant-première",
|
||||
"Editor": "Éditer",
|
||||
"Preview": "Prévisualiser",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php."
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.",
|
||||
"Decrypt":
|
||||
"Decrypt",
|
||||
"Enter password":
|
||||
"Entrez le mot de passe",
|
||||
"Loading…": "Loading…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a> (in English)."
|
||||
}
|
||||
|
||||
151
i18n/it.json
Normal file
151
i18n/it.json
Normal file
@@ -0,0 +1,151 @@
|
||||
{
|
||||
"en": "it",
|
||||
"Paste does not exist, has expired or has been deleted.":
|
||||
"Questo messaggio non esiste, è scaduto o è stato cancellato.",
|
||||
"PrivateBin requires php 5.3.0 or above to work. Sorry.":
|
||||
"PrivateBin richiede PHP 5.3.0 o superiore.",
|
||||
"PrivateBin requires configuration section [%s] to be present in configuration file.":
|
||||
"PrivateBin richiede la presenza della sezione [%s] nei file di configurazione.",
|
||||
"Please wait %d seconds between each post.":
|
||||
"Attendi per favore %d secondi prima di ciascun invio.",
|
||||
"Paste is limited to %s of encrypted data.":
|
||||
"La dimensione del messaggio è limitata a %s di dati cifrati.",
|
||||
"Invalid data.":
|
||||
"Dati non validi.",
|
||||
"You are unlucky. Try again.":
|
||||
"Riprova, sarai più fortunato.",
|
||||
"Error saving comment. Sorry.":
|
||||
"Errore durante il salvataggio del commento.",
|
||||
"Error saving paste. Sorry.":
|
||||
"Errore durante il salvataggio del messaggio.",
|
||||
"Invalid paste ID.":
|
||||
"ID-Messaggio non valido.",
|
||||
"Paste is not of burn-after-reading type.":
|
||||
"Il messaggio non è di tipo Distruggi-dopo-lettura.",
|
||||
"Wrong deletion token. Paste was not deleted.":
|
||||
"Codice cancellazione errato. Il messaggio NON è stato cancellato.",
|
||||
"Paste was properly deleted.":
|
||||
"Il messaggio è stato correttamente cancellato.",
|
||||
"PrivateBin": "PrivateBin",
|
||||
"PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted <i>in the browser</i> using 256 bits AES. More information on the <a href=\"https://privatebin.info/\">project page</a>.":
|
||||
"PrivateBin è un sistema di tipo \"Pastebin\" online, open source, minimalista. Il server non possiede alcuna conoscenza (\"Zero Knowledge\") del contenuto dei dati inviati. I dati sono cifrati/decifrati <i>nel Browser</i> con algoritmo AES a 256 Bit. Per ulteriori informazioni, vedi <a href=\"https://privatebin.info/\">Sito del progetto</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Perché l'ignoranza è una benedizione (Because ignorance is bliss)",
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"PrivateBin funziona solo con JavaScript attivo.<br />Ci dispiace per l'inconveniente.",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin richiede un browser moderno e aggiornato per funzionare.",
|
||||
"Still using Internet Explorer? Do yourself a favor, switch to a modern browser:":
|
||||
"Usi ancora Internet Explorer? Ti consigliamo di passare ad un browser più sicuro:",
|
||||
"New":
|
||||
"Nuovo",
|
||||
"Send":
|
||||
"Invia",
|
||||
"Clone":
|
||||
"Clona",
|
||||
"Raw text":
|
||||
"Testo Raw",
|
||||
"Expires":
|
||||
"Scade",
|
||||
"Burn after reading":
|
||||
"Distruggi dopo lettura",
|
||||
"Open discussion":
|
||||
"Apri discussione",
|
||||
"Password (recommended)":
|
||||
"Password (raccomandato)",
|
||||
"Discussion":
|
||||
"Discussione",
|
||||
"Toggle navigation":
|
||||
"Scambia Navigazione",
|
||||
"%d seconds": ["%d secondo", "%d secondi"],
|
||||
"%d minutes": ["%d minuto", "%d minuti"],
|
||||
"%d hours": ["%d ora", "%d ore"],
|
||||
"%d days": ["%d giorno", "%d giorni"],
|
||||
"%d weeks": ["%d settimana", "%d settimane"],
|
||||
"%d months": ["%d mese", "%d mesi"],
|
||||
"%d years": ["%d anno", "%d anni"],
|
||||
"Never":
|
||||
"Mai",
|
||||
"Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.":
|
||||
"Nota: questo è un servizio di prova, i dati possono essere cancellati in qualsiasi momento. Ti preghiamo di non abusare di questo servizio, grazie.",
|
||||
"This document will expire in %d seconds.":
|
||||
["Questo documento scadrà tra un secondo.", "Questo documento scadrà in %d secondi."],
|
||||
"This document will expire in %d minutes.":
|
||||
["Questo documento scadrà tra un minuto.", "Questo documento scadrà in %d minuti."],
|
||||
"This document will expire in %d hours.":
|
||||
["Questo documento scadrà tra un'ora.", "Questo documento scadrà in %d ore."],
|
||||
"This document will expire in %d days.":
|
||||
["Questo documento scadrà tra un giorno.", "Questo documento scadrà in %d giorni."],
|
||||
"This document will expire in %d months.":
|
||||
["Questo documento scadrà tra un mese.", "Questo documento scadrà in %d mesi."],
|
||||
"Please enter the password for this paste:":
|
||||
"Inserisci la password per questo messaggio:",
|
||||
"Could not decrypt data (Wrong key?)":
|
||||
"Non riesco a decifrari i dati (Chiave errata?)",
|
||||
"Could not delete the paste, it was not stored in burn after reading mode.":
|
||||
"Non riesco a cancellare il messaggio, non è stato salvato in modalità Distruggi-dopo-lettora.",
|
||||
"FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.":
|
||||
"FOR YOUR EYES ONLY. Non chiudere questa finestra, il messaggio non può essere visualizzato una seconda volta.",
|
||||
"Could not decrypt comment; Wrong key?":
|
||||
"Non riesco a decifrari il commento (Chiave errata?)",
|
||||
"Reply":
|
||||
"Rispondi",
|
||||
"Anonymous":
|
||||
"Anonimo",
|
||||
"Anonymous avatar (Vizhash of the IP address)":
|
||||
"Avatar Anonino (Vizhash dell'indirizzo IP)",
|
||||
"Add comment":
|
||||
"Aggiungi un commento",
|
||||
"Optional nickname...":
|
||||
"Nickname opzionale...",
|
||||
"Post comment":
|
||||
"Invia commento",
|
||||
"Sending comment...":
|
||||
"Commento in fase di invio...",
|
||||
"Comment posted.":
|
||||
"Commento inviato.",
|
||||
"Could not refresh display: %s":
|
||||
"Non riesco ad aggiornare il display: %s",
|
||||
"unknown status":
|
||||
"errore sconosciuto",
|
||||
"server error or not responding":
|
||||
"errore o mancata risposta dal server",
|
||||
"Could not post comment: %s":
|
||||
"Impossibile inviare il commento: %s",
|
||||
"Sending paste (Please move your mouse for more entropy)...":
|
||||
"Invio messaggio (Muovi il mouse in modo casuale, per generare maggior entropia)...",
|
||||
"Sending paste...":
|
||||
"Messaggio in fase di invio...",
|
||||
"Your paste is <a id=\"pasteurl\" href=\"%s\">%s</a> <span id=\"copyhint\">(Hit [Ctrl]+[c] to copy)</span>":
|
||||
"Il tuo messaggio è qui: <a id=\"pasteurl\" href=\"%s\">%s</a> <span id=\"copyhint\">([CTRL | CMD]+[C] per copiare il link)</span>",
|
||||
"Delete data":
|
||||
"Cancella i dati",
|
||||
"Could not create paste: %s":
|
||||
"Non rieco a creare il messaggio: %s",
|
||||
"Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)":
|
||||
"Non riesco a decifrare il messaggio: manca la chiave di decifrazione nell'URL (La chiave è parte integrante dell'URL. Per caso hai usato un Redirector o un altro servizio che ha rimosso una parte dell'URL?)",
|
||||
"Format": "Formato",
|
||||
"Plain Text": "Solo Testo",
|
||||
"Source Code": "Codice Sorgente",
|
||||
"Markdown": "Markdown",
|
||||
"Download attachment": "Scarica Allegato",
|
||||
"Cloned file attached.": "Copia del file allegata.",
|
||||
"Attach a file": "Allega un file",
|
||||
"Remove attachment": "Rimuovi allegato",
|
||||
"Your browser does not support uploading encrypted files. Please use a newer browser.":
|
||||
"Il tuo browser non supporta l'invio di file cifrati. Utilizza un browser più recente.",
|
||||
"Invalid attachment.": "Allegato non valido.",
|
||||
"Options": "Opzioni",
|
||||
"Shorten URL": "Accorcia URL",
|
||||
"Editor": "Editor",
|
||||
"Preview": "Preview",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"PrivateBin necessita che PATH termini con \"%s\". Aggiorna la variabile PATH nel tuo index.php.",
|
||||
"Decrypt":
|
||||
"Decrypt",
|
||||
"Enter password":
|
||||
"Inserisci la password",
|
||||
"Loading…": "Loading…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a> (in English)."
|
||||
}
|
||||
19
i18n/pl.json
19
i18n/pl.json
@@ -31,7 +31,7 @@
|
||||
"PrivateBin jest minimalistycznym, otwartoźródłowym serwisem typu pastebin, w którym serwer nie ma jakichkolwiek informacji o tym, co jest wklejane. Dane są szyfrowane i deszyfrowane <i>w przeglądarce</i> z użyciem 256-bitowego klucza AES. Więcej informacji na <a href=\"https://privatebin.info/\">stronie projektu</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Ponieważ ignorancja jest cnotą",
|
||||
"Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Do działania PrivateBina jest wymagany JavaScript. Przepraszamy za tę niedogodność.",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin wymaga do działania nowoczesnej przeglądarki.",
|
||||
@@ -59,11 +59,11 @@
|
||||
"Przełącz nawigację",
|
||||
"%d seconds": ["%d second", "%d second", "%d second"],
|
||||
"%d minutes": ["%d minut", "%d minut", "%d minut"],
|
||||
"%d hours": ["%d godzina", "%d godzina", "godzinę"],
|
||||
"%d hours": ["%d godzina", "%d godzina", "%d godzinę"],
|
||||
"%d days": ["%d dzień", "%d dzień", "%d dzień"],
|
||||
"%d weeks": ["%d tydzień", "%d tydzień", "tydzień"],
|
||||
"%d months": ["%d miesiąc", "%d miesiąc", "miesiąc"],
|
||||
"%d years": ["%d rok", "%d rok", "rok"],
|
||||
"%d weeks": ["%d tydzień", "%d tydzień", "%d tydzień"],
|
||||
"%d months": ["%d miesiąc", "%d miesiąc", "%d miesiąc"],
|
||||
"%d years": ["%d rok", "%d rok", "%d rok"],
|
||||
"Never":
|
||||
"nigdy",
|
||||
"Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.":
|
||||
@@ -140,5 +140,12 @@
|
||||
"Editor": "Edytować",
|
||||
"Preview": "Zapowiedź",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php."
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.",
|
||||
"Decrypt":
|
||||
"Decrypt",
|
||||
"Enter password":
|
||||
"Wpisz hasło",
|
||||
"Loading…": "Loading…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a> (in English)."
|
||||
}
|
||||
|
||||
157
i18n/ru.json
Normal file
157
i18n/ru.json
Normal file
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"en": "ru",
|
||||
"Paste does not exist, has expired or has been deleted.":
|
||||
"Запись не существует, просрочена или была удалена.",
|
||||
"PrivateBin requires php 5.3.0 or above to work. Sorry.":
|
||||
"Для работы PrivateBin требуется PHP 5.3.0 или выше. Извините.",
|
||||
"PrivateBin requires configuration section [%s] to be present in configuration file.":
|
||||
"PrivateBin необходимо наличие секции [%s] в конфигурационном файле.",
|
||||
"Please wait %d seconds between each post.":
|
||||
["Пожалуйста ожидайте %d секунду между каждыми записями.", "Пожалуйста ожидайте %d секунды между каждыми записями.", "Пожалуйста ожидайте %d секунд между каждыми записями."],
|
||||
"Paste is limited to %s of encrypted data.":
|
||||
"Размер записи ограничен %s зашифрованных данных.",
|
||||
"Invalid data.":
|
||||
"Неверные данные.",
|
||||
"You are unlucky. Try again.":
|
||||
"Вам не повезло. Попробуйте еще раз.",
|
||||
"Error saving comment. Sorry.":
|
||||
"Ошибка при сохранении комментария. Извините.",
|
||||
"Error saving paste. Sorry.":
|
||||
"Ошибка при сохранении записи. Извините.",
|
||||
"Invalid paste ID.":
|
||||
"Неверный ID записи.",
|
||||
"Paste is not of burn-after-reading type.":
|
||||
"Тип записи не \"Удалить после прочтения\".",
|
||||
"Wrong deletion token. Paste was not deleted.":
|
||||
"Неверный ключ удаления записи. Запись не удалена",
|
||||
"Paste was properly deleted.":
|
||||
"Запись была успешно удалена.",
|
||||
"PrivateBin": "PrivateBin",
|
||||
"PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted <i>in the browser</i> using 256 bits AES. More information on the <a href=\"https://privatebin.info/\">project page</a>.":
|
||||
"PrivateBin это минималистичный Open Source проект для создания заметок, где сервер не знает ничего о сохраняемых данных. Данные шифруются/расшифровываются <i>в браузере</i> с использованием 256 битного шифрования AES. Подробнее можно узнать на <a href=\"https://privatebin.info/\">сайте проекта</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Потому что неведение - благо",
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Для работы PrivateBin требуется включенный JavaScript.<br />Приносим извинения за неудобства..",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"Для работы PrivateBin требуется более современный браузер.",
|
||||
"Still using Internet Explorer? Do yourself a favor, switch to a modern browser:":
|
||||
"До сих пор используете Internet Explorer? Пожалейте себя, перейдите на более современный браузер:",
|
||||
"New":
|
||||
"Новая запись",
|
||||
"Send":
|
||||
"Отправить",
|
||||
"Clone":
|
||||
"Дублировать",
|
||||
"Raw text":
|
||||
"Исходный текст",
|
||||
"Expires":
|
||||
"Удалить через",
|
||||
"Burn after reading":
|
||||
"Удалить после прочтения",
|
||||
"Open discussion":
|
||||
"Открыть обсуждение",
|
||||
"Password (recommended)":
|
||||
"Пароль (рекомендуется)",
|
||||
"Discussion":
|
||||
"Обсуждение",
|
||||
"Toggle navigation":
|
||||
"Переключить навигацию",
|
||||
"%d seconds": ["%d секунду", "%d секунды", "%d секунд"],
|
||||
"%d minutes": ["%d минуту", "%d минуты", "%d минут"],
|
||||
"%d hours": ["%d час", "%d часа", "%d часов"],
|
||||
"%d days": ["%d день", "%d дня", "%d дней"],
|
||||
"%d weeks": ["%d неделю", "%d недели", "%d недель"],
|
||||
"%d months": ["%d месяц", "%d месяца", "%d месяцев"],
|
||||
"%d years": ["%d год", "%d года", "%d лет"],
|
||||
"Never":
|
||||
"Никогда",
|
||||
"Note: This is a test service: Data may be deleted anytime. Kittens will die if you abuse this service.":
|
||||
"Примечание: Этот сервис тестовый: Данные могут быть удалены в любое время. Котята умрут, если вы будете злоупотреблять серсисом.",
|
||||
"This document will expire in %d seconds.":
|
||||
["Документ будет удален через %d секунду.", "Документ будет удален через %d секунды.", "Документ будет удален через %d секунд."],
|
||||
"This document will expire in %d minutes.":
|
||||
["Документ будет удален через %d минуту.", "Документ будет удален через %d минуты.", "Документ будет удален через %d минут."],
|
||||
"This document will expire in %d hours.":
|
||||
["Документ будет удален через %d час.", "Документ будет удален через %d часа.", "Документ будет удален через %d часов."],
|
||||
"This document will expire in %d days.":
|
||||
["Документ будет удален через %d день.", "Документ будет удален через %d дня.", "Документ будет удален через %d дней."],
|
||||
"This document will expire in %d months.":
|
||||
["Документ будет удален через %d месяц.", "Документ будет удален через %d месяца.", "Документ будет удален через %d месяцев."],
|
||||
"Please enter the password for this paste:":
|
||||
"Пожалуйста введите пароль от записи:",
|
||||
"Could not decrypt data (Wrong key?)":
|
||||
"Невозможно расшифровать данные (Неверный ключ?)",
|
||||
"Could not delete the paste, it was not stored in burn after reading mode.":
|
||||
"Невозможно удалить запись, она не была сохранена в режиме удаления после прочтения",
|
||||
"FOR YOUR EYES ONLY. Don't close this window, this message can't be displayed again.":
|
||||
"ТОЛЬКО ДЛЯ ВАШИХ ГЛАЗ. Не закрывайте это окно, это сообщение не может быть показано снова.",
|
||||
"Could not decrypt comment; Wrong key?":
|
||||
"Невозможно расшифровать комментарий; Неверный ключ?",
|
||||
"Reply":
|
||||
"Ответить",
|
||||
"Anonymous":
|
||||
"Аноним",
|
||||
"Anonymous avatar (Vizhash of the IP address)":
|
||||
"Анонимный аватар (Vizhash IP адреса)",
|
||||
"Add comment":
|
||||
"Добавить комментарий",
|
||||
"Optional nickname...":
|
||||
"Опциональный никнейм...",
|
||||
"Post comment":
|
||||
"Отправить комментарий",
|
||||
"Sending comment...":
|
||||
"Отправка комментария...",
|
||||
"Comment posted.":
|
||||
"Комментарий опубликован.",
|
||||
"Could not refresh display: %s":
|
||||
"Невозможно обновить данные: %s",
|
||||
"unknown status":
|
||||
"неизвестная причина",
|
||||
"server error or not responding":
|
||||
"ошибка сервера или нет ответа",
|
||||
"Could not post comment: %s":
|
||||
"Не удалось опубликовать комментарий: %s",
|
||||
"Sending paste (Please move your mouse for more entropy)...":
|
||||
"Отправка записи (Пожалуйста двигайте мышкой для большей энтропии)...",
|
||||
"Sending paste...":
|
||||
"Отправка записи...",
|
||||
"Your paste is <a id=\"pasteurl\" href=\"%s\">%s</a> <span id=\"copyhint\">(Hit [Ctrl]+[c] to copy)</span>":
|
||||
"Ссылка на запись <a id=\"pasteurl\" href=\"%s\">%s</a> <span id=\"copyhint\">(Нажмите [Ctrl]+[c] чтобы скопировать ссылку)</span>",
|
||||
"Delete data":
|
||||
"Удалить запись",
|
||||
"Could not create paste: %s":
|
||||
"Не удалось опубликовать запись: %s",
|
||||
"Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)":
|
||||
"Невозможно расшифровать запись: Ключ расшифровки отсутствует в ссылке (Может быть вы используете сокращатель ссылок, который удаляет часть ссылки?)",
|
||||
"B": "байт",
|
||||
"KiB": "Кбайт",
|
||||
"MiB": "Мбайт",
|
||||
"GiB": "Гбайт",
|
||||
"TiB": "Тбайт",
|
||||
"PiB": "Пбайт",
|
||||
"EiB": "Эбайт",
|
||||
"ZiB": "Збайт",
|
||||
"YiB": "Йбайт",
|
||||
"Format": "Формат",
|
||||
"Plain Text": "Обычный текст",
|
||||
"Source Code": "Исходный код",
|
||||
"Markdown": "Язык разметки",
|
||||
"Download attachment": "Скачать прикрепленный файл",
|
||||
"Cloned file attached.": "Дубль файла прикреплен.",
|
||||
"Attach a file": "Прикрепить файл",
|
||||
"Remove attachment": "Удалить вложение",
|
||||
"Your browser does not support uploading encrypted files. Please use a newer browser.":
|
||||
"Ваш браузер не поддерживает отправку зашифрованных файлов. Используйте более новый браузер.",
|
||||
"Invalid attachment.": "Неизвестное вложение.",
|
||||
"Options": "Опции",
|
||||
"Shorten URL": "Короткая ссылка",
|
||||
"Editor": "Редактор",
|
||||
"Preview": "Предпросмотр",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"Переменная PATH необходима PrivateBin в конце \"%s\". Пожалуйста обновите переменную PATH в вашем index.php.",
|
||||
"Decrypt":
|
||||
"Расшифровать",
|
||||
"Enter password":
|
||||
"Введите пароль"
|
||||
}
|
||||
13
i18n/sl.json
13
i18n/sl.json
@@ -31,8 +31,8 @@
|
||||
"PrivateBin je minimalističen, odprtokodni spletni 'pastebin', kjer server ne ve ničesar o prilepljenih podatkih. Podatki so zakodirani/odkodirani <i>v brskalniku</i> z uporabo 256 bitnega AES. Več informacij na < href=\"https://privatebin.info/\">spletni strani projekta.</a>.",
|
||||
"Because ignorance is bliss":
|
||||
"Ker kar ne veš ne boli.",
|
||||
"Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Da PrivateBin deluje, moraš vklopiti Javascript.<br />Oprosti za povročene nevšečnosti.",
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"Da PrivateBin deluje, moraš vklopiti JavaScript.<br />Oprosti za povročene nevšečnosti.",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin za svoje delovanje potrebuje moderen brskalnik.",
|
||||
"Still using Internet Explorer? Do yourself a favor, switch to a modern browser:":
|
||||
@@ -149,5 +149,12 @@
|
||||
"Editor": "Uredi",
|
||||
"Preview": "Predogled",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php."
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.",
|
||||
"Decrypt":
|
||||
"Decrypt",
|
||||
"Enter password":
|
||||
"Prosim vnesi geslo",
|
||||
"Loading…": "Loading…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a> (in English)."
|
||||
}
|
||||
|
||||
11
i18n/zh.json
11
i18n/zh.json
@@ -31,7 +31,7 @@
|
||||
"PrivateBin是一个极简,开源,对粘贴内容毫不知情的在线粘贴板,数据<i>在浏览器内</i>进行AES-256加密。更多信息请查看<a href=\"https://privatebin.info/\">项目主页</a>。",
|
||||
"Because ignorance is bliss":
|
||||
"因为无知是福",
|
||||
"Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.":
|
||||
"PrivateBin需要JavaScript来进行加解密。<br />带来的不便敬请谅解。",
|
||||
"PrivateBin requires a modern browser to work.":
|
||||
"PrivateBin需要工作于现代化的浏览器。",
|
||||
@@ -140,5 +140,12 @@
|
||||
"Editor": "編輯",
|
||||
"Preview": "預習",
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.":
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php."
|
||||
"PrivateBin requires the PATH to end in a \"%s\". Please update the PATH in your index.php.",
|
||||
"Decrypt":
|
||||
"Decrypt",
|
||||
"Enter password":
|
||||
"Enter password",
|
||||
"Loading…": "Loading…",
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a>.":
|
||||
"In case this message never disappears please have a look at <a href=\"https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away\">this FAQ for information to troubleshoot</a> (in English)."
|
||||
}
|
||||
|
||||
5
js/jquery-1.11.3.js
vendored
5
js/jquery-1.11.3.js
vendored
File diff suppressed because one or more lines are too long
4
js/jquery-3.1.1.js
vendored
Normal file
4
js/jquery-3.1.1.js
vendored
Normal file
File diff suppressed because one or more lines are too long
105
js/privatebin.js
105
js/privatebin.js
@@ -6,7 +6,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -295,6 +295,7 @@ $(function() {
|
||||
/**
|
||||
* Convert all applicable characters to HTML entities.
|
||||
* From: https://github.com/janl/mustache.js/blob/master/mustache.js#L60
|
||||
* Also: https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
|
||||
*
|
||||
* @param string str
|
||||
* @return string escaped HTML
|
||||
@@ -328,7 +329,7 @@ $(function() {
|
||||
/**
|
||||
* supported languages, minus the built in 'en'
|
||||
*/
|
||||
supportedLanguages: ['de', 'fr', 'pl', 'sl', 'zh'],
|
||||
supportedLanguages: ['de', 'fr', 'it', 'pl', 'ru', 'sl', 'zh'],
|
||||
|
||||
/**
|
||||
* translate a string, alias for translate()
|
||||
@@ -413,7 +414,9 @@ $(function() {
|
||||
case 'zh':
|
||||
return (n > 1 ? 1 : 0);
|
||||
case 'pl':
|
||||
return (n === 1 ? 0 : n%10 >= 2 && n %10 <=4 && (n%100 < 10 || n%100 >= 20) ? 1 : 2);
|
||||
return (n === 1 ? 0 : (n%10 >= 2 && n %10 <=4 && (n%100 < 10 || n%100 >= 20) ? 1 : 2));
|
||||
case 'ru':
|
||||
return (n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2));
|
||||
// en, de
|
||||
default:
|
||||
return (n !== 1 ? 1 : 0);
|
||||
@@ -611,23 +614,26 @@ $(function() {
|
||||
},
|
||||
|
||||
/**
|
||||
* ask the user for the password and return it
|
||||
*
|
||||
* @throws error when dialog canceled
|
||||
* @return string password
|
||||
* ask the user for the password and set it
|
||||
*/
|
||||
requestPassword: function()
|
||||
{
|
||||
var password = prompt(i18n._('Please enter the password for this paste:'), '');
|
||||
if (password === null)
|
||||
{
|
||||
throw 'password prompt canceled';
|
||||
if (this.passwordModal.length === 0) {
|
||||
var password = prompt(i18n._('Please enter the password for this paste:'), '');
|
||||
if (password === null)
|
||||
{
|
||||
throw 'password prompt canceled';
|
||||
}
|
||||
if (password.length === 0)
|
||||
{
|
||||
this.requestPassword();
|
||||
} else {
|
||||
this.passwordInput.val(password);
|
||||
this.displayMessages();
|
||||
}
|
||||
} else {
|
||||
this.passwordModal.modal();
|
||||
}
|
||||
if (password.length === 0)
|
||||
{
|
||||
return this.requestPassword();
|
||||
}
|
||||
return password;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -652,6 +658,9 @@ $(function() {
|
||||
this.clearText.html(
|
||||
converter.makeHtml(text)
|
||||
);
|
||||
// add table classes from bootstrap css
|
||||
this.clearText.find('table').addClass('table-condensed table-bordered');
|
||||
|
||||
this.clearText.removeClass('hidden');
|
||||
}
|
||||
this.prettyMessage.addClass('hidden');
|
||||
@@ -688,14 +697,15 @@ $(function() {
|
||||
/**
|
||||
* Show decrypted text in the display area, including discussion (if open)
|
||||
*
|
||||
* @param string key : decryption key
|
||||
* @param object paste : paste object including comments to display (items = array with keys ('data','meta')
|
||||
* @param object paste (optional) object including comments to display (items = array with keys ('data','meta')
|
||||
*/
|
||||
displayMessages: function(key, paste)
|
||||
displayMessages: function(paste)
|
||||
{
|
||||
// Try to decrypt the paste.
|
||||
paste = paste || $.parseJSON(this.cipherData.text());
|
||||
var key = this.pageKey();
|
||||
var password = this.passwordInput.val();
|
||||
if (!this.prettyPrint.hasClass('prettyprinted')) {
|
||||
// Try to decrypt the paste.
|
||||
try
|
||||
{
|
||||
if (paste.attachment)
|
||||
@@ -705,7 +715,8 @@ $(function() {
|
||||
{
|
||||
if (password.length === 0)
|
||||
{
|
||||
password = this.requestPassword();
|
||||
this.requestPassword();
|
||||
return;
|
||||
}
|
||||
attachment = filter.decipher(key, password, paste.attachment);
|
||||
}
|
||||
@@ -740,8 +751,8 @@ $(function() {
|
||||
var cleartext = filter.decipher(key, password, paste.data);
|
||||
if (cleartext.length === 0 && password.length === 0 && !paste.attachment)
|
||||
{
|
||||
password = this.requestPassword();
|
||||
cleartext = filter.decipher(key, password, paste.data);
|
||||
this.requestPassword();
|
||||
return;
|
||||
}
|
||||
if (cleartext.length === 0 && !paste.attachment)
|
||||
{
|
||||
@@ -942,7 +953,7 @@ $(function() {
|
||||
{
|
||||
if (data.status === 0)
|
||||
{
|
||||
privatebin.displayMessages(privatebin.pageKey(), data);
|
||||
privatebin.displayMessages(data);
|
||||
}
|
||||
else if (data.status === 1)
|
||||
{
|
||||
@@ -1161,7 +1172,7 @@ $(function() {
|
||||
/**
|
||||
* Put the screen in "Existing paste" mode.
|
||||
*
|
||||
* @param boolean preview (optional) : tell if the preview tabs should be displayed, defaults to false.
|
||||
* @param boolean preview (optional) tell if the preview tabs should be displayed, defaults to false.
|
||||
*/
|
||||
stateExistingPaste: function(preview)
|
||||
{
|
||||
@@ -1269,7 +1280,7 @@ $(function() {
|
||||
// we use text/html instead of text/plain to avoid a bug when
|
||||
// reloading the raw text view (it reverts to type text/html)
|
||||
var newDoc = document.open('text/html', 'replace');
|
||||
newDoc.write('<pre>' + paste + '</pre>');
|
||||
newDoc.write('<pre>' + helper.htmlEntities(paste) + '</pre>');
|
||||
newDoc.close();
|
||||
},
|
||||
|
||||
@@ -1420,6 +1431,34 @@ $(function() {
|
||||
this.fileWrap.removeClass('hidden');
|
||||
},
|
||||
|
||||
/**
|
||||
* Focus on the modal password dialog.
|
||||
*/
|
||||
focusPasswordModal: function()
|
||||
{
|
||||
this.passwordDecrypt.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Decrypt using the password from the modal dialog.
|
||||
*/
|
||||
decryptPasswordModal: function()
|
||||
{
|
||||
this.passwordInput.val(this.passwordDecrypt.val());
|
||||
this.displayMessages();
|
||||
},
|
||||
|
||||
/**
|
||||
* Submit a password in the modal dialog.
|
||||
*
|
||||
* @param Event event
|
||||
*/
|
||||
submitPasswordModal: function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
this.passwordModal.modal('hide');
|
||||
},
|
||||
|
||||
/**
|
||||
* Display an error message
|
||||
* (We use the same function for paste and reply to comments)
|
||||
@@ -1507,6 +1546,11 @@ $(function() {
|
||||
|
||||
// page template drop down
|
||||
$('#language select option').click($.proxy(this.setLanguage, this));
|
||||
|
||||
// handle modal password request on decryption
|
||||
this.passwordModal.on('shown.bs.modal', $.proxy(this.focusPasswordModal, this));
|
||||
this.passwordModal.on('hidden.bs.modal', $.proxy(this.decryptPasswordModal, this));
|
||||
this.passwordForm.submit($.proxy(this.submitPasswordModal, this));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1543,6 +1587,9 @@ $(function() {
|
||||
this.openDiscussion = $('#opendiscussion');
|
||||
this.password = $('#password');
|
||||
this.passwordInput = $('#passwordinput');
|
||||
this.passwordModal = $('#passwordmodal');
|
||||
this.passwordForm = $('#passwordform');
|
||||
this.passwordDecrypt = $('#passworddecrypt');
|
||||
this.pasteResult = $('#pasteresult');
|
||||
this.prettyMessage = $('#prettymessage');
|
||||
this.prettyPrint = $('#prettyprint');
|
||||
@@ -1573,13 +1620,9 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
// List of messages to display.
|
||||
var data = $.parseJSON(this.cipherData.text());
|
||||
|
||||
// Show proper elements on screen.
|
||||
this.stateExistingPaste();
|
||||
|
||||
this.displayMessages(this.pageKey(), data);
|
||||
this.displayMessages();
|
||||
}
|
||||
// Display error message from php code.
|
||||
else if (this.errorMessage.text().length > 1)
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\I18n;
|
||||
use Exception;
|
||||
use PDO;
|
||||
|
||||
@@ -37,51 +36,51 @@ class Configuration
|
||||
*/
|
||||
private static $_defaults = array(
|
||||
'main' => array(
|
||||
'discussion' => true,
|
||||
'opendiscussion' => false,
|
||||
'password' => true,
|
||||
'fileupload' => false,
|
||||
'discussion' => true,
|
||||
'opendiscussion' => false,
|
||||
'password' => true,
|
||||
'fileupload' => false,
|
||||
'burnafterreadingselected' => false,
|
||||
'defaultformatter' => 'plaintext',
|
||||
'syntaxhighlightingtheme' => null,
|
||||
'sizelimit' => 2097152,
|
||||
'template' => 'bootstrap',
|
||||
'notice' => '',
|
||||
'languageselection' => false,
|
||||
'languagedefault' => '',
|
||||
'urlshortener' => '',
|
||||
'icon' => 'identicon',
|
||||
'cspheader' => 'default-src \'none\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:;',
|
||||
'zerobincompatibility' => false,
|
||||
'defaultformatter' => 'plaintext',
|
||||
'syntaxhighlightingtheme' => null,
|
||||
'sizelimit' => 2097152,
|
||||
'template' => 'bootstrap',
|
||||
'notice' => '',
|
||||
'languageselection' => false,
|
||||
'languagedefault' => '',
|
||||
'urlshortener' => '',
|
||||
'icon' => 'identicon',
|
||||
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; referrer no-referrer;',
|
||||
'zerobincompatibility' => false,
|
||||
),
|
||||
'expire' => array(
|
||||
'default' => '1week',
|
||||
'clone' => true,
|
||||
'clone' => true,
|
||||
),
|
||||
'expire_options' => array(
|
||||
'5min' => 300,
|
||||
'10min' => 600,
|
||||
'1hour' => 3600,
|
||||
'1day' => 86400,
|
||||
'1week' => 604800,
|
||||
'5min' => 300,
|
||||
'10min' => 600,
|
||||
'1hour' => 3600,
|
||||
'1day' => 86400,
|
||||
'1week' => 604800,
|
||||
'1month' => 2592000,
|
||||
'1year' => 31536000,
|
||||
'never' => 0,
|
||||
'1year' => 31536000,
|
||||
'never' => 0,
|
||||
),
|
||||
'formatter_options' => array(
|
||||
'plaintext' => 'Plain Text',
|
||||
'plaintext' => 'Plain Text',
|
||||
'syntaxhighlighting' => 'Source Code',
|
||||
'markdown' => 'Markdown',
|
||||
'markdown' => 'Markdown',
|
||||
),
|
||||
'traffic' => array(
|
||||
'limit' => 10,
|
||||
'limit' => 10,
|
||||
'header' => null,
|
||||
'dir' => 'data',
|
||||
'dir' => 'data',
|
||||
),
|
||||
'purge' => array(
|
||||
'limit' => 300,
|
||||
'limit' => 300,
|
||||
'batchsize' => 10,
|
||||
'dir' => 'data',
|
||||
'dir' => 'data',
|
||||
),
|
||||
'model' => array(
|
||||
'class' => 'Filesystem',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
use PrivateBin\PrivateBin;
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PrivateBin\PrivateBin;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@@ -417,7 +417,7 @@ class Database extends AbstractData
|
||||
$pastes = array();
|
||||
$rows = self::_select(
|
||||
'SELECT dataid FROM ' . self::_sanitizeIdentifier('paste') .
|
||||
' WHERE expiredate < ? LIMIT ?', array(time(), $batchsize)
|
||||
' WHERE expiredate < ? AND expiredate != ? LIMIT ?', array(time(), 0, $batchsize)
|
||||
);
|
||||
if (count($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
@@ -701,10 +701,11 @@ class Database extends AbstractData
|
||||
);
|
||||
// no break, continue with updates for 0.22
|
||||
case '0.22':
|
||||
case '1.0':
|
||||
self::_exec(
|
||||
'UPDATE ' . self::_sanitizeIdentifier('config') .
|
||||
' SET value = ? WHERE id = ?',
|
||||
array('1.0', 'VERSION')
|
||||
array(PrivateBin::VERSION, 'VERSION')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Data;
|
||||
|
||||
use PrivateBin\Model\Paste;
|
||||
use PrivateBin\Json;
|
||||
use PrivateBin\Model\Paste;
|
||||
|
||||
/**
|
||||
* Filesystem
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\I18n;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
||||
10
lib/I18n.php
10
lib/I18n.php
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
@@ -296,12 +296,14 @@ class I18n
|
||||
switch (self::$_language) {
|
||||
case 'fr':
|
||||
case 'zh':
|
||||
return ($n > 1 ? 1 : 0);
|
||||
return $n > 1 ? 1 : 0;
|
||||
case 'pl':
|
||||
return ($n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
case 'ru':
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
// en, de
|
||||
default:
|
||||
return ($n != 1 ? 1 : 0);
|
||||
return $n != 1 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\Data;
|
||||
use PrivateBin\Model\Paste;
|
||||
use PrivateBin\Persistence\PurgeLimiter;
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use Exception;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\AbstractData;
|
||||
use PrivateBin\Sjcl;
|
||||
use Exception;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use PrivateBin\Sjcl;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
use Identicon\Identicon;
|
||||
use Exception;
|
||||
use Identicon\Identicon;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Sjcl;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
|
||||
/**
|
||||
* Comment
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Model;
|
||||
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Sjcl;
|
||||
use Exception;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Sjcl;
|
||||
|
||||
/**
|
||||
* Paste
|
||||
@@ -307,7 +307,6 @@ class Paste extends AbstractModel
|
||||
$this->_data->meta->burnafterreading === true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if paste has discussions enabled.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin\Persistence;
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use Exception;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
|
||||
/**
|
||||
* PrivateBin
|
||||
@@ -27,7 +28,7 @@ class PrivateBin
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const VERSION = '1.0';
|
||||
const VERSION = '1.1';
|
||||
|
||||
/**
|
||||
* show the same error message if the paste expired or does not exist
|
||||
@@ -183,6 +184,7 @@ class PrivateBin
|
||||
$this->_request = new Request;
|
||||
$this->_urlBase = array_key_exists('REQUEST_URI', $_SERVER) ?
|
||||
htmlspecialchars($_SERVER['REQUEST_URI']) : '/';
|
||||
ServerSalt::setPath($this->_conf->getKey('dir', 'traffic'));
|
||||
|
||||
// set default language
|
||||
$lang = $this->_conf->getKey('languagedefault');
|
||||
@@ -401,12 +403,15 @@ class PrivateBin
|
||||
{
|
||||
// set headers to disable caching
|
||||
$time = gmdate('D, d M Y H:i:s \G\M\T');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: no-store, no-cache, no-transform, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: ' . $time);
|
||||
header('Last-Modified: ' . $time);
|
||||
header('Vary: Accept');
|
||||
header('Content-Security-Policy: ' . $this->_conf->getKey('cspheader'));
|
||||
header('X-Xss-Protection: 1; mode=block');
|
||||
header('X-Frame-Options: DENY');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
|
||||
// label all the expiration options
|
||||
$expire = array();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
@@ -31,7 +31,7 @@ class Sjcl
|
||||
*/
|
||||
public static function isValid($encoded)
|
||||
{
|
||||
$accepted_keys = array('iv','v','iter','ks','ts','mode','adata','cipher','salt','ct');
|
||||
$accepted_keys = array('iv', 'v', 'iter', 'ks', 'ts', 'mode', 'adata', 'cipher', 'salt', 'ct');
|
||||
|
||||
// Make sure content is valid json
|
||||
$decoded = json_decode($encoded);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://github.com/PrivateBin/PrivateBin
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 1.0
|
||||
* @version 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @link http://sebsauvage.net/wiki/doku.php?id=php:vizhash_gd
|
||||
* @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
|
||||
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
|
||||
* @version 0.0.5 beta PrivateBin 1.0
|
||||
* @version 0.0.5 beta PrivateBin 1.1
|
||||
*/
|
||||
|
||||
namespace PrivateBin;
|
||||
@@ -23,7 +23,6 @@ namespace PrivateBin;
|
||||
* echo $data;
|
||||
* exit;
|
||||
*/
|
||||
|
||||
class Vizhash16x16
|
||||
{
|
||||
/**
|
||||
@@ -105,7 +104,7 @@ class Vizhash16x16
|
||||
$op = 'v';
|
||||
if (($this->getInt() % 2) == 0) {
|
||||
$op = 'h';
|
||||
};
|
||||
}
|
||||
$image = $this->degrade($image, $op, array($r0, $g0, $b0), array(0, 0, 0));
|
||||
|
||||
for ($i = 0; $i < 7; ++$i) {
|
||||
@@ -189,7 +188,7 @@ class Vizhash16x16
|
||||
$diffs = array(
|
||||
(($color2[0] - $color1[0]) / $size),
|
||||
(($color2[1] - $color1[1]) / $size),
|
||||
(($color2[2] - $color1[2]) / $size)
|
||||
(($color2[2] - $color1[2]) / $size),
|
||||
);
|
||||
for ($i = 0; $i < $size; ++$i) {
|
||||
$r = $color1[0] + ($diffs[0] * $i);
|
||||
@@ -217,20 +216,20 @@ class Vizhash16x16
|
||||
{
|
||||
switch ($action % 7) {
|
||||
case 0:
|
||||
ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
imagefilledrectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
imagefilledellipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
|
||||
break;
|
||||
case 3:
|
||||
$points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY());
|
||||
ImageFilledPolygon($image, $points, 4, $color);
|
||||
imagefilledpolygon($image, $points, 4, $color);
|
||||
break;
|
||||
default:
|
||||
$start = $this->getInt() * 360 / 256;
|
||||
$end = $start + $this->getInt() * 180 / 256;
|
||||
ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
|
||||
imagefilledarc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use PrivateBin\I18n;
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-3.3.5.css" />
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-theme-3.3.5.css" />
|
||||
@@ -23,7 +24,7 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -51,7 +52,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -65,6 +66,21 @@ endif;
|
||||
<meta name="theme-color" content="#ffe57e" />
|
||||
</head>
|
||||
<body role="document" class="navbar-spacing">
|
||||
<div id="passwordmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<form id="passwordform" role="form">
|
||||
<div class="form-group">
|
||||
<label for="passworddecrypt"><span class="glyphicon glyphicon-eye-open"></span> <?php echo I18n::_('Please enter the password for this paste:') ?></label>
|
||||
<input id="passworddecrypt" type="password" class="form-control" placeholder="<?php echo I18n::_('Enter password') ?>" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> <?php echo I18n::_('Decrypt') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
@@ -328,6 +344,12 @@ endif;
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="container">
|
||||
<div class="row">
|
||||
<h4 class="col-md-5 col-xs-8"><?php echo I18n::_('PrivateBin'); ?> <small>- <?php echo I18n::_('Because ignorance is bliss'); ?></small></h4>
|
||||
|
||||
@@ -7,6 +7,7 @@ use PrivateBin\I18n;
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-theme-3.3.5.css" />
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/darkstrap-0.9.3.css" />
|
||||
@@ -23,7 +24,7 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -51,7 +52,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -65,6 +66,21 @@ endif;
|
||||
<meta name="theme-color" content="#ffe57e" />
|
||||
</head>
|
||||
<body role="document">
|
||||
<div id="passwordmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<form id="passwordform" role="form">
|
||||
<div class="form-group">
|
||||
<label for="passworddecrypt"><span class="glyphicon glyphicon-eye-open"></span> <?php echo I18n::_('Please enter the password for this paste:') ?></label>
|
||||
<input id="passworddecrypt" type="password" class="form-control" placeholder="<?php echo I18n::_('Enter password') ?>" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> <?php echo I18n::_('Decrypt') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
@@ -322,6 +338,12 @@ endif;
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="container">
|
||||
<div class="row">
|
||||
<h4 class="col-md-5 col-xs-8"><?php echo I18n::_('PrivateBin'); ?> <small>- <?php echo I18n::_('Because ignorance is bliss'); ?></small></h4>
|
||||
|
||||
@@ -7,6 +7,7 @@ use PrivateBin\I18n;
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-theme-3.3.5.css" />
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/darkstrap-0.9.3.css" />
|
||||
@@ -23,7 +24,8 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<noscript><link type="text/css" rel="stylesheet" href="css/noscript.css" /></noscript>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -51,7 +53,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -65,6 +67,21 @@ endif;
|
||||
<meta name="theme-color" content="#ffe57e" />
|
||||
</head>
|
||||
<body role="document">
|
||||
<div id="passwordmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<form id="passwordform" role="form">
|
||||
<div class="form-group">
|
||||
<label for="passworddecrypt"><span class="glyphicon glyphicon-eye-open"></span> <?php echo I18n::_('Please enter the password for this paste:') ?></label>
|
||||
<input id="passworddecrypt" type="password" class="form-control" placeholder="<?php echo I18n::_('Enter password') ?>" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> <?php echo I18n::_('Decrypt') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-inverse navbar-static-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
@@ -322,6 +339,12 @@ endif;
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="container">
|
||||
<div class="row">
|
||||
<h4 class="col-md-5 col-xs-8"><?php echo I18n::_('PrivateBin'); ?> <small>- <?php echo I18n::_('Because ignorance is bliss'); ?></small></h4>
|
||||
|
||||
@@ -7,6 +7,7 @@ use PrivateBin\I18n;
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-3.3.5.css" />
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-theme-3.3.5.css" />
|
||||
@@ -23,7 +24,7 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -51,7 +52,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -65,6 +66,21 @@ endif;
|
||||
<meta name="theme-color" content="#ffe57e" />
|
||||
</head>
|
||||
<body role="document">
|
||||
<div id="passwordmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<form id="passwordform" role="form">
|
||||
<div class="form-group">
|
||||
<label for="passworddecrypt"><span class="glyphicon glyphicon-eye-open"></span> <?php echo I18n::_('Please enter the password for this paste:') ?></label>
|
||||
<input id="passworddecrypt" type="password" class="form-control" placeholder="<?php echo I18n::_('Enter password') ?>" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> <?php echo I18n::_('Decrypt') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-default navbar-static-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
@@ -322,6 +338,12 @@ endif;
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="container">
|
||||
<div class="row">
|
||||
<h4 class="col-md-5 col-xs-8"><?php echo I18n::_('PrivateBin'); ?> <small>- <?php echo I18n::_('Because ignorance is bliss'); ?></small></h4>
|
||||
|
||||
@@ -7,6 +7,7 @@ use PrivateBin\I18n;
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-3.3.5.css" />
|
||||
<link type="text/css" rel="stylesheet" href="css/bootstrap/bootstrap-theme-3.3.5.css" />
|
||||
@@ -23,7 +24,8 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<noscript><link type="text/css" rel="stylesheet" href="css/noscript.css" /></noscript>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -51,7 +53,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -65,6 +67,21 @@ endif;
|
||||
<meta name="theme-color" content="#ffe57e" />
|
||||
</head>
|
||||
<body role="document">
|
||||
<div id="passwordmodal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<form id="passwordform" role="form">
|
||||
<div class="form-group">
|
||||
<label for="passworddecrypt"><span class="glyphicon glyphicon-eye-open"></span> <?php echo I18n::_('Please enter the password for this paste:') ?></label>
|
||||
<input id="passworddecrypt" type="password" class="form-control" placeholder="<?php echo I18n::_('Enter password') ?>" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> <?php echo I18n::_('Decrypt') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-default navbar-static-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
@@ -278,7 +295,7 @@ if (!strlen($ERROR)):
|
||||
?>hidden <?php
|
||||
endif;
|
||||
?>alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span> <?php echo htmlspecialchars($ERROR); ?></div>
|
||||
<noscript><div id="noscript" role="alert" class="nonworking alert alert-warning"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <?php echo I18n::_('Javascript is required for PrivateBin to work.<br />Sorry for the inconvenience.'); ?></div></noscript>
|
||||
<noscript><div id="noscript" role="alert" class="nonworking alert alert-warning"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <?php echo I18n::_('JavaScript is required for PrivateBin to work.<br />Sorry for the inconvenience.'); ?></div></noscript>
|
||||
<div id="oldienotice" role="alert" class="hidden nonworking alert alert-danger"><span class="glyphicon glyphicon-alert" aria-hidden="true"></span> <?php echo I18n::_('PrivateBin requires a modern browser to work.'); ?></div>
|
||||
<div id="ienotice" role="alert" class="hidden alert alert-warning"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> <?php echo I18n::_('Still using Internet Explorer? Do yourself a favor, switch to a modern browser:'), PHP_EOL; ?>
|
||||
<a href="https://www.mozilla.org/firefox/">Firefox</a>,
|
||||
@@ -322,6 +339,12 @@ endif;
|
||||
<div id="comments"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="container">
|
||||
<div class="row">
|
||||
<h4 class="col-md-5 col-xs-8"><?php echo I18n::_('PrivateBin'); ?> <small>- <?php echo I18n::_('Because ignorance is bliss'); ?></small></h4>
|
||||
|
||||
11
tpl/page.php
11
tpl/page.php
@@ -5,6 +5,7 @@ use PrivateBin\I18n;
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title><?php echo I18n::_('PrivateBin'); ?></title>
|
||||
<link type="text/css" rel="stylesheet" href="css/privatebin.css?<?php echo rawurlencode($VERSION); ?>" />
|
||||
<?php
|
||||
@@ -19,7 +20,7 @@ if ($SYNTAXHIGHLIGHTING):
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.11.3.js" integrity="sha512-xAERw8wHVOkM9x9y9/FvQ7g1t+gIQj39mfkN1Rd1OLcC5k/x2e6NO8hq6qEbb3oO+CYYTjVLFiFYg5/7ddF0zA==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/sjcl-1.0.4.js" integrity="sha512-BqVQ8GgWfMCcdsDuP6Ggm1BV7+mmoWH3PC4UqcYpEKSdEq1rthy6NUsa6gu5sydewbi/ilI3E3ohdCxlPPF9ww==" crossorigin="anonymous"></script>
|
||||
<?php
|
||||
if ($ZEROBINCOMPATIBILITY):
|
||||
@@ -46,7 +47,7 @@ if ($MARKDOWN):
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-Jx4qD49amdzpNe9FLtxLO84Xt5LZeQ2PGaM0I9UCS2Kr4xhrnFyvP+0hrLIMgDTwjWFDpTSCoDHuj0SHzuqXuQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-q/2ZUVaS+RVZEaIzIufFOAbhkq2/hYXix2f/Dt3+MxWouGt7vxB3rIU3jkn3f7VHNBnK/wL3KjKL+xZuaaKPVQ==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
@@ -226,5 +227,11 @@ endif;
|
||||
</div>
|
||||
</section>
|
||||
<div id="cipherdata" class="hidden"><?php echo htmlspecialchars($CIPHERDATA, ENT_NOQUOTES); ?></div>
|
||||
<section class="container">
|
||||
<div id="noscript" role="alert" class="nonworking alert alert-info noscript-hide"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true">
|
||||
<span> <?php echo I18n::_('Loading…'); ?></span><br>
|
||||
<span class="small"><?php echo I18n::_('In case this message never disappears please have a look at <a href="https://github.com/PrivateBin/PrivateBin/wiki/FAQ#why-does-not-the-loading-message-go-away">this FAQ for information to troubleshoot</a>.'); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -36,12 +36,12 @@ class Helper
|
||||
* @var array
|
||||
*/
|
||||
private static $paste = array(
|
||||
'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}',
|
||||
'attachment' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}',
|
||||
'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}',
|
||||
'attachment' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}',
|
||||
'attachmentname' => '{"iv":"76MkAtOGC4oFogX/aSMxRA","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"b6Ae/U1xJdsX/+lATud4sQ"}',
|
||||
'meta' => array(
|
||||
'formatter' => 'plaintext',
|
||||
'postdate' => 1344803344,
|
||||
'meta' => array(
|
||||
'formatter' => 'plaintext',
|
||||
'postdate' => 1344803344,
|
||||
'opendiscussion' => true,
|
||||
),
|
||||
);
|
||||
@@ -62,7 +62,7 @@ class Helper
|
||||
'data' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}',
|
||||
'meta' => array(
|
||||
'nickname' => '{"iv":"76MkAtOGC4oFogX/aSMxRA","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"b6Ae/U1xJdsX/+lATud4sQ"}',
|
||||
'vizhash' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGUlEQVQokWOsl5/94983CNKQMjnxaOePf98MeKwPfNjkLZ3AgARab6b9+PeNEVnDj3/ff/z7ZiHnzsDA8Pv7H2TVPJw8EAYLAwb48OaVgIgYKycLsrYv378wMDB8//qdCVMDRA9EKSsnCwRBxNsepaLboMFlyMDAICAi9uHNK24GITQ/MDAwoNhgIGMLtwGrzegaLjw5jMz9+vUdnN17uwDCQDhJgk0O07yvX9+teDX1x79v6DYIsIjgcgMaYGFgYOBg4kJx2JejkAiBxAw+PzAwMNz4dp6wDXDw4MdNNOl0rWYsNkD89OLXI/xmo9sgzatJjAYmBgYGDiauD3/ePP18nVgb4MF89+M5ZX6js293wUMpnr8KTQMAxsCJnJ30apMAAAAASUVORK5CYII=',
|
||||
'vizhash' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGUlEQVQokWOsl5/94983CNKQMjnxaOePf98MeKwPfNjkLZ3AgARab6b9+PeNEVnDj3/ff/z7ZiHnzsDA8Pv7H2TVPJw8EAYLAwb48OaVgIgYKycLsrYv378wMDB8//qdCVMDRA9EKSsnCwRBxNsepaLboMFlyMDAICAi9uHNK24GITQ/MDAwoNhgIGMLtwGrzegaLjw5jMz9+vUdnN17uwDCQDhJgk0O07yvX9+teDX1x79v6DYIsIjgcgMaYGFgYOBg4kJx2JejkAiBxAw+PzAwMNz4dp6wDXDw4MdNNOl0rWYsNkD89OLXI/xmo9sgzatJjAYmBgYGDiauD3/ePP18nVgb4MF89+M5ZX6js293wUMpnr8KTQMAxsCJnJ30apMAAAAASUVORK5CYII=',
|
||||
'postdate' => 1344803528,
|
||||
),
|
||||
);
|
||||
@@ -103,9 +103,9 @@ class Helper
|
||||
*/
|
||||
public static function getPasteWithAttachment($meta = array())
|
||||
{
|
||||
$example = self::$paste;
|
||||
$example = self::$paste;
|
||||
$example['meta']['salt'] = ServerSalt::generate();
|
||||
$example['meta'] = array_merge($example['meta'], $meta);
|
||||
$example['meta'] = array_merge($example['meta'], $meta);
|
||||
return $example;
|
||||
}
|
||||
|
||||
@@ -122,10 +122,10 @@ class Helper
|
||||
if (count($meta)) {
|
||||
$example['meta'] = $meta;
|
||||
}
|
||||
$example['comments'] = array();
|
||||
$example['comment_count'] = 0;
|
||||
$example['comments'] = array();
|
||||
$example['comment_count'] = 0;
|
||||
$example['comment_offset'] = 0;
|
||||
$example['@context'] = 'js/paste.jsonld';
|
||||
$example['@context'] = 'js/paste.jsonld';
|
||||
return json_encode($example);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ class Helper
|
||||
*/
|
||||
public static function getComment($meta = array())
|
||||
{
|
||||
$example = self::$comment;
|
||||
$example = self::$comment;
|
||||
$example['meta'] = array_merge($example['meta'], $meta);
|
||||
return $example;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class Helper
|
||||
*/
|
||||
public static function getCommentPost($meta = array())
|
||||
{
|
||||
$example = self::getComment($meta);
|
||||
$example = self::getComment($meta);
|
||||
$example['nickname'] = $example['meta']['nickname'];
|
||||
unset($example['meta']['nickname']);
|
||||
return $example;
|
||||
|
||||
@@ -12,11 +12,11 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
Helper::confBackup();
|
||||
$this->_options = configuration::getDefaults();
|
||||
$this->_options = configuration::getDefaults();
|
||||
$this->_options['model_options']['dir'] = PATH . $this->_options['model_options']['dir'];
|
||||
$this->_options['traffic']['dir'] = PATH . $this->_options['traffic']['dir'];
|
||||
$this->_options['purge']['dir'] = PATH . $this->_options['purge']['dir'];
|
||||
$this->_minimalConfig = '[main]' . PHP_EOL . '[model]' . PHP_EOL . '[model_options]';
|
||||
$this->_options['traffic']['dir'] = PATH . $this->_options['traffic']['dir'];
|
||||
$this->_options['purge']['dir'] = PATH . $this->_options['purge']['dir'];
|
||||
$this->_minimalConfig = '[main]' . PHP_EOL . '[model]' . PHP_EOL . '[model_options]';
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@@ -94,19 +94,19 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testHandleWrongTypes()
|
||||
{
|
||||
$original_options = $this->_options;
|
||||
$original_options = $this->_options;
|
||||
$original_options['main']['syntaxhighlightingtheme'] = 'foo';
|
||||
$options = $original_options;
|
||||
$options['main']['discussion'] = 'true';
|
||||
$options['main']['opendiscussion'] = 0;
|
||||
$options['main']['password'] = -1; // evaluates to TRUE
|
||||
$options['main']['fileupload'] = 'false';
|
||||
$options['expire_options']['foo'] = 'bar';
|
||||
$options['formatter_options'][] = 'foo';
|
||||
$options = $original_options;
|
||||
$options['main']['discussion'] = 'true';
|
||||
$options['main']['opendiscussion'] = 0;
|
||||
$options['main']['password'] = -1; // evaluates to TRUE
|
||||
$options['main']['fileupload'] = 'false';
|
||||
$options['expire_options']['foo'] = 'bar';
|
||||
$options['formatter_options'][] = 'foo';
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$conf = new Configuration;
|
||||
$conf = new Configuration;
|
||||
$original_options['expire_options']['foo'] = intval('bar');
|
||||
$original_options['formatter_options'][0] = 'foo';
|
||||
$original_options['formatter_options'][0] = 'foo';
|
||||
$this->assertEquals($original_options, $conf->get(), 'incorrect types are corrected');
|
||||
}
|
||||
|
||||
@@ -117,14 +117,14 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
unset($options['expire_options']['1year']);
|
||||
unset($options['expire_options']['never']);
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$conf = new Configuration;
|
||||
$conf = new Configuration;
|
||||
$options['expire']['default'] = '5min';
|
||||
$this->assertEquals($options, $conf->get(), 'not overriding "missing" subkeys');
|
||||
}
|
||||
|
||||
public function testHandlePreRenameConfig()
|
||||
{
|
||||
$options = $this->_options;
|
||||
$options = $this->_options;
|
||||
$options['model']['class'] = 'zerobin_data';
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$conf = new Configuration;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
* DANGER: Too many options/settings and too high max iteration setting may trigger
|
||||
* a fork bomb. Please save your work before executing this script.
|
||||
*/
|
||||
|
||||
include 'Bootstrap.php';
|
||||
|
||||
$vrd = array('view', 'read', 'delete');
|
||||
@@ -19,85 +18,85 @@ new ConfigurationTestGenerator(array(
|
||||
'main/discussion' => array(
|
||||
array(
|
||||
'setting' => true,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => $vrd),
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
'#<div[^>]*id="opendisc"[^>]*>#',
|
||||
'$content',
|
||||
'outputs enabled discussion correctly'
|
||||
'outputs enabled discussion correctly',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
|
||||
'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when discussions are enabled, but invalid flag posted, fail to create paste'
|
||||
'when discussions are enabled, but invalid flag posted, fail to create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
|
||||
'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'),
|
||||
'type' => 'False',
|
||||
'args' => array(
|
||||
'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'),
|
||||
'type' => 'False',
|
||||
'args' => array(
|
||||
'$this->_model->exists(Helper::getPasteId())',
|
||||
'when discussions are enabled, but invalid flag posted, paste is not created'
|
||||
'when discussions are enabled, but invalid flag posted, paste is not created',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vcud
|
||||
'affects' => $vcud,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
'#<div[^>]*id="opendisc"[^>]*>#',
|
||||
'$content',
|
||||
'outputs disabled discussion correctly'
|
||||
'outputs disabled discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/opendiscussion' => array(
|
||||
array(
|
||||
'setting' => true,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('main/discussion' => true),
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
'$content',
|
||||
'outputs checked discussion correctly'
|
||||
'outputs checked discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('main/discussion' => true),
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
'$content',
|
||||
'outputs unchecked discussion correctly'
|
||||
'outputs unchecked discussion correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/burnafterreadingselected' => array(
|
||||
array(
|
||||
'setting' => true,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
@@ -110,7 +109,7 @@ new ConfigurationTestGenerator(array(
|
||||
'affects' => array('view'),
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
@@ -126,37 +125,37 @@ new ConfigurationTestGenerator(array(
|
||||
'main/password' => array(
|
||||
array(
|
||||
'setting' => true,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
'#<div[^>]*id="password"[^>]*>#',
|
||||
'$content',
|
||||
'outputs password input correctly'
|
||||
'outputs password input correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
), array(
|
||||
'setting' => false,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('main/discussion' => true),
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
'#<div[^>]*id="password"[^>]*>#',
|
||||
'$content',
|
||||
'removes password input correctly'
|
||||
'removes password input correctly',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => $vrd
|
||||
'affects' => $vrd,
|
||||
),
|
||||
),
|
||||
'main/template' => array(
|
||||
array(
|
||||
'setting' => 'page',
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'RegExp',
|
||||
'args' => array(
|
||||
@@ -176,7 +175,7 @@ new ConfigurationTestGenerator(array(
|
||||
'affects' => $vrd,
|
||||
), array(
|
||||
'setting' => 'bootstrap',
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'type' => 'NotRegExp',
|
||||
'args' => array(
|
||||
@@ -199,102 +198,102 @@ new ConfigurationTestGenerator(array(
|
||||
'main/sizelimit' => array(
|
||||
array(
|
||||
'setting' => 10,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when sizelimit limit exceeded, fail to create paste'
|
||||
'when sizelimit limit exceeded, fail to create paste',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 2097152,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true),
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when sizelimit limit is not reached, successfully create paste'
|
||||
'when sizelimit limit is not reached, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true),
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when sizelimit limit is not reached, paste exists after posting data'
|
||||
'when sizelimit limit is not reached, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
),
|
||||
),
|
||||
'traffic/limit' => array(
|
||||
array(
|
||||
'setting' => 0,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when traffic limit is disabled, successfully create paste'
|
||||
'when traffic limit is disabled, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when traffic limit is disabled, paste exists after posting data'
|
||||
'when traffic limit is disabled, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 10,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => array('create')),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
1,
|
||||
'$response["status"]',
|
||||
'when traffic limit is on and we do not wait, fail to create paste'
|
||||
'when traffic limit is on and we do not wait, fail to create paste',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
), array(
|
||||
'setting' => 2,
|
||||
'tests' => array(
|
||||
'tests' => array(
|
||||
array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'Equals',
|
||||
'args' => array(
|
||||
0,
|
||||
'$response["status"]',
|
||||
'when traffic limit is on and we wait, successfully create paste'
|
||||
'when traffic limit is on and we wait, successfully create paste',
|
||||
),
|
||||
), array(
|
||||
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'settings' => array('sleep(3)'),
|
||||
'type' => 'True',
|
||||
'args' => array(
|
||||
'$this->_model->exists($response["id"])',
|
||||
'when traffic limit is on and we wait, paste exists after posting data'
|
||||
'when traffic limit is on and we wait, paste exists after posting data',
|
||||
),
|
||||
),
|
||||
),
|
||||
'affects' => array('create')
|
||||
'affects' => array('create'),
|
||||
),
|
||||
),
|
||||
));
|
||||
@@ -325,7 +324,7 @@ class ConfigurationTestGenerator
|
||||
* @var array
|
||||
*/
|
||||
private $_configurations = array(
|
||||
array('options' => array(), 'tests' => array(), 'affects' => array())
|
||||
array('options' => array(), 'tests' => array(), 'affects' => array()),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -346,10 +345,10 @@ class ConfigurationTestGenerator
|
||||
private function _writeConfigurationTest()
|
||||
{
|
||||
$defaultOptions = parse_ini_file(CONF, true);
|
||||
$code = $this->_getHeader();
|
||||
$code = $this->_getHeader();
|
||||
foreach ($this->_configurations as $key => $conf) {
|
||||
$fullOptions = array_replace_recursive($defaultOptions, $conf['options']);
|
||||
$options = Helper::varExportMin($fullOptions, true);
|
||||
$options = Helper::varExportMin($fullOptions, true);
|
||||
foreach ($conf['affects'] as $step) {
|
||||
$testCode = $preCode = array();
|
||||
foreach ($conf['tests'] as $tests) {
|
||||
@@ -470,7 +469,7 @@ EOT;
|
||||
private function _getFunction($step, $key, &$options, $preCode, $testCode)
|
||||
{
|
||||
if (count($testCode) == 0) {
|
||||
echo "skipping creation of test$step$key, no valid tests found for configuration: $options". PHP_EOL;
|
||||
echo "skipping creation of test$step$key, no valid tests found for configuration: $options" . PHP_EOL;
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -593,7 +592,7 @@ EOT;
|
||||
|
||||
// create clones for each of the other settings
|
||||
while ($setting = next($settings)) {
|
||||
$clone = $this->_configurations[$c];
|
||||
$clone = $this->_configurations[$c];
|
||||
$this->_configurations[] = $this->_addSetting($clone, $setting, $section, $option);
|
||||
}
|
||||
reset($settings);
|
||||
@@ -626,7 +625,7 @@ EOT;
|
||||
throw new Exception("Endless loop or error in options detected: option '$option' already exists with setting '$val' in one of the configurations!");
|
||||
}
|
||||
$configuration['options'][$section][$option] = $setting['setting'];
|
||||
$configuration['tests'][$option] = array($setting['tests'], $setting['affects']);
|
||||
$configuration['tests'][$option] = array($setting['tests'], $setting['affects']);
|
||||
foreach ($setting['affects'] as $affects) {
|
||||
if (!in_array($affects, $configuration['affects'])) {
|
||||
$configuration['affects'][] = $affects;
|
||||
|
||||
@@ -19,7 +19,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Database::getInstance($this->_options);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
|
||||
$this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()) !== false, 'store comment');
|
||||
$this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it');
|
||||
$comment = json_decode(json_encode(Helper::getComment()));
|
||||
$comment->id = Helper::getCommentId();
|
||||
$comment = json_decode(json_encode(Helper::getComment()));
|
||||
$comment->id = Helper::getCommentId();
|
||||
$comment->parentid = Helper::getPasteId();
|
||||
$this->assertEquals(
|
||||
array($comment->meta->postdate => $comment),
|
||||
@@ -65,10 +65,10 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
public function testDatabaseBasedAttachmentStoreWorks()
|
||||
{
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['burnafterreading'] = $original['meta']['burnafterreading'] = true;
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste['meta']['attachmentname'] = $paste['attachmentname'];
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste['meta']['attachmentname'] = $paste['attachmentname'];
|
||||
unset($paste['attachment'], $paste['attachmentname']);
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
|
||||
$this->assertTrue($this->_model->create(Helper::getPasteId(), $paste), 'store new paste');
|
||||
@@ -77,19 +77,24 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(json_decode(json_encode($original)), $this->_model->read(Helper::getPasteId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* pastes a-g are expired and should get deleted, x never expires and y-z expire in an hour
|
||||
*/
|
||||
public function testPurge()
|
||||
{
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
$expired = Helper::getPaste(array('expire_date' => 1344803344));
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$this->_model->delete($ids[$key]);
|
||||
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
if (in_array($key, array('y', 'z'))) {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");
|
||||
} elseif ($key === 'x') {
|
||||
$this->assertTrue($this->_model->create($ids[$key], Helper::getPaste()), "store $key paste");
|
||||
} else {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste");
|
||||
}
|
||||
@@ -113,7 +118,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -124,7 +129,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -135,7 +140,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -146,7 +151,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -157,7 +162,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -168,7 +173,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -179,7 +184,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
public function testGetFooInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -231,13 +236,15 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
mkdir($this->_path);
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'attachement-test.sq3';
|
||||
if (is_file($path)) unlink($path);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'bar_';
|
||||
$model = Database::getInstance($this->_options);
|
||||
$model = Database::getInstance($this->_options);
|
||||
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste['meta']['attachmentname'] = $paste['attachmentname'];
|
||||
unset($paste['attachment'], $paste['attachmentname']);
|
||||
$meta = $paste['meta'];
|
||||
@@ -274,10 +281,12 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
mkdir($this->_path);
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'db-test.sq3';
|
||||
if (is_file($path)) unlink($path);
|
||||
if (is_file($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'foo_';
|
||||
$db = new PDO(
|
||||
$db = new PDO(
|
||||
$this->_options['dsn'],
|
||||
$this->_options['usr'],
|
||||
$this->_options['pwd'],
|
||||
@@ -294,13 +303,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
$db->exec(
|
||||
'CREATE TABLE foo_comment ( ' .
|
||||
"dataid CHAR(16) NOT NULL, " .
|
||||
'dataid CHAR(16) NOT NULL, ' .
|
||||
'pasteid CHAR(16), ' .
|
||||
'parentid CHAR(16), ' .
|
||||
'data BLOB, ' .
|
||||
'nickname BLOB, ' .
|
||||
'vizhash BLOB, ' .
|
||||
"postdate INT );"
|
||||
'postdate INT );'
|
||||
);
|
||||
$this->assertInstanceOf(Database::class, Database::getInstance($this->_options));
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Filesystem::getInstance(array('dir' => $this->_path));
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
|
||||
$this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment()), 'store comment');
|
||||
$this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it');
|
||||
$comment = json_decode(json_encode(Helper::getComment()));
|
||||
$comment->id = Helper::getCommentId();
|
||||
$comment = json_decode(json_encode(Helper::getComment()));
|
||||
$comment->id = Helper::getCommentId();
|
||||
$comment->parentid = Helper::getPasteId();
|
||||
$this->assertEquals(
|
||||
array($comment->meta->postdate => $comment),
|
||||
@@ -55,8 +55,8 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
public function testFileBasedAttachmentStoreWorks()
|
||||
{
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$original = $paste = Helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste['meta']['attachmentname'] = $paste['attachmentname'];
|
||||
unset($paste['attachment'], $paste['attachmentname']);
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
|
||||
@@ -66,18 +66,23 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(json_decode(json_encode($original)), $this->_model->read(Helper::getPasteId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* pastes a-g are expired and should get deleted, x never expires and y-z expire in an hour
|
||||
*/
|
||||
public function testPurge()
|
||||
{
|
||||
mkdir($this->_path . DIRECTORY_SEPARATOR . '00', 0777, true);
|
||||
$expired = Helper::getPaste(array('expire_date' => 1344803344));
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
|
||||
if (in_array($key, array('x', 'y', 'z'))) {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $paste), "store $key paste");
|
||||
} elseif ($key === 'x') {
|
||||
$this->assertTrue($this->_model->create($ids[$key], Helper::getPaste()), "store $key paste");
|
||||
} else {
|
||||
$this->assertTrue($this->_model->create($ids[$key], $expired), "store $key paste");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class I18nTest extends PHPUnit_Framework_TestCase
|
||||
public function testTranslationFallback()
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'foobar';
|
||||
$messageId = 'It does not matter if the message ID exists';
|
||||
$messageId = 'It does not matter if the message ID exists';
|
||||
I18n::loadTranslations();
|
||||
$this->assertEquals($messageId, I18n::_($messageId), 'fallback to en');
|
||||
}
|
||||
@@ -63,7 +63,25 @@ class I18nTest extends PHPUnit_Framework_TestCase
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'pl;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||
I18n::loadTranslations();
|
||||
$this->assertEquals('pl', I18n::_('en'), 'browser language pl');
|
||||
$this->assertEquals('2 godzina', I18n::_('%d hours', 2), 'hours in polish');
|
||||
$this->assertEquals('1 godzina', I18n::_('%d hours', 1), '1 hour in polish');
|
||||
$this->assertEquals('2 godzina', I18n::_('%d hours', 2), '2 hours in polish');
|
||||
$this->assertEquals('12 godzinę', I18n::_('%d hours', 12), '12 hours in polish');
|
||||
$this->assertEquals('22 godzina', I18n::_('%d hours', 22), '22 hours in polish');
|
||||
$this->assertEquals('1 minut', I18n::_('%d minutes', 1), '1 minute in polish');
|
||||
$this->assertEquals('3 minut', I18n::_('%d minutes', 3), '3 minutes in polish');
|
||||
$this->assertEquals('13 minut', I18n::_('%d minutes', 13), '13 minutes in polish');
|
||||
$this->assertEquals('23 minut', I18n::_('%d minutes', 23), '23 minutes in polish');
|
||||
}
|
||||
|
||||
public function testBrowserLanguageRuDetection()
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'ru;q=0.8,en-GB;q=0.6,en-US;q=0.4,en;q=0.2';
|
||||
I18n::loadTranslations();
|
||||
$this->assertEquals('ru', I18n::_('en'), 'browser language ru');
|
||||
$this->assertEquals('1 минуту', I18n::_('%d minutes', 1), '1 minute in russian');
|
||||
$this->assertEquals('3 минуты', I18n::_('%d minutes', 3), '3 minutes in russian');
|
||||
$this->assertEquals('10 минут', I18n::_('%d minutes', 10), '10 minutes in russian');
|
||||
$this->assertEquals('21 минуту', I18n::_('%d minutes', 21), '21 minutes in russian');
|
||||
}
|
||||
|
||||
public function testBrowserLanguageAnyDetection()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Request;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
|
||||
class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -15,7 +15,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
Helper::confBackup();
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Filesystem::getInstance(array('dir' => $this->_path));
|
||||
ServerSalt::setPath($this->_path);
|
||||
$this->reset();
|
||||
@@ -30,16 +30,16 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_SERVER = array();
|
||||
if ($this->_model->exists(Helper::getPasteId())) {
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
}
|
||||
Helper::confRestore();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options['model_options']['dir'] = $this->_path;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
@@ -51,14 +51,14 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -81,7 +81,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
public function testPut()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
@@ -90,10 +90,10 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
$file = tempnam(sys_get_temp_dir(), 'FOO');
|
||||
file_put_contents($file, http_build_query($paste));
|
||||
Request::setInputStream($file);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -120,14 +120,14 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$paste = $this->_model->read(Helper::getPasteId());
|
||||
$file = tempnam(sys_get_temp_dir(), 'FOO');
|
||||
$file = tempnam(sys_get_temp_dir(), 'FOO');
|
||||
file_put_contents($file, http_build_query(array(
|
||||
'deletetoken' => hash_hmac('sha256', Helper::getPasteId(), $paste->meta->salt),
|
||||
)));
|
||||
Request::setInputStream($file);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'DELETE';
|
||||
$_SERVER['REQUEST_METHOD'] = 'DELETE';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -147,12 +147,12 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$paste = $this->_model->read(Helper::getPasteId());
|
||||
$_POST = array(
|
||||
'action' => 'delete',
|
||||
'action' => 'delete',
|
||||
'deletetoken' => hash_hmac('sha256', Helper::getPasteId(), $paste->meta->salt),
|
||||
);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -168,13 +168,13 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
public function testRead()
|
||||
{
|
||||
$this->reset();
|
||||
$paste = Helper::getPasteWithAttachment();
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste = Helper::getPasteWithAttachment();
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
$paste['meta']['attachmentname'] = $paste['attachmentname'];
|
||||
unset($paste['attachment']);
|
||||
unset($paste['attachmentname']);
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Identicon\Identicon;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\Model;
|
||||
@@ -7,7 +8,6 @@ use PrivateBin\Model\Paste;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
use Identicon\Identicon;
|
||||
|
||||
class ModelTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -22,11 +22,13 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
/* Setup Routine */
|
||||
Helper::confRestore();
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
if (!is_dir($this->_path)) mkdir($this->_path);
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
ServerSalt::setPath($this->_path);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['limit'] = 0;
|
||||
$options['model'] = array(
|
||||
$options['model'] = array(
|
||||
'class' => 'Database',
|
||||
);
|
||||
$options['model_options'] = array(
|
||||
@@ -37,8 +39,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$this->_conf = new Configuration;
|
||||
$this->_model = new Model($this->_conf);
|
||||
$this->_conf = new Configuration;
|
||||
$this->_model = new Model($this->_conf);
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
}
|
||||
|
||||
@@ -73,8 +75,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// storing comments
|
||||
$commentData = Helper::getComment();
|
||||
$paste = $this->_model->getPaste(Helper::getPasteId());
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
|
||||
$paste = $this->_model->getPaste(Helper::getPasteId());
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
|
||||
$this->assertFalse($comment->exists(), 'comment does not yet exist');
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
@@ -123,7 +125,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCommentDuplicate()
|
||||
{
|
||||
$pasteData = Helper::getPaste();
|
||||
$pasteData = Helper::getPaste();
|
||||
$commentData = Helper::getComment();
|
||||
$this->_model->getPaste(Helper::getPasteId())->delete();
|
||||
|
||||
@@ -146,7 +148,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testImplicitDefaults()
|
||||
{
|
||||
$pasteData = Helper::getPaste();
|
||||
$pasteData = Helper::getPaste();
|
||||
$commentData = Helper::getComment();
|
||||
$this->_model->getPaste(Helper::getPasteId())->delete();
|
||||
|
||||
@@ -175,8 +177,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$comment->store();
|
||||
|
||||
$identicon = new Identicon();
|
||||
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
|
||||
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
|
||||
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');
|
||||
}
|
||||
|
||||
@@ -230,13 +232,13 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testPurge()
|
||||
{
|
||||
$conf = new Configuration;
|
||||
$conf = new Configuration;
|
||||
$store = Database::getInstance($conf->getSection('model_options'));
|
||||
$store->delete(Helper::getPasteId());
|
||||
$expired = Helper::getPaste(array('expire_date' => 1344803344));
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
$paste = Helper::getPaste(array('expire_date' => time() + 3600));
|
||||
$keys = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z');
|
||||
$ids = array();
|
||||
foreach ($keys as $key) {
|
||||
$ids[$key] = substr(md5($key), 0, 16);
|
||||
$store->delete($ids[$key]);
|
||||
@@ -261,9 +263,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCommentWithDisabledVizhash()
|
||||
{
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['icon'] = 'none';
|
||||
$options['model'] = array(
|
||||
$options['model'] = array(
|
||||
'class' => 'Database',
|
||||
);
|
||||
$options['model_options'] = array(
|
||||
@@ -297,8 +299,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// storing comments
|
||||
$commentData = Helper::getComment();
|
||||
$paste = $model->getPaste(Helper::getPasteId());
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
|
||||
$paste = $model->getPaste(Helper::getPasteId());
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
|
||||
$this->assertFalse($comment->exists(), 'comment does not yet exist');
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
@@ -316,9 +318,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCommentIdenticon()
|
||||
{
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['icon'] = 'identicon';
|
||||
$options['model'] = array(
|
||||
$options['model'] = array(
|
||||
'class' => 'Database',
|
||||
);
|
||||
$options['model_options'] = array(
|
||||
@@ -331,7 +333,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$model = new Model(new Configuration);
|
||||
|
||||
$pasteData = Helper::getPaste();
|
||||
$pasteData = Helper::getPaste();
|
||||
$commentData = Helper::getComment();
|
||||
$model->getPaste(Helper::getPasteId())->delete();
|
||||
|
||||
@@ -347,16 +349,16 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$comment->store();
|
||||
|
||||
$identicon = new Identicon();
|
||||
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
|
||||
$pngdata = $identicon->getImageDataUri(TrafficLimiter::getHash(), 16);
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
|
||||
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');
|
||||
}
|
||||
|
||||
public function testCommentVizhash()
|
||||
{
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['icon'] = 'vizhash';
|
||||
$options['model'] = array(
|
||||
$options['model'] = array(
|
||||
'class' => 'Database',
|
||||
);
|
||||
$options['model_options'] = array(
|
||||
@@ -369,7 +371,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$model = new Model(new Configuration);
|
||||
|
||||
$pasteData = Helper::getPaste();
|
||||
$pasteData = Helper::getPaste();
|
||||
$commentData = Helper::getComment();
|
||||
$model->getPaste(Helper::getPasteId())->delete();
|
||||
|
||||
@@ -384,7 +386,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$comment->setNickname($commentData['meta']['nickname']);
|
||||
$comment->store();
|
||||
|
||||
$vz = new Vizhash16x16();
|
||||
$vz = new Vizhash16x16();
|
||||
$pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash()));
|
||||
$comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId())->get();
|
||||
$this->assertEquals($pngdata, $comment->meta->vizhash, 'nickname triggers vizhash to be set');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\PrivateBin;
|
||||
|
||||
class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -14,7 +14,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Filesystem::getInstance(array('dir' => $this->_path));
|
||||
ServerSalt::setPath($this->_path);
|
||||
$this->reset();
|
||||
@@ -29,16 +29,16 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_SERVER = array();
|
||||
if ($this->_model->exists(Helper::getPasteId())) {
|
||||
$this->_model->delete(Helper::getPasteId());
|
||||
}
|
||||
Helper::confRestore();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options['model_options']['dir'] = $this->_path;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
@@ -72,7 +72,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testViewLanguageSelection()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['languageselection'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
@@ -94,9 +94,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testViewForceLanguageDefault()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['languageselection'] = false;
|
||||
$options['main']['languagedefault'] = 'fr';
|
||||
$options['main']['languagedefault'] = 'fr';
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_COOKIE['lang'] = 'de';
|
||||
@@ -118,7 +118,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$shortener = 'https://shortener.example.com/api?link=';
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['urlshortener'] = $shortener;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
@@ -175,14 +175,14 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -204,14 +204,14 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidTimelimit()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste(array('expire' => 25));
|
||||
$_POST = Helper::getPaste(array('expire' => 25));
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
TrafficLimiter::canPass();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -234,15 +234,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidSize()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['main']['sizelimit'] = 10;
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -258,15 +258,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateProxyHeader()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['header'] = 'X_FORWARDED_FOR';
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::2';
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_FORWARDED_FOR'] = '::2';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -288,15 +288,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateDuplicateId()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -312,17 +312,17 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateValidExpire()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
$_POST['formatter'] = 'foo';
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
$_POST['formatter'] = 'foo';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$time = time();
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$time = time();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -345,17 +345,17 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateValidExpireWithDiscussion()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
$_POST['opendiscussion'] = '1';
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = '5min';
|
||||
$_POST['opendiscussion'] = '1';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$time = time();
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$time = time();
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -379,15 +379,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidExpire()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = 'foo';
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['expire'] = 'foo';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -409,15 +409,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidBurn()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['burnafterreading'] = 'neither 1 nor 0';
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['burnafterreading'] = 'neither 1 nor 0';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -433,15 +433,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidOpenDiscussion()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['opendiscussion'] = 'neither 1 nor 0';
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['opendiscussion'] = 'neither 1 nor 0';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -457,15 +457,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateAttachment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['main']['fileupload'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPasteWithAttachment();
|
||||
$_POST = Helper::getPasteWithAttachment();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data');
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -475,7 +475,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(0, $response['status'], 'outputs status');
|
||||
$this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data');
|
||||
$original = json_decode(json_encode($_POST));
|
||||
$stored = $this->_model->read($response['id']);
|
||||
$stored = $this->_model->read($response['id']);
|
||||
foreach (array('data', 'attachment', 'attachmentname') as $key) {
|
||||
$this->assertEquals($original->$key, $stored->$key);
|
||||
}
|
||||
@@ -495,16 +495,16 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateBrokenAttachmentUpload()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
$options['main']['fileupload'] = true;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPasteWithAttachment();
|
||||
unset($_POST['attachment']);
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data');
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -521,10 +521,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateTooSoon()
|
||||
{
|
||||
$this->reset();
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST = Helper::getPaste();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
ob_end_clean();
|
||||
@@ -544,15 +544,15 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateValidNick()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['nickname'] = Helper::getComment()['meta']['nickname'];
|
||||
$_POST = Helper::getPaste();
|
||||
$_POST['nickname'] = Helper::getComment()['meta']['nickname'];
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -574,17 +574,17 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidNick()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST['nickname'] = 'foo';
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST['nickname'] = 'foo';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -601,16 +601,16 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -627,16 +627,16 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateInvalidComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = 'foo';
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = 'foo';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -653,17 +653,17 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateCommentDiscussionDisabled()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$paste = Helper::getPaste(array('opendiscussion' => false));
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$paste = Helper::getPaste(array('opendiscussion' => false));
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -680,16 +680,16 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateCommentInvalidPaste()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -705,19 +705,19 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testCreateDuplicateComment()
|
||||
{
|
||||
$this->reset();
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['traffic']['limit'] = 0;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), Helper::getComment());
|
||||
$this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists before posting data');
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_POST = Helper::getCommentPost();
|
||||
$_POST['pasteid'] = Helper::getPasteId();
|
||||
$_POST['parentid'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -835,7 +835,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->reset();
|
||||
$paste = Helper::getPaste();
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -859,7 +859,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testReadInvalidJson()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -876,9 +876,9 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$oldPaste = Helper::getPaste();
|
||||
$meta = array(
|
||||
$meta = array(
|
||||
'syntaxcoloring' => true,
|
||||
'postdate' => $oldPaste['meta']['postdate'],
|
||||
'postdate' => $oldPaste['meta']['postdate'],
|
||||
'opendiscussion' => $oldPaste['meta']['opendiscussion'],
|
||||
);
|
||||
$oldPaste['meta'] = $meta;
|
||||
@@ -931,8 +931,8 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$paste = $this->_model->read(Helper::getPasteId());
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$paste = $this->_model->read(Helper::getPasteId());
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), $paste->meta->salt);
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -953,7 +953,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_GET['pasteid'] = 'foo';
|
||||
$_GET['pasteid'] = 'foo';
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -973,7 +973,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
public function testDeleteInexistantId()
|
||||
{
|
||||
$this->reset();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -993,7 +993,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -1016,10 +1016,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$burnPaste = Helper::getPaste(array('burnafterreading' => true));
|
||||
$this->_model->create(Helper::getPasteId(), $burnPaste);
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$_POST['deletetoken'] = 'burnafterreading';
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_POST['deletetoken'] = 'burnafterreading';
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -1037,10 +1037,10 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->reset();
|
||||
$this->_model->create(Helper::getPasteId(), Helper::getPaste());
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$_POST['deletetoken'] = 'burnafterreading';
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_POST['deletetoken'] = 'burnafterreading';
|
||||
$_SERVER['QUERY_STRING'] = Helper::getPasteId();
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
$content = ob_get_contents();
|
||||
@@ -1060,7 +1060,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exist before being created');
|
||||
$this->_model->create(Helper::getPasteId(), $expiredPaste);
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = 'does not matter in this context, but has to be set';
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
@@ -1084,7 +1084,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
|
||||
unset($paste['meta']['salt']);
|
||||
$this->_model->create(Helper::getPasteId(), $paste);
|
||||
$this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['pasteid'] = Helper::getPasteId();
|
||||
$_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), ServerSalt::get());
|
||||
ob_start();
|
||||
new PrivateBin;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\PrivateBin;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
|
||||
require_once 'PrivateBinTest.php';
|
||||
|
||||
@@ -13,8 +11,8 @@ class PrivateBinWithDbTest extends PrivateBinTest
|
||||
'usr' => null,
|
||||
'pwd' => null,
|
||||
'opt' => array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_PERSISTENT => true
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -27,7 +25,7 @@ class PrivateBinWithDbTest extends PrivateBinTest
|
||||
}
|
||||
ServerSalt::setPath($this->_path);
|
||||
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
|
||||
$this->_model = Database::getInstance($this->_options);
|
||||
$this->_model = Database::getInstance($this->_options);
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -35,13 +33,13 @@ class PrivateBinWithDbTest extends PrivateBinTest
|
||||
{
|
||||
parent::reset();
|
||||
// but then inject a db config
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options = parse_ini_file(CONF, true);
|
||||
$options['model'] = array(
|
||||
'class' => 'Database',
|
||||
);
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['purge']['dir'] = $this->_path;
|
||||
$options['traffic']['dir'] = $this->_path;
|
||||
$options['model_options'] = $this->_options;
|
||||
$options['model_options'] = $this->_options;
|
||||
Helper::confBackup();
|
||||
Helper::createIniFile(CONF, $options);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,17 @@ Running unit tests
|
||||
In order to run these tests, you will need to install the following packages
|
||||
and its dependencies:
|
||||
* phpunit
|
||||
* php5-gd
|
||||
* php5-sqlite
|
||||
* php5-xdebug
|
||||
* php-gd
|
||||
* php-sqlite3
|
||||
* php-xdebug
|
||||
|
||||
Example for Debian and Ubuntu:
|
||||
$ sudo aptitude install phpunit php5-gd php5-sqlite php5-xdebug
|
||||
```sh
|
||||
$ sudo aptitude install phpunit php-gd php-sqlite php-xdebug
|
||||
```
|
||||
|
||||
To run the tests, just change into this directory and run phpunit:
|
||||
$ cd PrivateBin/tst
|
||||
$ phpunit
|
||||
```sh
|
||||
$ cd PrivateBin/tst
|
||||
$ phpunit
|
||||
```
|
||||
|
||||
@@ -17,15 +17,15 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
public function reset()
|
||||
{
|
||||
$_SERVER = array();
|
||||
$_GET = array();
|
||||
$_POST = array();
|
||||
$_GET = array();
|
||||
$_POST = array();
|
||||
}
|
||||
|
||||
public function testView()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$request = new Request;
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('view', $request->getOperation());
|
||||
}
|
||||
@@ -34,8 +34,8 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
@@ -45,9 +45,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_GET['pasteid'] = 'foo';
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
$request = new Request;
|
||||
$_GET['pasteid'] = 'foo';
|
||||
$_GET['deletetoken'] = 'bar';
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('delete', $request->getOperation());
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
@@ -57,9 +57,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
public function testApiCreate()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$file = tempnam(sys_get_temp_dir(), 'FOO');
|
||||
$file = tempnam(sys_get_temp_dir(), 'FOO');
|
||||
file_put_contents($file, 'data=foo');
|
||||
Request::setInputStream($file);
|
||||
$request = new Request;
|
||||
@@ -72,9 +72,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
|
||||
$_POST['attachment'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
|
||||
$_POST['attachment'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertTrue($request->isJsonApiCall(), 'is JSON Api call');
|
||||
$this->assertEquals('create', $request->getOperation());
|
||||
$this->assertEquals('foo', $request->getParam('attachment'));
|
||||
@@ -84,9 +84,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertTrue($request->isJsonApiCall(), 'is JSON Api call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
@@ -95,11 +95,11 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
public function testApiDelete()
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$_POST['deletetoken'] = 'bar';
|
||||
$request = new Request;
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$_POST['deletetoken'] = 'bar';
|
||||
$request = new Request;
|
||||
$this->assertTrue($request->isJsonApiCall(), 'is JSON Api call');
|
||||
$this->assertEquals('delete', $request->getOperation());
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
@@ -110,9 +110,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/html,text/html; charset=UTF-8,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/html,text/html; charset=UTF-8,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
@@ -122,9 +122,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/xhtml+xml,text/html,text/html; charset=UTF-8, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/xhtml+xml,text/html,text/html; charset=UTF-8, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
@@ -134,9 +134,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, application/json, text/html,text/html; charset=UTF-8,application/xhtml+xml, */*;q=0.8';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, application/json, text/html,text/html; charset=UTF-8,application/xhtml+xml, */*;q=0.8';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertTrue($request->isJsonApiCall(), 'is JSON Api call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
@@ -146,9 +146,9 @@ class RequestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->reset();
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, */*;q=0.8';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, */*;q=0.8';
|
||||
$_SERVER['QUERY_STRING'] = 'foo';
|
||||
$request = new Request;
|
||||
$this->assertFalse($request->isJsonApiCall(), 'is HTML call');
|
||||
$this->assertEquals('foo', $request->getParam('pasteid'));
|
||||
$this->assertEquals('read', $request->getOperation());
|
||||
|
||||
@@ -10,15 +10,15 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
private static $status = '!*#@?$+';
|
||||
|
||||
private static $formatters = array(
|
||||
'plaintext' => 'Plain Text',
|
||||
'plaintext' => 'Plain Text',
|
||||
'syntaxhighlighting' => 'Source Code',
|
||||
'markdown' => 'Markdown',
|
||||
'markdown' => 'Markdown',
|
||||
);
|
||||
|
||||
private static $formatter_default = 'plaintext';
|
||||
|
||||
private static $expire = array(
|
||||
'5min' => '5 minutes',
|
||||
'5min' => '5 minutes',
|
||||
'1hour' => '1 hour',
|
||||
'never' => 'Never',
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@ class Vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testVizhashGeneratesUniquePngsPerIp()
|
||||
{
|
||||
$vz = new Vizhash16x16();
|
||||
$vz = new Vizhash16x16();
|
||||
$pngdata = $vz->generate(hash('sha512', '127.0.0.1'));
|
||||
file_put_contents($this->_file, $pngdata);
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
if (!function_exists('RandomCompat_strlen')) {
|
||||
if (!is_callable('RandomCompat_strlen')) {
|
||||
if (
|
||||
defined('MB_OVERLOAD_STRING') &&
|
||||
ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
|
||||
@@ -78,7 +78,7 @@ if (!function_exists('RandomCompat_strlen')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('RandomCompat_substr')) {
|
||||
if (!is_callable('RandomCompat_substr')) {
|
||||
|
||||
if (
|
||||
defined('MB_OVERLOAD_STRING')
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
if (!function_exists('RandomCompat_intval')) {
|
||||
if (!is_callable('RandomCompat_intval')) {
|
||||
|
||||
/**
|
||||
* Cast to an integer if we can, safely.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -35,8 +35,15 @@ if (!class_exists('Error', false)) {
|
||||
}
|
||||
|
||||
if (!class_exists('TypeError', false)) {
|
||||
class TypeError extends Error
|
||||
{
|
||||
|
||||
if (is_subclass_of('Error', 'Exception')) {
|
||||
class TypeError extends Error
|
||||
{
|
||||
|
||||
}
|
||||
} else {
|
||||
class TypeError extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
vendor/paragonie/random_compat/lib/random.php
vendored
48
vendor/paragonie/random_compat/lib/random.php
vendored
@@ -3,12 +3,12 @@
|
||||
* Random_* Compatibility Library
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* @version 2.0.2
|
||||
* @released 2016-04-03
|
||||
* @version 2.0.4
|
||||
* @released 2016-11-07
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
if (!defined('PHP_VERSION_ID')) {
|
||||
// This constant was introduced in PHP 5.2.7
|
||||
$RandomCompatversion = explode('.', PHP_VERSION);
|
||||
$RandomCompatversion = array_map('intval', explode('.', PHP_VERSION));
|
||||
define(
|
||||
'PHP_VERSION_ID',
|
||||
$RandomCompatversion[0] * 10000
|
||||
@@ -41,8 +41,10 @@ if (!defined('PHP_VERSION_ID')) {
|
||||
$RandomCompatversion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP 7.0.0 and newer have these functions natively.
|
||||
*/
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
|
||||
if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
|
||||
define('RANDOM_COMPAT_READ_BUFFER', 8);
|
||||
}
|
||||
@@ -53,7 +55,7 @@ if (PHP_VERSION_ID < 70000) {
|
||||
require_once $RandomCompatDIR.'/cast_to_int.php';
|
||||
require_once $RandomCompatDIR.'/error_polyfill.php';
|
||||
|
||||
if (!function_exists('random_bytes')) {
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* PHP 5.2.0 - 5.6.x way to implement random_bytes()
|
||||
*
|
||||
@@ -67,11 +69,11 @@ if (PHP_VERSION_ID < 70000) {
|
||||
* 4. COM('CAPICOM.Utilities.1')->GetRandom()
|
||||
* 5. openssl_random_pseudo_bytes() (absolute last resort)
|
||||
*
|
||||
* See ERRATA.md for our reasoning behind this particular order
|
||||
* See RATIONALE.md for our reasoning behind this particular order
|
||||
*/
|
||||
if (extension_loaded('libsodium')) {
|
||||
// See random_bytes_libsodium.php
|
||||
if (PHP_VERSION_ID >= 50300 && function_exists('\\Sodium\\randombytes_buf')) {
|
||||
if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) {
|
||||
require_once $RandomCompatDIR.'/random_bytes_libsodium.php';
|
||||
} elseif (method_exists('Sodium', 'randombytes_buf')) {
|
||||
require_once $RandomCompatDIR.'/random_bytes_libsodium_legacy.php';
|
||||
@@ -100,7 +102,7 @@ if (PHP_VERSION_ID < 70000) {
|
||||
}
|
||||
|
||||
if (
|
||||
!function_exists('random_bytes')
|
||||
!is_callable('random_bytes')
|
||||
&&
|
||||
$RandomCompatUrandom
|
||||
&&
|
||||
@@ -123,15 +125,27 @@ if (PHP_VERSION_ID < 70000) {
|
||||
|
||||
/**
|
||||
* mcrypt_create_iv()
|
||||
*
|
||||
* We only want to use mcypt_create_iv() if:
|
||||
*
|
||||
* - random_bytes() hasn't already been defined
|
||||
* - PHP >= 5.3.7
|
||||
* - the mcrypt extensions is loaded
|
||||
* - One of these two conditions is true:
|
||||
* - We're on Windows (DIRECTORY_SEPARATOR !== '/')
|
||||
* - We're not on Windows and /dev/urandom is readabale
|
||||
* (i.e. we're not in a chroot jail)
|
||||
* - Special case:
|
||||
* - If we're not on Windows, but the PHP version is between
|
||||
* 5.6.10 and 5.6.12, we don't want to use mcrypt. It will
|
||||
* hang indefinitely. This is bad.
|
||||
*/
|
||||
if (
|
||||
!function_exists('random_bytes')
|
||||
!is_callable('random_bytes')
|
||||
&&
|
||||
PHP_VERSION_ID >= 50307
|
||||
&&
|
||||
extension_loaded('mcrypt')
|
||||
&&
|
||||
(DIRECTORY_SEPARATOR !== '/' || $RandomCompatUrandom)
|
||||
) {
|
||||
// Prevent this code from hanging indefinitely on non-Windows;
|
||||
// see https://bugs.php.net/bug.php?id=69833
|
||||
@@ -145,8 +159,12 @@ if (PHP_VERSION_ID < 70000) {
|
||||
}
|
||||
$RandomCompatUrandom = null;
|
||||
|
||||
/**
|
||||
* This is a Windows-specific fallback, for when the mcrypt extension
|
||||
* isn't loaded.
|
||||
*/
|
||||
if (
|
||||
!function_exists('random_bytes')
|
||||
!is_callable('random_bytes')
|
||||
&&
|
||||
extension_loaded('com_dotnet')
|
||||
&&
|
||||
@@ -175,7 +193,7 @@ if (PHP_VERSION_ID < 70000) {
|
||||
/**
|
||||
* throw new Exception
|
||||
*/
|
||||
if (!function_exists('random_bytes')) {
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* We don't have any more options, so let's throw an exception right now
|
||||
* and hope the developer won't let it fail silently.
|
||||
@@ -189,7 +207,7 @@ if (PHP_VERSION_ID < 70000) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('random_int')) {
|
||||
if (!is_callable('random_int')) {
|
||||
require_once $RandomCompatDIR.'/random_int.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,56 +26,58 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Windows with PHP < 5.3.0 will not have the function
|
||||
* openssl_random_pseudo_bytes() available, so let's use
|
||||
* CAPICOM to work around this deficiency.
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
$buf = '';
|
||||
$util = new COM('CAPICOM.Utilities.1');
|
||||
$execCount = 0;
|
||||
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* Let's not let it loop forever. If we run N times and fail to
|
||||
* get N bytes of random data, then CAPICOM has failed us.
|
||||
* Windows with PHP < 5.3.0 will not have the function
|
||||
* openssl_random_pseudo_bytes() available, so let's use
|
||||
* CAPICOM to work around this deficiency.
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
do {
|
||||
$buf .= base64_decode($util->GetRandom($bytes, 0));
|
||||
if (RandomCompat_strlen($buf) >= $bytes) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return RandomCompat_substr($buf, 0, $bytes);
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
++$execCount;
|
||||
} while ($execCount < $bytes);
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
$buf = '';
|
||||
$util = new COM('CAPICOM.Utilities.1');
|
||||
$execCount = 0;
|
||||
|
||||
/**
|
||||
* Let's not let it loop forever. If we run N times and fail to
|
||||
* get N bytes of random data, then CAPICOM has failed us.
|
||||
*/
|
||||
do {
|
||||
$buf .= base64_decode($util->GetRandom($bytes, 0));
|
||||
if (RandomCompat_strlen($buf) >= $bytes) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return RandomCompat_substr($buf, 0, $bytes);
|
||||
}
|
||||
++$execCount;
|
||||
} while ($execCount < $bytes);
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,119 +30,121 @@ if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
|
||||
define('RANDOM_COMPAT_READ_BUFFER', 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unless open_basedir is enabled, use /dev/urandom for
|
||||
* random numbers in accordance with best practices
|
||||
*
|
||||
* Why we use /dev/urandom and not /dev/random
|
||||
* @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
static $fp = null;
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* This block should only be run once
|
||||
* Unless open_basedir is enabled, use /dev/urandom for
|
||||
* random numbers in accordance with best practices
|
||||
*
|
||||
* Why we use /dev/urandom and not /dev/random
|
||||
* @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
if (empty($fp)) {
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
static $fp = null;
|
||||
/**
|
||||
* We use /dev/urandom if it is a char device.
|
||||
* We never fall back to /dev/random
|
||||
* This block should only be run once
|
||||
*/
|
||||
$fp = fopen('/dev/urandom', 'rb');
|
||||
if (!empty($fp)) {
|
||||
$st = fstat($fp);
|
||||
if (($st['mode'] & 0170000) !== 020000) {
|
||||
fclose($fp);
|
||||
$fp = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fp)) {
|
||||
if (empty($fp)) {
|
||||
/**
|
||||
* stream_set_read_buffer() does not exist in HHVM
|
||||
*
|
||||
* If we don't set the stream's read buffer to 0, PHP will
|
||||
* internally buffer 8192 bytes, which can waste entropy
|
||||
*
|
||||
* stream_set_read_buffer returns 0 on success
|
||||
* We use /dev/urandom if it is a char device.
|
||||
* We never fall back to /dev/random
|
||||
*/
|
||||
if (function_exists('stream_set_read_buffer')) {
|
||||
stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
|
||||
$fp = fopen('/dev/urandom', 'rb');
|
||||
if (!empty($fp)) {
|
||||
$st = fstat($fp);
|
||||
if (($st['mode'] & 0170000) !== 020000) {
|
||||
fclose($fp);
|
||||
$fp = false;
|
||||
}
|
||||
}
|
||||
if (function_exists('stream_set_chunk_size')) {
|
||||
stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
|
||||
|
||||
if (!empty($fp)) {
|
||||
/**
|
||||
* stream_set_read_buffer() does not exist in HHVM
|
||||
*
|
||||
* If we don't set the stream's read buffer to 0, PHP will
|
||||
* internally buffer 8192 bytes, which can waste entropy
|
||||
*
|
||||
* stream_set_read_buffer returns 0 on success
|
||||
*/
|
||||
if (is_callable('stream_set_read_buffer')) {
|
||||
stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
|
||||
}
|
||||
if (is_callable('stream_set_chunk_size')) {
|
||||
stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This if() block only runs if we managed to open a file handle
|
||||
*
|
||||
* It does not belong in an else {} block, because the above
|
||||
* if (empty($fp)) line is logic that should only be run once per
|
||||
* page load.
|
||||
*/
|
||||
if (!empty($fp)) {
|
||||
$remaining = $bytes;
|
||||
$buf = '';
|
||||
|
||||
/**
|
||||
* We use fread() in a loop to protect against partial reads
|
||||
*/
|
||||
do {
|
||||
$read = fread($fp, $remaining);
|
||||
if ($read === false) {
|
||||
/**
|
||||
* We cannot safely read from the file. Exit the
|
||||
* do-while loop and trigger the exception condition
|
||||
*/
|
||||
$buf = false;
|
||||
break;
|
||||
}
|
||||
/**
|
||||
* Decrease the number of bytes returned from remaining
|
||||
*/
|
||||
$remaining -= RandomCompat_strlen($read);
|
||||
$buf .= $read;
|
||||
} while ($remaining > 0);
|
||||
|
||||
/**
|
||||
* Is our result valid?
|
||||
*/
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Error reading from source device'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This if() block only runs if we managed to open a file handle
|
||||
*
|
||||
* It does not belong in an else {} block, because the above
|
||||
* if (empty($fp)) line is logic that should only be run once per
|
||||
* page load.
|
||||
*/
|
||||
if (!empty($fp)) {
|
||||
$remaining = $bytes;
|
||||
$buf = '';
|
||||
|
||||
/**
|
||||
* We use fread() in a loop to protect against partial reads
|
||||
*/
|
||||
do {
|
||||
$read = fread($fp, $remaining);
|
||||
if ($read === false) {
|
||||
/**
|
||||
* We cannot safely read from the file. Exit the
|
||||
* do-while loop and trigger the exception condition
|
||||
*/
|
||||
$buf = false;
|
||||
break;
|
||||
}
|
||||
/**
|
||||
* Decrease the number of bytes returned from remaining
|
||||
*/
|
||||
$remaining -= RandomCompat_strlen($read);
|
||||
$buf .= $read;
|
||||
} while ($remaining > 0);
|
||||
|
||||
/**
|
||||
* Is our result valid?
|
||||
*/
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Error reading from source device'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,61 +26,63 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* If the libsodium PHP extension is loaded, we'll use it above any other
|
||||
* solution.
|
||||
*
|
||||
* libsodium-php project:
|
||||
* @ref https://github.com/jedisct1/libsodium-php
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* If the libsodium PHP extension is loaded, we'll use it above any other
|
||||
* solution.
|
||||
*
|
||||
* libsodium-php project:
|
||||
* @ref https://github.com/jedisct1/libsodium-php
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
|
||||
* generated in one invocation.
|
||||
*/
|
||||
if ($bytes > 2147483647) {
|
||||
$buf = '';
|
||||
for ($i = 0; $i < $bytes; $i += 1073741824) {
|
||||
$n = ($bytes - $i) > 1073741824
|
||||
? 1073741824
|
||||
: $bytes - $i;
|
||||
$buf .= \Sodium\randombytes_buf($n);
|
||||
}
|
||||
} else {
|
||||
$buf = \Sodium\randombytes_buf($bytes);
|
||||
}
|
||||
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
|
||||
* generated in one invocation.
|
||||
*/
|
||||
if ($bytes > 2147483647) {
|
||||
$buf = '';
|
||||
for ($i = 0; $i < $bytes; $i += 1073741824) {
|
||||
$n = ($bytes - $i) > 1073741824
|
||||
? 1073741824
|
||||
: $bytes - $i;
|
||||
$buf .= \Sodium\randombytes_buf($n);
|
||||
}
|
||||
} else {
|
||||
$buf = \Sodium\randombytes_buf($bytes);
|
||||
}
|
||||
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,61 +26,63 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* If the libsodium PHP extension is loaded, we'll use it above any other
|
||||
* solution.
|
||||
*
|
||||
* libsodium-php project:
|
||||
* @ref https://github.com/jedisct1/libsodium-php
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* If the libsodium PHP extension is loaded, we'll use it above any other
|
||||
* solution.
|
||||
*
|
||||
* libsodium-php project:
|
||||
* @ref https://github.com/jedisct1/libsodium-php
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
|
||||
* generated in one invocation.
|
||||
*/
|
||||
if ($bytes > 2147483647) {
|
||||
$buf = '';
|
||||
for ($i = 0; $i < $bytes; $i += 1073741824) {
|
||||
$n = ($bytes - $i) > 1073741824
|
||||
? 1073741824
|
||||
: $bytes - $i;
|
||||
$buf .= Sodium::randombytes_buf($n);
|
||||
}
|
||||
} else {
|
||||
$buf = Sodium::randombytes_buf($bytes);
|
||||
}
|
||||
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
|
||||
* generated in one invocation.
|
||||
*/
|
||||
if ($bytes > 2147483647) {
|
||||
$buf = '';
|
||||
for ($i = 0; $i < $bytes; $i += 1073741824) {
|
||||
$n = ($bytes - $i) > 1073741824
|
||||
? 1073741824
|
||||
: $bytes - $i;
|
||||
$buf .= Sodium::randombytes_buf($n);
|
||||
}
|
||||
} else {
|
||||
$buf = Sodium::randombytes_buf($bytes);
|
||||
}
|
||||
|
||||
if ($buf !== false) {
|
||||
if (RandomCompat_strlen($buf) === $bytes) {
|
||||
return $buf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,51 +26,52 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Powered by ext/mcrypt (and thankfully NOT libmcrypt)
|
||||
*
|
||||
* @ref https://bugs.php.net/bug.php?id=55169
|
||||
* @ref https://github.com/php/php-src/blob/c568ffe5171d942161fc8dda066bce844bdef676/ext/mcrypt/mcrypt.c#L1321-L1386
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
|
||||
if (
|
||||
$buf !== false
|
||||
&&
|
||||
RandomCompat_strlen($buf) === $bytes
|
||||
) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return $buf;
|
||||
}
|
||||
|
||||
if (!is_callable('random_bytes')) {
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
* Powered by ext/mcrypt (and thankfully NOT libmcrypt)
|
||||
*
|
||||
* @ref https://bugs.php.net/bug.php?id=55169
|
||||
* @ref https://github.com/php/php-src/blob/c568ffe5171d942161fc8dda066bce844bdef676/ext/mcrypt/mcrypt.c#L1321-L1386
|
||||
*
|
||||
* @param int $bytes
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
function random_bytes($bytes)
|
||||
{
|
||||
try {
|
||||
$bytes = RandomCompat_intval($bytes);
|
||||
} catch (TypeError $ex) {
|
||||
throw new TypeError(
|
||||
'random_bytes(): $bytes must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if ($bytes < 1) {
|
||||
throw new Error(
|
||||
'Length must be greater than 0'
|
||||
);
|
||||
}
|
||||
|
||||
$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
|
||||
if (
|
||||
$buf !== false
|
||||
&&
|
||||
RandomCompat_strlen($buf) === $bytes
|
||||
) {
|
||||
/**
|
||||
* Return our random entropy buffer here:
|
||||
*/
|
||||
return $buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we reach here, PHP has failed us.
|
||||
*/
|
||||
throw new Exception(
|
||||
'Could not gather sufficient random data'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* for using the new PHP 7 random_* API in PHP 5 projects
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Paragon Initiative Enterprises
|
||||
*
|
||||
* Copyright (c) 2015 - 2016 Paragon Initiative Enterprises
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
Reference in New Issue
Block a user