wok view zerobin/stuff/zerobin.u @ rev 21280

updated libqcow and libqcow-dev (20120225 -> 20181227)
author Hans-G?nter Theisgen
date Sun Apr 14 16:12:00 2019 +0100 (2019-04-14)
parents 7a16da2c93b9
children 5b0e64c0628a
line source
1 --- index.php
2 +++ index.php
3 @@ -17,6 +17,13 @@
4 $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
5 }
7 +function remote_address()
8 +{
9 + // if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
10 + // return $_SERVER["HTTP_X_FORWARDED_FOR"];
11 + return $_SERVER["REMOTE_ADDR"];
12 +}
13 +
14 // trafic_limiter : Make sure the IP address makes at most 1 request every 10 seconds.
15 // Will return false if IP address made a call less than 10 seconds ago.
16 function trafic_limiter_canPass($ip)
17 @@ -157,7 +164,7 @@
18 }
20 // Make sure last paste from the IP address was more than 10 seconds ago.
21 - if (!trafic_limiter_canPass($_SERVER['REMOTE_ADDR']))
22 + if (!trafic_limiter_canPass(remote_address()))
23 { echo json_encode(array('status'=>1,'message'=>'Please wait 10 seconds between each post.')); exit; }
25 // Make sure content is not too big.
26 @@ -229,7 +236,7 @@
27 // (We assume that if the user did not enter a nickname, he/she wants
28 // to be anonymous and we will not generate the vizhash.)
29 $vz = new vizhash16x16();
30 - $pngdata = $vz->generate($_SERVER['REMOTE_ADDR']);
31 + $pngdata = $vz->generate(remote_address());
32 if ($pngdata!='') $meta['vizhash'] = 'data:image/png;base64,'.base64_encode($pngdata);
33 // Once the avatar is generated, we do not keep the IP address, nor its hash.
34 }
35 --- js/zerobin.js
36 +++ js/zerobin.js
37 @@ -340,7 +340,13 @@
39 showStatus('Sending paste...', spin=true);
41 - var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0);
42 + var randomkey = (window.location.hash.length > 2) ?
43 + // force key
44 + window.location.hash.substring(1) :
45 + // Generate a random 256 bits key, encoded in base64:
46 + sjcl.codec.base64.fromBits(sjcl.random.randomWords(8,0),0);
47 + if (randomkey.charAt(randomkey.length-1) !== '=')
48 + randomkey+='='; // Add trailing = if missing.
49 var cipherdata = zeroCipher(randomkey, $('textarea#message').val());
50 var data_to_send = { data: cipherdata,
51 expire: $('select#pasteExpiration').val(),
52 @@ -410,6 +416,7 @@
53 $('button#sendbutton').show();
54 $('button#clonebutton').hide();
55 $('button#rawtextbutton').hide();
56 + $('button#downloadbutton').hide();
57 $('div#expiration').show();
58 $('div#remainingtime').hide();
59 $('div#burnafterreadingoption').show();
60 @@ -438,6 +445,7 @@
61 $('button#clonebutton').show();
62 }
63 $('button#rawtextbutton').show();
64 + $('button#downloadbutton').show();
66 $('div#expiration').hide();
67 $('div#burnafterreadingoption').hide();
68 @@ -457,6 +465,14 @@
69 var newDoc = document.open('text/html', 'replace');
70 newDoc.write('<pre>'+paste+'</pre>');
71 newDoc.close();
72 +}
73 +
74 +/** Download raw text
75 + */
76 +function downLoad()
77 +{
78 + var paste = $('div#cleartext').html();
79 + document.location = 'data:Application/octet-stream,' + encodeURIComponent(paste);
80 }
82 /**
83 --- tpl/page.html
84 +++ tpl/page.html
85 @@ -47,6 +47,7 @@
86 <button id="sendbutton" onclick="send_data();return false;" style="display:none;"><img src="img/icon_send.png#" width="18" height="15" />Send</button>
87 <button id="clonebutton" onclick="clonePaste();return false;" style="display:none;"><img src="img/icon_clone.png#" width="15" height="17" />Clone</button>
88 <button id="rawtextbutton" onclick="rawText();return false;" style="display:none; "><img src="img/icon_raw.png#" width="15" height="15" style="padding:1px 0px 1px 0px;"/>Raw text</button>
89 + <button id="downloadbutton" onclick="downLoad();return false;" style="display:none; "><img src="img/icon_new.png#" width="11" height="15" style="padding:1px 0px 1px 0px;"/>Download</button>
90 <div id="expiration" style="display:none;">Expires:
91 <select id="pasteExpiration" name="pasteExpiration">
92 <option value="5min">5 minutes</option>