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/PRO_MODE_CHARACTER_LIMIT_AUDIT.md
# Pro Mode Character Limit Audit

## Issue Reported
User reports that in Pro mode, after reaching 2001 characters:
1. The character limit shifts from 2000 to 5000
2. The initial prompt then gets reduced to 400 characters

## Current Implementation Analysis

### HTML Configuration
- **Location**: `index.php` line 3952, `includes/create_music_modal.php` line 922
- **Setting**: `maxlength="5000"` on `proPrompt` textarea
- **Status**: ✅ Correct - allows up to 5000 characters

### JavaScript Character Counter
- **Location**: `index.php` lines 4514, 4532
- **Current Behavior**: 
  - Shows `X/2000` in character counter
  - Uses `updateCharCount(e.target, 2000)` for proPrompt
- **Issue**: ❌ **MISMATCH** - Counter shows 2000 but HTML allows 5000

### Server-Side Processing
- **Location**: `create_music.php`

#### CustomMode Detection (Lines 201-206)
```php
// Enable customMode when pro mode is used (pro mode allows up to 5000 characters)
// Pro mode is detected when proPrompt is provided
if (!empty($proPrompt)) {
    $customMode = 'true';
    error_log("Pro mode detected (proPrompt provided), enabling customMode to allow up to 5000 characters");
}
```
- **Status**: ✅ Should enable customMode when proPrompt is not empty

#### Prompt Truncation (Lines 1059-1067)
```php
if ($promptLength > 400 && ($customMode !== 'true' && $customMode !== true)) {
    // Truncate to 400 characters
    $finalPrompt = mb_substr($finalPrompt, 0, 400);
    error_log("WARNING: Prompt length exceeded 400 characters, truncated to $promptLength characters for non-custom mode");
}
```
- **Status**: ⚠️ **POTENTIAL ISSUE** - Only truncates if customMode is NOT 'true' or true

## Potential Issues Identified

### Issue #1: JavaScript Counter Mismatch
**Problem**: Character counter shows `2000` but HTML allows `5000`
- **Impact**: User sees wrong limit in UI
- **Location**: `index.php` lines 4514, 4532
- **Fix Required**: Change counter to show `5000` for proPrompt

### Issue #2: No Dynamic Limit Switching Code Found
**Problem**: No JavaScript code found that changes limit from 2000 to 5000 at 2001 characters
- **Impact**: User's reported behavior doesn't match code
- **Possible Explanation**: 
  - HTML `maxlength="5000"` allows typing beyond 2000
  - But counter still shows `/2000` until manually updated
  - User might be seeing the HTML limit (5000) while counter shows 2000

### Issue #3: Potential Truncation Bug
**Problem**: If `$proPrompt` is empty or whitespace-only, `customMode` won't be enabled
- **Scenario**: 
  - User types 2001+ characters
  - Something clears or empties `$proPrompt` before submission
  - `customMode` remains `'false'`
  - Prompt gets truncated to 400 characters
- **Location**: `create_music.php` line 203 - checks `!empty($proPrompt)`
- **Fix Required**: Ensure `trim($proPrompt)` is checked, not just `!empty()`

## Recommended Fixes

### Fix #1: Update JavaScript Counter to 5000
**File**: `index.php`
**Lines**: 4514, 4532
**Change**: 
```javascript
// FROM:
document.getElementById('proPrompt')?.addEventListener('input', (e) => updateCharCount(e.target, 2000));
if (proPrompt) updateCharCount(proPrompt, 2000);

// TO:
document.getElementById('proPrompt')?.addEventListener('input', (e) => updateCharCount(e.target, 5000));
if (proPrompt) updateCharCount(proPrompt, 5000);
```

### Fix #2: Update HTML Initial Counter Display
**File**: `index.php` line 3953, `includes/create_music_modal.php` line 923
**Change**:
```html
<!-- FROM: -->
<div class="char-count">0/5000</div>
<!-- This is already correct, but ensure JavaScript updates it properly -->
```

### Fix #3: Strengthen CustomMode Detection
**File**: `create_music.php` line 203
**Change**:
```php
// FROM:
if (!empty($proPrompt)) {
    $customMode = 'true';
}

// TO:
if (!empty($proPrompt) && trim($proPrompt) !== '') {
    $customMode = 'true';
    error_log("Pro mode detected (proPrompt provided), enabling customMode to allow up to 5000 characters");
}
```

### Fix #4: Add Dynamic Counter Update (Optional Enhancement)
If the user wants the counter to dynamically switch from 2000 to 5000 at 2001 characters:
**File**: `index.php`
**Add after line 4514**:
```javascript
// Dynamic limit switching for Pro mode
document.getElementById('proPrompt')?.addEventListener('input', (e) => {
    const length = e.target.value.length;
    const maxLength = length > 2000 ? 5000 : 2000;
    updateCharCount(e.target, maxLength);
    
    // Update maxlength attribute if needed
    if (length > 2000 && e.target.maxLength !== 5000) {
        e.target.maxLength = 5000;
    }
});
```

## Verification Steps

1. ✅ **HTML maxlength**: Confirmed `maxlength="5000"` on proPrompt
2. ❌ **JavaScript counter**: Shows `2000` instead of `5000` - **NEEDS FIX**
3. ✅ **Server customMode**: Should enable when proPrompt not empty
4. ⚠️ **Server truncation**: Only happens if customMode is false - **NEEDS VERIFICATION**

## Conclusion

**The reported behavior likely occurs because:**
1. HTML allows typing up to 5000 characters (correct)
2. JavaScript counter incorrectly shows `/2000` (bug)
3. If proPrompt becomes empty/whitespace, customMode might not enable, causing truncation to 400

**No code found that dynamically switches from 2000 to 5000 at 2001 characters** - this might be a user perception based on the HTML maxlength allowing typing beyond 2000 while the counter shows 2000.





CasperSecurity Mini