is it possible to take screenshots of webpages?
Posted: Sat Nov 26, 2005 5:38 pm
is it possible to take screenshots of webpages? using php only like have a site take a pic of sitea every time it loads and displays a image of sitea
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
firefox http://example.com -display localhost:0 &
import -window root -display localhost:0 myfile01.pcx /home/user/website/screenshot.png
chmod o+r /home/user/website/screenshot.pngCode: Select all
<?php
/* Define GamerTag */
if ( $_GET['gamertag'] == "" ) {
$gamertag = "No Gamertag";
} else {
$gamertag = $_GET['gamertag'];
}
/* Format Text */
$name = str_replace(" ", "%20", $gamertag);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
$name = str_replace(".card", "", $name);
/* Open file - change path to suit your needs */
$fp = fopen("http://gamercard.xbox.com/$name.card", 'r');
/* Read the card file */
while ($tmp = fread($fp, 4096)) {
$file .= $tmp;
}
/* Match nick */
preg_match('@<span class="XbcFLAL">([^<]+)</span>@', $file, $matches);
$name = $matches[1];
/* Match avatar */
preg_match('@<img class="XbcgcGamertile" height="64" width="64" src="([^"]+)" />@', $file, $matches);
$avatar1 = $matches[1];
/* Match rep */
preg_match('@<img src="([^"]+)" />@', $file, $matches);
$rep = $matches[1];
/* Match score */
preg_match('@<span class="XbcFRAR">([\d]+)</span>@', $file, $matches);
$score1 = $matches[1];
/* Match zone */
preg_match('@<span class="XbcFRAR">([^<]+)</span>@', $file, $matches);
$zone1 = $matches[1];
/* Match game titles & icons */
preg_match_all('@<img height\="32" width\="32" title\="([^"]+)" alt\="" src="(http\:\/\/tiles\.xbox\.com\/tiles\/[\w]{2}\/[\w]{2}\/[^=]+\=\.jpg)" />@', $file, $matches);
$titles = $matches[1];
$games1 = $matches[2];
/* Define Rep Image */
if($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_12.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_12.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_13.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_13.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_14.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_14.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_15.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_15.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_16.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_16.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_17.gif") {
$stars = "src= http://gamercard.xbox.com/xweb/lib/imag ... nal_17.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_18.gif") {
$stars = "= http://gamercard.xbox.com/xweb/lib/imag ... nal_18.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_19.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_19.gif";
} elseif($rep=="http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_20.gif") {
$stars = "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_20.gif";
} else {
$stars = "";
/* Define BackGround */
$im = imagecreatefromgif("bg.gif");
/* Font Info */
$text = imagecolorallocate($im, 246, 246, 246);
$black = imagecolorallocate($im, 0, 0, 0);
$font = "X360.ttf"
/* Define Avatar */
$avatar1 = str_replace(".png", "", $avatar1)
$avatar1 = str_replace(".jpg", "", $avatar1);
$avatar1 = str_replace(".gif", "", $avatar1);
$avatar = imagecreatefromgif("$avatar1.jpg");
/* Define Gamerscore */
$score = "$score1";
/* Define Rep */
$stars = str_replace(".png", "", $stars);
$stars = str_replace(".jpg", "", $stars);
$stars = str_replace(".gif", "", $stars);
$rep = imagecreatefromgif("$stars.gif");
/* Define Games */
$games = "<img src= $games1>";
/* Define Zone */
$zone = "$zone1";
/* Define Text */
$zonetxt = "Zone";
$reptxt = "Rep";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*Imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)*/
Imagettftext($im, 1,0,3,3,$text,'$font',$zonetxt);
?>