-
Notifications
You must be signed in to change notification settings - Fork 0
/
uploadToDB.php
35 lines (29 loc) · 1.12 KB
/
uploadToDB.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once('1trainSongs.php');
require_once('1trainArtists.php');
require_once('1trainUsers.php');
$songid = $_REQUEST['id'];
$artistid = $_REQUEST['user_id'];
$title = $_REQUEST['title'];
$artist = $_REQUEST['user']['username'];
$art = $_REQUEST['artwork_url'];
$avatar = $_REQUEST['user']['avatar_url'];
$user_id = $_REQUEST['whoLikedID'];
$profile = $_REQUEST['whoLiked'];
Artists::create($artistid, $artist);
Users::create($user_id, $profile);
if($art == "") {
$avatar = explode("large", $avatar)[0] . "crop.jpg"; //gets a higher quality image
Songs::create($songid, $title, $artistid, $avatar, $user_id);
} elseif ($art=="https://sndcdn.com/images/default_avatar_crop.jpg") { //if no song art or user avatar
$art = "photoshop/carousel-headphones-black-red.png";
Songs::create($songid, $title, $artistid, $art, $user_id);
}
else {
$art = explode("large", $art)[0] . "crop.jpg"; //gets a higher quality image
Songs::create($songid, $title, $artistid, $art, $user_id);
}
header('Content-type: application/json');
print("success from uploadToDB");
exit();
?>