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/GENRE_AUDIT.md
# Genre System Audit Report

## Overview
This audit examines how genres are stored, displayed, searched, and linked across the application.

## 1. Genre Storage

### Database Schema
- **`music_tracks.genre`**: VARCHAR(100) - Direct genre column
- **`music_tracks.metadata`**: JSON - Contains `genre` and `style` fields
- **`user_profiles.genres`**: JSON array - Artist profile genres

### Storage Locations
1. **Primary**: `mt.genre` column (VARCHAR)
2. **Secondary**: `metadata.genre` (JSON field)
3. **Alternative**: `metadata.style` (JSON field, sometimes used as genre)
4. **Artist**: `user_profiles.genres` (JSON array)

### Issues Found
- **Inconsistency**: Genres can be stored in multiple places (mt.genre, metadata.genre, metadata.style)
- **No standardization**: Some tracks use "Deep House", others "deep house" or "DeepHouse"
- **Compound genres**: "Psytrance", "Deep House" stored as single strings vs separate words

## 2. Genre Display on Cards

### community_fixed.php
**Location**: Lines ~550-650
**Logic**:
```php
// Extract genre from metadata or use track genre
$genre = 'Electronic'; // Default
if (!empty($track['metadata'])) {
    $metadata = json_decode($track['metadata'], true);
    if (!empty($metadata['genre'])) {
        $genre = $metadata['genre'];
    } elseif (!empty($track['genre'])) {
        $genre = $track['genre'];
    }
}
```

**Display**:
- Shows as clickable tag: `<a href="/community_fixed.php?genre=..." class="genre-tag">`
- CSS: `.genre-tag` with background, padding, hover effects
- Mobile responsive

**Issues**:
- Defaults to "Electronic" if no genre found
- Only shows one genre tag (first found)
- No handling for multiple genres

### artist_profile_clean.php
**Location**: Lines ~5540-5620
**Logic**:
```php
// Similar extraction logic
$genre = 'Electronic'; // Default
if (!empty($metadata['genre'])) {
    $genre = $metadata['genre'];
} elseif (!empty($track['genre'])) {
    $genre = $track['genre'];
}
```

**Display**:
- Shows as clickable tag linking to community_fixed.php
- Same CSS styling as community_fixed.php

**Issues**:
- Same default "Electronic" issue
- Only shows one genre

## 3. Genre Search (api_global_search.php)

### Current Implementation
**Tracks Search** (Lines 30-75):
- Searches: `mt.genre`, `metadata.genre`, `metadata.style`
- Uses: `LOWER(field) LIKE ?` with `%query%` pattern
- Case-insensitive partial matching

**Genres Search** (Lines 201-234):
- Searches: `mt.genre`, `metadata.genre`
- Groups by genre and counts tracks
- Returns: genre name + track_count

**Issues**:
- ✅ Case-insensitive (fixed)
- ✅ Partial matching (fixed)
- ⚠️ Doesn't search `metadata.style` in genres query
- ⚠️ No normalization (e.g., "Deep House" vs "deep house")

## 4. Genre Filtering (community_fixed.php)

### Current Implementation (Lines 100-112)
```php
$genre_condition = "AND (
    mt.genre = ? 
    OR mt.tags LIKE ? 
    OR JSON_EXTRACT(mt.metadata, '$.genre') = ?
    OR JSON_EXTRACT(mt.metadata, '$.style') = ?
    OR JSON_UNQUOTE(JSON_EXTRACT(mt.metadata, '$.genre')) LIKE ?
    OR JSON_UNQUOTE(JSON_EXTRACT(mt.metadata, '$.style')) LIKE ?
)";
```

**Issues**:
- Uses exact match (`=`) for some conditions, LIKE for others
- Inconsistent: exact match won't find "Deep House" when searching "deep"
- Case-sensitive exact matches
- Tags LIKE might return false positives

## 5. Genre Links

### From Cards to Community
- **Format**: `/community_fixed.php?genre={genre}`
- **Encoding**: URL encoded
- **Example**: `/community_fixed.php?genre=Deep%20House`

### From Search Results
- **Format**: `/community_fixed.php?genre={genre}`
- **Encoding**: `encodeURIComponent(genre)`

**Issues**:
- No normalization before linking
- "Deep House" and "deep house" create different URLs
- Case sensitivity in URL parameters

## 6. Critical Issues Summary

### 🔴 High Priority
1. **Inconsistent Filtering**: Exact match vs LIKE causes missed results
2. **Case Sensitivity**: "Deep" vs "deep" treated differently
3. **Compound Genres**: "Psytrance" not found when searching "psy"
4. **Multiple Storage Locations**: No single source of truth

### 🟡 Medium Priority
1. **Default Genre**: All tracks without genre show "Electronic"
2. **Single Genre Display**: Only one genre shown per track
3. **No Normalization**: Same genre stored in different formats

### 🟢 Low Priority
1. **Genre Count**: Track count in search may be inaccurate
2. **Artist Genres**: Not fully integrated into search

## 7. Recommendations

### Immediate Fixes
1. **Standardize Genre Filtering**: Use case-insensitive LIKE for all genre matches
2. **Normalize Genre Display**: Convert to title case before display
3. **Fix Compound Genre Search**: Ensure partial word matching works

### Long-term Improvements
1. **Genre Normalization Table**: Create mapping for variations
2. **Multiple Genres Support**: Allow tracks to have multiple genres
3. **Genre Hierarchy**: Support sub-genres (e.g., "Deep House" under "House")
4. **Genre Validation**: Ensure consistent storage format

## 8. Files to Review/Update

1. **community_fixed.php**: Genre filtering logic (lines 100-112, 173-184)
2. **api_global_search.php**: Genre search queries (lines 201-234)
3. **artist_profile_clean.php**: Genre display (lines ~5540-5620)
4. **community_fixed.php**: Genre display (lines ~550-650)

## 9. Test Cases

### Search Tests
- [ ] "deep" should find "Deep House", "Deep Dubstep"
- [ ] "psy" should find "Psytrance", "Psychedelic"
- [ ] "house" should find "Deep House", "Progressive House"
- [ ] Case insensitive: "DEEP" = "deep" = "Deep"

### Filter Tests
- [ ] Clicking "Deep House" tag filters correctly
- [ ] URL parameter `?genre=Deep%20House` works
- [ ] Case variations work: `?genre=deep%20house`

### Display Tests
- [ ] Genre tag shows correct genre
- [ ] Clicking tag navigates to filtered community page
- [ ] Default "Electronic" only when no genre exists


CasperSecurity Mini