Example #1
0
<?
require("_database.php");
require("_functions.php");

$id = $_GET['id'];
$version = $_GET['version'];
$content = file_get_contents('php://input');
$success = false;

if (!$id) {
  $rslt = insertNote($content);
  $id = $rslt['id'];
  $version = $rslt['version'];
  $success = true;
}
else {
  $conflict = updateNote($id, $version, $content);

  if ($conflict) {
    $version = $conflict;
  } else {
    $version += 1;
  }
}

setNoteID($id);

if (!$conflict) {
  print "OK\n$id\n$version";
} else {
  print "CONFLICT\n$id\n$version";
Example #2
0
if (isset($_POST["notesRequest_Type"])) {
    if ($_POST["notesRequest_Type"] == "page") {
        if (ctype_digit($_POST["notesRequest_LastGroupNo"]) && ctype_digit($_POST["noteRequest_Page"])) {
            getNotesPage($conn, $_POST["notesRequest_LastGroupNo"], $_POST["noteRequest_Page"]);
        }
    } else {
        if ($_POST["notesRequest_Type"] == "remove") {
            if (ctype_digit($_POST["noteNo"])) {
                removeNote($conn, $_POST["noteNo"]);
            }
        } else {
            if ($_POST["notesRequest_Type"] == "elementno") {
                if (ctype_digit($_POST["notesRequest_Elements"])) {
                    getNotesElementNo($conn, $_POST["notesRequest_Elements"]);
                }
            } else {
                if ($_POST["notesRequest_Type"] == "checkupdate") {
                    checkUpdates($conn, $_POST["notesRequest_CheckNotes"]);
                } else {
                    if ($_POST["notesRequest_Type"] == "add") {
                        insertNote($conn);
                    } else {
                        if ($_POST["notesRequest_Type"] == "update") {
                            updateNote($conn);
                        }
                    }
                }
            }
        }
    }
}
Example #3
0
function bagCheckSaveDayInformation($bagCheckInfo)
{
    // Make connection to the database
    $dbInfo = initialize_db_info();
    $dbLink = db_connect($dbInfo);
    db_select($dbLink, $dbInfo);
    // First check to see if the note is new.
    $noteId = $bagCheckInfo->getNoteId();
    $noteContent = $bagCheckInfo->getNote();
    if ($noteId == -1) {
        if ($noteContent != "") {
            $noteId = insertNote($noteContent);
            $bagCheckInfo->setNoteId($noteId);
        }
    } else {
        // Update existing Note
        $updateSql = generateBCNoteUpdateSql($bagCheckInfo);
        $result = mysql_query($updateSql, $dbLink);
        if (!$result) {
            echo $updateSql;
            throw new Exception('Save Update Note Info Failed: ' . $updateSql);
        }
    }
    $dayId = $bagCheckInfo->getId();
    if ($dayId == -1) {
        // Insert new day information
        $insertSql = generateBCDayInsertSql($bagCheckInfo);
        $result = mysql_query($insertSql, $dbLink);
        if (!$result) {
            echo $insertSql;
            throw new Exception('Save Insert Day Info Failed: ' . $insertSql);
        }
        $dayId = getInsertId();
        $bagCheckInfo->setId($dayId);
    } else {
        // Update existing day information
        $updateSql = generateBCDayUpdateSql($bagCheckInfo);
        $result = mysql_query($updateSql, $dbLink);
        if (!$result) {
            echo $updateSql;
            throw new Exception('Save Update Day Info Failed: ' . $updateSql);
        }
    }
    // Save the hunt information
    bagCheckSaveHuntInformation($bagCheckInfo);
}