adjust.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2009 Free Software Foundation, Inc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. require_once('../database.php');
  16. require_once('radio-utils.php');
  17. if (!isset($_GET['session']) || !isset($_GET['url'])) {
  18. die("FAILED\n");
  19. }
  20. $session = $_GET['session'];
  21. $url = $_GET['url'];
  22. $res = $adodb->GetOne('SELECT username FROM Radio_Sessions WHERE session = ' . $adodb->qstr($session));
  23. if (!$res) {
  24. die("BADSESSION\n");
  25. }
  26. if (preg_match('@^(globaltags|artist|user)/[^:]+$@', $url, $regs)) {
  27. $url = 'librefm://' . $url; // compensate for shell-fm sending incomplete urls
  28. }
  29. $stationname = radio_title_from_url($url);
  30. if ($stationname == 'FAILED') {
  31. die("FAILED Unavailable station\n");
  32. }
  33. $adodb->Execute('UPDATE Radio_Sessions SET url = ' . $adodb->qstr($url) . ' WHERE session = ' . $adodb->qstr($session));
  34. echo "response=OK\n";
  35. echo "url=http://libre.fm\n"; // Need to parse the station request and give a real URL
  36. echo 'stationname=' . $stationname ."\n";