$syntaxcoloring = $_POST['syntaxcoloring']; if ($syntaxcoloring != '0' && $syntaxcoloring != '1') { $error = true; } if ($syntaxcoloring != '0') { $meta['syntaxcoloring'] = true; } } // You can't have an open discussion on a "Burn after reading" paste: if (isset($meta['burnafterreading'])) { unset($meta['opendiscussion']); } // Optional nickname for comments if (!empty($_POST['nickname'])) { $nick = $_POST['nickname']; if (!validSJCL($nick)) { $error = true; } else { $meta['nickname'] = $nick; // Generation of the anonymous avatar (Vizhash): // If a nickname is provided, we generate a Vizhash. // (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']); 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. } }
mkdir('data', 0705); file_put_contents('data/.htaccess', "Allow from none\nDeny from all\n", LOCK_EX); } // Make sure last paste from the IP address was more than 10 seconds ago. if (limitReached($_SERVER['REMOTE_ADDR'])) { echo json_encode(array('status' => 1, 'message' => 'Please wait 10 seconds between each post.')); exit; } // Make sure content is not too big. $data = $_POST['data']; if (strlen($data) > 2000000) { echo json_encode(array('status' => 1, 'message' => 'Paste is too big! File size limit for encrypted data is 2mb.')); exit; } // Make sure format is correct. if (!validSJCL($data)) { echo json_encode(array('status' => 1, 'message' => 'Invalid data.')); exit; } // Read additional meta-information. $meta = array(); if ($error) { echo json_encode(array('status' => 1, 'message' => 'Invalid data.')); exit; } // We just want a small hash to avoid collisions: Half-MD5 (64 bits) will do the trick. $dataid = substr(hash('md5', $data), 0, 16); $storage = array('data' => $data); $storagedir = dataid2path($dataid); if (!is_dir($storagedir)) { mkdir($storagedir, $mode = 0705, $recursive = true);