die('Error: Team name or code must not be empty'); } $name = $_POST['name']; $code = $_POST['code']; $output = create_team($name, $code); echo $output; break; case 'join': if (!isset($_POST['code'])) { die('Error: Team code must not be empty'); } if (empty($_POST['code'])) { die('Error: Team code must not be empty'); } $code = $_POST['code']; $output = join_team($code); echo $output; break; case 'leave': if (!isset($_SESSION['User'])) { die("You are not logged in! You cannot leave a team!!"); } if (!load_user_data('team')) { die("You are not on a team."); } $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); $user = $_SESSION['User']; $euser = $conn->real_escape_string($user); $query = "UPDATE `users` SET team=NULL WHERE name='{$euser}'"; $conn->query($query); if ($conn->error) {
public function process_post($action) { switch ($action) { case "login": $status = login_member($this); return $status; break; case "autologin": $status = autologin_member($this); return $status; break; case "reset-password-link": $status = get_reset_password_code($this); if ($status["status_code"] == 200) { $this->first_name = get_team_member_name_by_email($this->email); $this->reset_code = $status["reset_code"]; $this->reset_password_link = json_decode(file_get_contents("env.json"))->website_host . "/reset-password.php?code=" . $this->reset_code . "&email=" . $this->email; send_password_reset_code($this); } return $status; break; case "reset-password": $status = reset_password($this); return $status; break; case "register": $status = register_new_member($this); if ($status["status_code"] == 200) { if ($this->team_id != "" && $this->team_name == get_team_name_by_team_id($this->team_id)) { $this->member_id = get_team_member_id_by_email($this->email); join_team($this); } send_registration_success_email($this); } return $status; break; case "funds": $this->email = get_team_member_email_by_id($this->member_id); $status = post_add_fund($this); send_add_fund_email($this); return $status; break; case "join-team": $this->first_name = get_team_member_name_by_team_member_id($this->member_id); $this->team_name = get_team_name_by_team_id($this->team_id); $this->email = get_team_member_email_by_id($this->member_id); $status = join_team($this); send_join_team_email($this); return $status; break; case "leave-team": $status = leave_team($this); send_leave_team_email($this); return $status; break; case "invite": $this->team_name = get_team_name_by_team_id($this->team_id); if ($this->team_name != "") { $this->invite_team_link = json_decode(file_get_contents("env.json"))->website_host . "/index.php?team-id=" . $this->team_id . "&team-name=" . urlencode($this->team_name); $status = invite_to_team($this); return $status["status_code"]; } else { return 400; } break; case "edit-member": $status = edit_member($this); return $status == true ? 200 : 400; break; default: break; } }