본문 바로가기

Web/PHP

게시판 글 자동 등록 방지

=== othr_img_rndm_test.php ===

<?php
session_start();
if(isset($_POST['n_txt'])) {
    if($_POST['n_txt']==$_SESSION['key'] AND $_POST['n_hddn']=='') echo "succeeded";
    else echo "failed";
    $_SESSION['key'] = NULL;
    ?>
    <input type='button' value='back' onclick="window.location.href='<?php echo $_SERVER['PHP_SELF']; ?>';" />
    <?php
} else {
    $_SESSION['key'] = rand(0,9).rand(0,9).rand(0,9).rand(0,9);
    ?>
    <img src='othr_img_rndm.php?<?php echo time(); ?>'
        style='visibility:hidden;' onload="this.style.visibility='visible';" /><br />
    <form name='n_frm' method='post' action='<?php echo $_SERVER['PHP_SELF']; ?>'>
        Insert the above characters: <input type='text' name='n_txt' />
        <input type='text' name='n_hddn' value='' style='visibility:hidden;' />
        <input type='submit' />
    </form>
    <?php
}
?>

=== othr_img_rndm_test.php ===

<?php
session_start();
header("Content-type: image/png");
$arry = array(
     '../Q_img/'.'arial' .'.ttf'
    ,'../Q_img/'.'cour' .'.ttf'
    ,'../Q_img/'.'verdana'.'.ttf'
    ,'../Q_img/'.'tahoma' .'.ttf');
$wdth = 100; $hght = 50;
$img = imagecreate($wdth,$hght);
$clr_bckgrnd = imagecolorallocate($img,150,150,150);
$clr_frgrnd = imagecolorallocate($img,0,0,0);

imagefilledrectangle($img,0,0,$wdth,$hght,$clr_bckgrnd);
imagettftext($img,rand(25,35),rand(-10,10),20,40,$clr_frgrnd,$arry[rand(0,3)],substr($_SESSION['key'],0,1));
imagettftext($img,rand(25,35),rand(-10,10),35,40,$clr_frgrnd,$arry[rand(0,3)],substr($_SESSION['key'],1,1));
imagettftext($img,rand(25,35),rand(-10,10),50,40,$clr_frgrnd,$arry[rand(0,3)],substr($_SESSION['key'],2,1));
imagettftext($img,rand(25,35),rand(-10,10),65,40,$clr_frgrnd,$arry[rand(0,3)],substr($_SESSION['key'],3,1));

imagepng($img);
imagedestroy($img);
?>


Qindex 2004-11-12 04:00 / 222.111.38.245
sample: http://www.qindex.info/Q_incld/othr_img_rndm_test.php    

'Web > PHP' 카테고리의 다른 글

XMLParser  (0) 2013.09.26
제로보드->킴스보드 파일긁어서넣기  (0) 2013.09.26
Create Js Cache File ( 캐시파일 )  (0) 2013.09.26
제로->킴스 컨버트, 변환  (0) 2013.09.26
xml_parser  (0) 2013.09.26