Пример #1
0
                 $response["success"] = true;
                 $response["update"] = (int) $r->votes;
             } elseif (json_last_error() == JSON_ERROR_NONE && isset($r->status) && isset($r->message) && $r->status == false) {
                 $response["success"] = false;
                 $response["msg"] = $r->message;
             } else {
                 $response["success"] = false;
                 $response["msg"] = "The server did not respond properly. Please try again later...";
             }
         }
     }
     echo json_encode($response);
     exit;
 } elseif (!empty($_REQUEST['id']) && !empty($_REQUEST['page']) && ($N = manual_notes_load($_REQUEST['page'])) && array_key_exists($_REQUEST['id'], $N) && !empty($_REQUEST['vote']) && ($_REQUEST['vote'] === 'up' || $_REQUEST['vote'] === 'down')) {
     if (!empty($_POST['challenge']) && !empty($_POST['func']) || empty($_POST['arga']) || empty($_POST['argb'])) {
         if (!test_answer($_POST['func'], $_POST['arga'], $_POST['argb'], $_POST['challenge'])) {
             $error = "Incorrect answer! Please try again.";
         } else {
             if ($_REQUEST['vote'] == 'up') {
                 $N[$_REQUEST['id']]['votes']['up']++;
             } elseif ($_REQUEST['vote'] == 'down') {
                 $N[$_REQUEST['id']]['votes']['down']++;
             }
             $update = $N[$_REQUEST['id']]['votes']['up'] - $N[$_REQUEST['id']]['votes']['down'];
             $hash = substr(md5($_REQUEST['page']), 0, 16);
             $notes_file = $_SERVER['DOCUMENT_ROOT'] . "/backend/notes/" . substr($hash, 0, 2) . "/{$hash}";
             if (file_exists($notes_file)) {
                 $data = array("noteid" => $_REQUEST['id'], "sect" => $_REQUEST['page'], "vote" => $_REQUEST['vote'], "ip" => $_SERVER['REMOTE_ADDR']);
                 if (($r = posttohost($master_url, $data)) !== null && strpos($r, "failed to open socket to") === false) {
                     $r = json_decode($r);
                     if (json_last_error() == JSON_ERROR_NONE && isset($r->status) && $r->status && isset($r->votes)) {
Пример #2
0
 $note = trim($_POST['note']);
 // Convert all line-endings to unix format,
 // and don't allow out-of-control blank lines
 $note = str_replace("\r\n", "\n", $note);
 $note = str_replace("\r", "\n", $note);
 $note = preg_replace("/\n{2,}/", "\n\n", $note);
 // Don't pass through example username
 if ($user == "*****@*****.**") {
     $user = "******";
 }
 // We don't know of any error now
 $error = FALSE;
 // No note specified
 if (strlen($note) == 0) {
     $error = "You have not specified the note text.";
 } elseif (!test_answer($_POST['func'], $_POST['arga'], $_POST['argb'], $_POST['answer'])) {
     $error = 'SPAM challenge failed.';
 } elseif (stristr($user, "|")) {
     $error = "You have included bad characters within your username. We appreciate you may want to obfuscate your email further, but we have a system in place to do this for you.";
 } elseif (strlen($note) >= 4096) {
     $error = "Your note is too long. You'll have to make it shorter before you can post it. Keep in mind that this is not the place for long code examples!";
 } elseif (strlen($note) < 32) {
     $error = "Your note is too short. Trying to test the notes system? Save us the trouble of deleting your test, and don't. It works.";
 } else {
     // Split the note by whitespace, and check length
     foreach (preg_split("/\\s+/", $note) as $chunk) {
         if (strlen($chunk) > 120) {
             $error = "Your note contains a bit of text that will result in a line that is too long, even after using wordwrap().";
             break;
         }
     }