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/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/public_html/GLOBAL_PLAYER_URL_FIX.md
# ✅ GLOBAL PLAYER URL FIX APPLIED

**Date:** December 2025  
**Status:** FIX APPLIED - URL CONVERSION ADDED

---

## 🔍 PROBLEM IDENTIFIED

The global player's `playTrack` function was receiving relative URLs (like `/utils/play_audio.php?id=X&token=Y&expires=Z`) but setting them directly on the audio element without converting to absolute URLs.

**Issues:**
1. Relative URLs may not load properly in all browsers
2. CORS issues with relative URLs
3. Session cookies may not be sent with relative URLs
4. Playlist matching fails when comparing relative vs absolute URLs

---

## ✅ FIX APPLIED

### Fix: URL Conversion in Global Player

**File:** `global_player.php`

**Change:** Added URL normalization at the start of `playTrack` function

**What it does:**
1. Converts relative URLs to absolute URLs before setting on audio element
2. Preserves query parameters (important for tokens)
3. Handles protocol-relative URLs
4. Normalizes URLs for playlist matching

**Code Added:**
```javascript
// CRITICAL: Ensure audio URL is absolute - browsers need absolute URLs for proper loading
// Signed URLs from play_audio.php are relative like /utils/play_audio.php?id=X&token=Y&expires=Z
let finalAudioUrl = audioUrl;
if (audioUrl && !audioUrl.startsWith('http') && !audioUrl.startsWith('//')) {
    if (audioUrl.startsWith('/')) {
        // Preserve query parameters for signed URLs with tokens
        finalAudioUrl = window.location.origin + audioUrl;
    } else {
        finalAudioUrl = window.location.origin + '/' + audioUrl;
    }
    console.log('🎵 Converted relative URL to absolute:', finalAudioUrl);
} else if (audioUrl && audioUrl.startsWith('//')) {
    // Handle protocol-relative URLs
    finalAudioUrl = window.location.protocol + audioUrl;
    console.log('🎵 Converted protocol-relative URL:', finalAudioUrl);
}

// Update audioUrl variable to use the absolute URL for all subsequent operations
audioUrl = finalAudioUrl;
```

**Also Added:** URL normalization helper for playlist matching
```javascript
// Helper function to normalize URLs for comparison (handles both relative and absolute)
const normalizeUrl = (url) => {
    if (!url) return '';
    if (url.startsWith('http')) return url;
    if (url.startsWith('/')) return window.location.origin + url;
    return window.location.origin + '/' + url;
};
```

---

## 🎯 EXPECTED BEHAVIOR

### Before Fix:
- Relative URL: `/utils/play_audio.php?id=123&token=abc&expires=1234567890`
- Audio element gets: `/utils/play_audio.php?id=123&token=abc&expires=1234567890`
- May fail to load or have CORS issues

### After Fix:
- Relative URL: `/utils/play_audio.php?id=123&token=abc&expires=1234567890`
- Converted to: `https://soundstudiopro.com/utils/play_audio.php?id=123&token=abc&expires=1234567890`
- Audio element gets: `https://soundstudiopro.com/utils/play_audio.php?id=123&token=abc&expires=1234567890`
- Should load properly with cookies and CORS

---

## 📋 TESTING

### Test 1: Basic Playback
- [ ] Click play on a track
- [ ] Check browser console for "🎵 Converted relative URL to absolute" message
- [ ] Audio should start playing
- [ ] Check Network tab - request should be to absolute URL

### Test 2: Playlist Navigation
- [ ] Play a track from a playlist
- [ ] Click next/previous
- [ ] Should continue playing without errors
- [ ] Playlist matching should work correctly

### Test 3: Token URLs
- [ ] Play a track with token
- [ ] Check console - URL should be converted to absolute
- [ ] Token parameters should be preserved
- [ ] Audio should load successfully

---

## 🔍 DEBUGGING

### Check Console Messages:
Look for:
- `🎵 Converted relative URL to absolute: https://...`
- `🎵 Setting audio source (absolute URL): https://...`

### Check Network Tab:
- Request URL should be absolute (starts with `https://`)
- Should include token parameters
- Response should be 200 (not 403/404)

### If Still Not Working:
1. Check browser console for errors
2. Check Network tab for failed requests
3. Verify token is being generated correctly
4. Check if URL conversion is happening (look for console message)

---

**Status:** ✅ **FIX APPLIED - READY FOR TESTING**


CasperSecurity Mini