# Code Context Generated # Generated on: 2025-07-14 03:56:57 # ====================== Directory Tree: EventPlanner/ ├── api │ └── endpoints.php ├── config │ └── database.php ├── context_generator (5).php ├── host.html ├── rsvp.html └── schema.sql # ====================== # File: rsvp.html # ====================== Event Planner Poll App - Game Night

🎮 Event Planner Poll App

Enter your event code to join the game night!

🎮 Game Night Details

Loading...

Loading...

Loading...

Loading...

Loading...

🏆 Top Game Choices

Loading...

🍿 Snacks Being Brought

Loading...

👥 People Coming

Current Attendees:

    Loading...
# ====================== # File: host.html # ====================== Host Event - Game Night Planner

Create Game Night Event

# ====================== # File: schema.sql # ====================== -- Event Planner Poll App Database Schema -- Run this file to create the database structure CREATE DATABASE IF NOT EXISTS harper_event_planner_db; USE harper_event_planner_db; -- Events table CREATE TABLE events ( event_id INT AUTO_INCREMENT PRIMARY KEY, event_code VARCHAR(10) UNIQUE NOT NULL, host_name VARCHAR(100) NOT NULL, location_address TEXT, rsvp_deadline DATETIME NOT NULL, final_date_time DATETIME NULL, host_provides_snacks BOOLEAN DEFAULT FALSE, event_name VARCHAR(255) DEFAULT 'Game Night', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); -- Event date options table CREATE TABLE event_date_options ( option_id INT AUTO_INCREMENT PRIMARY KEY, event_id INT NOT NULL, date_time_string VARCHAR(255) NOT NULL, date_time_value DATETIME NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (event_id) REFERENCES events(event_id) ON DELETE CASCADE ); -- Games table (pre-populated with suggested games) CREATE TABLE games ( game_id INT AUTO_INCREMENT PRIMARY KEY, game_name VARCHAR(100) NOT NULL UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Attendees table CREATE TABLE attendees ( attendee_id INT AUTO_INCREMENT PRIMARY KEY, event_id INT NOT NULL, first_name VARCHAR(100) NOT NULL, is_rsvp BOOLEAN DEFAULT TRUE, brings_snack BOOLEAN DEFAULT FALSE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (event_id) REFERENCES events(event_id) ON DELETE CASCADE, UNIQUE KEY unique_attendee (event_id, first_name) ); -- Attendee date votes table CREATE TABLE attendee_date_votes ( vote_id INT AUTO_INCREMENT PRIMARY KEY, attendee_id INT NOT NULL, option_id INT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (attendee_id) REFERENCES attendees(attendee_id) ON DELETE CASCADE, FOREIGN KEY (option_id) REFERENCES event_date_options(option_id) ON DELETE CASCADE, UNIQUE KEY unique_vote (attendee_id, option_id) ); -- Attendee game preferences table CREATE TABLE attendee_game_preferences ( preference_id INT AUTO_INCREMENT PRIMARY KEY, attendee_id INT NOT NULL, game_id INT NOT NULL, rank INT DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (attendee_id) REFERENCES attendees(attendee_id) ON DELETE CASCADE, FOREIGN KEY (game_id) REFERENCES games(game_id) ON DELETE CASCADE, UNIQUE KEY unique_preference (attendee_id, game_id) ); -- Snacks brought table CREATE TABLE snacks_brought ( snack_id INT AUTO_INCREMENT PRIMARY KEY, attendee_id INT NOT NULL, snack_description TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (attendee_id) REFERENCES attendees(attendee_id) ON DELETE CASCADE ); -- Insert default games INSERT INTO games (game_name) VALUES ('Catan'), ('Spicy Uno'), ('Ticket to Ride'), ('Super Smash Bros'), ('Pounce'), ('Rummy'), ('Family Business'), ('Dragonwood'), ('Other'); -- Create indexes for better performance CREATE INDEX idx_events_code ON events(event_code); CREATE INDEX idx_attendees_event ON attendees(event_id); CREATE INDEX idx_date_votes_attendee ON attendee_date_votes(attendee_id); CREATE INDEX idx_game_preferences_attendee ON attendee_game_preferences(attendee_id); CREATE INDEX idx_snacks_attendee ON snacks_brought(attendee_id); -- Sample data for testing INSERT INTO events (event_code, host_name, location_address, rsvp_deadline, event_name) VALUES ('GAME001', 'Jadon & Anneliese', '4864 N. Larkwood Pl. Meridian ID 83646', '2024-07-25 18:00:00', 'Harper Game Nights'); INSERT INTO event_date_options (event_id, date_time_string, date_time_value) VALUES (1, 'July 27th @ 7 PM-10:30 PM', '2024-07-27 19:00:00'), (1, 'August 2nd @ 7 PM-10 PM', '2024-08-02 19:00:00'), (1, 'August 10th @ 6:30 PM-9:30 PM', '2024-08-10 18:30:00'); -- Function to generate random event codes DELIMITER // CREATE FUNCTION generate_event_code() RETURNS VARCHAR(10) READS SQL DATA DETERMINISTIC BEGIN DECLARE new_code VARCHAR(10); DECLARE code_exists INT DEFAULT 1; WHILE code_exists > 0 DO SET new_code = CONCAT('GAME', LPAD(FLOOR(RAND() * 1000), 3, '0')); SELECT COUNT(*) INTO code_exists FROM events WHERE event_code = new_code; END WHILE; RETURN new_code; END// DELIMITER ; # ====================== # File: api/endpoints.php # ====================== getConnection(); $method = $_SERVER['REQUEST_METHOD']; $path = $_SERVER['PATH_INFO'] ?? '/'; // Route handling switch ($path) { case '/event': if ($method === 'GET') { getEventDetails($db); } elseif ($method === 'POST') { createEvent($db); } break; case '/rsvp': if ($method === 'POST') { submitRSVP($db); } break; case '/games': if ($method === 'GET') { getGames($db); } break; case '/results': if ($method === 'GET') { getEventResults($db); } break; case '/finalize': if ($method === 'POST') { finalizeEvent($db); } break; default: Response::error('Endpoint not found', 404); } // Get event details by code function getEventDetails($db) { $event_code = $_GET['code'] ?? ''; if (!Security::validateEventCode($event_code)) { Response::error('Invalid event code format'); } try { // Get event info $stmt = $db->prepare(" SELECT e.*, (SELECT COUNT(*) FROM attendees WHERE event_id = e.event_id AND is_rsvp = 1) + 1 as rsvp_count FROM events e WHERE event_code = ? "); $stmt->execute([$event_code]); $event = $stmt->fetch(); if (!$event) { Response::error('Event not found', 404); } // Get date options $stmt = $db->prepare(" SELECT option_id, date_time_string, date_time_value, (SELECT COUNT(*) FROM attendee_date_votes adv JOIN attendees a ON adv.attendee_id = a.attendee_id WHERE adv.option_id = edo.option_id AND a.event_id = ?) as vote_count FROM event_date_options edo WHERE event_id = ? ORDER BY date_time_value "); $stmt->execute([$event['event_id'], $event['event_id']]); $dateOptions = $stmt->fetchAll(); // Get top game $stmt = $db->prepare(" SELECT g.game_name, COUNT(*) as vote_count FROM attendee_game_preferences agp JOIN games g ON agp.game_id = g.game_id JOIN attendees a ON agp.attendee_id = a.attendee_id WHERE a.event_id = ? GROUP BY g.game_id, g.game_name ORDER BY vote_count DESC, g.game_name LIMIT 1 "); $stmt->execute([$event['event_id']]); $topGame = $stmt->fetch(); // Get snack info $stmt = $db->prepare(" SELECT COUNT(*) as snack_count, GROUP_CONCAT(DISTINCT CONCAT(a.first_name, ': ', sb.snack_description) SEPARATOR ', ') as snacks FROM attendees a LEFT JOIN snacks_brought sb ON a.attendee_id = sb.attendee_id WHERE a.event_id = ? AND a.brings_snack = 1 "); $stmt->execute([$event['event_id']]); $snackInfo = $stmt->fetch(); Response::success([ 'event' => $event, 'dateOptions' => $dateOptions, 'topGame' => $topGame, 'snackInfo' => $snackInfo ]); } catch (PDOException $e) { Response::error('Database error: ' . $e->getMessage(), 500); } } // Create new event function createEvent($db) { $input = json_decode(file_get_contents('php://input'), true); $hostName = Security::sanitizeInput($input['host_name'] ?? ''); $locationAddress = Security::sanitizeInput($input['location_address'] ?? ''); $rsvpDeadline = $input['rsvp_deadline'] ?? ''; $eventName = Security::sanitizeInput($input['event_name'] ?? 'Game Night'); $hostProvidesSnacks = (bool)($input['host_provides_snacks'] ?? false); $dateOptions = $input['date_options'] ?? []; if (empty($hostName) || empty($rsvpDeadline) || empty($dateOptions)) { Response::error('Missing required fields'); } try { $db->beginTransaction(); // Generate unique event code $eventCode = 'GAME' . str_pad(mt_rand(0, 999), 3, '0', STR_PAD_LEFT); // Check if code exists and regenerate if needed $stmt = $db->prepare("SELECT COUNT(*) FROM events WHERE event_code = ?"); $stmt->execute([$eventCode]); while ($stmt->fetchColumn() > 0) { $eventCode = 'GAME' . str_pad(mt_rand(0, 999), 3, '0', STR_PAD_LEFT); $stmt->execute([$eventCode]); } // Insert event $stmt = $db->prepare(" INSERT INTO events (event_code, host_name, location_address, rsvp_deadline, event_name, host_provides_snacks) VALUES (?, ?, ?, ?, ?, ?) "); $stmt->execute([$eventCode, $hostName, $locationAddress, $rsvpDeadline, $eventName, $hostProvidesSnacks]); $eventId = $db->lastInsertId(); // Insert date options $stmt = $db->prepare(" INSERT INTO event_date_options (event_id, date_time_string, date_time_value) VALUES (?, ?, ?) "); foreach ($dateOptions as $option) { $stmt->execute([ $eventId, Security::sanitizeInput($option['string']), $option['value'] ]); } $db->commit(); Response::success([ 'event_code' => $eventCode, 'event_id' => $eventId ]); } catch (PDOException $e) { $db->rollback(); Response::error('Database error: ' . $e->getMessage(), 500); } } // Submit RSVP function submitRSVP($db) { $input = json_decode(file_get_contents('php://input'), true); $eventCode = Security::sanitizeInput($input['event_code'] ?? ''); $firstName = Security::sanitizeInput($input['first_name'] ?? ''); $dateVotes = $input['date_votes'] ?? []; $gamePreferences = $input['game_preferences'] ?? []; $bringsSnack = (bool)($input['brings_snack'] ?? false); $snackDescription = Security::sanitizeInput($input['snack_description'] ?? ''); if (!Security::validateEventCode($eventCode) || !Security::validateName($firstName)) { Response::error('Invalid input format'); } try { $db->beginTransaction(); // Get event ID $stmt = $db->prepare("SELECT event_id FROM events WHERE event_code = ?"); $stmt->execute([$eventCode]); $eventId = $stmt->fetchColumn(); if (!$eventId) { Response::error('Event not found', 404); } // Insert or update attendee $stmt = $db->prepare(" INSERT INTO attendees (event_id, first_name, is_rsvp, brings_snack) VALUES (?, ?, 1, ?) ON DUPLICATE KEY UPDATE is_rsvp = 1, brings_snack = VALUES(brings_snack), updated_at = CURRENT_TIMESTAMP "); $stmt->execute([$eventId, $firstName, $bringsSnack]); // Get attendee ID $stmt = $db->prepare("SELECT attendee_id FROM attendees WHERE event_id = ? AND first_name = ?"); $stmt->execute([$eventId, $firstName]); $attendeeId = $stmt->fetchColumn(); // Clear existing votes and preferences $stmt = $db->prepare("DELETE FROM attendee_date_votes WHERE attendee_id = ?"); $stmt->execute([$attendeeId]); $stmt = $db->prepare("DELETE FROM attendee_game_preferences WHERE attendee_id = ?"); $stmt->execute([$attendeeId]); $stmt = $db->prepare("DELETE FROM snacks_brought WHERE attendee_id = ?"); $stmt->execute([$attendeeId]); // Insert date votes if (!empty($dateVotes)) { $stmt = $db->prepare("INSERT INTO attendee_date_votes (attendee_id, option_id) VALUES (?, ?)"); foreach ($dateVotes as $optionId) { $stmt->execute([$attendeeId, $optionId]); } } // Insert game preferences if (!empty($gamePreferences)) { $stmt = $db->prepare("INSERT INTO attendee_game_preferences (attendee_id, game_id, rank) VALUES (?, ?, ?)"); foreach ($gamePreferences as $index => $gameId) { $stmt->execute([$attendeeId, $gameId, $index + 1]); } } // Insert snack description if bringing snack if ($bringsSnack && !empty($snackDescription)) { $stmt = $db->prepare("INSERT INTO snacks_brought (attendee_id, snack_description) VALUES (?, ?)"); $stmt->execute([$attendeeId, $snackDescription]); } $db->commit(); Response::success(['message' => 'RSVP submitted successfully']); } catch (PDOException $e) { $db->rollback(); Response::error('Database error: ' . $e->getMessage(), 500); } } // Get games list function getGames($db) { try { $stmt = $db->prepare("SELECT game_id, game_name FROM games ORDER BY game_name"); $stmt->execute(); $games = $stmt->fetchAll(); Response::success($games); } catch (PDOException $e) { Response::error('Database error: ' . $e->getMessage(), 500); } } // Get event results function getEventResults($db) { $eventCode = $_GET['code'] ?? ''; if (!Security::validateEventCode($eventCode)) { Response::error('Invalid event code format'); } try { // Get event info $stmt = $db->prepare("SELECT * FROM events WHERE event_code = ?"); $stmt->execute([$eventCode]); $event = $stmt->fetch(); if (!$event) { Response::error('Event not found', 404); } // Get attendees $stmt = $db->prepare(" SELECT first_name, brings_snack, GROUP_CONCAT(sb.snack_description SEPARATOR ', ') as snacks FROM attendees a LEFT JOIN snacks_brought sb ON a.attendee_id = sb.attendee_id WHERE event_id = ? AND is_rsvp = 1 GROUP BY a.attendee_id, a.first_name, a.brings_snack ORDER BY a.first_name "); $stmt->execute([$event['event_id']]); $attendees = $stmt->fetchAll(); // Get top games $stmt = $db->prepare(" SELECT g.game_name, COUNT(*) as vote_count FROM attendee_game_preferences agp JOIN games g ON agp.game_id = g.game_id JOIN attendees a ON agp.attendee_id = a.attendee_id WHERE a.event_id = ? GROUP BY g.game_id, g.game_name ORDER BY vote_count DESC, g.game_name LIMIT 3 "); $stmt->execute([$event['event_id']]); $topGames = $stmt->fetchAll(); Response::success([ 'event' => $event, 'attendees' => $attendees, 'topGames' => $topGames, 'rsvpCount' => count($attendees) + 1 // +1 for host ]); } catch (PDOException $e) { Response::error('Database error: ' . $e->getMessage(), 500); } } // Finalize event (set final date) function finalizeEvent($db) { $input = json_decode(file_get_contents('php://input'), true); $eventCode = Security::sanitizeInput($input['event_code'] ?? ''); $optionId = (int)($input['option_id'] ?? 0); if (!Security::validateEventCode($eventCode) || $optionId <= 0) { Response::error('Invalid input'); } try { $db->beginTransaction(); // Get event and option info $stmt = $db->prepare(" SELECT e.event_id, edo.date_time_value, edo.date_time_string FROM events e JOIN event_date_options edo ON e.event_id = edo.event_id WHERE e.event_code = ? AND edo.option_id = ? "); $stmt->execute([$eventCode, $optionId]); $result = $stmt->fetch(); if (!$result) { Response::error('Event or date option not found', 404); } // Update event with final date $stmt = $db->prepare("UPDATE events SET final_date_time = ? WHERE event_id = ?"); $stmt->execute([$result['date_time_value'], $result['event_id']]); $db->commit(); Response::success(['message' => 'Event finalized successfully']); } catch (PDOException $e) { $db->rollback(); Response::error('Database error: ' . $e->getMessage(), 500); } } ?> # ====================== # File: config/database.php # ====================== ~K.aPVw8_z->U'; private $conn; public function getConnection() { $this->conn = null; try { $this->conn = new PDO( "mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ] ); } catch(PDOException $e) { echo "Connection error: " . $e->getMessage(); } return $this->conn; } } // Utility functions for security class Security { public static function sanitizeInput($input) { return htmlspecialchars(strip_tags(trim($input)), ENT_QUOTES, 'UTF-8'); } public static function validateEventCode($code) { return preg_match('/^[A-Z0-9]{7}$/', $code); } public static function validateName($name) { return preg_match('/^[a-zA-Z\s\-\']{1,100}$/', $name); } public static function generateCSRFToken() { if (session_status() == PHP_SESSION_NONE) { session_start(); } if (!isset($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); } return $_SESSION['csrf_token']; } public static function validateCSRFToken($token) { if (session_status() == PHP_SESSION_NONE) { session_start(); } return isset($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token); } } // JSON response helper class Response { public static function json($data, $status = 200) { http_response_code($status); header('Content-Type: application/json'); echo json_encode($data); exit; } public static function error($message, $status = 400) { self::json(['error' => $message], $status); } public static function success($data) { self::json(['success' => true, 'data' => $data]); } } ?> # ====================== # File: context_generator (5).php # ====================== textExtensions); } private function shouldIgnore($path) { $basename = basename($path); return in_array($basename, $this->ignoreDirectories) || in_array($basename, $this->ignoreFiles) || $basename[0] === '.'; } private function generateTree($dir, $prefix = '') { $output = []; $items = scandir($dir); $items = array_filter($items, fn($item) => !$this->shouldIgnore($dir . '/' . $item)); $items = array_values($items); foreach ($items as $i => $item) { $isLast = ($i === count($items) - 1); $path = $dir . '/' . $item; $output[] = $prefix . ($isLast ? '└── ' : '├── ') . $item; if (is_dir($path)) { $newPrefix = $prefix . ($isLast ? ' ' : '│ '); $output = array_merge($output, $this->generateTree($path, $newPrefix)); } } return $output; } private function getFileContent($path) { if (!$this->isTextFile($path)) { return "[Binary file]"; } try { return file_get_contents($path); } catch (Exception $e) { return "[Error reading file: " . $e->getMessage() . "]"; } } public function generateContext() { $timestamp = date('Y-m-d H:i:s'); $rootDir = dirname(__FILE__); // Start with header $output = [ "# Code Context Generated", "# Generated on: $timestamp", "# ======================", "", "Directory Tree:", basename($rootDir) . "/", ]; // Add directory tree $output = array_merge($output, $this->generateTree($rootDir)); $output[] = ""; // Add file contents $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($rootDir, RecursiveDirectoryIterator::SKIP_DOTS) ); foreach ($iterator as $file) { if ($this->shouldIgnore($file->getPathname())) { continue; } $relativePath = str_replace($rootDir . '/', '', $file->getPathname()); $output[] = "# ======================"; $output[] = "# File: " . $relativePath; $output[] = "# ======================"; $output[] = $this->getFileContent($file->getPathname()); $output[] = ""; } // Save the context file $contextFile = $rootDir . '/ai_context.txt'; file_put_contents($contextFile, implode("\n", $output)); return [ 'success' => true, 'message' => 'Context generated successfully', 'path' => $contextFile ]; } } // Simple HTML interface if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['generate'])) { $generator = new CodeContextGenerator(); $result = $generator->generateContext(); header('Content-Type: application/json'); echo json_encode($result); exit; } ?> Code Context Generator

Code Context Generator

Click the button below to generate a context file of your codebase.