![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-7cf403ed/ |
<?php
session_start();
require_once __DIR__ . '/../config/database.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/../includes/translations.php';
$error = '';
$success = '';
$tables_exist = false;
// Check if radio_stations table exists
$pdo = getDBConnection();
if ($pdo) {
try {
$pdo->query("SELECT 1 FROM radio_stations LIMIT 1");
$tables_exist = true;
} catch (Exception $e) {
$tables_exist = false;
$error = "Database setup required. The radio_stations table doesn't exist.";
}
} else {
$error = "Database connection failed.";
}
// Get tier from URL if provided
$default_tier = $_GET['tier'] ?? 'local';
if (!in_array($default_tier, ['local', 'regional', 'national', 'enterprise'])) {
$default_tier = 'local';
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $tables_exist) {
if (!$pdo) {
$error = "Database connection failed. Please try again.";
} else {
// Validate input
$station_name = trim($_POST['station_name'] ?? '');
$contact_name = trim($_POST['contact_name'] ?? '');
$contact_email = trim($_POST['contact_email'] ?? '');
$contact_phone = trim($_POST['contact_phone'] ?? '');
$license_tier = $_POST['license_tier'] ?? 'local';
if (empty($station_name) || empty($contact_name) || empty($contact_email)) {
$error = t('radio_register.error_required');
} elseif (!filter_var($contact_email, FILTER_VALIDATE_EMAIL)) {
$error = t('radio_register.error_email');
} else {
try {
// Check if email already exists
$stmt = $pdo->prepare("SELECT id FROM radio_stations WHERE contact_email = ?");
$stmt->execute([$contact_email]);
if ($stmt->fetch()) {
$error = t('radio_register.error_exists');
} else {
// Generate API credentials
$credentials = generateAPICredentials();
// Create station record
$stmt = $pdo->prepare("
INSERT INTO radio_stations (
station_name, call_sign, station_type, license_tier,
contact_name, contact_email, contact_phone,
city, state, country, timezone,
subscription_status, monthly_play_limit,
api_key, api_secret, api_enabled
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$result = $stmt->execute([
$station_name,
$_POST['call_sign'] ?? null,
$_POST['station_type'] ?? 'local',
$license_tier,
$contact_name,
$contact_email,
$contact_phone ?: null,
$_POST['city'] ?? null,
$_POST['state'] ?? null,
$_POST['country'] ?? 'US',
$_POST['timezone'] ?? 'America/New_York',
'trial',
getTierPlayLimit($license_tier),
$credentials['api_key'],
password_hash($credentials['api_secret'], PASSWORD_DEFAULT),
true
]);
if ($result) {
$station_id = $pdo->lastInsertId();
// Store credentials in session temporarily
$_SESSION['radio_station_id'] = $station_id;
$_SESSION['radio_api_key'] = $credentials['api_key'];
$_SESSION['radio_api_secret'] = $credentials['api_secret'];
// Redirect to subscription
header("Location: /radio/subscribe.php?station_id=" . $station_id);
exit;
} else {
$error = t('radio_register.error_failed');
}
}
} catch (Exception $e) {
error_log("Radio registration error: " . $e->getMessage());
$error = "Registration failed: " . $e->getMessage();
}
}
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && !$tables_exist) {
$error = "Database tables not set up. Please run the migration first.";
}
$page_title = t('radio_register.title') . ' - SoundStudioPro';
?>
<!DOCTYPE html>
<html lang="<?= getCurrentLanguage() ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlspecialchars($page_title) ?></title>
<link rel="stylesheet" href="/assets/css/main.css">
<style>
.radio-register {
max-width: 600px;
margin: 2rem auto;
padding: 2rem;
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.radio-register h1 {
margin-bottom: 1.5rem;
color: #667eea;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
.form-group input,
.form-group select {
width: 100%;
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
}
.tier-options {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.tier-option {
border: 2px solid #ddd;
border-radius: 8px;
padding: 1rem;
cursor: pointer;
transition: all 0.3s;
}
.tier-option:hover {
border-color: #667eea;
}
.tier-option.selected {
border-color: #667eea;
background: #f0f4ff;
}
.tier-option input[type="radio"] {
width: auto;
}
.btn-primary {
background: #667eea;
color: white;
padding: 0.75rem 2rem;
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
width: 100%;
}
.btn-primary:hover {
background: #5568d3;
}
.error {
background: #fee;
color: #c33;
padding: 1rem;
border-radius: 4px;
margin-bottom: 1rem;
}
</style>
</head>
<body>
<?php include __DIR__ . '/../includes/header.php'; ?>
<div class="radio-register">
<h1>🎵 <?= t('radio_register.title') ?></h1>
<p><?= t('radio_register.subtitle') ?></p>
<?php if (!$tables_exist): ?>
<div class="error" style="background: #fff3cd; color: #856404; border: 1px solid #ffc107;">
<h3 style="margin-top: 0;">⚠️ Database Setup Required</h3>
<p>The <code>radio_stations</code> table doesn't exist. You need to run the database migration first.</p>
<p style="margin-top: 1rem;">
<strong>Step 1:</strong> Create radio_stations table<br>
<a href="/migrations/add_radio_station_system.php" target="_blank"
style="display: inline-block; padding: 0.75rem 1.5rem; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 0.5rem;">
🔧 Run Radio Stations Migration
</a>
</p>
<p style="margin-top: 1rem;">
<strong>Step 2:</strong> Create live streaming tables (optional)<br>
<a href="/radio/migrations/add_live_streaming_tables.php" target="_blank"
style="display: inline-block; padding: 0.75rem 1.5rem; background: rgba(102, 126, 234, 0.2); color: #667eea; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 0.5rem; border: 1px solid #667eea;">
📻 Run Live Streaming Migration
</a>
</p>
<p style="margin-top: 1rem; font-size: 0.9rem; color: #666;">
After running the migrations, refresh this page to continue registration.
</p>
</div>
<?php endif; ?>
<?php if ($error && $tables_exist): ?>
<div class="error"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<?php if ($tables_exist): ?>
<form method="POST">
<div class="form-group">
<label><?= t('radio_register.station_name') ?></label>
<input type="text" name="station_name" required value="<?= htmlspecialchars($_POST['station_name'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.call_sign') ?></label>
<input type="text" name="call_sign" value="<?= htmlspecialchars($_POST['call_sign'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.station_type') ?></label>
<select name="station_type">
<option value="local"><?= t('radio_register.station_type_local') ?></option>
<option value="regional"><?= t('radio_register.station_type_regional') ?></option>
<option value="national"><?= t('radio_register.station_type_national') ?></option>
<option value="internet"><?= t('radio_register.station_type_internet') ?></option>
<option value="podcast"><?= t('radio_register.station_type_podcast') ?></option>
</select>
</div>
<div class="form-group">
<label><?= t('radio_register.license_tier') ?></label>
<div class="tier-options">
<label class="tier-option <?= $default_tier === 'local' ? 'selected' : '' ?>">
<input type="radio" name="license_tier" value="local" <?= $default_tier === 'local' ? 'checked' : '' ?>>
<strong><?= t('radio_register.tier_local') ?></strong><br>
$99<?= t('radio_register.tier_price_month') ?><br>
500 <?= t('radio_register.tier_plays_month') ?>
</label>
<label class="tier-option <?= $default_tier === 'regional' ? 'selected' : '' ?>">
<input type="radio" name="license_tier" value="regional" <?= $default_tier === 'regional' ? 'checked' : '' ?>>
<strong><?= t('radio_register.tier_regional') ?></strong><br>
$299<?= t('radio_register.tier_price_month') ?><br>
2,000 <?= t('radio_register.tier_plays_month') ?>
</label>
<label class="tier-option <?= $default_tier === 'national' ? 'selected' : '' ?>">
<input type="radio" name="license_tier" value="national" <?= $default_tier === 'national' ? 'checked' : '' ?>>
<strong><?= t('radio_register.tier_national') ?></strong><br>
$999<?= t('radio_register.tier_price_month') ?><br>
<?= t('radio_register.tier_unlimited') ?>
</label>
</div>
</div>
<div class="form-group">
<label><?= t('radio_register.contact_name') ?></label>
<input type="text" name="contact_name" required value="<?= htmlspecialchars($_POST['contact_name'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.contact_email') ?></label>
<input type="email" name="contact_email" required value="<?= htmlspecialchars($_POST['contact_email'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.contact_phone') ?></label>
<input type="tel" name="contact_phone" value="<?= htmlspecialchars($_POST['contact_phone'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.city') ?></label>
<input type="text" name="city" value="<?= htmlspecialchars($_POST['city'] ?? '') ?>">
</div>
<div class="form-group">
<label><?= t('radio_register.state') ?></label>
<input type="text" name="state" value="<?= htmlspecialchars($_POST['state'] ?? '') ?>">
</div>
<button type="submit" class="btn-primary"><?= t('radio_register.submit') ?></button>
</form>
<?php else: ?>
<div style="padding: 2rem; text-align: center; color: #666;">
<p>Please run the database migration to enable station registration.</p>
</div>
<?php endif; ?>
</div>
<?php include __DIR__ . '/../includes/footer.php'; ?>
</body>
</html>