Файл: demos/captcha.php
Строк: 83
<?php
/**************************************************************************************************
|
| http://alternanetworks.com
| ask@alternanetworks.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License
| Agreement available at http://envato.com/ and to be bound by it.
|
| Copyright (c) 2011 alternanetworks.com All rights reserved.
|
| http://codecanyon.net/user/AlternaNetworks
|**************************************************************************************************/
//error_reporting( E_ALL );
//ini_set( 'display_errors', '1' );
// randomize boolean
function getRandomBoolean()
{
return .01 * mt_rand( 0, 100 ) >= .5;
}
// random array
function array_random($array) {
return $array[array_rand($array)];
}
// generate random hex color
function getRandomColorHex()
{
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
}
// randomize bgs
$bg = array('bg00.jpg','bg01.jpg','bg02.jpg','bg03.jpg','bg04.jpg','bg05.jpg','bg06.jpg','bg07.jpg','bg08.jpg');
$bg = array_random($bg);
// random font size
$fontSize = mt_rand(40, 60);
// random lenght
$lenght = mt_rand(4, 6);
// load myCaptcha
require_once ( "../captcha/load.php" );
$captcha = new myCaptcha( 'standalone_demo' );
$captcha->font( 'KGSkinnyLatte.ttf' );
$captcha->fontSize( $fontSize );
$captcha->pattern( '0123456789' );
$captcha->lenght( $lenght );
$captcha->dictionary( 'default.dictionary.php' );
$captcha->useDictionary( getRandomBoolean() );
$captcha->width( 250 );
$captcha->height( 80 );
$captcha->fontAngle(4);
$captcha->useBgWave( getRandomBoolean() );
$captcha->useFontWave( getRandomBoolean() );
$captcha->fontWaveX(10);
$captcha->fontWaveY(10);
$captcha->useBg( getRandomBoolean() );
$captcha->bg( $bg );
$captcha->color( getRandomColorHex() );
$captcha->bgColor( getRandomColorHex() );
$captcha->base64( false );
echo $captcha->image();