playlist.php
changeset 21 74edc873234f
parent 10 d3059e20b0fa
child 25 5c377ceb0e4c
--- a/playlist.php	Fri Apr 25 14:56:52 2008 -0400
+++ b/playlist.php	Mon Jun 30 12:36:13 2008 -0400
@@ -13,9 +13,32 @@
  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
  */
 
-function amarok_playlist($server)
+function amarok_playlist($httpd, $socket)
 {
   global $theme, $playlist, $allowcontrol;
+  global $use_auth, $auth_data;
+  
+  if ( $use_auth )
+  {
+    if ( !isset($_SERVER['PHP_AUTH_USER']) )
+    {
+      $httpd->header('WWW-Authenticate: basic');
+      $httpd->send_http_error($socket, 401, "A username and password are required to access this resource. Either you did not specify a username and password, or the supplied credentials were incorrect.");
+      return true;
+    }
+    if ( !isset($auth_data[$_SERVER['PHP_AUTH_USER']]) )
+    {
+      $httpd->header('WWW-Authenticate: basic');
+      $httpd->send_http_error($socket, 401, "A username and password are required to access this resource. Either you did not specify a username and password, or the supplied credentials were incorrect.");
+      return true;
+    }
+    else if ( $auth_data[$_SERVER['PHP_AUTH_USER']] !== $_SERVER['PHP_AUTH_PW'] )
+    {
+      $httpd->header('WWW-Authenticate: basic');
+      $httpd->send_http_error($socket, 401, "A username and password are required to access this resource. Either you did not specify a username and password, or the supplied credentials were incorrect.");
+      return true;
+    }
+  }
   
   $iphone = ( ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
        strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') ||