Skip to content

Commit

Permalink
Initial commit of FormBuilder 0.87
Browse files Browse the repository at this point in the history
  • Loading branch information
warkior committed Sep 2, 2011
0 parents commit bbf9e01
Show file tree
Hide file tree
Showing 51 changed files with 15,034 additions and 0 deletions.
619 changes: 619 additions & 0 deletions GPLv3.txt

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions additional_styles.sample.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
If you need to further customize the FormBuilder CSS,
items in this file will over-ride the standard
FormBuilder CSS. To use this file, rename and copy
it to /wp-content/additional_styles.css and make
changes as necessary.
*/
78 changes: 78 additions & 0 deletions captcha/CaptchaSecurityImages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*/

if(!class_exists("CaptchaSecurityImages")) {

class CaptchaSecurityImages {

var $font = './monofont.ttf';

function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}

function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.85;
$image = imagecreate($width, $height) or die(__('Cannot initialize new GD image stream', 'formbuilder'));
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* generate random dots in background */
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}
/* generate random lines in background */
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die(__('Error in imagettfbbox function', 'formbuilder'));
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die(__('Error in imagettftext function', 'formbuilder'));
/* output captcha image to browser */

session_start();

header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}

}

}

?>
29 changes: 29 additions & 0 deletions captcha/display.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*/

require_once('CaptchaSecurityImages.php');

$captcha = new CaptchaSecurityImages(120, 40, 6);


?>
Loading

0 comments on commit bbf9e01

Please sign in to comment.