Untitled
unknown
php
2 years ago
16 kB
1
Indexable
Never
<?php // Începeți sesiunea session_start(); if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { $_SESSION['return_to_page'] = $_SERVER['REQUEST_URI']; header("location: login.php"); exit; } // Preiați numele utilizatorului autentificat din variabila de sesiune $uploader = $_SESSION['username']; // Conectați-vă la baza de date pentru utilizator $servername_dashboard = "localhost"; $username_dashboard = "xtramus1_user"; $password_dashboard = "Pysquaifk!1@@XtraMusic"; $dbname_dashboard = "xtramus1_dashboard"; $conn_dashboard = new mysqli($servername_dashboard, $username_dashboard, $password_dashboard, $dbname_dashboard); if ($conn_dashboard->connect_error) { die("Connection failed: " . $conn_dashboard->connect_error); } // Conectați-vă la baza de date $servername = "localhost"; $username = "xtramus1_accounts"; $password = "Pysquaifk!1@@XtraMusic1234"; $dbname = "xtramus1_beatstore"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Procesați datele trimise prin formular $name = $_POST['name']; $bpm = $_POST['bpm']; $tone_key = $_POST['tone_key']; $genre = $_POST['genre']; $subgenre = $_POST['subgenre']; $main_mood = $_POST['main_mood']; $secondary_mood = $_POST['secondary_mood']; $price = $_POST['price']; // Schimbați aici $paypal_email = $_POST['paypal_email']; // Încărcați fișierul WAV în directorul "./beatstore" $file_path = './beatstore/' . basename($_FILES['file']['name']); move_uploaded_file($_FILES['file']['tmp_name'], $file_path); // Salvați datele în baza de date $sql = "INSERT INTO beats (name, file_path, bpm, tone_key, genre, subgenre, uploader, main_mood, secondary_mood, price, paypal_email) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmt = $conn->prepare($sql); if($uploader === null) { echo "Eroare: Uploader-ul nu a putut fi găsit."; exit; } else { $stmt->bind_param("ssissssssis", $name, $file_path, $bpm, $tone_key, $genre, $subgenre, $uploader, $main_mood, $secondary_mood, $price, $paypal_email); } $stmt->execute(); // Redirecționați către pagina 'beatstore.php' header('Location: beatstore.php'); exit; } ?> <!DOCTYPE html> <html lang="ro"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Upload Beatstore</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> <style> body { background-color: #f5f5f5; font-family: "Roboto", sans-serif; } .container { background-color: white; border-radius: 15px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); padding: 30px; margin-top: 50px; animation: fadeIn 1s; max-width: 600px; } h1 { font-weight: bold; margin-bottom: 20px; text-align: center; } label { font-weight: 600; } .form-control { border-radius: 5px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .form-control:focus { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); border-color: #0056b3; } .btn-primary { background-color: #007bff; border-color: #007bff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); font-weight: 600; transition: all 0.3s; } .btn-primary:hover { background-color: #0056b3; border-color: #0056b3; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); } .btn-primary:focus { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3); } @keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .custom-file-upload { position: relative; display: inline-block; cursor: pointer; padding: 10px 20px; background-color: #007BFF; color: white; font-weight: bold; border-radius: 5px; text-align: center; user-select: none; margin-top: 20px; } .custom-file-upload input[type="file"] { position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; } .custom-file-upload:hover { background-color: #0056b3; } .custom-file { margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; } .genre-label { margin-top: 20px; margin-bottom: 10px; } </style> </head> <body> <div class="row justify-content-center"> <div class="container col-md-6"> <div class="container"> <h1>Încărcați un beat</h1> <div class="form-group"> <label class="custom-file-upload"> <input type="file" name="file" id="file" class="form-control" accept=".wav" required> Alegeți un fișier WAV </label> </div> <form method="post" enctype="multipart/form-data"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="name">Titlu:</label> <input type="text" name="name" id="name" class="form-control" required> </div> <div class="form-group"> <label for="bpm">BPM:</label> <input type="number" name="bpm" id="bpm" class="form-control" required> </div> <div class="form-group"> <label for="tone_key">Tonalitate:</label> <select name="tone_key" id="tone_key" class="form-control" required> <option value="C">C</option> <option value="C#">C#</option> <option value="D">D</option> <option value="D#">D#</option> <option value="E">E</option> <option value="F">F</option> <option value="F#">F#</option> <option value="G">G</option> <option value="G#">G#</option> <option value="A">A</option> <option value="A#">A#</option> <option value="B">B</option> <option value="Cm">Cm</option> <option value="C#m">C#m</option> <option value="Dm">Dm</option> <option value="D#m">D#m</option> <option value="Em">Em</option> <option value="Fm">Fm</option> <option value="F#m">F#m</option> <option value="Gm">Gm</option> <option value="G#m">G#m</option> <option value="Am">Am</option> <option value="A#m">A#m</option> <option value="Bm">Bm</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="genre">Gen muzical:</label> <select name="genre" id="genre" class="form-control" required> <option value="Hip Hop">Hip Hop</option> <option value="Pop">Pop</option> <option value="R&B">R&B</option> <option value="Rock">Rock</option> <option value="Electronic">Electronic</option> <option value="Reggae">Reggae</option> <option value="Country">Country</option> <option value="Drill">Drill</option> <option value="HyperPop">HyperPop</option> <option value="Lo-Fi">Lo-Fi</option> <option value="Neo Soul">Neo Soul</option> </select> </div> <div class="form-group"> <label for="subgenre">Subgen:</label> <select name="subgenre" id="subgenre" class="form-control" required> <!-- Opțiunile vor fi actualizate de JavaScript --> </select> </div> <div class="form-group"> <label for="uploader">Numele uploader-ului:</label> <input class="form-control" type="text" id="uploader" name="uploader" value="<?php echo $_SESSION['username']; ?>" readonly> </div> </div> <div class="col-md-4"> <div class="form-group"> <!-- Adăugați acest câmp în formularul de încărcare --> <label for="paypal_email">E-mail PayPal:</label> <input class="form-control" type="email" name="paypal_email" id="paypal_email" required> </div> <div class="form-group"> <label for="main_mood">Mood principal:</label> <select name="main_mood" id="main_mood" class="form-control" required> <option value="None">None</option> <option value="Accomplished">Accomplished</option> <option value="Adored">Adored</option> <option value="Angry">Angry</option> <option value="Annoyed">Annoyed</option> <option value="Anxious">Anxious</option> <option value="Bouncy">Bouncy</option> <option value="Calm">Calm</option> <option value="Confident">Confident</option> <option value="Crazy">Crazy</option> <option value="Crunk">Crunk</option> <option value="Dark">Dark</option> <option value="Depressed">Depressed</option> <option value="Determined">Determined</option> <option value="Dirty">Dirty</option> <option value="Disappointed">Disappointed</option> <option value="Eccentric">Eccentric</option> <option value="Energetic">Energetic</option> <option value="Enraged">Enraged</option> <option value="Epic">Epic</option> <option value="Evil">Evil</option> <option value="Flirty">Flirty</option> <option value="Frantic">Frantic</option> <option value="Giddy">Giddy</option> <option value="Gloomy">Gloomy</option> <option value="Grateful">Grateful</option> <option value="Happy">Happy</option> <option value="Hyper">Hyper</option> <option value="Inspiring">Inspiring</option> <option value="Intense">Intense</option> <option value="Lazy">Lazy</option> <option value="Lonely">Lonely</option> <option value="Loved">Loved</option> <option value="Mellow">Mellow</option> <option value="Peaceful">Peaceful</option> <option value="Rebellious">Rebellious</option> <option value="Relaxed">Relaxed</option> <option value="Sad">Sad</option> <option value="Scared">Scared</option> <option value="Silly">Silly</option> </select> </div> <div class="form-group"> <label for="secondary_mood">Mood secundar:</label> <select name="secondary_mood" id="secondary_mood" class="form-control"> <option value="None">None</option> <option value="Accomplished">Accomplished</option> <option value="Adored">Adored</option> <option value="Angry">Angry</option> <option value="Annoyed">Annoyed</option> <option value="Anxious">Anxious</option> <option value="Bouncy">Bouncy</option> <option value="Calm">Calm</option> <option value="Confident">Confident</option> <option value="Crazy">Crazy</option> <option value="Crunk">Crunk</option> <option value="Dark">Dark</option> <option value="Depressed">Depressed</option> <option value="Determined">Determined</option> <option value="Dirty">Dirty</option> <option value="Disappointed">Disappointed</option> <option value="Eccentric">Eccentric</option> <option value="Energetic">Energetic</option> <option value="Enraged">Enraged</option> <option value="Epic">Epic</option> <option value="Evil">Evil</option> <option value="Flirty">Flirty</option> <option value="Frantic">Frantic</option> <option value="Giddy">Giddy</option> <option value="Gloomy">Gloomy</option> <option value="Grateful">Grateful</option> <option value="Happy">Happy</option> <option value="Hyper">Hyper</option> <option value="Inspiring">Inspiring</option> <option value="Intense">Intense</option> <option value="Lazy">Lazy</option> <option value="Lonely">Lonely</option> <option value="Loved">Loved</option> <option value="Mellow">Mellow</option> <option value="Peaceful">Peaceful</option> <option value="Rebellious">Rebellious</option> <option value="Relaxed">Relaxed</option> <option value="Sad">Sad</option> <option value="Scared">Scared</option> <option value="Silly">Silly</option> </select> </form> </div> </div> </div> <div class="row"> <div style="margin: auto;" class="col-md-4"> <div class="form-group"> <label for="price">Preț (EUR):</label> <input class="form-control" type="number" id="price" name="price" min="0" step="0.01"> </div> </div> </div> <div class="row"> <div class="col-md-12 text-right"> <button type="submit" class="btn btn-primary">Încărcați</button> </div> </div> <script> function updateSubgenreOptions() { var genre = document.getElementById("genre").value; var subgenreSelect = document.getElementById("subgenre"); subgenreSelect.innerHTML = ""; // Golește opțiunile existente var subgenres = []; if (genre === "Hip Hop") { subgenres = ["None", "Club", "Dirty South", "Old School", "East Coast", "Gangsta", "Reggaeton", "Underground", "Grime", "West Coast", "Crunk", "Orchestral", "Trap"]; } else if (genre === "Pop") { subgenres = ["None", "Rock", "Hip Hop", "Electronic", "R&B", "Country", "K-Pop"]; } else if (genre === "R&B") { subgenres = ["None", "Classic Soul", "Funk", "New soul", "Soul"]; } else if (genre === "Rock") { subgenres = ["None", "Alternative", "Indie Rock", "Classic Rock"]; } else if (genre === "Electronic") { subgenres = ["None", "Dance", "Techno", "House", "Dub step", "Break", "Drum&Bass", "Break", "2 Step", "Trip Hop", "Tropical House"]; } else if (genre === "Reggae") { subgenres = ["None", "Afrobeat", "Dancehall", "Reggaeton", "Dub", "Roots"]; } else if (genre === "Country") { subgenres = ["None", "Alternative", "Bluegrass", "Christian", "Country Rock", "Cowpunk", "Progressive", "Rockabilly", "Texas Country", "Western", "Western Swing"]; } else if (genre === "Drill" || genre === "HyperPop" || genre === "Lo-Fi" || genre === "Neo Soul") { subgenres = ["None"]; } for (var i = 0; i < subgenres.length; i++) { var option = document.createElement("option"); option.value = subgenres[i]; option.text = subgenres[i]; subgenreSelect.add(option); } } // Actualizați opțiunile subgenului când se modifică genul muzical document.getElementById("genre").addEventListener("change", updateSubgenreOptions); // Inițializează opțiunile subgenului când se încarcă pagina document.addEventListener("DOMContentLoaded", function () { updateSubgenreOptions(); }); </script> </body> </html>