<?php require_once "includes.php"; if (!isset($_GET["event"])) { header("Location: /" . SITE_ROOT); } $event = get_event($_GET["event"]); if ($event == null) { header("Location: /" . SITE_ROOT); } if ($event["public"] == 0 && $event["account"] != $account && !(isset($_GET["key"]) && validate_invite($event["id"], $_GET["key"])) && !($account !== false && validate_invite_account($event["id"], $account))) { header("Location: /" . SITE_ROOT); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($account === false && (isset($_POST["name"]) && $_POST["name"] == "")) { echo "Please enter your name"; } else { $intervals = array(); $ids = get_schedules_for_event($event["id"]); foreach ($ids as $id) { array_push($intervals, array($id["id"], $_POST[$id["id"] . ""])); } $userid = 0; if ($account !== false) { $userid = add_vote("", $intervals, $event["id"], $account); } else { if ($event["public"] == 0) { $userid = add_vote(isset($_POST["name"]) ? $_POST["name"] : "", $intervals, $event["id"], 0, $_GET["key"]); } else { $userid = add_vote(isset($_POST["name"]) ? $_POST["name"] : "", $intervals, $event["id"]); }
private function validate_invite($user = '') { $this->load->model(array('Team', 'Project')); $invite = null; $user_uuid = ''; $user_id = ''; if ($user) { $user_uuid = $user->uuid; $user_id = $user->id; } $invite_key = $this->post('invite_key', TRUE); $invite_type = $this->post('invite_type', TRUE); if ($invite_key && $invite_type) { /* Team Invite */ if ($invite_type == INVITE_TYPE_TEAM) { $invite = $this->Team_Invite->load_by_key($invite_key); validate_invite($invite); /* Validate that there is room to join the team */ $team = $this->Team->load_fields($invite->team_id, 'owner_id'); validate_user_add($team->owner_id); } else { $invite = $this->Project_Invite->load_by_key($invite_key); validate_invite($invite, $user_id); /* Validate that there is room to join the team */ $project = $this->Project->load($invite->project_id); $team = $this->Team->load_fields($project->team_id, 'owner_id'); validate_user_add($team->owner_id, $user_uuid); } } return $invite; }