ajax.php
changeset 44 92dd253f501c
parent 21 74edc873234f
child 55 b8a3c9c54fbe
equal deleted inserted replaced
43:2634d550a97b 44:92dd253f501c
    37 function ajax_request_handler($httpd, $socket)
    37 function ajax_request_handler($httpd, $socket)
    38 {
    38 {
    39   global $playlist, $mime_types, $json, $allowcontrol;
    39   global $playlist, $mime_types, $json, $allowcontrol;
    40   global $use_auth, $auth_data;
    40   global $use_auth, $auth_data;
    41   
    41   
    42   if ( $use_auth )
    42   if ( !session_check() )
    43   {
    43     return true;
    44     if ( !isset($_SERVER['PHP_AUTH_USER']) )
       
    45     {
       
    46       $httpd->header('WWW-Authenticate: basic');
       
    47       $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.");
       
    48       return true;
       
    49     }
       
    50     if ( !isset($auth_data[$_SERVER['PHP_AUTH_USER']]) )
       
    51     {
       
    52       $httpd->header('WWW-Authenticate: basic');
       
    53       $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.");
       
    54       return true;
       
    55     }
       
    56     else if ( $_SERVER['PHP_AUTH_PW'] !== $auth_data[$_SERVER['PHP_AUTH_USER']] )
       
    57     {
       
    58       $httpd->header('WWW-Authenticate: basic');
       
    59       $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.");
       
    60       return true;
       
    61     }
       
    62   }
       
    63   
    44   
    64   // Set content type
    45   // Set content type
    65   $httpd->header("Content-type: {$mime_types['js']}");
    46   $httpd->header("Content-type: {$mime_types['js']}");
    66   
    47   
    67   // get PATH_INFO
    48   // get PATH_INFO