Event Booking System for Police Training (LiveCode Version)
Installation & Configuration Guide
Version 1.0.0 (LiveCode Server)
Overview
This is a portable, flat-file event booking system designed for training events (police training, martial arts, etc.). It runs on LiveCode Server and integrates with your antiGravity CMS via iframe embedding.
Components
- events.lc - Main public-facing script (event listing, registration, payment)
- events-admin.lc - Admin panel for managing events and registrations
- sample-events.json - Example event data
Installation Steps
1. Upload Files
Upload the .lc files to your server:
/home/youruser/public_html/yoursite.com/
└── events/
├── events.lc
└── events-admin.lc
Set appropriate permissions:
chmod 755 /home/youruser/public_html/yoursite.com/events
chmod 644 /home/youruser/public_html/yoursite.com/events/events.lc
chmod 644 /home/youruser/public_html/yoursite.com/events/events-admin.lc
2. Create Data Directory
Create the data directory structure:
/home/youruser/public_html/yoursite.com/
└── events/
└── data/
├── events.json (will be created automatically)
└── registrations/ (create this folder manually)
Set appropriate permissions:
chmod 755 /home/youruser/public_html/yoursite.com/events/data
chmod 755 /home/youruser/public_html/yoursite.com/events/data/registrations
3. Create antiGravity Content Pages with iFrames
Create markdown pages in your antiGravity content structure that embed the LiveCode scripts:
For the public event listing page:
/content/events/page.md
Content:
---
title: Training Events
---
<iframe src="https://yoursite.com/events/events.lc" style="border:none; width:100%; min-height:800px;" frameborder="0"></iframe>
<script>
// Auto-resize iframe to content height
window.addEventListener('message', function(e) {
if (e.data.height) {
document.querySelector('iframe').style.height = e.data.height + 'px';
}
});
</script>
For the admin panel:
/content/events/admin/page.md
Content:
---
title: Event Admin
menu: false
---
<iframe src="https://yoursite.com/events/events-admin.lc" style="border:none; width:100%; min-height:800px;" frameborder="0"></iframe>
<script>
window.addEventListener('message', function(e) {
if (e.data.height) {
document.querySelector('iframe').style.height = e.data.height + 'px';
}
});
</script>
Benefits of the iFrame Approach:
- ✅ LiveCode scripts execute independently
- ✅ No router modifications needed
- ✅ Scripts can set their own headers
- ✅ Easier to debug (can access scripts directly)
- ✅ Better separation of concerns
Configuration
IMPORTANT: Configure Both Scripts
Both events.lc and events-admin.lc have configuration sections at the top. These must match!
events.lc Configuration
Open events.lc and edit the configuration section (starting around line 13):
-- Site Configuration
put "/home/youruser/public_html/yoursite.com" into gConfig["basePath"]
put gConfig["basePath"] & "/events/data" into gConfig["dataPath"]
put gConfig["basePath"] & "/events/data/registrations" into gConfig["regPath"]
put "Your Police Training Center" into gConfig["siteName"]
-- Email Configuration
put "events@yoursite.com" into gConfig["fromEmail"]
put "Event Registration System" into gConfig["fromName"]
put "admin@yoursite.com" into gConfig["adminEmail"]
-- Payment Configuration
put "none" into gConfig["paymentProvider"] -- Options: "braintree", "paypal", "none"
put "" into gConfig["paymentAPIKey"]
put "" into gConfig["paymentMerchantID"]
put "" into gConfig["paymentPublicKey"]
events-admin.lc Configuration
Open events-admin.lc and edit the configuration section (starting around line 18):
-- Site Configuration (MUST MATCH events.lc)
put "/home/youruser/public_html/yoursite.com" into gConfig["basePath"]
put gConfig["basePath"] & "/events/data" into gConfig["dataPath"]
put gConfig["basePath"] & "/events/data/registrations" into gConfig["regPath"]
put "Your Police Training Center" into gConfig["siteName"]
-- Admin Password (CHANGE THIS!)
put "your_secure_password_here" into gConfig["adminPassword"]
-- Email Configuration
put "events@yoursite.com" into gConfig["fromEmail"]
put "Event Registration System" into gConfig["fromName"]
Adding Payment Integration
For Braintree:
- Sign up for Braintree account
- Get your API credentials
- In
events.lc, update configuration:
put "braintree" into gConfig["paymentProvider"]
put "your_braintree_merchant_id" into gConfig["paymentMerchantID"]
put "your_braintree_public_key" into gConfig["paymentPublicKey"]
put "your_braintree_private_key" into gConfig["paymentAPIKey"]
- Implement the
processBraintreePaymentfunction inevents.lc(around line 660)
For PayPal:
- Sign up for PayPal Business account
- Get your API credentials
- In
events.lc, update configuration:
put "paypal" into gConfig["paymentProvider"]
put "your_paypal_client_id" into gConfig["paymentPublicKey"]
put "your_paypal_secret" into gConfig["paymentAPIKey"]
- Implement the
processPayPalPaymentfunction inevents.lc(around line 668)
Usage
Direct Access (for testing)
You can access the scripts directly:
- Events:
https://yoursite.com/events/events.lc - Admin:
https://yoursite.com/events/events-admin.lc
Through antiGravity (production)
Users access via your CMS pages:
- Events:
https://yoursite.com/events - Admin:
https://yoursite.com/events/admin
Admin Panel Access
Navigate to: https://yoursite.com/events/admin
Login with the password you configured.
Creating Your First Event
- Login to admin panel
- Click "Add New Event"
- Fill in:
- Title (e.g., "Tactical Firearms Training") - Description - Start Date (and optional End Date for multi-day events) - Location - Total Seats - Price per Person
- Click "Save Event"
Public Registration
Users navigate to: https://yoursite.com/events
They will see:
- List of upcoming events with available seats
- Click "Register Now" to book
- Fill out contact info and attendee names
- Process payment (or simulated payment if
paymentProvideris "none") - Receive confirmation email
Managing Registrations
In admin panel:
- Switch to "Registrations" tab
- Filter by event (or view all)
- See all registration details
- Cancel registrations if needed (frees up seats, optionally sends email)
Data Files
events.json
Stores all event data. Format:
{
"evt_1234567890": {
"title": "Tactical Training",
"description": "Advanced tactical scenarios",
"date": "2025-03-15",
"end_date": "",
"location": "Training Center A",
"total_seats": 20,
"price": 150
}
}
Registration Files
Stored in /data/registrations/ as individual JSON files:
evt_1234567890_1704123456_5432.json
Format:
{
"event_id": "evt_1234567890",
"registration_id": "evt_1234567890_1704123456_5432",
"organization": "Springfield PD",
"contact_name": "John Smith",
"contact_email": "jsmith@springfieldpd.gov",
"contact_phone": "555-1234",
"contact_address": "123 Main St, Springfield, MO 65806",
"attendees": "John Smith\nJane Doe\nBob Johnson",
"attendee_count": 3,
"total_amount": 450,
"status": "completed",
"transaction_id": "TEST-1704123456",
"registration_date": 1704123456
}
Customization for Different Sites
To adapt this for a martial arts dojo or other training facility:
- Update
gConfig["siteName"]in both files - Adjust email copy in email functions (search for "sendConfirmationEmail", "sendAdminNotification", etc.)
- Modify form labels if needed (change "Organization/Department" to "School/Affiliation", etc.)
- Update styling in CSS sections to match your brand
Troubleshooting
Events not showing up
- Check that
data/events.jsonexists and is readable - Verify file permissions (should be 644)
- Check that events have future dates and available seats
- Access the script directly (e.g.,
yoursite.com/events/events.lc) to see any error messages
Emails not sending
- Verify server has
mailcommand available - Test with:
echo "test" | mail -s "test" your@email.com - Check spam folder
- Verify email configuration in both scripts
Registration not saving
- Check
data/registrations/folder exists and is writable (755) - Check disk space
- Review server error logs
- Access script directly to see detailed errors
Payment not processing
- Verify
paymentProviderconfiguration - Check API credentials
- Review payment provider documentation
- Test with
paymentProviderset to "none" first
iFrame not displaying properly
- Check that the script URLs are correct and accessible
- View browser console for CORS or other errors
- Ensure scripts are returning valid HTML
- Adjust iframe height as needed
Security Notes
- Change the admin password! Don't use "admin123"
- Keep API keys secure - never commit to version control
- Use HTTPS for all pages (especially registration and admin)
- Regularly backup the
data/directory - Monitor registrations for fraudulent activity
- Consider adding CAPTCHA to registration form for high-traffic sites
File Permissions Checklist
events/ → 755
events/events.lc → 644
events/events-admin.lc → 644
events/data/ → 755
events/data/registrations/ → 755
events/data/events.json → 644 (created automatically)
events/data/registrations/*.json → 644 (created automatically)
Quick Start Checklist
- [ ] Upload events.lc and events-admin.lc to server
- [ ] Set file permissions (644 for scripts, 755 for directories)
- [ ] Create events/data/ directory structure
- [ ] Configure events.lc (paths, email, payment)
- [ ] Configure events-admin.lc (SAME paths, set password)
- [ ] Create antiGravity pages with iframe embeds
- [ ] Test direct script access (yoursite.com/events/events.lc)
- [ ] Test through antiGravity (yoursite.com/events)
- [ ] Test admin login
- [ ] Create test event
- [ ] Test public registration
- [ ] Verify emails are sending
- [ ] Configure payment provider (or leave as "none" for testing)
- [ ] Go live!
Advantages of LiveCode Version
- Native to your antiGravity CMS ecosystem
- Consistent development environment
- Direct file system access
- No additional language dependencies
- Easier to customize alongside your CMS
License
This system is provided as-is for your use. Modify as needed for your specific requirements.