Advertisement
Kwarde

PHP Image - Custom user text

Oct 11th, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. <?php
  2.  
  3.     if(!isset($_GET['t']) || empty($_GET['t'])) $text = "No input given";
  4.     elseif($_GET['t'] == "_IP_") $text = $_SERVER['REMOTE_ADDR'];
  5.     elseif(substr($_GET['t'], 0, 9) == "_IPSTART_") $text = $_SERVER['REMOTE_ADDR'] . substr($_GET['t'], 9);
  6.     elseif(substr($_GET['t'], 0, 7) == "_IPEND_") $text = substr($_GET['t'], 7) . $_SERVER['REMOTE_ADDR'];
  7.     elseif($_GET['t'] == "_JOINSERVER_") $text = "Come join us: " . $_SERVER['REMOTE_ADDR'] . ":7777";
  8.     else $text = $_GET['t'];
  9.     if($_GET['c'] && !empty($_GET['c']))
  10.     {
  11.         $c = $_GET['c'];
  12.         $activate_c = true;
  13.     }
  14.     if($_GET['b'] && !empty($_GET['b']))
  15.     {
  16.         $b = $_GET['b'];
  17.         $activate_b = true;
  18.     }
  19.    
  20.     $image = imagecreate((strlen($text) * 7) + 5, 20);
  21.     if($b >= 0 && $b <= 8 && $activate_b)
  22.     {
  23.         if($b == 0) $bgcol = imagecolorallocate($image, 255, 255, 255);
  24.         elseif($b == 1) $bgcol = imagecolorallocate($image, 255, 0, 0);
  25.         elseif($b == 2) $bgcol = imagecolorallocate($image, 0, 255, 0);
  26.         elseif($b == 3) $bgcol = imagecolorallocate($image, 0, 0, 255);
  27.         elseif($b == 4) $bgcol = imagecolorallocate($image, 100, 100, 255);
  28.         elseif($b == 5) $bgcol = imagecolorallocate($image, 175, 175, 175);
  29.         elseif($b == 6) $bgcol = imagecolorallocate($image, 255, 255, 0);
  30.         elseif($b == 7) $bgcol = imagecolorallocate($image, 0, 255, 255);
  31.         elseif($b == 8) $bgcol = imagecolorallocate($image, 0, 0, 0);
  32.     }
  33.     else $bgcol = imagecolorallocate($image, 0, 0, 0);
  34.     if(!isset($_GET['t']) || empty($_GET['t'])) $txcol = imagecolorallocate($image, 255, 0, 0);
  35.     if($c >= 0 && $c <= 8 && $activate_c)
  36.     {
  37.         if($c == 0) $txcol = imagecolorallocate($image, 255, 255, 255);
  38.         elseif($c == 1) $txcol = imagecolorallocate($image, 255, 0, 0);
  39.         elseif($c == 2) $txcol = imagecolorallocate($image, 0, 255, 0);
  40.         elseif($c == 3) $txcol = imagecolorallocate($image, 0, 0, 255);
  41.         elseif($c == 4) $txcol = imagecolorallocate($image, 100, 100, 255);
  42.         elseif($c == 5) $txcol = imagecolorallocate($image, 175, 175, 175);
  43.         elseif($c == 6) $txcol = imagecolorallocate($image, 255, 255, 0);
  44.         elseif($c == 7) $txcol = imagecolorallocate($image, 0, 255, 255);
  45.         elseif($c == 8) $txcol = imagecolorallocate($image, 0, 0, 0);
  46.     }
  47.     else $txcol = imagecolorallocate($image, 255, 255, 255);
  48.     imagestring($image, 3, 3, 4, $text, $txcol);
  49.     imagesetthickness($image, 5);
  50.     header("content-type: image/png");
  51.     imagepng($image);
  52.     imagecolordeallocate($txcol);
  53.     imagecolordeallocate($bgcol);
  54.     imagedestroy($image);
  55. ?>
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement