playlist.php
changeset 44 92dd253f501c
parent 40 bd3372a2afc1
equal deleted inserted replaced
43:2634d550a97b 44:92dd253f501c
    14  */
    14  */
    15 
    15 
    16 function amarok_playlist($httpd, $socket)
    16 function amarok_playlist($httpd, $socket)
    17 {
    17 {
    18   global $theme, $playlist, $allowcontrol;
    18   global $theme, $playlist, $allowcontrol;
    19   global $use_auth, $auth_data;
    19   global $use_auth;
    20   
    20   
    21   if ( $use_auth )
    21   if ( !session_check() )
    22   {
    22   {
    23     if ( !isset($_SERVER['PHP_AUTH_USER']) )
    23     $httpd->header('HTTP/1.1 307 Temporary Redirect');
    24     {
    24     $httpd->header('Location: /login');
    25       $httpd->header('WWW-Authenticate: basic');
    25     
    26       $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.");
    26     return;
    27       return true;
       
    28     }
       
    29     if ( !isset($auth_data[$_SERVER['PHP_AUTH_USER']]) )
       
    30     {
       
    31       $httpd->header('WWW-Authenticate: basic');
       
    32       $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.");
       
    33       return true;
       
    34     }
       
    35     else if ( $auth_data[$_SERVER['PHP_AUTH_USER']] !== $_SERVER['PHP_AUTH_PW'] )
       
    36     {
       
    37       $httpd->header('WWW-Authenticate: basic');
       
    38       $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.");
       
    39       return true;
       
    40     }
       
    41   }
    27   }
    42   
    28   
    43   $iphone = ( ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
    29   $iphone = ( ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
    44        strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') ||
    30        strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') ||
    45        strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ||
    31        strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ||
    59       'volume.js',
    45       'volume.js',
    60       'dom-drag.js',
    46       'dom-drag.js',
    61       'position.js'
    47       'position.js'
    62     ));
    48     ));
    63   $smarty->assign('allow_control', $allowcontrol);
    49   $smarty->assign('allow_control', $allowcontrol);
       
    50   $smarty->assign('use_auth', $use_auth);
       
    51   $smarty->assign('greyhound_version', GREY_VERSION);
    64   $smarty->register_function('sprite', 'smarty_function_sprite');
    52   $smarty->register_function('sprite', 'smarty_function_sprite');
    65   $smarty->display('playlist.tpl');
    53   $smarty->display('playlist.tpl');
    66 }
    54 }
    67 
    55 
    68 function artwork_request_handler($httpd, $socket)
    56 function artwork_request_handler($httpd, $socket)