Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: Biblioteka GD
Forum PHP.pl > Forum > Przedszkole
eoor
Witam, ten oto skrypt na php pod win z obsluga GD chodzi wysmienicie.

Kod
GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with TTF library
JPG Support enabled
PNG Support enabled
WBMP Support enabled


Problem jest gdy wrzuce go na serwer rowniez z GD
Kod
GD Support  enabled  
GD Version  2.0 or higher  
FreeType Support  enabled  
FreeType Linkage  with freetype  
T1Lib Support  enabled  
GIF Read Support  enabled  
GIF Create Support  enabled  
JPG Support  enabled  
PNG Support  enabled  
WBMP Support  enabled  


I szukam przyczyny dlaczgo pod windows obraz wyswietla sie, natomiast na serwerze nie. Czy w wersji 2.0 ktora jest na serwerze sa nieaktualne niektore funkcje z tego skryptu ?
  1. <?php 
  2. // Image should expire immediately 
  3. header('Content-type:image/png'); 
  4.  
  5.  
  6. // Gather request id from querystring 
  7. $request_id = isset($_GET['rid']) ? $_GET['rid'] : &#092;"0\"; 
  8. if (strlen($request_id)!=45) $error_msg= 'Niepoprawny numer ID'; 
  9.  
  10. // Connect database and get the number to be displayed 
  11. $db_conn = @mysql_connect('localhost', 'user', 'pass') or die('Brak polaczenia z baza danych'); 
  12. @mysql_select_db(&#092;"michal\");
  13.  
  14. //Construct SQL 
  15. $sql = &#092;"SELECT auth_code FROM auth_code WHERE request_id='$request_id'\";
  16. $tmp_rs = @mysql_query($sql, $db_conn) or die('Blad zapytania:'.mysql_error()); 
  17.  
  18. // Really got such request id or someone having fun? 
  19. if (mysql_num_rows($tmp_rs)==0) { 
  20. $error_msg='Nie znaleziono takiego ID'; 
  21. } else { 
  22. $number = mysql_result($tmp_rs, 0, 0); 
  23. } 
  24.  
  25. // Variables 
  26. ////////////////////////////////////////////////////////////////////////// 
  27. $x = 100;  // Image width 
  28. $y = 30;  // Image height 
  29. $freq=20; // Number of noise dots 
  30. $noise_method=&#092;"line\"; // line | dots | rectangle 
  31. $font_selection = &#092;"random\"; // random | fixed 
  32. $font_folder = &#092;"\"; // Path to fonts folder 
  33. $default_font = 4; // Array index of default font in $fonts array. 
  34. $angle_selection = &#092;"random\"; // random | fixed 
  35. $max_angle = 10; // Max angle 
  36. $default_angle = 0; // Default angle. 
  37. $font_size = 27; // Font size in points 
  38. ////////////////////////////////////////////////////////////////////////// 
  39.  
  40. // Set font 
  41.  
  42. $font = &#092;"arial.ttf\"; 
  43.  
  44.  
  45. // Set Text Angle 
  46. if ($angle_selection==&#092;"random\") { 
  47. $angle = rand((-1)*($max_angle/2), ($max_angle/2)); 
  48. } else { 
  49. $angle = $default_angle; 
  50. } 
  51.  
  52. // Create image with specified size. 
  53. $img = @ImageCreate($x, $y) or die(&#092;"Nie mozna utworzyc obrazu\"); 
  54.  
  55. // Allocate colors 
  56. $black = ImageColorAllocate($img, 0, 0, 0); 
  57. $white = ImageColorAllocate($img, 255, 255, 255); 
  58. /* Get background , noise and font color randomly from get_random_colors() function. This function returns contrary colors for readability.*/ 
  59. function get_random_colors() { 
  60. // $bck = array of background (R,G,B) values 
  61. // $dot = array of noise (R,G,B) values 
  62. // $txt = array of text (R,G,B) values 
  63.  
  64. $bck=array(); $dot=array(); $txt=array(); 
  65. // i=O =>Red | i=1 =>Green | i=2 =>Blue 
  66. for ($i=0; $i<3; $i++) { 
  67. $x = rand(0,132); 
  68. $y = rand(191,255); 
  69. array_push($bck, $x); 
  70. array_push($dot, (255-$x)); 
  71. array_push($txt, $y); 
  72. } 
  73. // Return array of 3 arrays : [0..2, 0..2] 
  74. return array($bck, $dot, $txt); 
  75. } 
  76.  
  77. $rnd_col = get_random_colors(); 
  78. $background = ImageColorAllocate($img, $rnd_col[0][0], $rnd_col[0][1], $rnd_col[0][2]); 
  79. $dots_color = ImageColorAllocate($img, $rnd_col[1][0], $rnd_col[1][1], $rnd_col[1][2]); 
  80. $text_color = ImageColorAllocate($img, $rnd_col[2][0], $rnd_col[2][1], $rnd_col[2][2]); 
  81.  
  82. // Stop execution if any error occured before 
  83. if (isset($error_msg)) { 
  84. //Fill image background with white 
  85. ImageFill ($img, 100, 50, $white); 
  86. //Display error 
  87. ImageString($img, 2, 20, 10, $error_msg, $black); 
  88. } else { 
  89. //Fill image with background color 
  90. ImageFill ($img, 100, 50, $background); 
  91. // Add centered text 
  92. $arr=ImageTtfbBox($font_size, $angle, $font, $number); 
  93.  
  94.  
  95. $text_x= round(($x-(abs($arr[2]-$arr[0]))) / 2, 0); 
  96. $text_y= round(($y-(abs($arr[5]-$arr[3]))) / 2, 0); 
  97. ImageTTFText($img, $font_size, $angle, $text_x, $text_y - $arr[5], $text_color, $font, $number); 
  98.  
  99. $i=0; //<---------Noise Counter 
  100.  
  101. // Add Noise Points 
  102. while ($i < $freq) { 
  103. $dotX = rand(0, $x); $dotY = rand(0, $y); 
  104. switch ($noise_method) { 
  105. case &#092;"line\": 
  106. $line_width = rand(4,20); 
  107. if (rand(0,10)>=5) { 
  108. // Draw horizontal line 
  109. ImageLine($img, $dotX, $dotY, $dotX+$line_width, $dotY, $dots_color); 
  110. } else { 
  111. // Draw vertical line 
  112. ImageLine($img, $dotX, $dotY, $dotX, $dotY+$line_width, $dots_color); 
  113. } 
  114. break; 
  115. case &#092;"dots\": 
  116. ImageSetPixel($img, $dotX, $dotY, $dots_color); 
  117. break; 
  118. case &#092;"rectangle\": 
  119. ImageRectangle($img, $dotX-1, $dotY-1, $dotX+1, $dotY+1, $dots_color); 
  120. break; 
  121. } 
  122. $i++; 
  123. } 
  124. } 
  125.  
  126. //Finalize the image. Free memory 
  127. ImagePNG($img);
  128. ImageDestroy($img); 
  129. ?>
Spirit86
dodaj error_reporting(E_ALL) na pocz±tku i siê przekonasz
vala
a ob_start()?
bo jak sie tym bawilem i mialem cos przed tym skryptem jakis glupi kod/html czy cus
to wyskakuje ze nie moze wyslac headerka
Spirit86
albo tworzysz obrazek, albo wysy³asz tre¶æ do skryptu, zdecyduj siê.
Zrób jeden plik html
i jeden php (generuje obrazek)
eoor
znaczy zamieszalem troszeczkze: obraz sie wyswietla, ale nie napis. Oczywiscie czcionke mam wrzucona...no chyba ze nie moze byc to windowsowy *.ttf...
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.