This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
58 lines (44 loc) · 1.62 KB
/
insert.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once('../../../wp-load.php');
$auth = $_POST['auth'];
$users_table = $wpdb->prefix . "users";
$songs_table = $wpdb->prefix . "songs";
$result = $wpdb->get_results("SELECT id FROM $users_table WHERE MD5(user_pass) = '$auth'");
if($result)
{
$user_id = $result[0]->id;
$title = $_POST['song']['title'];
$artist = $_POST['song']['artist'];
$album = $_POST['song']['album'];
if($title && $artist && $album)
{
require("aws_signed_request.php");
$search = "$artist, $album";
$public_key = get_option("now_playing_amzn_public");
$private_key = get_option("now_playing_amzn_private");
$tag = get_option("now_playing_amzn_tag") ? get_option("now_playing_amzn_tag") : "mybl06a-20";
$pxml = aws_signed_request("com", array("Operation"=>"ItemSearch","SearchIndex"=>"Music","ResponseGroup"=>"Small,Images", "Keywords" => $search, "AssociateTag" => $tag), $public_key, $private_key);
if ($pxml === False)
{
die("problem inserting song");
}
else
{
if (isset($pxml->Items->Item->MediumImage->URL))
{
$img = $pxml->Items->Item->MediumImage->URL;
$url = $pxml->Items->Item->DetailPageURL;
}
}
$insert = "INSERT INTO $songs_table (img, title, artist, album, url, user_id) VALUES ('$img','$title','$artist','$album','$url','$user_id')";
$results = $wpdb->query( $insert );
echo "song inserted";
}
else
die("Missing required field");
}
else
{
die("bad credentials");
}
?>