ajax.php
changeset 3 e7447a6044ec
parent 2 860ba7141641
child 5 9b96265b5918
equal deleted inserted replaced
2:860ba7141641 3:e7447a6044ec
    30   return true;
    30   return true;
    31 }
    31 }
    32 
    32 
    33 function ajax_request_handler($httpd)
    33 function ajax_request_handler($httpd)
    34 {
    34 {
    35   global $playlist, $mime_types, $json;
    35   global $playlist, $mime_types, $json, $allowcontrol;
    36   
    36   
    37   // Set content type
    37   // Set content type
    38   $httpd->header("Content-type: {$mime_types['js']}");
    38   $httpd->header("Content-type: {$mime_types['js']}");
    39   
    39   
    40   // get PATH_INFO
    40   // get PATH_INFO
    49   switch ( $action )
    49   switch ( $action )
    50   {
    50   {
    51     case 'stop':
    51     case 'stop':
    52     case 'next':
    52     case 'next':
    53     case 'prev':
    53     case 'prev':
       
    54       if ( !$allowcontrol )
       
    55         return false;
    54       echo dcop_action('player', 'stop');
    56       echo dcop_action('player', 'stop');
    55       break;
    57       break;
    56     case 'play':
    58     case 'play':
       
    59       if ( !$allowcontrol )
       
    60         return false;
    57       echo dcop_action('player', 'playPause');
    61       echo dcop_action('player', 'playPause');
    58       break;
    62       break;
    59     case 'jump':
    63     case 'jump':
       
    64       if ( !$allowcontrol )
       
    65         return false;
    60       $tid =& $params[1];
    66       $tid =& $params[1];
    61       if ( !preg_match('/^[0-9]+$/', $tid) )
    67       if ( !preg_match('/^[0-9]+$/', $tid) )
    62       {
    68       {
    63         return die_json('Invalid track ID');
    69         return die_json('Invalid track ID');
    64       }
    70       }
    69         'current_track_pos' => 0
    75         'current_track_pos' => 0
    70       );
    76       );
    71       echo $json->encode($return);
    77       echo $json->encode($return);
    72       break;
    78       break;
    73     case 'volume':
    79     case 'volume':
       
    80       if ( !$allowcontrol )
       
    81         return false;
    74       $volume =& $params[1];
    82       $volume =& $params[1];
    75       if ( !preg_match('/^[0-9]+$/', $volume) )
    83       if ( !preg_match('/^[0-9]+$/', $volume) )
    76       {
    84       {
    77         return die_json('Invalid track ID');
    85         return die_json('Invalid track ID');
    78       }
    86       }