php: Showing client information in PNG file

Forum for anything hard- or software related.

Moderator: Moderators

Post Reply
Deimos

php: Showing client information in PNG file

Post by Deimos »

php: This script creates an easy .png file of the clients information. The way it's scripted now, you should include it as an image.



If you call it php2png.php

Example: <img src="php2png.php" />



[php]<?php



//This script is copyrighted by Deimos.

//For questions mail deimos@aq2world.net



//Take a look at http://www.aq2world.net





header ("Content-type: image/png");



$UserAgent = $_SERVER['HTTP_USER_AGENT'];



$Platform = "This platform is not recognized";



if(strstr($UserAgent, 'Win')){

$Platform = 'Windows';

}else if(strstr($UserAgent, 'Mac')){

$Platform = 'Macintosh';

}else if(strstr($UserAgent, 'Linux')){

$Platform = 'Linux';

}else if(strstr($UserAgent, 'Unix')){

$Platform='Unix';

}



if(preg_match("/Opera ([0-9]\.[0-9]{0,2})/i", $UserAgent, $found) && strstr($UserAgent, "MSIE")){

$Browser = "Opera " . $found[1];

}else if(preg_match("/Opera ([0-9]\.[0-9]{0,2})/i", $UserAgent, $found) && strstr($UserAgent, "Mozilla")){

$Browser = "Opera " . $found[1];

}else if(preg_match("/Opera\/([0-9]\.[0-9]{0,2})/i", $UserAgent, $found)){

$Browser = "Opera " . $found[1];

}else if(preg_match("/Netscape[0-9]\/([0-9]{1,2}\.[0-9]{1,2})/i", $UserAgent, $found)){

$Browser = "Netscape " . $found[1];

}else if(preg_match("/Mozilla\/([0-9]{1}\.[0-9]{1,2}) \[en\]/i", $UserAgent, $found)){

$Browser = "Netscape " . $found[1];

}else if(preg_match("/MSIE ([0-9]{1,2})/i", $UserAgent, $found)){

$Browser = $found[0];

}else{

$Browser = $UserAgent;

}



if($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]!=""){

$IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];

$Proxy = $HTTP_SERVER_VARS["REMOTE_ADDR"];

}else{

$IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];

}



$Host = gethostbyaddr($IP);

$s = preg_split("/\./", $Host);

$i = count($s);

$x = $i - 1;

$n = $i - 2;

$ISP = $s[$n] . "." . $s[$x];





$s1 = "Your ip is " . $IP . " and your isp " . $ISP;

$s2 = "You are using " . $Platform . " and browsing with " . $Browser;



$w = strlen($s1) >= strlen($s2) ? strlen($s1) : strlen($s2);



if($Proxy){

$s3= "Through proxy " . $Proxy;

$w = $w >= strlen($s3) ? $w : strlen($s3);

$w = $w * imagefontwidth(3) + 20;

$im = @ImageCreate($w, 80) or die ("Cannot Initialize new GD image stream");

$background_color = ImageColorAllocate ($im, 255, 255, 255);

$text_color = ImageColorAllocate ($im, 0, 0, 255);

ImageString ($im, 3, 10, 30, $s1, $text_color);

ImageString ($im, 3, ($w / 2) - ((strlen($s2) * imagefontwidth(3)) / 2), 50, $s2, $text_color);

ImageString ($im, 3, ($w / 2) - ((strlen($s3) * imagefontwidth(3)) / 2), 70, $s3, $text_color);

ImagePng ($im);

}else{

$w = $w * imagefontwidth(3) + 20;

$im = @ImageCreate ($w, 60) or die ("Cannot Initialize new GD image stream");

$background_color = ImageColorAllocate ($im, 255, 255, 255);

$text_color = ImageColorAllocate ($im, 0, 0, 255);

ImageString ($im, 3, 10, 10, $s1, $text_color);

ImageString ($im, 3, ($w / 2) - ((strlen($s2) * imagefontwidth(3)) / 2), 30, $s2, $text_color);

ImagePng ($im);

}







?>[/php]
Clown
unpossible??!?!!
Posts: 1750
Joined: Sun Jul 27, 2003 7:38 am
Location: en

Post by Clown »

Can someone do this so I can see it in action please?
I don't give a shit.
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

Parse error: parse error in /var/www/****/html/php2png.php on line 25
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Deimos

Post by Deimos »

Clown
unpossible??!?!!
Posts: 1750
Joined: Sun Jul 27, 2003 7:38 am
Location: en

Post by Clown »

I don't see the point of that :)
I don't give a shit.
Den
something dur dur
Posts: 2616
Joined: Fri Jul 25, 2003 8:56 am
Location: nl
Contact:

Post by Den »

totally agree :) altho the image creating part is always fun to look at :)
There's a chopper coming in 3 days and there's a katana on top of the cafe and that's all you need to know
Image
Post Reply