<?php

    error_reporting
(0);
    
define('API_KEY''example');
    
// change API_KEY in production mode!

    
$data $_POST;
    unset(
$data['hash']);

    
// check hash
    // if( $_POST['hash'] != substr( md5(API_KEY . '+'. join('+', $data) ), -8 ) ) {

    //     die('Invalid hash!');

    // }

    
if( $_POST['action'] == 'getAvailability' ) {

        
$result = array();

        
// fill data - this is example with random data!

        
$courtStatus = array( 0510 );
        for( 
$h 7$h 24$h++ ) {

            
$resultsprintf("%'.02d:00"$h) ] = array(
                
'status' => $courtStatusrand(02) ],
                
'price' => null
            
);
        }

        
// end: fill data

        
echo json_encode$result );

    }

    if( 
$_POST['action'] == 'getCourtsAvailability' ) {

        
$result = array();

        
// fill data - this is example with random data!

        
$courts range(110);
        
shuffle($courts);

        for( 
$c 1$c rand(25); $c++ ) {

            
$result$c ] = array(
                
'name' => 'Kort '$c,
                
'price' => null
            
);
        }

        
// end: fill data

        
echo json_encode$result );

    }

    if( 
$_POST['action'] == 'reserve' ) {

        
// fill data - this is example with random data!

        
$results = array('OK','NO_COURTS','FATAL ERROR');
        echo 
$resultsrand(02) ];

        
// end: fill data

    
}

?>