22 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
34 if (!extension_loaded(
'gd')) {
35 trigger_error(
'GD library is not loaded', E_USER_WARNING);
38 $required_functions = array(
39 'imagecreatetruecolor' ,
40 'imagecolorallocate' ,
41 'imagefilledrectangle' ,
45 foreach ($required_functions as $func) {
46 if (!function_exists($func)) {
47 trigger_error(
'Function ' . $func .
' is not defined', E_USER_WARNING);
62 $js =
"<script type='text/javascript'>
63 function xoops_captcha_refresh(imgId)
65 xoopsGetElementById(imgId).src = '" . XOOPS_URL .
"/class/captcha/image/scripts/image.php?refresh='+Math.random();
68 $image = $this->loadImage();
69 $image .=
"<br /><a href=\"javascript: xoops_captcha_refresh('" . ($this->config[
'name']) .
"')\">" .
_CAPTCHA_REFRESH .
"</a>";
70 $input =
'<input type="text" name="' . $this->config[
'name'] .
'" id="' . $this->config[
'name'] .
'" size="' . $this->config[
'num_chars'] .
'" maxlength="' . $this->config[
'num_chars'] .
'" value="" />';
73 if (!empty($this->config[
'maxattempts'])) {
76 return $js .
$image .
'<br /><br />' . $input .
'<br />' . $rule;
86 return '<img id="' . ($this->config[
"name"]) .
'" src="' . XOOPS_URL .
'/class/captcha/image/scripts/image.php" onclick=\'this.src="' . XOOPS_URL .
'/class/captcha/image/scripts/image.php?refresh="+Math.random()' .
'\' style=
"cursor: pointer; vertical-align: middle;" alt=
"" />
';