Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/croquis/classes/ctextimage.php
<?
	#########################################################################################
	# Croquis en ligne, pour réaliser la pancarte dans Pnyx									#
	# Auteur : Sébastien Tremblay, hide@address.com										#
	# 																						#
	# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour	des	élèves	#
	# du primaire et du secondaire, dans lequel ils sont amenés à faire des	propositions	#
	# en ligne et voter pour leur favorite, sous la supervision d'un enseignant.			#
	#																						#
    # Copyright (C) <2008 - 2009>															#
	# <Service national du RÉCIT de l'univers social de la Commission scolaire de la		#
	# Pointe-de-l'Île>																		#
	#																						#
	# This program is free software; you can redistribute it and/or modify it under the 	#
	# terms of the GNU General Public License as published by the Free Software Foundation.	#
	# This program is distributed in the hope that it will be useful, but WITHOUT ANY 		#
	# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 		#
	# PARTICULAR PURPOSE.  See the GNU General Public License for more details.				#
	# You should have received a copy of the GNU General Public License along with this 	#
	# program as the file LICENSE.txt; if not, please see 									#
	# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.									#
	# 																						#
	# Service national du RÉCIT de l'univers social											#
	# http://www.recitus.qc.ca																#
	# Contact e-mail : steve-hide@address.com												#
	#########################################################################################

  include_once(file_exists("constante.php")? "constante.php" : "../constante.php");

  class CTextImage
  {
      var $m_ImageFinale;

      function construct()
      {
          $this->Init();
      }

      function Init()
      {
          $TabTemp1 = array();
          $TabTemp2 = array();
          $TabTemp3 = array();

          if ((isset($_POST)) && (isset($_GET)))
              $this->m_VarFormulaire = array_merge ($_POST, $_GET);
          elseif ((isset($HTTP_POST_VARS)) && (isset($HTTP_GET_VARS)))
              $this->m_VarFormulaire = array_merge ($HTTP_POST_VARS, $HTTP_GET_VARS);
          $TabTemp1 = explode(";", $this->m_VarFormulaire["b"]);
          for ($i = 0; $i < count($TabTemp1); $i++)
          {
              $TabTemp2 = explode("=", $TabTemp1[$i]);
              $TabTemp3[$TabTemp2[0]] = $TabTemp2[1];
              $this->m_VarFormulaire = array_merge ($TabTemp3, $this->m_VarFormulaire);
          }

      }

      function Main()
      {
          $oCTextImage = new CTextImage();
          $oCTextImage->construct();
          $oCTextImage->Demarrer();
      }

      function Demarrer()
      {
          $this->m_VarFormulaire['text'] = urldecode($this->m_VarFormulaire['text']);
          $r = (hexdec(substr($this->m_VarFormulaire['c'],0,2)) < 32) ? 32 : hexdec(substr($this->m_VarFormulaire['c'],0,2));
          $g = (hexdec(substr($this->m_VarFormulaire['c'],2,2)) < 32) ? 32 : hexdec(substr($this->m_VarFormulaire['c'],2,2));
          $b = (hexdec(substr($this->m_VarFormulaire['c'],4,2)) < 32) ? 32 : hexdec(substr($this->m_VarFormulaire['c'],4,2));
          
          $t = substr($this->m_VarFormulaire['t'], 0, strlen($this->m_VarFormulaire['t'])-2);
          if ($this->m_VarFormulaire['p'] == "") $this->m_VarFormulaire['p'] = "Arial";
          $police = strtolower($this->m_VarFormulaire['p']);
          $police.= ($this->m_VarFormulaire['g'] == "bold") ? "B" : "";
          $police.= ($this->m_VarFormulaire['i'] == "italic") ? "I" : "";

          $width  = ((strlen($this->m_VarFormulaire['text']) * (6*$t/6)) < 50) ? 50 : (strlen($this->m_VarFormulaire['text']) * (6*$t/6));
          $height = $t*2+10;

          $this->m_ImageFinale = imagecreatetruecolor($width, $height);
          $trans_color = imagecolorallocate($this->m_ImageFinale, 255, 0, 0);
          $color = imagecolorallocate($this->m_ImageFinale, $r, $g, $b);
          imagecolortransparent($this->m_ImageFinale, $trans_color);
          
          $font = REP_ROOT.REP_POLICES.$police.".ttf";

          imagettftext($this->m_ImageFinale, $t, 0, 1, 20+$t, -$color, $font, $this->m_VarFormulaire['text']);

          $this->Afficher();
      }

      function Afficher()
      {
          //header("Content-Type: application/octet-stream");
          header("Content-Disposition: attachment; filename=image.gif");
          //header("Accept-Ranges: bytes");
          //header("Pragma: no-cache");
          //header("Expires: 0");
          //header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
          //header("Content-transfer-encoding: binary");
          imagegif($this->m_ImageFinale);
      }
  }
  CTextImage::Main();
?>
Return current item: Pnyx : des lections virtuelles!