Changeset 1357

Show
Ignore:
Timestamp:
12/17/07 17:35:40 (13 months ago)
Author:
vollmerk
Message:

cleaned up XML API errors so that they are always xml docs regardless

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/docs/CHANGELOG

    r1355 r1357  
    55-------------------------------------------------------------------------- 
    66  v.3.4-Alpha4  
     7        - Fixed it so that all errors should return an XML document when 
     8                using the XML API.  
    79        - Added Basic ShoutBox functionality, needs formating fixes 
    810                and needs to be moved to a better spot in classic theme it 
  • trunk/lib/class/access.class.php

    r1337 r1357  
    180180                         * however we don't have the key that was passed yet so we've got to do just ip 
    181181                         */ 
     182                        case 'init-rpc': 
    182183                        case 'init-xml-rpc': 
    183184                                $sql = "SELECT `id` FROM `access_list`" . 
     
    190191                                        " AND  `key` = '$key' AND `level` >= '$level' AND `type`='rpc'"; 
    191192                        break; 
     193                        case 'init-api': 
    192194                        case 'network': 
    193195                        case 'interface': 
  • trunk/lib/init.php

    r1351 r1357  
    8282 
    8383/** This is the version.... fluf nothing more... **/ 
    84 $results['version']             = '3.4-Alpha4 Build (004)'; 
     84$results['version']             = '3.4-Alpha4 Build (005)'; 
    8585$results['int_config_version']  = '6';  
    8686 
  • trunk/server/xml.server.php

    r1320 r1357  
    2828require_once '../lib/init.php'; 
    2929 
    30 // If we don't even have access control on then we can't use this! 
    31 if (!Config::get('access_control')) { access_denied(); exit; }   
    3230 
    33 /**  
    34  * Verify the existance of the Session they passed in we do allow them to 
    35  * login via this interface so we do have an exception for action=login 
    36  */ 
    37 if (!Access::session_exists(array(),$_REQUEST['auth'],'api') AND $_REQUEST['action'] != 'handshake') {  
    38         debug_event('Access Denied','Invalid Session or unthorized access attempt to API','5');  
    39         exit();  
    40 } 
    4131 
    4232// If it's not a handshake then we can allow it to take up lots of time 
     
    4939header("Content-Disposition: attachment; filename=information.xml"); 
    5040 
     41// If we don't even have access control on then we can't use this! 
     42if (!Config::get('access_control')) {  
     43        ob_end_clean();  
     44        echo xmlData::error('Access Control not Enabled'); 
     45        exit;  
     46 
     47 
     48/**  
     49 * Verify the existance of the Session they passed in we do allow them to 
     50 * login via this interface so we do have an exception for action=login 
     51 */ 
     52if ((!Access::session_exists(array(),$_REQUEST['auth'],'api') AND $_REQUEST['action'] != 'handshake') || !Access::check_network('init-api',$_SERVER['REMOTE_ADDR'],$_REQUEST['user'])) {  
     53        debug_event('Access Denied','Invalid Session or unathorized access attempt to API','5');  
     54        ob_end_clean();  
     55        echo xmlData::error('Access Denied due to ACL or unauthorized access attempt to API, attempt logged'); 
     56        exit();  
     57} 
     58 
     59 
    5160switch ($_REQUEST['action']) {  
    5261        case 'handshake':  
     
    5564                 
    5665                if (!$token) {  
     66                        ob_end_clean();  
    5767                        echo xmlData::error('Error Invalid Handshake, attempt logged');  
    5868                }  
    5969                else {  
     70                        ob_end_clean();  
    6071                        echo xmlData::keyed_array($token);  
    6172                }  
     
    7687                $artists = Browse::get_objects();  
    7788                // echo out the resulting xml document 
     89                ob_end_clean();  
    7890                echo xmlData::artists($artists);  
    7991        break;  
     
    8597                // Set the offset 
    8698                xmlData::set_offset($_REQUEST['offset']); 
    87  
     99                ob_end_clean();  
    88100                echo xmlData::albums($albums);  
    89101        break;  
     
    94106                // Set the offset 
    95107                xmlData::set_offset($_REQUEST['offset']);  
    96                 xmlData::songs($songs);  
     108                ob_end_clean();  
     109                echo xmlData::songs($songs);  
    97110        break;  
    98111        case 'albums':  
     
    108121                // Set the offset 
    109122                xmlData::set_offset($_REQUEST['offset']); 
    110  
     123                ob_end_clean();  
    111124                echo xmlData::albums($albums);  
    112125        break;  
     
    117130                // Set the offset 
    118131                xmlData::set_offset($_REQUEST['offset']); 
    119  
     132                ob_end_clean();  
    120133                echo xmlData::songs($songs);  
    121134        break;  
     
    132145                // Set the offset 
    133146                xmlData::set_offset($_REQUEST['offset']); 
    134  
     147                ob_end_clean();  
    135148                echo xmlData::genres($genres);  
    136149        break;  
     
    138151                $genre = new Genre($_REQUEST['filter']);  
    139152                $artists = $genre->get_artists();  
    140                  
     153                ob_end_clean();  
    141154                echo xmlData::artists($artists);         
    142155        break;  
     
    144157                $genre = new Genre($_REQUEST['filter']);  
    145158                $albums = $genre->get_albums();  
    146  
     159                ob_end_clean();  
    147160                echo xmlData::albums($albums);  
    148161        break; 
     
    150163                $genre = new Genre($_REQUEST['filter']);  
    151164                $songs = $genre->get_songs();  
    152          
     165                ob_end_clean();          
    153166                echo xmlData::songs($songs);  
    154167        break;  
     
    165178                // Set the offset 
    166179                xmlData::set_offset($_REQUEST['offset']); 
    167  
     180                ob_end_clean();  
    168181                echo xmlData::songs($songs);  
    169182        break;  
    170183        default: 
    171                 // Rien a faire 
     184                ob_end_clean(); 
     185                echo xmlData::error('Invalid Request'); 
    172186        break; 
    173187} // end switch action