1: <?php
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: class XoopsCaptchaText extends XoopsCaptchaMethod
27: {
28: 29: 30: 31: 32:
33: public function render()
34: {
35: $form = $this->loadText() . ' <input type="text" name="' . $this->config['name']
36: . '" id="' . $this->config['name'] . '" size="' . $this->config['num_chars']
37: . '" maxlength="' . $this->config['num_chars'] . '" value="" />';
38: $form .= '<br />' . XoopsLocale::INPUT_RESULT_FROM_EXPRESSION;
39: if (!empty($this->config['maxattempts'])) {
40: $form .= '<br />' . sprintf(XoopsLocale::F_MAXIMUM_ATTEMPTS, $this->config['maxattempts']);
41: }
42: return $form;
43: }
44:
45: 46: 47: 48: 49:
50: public function loadText()
51: {
52: $val_a = mt_rand(0, 9);
53: $val_b = mt_rand(0, 9);
54: if ($val_a > $val_b) {
55: $expression = "{$val_a} - {$val_b} = ?";
56: $this->code = $val_a - $val_b;
57: } else {
58: $expression = "{$val_a} + {$val_b} = ?";
59: $this->code = $val_a + $val_b;
60: }
61: return '<span style="font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;">' . $expression . '</span>';
62: }
63: }
64: