Page 1 of 1
how to perform this task?
Posted: Thu Apr 22, 2004 3:41 am
by hughr
i saw some pic on there .
can show you ip ,you location.
how to use php to perform this task?
regards
Posted: Thu Apr 22, 2004 3:45 am
by feyd
combo:
imagecreate() and $_SERVER['REMOTE_ADDR']
Posted: Sat May 15, 2004 11:58 am
by erikante
You need to download JPGraph first. then save the following code and include in your page. Works for me..Hope that helps.
Code: Select all
<?
include ("../jpgraph-1.15beta/src/jpgraph.php"); //you need to include these two files
include ("../jpgraph-1.15beta/src/jpgraph_canvas.php"); //you can download jpgraph from http://www.aditus.nu/jpgraph/
function getip() {
if (isSet($_SERVER)) {
if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) {
$realip = $_SERVER["HTTP_CLIENT_IP"];
} else {
$realip = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$realip = getenv( 'HTTP_X_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$realip = getenv( 'HTTP_CLIENT_IP' );
} else {
$realip = getenv( 'REMOTE_ADDR' );
}
}
return $realip;
}
// Create the graph.
$graph = new CanvasGraph(115,72,"auto");
$ip=getip();
$t1 = new Text(" Your IP address\n $ip" );
$t1->Pos(0.05,0.15);
$t1->SetFont(FF_FONT1,FS_NORMAL);
$t1->SetBox("white","black",true);
$t1->ParagraphAlign("center");
$t1->SetColor("black");
$graph->AddText($t1);
$graph->Stroke();
?>
Posted: Sat May 15, 2004 4:32 pm
by JAM
erikante wrote:You need to download JPGraph first.
...or if you prefer using [php_man]ImageTTFText[/php_man]:
Code: Select all
<?php
$l = $_SERVER['REMOTE_ADDR'];
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Pragma: no-cache");
header("Content-type: image/png");
$img_handle = ImageCreate (500, 30) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 200, 200, 200);
ImageTTFText ($img_handle, 14 / 96 * 72, 0, 20, 18, ImageColorAllocate ($img_handle, 0, 0, 0), dirname( __FILE__ )."/verdana.ttf", $l);
ImagePng ($img_handle);
?>
Not tested, but it should work and should be tweaked to fit your desired result.