ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  const MAX_CAPTCHA_IMG_WIDTH = 430;
19 
24 
28  protected $image_width = 0;
29 
33  protected $image_height = 0;
34 
38  protected $securimage;
39 
43  protected static $supported_audio_languages = array(
44  'fr', 'de'
45  );
46 
50  public function __construct()
51  {
53  $this->securimage = new Securimage();
54  if(!function_exists("imagettftext"))
55  {
56  $this->securimage->use_gd_font = true;
57  }
58 
59  $this->securimage->num_lines = 3;
60  }
61 
65  public function getSecureImageObject()
66  {
67  return $this->securimage;
68  }
69 
74  public function check($a_input)
75  {
76  return $this->securimage->check($a_input);
77  }
78 
82  public function showImage()
83  {
85  $this->securimage->show();
86  }
87 
91  public function outputAudioFile()
92  {
96  global $lng;
97 
99  if(
100  $lng->lang_key != 'en' &&
101  in_array($lng->lang_key, self::$supported_audio_languages)
102  )
103  {
104  $this->securimage->audio_path = $this->securimage->securimage_path . '/audio/' . $lng->lang_key . '/';
105  }
106  $this->securimage->outputAudioFile();
107  }
108 
113  public function setImageHeight($image_height)
114  {
115  if(!is_numeric($image_height) || $image_height > self::MAX_CAPTCHA_IMG_HEIGHT)
116  {
117  throw new InvalidArgumentException('Please provide a valid image height (numeric value > 0 and <= ' . self::MAX_CAPTCHA_IMG_HEIGHT);
118  }
119  $this->image_height = $image_height;
120  }
121 
125  public function getImageHeight()
126  {
127  return $this->image_height;
128  }
129 
134  public function setImageWidth($image_width)
135  {
136  if(!is_numeric($image_width) || $image_width > self::MAX_CAPTCHA_IMG_WIDTH)
137  {
138  throw new InvalidArgumentException('Please provide a valid image width (numeric value > 0 and <= ' . self::MAX_CAPTCHA_IMG_WIDTH);
139  }
140  $this->image_width = $image_width;
141  }
142 
146  public function getImageWidth()
147  {
148  return $this->image_width;
149  }
150 }