ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4require_once 'Services/Captcha/classes/class.ilSecurImageUtil.php';
5
14{
18 protected $lng;
19
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 {
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
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
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}
An exception for terminatinating execution or to throw for unit testing.
SecurImage Wrapper (very simply wrapper, does not abstract other captchas)
const MAX_CAPTCHA_IMG_HEIGHT
setImageHeight($image_height)
setImageWidth($image_width)
__construct()
Constructor.
static $supported_audio_languages
global $DIC
Definition: goto.php:24
Project: Securimage: A PHP class for creating and managing form CAPTCHA images File: securimage....