"$number"); getDataFromClient($clientid,"getLastClosings",$data); } /** * Get the sum of still unpaid tables and the number of open tables. * @param unknown $clientid */ function getOpenTables($clientid) { getDataFromClient($clientid,"getOpenTables",array()); } function getReport($clientid) { getDataFromClient($clientid,"getReport",array()); } function getWaiterMessage($clientid) { getDataFromClient($clientid,"getWaiterMessage",array()); } function sendWaiterMessage($clientid,$message) { getDataFromClient($clientid,"sendWaiterMessage",array("message" => $message)); } function getLoginMessage($clientid) { getDataFromClient($clientid,"getLoginMessage",array()); } function sendLoginMessage($clientid,$message) { getDataFromClient($clientid,"sendLoginMessage",array("message" => $message)); } /** * Fetch the parameters of a client with the given clientid from the data base * by use of the remote access command of that client. */ function getDataFromClient($clientid,$command,$data) { $pdo = DbUtils::openDbAndReturnPdo(); $sql = "SELECT * FROM %clients% WHERE id=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($clientid)); if ($stmt->rowCount() > 0) { $client =$stmt->fetchObject(); $clientname = $client->name; $clienturl = $client->url . "/php/remoteaccess.php?command=$command"; $clientaccesscode = $client->remoteaccesscode; $clientAuthUser = $client->basicauthuser; $clientAuthPass = $client->basicauthpass; } $data = array_merge($data,array('remoteaccesscode' => "$clientaccesscode")); $query = http_build_query($data); $opts = array( 'http'=>array( 'header' => "Content-Type: application/x-www-form-urlencoded\r\n". "Authorization: Basic " . base64_encode("$clientAuthUser:$clientAuthPass") . "Content-Length: ".strlen($query)."\r\n". "User-Agent:MyAgent/1.0\r\n", 'method' => 'POST', 'content' => $query ) ); $context = stream_context_create($opts); // Open the file using the HTTP headers set above $file = file_get_contents($clienturl, false, $context); echo $file; }