function show_page() { $row = DB::queryFirstRow('SELECT id, name, email, grade, paid, attendance FROM individuals WHERE id=%i AND deleted="0"', $_GET['ID']); if ($row == null) { alert('Individual not found', -1); lmt_location('Home'); } else { if ($row['email'] == "") { alert('Individual was registered as part of a team', -1); lmt_location('Home'); } } $id = htmlentities($row['id']); $name = htmlentities($row['name']); $email = htmlentities($row['email']); $grade = htmlentities($row['grade']); $paid = $row['paid'] == "1" ? '<span style="color: red">Yes</span>' : 'No'; $attendance = $row['attendance'] == "1" ? '<span style="color: red">Present</span>' : 'Absent'; echo <<<HEREDOC <h1>Individual Check-in</h1> {$err} <form method="post" action="{$_SERVER['REQUEST_URI']}"> <table> <tr> <td>ID:</td> <td class="b">{$id} <span class="small">(<a href="../Data/Individual?ID={$id}">Data Page</a>)</span></td> </tr><tr> <td>Name:</td> <td class="b">{$name}</td> </tr><tr> <td>Email:</td> <td class="b">{$email}</td> </tr><tr> <td>Grade:</td> <td class="b">{$grade}</td> </tr><tr> <td>Paid:</td> <td class="b">{$paid}</td> </tr><tr> <td>Attendance: </td> <td class="b">{$attendance}<br /><br /></td> </tr><tr> <td>Check-in:</td> <td> <input id="paid" type="checkbox" name="paid" value="Yes" checked="checked"/> <label for="paid">Payment has been received</label> <br /> <input id="attendance" type="checkbox" name="attendance" value="Yes" checked="checked"/> <label for="attendance">Individual is present</label> </td> </tr><tr> <td></td> <td> <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" /> <input type="submit" name="do_lmt_checkin_individual" value="Update" /> <a href="Home">Cancel</a> </td> </tr> </table> </form> HEREDOC; die; }
function do_change_paid() { if ($_POST['xsrf_token'] != $_SESSION['xsrf_token']) { trigger_error('XSRF code incorrect', E_USER_ERROR); } DB::queryRaw('UPDATE schools SET teams_paid="' . htmlentities(intval($_POST['teams_paid'])) . '" WHERE school_id="' . htmlentities($_GET['ID']) . '" AND teams_paid <> "' . htmlentities(intval($_POST['teams_paid'])) . '" LIMIT 1'); global $LMT_DB; if (mysqli_affected_rows($LMT_DB) == 1) { alert('Number of teams paid was changed', 1); } lmt_location('Backstage/Data/School?ID=' . $_GET['ID']); }
function do_change_grade() { if ($_POST['xsrf_token'] != $_SESSION['xsrf_token']) { trigger_error('XSRF code incorrect', E_USER_ERROR); } $grade_msg = validate_grade($_POST['grade']); if ($grade_msg !== true) { display_individual($grade_msg, 'document.forms[\'lmtDataIndividualGrade\'].grade.focus();'); } $row = DB::queryFirstRow('SELECT grade FROM individuals WHERE id=%i', $_GET['ID']); if ($_POST['grade'] == $row['grade']) { header('Location: Individual?ID=' . $_GET['ID']); die; } DB::queryRaw('UPDATE individuals SET grade="' . mysqli_real_escape_string(DB::get(), $_POST['grade']) . '" WHERE id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" LIMIT 1'); alert('Grade was changed', 1); lmt_location('Backstage/Data/Individual?ID=' . $_GET['ID']); }
function lmt_reg_restrict_access($level) { // Registration must be open if (!registration_is_open()) { lmt_location(''); } // Check permissions if ($level == 'X' && isset($_SESSION['LMT_user_id'])) { lmt_location('Registration'); } if ($level == 'L' && !isset($_SESSION['LMT_user_id'])) { lmt_location('Registration'); } }