function delete_user($username) { // Connect to the DB $ret = create_connection($connection); if ($ret !== true) { return $ret; } // Validate input $ret = validate_input($username); if ($ret !== true) { $connection->close(); return $ret; } // Get user data $user_data = get_user_data($username, $connection); if ($user_data === false) { $connection->close(); return 'Username provided does not exist'; } // Delete feeds if (delete_feeds($user_data, $connection) !== true) { $connection->close(); return 'Error while deleting the feeds'; } // Delete inputs if (delete_inputs($user_data, $connection) !== true) { $connection->close(); return 'Error while deleting the inputs'; } // Delete EWatcher panels if (delete_ewatcher($user_data, $connection) !== true) { $connection->close(); return 'Error while deleting user configuration (EWatcher)'; } // Delete user if (delete_user_data($user_data, $connection) !== true) { $connection->close(); return 'Error while deleting user data'; } $connection->close(); return true; }
include_once 'main.php'; if (check_login() != true) { exit; } if ($_SESSION['user_is_admin'] == '1' && isset($_GET['list_users'])) { echo list_users(); } elseif ($_SESSION['user_is_admin'] == '1' && isset($_GET['reset_user_password'])) { $user_id = mysql_real_escape_string($_POST['user_id']); echo reset_user_password($user_id); } elseif ($_SESSION['user_is_admin'] == '1' && isset($_GET['change_user_permissions'])) { $user_id = mysql_real_escape_string($_POST['user_id']); echo change_user_permissions($user_id); } elseif ($_SESSION['user_is_admin'] == '1' && isset($_GET['delete_user_data'])) { $user_id = mysql_real_escape_string($_POST['user_id']); $data = $_POST['delete_data']; echo delete_user_data($user_id, $data); } elseif ($_SESSION['user_is_admin'] == '1' && isset($_GET['delete_all'])) { $data = $_POST['delete_data']; echo delete_all($data); } elseif ($_SESSION['user_is_admin'] == '1' && isset($_GET['save_system_configuration'])) { $price = mysql_real_escape_string($_POST['price']); echo save_system_configuration($price); } elseif (isset($_GET['get_usage'])) { echo get_usage(); } elseif (isset($_GET['get_reservation_reminders'])) { echo get_reservation_reminders(); } elseif (isset($_GET['toggle_reservation_reminder'])) { echo toggle_reservation_reminder(); } elseif (isset($_GET['change_user_details'])) { $user_name = mysql_real_escape_string(trim($_POST['user_name'])); $user_email = mysql_real_escape_string($_POST['user_email']);