$title = isset($_POST['title']) ? $_POST['title'] : ""; $description = isset($_POST['description']) ? $_POST['description'] : ""; $downloadable = isset($_POST['downloadable']) ? "true" : "false"; if ($title) { $user = '******'; $sequence = $_SESSION['sequenceArr']; $hash = md5($user . $sequence + rand()); $shareUrl = APP_URL . "?p=" . $hash; $options = array("asset_data" => "@" . APP_PATH . $_SESSION['soundcloud_tmp_file'], "title" => $title, "description" => $description . "\n<a href='{$shareUrl}'>{$shareUrl}</a>", "sharing" => "public", "streamable" => "true", "downloadable" => $downloadable); //UPLOAD TRACK TO SOUNDCLOUD $result = $soundcloud->execute('tracks.json', 'track', 'POST', $options, 'multipart/form-data'); $permalink = $result->permalink_url; //ADD NEWLY UPLOADED TRACK INFO TO DB //$tracks = $soundcloud->execute('groups/20839/tracks?format=json', '', 'GET'); $battle = new Battle(); $battle->addTrack($result); //ASSOCIATE NEWLY UPLOADED TRACK WITH GROUP $soundcloud->execute('groups/20839/contributions/' . $result->id, '', 'PUT'); //SAVE PATTERN IN `shared_patterns` TABLE $patternAPI = new Pattern(); $patternAPI->share($user, $sequence, $hash); //DELETE TRACK FROM DISK AND CLEAR SESSION VARIABLES unlink($_SESSION['soundcloud_tmp_file']); $_SESSION['soundcloud_tmp_file'] = ""; $_SESSION['sequenceArr'] = ""; $success = true; } else { $error = true; } } ?>