# HG changeset patch # User Pascal Bellard # Date 1450711712 -3600 # Node ID 139df21c10dd55ba13b8783304e775f2c7b950e3 # Parent d6ca18366f4121d446b000ec4fc78b73ea05c6c1 Up zerobin (6 feb 2014) diff -r d6ca18366f41 -r 139df21c10dd zerobin/receipt --- a/zerobin/receipt Mon Dec 21 02:53:09 2015 +0200 +++ b/zerobin/receipt Mon Dec 21 16:28:32 2015 +0100 @@ -1,14 +1,15 @@ # SliTaz package receipt. PACKAGE="zerobin" -VERSION="0.18_alpha" +GITHASH="8cae64d6eab99fb0d31868df77846285c0958ed0" # 6 feb 2014 +VERSION="${GITHASH:0:7}" CATEGORY="network" SHORT_DESC="Online pastebin where the server has zero knowledge of pasted data." MAINTAINER="pascal.bellard@slitaz.org" LICENSE="zlib/libpng" -TARBALL="${PACKAGE}_$VERSION.zip" +TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="http://sebsauvage.net/wiki/doku.php?id=php:zerobin" -WGET_URL="http://sebsauvage.net/files/$TARBALL" +WGET_URL="https://github.com/sebsauvage/ZeroBin/archive/$VERSION.tar.gz" HOST_ARCH="any" DEPENDS="php" @@ -17,9 +18,7 @@ # Rules to configure and make the package. compile_rules() { - cd $src patch -p0 < $stuff/zerobin.u - find css js lib tpl -type f | xargs dos2unix *.* } # Rules to gen a SliTaz package suitable for Tazpkg. diff -r d6ca18366f41 -r 139df21c10dd zerobin/stuff/zerobin.u --- a/zerobin/stuff/zerobin.u Mon Dec 21 02:53:09 2015 +0200 +++ b/zerobin/stuff/zerobin.u Mon Dec 21 16:28:32 2015 +0100 @@ -1,51 +1,51 @@ --- index.php +++ index.php @@ -17,6 +17,13 @@ - $_COOKIE = array_map('stripslashes_deep', $_COOKIE); - } - -+function remote_address() -+{ -+ // if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) -+ // return $_SERVER["HTTP_X_FORWARDED_FOR"]; -+ return $_SERVER["REMOTE_ADDR"]; -+} -+ - // trafic_limiter : Make sure the IP address makes at most 1 request every 10 seconds. - // Will return false if IP address made a call less than 10 seconds ago. - function trafic_limiter_canPass($ip) + $_COOKIE = array_map('stripslashes_deep', $_COOKIE); + } + ++function remote_address() ++{ ++ // if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) ++ // return $_SERVER["HTTP_X_FORWARDED_FOR"]; ++ return $_SERVER["REMOTE_ADDR"]; ++} ++ + // trafic_limiter : Make sure the IP address makes at most 1 request every 10 seconds. + // Will return false if IP address made a call less than 10 seconds ago. + function trafic_limiter_canPass($ip) @@ -144,7 +151,7 @@ - } - - // Make sure last paste from the IP address was more than 10 seconds ago. -- if (!trafic_limiter_canPass($_SERVER['REMOTE_ADDR'])) -+ if (!trafic_limiter_canPass(remote_address())) - { echo json_encode(array('status'=>1,'message'=>'Please wait 10 seconds between each post.')); exit; } - - // Make sure content is not too big. + } + + // Make sure last paste from the IP address was more than 10 seconds ago. +- if (!trafic_limiter_canPass($_SERVER['REMOTE_ADDR'])) ++ if (!trafic_limiter_canPass(remote_address())) + { echo json_encode(array('status'=>1,'message'=>'Please wait 10 seconds between each post.')); exit; } + + // Make sure content is not too big. @@ -216,7 +223,7 @@ - // (We assume that if the user did not enter a nickname, he/she wants - // to be anonymous and we will not generate the vizhash.) - $vz = new vizhash16x16(); -- $pngdata = $vz->generate($_SERVER['REMOTE_ADDR']); -+ $pngdata = $vz->generate(remote_address()); - if ($pngdata!='') $meta['vizhash'] = 'data:image/png;base64,'.base64_encode($pngdata); - // Once the avatar is generated, we do not keep the IP address, nor its hash. - } + // (We assume that if the user did not enter a nickname, he/she wants + // to be anonymous and we will not generate the vizhash.) + $vz = new vizhash16x16(); +- $pngdata = $vz->generate($_SERVER['REMOTE_ADDR']); ++ $pngdata = $vz->generate(remote_address()); + if ($pngdata!='') $meta['vizhash'] = 'data:image/png;base64,'.base64_encode($pngdata); + // Once the avatar is generated, we do not keep the IP address, nor its hash. + } --- js/zerobin.js +++ js/zerobin.js -@@ -326,7 +326,13 @@ - return; - } - showStatus('Sending paste...', spin=true); -- var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0); -+ var randomkey = (window.location.hash.length > 2) ? -+ // force key -+ window.location.hash.substring(1) : -+ // Generate a random 256 bits key, encoded in base64: -+ sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0); -+ if (randomkey.charAt(randomkey.length-1) !== '=') -+ randomkey+='='; // Add trailing = if missing. - var cipherdata = zeroCipher(randomkey, $('textarea#message').val()); - var data_to_send = { data: cipherdata, - expire: $('select#pasteExpiration').val(), +@@ -340,7 +340,13 @@ + + showStatus('Sending paste...', spin=true); + +- var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0); ++ var randomkey = (window.location.hash.length > 2) ? ++ // force key ++ window.location.hash.substring(1) : ++ // Generate a random 256 bits key, encoded in base64: ++ sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0); ++ if (randomkey.charAt(randomkey.length-1) !== '=') ++ randomkey+='='; // Add trailing = if missing. + var cipherdata = zeroCipher(randomkey, $('textarea#message').val()); + var data_to_send = { data: cipherdata, + expire: $('select#pasteExpiration').val(),