ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCaptchaUtil Class Reference

Captcha util. More...

+ Collaboration diagram for ilCaptchaUtil:

Static Public Member Functions

static checkFreetype ()
 Check whether captcha support is active. More...
 
static __callStatic ($name, array $arguments=array())
 

Data Fields

const CONTEXT_FORUM = 'frm'
 
const CONTEXT_LOGIN = 'auth'
 
const CONTEXT_REGISTRATION = 'reg'
 
const CONTEXT_WIKI = 'wiki'
 

Static Protected Attributes

static $context_map
 

Static Private Member Functions

static getSupportedContexts ()
 

Detailed Description

Captcha util.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file class.ilCaptchaUtil.php.

Member Function Documentation

◆ __callStatic()

static ilCaptchaUtil::__callStatic (   $name,
array  $arguments = array() 
)
static
Parameters
string$name
array$arguments
Returns
bool
Exceptions
BadMethodCallException

Definition at line 43 of file class.ilCaptchaUtil.php.

References $DIC, $lng, and $name.

44  {
45  if (
46  strpos($name, 'isActiveFor') === 0 ||
47  strpos($name, 'setActiveFor') === 0
48  ) {
49  $settings = new ilSetting('cptch');
50  $supported_contexts = self::getSupportedContexts();
51  $method_parts = explode('_', strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name)));
52  $requested_context = strtolower($method_parts[count($method_parts) - 1]);
53  if (!isset($requested_context, self::$context_map)) {
54  throw new BadMethodCallException('Method ' . $name . ' called for a non existing context.');
55  }
56 
57  if ('set' == $method_parts[0]) {
58  $settings->set('activate_captcha_anonym_' . $supported_contexts[$requested_context], (int) $arguments[0]);
59  return;
60  } else {
61  return self::checkFreetype() && (bool) $settings->get('activate_captcha_anonym_' . $supported_contexts[$requested_context], false);
62  }
63  } else {
64  throw new BadMethodCallException('Call to an undefined static method ' . $name . ' in class ' . __CLASS__ . '.');
65  }
66  }
if($format !==null) $name
Definition: metadata.php:146

◆ checkFreetype()

static ilCaptchaUtil::checkFreetype ( )
static

Check whether captcha support is active.

Returns
bool

Definition at line 27 of file class.ilCaptchaUtil.php.

References ilLoggerFactory\getLogger().

Referenced by ilObjForumAdministrationGUI\getSettingsForm(), ilObjAuthSettingsGUI\initAuthModeDetermination(), ilRegistrationSettingsGUI\initForm(), and ilObjWikiSettingsGUI\initForm().

28  {
29  if (function_exists('imageftbbox')) {
30  ilLoggerFactory::getLogger('auth')->debug('Function imageftbox is available.');
31  return true;
32  }
33  ilLoggerFactory::getLogger('auth')->debug('Function imageftbox is not available.');
34  return false;
35  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedContexts()

static ilCaptchaUtil::getSupportedContexts ( )
staticprivate
Returns
array

Definition at line 87 of file class.ilCaptchaUtil.php.

References $name, $r, and array.

88  {
89  if (null !== self::$context_map) {
90  return self::$context_map;
91  }
92 
93  self::$context_map = array();
94 
95  $r = new ReflectionClass(new self());
96  $constants = $r->getConstants();
97  foreach ($constants as $name => $value) {
98  if (strpos($name, 'CONTEXT_') === 0) {
99  self::$context_map[strtolower(substr($name, strlen('CONTEXT_')))] = $value;
100  }
101  }
102 
103  return self::$context_map;
104  }
if($format !==null) $name
Definition: metadata.php:146
$r
Definition: example_031.php:79
Create styles array
The data for the language used.

Field Documentation

◆ $context_map

ilCaptchaUtil::$context_map
staticprotected

Definition at line 21 of file class.ilCaptchaUtil.php.

◆ CONTEXT_FORUM

const ilCaptchaUtil::CONTEXT_FORUM = 'frm'

Definition at line 13 of file class.ilCaptchaUtil.php.

◆ CONTEXT_LOGIN

const ilCaptchaUtil::CONTEXT_LOGIN = 'auth'

Definition at line 14 of file class.ilCaptchaUtil.php.

◆ CONTEXT_REGISTRATION

const ilCaptchaUtil::CONTEXT_REGISTRATION = 'reg'

Definition at line 15 of file class.ilCaptchaUtil.php.

◆ CONTEXT_WIKI

const ilCaptchaUtil::CONTEXT_WIKI = 'wiki'

Definition at line 16 of file class.ilCaptchaUtil.php.


The documentation for this class was generated from the following file: