ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSecurImage.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Captcha/classes/class.ilSecurImageUtil.php';
5 
14 {
18  protected $lng;
19 
23  const MAX_CAPTCHA_IMG_WIDTH = 430;
24 
29 
33  protected $image_width = 0;
34 
38  protected $image_height = 0;
39 
43  protected $securimage;
44 
48  protected static $supported_audio_languages = array(
49  'fr', 'de'
50  );
51 
55  public function __construct()
56  {
57  global $DIC;
58 
59  $this->lng = $DIC->language();
61  $this->securimage = new Securimage();
62  if (!function_exists("imagettftext")) {
63  $this->securimage->use_gd_font = true;
64  }
65 
66  $this->securimage->num_lines = 3;
67  }
68 
72  public function getSecureImageObject()
73  {
74  return $this->securimage;
75  }
76 
81  public function check($a_input)
82  {
83  return $this->securimage->check($a_input);
84  }
85 
89  public function showImage()
90  {
92  $this->securimage->show();
93  }
94 
98  public function outputAudioFile()
99  {
103  $lng = $this->lng;
104 
106  if (
107  $lng->lang_key != 'en' &&
108  in_array($lng->lang_key, self::$supported_audio_languages)
109  ) {
110  $this->securimage->audio_path = $this->securimage->securimage_path . '/audio/' . $lng->lang_key . '/';
111  }
112  $this->securimage->outputAudioFile();
113  }
114 
119  public function setImageHeight($image_height)
120  {
121  if (!is_numeric($image_height) || $image_height > self::MAX_CAPTCHA_IMG_HEIGHT) {
122  throw new InvalidArgumentException('Please provide a valid image height (numeric value > 0 and <= ' . self::MAX_CAPTCHA_IMG_HEIGHT);
123  }
124  $this->image_height = $image_height;
125  }
126 
130  public function getImageHeight()
131  {
132  return $this->image_height;
133  }
134 
139  public function setImageWidth($image_width)
140  {
141  if (!is_numeric($image_width) || $image_width > self::MAX_CAPTCHA_IMG_WIDTH) {
142  throw new InvalidArgumentException('Please provide a valid image width (numeric value > 0 and <= ' . self::MAX_CAPTCHA_IMG_WIDTH);
143  }
144  $this->image_width = $image_width;
145  }
146 
150  public function getImageWidth()
151  {
152  return $this->image_width;
153  }
154 }
global $DIC
Definition: saml.php:7
Project: Securimage: A PHP class for creating and managing form CAPTCHA images File: securimage...
const MAX_CAPTCHA_IMG_HEIGHT
__construct()
Constructor.
setImageWidth($image_width)
Create styles array
The data for the language used.
static $supported_audio_languages
SecurImage Wrapper (very simply wrapper, does not abstract other captchas)
setImageHeight($image_height)