![]() 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/gocodeme.com/public_html/BACKUP/includes/ |
<?php
// Database functions for SoundStudioPro
/**
* Get user's music tracks from database
*/
function getUserMusicTracks($userId, $limit = 10) {
$pdo = getDBConnection();
if (!$pdo) return [];
try {
$stmt = $pdo->prepare("
SELECT * FROM music_tracks
WHERE user_id = ?
ORDER BY created_at DESC
LIMIT ?
");
$stmt->execute([$userId, $limit]);
return $stmt->fetchAll();
} catch (PDOException $e) {
error_log("Get user music tracks failed: " . $e->getMessage());
return [];
}
}
/**
* Get user by ID
*/
function getUserById($userId) {
$pdo = getDBConnection();
if (!$pdo) return false;
try {
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$userId]);
return $stmt->fetch();
} catch (PDOException $e) {
error_log("Get user failed: " . $e->getMessage());
return false;
}
}
/**
* Update user credits
*/
function updateUserCredits($userId, $credits) {
$pdo = getDBConnection();
if (!$pdo) return false;
try {
$stmt = $pdo->prepare("UPDATE users SET credits = ? WHERE id = ?");
return $stmt->execute([$credits, $userId]);
} catch (PDOException $e) {
error_log("Update user credits failed: " . $e->getMessage());
return false;
}
}
/**
* Get user's total tracks count
*/
function getUserTracksCount($userId) {
$pdo = getDBConnection();
if (!$pdo) return 0;
try {
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM music_tracks WHERE user_id = ?");
$stmt->execute([$userId]);
$result = $stmt->fetch();
return $result['count'] ?? 0;
} catch (PDOException $e) {
error_log("Get user tracks count failed: " . $e->getMessage());
return 0;
}
}
/**
* Get recent tracks for dashboard
*/
function getRecentTracks($limit = 5) {
$pdo = getDBConnection();
if (!$pdo) return [];
try {
$stmt = $pdo->prepare("
SELECT mt.*, u.name as user_name
FROM music_tracks mt
LEFT JOIN users u ON mt.user_id = u.id
ORDER BY mt.created_at DESC
LIMIT ?
");
$stmt->execute([$limit]);
return $stmt->fetchAll();
} catch (PDOException $e) {
error_log("Get recent tracks failed: " . $e->getMessage());
return [];
}
}
?>