Skip to content

Instantly share code, notes, and snippets.

@Momijinn
Created August 26, 2015 06:21
Show Gist options
  • Save Momijinn/4c75e024ea55eab2e175 to your computer and use it in GitHub Desktop.
Save Momijinn/4c75e024ea55eab2e175 to your computer and use it in GitHub Desktop.
アクセスしてきた人のIPアドレスなどを取得してjpegに書き込む
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$ag = $_SERVER['HTTP_USER_AGENT'];
$rh = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$dt = date("Y/m/d H:i:s");
$gz = imagecreatetruecolor(1100, 180);
$col = imagecolorallocate($gz, 255, 0, 0);
//jpegに文字を書き込み
imagestring($gz, 8, 20, 30, "=Your_Address=", $col);
imagestring($gz, 8, 20, 50, $dt, $col);
imagestring($gz, 8, 20, 70, "IP_Address: ".$ip, $col);
imagestring($gz, 8, 20, 90, "USER_AGENT:", $col);
imagestring($gz, 8, 40, 110, $ag, $col);
imagestring($gz, 8, 20, 130, "REMOTE_HOST: ".$rh, $col);
//jpegの作成
imagejpeg($gz, "Your_Address.jpg");
//jpegメモリの開放
imagedestroy($gz);
//jpegの表示
print "<IMG SRC='Your_Address.jpg'>";
?>
@Momijinn
Copy link
Author

phpでアクセスしてきた人のIPアドレス、利用しているブラウザ情報などを読み込みJPEGにして表示するプログラムをつくりました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment