source: extensions/CryptograPHP/securimage/securimage_show.php @ 12617

Last change on this file since 12617 was 12617, checked in by mistic100, 12 years ago

rewrite some prefilters, replace CryptograPHP by Securimage (not abandoned project!)

File size: 3.8 KB
Line 
1<?php
2/**
3 * Project:     Securimage: A PHP class for creating and managing form CAPTCHA images
4 * File:        securimage_show.php
5 *
6 * Copyright (c) 2011, Drew Phillips
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without modification,
10 * are permitted provided that the following conditions are met:
11 *
12 *  - Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  - Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Any modifications to the library should be indicated clearly in the source code
31 * to inform users that the changes are not a part of the original software.
32 *
33 * If you found this script useful, please take a quick moment to rate it.
34 * http://www.hotscripts.com/rate/49400.html  Thanks.
35 *
36 * @link http://www.phpcaptcha.org Securimage PHP CAPTCHA
37 * @link http://www.phpcaptcha.org/latest.zip Download Latest Version
38 * @link http://www.phpcaptcha.org/Securimage_Docs/ Online Documentation
39 * @copyright 2011 Drew Phillips
40 * @author Drew Phillips <drew@drew-phillips.com>
41 * @version 3.0 (October 2011)
42 * @package Securimage
43 *
44 */
45
46// error_reporting(E_ALL); ini_set('display_errors', 1); // uncomment this line for debugging
47
48define('PHPWG_ROOT_PATH','../../../');
49include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
50
51$conf['cryptographp'] = unserialize($conf['cryptographp']);
52
53// randomize colors
54function randomColor()
55{
56  mt_srand((double)microtime()*1000000);
57  $c = null;
58  while(strlen($c)<6)
59  {
60      $c .= sprintf("%02X", mt_rand(0, 255));
61  }
62  return $c;
63}
64
65foreach (array('image_bg_color','text_color','line_color','noise_color') as $color)
66{
67  if ($conf['cryptographp'][$color] == 'random') $conf['cryptographp'][$color] = randomColor();
68}
69
70require_once dirname(__FILE__) . '/securimage.php';
71$img = new securimage();
72
73$img->ttf_file        = './fonts/'.$conf['cryptographp']['ttf_file'].'.ttf';
74$img->captcha_type    = ($conf['cryptographp']['captcha_type'] == 'string') ? Securimage::SI_CAPTCHA_STRING : Securimage::SI_CAPTCHA_MATHEMATIC;
75// $img->case_sensitive  = get_boolean($conf['cryptographp']['case_sensitive']);
76$img->image_width     = $conf['cryptographp']['width']; 
77$img->image_height    = $conf['cryptographp']['height'];
78$img->perturbation    = $conf['cryptographp']['perturbation'];
79$img->image_bg_color  = new Securimage_Color('#'.$conf['cryptographp']['image_bg_color']);
80$img->text_color      = new Securimage_Color('#'.$conf['cryptographp']['text_color']); 
81$img->num_lines       = $conf['cryptographp']['num_lines'];
82$img->line_color      = new Securimage_Color('#'.$conf['cryptographp']['line_color']);
83$img->noise_level     = $conf['cryptographp']['noise_level'];
84$img->noise_color     = new Securimage_Color('#'.$conf['cryptographp']['noise_color']);
85$img->code_length     = $conf['cryptographp']['code_length'];
86
87$img->show();
88
89?>
Note: See TracBrowser for help on using the repository browser.