} $inval = $indata->{$opfieldid}; switch ($opfieldtype) { case 'text': if (!is_string($inval)) { finishWith('invalid: ' . $opfieldid); } break; case 'list': if (!is_array($inval)) { finishWith('invalid: ' . $opfieldid); } foreach ($inval as $val) { if (!is_string($val)) { finishWith('invalid val in ' . $opfieldid); } } break; } $indata_processed->{$opfieldid} = $inval; } $op_part_data = json_encode($indata_processed); } $return = joinOperation($op['id'], $user['id'], $op_part_data); $status = $return['status']; if ($status !== TRUE) { finishWith($status); } attachParticipantToOperation($op, $user['id']); $opHtml = renderOpWithTasks($op); echo json_encode(array('status' => 'success', 'ophtml' => $opHtml, 'addedpoints' => $return['addedpoints']));
if (!$result) { finishWith('failure'); } } $stops_for_email = array(); for ($i = 0; $i < count($stopid_inps); $i++) { $stopid_inp = $stopid_inps[$i]; $stopname = $stopnames[$i]; $stops_for_email[] = "{$stopname} ({$stopid_inp})"; } sendNewSignupEmail($name, $email, $stops_for_email, $notes, $op_result == 'already'); finishWith('success'); } else { if ($stopmode == 'stopaddress') { if (!isset($_POST['stopaddress'])) { finishWith('incomplete'); } $stoptoadopt = trim($_POST['stopaddress']); if (empty($stoptoadopt)) { finishWith('nostoptoadopt'); } $result = addAdoptedStop($userid, $stoptoadopt, null, null); if (!$result) { finishWith('failure'); } sendNewSignupEmail($name, $email, array($stoptoadopt), $notes, $op_result == 'already'); finishWith('success'); } else { finishWith('invalidstopmode'); } }
include '../../lib/db.php'; init_db(); include '../../lib/admindb.php'; if (!isset($_POST['id']) || !isset($_POST['stopname']) || !isset($_POST['stopid']) || !isset($_POST['agency']) || !isset($_POST['given']) || !isset($_POST['nameonsign']) || !isset($_POST['abandoned'])) { finishWith('missing'); } $id = trim($_POST['id']); $stopname = trim($_POST['stopname']); $stopid = empty($_POST['stopid']) ? null : intval($_POST['stopid']); $agency = empty($_POST['agency']) ? null : trim($_POST['agency']); if (!is_null($stopid) && is_null($agency)) { finishWith('agencynull'); } $given = $_POST['given'] == 'true' ? true : false; $nameonsign = trim($_POST['nameonsign']); $abandoned = $_POST['abandoned'] == 'true' ? true : false; if ($given && empty($nameonsign)) { finishWith('given_nameonsign'); } $result = updateAdoptedStop($id, $stopname, $stopid, $agency, $given, $nameonsign, $abandoned); if ($result === TRUE) { if ($given) { $stop_classification = 'notask'; } else { $stop_classification = 'notgiven'; } echo json_encode(array('status' => 'success', 'stop_classification' => $stop_classification)); exit; } else { finishWith('phperror: ' . $result); }
<?php header('Content-Type: application/json'); function finishWith($status, $sid = NULL) { exit(json_encode(array('status' => $status))); } if (!isset($_COOKIE["sid"])) { finishWith('nologin'); } include '../lib/db.php'; init_db(); $user = getSessionUser($_COOKIE["sid"]); if (is_null($user)) { setcookie('sid', '', time() - 3600); finishWith('nologin'); } if (!isset($_POST['current-password']) || !isset($_POST['new-password'])) { finishWith('incomplete'); } $currPass = $_POST['current-password']; $newPass = $_POST['new-password']; $result = changePassword($user['id'], $currPass, $newPass); if ($result !== TRUE) { finishWith($result); } finishWith('success');
<?php header('Content-Type: application/json'); function finishWith($status, $sid = NULL) { exit(json_encode(array('status' => $status, 'sid' => $sid))); } if (!isset($_POST['email'])) { finishWith('noemail'); } if (!isset($_POST['password'])) { finishWith('nopassword'); } $email = $_POST['email']; $password = $_POST['password']; include '../lib/db.php'; init_db(); $sid = createNewSession($email, $password); if (is_null($sid)) { finishWith('fail'); } else { finishWith('success', $sid); }