mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Merge branch 'master' of sametmax-github:sametmax/0bin
This commit is contained in:
commit
abaee22924
@ -1,6 +1,8 @@
|
||||
0bin
|
||||
====
|
||||
|
||||
Have try here: <a href="0bin.net">0bin.net</a>
|
||||
|
||||
0bin is client side encrypted pastebin that can run without a database.
|
||||
|
||||
It allows anybody to host a pastebin while welcoming any type of content to be pasted in it. The idea is that one can (probably...) not be legally entitled to moderate the pastebin content (http://www.zdnet.com/blog/security/pastebin-to-hunt-for-hacker-pastes-anonymous-cries-censorship/11336) as one has no way to decrypt it.
|
||||
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import math
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
STATIC_FILES_ROOT = os.path.join(ROOT_DIR, 'static')
|
||||
|
||||
@ -28,4 +29,5 @@ GROUP = None
|
||||
|
||||
# limit size of pasted text in bytes. Be carefull allowing too much size can slow down user's
|
||||
# browser
|
||||
MAX_SIZE = 500 * 1000
|
||||
MAX_SIZE = 1024 * 500
|
||||
MAX_SIZE_KB = int(math.ceil(MAX_SIZE / 1024.0))
|
||||
|
16
src/paste.py
16
src/paste.py
@ -153,15 +153,13 @@ class Paste(object):
|
||||
if self.expiration == "burn_after_reading":
|
||||
self.expiration = self.expiration + '#%s' % datetime.now()
|
||||
|
||||
# write the paste
|
||||
try:
|
||||
with open(self.path, 'w') as f:
|
||||
f.write(unicode(self.expiration) + '\n')
|
||||
f.write(self.content + '\n')
|
||||
if self.comments:
|
||||
f.write(comments)
|
||||
except Exception as e:
|
||||
import ipdb; ipdb.set_trace()
|
||||
# write the paste
|
||||
with open(self.path, 'w') as f:
|
||||
f.write(unicode(self.expiration) + '\n')
|
||||
f.write(self.content + '\n')
|
||||
if self.comments:
|
||||
f.write(comments)
|
||||
|
||||
return self
|
||||
|
||||
|
||||
|
19
start.py
19
start.py
@ -32,8 +32,7 @@ app = Bottle()
|
||||
@app.route('/')
|
||||
@view('home')
|
||||
def index():
|
||||
max_size_kb = int(math.ceil(settings.MAX_SIZE / 1024.0))
|
||||
return {'max_size': settings.MAX_SIZE, 'max_size_kb': max_size_kb}
|
||||
return {'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
|
||||
|
||||
|
||||
@app.route('/paste/create', method='POST')
|
||||
@ -49,11 +48,15 @@ def create_paste():
|
||||
return ''
|
||||
|
||||
if content:
|
||||
expiration = request.forms.get('expiration', u'burn_after_reading')
|
||||
paste = Paste(expiration=expiration, content=content)
|
||||
paste.save()
|
||||
return {'status': 'ok',
|
||||
'paste': paste.uuid}
|
||||
# check size of the paste. if more than settings return error without saving paste.
|
||||
# prevent from unusual use of the system.
|
||||
# need to be improved
|
||||
if len(content) < settings.MAX_SIZE:
|
||||
expiration = request.forms.get('expiration', u'burn_after_reading')
|
||||
paste = Paste(expiration=expiration, content=content)
|
||||
paste.save()
|
||||
return {'status': 'ok',
|
||||
'paste': paste.uuid}
|
||||
|
||||
return {'status': 'error',
|
||||
'message': u"Serveur error: the paste couldn't be saved. Please try later."}
|
||||
@ -89,7 +92,7 @@ def display_paste(paste_id):
|
||||
except (TypeError, ValueError):
|
||||
abort(404, u"This paste doesn't exist or has expired")
|
||||
|
||||
return {'paste': paste, 'keep_alive': keep_alive}
|
||||
return {'paste': paste, 'keep_alive': keep_alive, 'max_size': settings.MAX_SIZE, 'max_size_kb': settings.MAX_SIZE_KB}
|
||||
|
||||
|
||||
@clize.clize
|
||||
|
@ -259,6 +259,10 @@ button.btn, input[type="submit"].btn {
|
||||
top:-4px;
|
||||
}
|
||||
|
||||
#alert-template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/** Progress bar */
|
||||
|
||||
.progress {
|
||||
|
@ -221,6 +221,8 @@ zerobin = {
|
||||
},
|
||||
message: function(type, message, title, flush, callback) {
|
||||
|
||||
$(window).scrollTop(0);
|
||||
|
||||
if (flush) {$('.alert-'+type).remove()}
|
||||
|
||||
$message = $('#alert-template').clone().attr('id', null)
|
||||
|
@ -42,9 +42,9 @@
|
||||
<a class="brand" href="/"><span>ø</span>bin<em>.net</em></a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#download">Download 0bin</a></li>
|
||||
<li><a href="#faq">Faq</a></li>
|
||||
<li class="active"><a href="/">Home</a></li>
|
||||
<li><a href="https://github.com/sametmax/0bin">Download 0bin</a></li>
|
||||
<!-- <li><a href="#faq">Faq</a></li> -->
|
||||
</ul>
|
||||
<p class="navbar-text pull-right"><i>"A client side encrypted PasteBin..."</i></p>
|
||||
</div><!--/.nav-collapse -->
|
||||
|
@ -74,4 +74,4 @@
|
||||
</span>
|
||||
|
||||
|
||||
%rebase base
|
||||
%rebase base max_size=max_size
|
||||
|
Loading…
Reference in New Issue
Block a user