forked from JanisV/Rompr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetLfmBio.php
More file actions
33 lines (30 loc) · 888 Bytes
/
Copy pathgetLfmBio.php
File metadata and controls
33 lines (30 loc) · 888 Bytes
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
<?php
ob_start();
include ("vars.php");
include ("functions.php");
if(array_key_exists("url", $_REQUEST)) {
get_lfm_page( $_REQUEST['url'], $prefs['lastfmlang']==='true' );
} else {
header('HTTP/1.1 400 Bad Request');
}
ob_flush();
function get_lfm_page($page, $use_lang) {
if ($use_lang) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$content = url_get_contents($page."/+wiki?lang=".$lang);
}
else {
$content = url_get_contents($page."/+wiki");
}
$html = $content['contents'];
$html = preg_replace('/\n/', '</p><p>', $html);
$html = preg_replace('/<br \/>/', '', $html);
$matches = array();
preg_match('/<div id=\"wiki\">(.*?)<\/div>/', $html, $matches);
if (array_key_exists(1, $matches)) {
print "<p>".$matches[1]."</p>";
} else {
header('HTTP/1.1 400 Bad Request');
}
}
?>