
08-28-2006, 01:47 AM
|
 | |
|
|
Join Date: Jul 2006
Age: 20
Rep Power: 20
|
|
found this in another forum
Quote:
|
Originally Posted by R4000
Grab yourself a copy of IECapt...
Then use this little script.
http://iecapt.sourceforge.net/
PHP Code:
<?php
/**
* IECapt - PHP Frontend.
* -
* IECapt is a small application designed for screengrabbing websites
* Using the Internet Explorer rendering engine.
* -
* This frontend is designed to allow people to enter URLs online
* and be thrown a screenshot (resized to required dimensions) back
* -
* This code is COPYRIGHT (c) 2006, Peter Corcoran. ALL RIGHTS RESERVED.
* ANY UNLICENSED USAGE WILL BE PUNISHED TO THE FULL EXTENT OF THE LAW.
**/
?>
<html>
<head>
<title>IECapt - Frontend</title>
<style>
* {
font-family: verdana;
font-size: 10px;
}
</style>
</head>
<body>
<?php
/**
* Okay, we will certainly go over the 30 second time limit.
* So we need to get rid of it. UNLIMITED TIME!!! :P
**/
set_time_limit(0);
/**
* If we had a URL posted...
**/
if($_POST['url']) {
/**
* This URL is going to end up in the shell.
* So we need to make it safe!
**/
$f = escapeshellcmd($_POST['url']);
/**
* Notify the user that we are working on creating the thumbnail
**/
echo " Attempting to create thumb... Please wait<br />\n";
/**
* Flush the output buffer.
* -> This is for stupid browsers that won't display text till 100% loaded
**/
flush();
/**
* Lets start creating that thumbnail
* -> This step takes a LONG time.
**/
shell_exec("IECapt.exe \"" . $f . "\" " . md5($f) . ".png");
/**
* Okay, the max width was sent to us via _POST
* and the max height doesn't exist, so make it big.
**/
$maxw = (int)$_POST['maxw'];
$maxh = 10000;
/**
* We need to resize what the IECapt generated now...
* -> So lets load it!
**/
$im = imagecreatefrompng(md5($f) . ".png");
/**
* Lets find out how big the image, that IECapt got, is...
**/
$w = ImageSX($im);
$h = ImageSY($im);
/**
* Now resize that baby!
* -> Thank you Alex Poole :)
**/
list($image) = resizeImage($im, $w, $h, $maxw, $maxh);
/**
* Resized... lets throw it back where it came from.
**/
imagepng($image, md5($f) . ".png");
/**
* And let the user know we have finished.
**/
echo " Created!<br /><img src=\"" . md5($f) . ".png\" />\n";
/**
* End If
**/
}
/**
* Output HTML
**/
?>
<form actiom="thumb.php" method="POST">
<table>
<tr><td>URL to Thumb: </td><td><input type="text" name="url" /> </td></tr>
<tr><td>Maximum Width:</td><td><input name="maxw" value="300" /> </td></tr>
<tr><td> </td><td><input type="submit" value="ThumbIT!" /></td></tr>
</table>
</form>
</body>
</html>
<?php
/**
* resizeImage
* -
* A small function by Alex Poole for resizing images
**/
function resizeImage($image, $iw, $ih, $maxw, $maxh) {
if ($iw > $maxw || $ih > $maxh){
if ($iw>$maxw && $ih<=$maxh){
$proportion=($maxw*100)/$iw;
$neww=$maxw;
$newh=ceil(($ih*$proportion)/100);
} else if ($iw<=$maxw && $ih>$maxh){
$proportion=($maxh*100)/$ih;
$newh=$maxh;
$neww=ceil(($iw*$proportion)/100);
} else {
if ($iw/$maxw > $ih/$maxh){
$proportion=($maxw*100)/$iw;
$neww=$maxw;
$newh=ceil(($ih*$proportion)/100);
} else {
$proportion=($maxh*100)/$ih;
$newh=$maxh;
$neww=ceil(($iw*$proportion)/100);
}
}
} else {
$neww=$iw;
$newh=$ih;
}
if (function_exists("imagecreatetruecolor")){
$newImage=imagecreatetruecolor($neww, $newh);
imagecopyresampled($newImage, $image, 0,0,0,0, $neww, $newh, $iw, $ih);
} else {
$newImage=imagecreate($neww, $newh);
imagecopyresized($newImage, $image, 0,0,0,0, $neww, $newh, $iw, $ih);
}
return Array($newImage, $neww, $newh);
}
?>
|
Not sure how it works, and although it is for windows, it may be worth looking at.
I havnt read everything, but i guess the php would execute a C++ program on the server or something, i dunno, but it cannot be totally done using ONLY php.
Last edited by John; 08-28-2006 at 01:57 AM.
|