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 ?
<?php
// Image should expire immediately
header('Content-type:image/png');
// Gather request id from querystring
$request_id = isset($_GET['rid']) ?
$_GET['rid'] : \"0\"; if (strlen($request_id)!=45
) $error_msg= 'Niepoprawny numer ID';
// Connect database and get the number to be displayed
$db_conn = @mysql_connect('localhost', 'user', 'pass') or
die('Brak polaczenia z baza danych');
//Construct SQL
$sql = \"SELECT auth_code FROM auth_code WHERE request_id='$request_id'\";
// Really got such request id or someone having fun?
$error_msg='Nie znaleziono takiego ID';
} else {
}
// Variables
//////////////////////////////////////////////////////////////////////////
$x = 100; // Image width
$y = 30; // Image height
$freq=20; // Number of noise dots
$noise_method=\"line\"; // line | dots | rectangle
$font_selection = \"random\"; // random | fixed
$font_folder = \"\"; // Path to fonts folder
$default_font = 4; // Array index of default font in $fonts array.
$angle_selection = \"random\"; // random | fixed
$max_angle = 10; // Max angle
$default_angle = 0; // Default angle.
$font_size = 27; // Font size in points
//////////////////////////////////////////////////////////////////////////
// Set font
$font = \"arial.ttf\";
// Set Text Angle
if ($angle_selection==\"random\") {
$angle = rand((-1
)*($max_angle/2
), ($max_angle/2
)); } else {
$angle = $default_angle;
}
// Create image with specified size.
$img = @ImageCreate
($x, $y) or
die(\"Nie mozna utworzyc obrazu\");
// Allocate colors
$black = ImageColorAllocate($img, 0, 0, 0);
$white = ImageColorAllocate($img, 255, 255, 255);
/* Get background , noise and font color randomly from get_random_colors() function. This function returns contrary colors for readability.*/
function get_random_colors() {
// $bck = array of background (R,G,B) values
// $dot = array of noise (R,G,B) values
// $txt = array of text (R,G,B) values
// i=O =>Red | i=1 =>Green | i=2 =>Blue
for ($i=0; $i<3; $i++) {
}
// Return array of 3 arrays : [0..2, 0..2]
return array($bck, $dot, $txt); }
$rnd_col = get_random_colors();
$background = ImageColorAllocate($img, $rnd_col[0][0], $rnd_col[0][1], $rnd_col[0][2]);
$dots_color = ImageColorAllocate($img, $rnd_col[1][0], $rnd_col[1][1], $rnd_col[1][2]);
$text_color = ImageColorAllocate($img, $rnd_col[2][0], $rnd_col[2][1], $rnd_col[2][2]);
// Stop execution if any error occured before
//Fill image background with white
ImageFill ($img, 100, 50, $white);
//Display error
ImageString($img, 2, 20, 10, $error_msg, $black);
} else {
//Fill image with background color
ImageFill ($img, 100, 50, $background);
// Add centered text
$arr=ImageTtfbBox($font_size, $angle, $font, $number);
$text_x= round(($x-(abs($arr[2
]-$arr[0
]))) / 2
, 0
); $text_y= round(($y-(abs($arr[5
]-$arr[3
]))) / 2
, 0
); ImageTTFText($img, $font_size, $angle, $text_x, $text_y - $arr[5], $text_color, $font, $number);
$i=0; //<---------Noise Counter
// Add Noise Points
while ($i < $freq) {
$dotX = rand(0
, $x); $dotY = rand(0
, $y); switch ($noise_method) {
case \"line\":
$line_width = rand(4
,20
); // Draw horizontal line
ImageLine($img, $dotX, $dotY, $dotX+$line_width, $dotY, $dots_color);
} else {
// Draw vertical line
ImageLine($img, $dotX, $dotY, $dotX, $dotY+$line_width, $dots_color);
}
break;
case \"dots\":
ImageSetPixel($img, $dotX, $dotY, $dots_color);
break;
case \"rectangle\":
ImageRectangle($img, $dotX-1, $dotY-1, $dotX+1, $dotY+1, $dots_color);
break;
}
$i++;
}
}
//Finalize the image. Free memory
ImagePNG($img);
ImageDestroy($img);
?>