We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 0ac0adf8 authored by elleo's avatar elleo

Automatically detect base_url in nixtaoe's install.php and submissions_server...

Automatically detect base_url in nixtaoe's install.php and submissions_server in gnukebox's install.php (fixes bug #26352)
Make display.php in gnukebox use submissions_server for url base locations (allows installations to places other than the root of a domain) (fixes bug #26352)
Add submissions_server option to nixtape's install.php for use by the javascript player
Add now playing support to the scrobble proxy in preparation for adding support to the javascript player
parent 8971cb1e
......@@ -21,19 +21,20 @@
header('Content-type: text/html; charset=utf-8');
require_once('database.php');
require_once('utils/human-time.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Libre.fm &mdash; discover new music</title>
<link rel="stylesheet" href="/reset-fonts-grids.css" type="text/css">
<link rel="stylesheet" href="/base.css" type="text/css">
<link rel="stylesheet" href="/librefm.css" type="text/css">
<link rel="stylesheet" href="<?php echo $submissions_server ?>/reset-fonts-grids.css" type="text/css">
<link rel="stylesheet" href="<?php echo $submissions_server ?>/base.css" type="text/css">
<link rel="stylesheet" href="<?php echo $submissions_server ?>/librefm.css" type="text/css">
</head>
<body>
<div id="doc2" class="yui-t7">
<div id="hd" role="navigation"><h1><a href="/">Header</a></h1>
<div id="hd" role="navigation"><h1><a href="<?php echo $submissions_server ?>">Header</a></h1>
<ul>
<li><a href="https://savannah.nongnu.org/svn/?group=librefm">Code</a></li>
......@@ -55,9 +56,9 @@ require_once('utils/human-time.php');
<div style="padding: 10px;">
<?php
$req_user = urldecode($_GET["u"]);
$req_artist = urldecode($_GET["a"]);
$req_track = urldecode($_GET["t"]);
$req_user = urldecode($_GET["u"]);
$req_artist = urldecode($_GET["a"]);
$req_track = urldecode($_GET["t"]);
if ($req_user) {
......@@ -102,7 +103,7 @@ if ($req_user) {
echo ($i % 2 == 0) ? "<tr class=\"even\">" : "<tr class=\"odd\">";
foreach($row as $field => $value) {
if($field == "username"){
$value = "<a href=\"/user/" . $value . "\">$value</a>";}
$value = "<a href=\"" . $submissions_server . "/user/" . $value . "\">$value</a>";}
if($field == "time") {
$value = '<abbr title=\'' . strftime('%c', $value) . '\'>' . human_timestamp($value) . '</abbr>';
}
......@@ -209,7 +210,7 @@ what's happening.
<p><img src="http://libre.fm/i/cc-by-sa.png" alt="Attribution-ShareAlike 3.0" /></p>
<p><a href="/data">Data dumps are here</a></p>
<p><a href="<? echo $submissions_server; ?>/data">Data dumps are here</a></p>
</div>
</div>
......
......@@ -21,6 +21,7 @@
require_once('MDB2.php');
require_once('version.php');
require_once('utils/get_absolute_url.php');
if(file_exists("config.php")) {
die("A configuration file already exists. Please delete <i>config.php</i> if you wish to reinstall.");
......@@ -201,7 +202,7 @@ if (isset($_POST['install'])) {
$install_path = dirname(__FILE__) . "/";
//Write out the configuration
$config = "<?php \$config_version = " . $version .";\n \$connect_string = '" . $connect_string . "';\n \$submissions_server = '" . $submissions_server . "';\n\$install_path = '" . $install_path . "'; ?>";
$config = "<?php\n \$config_version = " . $version .";\n \$connect_string = '" . $connect_string . "';\n \$submissions_server = '" . $submissions_server . "';\n\$install_path = '" . $install_path . "'; ?>";
$conf_file = fopen("config.php", "w");
$result = fwrite($conf_file, $config);
......@@ -253,7 +254,7 @@ if (isset($_POST['install'])) {
</div>
<br />
<h2>Servers</h2>
Submissions Server URL: <input type="text" name="submissions" value="http://localhost/" /><br />
Submissions Server URL: <input type="text" name="submissions" value="<?php echo getAbsoluteURL(); ?>" /><br />
<br />
<input type="submit" value="Install" name="install" />
</form>
......
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
Copyright (C) 2009 Libre.fm Project
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/>.
*/
function getAbsoluteURL() {
$scriptName = $_SERVER['SCRIPT_NAME'];
$path = explode("/", $scriptName);
array_pop($path);
$server = $_SERVER['HTTP_HOST'];
$string = (implode("/", $path).'/');
return "http://".$server.$string;
}
?>
......@@ -19,11 +19,9 @@
*/
?>
<?php
require_once('MDB2.php');
require_once('version.php');
require_once('utils/get_absolute_url.php');
if(file_exists("config.php")) {
die("A configuration file already exists. Please delete <i>config.php</i> if you wish to reinstall.");
......@@ -51,9 +49,10 @@ if (isset($_POST['install'])) {
$default_theme = $_POST['default_theme'];
$base_url = $_POST['base_url'];
$submissions_server = $_POST['submissions_server'];
//Write out the configuration
$config = "<?php \$config_version = " . $version .";\n \$connect_string = '" . $connect_string . "';\n \$default_theme = '" . $default_theme . "';\n \$base_url = '" . $base_url . "';\n \$install_path = '" . $install_path . "'; ?>";
$config = "<?php\n \$config_version = " . $version .";\n \$connect_string = '" . $connect_string . "';\n \$default_theme = '" . $default_theme . "';\n \$base_url = '" . $base_url . "';\n \$submissions_server = '" . $submissions_server . "';\n \$install_path = '" . $install_path . "'; ?>";
$conf_file = fopen("config.php", "w");
$result = fwrite($conf_file, $config);
......@@ -116,7 +115,8 @@ if (isset($_POST['install'])) {
}
?>
</select><br />
Base URL: <input type="text" name="base_url" /><br />
Base URL: <input type="text" name="base_url" value="<?php echo getAbsoluteURL(); ?>" /><br />
Submissions Server: <input type="text" name="submissions_server" /> (URL to your gnukebox install)<br />
<br /><br />
<input type="submit" value="Install" name="install" />
</form>
......
......@@ -108,7 +108,7 @@ function scrobble() {
return;
}
timestamp = Math.round(new Date().getTime() / 1000)
$.post("/scrobble-proxy.php", { "a[0]" : artist, "b[0]" : album, "t[0]" : track, "i[0]" : timestamp, "s" : session_key },
$.post("/scrobble-proxy.php?method=scrobble", { "a[0]" : artist, "b[0]" : album, "t[0]" : track, "i[0]" : timestamp, "s" : session_key },
function(data){
if(data.substring(0, 2) == "OK") {
$("#scrobbled").fadeIn(5000, function() { $("#scrobbled").fadeOut(5000) } );
......
......@@ -21,7 +21,15 @@
require_once('config.php');
$session = curl_init($submissions_url);
if ($_GET['method'] == "scrobble") {
$url = $submissions_server . "/submissions/1.2/";
} elseif ($_GET['method'] == "nowplaying") {
$url = $submissions_server . "/nowplaying/1.2/";
} else {
die("Invalid proxy method\n");
}
$session = curl_init($url);
$post_vars = '';
foreach($_POST as $key => $element) {
......
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
Copyright (C) 2009 Libre.fm Project
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/>.
*/
function getAbsoluteURL() {
$scriptName = $_SERVER['SCRIPT_NAME'];
$path = explode("/", $scriptName);
array_pop($path);
$server = $_SERVER['HTTP_HOST'];
$string = (implode("/", $path).'/');
return "http://".$server.$string;
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment