-1

Is there any way of taking screenshots of my server's desktop using PHP, so that they can be presented to my website's remote administration page?

I am running a Windows Server 2008, but would be interested in a *nix alternative aswell for future purposes.

ᴘᴀɴᴀʏɪᴏᴛɪs
  • 7,169
  • 9
  • 50
  • 81
  • 2
    *nix doesn't usually make a habit of running graphical environments on headless servers. – Chris Eberle Feb 11 '12 at 18:46
  • @Chris Yeah, just wanted to know though for my small red hat kde desktop, which I use as a server for personal purposes, although I don't really think it can be done without the use of an external program – ᴘᴀɴᴀʏɪᴏᴛɪs Feb 11 '12 at 18:53
  • I think you'd be better running an executable for KDE to do the screenshot, potentially using PHP to modify it afterwards if you wish. A quick web search should turn up a possible solution. (Edit: ditto for Windows too). – halfer Feb 11 '12 at 18:55

1 Answers1

5

Will only work on Windows based servers, but how about:

<?php
// capture the screen
$img = imagegrabscreen();
imagepng($img, 'screenshot.png');
?>

Or:

<?php
// Capture the browser window
$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$Browser->Fullscreen = true;
$Browser->Navigate('http://www.stackoverflow.com');

while($Browser->Busy){
  com_message_pump(4000);
}

$img = imagegrabwindow($Browserhandle, 0);
$Browser->Quit();
imagepng($img, 'screenshot.png');
?>

Searching is useful for a fast answer ;)

Website screenshots using PHP

Community
  • 1
  • 1
MrJ
  • 1,910
  • 1
  • 16
  • 29