Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / www / html / ulungkusma_web_id / functions / captcha / | server ip : 172.67.156.115 your ip : 172.70.80.171 H O M E |
Filename | /var/www/html/ulungkusma_web_id/functions/captcha/captcha.php |
Size | 1.18 kb |
Permission | rw-rw-r-- |
Owner | ulung : ulung |
Create time | 27-Apr-2025 11:16 |
Last modified | 05-Feb-2025 12:52 |
Last accessed | 23-Jun-2025 20:25 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
session_start();
header("Content-type: image/jpg");
//generate Code
function RandomCode($max){
//Huruf dan angka yang akan di acak
$char = array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y",
"Z","a","b","c","d","e","f","g","h","j","k","l","m","n","p","q","r","s","t","u","v","w","x",
"y","z","1","2","3","4","5","6","7","8","9");
$keys = array();
while(count($keys) < $max) {
$x = mt_rand(0, count($char)-1);
if(!in_array($x, $keys)) {
$keys[] = $x;
}
}
foreach($keys as $key => $val){
$random .= $char[$val];
}
return $random;
}
$font='./font/COOPBL.TTF'; //setting font yang akan digunakan
$images='./images/mk-logo.jpg'; //gambar yang akan digunakan sebagai background
$im = imagecreatefromjpeg("$images")or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 15, 110, 1); //menentukan warna text
//Generate kode yang akan dituliskan pada gambar sebanyak 6
$text=RandomCode(6);
//Buat sessi untuk pengecekan pada halaman lain
$_SESSION['captcha']=$text;
//Tuliskan text pada gambar
imagettftext($im, 40, 0, 20, 60, $text_color, $font, $text);
imagejpeg($im);
imagedestroy($im);
?>
session_start();
header("Content-type: image/jpg");
//generate Code
function RandomCode($max){
//Huruf dan angka yang akan di acak
$char = array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y",
"Z","a","b","c","d","e","f","g","h","j","k","l","m","n","p","q","r","s","t","u","v","w","x",
"y","z","1","2","3","4","5","6","7","8","9");
$keys = array();
while(count($keys) < $max) {
$x = mt_rand(0, count($char)-1);
if(!in_array($x, $keys)) {
$keys[] = $x;
}
}
foreach($keys as $key => $val){
$random .= $char[$val];
}
return $random;
}
$font='./font/COOPBL.TTF'; //setting font yang akan digunakan
$images='./images/mk-logo.jpg'; //gambar yang akan digunakan sebagai background
$im = imagecreatefromjpeg("$images")or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 15, 110, 1); //menentukan warna text
//Generate kode yang akan dituliskan pada gambar sebanyak 6
$text=RandomCode(6);
//Buat sessi untuk pengecekan pada halaman lain
$_SESSION['captcha']=$text;
//Tuliskan text pada gambar
imagettftext($im, 40, 0, 20, 60, $text_color, $font, $text);
imagejpeg($im);
imagedestroy($im);
?>