T.ME/BIBIL_0DAY
CasperSecurity


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/domains/soundstudiopro.com/private_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/private_html/auto_monitor.php
<?php
/**
 * Automatic Track Status Monitor
 * Runs every 5 minutes to fix stuck tracks
 */

require_once "config/database.php";

$pdo = getDBConnection();
$api_key = "63edba40620216c5aa2c04240ac41dbd";

// Log file
$log_file = "monitor_log.txt";
$timestamp = date("Y-m-d H:i:s");

// Get processing tracks
$stmt = $pdo->query("SELECT * FROM music_tracks WHERE status = \"processing\" AND created_at >= DATE_SUB(NOW(), INTERVAL 24 HOUR)");
$tracks = $stmt->fetchAll();

$fixed_count = 0;
$failed_count = 0;

foreach ($tracks as $track) {
    // Skip temporary task IDs
    if (strpos($track["task_id"], "temp_") === 0) {
        continue;
    }
    
    // Check result files first
    $result_file = "task_results/{$track["task_id"]}.json";
    if (file_exists($result_file)) {
        $result_data = json_decode(file_get_contents($result_file), true);
        if ($result_data && isset($result_data["data"]["callbackType"]) && $result_data["data"]["callbackType"] === "complete") {
            $audio_data = $result_data["data"]["data"][0] ?? null;
            if ($audio_data && isset($audio_data["audio_url"])) {
                $stmt = $pdo->prepare("UPDATE music_tracks SET status = \"complete\", audio_url = ?, duration = ?, updated_at = NOW() WHERE id = ?");
                if ($stmt->execute([$audio_data["audio_url"], $audio_data["duration"] ?? 30, $track["id"]])) {
                    $fixed_count++;
                    file_put_contents($log_file, "[$timestamp] Fixed track {$track["id"]} ({$track["title"]}) from result file\n", FILE_APPEND | LOCK_EX);
                }
            }
        }
    } else {
        // Check API.Box directly
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.api.box/api/v1/status/{$track["task_id"]}");
        curl_setopt($ch, CURLOPT_HTTPGET, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $api_key", "Content-Type: application/json"]);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        
        $response = curl_exec($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        
        if ($http_code === 200) {
            $api_data = json_decode($response, true);
            if ($api_data && isset($api_data["data"]["status"])) {
                if ($api_data["data"]["status"] === "complete" && isset($api_data["data"]["audioUrl"])) {
                    $stmt = $pdo->prepare("UPDATE music_tracks SET status = \"complete\", audio_url = ?, updated_at = NOW() WHERE id = ?");
                    if ($stmt->execute([$api_data["data"]["audioUrl"], $track["id"]])) {
                        $fixed_count++;
                        file_put_contents($log_file, "[$timestamp] Fixed track {$track["id"]} ({$track["title"]}) from API.Box\n", FILE_APPEND | LOCK_EX);
                    }
                } elseif ($api_data["data"]["status"] === "failed") {
                    $stmt = $pdo->prepare("UPDATE music_tracks SET status = \"failed\", updated_at = NOW() WHERE id = ?");
                    if ($stmt->execute([$track["id"]])) {
                        $failed_count++;
                        file_put_contents($log_file, "[$timestamp] Marked track {$track["id"]} ({$track["title"]}) as failed\n", FILE_APPEND | LOCK_EX);
                    }
                }
            }
        } elseif ($http_code === 404) {
            // Task not found, mark as failed if old
            $track_age = time() - strtotime($track["created_at"]);
            if ($track_age > 3600) { // 1 hour
                $stmt = $pdo->prepare("UPDATE music_tracks SET status = \"failed\", updated_at = NOW() WHERE id = ?");
                if ($stmt->execute([$track["id"]])) {
                    $failed_count++;
                    file_put_contents($log_file, "[$timestamp] Marked track {$track["id"]} ({$track["title"]}) as failed (not found in API.Box)\n", FILE_APPEND | LOCK_EX);
                }
            }
        }
    }
}

// Log summary
file_put_contents($log_file, "[$timestamp] Monitor run complete - Fixed: $fixed_count, Failed: $failed_count\n", FILE_APPEND | LOCK_EX);

// Keep log file manageable (last 1000 lines)
$log_lines = file($log_file);
if (count($log_lines) > 1000) {
    $log_lines = array_slice($log_lines, -1000);
    file_put_contents($log_file, implode("", $log_lines));
}
?>

CasperSecurity Mini