\n "; echo($insertstr); } //Define function to check security image confirmation function checkSecurityImage($referenceid, $enteredvalue) { $referenceid = mysql_escape_string($referenceid); $enteredvalue = mysql_escape_string($enteredvalue); $tempQuery = mysql_query("SELECT ID FROM security_images WHERE referenceid='".$referenceid."' AND hiddentext='".$enteredvalue."'"); if (mysql_num_rows($tempQuery)!=0) { return true; } else { return false; } ?> Signup Demo Raka Yusuf: Pemrograman Berbasis Web 2 (Modul 12) #3/7"> \n "; echo($insertstr); } //Define function to check security image confirmation function checkSecurityImage($referenceid, $enteredvalue) { $referenceid = mysql_escape_string($referenceid); $enteredvalue = mysql_escape_string($enteredvalue); $tempQuery = mysql_query("SELECT ID FROM security_images WHERE referenceid='".$referenceid."' AND hiddentext='".$enteredvalue."'"); if (mysql_num_rows($tempQuery)!=0) { return true; } else { return false; } ?> Signup Demo Raka Yusuf: Pemrograman Berbasis Web 2 (Modul 12) #3/7">

Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

(SECURITY CODE – CAPTCHA)

Presentasi serupa


Presentasi berjudul: "(SECURITY CODE – CAPTCHA)"— Transcript presentasi:

1 (SECURITY CODE – CAPTCHA)
MODUL 12 SECURITY IMAGE (SECURITY CODE – CAPTCHA) Apa itu security image/ security code? Security image adalah suatu bentuk perlindungan terhadap suatu form dari serangan SPAM. Sebagai contoh, pada pengisian formulir pendaftaran untuk mendapatkan account di Yahoo. Pada bagian bawah di atas tombol submit, terdapat security code yang muncul dan anda harus mengisi security code tesebut. Cara kerja dari security code tersebut sebagai berikut: Pertama: Formulir akan menampilkan security code yang di generate oleh script PHP, apabila page tersebut di refresh maka security code akan di generate lagi sehingga berubah codenya. Hal ini sangat berguna sekali untuk menangkal serangan spam. Lihat Gambar 12.1 Gambar Contoh security image. Kedua: Raka Yusuf: Pemrograman Berbasis Web 2 (Modul 12) #1/7

2 } http://www.mercubuana.ac.id `ID` int(11) NOT NULL auto_increment,
`insertdate` datetime NOT NULL default ' :00:00', `referenceid` varchar(100) NOT NULL default '', `hiddentext` varchar(100) NOT NULL default '', PRIMARY KEY (`ID`) ) TYPE=MyISAM; Latihan singup.php <?php //Define function to insert security image function insertSecurityImage($inputname) { $refid = md5(mktime()*rand()); $insertstr = "<img src=\"securityimage.php?refid=".$refid."\" alt=\"Security Image\">\n <input type=\"hidden\" name=\"".$inputname."\" value=\"".$refid."\">"; echo($insertstr); } //Define function to check security image confirmation function checkSecurityImage($referenceid, $enteredvalue) { $referenceid = mysql_escape_string($referenceid); $enteredvalue = mysql_escape_string($enteredvalue); $tempQuery = mysql_query("SELECT ID FROM security_images WHERE referenceid='".$referenceid."' AND hiddentext='".$enteredvalue."'"); if (mysql_num_rows($tempQuery)!=0) { return true; } else { return false; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso "> <title>Signup Demo</title> Raka Yusuf: Pemrograman Berbasis Web 2 (Modul 12) #3/7

3 http://www.mercubuana.ac.id Enter what you see:
<input name="security_try" type="text" id="security_try" size="20" maxlength="10"> (can't see? try reloading page) <br><br> <input type="submit" name="Submit" value="Signup!"> </body> </html> Latihan 3. – securityimage.php <?php //Generate Reference ID if (isset($HTTP_GET_VARS["refid"]) && $HTTP_GET_VARS["refid"]!="") { $referenceid = stripslashes($HTTP_GET_VARS["refid"]); } else { $referenceid = md5(mktime()*rand()); } //Select Font $font = "trebuc.ttf"; //Select random background image $bgurl = rand(1, 3); $im = ImageCreateFromPNG("images/bg".$bgurl.".png"); //Generate the random string $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g", "G","h","H","i","I","j","J","k", "K","l","L","m","M","n","N","o","O","p","P","q","Q", "r","R","s","S","t","T","u","U","v", "V","w","W","x","X","y","Y","z","Z","1","2","3","4", "5","6","7","8","9"); $length = 8; $textstr = ""; for ($i=0; $i<$length; $i++) { $textstr .= $chars[rand(0, count($chars)-1)]; Raka Yusuf: Pemrograman Berbasis Web 2 (Modul 12) #5/7


Download ppt "(SECURITY CODE – CAPTCHA)"

Presentasi serupa


Iklan oleh Google