scrobble-proxy.php 1.5 KB
Newer Older
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
4

5
   Copyright (C) 2009 Free Software Foundation, Inc
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

require_once('config.php');

elleo's avatar
elleo committed
24 25
if ($_GET['method'] == 'scrobble') {
	$url = $submissions_server . '/submissions/1.2/';
26
} else if ($_GET['method'] == 'nowplaying') {
elleo's avatar
elleo committed
27
	$url = $submissions_server . '/nowplaying/1.2/';
28
} else {
clint's avatar
clint committed
29
	die("Invalid proxy method\n");
30 31 32
}

$session = curl_init($url);
33 34

$post_vars = '';
35
foreach ($_POST as $key => $element) {
36 37
	if (is_array($element)) {
		$i = 0;
38
		foreach ($element as $e) {
39
			$post_vars .= $key . '[' . $i . ']=' . rawurlencode($e) . '&';
40 41 42
			$i++;
		}
	} else {
43
		$post_vars .= $key . '=' . rawurlencode($element) . '&';
44 45
	}
}
46 47
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $post_vars);
48 49 50 51 52

$response = curl_exec($session);
echo $response;

curl_close($session);