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

handshake.php 1.81 KB
Newer Older
1
<?php
2
/* GNU FM -- a free network service for sharing your music listening habits
clint's avatar
clint committed
3

4
   Copyright (C) 2009 Free Software Foundation, Inc
clint's avatar
clint committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

   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/>.

*/

21
require_once('../database.php');
clint's avatar
clint committed
22 23

if(!isset($_GET['username']) || !isset($_GET['passwordmd5'])) {
clint's avatar
clint committed
24
	die("BADAUTH\n");
clint's avatar
clint committed
25 26
}

clint's avatar
hmm  
clint committed
27
$username = $_GET['username'];
28
$passmd5 = $_GET['passwordmd5'];
clint's avatar
hmm  
clint committed
29

30
$res = $adodb->GetOne('SELECT username FROM Users WHERE lower(username) = ' . $adodb->qstr(strtolower($username)) . ' AND password = ' . $adodb->qstr($passmd5));
clint's avatar
clint committed
31
if (!$res) {
clint's avatar
clint committed
32
	die("BADAUTH\n");
33 34 35 36
}

$session = md5($passmd5 . time());

clint's avatar
clint committed
37
$adodb->Execute('DELETE FROM Radio_Sessions WHERE expires < ' . (int)(time()));
38

clint's avatar
clint committed
39
$adodb->Execute('INSERT INTO Radio_Sessions (username, session, expires) VALUES ( ' . $adodb->qstr($username) . ', ' . $adodb->qstr($session) . ', ' . (int)(time() + 259200) . ')');
40

41 42
echo 'session=' . $session . "\n";
echo "stream_url=this.is.broken.{$username}.example.com\n";
clint's avatar
clint committed
43 44 45 46 47 48 49 50
echo "subscriber=0\n";
echo "framehack=0..\n";
echo "base_url=alpha.libre.fm\n";
echo "base_path=/radio\n";
echo "info_message=\n";
echo "fingerprint_upload_url=http://this.is.broken.example.com/fingerprint/upload.php\n";
echo "permit_bootstrap=0\n";
echo "freetrial=0\n";
clint's avatar
clint committed
51 52

?>