![]() 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/-2ba8cf95/ |
<?php
// Setup script for automated track monitoring
// This provides instructions for setting up cron jobs and monitoring
echo "<h1>๐ต Automated Track Monitoring Setup</h1>";
echo "<p>This script helps you set up automated monitoring for your music tracks.</p>";
// Check if we can write to the directory
$logFile = 'monitor_log.txt';
$canWrite = is_writable(dirname($logFile));
echo "<h2>๐ Current Status</h2>";
echo "<p><strong>Log file writable:</strong> " . ($canWrite ? "โ
Yes" : "โ No") . "</p>";
// Test the monitor API
echo "<h2>๐งช Testing Monitor API</h2>";
$testUrl = "http://" . $_SERVER['HTTP_HOST'] . "/api/monitor.php?key=soundstudiopro_monitor_2025";
echo "<p><strong>Monitor URL:</strong> <a href='$testUrl' target='_blank'>$testUrl</a></p>";
// Test the API
$context = stream_context_create(['http' => ['timeout' => 10]]);
$response = @file_get_contents($testUrl, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
if ($data && !isset($data['error'])) {
echo "<p style='color: green;'>โ
Monitor API is working!</p>";
echo "<p><strong>Processing tracks:</strong> " . ($data['total_processing'] ?? 0) . "</p>";
} else {
echo "<p style='color: red;'>โ Monitor API error: " . ($data['error'] ?? 'Unknown error') . "</p>";
}
} else {
echo "<p style='color: orange;'>โ ๏ธ Could not test monitor API</p>";
}
echo "<h2>โ๏ธ Setup Options</h2>";
echo "<h3>Option 1: Manual Monitoring (Recommended for testing)</h3>";
echo "<p>Call this URL every 5-10 minutes:</p>";
echo "<code style='background: #f0f0f0; padding: 10px; display: block; margin: 10px 0;'>$testUrl</code>";
echo "<p>You can use browser bookmarks, browser extensions, or manual calls.</p>";
echo "<h3>Option 2: JavaScript Polling (Automatic)</h3>";
echo "<p>The track monitor script will automatically check for updates every 30 seconds on track pages.</p>";
echo "<p>This is already set up and will work automatically when you visit:</p>";
echo "<ul>";
echo "<li>/library_new.php</li>";
echo "<li>/feed.php</li>";
echo "<li>/dashboard.php</li>";
echo "<li>/ (homepage)</li>";
echo "</ul>";
echo "<h3>Option 3: Server Cron Job (Most reliable)</h3>";
echo "<p>If your hosting provider supports cron jobs, add this to your crontab:</p>";
echo "<code style='background: #f0f0f0; padding: 10px; display: block; margin: 10px 0;'>*/5 * * * * curl -s \"$testUrl\" > /dev/null 2>&1</code>";
echo "<p>This runs every 5 minutes. You can adjust the frequency:</p>";
echo "<ul>";
echo "<li><code>*/2 * * * *</code> - Every 2 minutes</li>";
echo "<li><code>*/5 * * * *</code> - Every 5 minutes (recommended)</li>";
echo "<li><code>*/10 * * * *</code> - Every 10 minutes</li>";
echo "</ul>";
echo "<h3>Option 4: External Monitoring Service</h3>";
echo "<p>Use services like:</p>";
echo "<ul>";
echo "<li><strong>UptimeRobot:</strong> Free monitoring service</li>";
echo "<li><strong>Cron-job.org:</strong> Free cron job service</li>";
echo "<li><strong>EasyCron:</strong> Web-based cron service</li>";
echo "</ul>";
echo "<h2>๐ Monitor Log</h2>";
if (file_exists($logFile)) {
$logContent = file_get_contents($logFile);
$logLines = explode("\n", $logContent);
$recentLines = array_slice($logLines, -10); // Last 10 lines
echo "<p><strong>Recent activity:</strong></p>";
echo "<div style='background: #f0f0f0; padding: 10px; max-height: 200px; overflow-y: auto; font-family: monospace;'>";
foreach ($recentLines as $line) {
if (trim($line)) {
echo htmlspecialchars($line) . "<br>";
}
}
echo "</div>";
} else {
echo "<p>No log file found yet. Run the monitor once to create it.</p>";
}
echo "<h2>๐ง Manual Test</h2>";
echo "<p><a href='$testUrl' target='_blank' class='btn btn-primary'>Test Monitor Now</a></p>";
echo "<h2>๐ฑ Mobile/Desktop Notifications</h2>";
echo "<p>The JavaScript monitor will show notifications when tracks are completed or failed.</p>";
echo "<p>You'll see popup notifications in the top-right corner of the screen.</p>";
echo "<h2>๐ฏ What the Monitor Does</h2>";
echo "<ul>";
echo "<li>โ
Checks all tracks with 'processing' status</li>";
echo "<li>โ
Looks for completed result files</li>";
echo "<li>โ
Updates track status to 'complete' with audio URLs</li>";
echo "<li>โ
Marks old processing tracks as 'failed' (after 10 minutes)</li>";
echo "<li>โ
Shows notifications to users</li>";
echo "<li>โ
Logs all activities</li>";
echo "</ul>";
echo "<h2>๐ Next Steps</h2>";
echo "<ol>";
echo "<li>Test the monitor API manually</li>";
echo "<li>Set up cron job or external monitoring service</li>";
echo "<li>Create a new track to test the system</li>";
echo "<li>Watch for automatic status updates</li>";
echo "</ol>";
echo "<p style='color: green; font-weight: bold;'>๐ต Your tracks will now automatically update from 'Failed' to 'Complete' status!</p>";
?>