source: extensions/CryptograPHP/securimage/securimage_preview.php @ 26554

Revision 26554, 2.5 KB checked in by mistic100, 6 years ago (diff)

update Securimage to 3.5.1, new font, new preset, allow to use backgrounds

Line 
1<?php
2/**
3 * this file take parameters from $_GET, reserved for admin usage
4 */
5 
6define('PHPWG_ROOT_PATH','../../../');
7include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
8
9is_admin() or die('Hacking attempt!');
10
11
12$temp_conf = array(
13  'captcha_type'    => $_GET['captcha_type'],
14  'width'           => (int)$_GET['width'], 
15  'height'          => (int)$_GET['height'],
16  'perturbation'    => (float)$_GET['perturbation'],
17  'background'      => $_GET['background'],
18  'bg_color'        => $_GET['bg_color'],
19  'bg_image'        => $_GET['bg_image'],
20  'code_length'     => (int)$_GET['code_length'],
21  'text_color'      => $_GET['text_color'],
22  'num_lines'       => (float)$_GET['num_lines'],
23  'line_color'      => $_GET['line_color'],
24  'noise_level'     => (float)$_GET['noise_level'],
25  'noise_color'     => $_GET['noise_color'],
26  'ttf_file'        => $_GET['ttf_file'],
27  );
28
29 
30// randomize colors
31function randomColor()
32{
33  mt_srand((double)microtime()*1000000);
34  $c = null;
35  while(strlen($c)<6)
36  {
37      $c .= sprintf("%02X", mt_rand(0, 255));
38  }
39  return $c;
40}
41
42foreach (array('bg_color','text_color','line_color','noise_color') as $color)
43{
44  if ($temp_conf[$color] == 'random') $temp_conf[$color] = randomColor();
45}
46
47
48require_once dirname(__FILE__) . '/securimage.php';
49$img = new securimage();
50
51$img->ttf_file        = './fonts/'.$temp_conf['ttf_file'].'.ttf';
52$img->captcha_type    = ($temp_conf['captcha_type'] == 'string') ? Securimage::SI_CAPTCHA_STRING : Securimage::SI_CAPTCHA_MATHEMATIC;
53// $img->case_sensitive  = get_boolean($temp_conf['case_sensitive']);
54$img->image_width     = $temp_conf['width']; 
55$img->image_height    = $temp_conf['height'];
56$img->perturbation    = $temp_conf['perturbation'];
57$img->text_color      = new Securimage_Color('#'.$temp_conf['text_color']); 
58$img->num_lines       = $temp_conf['num_lines'];
59$img->line_color      = new Securimage_Color('#'.$temp_conf['line_color']);
60$img->noise_level     = $temp_conf['noise_level'];
61$img->noise_color     = new Securimage_Color('#'.$temp_conf['noise_color']);
62$img->code_length     = $temp_conf['code_length'];
63
64if ($temp_conf['background'] == 'image')
65{
66  if ($temp_conf['bg_image'] == 'random')
67  {
68    $img->background_directory = realpath(CRYPTO_PATH . 'securimage/backgrounds/');
69    $img->show();
70  }
71  else
72  {
73    $img->show(realpath(CRYPTO_PATH . 'securimage/backgrounds/' . $temp_conf['bg_image']));
74  }
75}
76else
77{
78  $img->image_bg_color  = new Securimage_Color('#'.$temp_conf['bg_color']);
79  $img->show();
80}
Note: See TracBrowser for help on using the repository browser.