[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_handlers/ -> secure_img_render.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     �Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_handlers/secure_img_render.php,v $
  14  |     $Revision: 1.16 $
  15  |     $Date: 2006/11/20 11:48:44 $
  16  |     $Author: mrpete $
  17  +----------------------------------------------------------------------------+
  18  */
  19  
  20  while (@ob_end_clean());
  21  
  22  function e107_ini_set($var, $value){
  23      if (function_exists('ini_set')){
  24          ini_set($var, $value);
  25      }
  26  }
  27  
  28  // setup some php options
  29  e107_ini_set('magic_quotes_runtime',     0);
  30  e107_ini_set('magic_quotes_sybase',      0);
  31  e107_ini_set('arg_separator.output',     '&amp;');
  32  e107_ini_set('session.use_only_cookies', 1);
  33  e107_ini_set('session.use_trans_sid',    0);
  34  
  35  while (list($global) = each($GLOBALS)) {
  36      if (!preg_match('/^(_SERVER|GLOBALS)$/', $global)) {
  37          unset($$global);
  38      }
  39  }
  40  
  41  unset($global);
  42  
  43  $imgtypes = array("jpeg", "png", "gif");
  44  
  45  define("e_QUERY", preg_replace("#&|/?PHPSESSID.*#i", "", $_SERVER['QUERY_STRING']));
  46  
  47  $recnum = preg_replace("#\D#","",e_QUERY);
  48  
  49  if($recnum == false){
  50      exit;
  51  }
  52  
  53  $mySQLserver = "";
  54  
  55  @include_once(dirname(__FILE__)."e107_config.php");
  56  
  57  $a = 0;
  58  $p = "";
  59  
  60  while(!$mySQLserver && $a < 5){
  61      $a ++;
  62      $p .= "../";
  63      @include_once ($p."e107_config.php");
  64  }
  65  
  66  mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword);
  67  mysql_select_db($mySQLdefaultdb);
  68  
  69  $result = mysql_query("SELECT tmp_info FROM {$mySQLprefix}tmp WHERE tmp_ip = '{$recnum}'");
  70  if(!$row = mysql_fetch_array($result)) {
  71      exit;
  72  }
  73  
  74  list($code, $url) = explode(",",$row['tmp_info']);
  75  
  76  $type = "none";
  77  
  78  foreach($imgtypes as $t) {
  79      if(function_exists("imagecreatefrom".$t)) {
  80          $type = $t;
  81          break;
  82      }
  83  }
  84  
  85  $path = realpath(dirname(__FILE__)."/../")."/".$IMAGES_DIRECTORY;
  86  
  87  if(is_readable($path."secure_image_custom.php")) {
  88      require_once($path."secure_image_custom.php");
  89      /*   Example secure_image_custom.php file:
  90  
  91      $secureimg['image'] = "code_bg_custom";  // filename excluding the .ext
  92      $secureimg['size']    = "15";
  93      $secureimg['angle']    = "0";
  94      $secureimg['x']        = "6";
  95      $secureimg['y']        = "22";
  96      $secureimg['font']     = "imagecode.ttf";
  97      $secureimg['color'] = array(90,90,90); // red,green,blue
  98  
  99      */
 100      $bg_file = $secureimg['image'];
 101  } else {
 102      $bg_file = "generic/code_bg";
 103  }
 104  
 105  switch($type) {
 106      case "jpeg":
 107          $image = ImageCreateFromJPEG($path.$bg_file.".jpg");
 108          break;
 109      case "png":
 110          $image = ImageCreateFromPNG($path.$bg_file.".png");
 111          break;
 112      case "gif":
 113          $image = ImageCreateFromGIF($path.$bg_file.".gif");
 114          break;
 115  }
 116  
 117  if(isset($secureimg['color'])) {
 118      $tmp = explode(",",$secureimg['color']);
 119      $text_color = ImageColorAllocate($image,$tmp[0],$tmp[1],$tmp[2]);
 120  } else {
 121      $text_color = ImageColorAllocate($image, 90, 90, 90);
 122  }
 123  
 124  header("Content-type: image/{$type}");
 125  
 126  if(isset($secureimg['font']) && is_readable($path.$secureimg['font'])){
 127      imagettftext($image, $secureimg['size'],$secureimg['angle'], $secureimg['x'], $secureimg['y'], $text_color,$path.$secureimg['font'], $code);
 128  } else {
 129      imagestring ($image, 5, 12, 2, $code, $text_color);
 130  }
 131  
 132  switch($type) {
 133      case "jpeg":
 134          imagejpeg($image);
 135          break;
 136      case "png":
 137          imagepng($image);
 138          break;
 139      case "gif":
 140          imagegif($image);
 141          break;
 142  }
 143  
 144  imagedestroy($image);
 145  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7