<?php
error_reporting(0);
global $service_url, $optician_id, $password;
$service_url = "http://87.127.13.154:899/DiaryWebService.svc?wsdl";
$optician_id = isset($_GET['OpticianId']) ? $_GET['OpticianId'] : null;
$password = 'OpenGate7';

errorIfNotSet('OpticianId');

function errorIfNotSet($param_name, $haystack = null){
    if(($haystack != null && isset($haystack[$param_name])) 
        || ($haystack == null && !isset($_GET[$param_name]))) {
        header('Content-Type: application/json');
        echo json_encode(['data'=> [], 
                    "status" => ["success"=>false, "message" => "$param_name not passed", "code" =>400 ]]);
        die;
    }
}

function checkGet(){
    if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
        header("HTTP/1.1 405 Method Not Allowed");
        header("Allow: GET");
        echo "Method Not Allowed";
    }
}

function checkPost(){
    if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
        header("HTTP/1.1 405 Method Not Allowed");
        header("Allow: POST");
        echo "Method Not Allowed";
    }
}
?>