<?php include_once dirname(__FILE__) . "/../configs.php"; $success = false; $message = ""; $logged_in = ManagerActions::isLoggedIn(); if ($logged_in && isset($_POST["json"])) { $json = json_decode($_POST['json'], true); $id = trim(strip_tags($json["id"])); $post_data = $json["post_data"]; if (count($post_data > 0)) { try { $db = MongoConnection(); $db_getter = new MongoGetter($db); $db_getter->updateSinglePostDataById($id, $post_data); $success = true; $message = "Post Edited"; } catch (MongoCursorException $e) { $message = "error message: " . $e->getMessage() . "\n"; } } } echo returnMessage($success, $message, null);
<?php $server = dirname(__FILE__) . "/../"; require_once $server . "/configs.php"; //$manager = new ManagerActions(); if (!ManagerActions::isLoggedIn() && !isset($_POST['username']) && !isset($_POST['pw'])) { ManagerActions::authenticate(); } else { if (!ManagerActions::isLoggedIn()) { $sent_user = $_POST['username']; $sent_pw = $_POST['pw']; if (ManagerActions::loginSuccess($sent_user, $sent_pw)) { //if true will set 2 session variables and log to file //give access to page if user is a key in array and the value matches the PW include $server . "/pages/manager_body.php"; } else { //wrong guess make sleep to prevent brute force sleep(4); ManagerActions::authenticate(); } } else { include $server . "/pages/manager_body.php"; } } //end else