gd함수로 링크 생성후 링크접속 문의드립니다.
- 0
-
0
일단 구현하려는 코드는, gd 라이브러리로 링크 이미지를 생성후,
html 코드
<img src="linkimage.php" />
-----------------------------
php 코드
<?php
if(isset($_SERVER['HTTP_REFERER'])) {
header("Content-type: image/png");
// header('Location: http://www.example.com/');
// Set some important CAPTCHA constants
define('CAPTCHA_NUMCHARS', 6); // number of characters in pass-phrase
define('CAPTCHA_WIDTH', 200); // width of image
define('CAPTCHA_HEIGHT', 16); // height of image
// $link = $_GET['link'];
$link = "http://www.example.com/";
// Create the image
$img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
// Set a white background with black text and gray graphics
$bg_color = imagecolorallocate($img, 255, 255, 255); // white
$text_color = imagecolorallocate($img, 0, 0, 204); // blue
// Fill the background
imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);
// Draw the pass-phrase string
imagettftext($img, 10, 0, 0, CAPTCHA_HEIGHT - 5, $text_color, 'gulim.ttc', $link);
// Output the image as a PNG using a header
imagepng($img);
// Clean up
imagedestroy($img);
}
else{
header('Location: http://www.example.com/');
}
?>
이미지를 클릭시 링크로 연결되는 소스인데요..
리퍼러를 전달하여 처리하려는데 제가 잘못짚은거같네요..
고수분들 도움좀 부탁드립니다.
- <?php
- header("Content-type: image/png");
- define('CAPTCHA_NUMCHARS', 6); // number of characters in pass-phrase
- define('CAPTCHA_WIDTH', 200); // width of image
- define('CAPTCHA_HEIGHT', 16); // height of image
- $link = "http://www.example.com/";
- $img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT);
- $bg_color = imagecolorallocate($img, 255, 255, 255); // white
- $text_color = imagecolorallocate($img, 0, 0, 204); // blue
- imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color);
- imagettftext($img, 10, 0, 0, CAPTCHA_HEIGHT - 5, $text_color, 'gulim.ttf', $link);
- imagepng($img);
- imagedestroy($img);
- ?>
- PHP Warning: imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Could not find/open font in
위가 에러 메세지네..
font 파일을 찾거나 오픈할 수 없다고 합니다.
imagettftext 함수 중 'gulim.ttc' -> 'gulim.ttf' 로 수정해보세요
오타인듯 합니다.
답변 작성
질문에 적합한 답변을 상세히 작성해 주시기 바랍니다.
답변이 찬성되면 태그평판 +2점이 적립, 반대되면 태그평판 -1점 차감됩니다.
답변이 채택되면 태그평판 +10점이 적립됩니다.