Exemple #1
0
    CourseRoadDB::changeRoadHash($oldhash, $newhash, $athena);
    dieJSON(array('success' => true, 'hash' => $newhash));
}
// And when the user adds a comment
if (isset($_POST['setRoadComment'])) {
    requireCSRF();
    requirePostDataFields('hash', 'comment');
    $hash = $_POST['hash'];
    $comment = htmlentities(substr($_POST['comment'], 0, 100));
    if (!$loggedin) {
        dieJSON(array('error' => true, 'errorDesc' => 'Not logged in', 'hash' => $oldhash));
    }
    if ($athena !== hashOwner($hash) && $hash !== 'null') {
        dieJSON(array('error' => true, 'errorDesc' => 'Bad owner or hash', 'hash' => $oldhash));
    }
    CourseRoadDB::setRoadComment($hash, $comment, $athena);
    dieJSON(array('success' => true, 'hash' => $hash, 'comment' => stripslashes($comment)));
}
//Similarly, runs when the user deletes a road.
if (isset($_POST['deleteRoad'])) {
    requireCSRF();
    requirePostDataFields('hash');
    $hash = $_POST['hash'];
    if (!$loggedin) {
        dieJSON(array('error' => true, 'errorDesc' => 'Not logged in', 'hash' => $oldhash));
    }
    if ($athena !== hashOwner($hash) && $hash !== 'null') {
        dieJSON(array('error' => true, 'errorDesc' => 'Bad owner or hash', 'hash' => $oldhash));
    }
    if ($hash !== 'null') {
        CourseRoadDB::deleteRoad($hash, $athena);