<?php
session_start();
  function make_seed() { 
	   list($usec, $sec) = explode(' ', microtime()); 
	   return (float) $sec + ((float) $usec * 100000); 
  } 
  srand(make_seed()); 
  $string = strtoupper(substr(md5(rand(0,9999)),1,6)); 
  $_SESSION['captcha_code'] = md5($string);
  $w = 120;
  $h = 30;
  $im = imagecreate($w, $h); 
  $bg = imagecolorallocate($im, 255, 255, 180);
  $textcolor = imagecolorallocate($im, 153, 153, 153);
  imagettftext($im, 22, 0, 8, 24, $textcolor, "Fonts/courbd.ttf", $string);
  for ($i=0;$i<=$w;$i+=10) {
	  if ($i==$w) $i--;
	  imageline($im,$i,0,$i,$h,$textcolor);   
  }	
  for ($i=0;$i<=$h;$i+=10) {
  	  if ($i==$h) $i--;
	  imageline($im,0,$i,$w,$i,$textcolor);   
  }	  
  srand(make_seed()); 
  $file = md5(rand(0,9999));    
  imagepng($im);
  //imagedestroy($im);

 /* if ($fp = fopen("/tmp/uses_signup_varify_list.tsv","a")) {
  	  $timestamp = time();
	  fwrite($fp,"$timestamp\t$string\t$file\n");
	  fclose($fp);*/
	  //print "document.write(\"<img src='../temp_security/$file.png' border='0'>\");\n";
	  //print "document.write(\"<img src='http://www.memorialfund.com.com/verify/temp/$file.png' border='0'>\");\n";
	 // print "<img src='temp_security/$file.png' border='0'>\n";
	 // print "<input type='hidden' name='verify_code' value='" . md5($string) . "'>";
	  //print "document.write(\"<input type='hidden' name='verify_code' value='" . md5($string) . "'>\");\n";
 // } else print "alert('Sorry, Could not create verify code.\nPlease try again.');\n";
?> 