function handlePostRequest($type, $eventid) { $data = json_decode(file_get_contents('php://input')); $write = array(); if (lockDatabase() !== FALSE) { if ($type != 'addroute') { $loggedIn = logIn($data); } else { // don't need to log in to add a route $loggedIn = TRUE; } if ($loggedIn) { //rg2log($type); switch ($type) { case 'addroute': $write = addNewRoute($eventid, $data); @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'addmap': $write = addNewMap($data); break; case 'createevent': $write = addNewEvent($data); @unlink(CACHE_DIRECTORY . "events.json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'editevent': $write = editEvent($eventid, $data); @unlink(CACHE_DIRECTORY . "events.json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'deleteevent': $write = deleteEvent($eventid); @unlink(CACHE_DIRECTORY . "events.json"); @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "courses_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'deleteroute': $write = deleteRoute($eventid); @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'deletecourse': $write = deleteCourse($eventid); @unlink(CACHE_DIRECTORY . "results_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "courses_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "tracks_" . $eventid . ".json"); @unlink(CACHE_DIRECTORY . "stats.json"); break; case 'login': // handled by default before we got here $write["ok"] = TRUE; $write["status_msg"] = "Login successful"; break; default: rg2log("Post request not recognised: " . $type); $write["status_msg"] = "Request not recognised: " . $type; $write["ok"] = FALSE; break; } } else { $write["ok"] = FALSE; $write["status_msg"] = "Incorrect user name or password"; } unlockDatabase(); } else { $write["status_msg"] = "File lock error"; $write["ok"] = FALSE; } $keksi = generateNewKeksi(); $write["keksi"] = $keksi; header("Content-type: application/json"); $write["version"] = RG2VERSION; echo json_encode($write); }
public function actionEventshead() { global $urlRequestRoot, $sourceFolder, $templateFolder, $cmsFolder, $moduleFolder; $moduleComponentId = $this->moduleComponentId; $userId = $this->userId; require_once "{$sourceFolder}/{$moduleFolder}/events/events_common.php"; require_once "{$sourceFolder}/{$moduleFolder}/events/events_forms.php"; if (isset($_POST['type'])) { if ($_POST['type'] == 'add') { validateAddEventData($moduleComponentId); } else { if ($_POST['type'] == 'edit') { validateEditEventData($moduleComponentId); } else { if ($_POST['type'] == "notif") { $query = "INSERT INTO `events_notifications` VALUES (NULL, '{$_POST['content']}', CURRENT_TIMESTAMP);"; //echo NOW(); mysql_query($query); // header('Location: ./+eventsHead'); // } } } exit; } if (isset($_GET['subaction'])) { if ($_GET['subaction'] == "addEvent") { return addNewEvent(); } if ($_GET['subaction'] == "deleteEvent") { return deleteEvent($_POST['eventId'], $moduleComponentId); exit; } if ($_GET['subaction'] == "editEvent") { return editEvent($_GET['eventId'], $moduleComponentId); } if ($_GET['subaction'] == "notif") { //return ":LL"; return getEventsForm(); } } else { return selectEventsHeadSubaction($moduleComponentId); } }
<?php session_start(); require_once "../../inc/config.php"; require_once ROOT_PATH . "inc/database.php"; include ROOT_PATH . "inc/header.php"; $admin = getUser($_SESSION["user_id"]); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (password_verify($_POST["admin_password"], $admin["password"])) { if ($_POST["max"] == "") { $max = 0; } else { $max = $_POST["max"]; } $new_event = addNewEvent($_POST["name"], str_replace(array("\r\n", "\r", "\n"), "<br>", $_POST["description"]), $_POST["date"], $_POST["start-time"], $_POST["end-time"], $_POST["member-price"], $_POST["nonmember-price"], $max, $_POST["deadline"]); $_SESSION["new-event"] = true; } else { $_SESSION["incorrect-password"] = true; } var_dump($new_event); header("Location:/admin/events/edit/" . $new_event . "/"); } else { ?> <html> <?php include ROOT_PATH . "inc/head.php"; ?> <body> <div class="wrapper content"> <div class="row"> <nav class="col-20">