clienttest.php revision d01bb88591e2ae070aa233b99c81e58598d557e1
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * Sample client for the VirtualBox webservice, written in PHP.
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * Run the VirtualBox web service server first; see the VirtualBox
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * SDK reference for details.
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * Copyright (C) 2009-2010 Oracle Corporation
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * Contributed by James Lucas (mjlucas at eng.uts.edu.au).
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * The following license applies to this file only:
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * Permission is hereby granted, free of charge, to any person
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * obtaining a copy of this software and associated documentation
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * files (the "Software"), to deal in the Software without
dfd576109cb676448a2c4574150060aa3d8626bavboxsync * restriction, including without limitation the rights to use,
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * copy, modify, merge, publish, distribute, sublicense, and/or
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * sell copies of the Software, and to permit persons to whom the
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * Software is furnished to do so, subject to the following conditions:
8bf8c6b1914c9e7e60b1547888400668f1774497vboxsync * The above copyright notice and this permission notice shall be
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * included in all copies or substantial portions of the Software.
8bf8c6b1914c9e7e60b1547888400668f1774497vboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync * OTHER DEALINGS IN THE SOFTWARE.
8bf8c6b1914c9e7e60b1547888400668f1774497vboxsyncrequire_once('./vboxServiceWrappers.php");
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync//Connect to webservice
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync$connection = new SoapClient("vboxwebService.wsdl", array('location" => "http://localhost:18083/"));
8bf8c6b1914c9e7e60b1547888400668f1774497vboxsync//Logon to webservice
a155a6f42e0cacc4b1586c8616c1fe35b8c6a326vboxsync$websessionManager = new IWebsessionManager($connection);
a155a6f42e0cacc4b1586c8616c1fe35b8c6a326vboxsync// Dummy username and password (change to appropriate values or set authentication method to null)
a155a6f42e0cacc4b1586c8616c1fe35b8c6a326vboxsync$virtualbox = $websessionManager->logon("username","password");
c0943c2324862691f6ed6b998fd3c3ad717bdd60vboxsync//Get a list of registered machines
8d8dfc00d014a62894327907a04f148b00a08529vboxsync//Take a screenshot of the first vm we find that is running
dfd576109cb676448a2c4574150060aa3d8626bavboxsync $session = $websessionManager->getSessionObject($virtualbox->handle);
dfd576109cb676448a2c4574150060aa3d8626bavboxsync list($screenWidth, $screenHeight, $screenBpp, $screenX, $screenY) = $display->getScreenResolution(0 /* First screen */);
dfd576109cb676448a2c4574150060aa3d8626bavboxsync $imageraw = $display->takeScreenShotToArray(0 /* First screen */, $screenWidth, $screenHeight, "RGBA");
dfd576109cb676448a2c4574150060aa3d8626bavboxsync echo "Screenshot size: " . sizeof($imageraw) . "\n";
dfd576109cb676448a2c4574150060aa3d8626bavboxsync echo "Saving screenshot of " . $machine->name . " (${screenWidth}x${screenHeight}, ${screenBpp}BPP) to $filename\n";
dfd576109cb676448a2c4574150060aa3d8626bavboxsync $image = imagecreatetruecolor($screenWidth, $screenHeight);
dfd576109cb676448a2c4574150060aa3d8626bavboxsync for ($height = 0; $height < $screenHeight; $height++)
59f99041108ab0a796cad9f56c910b53da4ac86cvboxsync //$alpha = $image[$start+3];