1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91:
<?php
class icms_form_elements_captcha_Image {
public function __construct() {
}
public function &instance() {
static $instance;
if (!isset($instance)) {
$instance = new self();
}
return $instance;
}
public function loadConfig($config = array()) {
$this->config =& $config;
}
public function render() {
global $icmsConfigCaptcha;
$form = "<input type='text' name='" . $this->config["name"]
. "' id='" . $this->config["name"]
. "' size='" . $icmsConfigCaptcha['captcha_num_chars']
. "' maxlength='" . $icmsConfigCaptcha['captcha_num_chars']
. "' value='' /> ". $this->loadImage();
$rule = htmlspecialchars(ICMS_CAPTCHA_REFRESH, ENT_QUOTES);
if ($icmsConfigCaptcha['captcha_maxattempt']) {
$rule .= " | ". sprintf(constant("ICMS_CAPTCHA_MAXATTEMPTS"), $icmsConfigCaptcha['captcha_maxattempt']);
}
$form .= " <small>{$rule}</small>";
return $form;
}
public function loadImage() {
global $icmsConfigCaptcha;
$rule = $icmsConfigCaptcha['captcha_casesensitive'] ? constant("ICMS_CAPTCHA_RULE_CASESENSITIVE") : constant("ICMS_CAPTCHA_RULE_CASEINSENSITIVE");
$ret = "<img id='captcha' src='" . ICMS_URL . "/libraries/icms/form/elements/captcha/img.php' onclick=\"this.src='" . ICMS_URL . "/libraries/icms/form/elements/captcha/img.php?refresh='+Math.random()"
."\" style='cursor: pointer;margin-left: auto;margin-right: auto;text-align:center;' alt='" . htmlspecialchars($rule, ENT_QUOTES) . "' />";
return $ret;
}
}