<?php
/*********************************************************************************
 * Gest'Ecole is a school management software developped by
 * DOX Conception Copyright (C) 2012-2013 DOX Conception
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the license published by DOX Conception.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY.  See the Software License for more details.
 * 
 * You should have received a copy of the software license along with
 * this program; if not, see:
 * http://www.doxconception.com/index.php/licence-de-gestecole.html
 ********************************************************************************/

  $image = @imagecreatefrompng("../images/fond_captcha.png");
  $bg = imagecolorallocate($image, 255, 255, 255);
  $textcolor = imagecolorallocate($image, 0, 0, 0);
  $code2=$_GET['code'];
  $code="";
  for ($i=1;$i<=strlen($code2);$i++)
  {
    $code=$code.substr($code2,$i-1,1)." ";
  }
  $code=substr($code,0,strlen($code)-1);
  $text_width = imagefontwidth(5)*strlen($code);
  $x = 70 - (ceil($text_width/2)); 
  imagestring($image, 5, $x, 5, $code, $textcolor);
  header('Content-type: image/png');
  imagepng($image);
  imagedestroy($image);
?>
