![]() 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/ |
<?php
/**
* Remove Wrong Tracks from Stephane Bergeron's Account
* Removes: "fun fun" by Demo User and "Dance All Night" by SoundStudioPro
*/
session_start();
require_once 'config/database.php';
// Check if admin
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
die("Admin access required");
}
$pdo = getDBConnection();
$user_id = 5; // Stephane Bergeron
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Remove Wrong Tracks - Stephane</title></head><body>";
echo "<style>
body { font-family: Arial; padding: 20px; background: #1a1a1a; color: white; }
.success { color: #48bb78; }
.error { color: #e53e3e; }
.warning { color: #ffc107; }
.section { margin: 20px 0; padding: 15px; background: #2a2a2a; border-radius: 8px; }
button { padding: 10px 20px; background: #e53e3e; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
button:hover { background: #c53030; }
table { border-collapse: collapse; width: 100%; margin: 20px 0; background: #1a1a1a; }
th, td { border: 1px solid #444; padding: 10px; text-align: left; }
th { background: #667eea; }
</style>";
echo "<h2>🗑️ Remove Wrong Tracks from Stephane's Account</h2>";
// Get user info
$stmt = $pdo->prepare("SELECT id, name, email FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<div class='section'>";
echo "<p><strong>User:</strong> {$user['name']} (ID: {$user_id})</p>";
echo "</div>";
// Find the tracks to remove
$tracks_to_remove = [
['title' => 'fun fun', 'artist' => 'Demo User'],
['title' => 'Dance All Night', 'artist' => 'SoundStudioPro']
];
echo "<div class='section'>";
echo "<h3>Step 1: Finding Tracks to Remove</h3>";
$found_tracks = [];
foreach ($tracks_to_remove as $track_info) {
// Find the track
$stmt = $pdo->prepare("
SELECT
mt.id as track_id,
mt.title,
u.id as artist_id,
u.name as artist_name,
tp.id as purchase_id,
tp.price_paid,
tp.purchase_date
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
JOIN track_purchases tp ON mt.id = tp.track_id
WHERE tp.user_id = ?
AND mt.title LIKE ?
AND u.name LIKE ?
LIMIT 1
");
$stmt->execute([$user_id, '%' . $track_info['title'] . '%', '%' . $track_info['artist'] . '%']);
$track = $stmt->fetch(PDO::FETCH_ASSOC);
if ($track) {
$found_tracks[] = $track;
echo "<p class='success'>✓ Found: <strong>{$track['title']}</strong> by {$track['artist_name']} (Track ID: {$track['track_id']}, Purchase ID: {$track['purchase_id']})</p>";
} else {
echo "<p class='error'>✗ Not found: {$track_info['title']} by {$track_info['artist']}</p>";
}
}
if (empty($found_tracks)) {
die("<p class='warning'>No tracks found to remove. They may have already been removed.</p></body></html>");
}
echo "<p><strong>Found " . count($found_tracks) . " track(s) to remove</p>";
echo "</div>";
// Show what will be removed
echo "<div class='section'>";
echo "<h3>Step 2: What Will Be Removed</h3>";
echo "<table>";
echo "<tr><th>Purchase ID</th><th>Track ID</th><th>Track Title</th><th>Artist</th><th>Price Paid</th><th>Purchase Date</th></tr>";
foreach ($found_tracks as $track) {
echo "<tr>";
echo "<td>{$track['purchase_id']}</td>";
echo "<td>{$track['track_id']}</td>";
echo "<td><strong>{$track['title']}</strong></td>";
echo "<td>{$track['artist_name']}</td>";
echo "<td>\${$track['price_paid']}</td>";
echo "<td>{$track['purchase_date']}</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
// Execute removal
if (isset($_POST['execute_removal'])) {
echo "<div class='section'>";
echo "<h3>Step 3: Removing Tracks...</h3>";
$removed = [];
$failed = [];
foreach ($found_tracks as $track) {
try {
$pdo->beginTransaction();
// 1. Delete from track_purchases
$stmt = $pdo->prepare("DELETE FROM track_purchases WHERE id = ?");
$stmt->execute([$track['purchase_id']]);
$purchases_deleted = $stmt->rowCount();
// 2. Delete from user_library
$stmt = $pdo->prepare("DELETE FROM user_library WHERE user_id = ? AND track_id = ?");
$stmt->execute([$user_id, $track['track_id']]);
$library_deleted = $stmt->rowCount();
// 3. Delete from sales
$stmt = $pdo->prepare("DELETE FROM sales WHERE buyer_id = ? AND track_id = ?");
$stmt->execute([$user_id, $track['track_id']]);
$sales_deleted = $stmt->rowCount();
$pdo->commit();
$removed[] = [
'track' => $track['title'],
'artist' => $track['artist_name'],
'purchases' => $purchases_deleted,
'library' => $library_deleted,
'sales' => $sales_deleted
];
} catch (Exception $e) {
if ($pdo->inTransaction()) {
$pdo->rollBack();
}
$failed[] = [
'track' => $track['title'],
'error' => $e->getMessage()
];
}
}
// Show results
if (!empty($removed)) {
echo "<p class='success'><strong>✅ Successfully Removed:</strong></p>";
echo "<table>";
echo "<tr><th>Track</th><th>Artist</th><th>Purchases Deleted</th><th>Library Deleted</th><th>Sales Deleted</th></tr>";
foreach ($removed as $r) {
echo "<tr>";
echo "<td><strong>{$r['track']}</strong></td>";
echo "<td>{$r['artist']}</td>";
echo "<td>{$r['purchases']}</td>";
echo "<td>{$r['library']}</td>";
echo "<td>{$r['sales']}</td>";
echo "</tr>";
}
echo "</table>";
}
if (!empty($failed)) {
echo "<p class='error'><strong>❌ Failed to Remove:</strong></p>";
echo "<ul>";
foreach ($failed as $f) {
echo "<li><strong>{$f['track']}</strong>: {$f['error']}</li>";
}
echo "</ul>";
}
echo "<p style='margin-top: 20px;'><a href='/account_settings.php?tab=purchases' style='color: #667eea; font-size: 18px;'>✅ View Updated Purchases</a></p>";
echo "</div>";
} else {
// Show removal button
echo "<div class='section'>";
echo "<form method='POST'>";
echo "<button type='submit' name='execute_removal' value='1'>🗑️ Remove These Tracks Now</button>";
echo "</form>";
echo "<p class='warning'>⚠️ This will permanently remove these tracks from Stephane's account:</p>";
echo "<ul>";
foreach ($found_tracks as $track) {
echo "<li><strong>{$track['title']}</strong> by {$track['artist_name']}</li>";
}
echo "</ul>";
echo "<p class='warning'>This action cannot be undone. Make sure these are the correct tracks to remove.</p>";
echo "</div>";
}
echo "<hr>";
echo "<p><a href='/admin.php' style='color: #667eea;'>← Back to Admin</a> | ";
echo "<a href='/account_settings.php?tab=purchases' style='color: #667eea;'>View Purchases</a></p>";
echo "</body></html>";
?>