| 1 | 596 | thorn | <?php
 | 
      
        | 2 |  |  | 
 | 
      
        | 3 |  |  | // $Id$
 | 
      
        | 4 |  |  | 
 | 
      
        | 5 |  |  | /*
 | 
      
        | 6 |  |  | 
 | 
      
        | 7 |  |  |  Website Baker Project <http://www.websitebaker.org/>
 | 
      
        | 8 | 915 | Ruebenwurz |  Copyright (C) 2004-2009, Ryan Djurovich
 | 
      
        | 9 | 596 | thorn | 
 | 
      
        | 10 |  |  |  Website Baker is free software; you can redistribute it and/or modify
 | 
      
        | 11 |  |  |  it under the terms of the GNU General Public License as published by
 | 
      
        | 12 |  |  |  the Free Software Foundation; either version 2 of the License, or
 | 
      
        | 13 |  |  |  (at your option) any later version.
 | 
      
        | 14 |  |  | 
 | 
      
        | 15 |  |  |  Website Baker is distributed in the hope that it will be useful,
 | 
      
        | 16 |  |  |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
      
        | 17 |  |  |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
      
        | 18 |  |  |  GNU General Public License for more details.
 | 
      
        | 19 |  |  | 
 | 
      
        | 20 |  |  |  You should have received a copy of the GNU General Public License
 | 
      
        | 21 |  |  |  along with Website Baker; if not, write to the Free Software
 | 
      
        | 22 |  |  |  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
      
        | 23 |  |  | 
 | 
      
        | 24 |  |  | */
 | 
      
        | 25 |  |  | 
 | 
      
        | 26 | 858 | thorn | // displays the image or text inside an <iframe>
 | 
      
        | 27 | 1371 | Luisehahne | if(!function_exists('display_captcha_real')) {
 | 
      
        | 28 |  |  | 	function display_captcha_real($kind='image') {
 | 
      
        | 29 |  |  | 		$t = time();
 | 
      
        | 30 | 1443 | Luisehahne | 		$output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" ";
 | 
      
        | 31 |  |  | 		$output .= "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
 | 
      
        | 32 |  |  | 		$output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"";
 | 
      
        | 33 |  |  | 		$output .= strtolower(LANGUAGE)."\" lang=\"".strtolower(LANGUAGE)."\">\n";
 | 
      
        | 34 |  |  | 		$output .= "\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n";
 | 
      
        | 35 |  |  | 		$output .= "\t\t<title>captcha</title>\n\t</head>\n\t<body>\n";
 | 
      
        | 36 | 1371 | Luisehahne | 		$_SESSION['captcha_time'] = $t;
 | 
      
        | 37 |  |  | 		if($kind=='image') {
 | 
      
        | 38 | 1444 | Luisehahne | 			$output .= "\t\t<a title=\"reload\" href=\"".WB_URL."/include/captcha/captcha.php?display_captcha_X986E21=2\">";
 | 
      
        | 39 |  |  | 			$output .= "<img style=\"border: none;\" src=\"".WB_URL."/include/captcha/captchas/";
 | 
      
        | 40 | 1443 | Luisehahne | 			$output .= CAPTCHA_TYPE.".php?t=".$t."\" alt=\"Captcha\" /></a>\n";
 | 
      
        | 41 | 1371 | Luisehahne | 		} else {
 | 
      
        | 42 | 1443 | Luisehahne | 			$output .= "\t\t<h2>error</h2>";
 | 
      
        | 43 | 1371 | Luisehahne | 		}
 | 
      
        | 44 | 1443 | Luisehahne | 		$output .= "\t</body>\n</html>";
 | 
      
        | 45 |  |  | 		echo $output;
 | 
      
        | 46 | 858 | thorn | 	}
 | 
      
        | 47 |  |  | }
 | 
      
        | 48 |  |  | 
 | 
      
        | 49 |  |  | // called from an <iframe>
 | 
      
        | 50 |  |  | if(isset($_GET['display_captcha_X986E21'])) {
 | 
      
        | 51 |  |  | 	require('../../config.php');
 | 
      
        | 52 |  |  | 	switch(CAPTCHA_TYPE) {
 | 
      
        | 53 |  |  | 	case 'calc_image':
 | 
      
        | 54 |  |  | 	case 'calc_ttf_image':
 | 
      
        | 55 |  |  | 	case 'ttf_image':
 | 
      
        | 56 |  |  | 	case 'old_image':
 | 
      
        | 57 |  |  | 		display_captcha_real('image');
 | 
      
        | 58 |  |  | 		break;
 | 
      
        | 59 |  |  | 	}
 | 
      
        | 60 |  |  | 	exit(0);
 | 
      
        | 61 |  |  | }
 | 
      
        | 62 |  |  | 
 | 
      
        | 63 |  |  | 
 | 
      
        | 64 |  |  | // Make sure page cannot be accessed directly
 | 
      
        | 65 | 596 | thorn | if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
 | 
      
        | 66 |  |  | 
 | 
      
        | 67 |  |  | // check if module language file exists for the language set by the user (e.g. DE, EN)
 | 
      
        | 68 |  |  | global $MOD_CAPTCHA;
 | 
      
        | 69 |  |  | if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
 | 
      
        | 70 |  |  | 	// no module language file exists for the language set by the user, include default module language file EN.php
 | 
      
        | 71 |  |  | 	require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
 | 
      
        | 72 |  |  | } else {
 | 
      
        | 73 |  |  | 	// a module language file exists for the language defined by the user, load it
 | 
      
        | 74 |  |  | 	require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
 | 
      
        | 75 |  |  | }
 | 
      
        | 76 |  |  | 
 | 
      
        | 77 |  |  | // output-handler for image-captchas to determine size of image
 | 
      
        | 78 |  |  | if(!function_exists('captcha_header')) {
 | 
      
        | 79 |  |  | 	function captcha_header() {
 | 
      
        | 80 |  |  | 		header("Expires: Mon, 1 Jan 1990 05:00:00 GMT");
 | 
      
        | 81 |  |  | 		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 | 
      
        | 82 |  |  | 		header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
 | 
      
        | 83 |  |  | 		header("Pragma: no-cache");
 | 
      
        | 84 |  |  | 		header("Content-type: image/png");
 | 
      
        | 85 |  |  | 		return;
 | 
      
        | 86 |  |  | 	}
 | 
      
        | 87 |  |  | }
 | 
      
        | 88 |  |  | 
 | 
      
        | 89 |  |  | // get list of available CAPTCHAS for the dropdown-listbox in admin-tools
 | 
      
        | 90 |  |  | if(extension_loaded('gd') && function_exists('imagepng') && function_exists('imagettftext')) {
 | 
      
        | 91 |  |  | 	$useable_captchas = array(
 | 
      
        | 92 |  |  | 		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
 | 
      
        | 93 |  |  | 		'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
 | 
      
        | 94 | 615 | thorn | 		'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
 | 
      
        | 95 | 596 | thorn | 		'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
 | 
      
        | 96 | 624 | thorn | 		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
 | 
      
        | 97 |  |  | 		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 | 
      
        | 98 | 596 | thorn | 	);
 | 
      
        | 99 |  |  | } elseif(extension_loaded('gd') && function_exists('imagepng')) {
 | 
      
        | 100 |  |  | 	$useable_captchas = array(
 | 
      
        | 101 |  |  | 		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
 | 
      
        | 102 |  |  | 		'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
 | 
      
        | 103 | 624 | thorn | 		'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
 | 
      
        | 104 |  |  | 		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 | 
      
        | 105 | 596 | thorn | 	);
 | 
      
        | 106 |  |  | } else {
 | 
      
        | 107 |  |  | 	$useable_captchas = array(
 | 
      
        | 108 | 624 | thorn | 		'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
 | 
      
        | 109 |  |  | 		'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
 | 
      
        | 110 | 596 | thorn | 	);
 | 
      
        | 111 |  |  | }
 | 
      
        | 112 |  |  | 
 | 
      
        | 113 |  |  | if(!function_exists('call_captcha')) {
 | 
      
        | 114 | 1371 | Luisehahne | 	function call_captcha($action='all', $style='', $sec_id='') {
 | 
      
        | 115 | 596 | thorn | 		global $MOD_CAPTCHA;
 | 
      
        | 116 | 609 | thorn | 		$t = time();
 | 
      
        | 117 |  |  | 		$_SESSION['captcha_time'] = $t;
 | 
      
        | 118 | 858 | thorn | 
 | 
      
        | 119 | 867 | thorn | 		// get width and height of captcha image for use in <iframe>
 | 
      
        | 120 | 858 | thorn | 		switch(CAPTCHA_TYPE) {
 | 
      
        | 121 |  |  | 		case 'calc_image':
 | 
      
        | 122 |  |  | 			$captcha_width = 142;
 | 
      
        | 123 |  |  | 			$captcha_height = 30;
 | 
      
        | 124 |  |  | 			break;
 | 
      
        | 125 |  |  | 		case 'calc_ttf_image':
 | 
      
        | 126 |  |  | 			$captcha_width = 162;
 | 
      
        | 127 |  |  | 			$captcha_height = 40;
 | 
      
        | 128 |  |  | 			break;
 | 
      
        | 129 |  |  | 		case 'ttf_image':
 | 
      
        | 130 |  |  | 			$captcha_width = 162;
 | 
      
        | 131 |  |  | 			$captcha_height = 40;
 | 
      
        | 132 |  |  | 			break;
 | 
      
        | 133 |  |  | 		case 'old_image':
 | 
      
        | 134 |  |  | 			$captcha_width = 142;
 | 
      
        | 135 |  |  | 			$captcha_height = 30;
 | 
      
        | 136 |  |  | 			break;
 | 
      
        | 137 |  |  | 		default:
 | 
      
        | 138 |  |  | 			$captcha_width = 250;
 | 
      
        | 139 |  |  | 			$captcha_height = 100;
 | 
      
        | 140 |  |  | 		}
 | 
      
        | 141 |  |  | 
 | 
      
        | 142 | 747 | thorn | 		if($action=='all') {
 | 
      
        | 143 |  |  | 			switch(CAPTCHA_TYPE) {
 | 
      
        | 144 | 867 | thorn | 				case 'text': // text-captcha
 | 
      
        | 145 | 1438 | DarkViper | 					?><table class="captcha_table" summary="captcha control"><tr>
 | 
      
        | 146 | 858 | thorn | 					<td class="text_captcha">
 | 
      
        | 147 |  |  | 						<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
 | 
      
        | 148 |  |  | 					</td>
 | 
      
        | 149 |  |  | 					<td></td>
 | 
      
        | 150 | 756 | thorn | 					<td><input type="text" name="captcha" maxlength="50"  style="width:150px;" /></td>
 | 
      
        | 151 | 747 | thorn | 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
 | 
      
        | 152 |  |  | 					</tr></table><?php
 | 
      
        | 153 |  |  | 					break;
 | 
      
        | 154 |  |  | 				case 'calc_text': // calculation as text
 | 
      
        | 155 | 1438 | DarkViper | 					?><table class="captcha_table" summary="captcha control"><tr>
 | 
      
        | 156 | 858 | thorn | 					<td class="text_captcha">
 | 
      
        | 157 |  |  | 						<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
 | 
      
        | 158 |  |  | 					</td>
 | 
      
        | 159 |  |  | 					<td> = </td>
 | 
      
        | 160 | 756 | thorn | 					<td><input type="text" name="captcha" maxlength="10"  style="width:20px;" /></td>
 | 
      
        | 161 | 747 | thorn | 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 | 
      
        | 162 |  |  | 					</tr></table><?php
 | 
      
        | 163 |  |  | 					break;
 | 
      
        | 164 |  |  | 				case 'calc_image': // calculation with image (old captcha)
 | 
      
        | 165 |  |  | 				case 'calc_ttf_image': // calculation with varying background and ttf-font
 | 
      
        | 166 | 1438 | DarkViper | 				  ?><table class="captcha_table" summary="captcha control"><tr>
 | 
      
        | 167 | 858 | thorn | 					<td class="image_captcha">
 | 
      
        | 168 | 1371 | Luisehahne | 						<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
 | 
      
        | 169 |  |  | 						<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
 | 
      
        | 170 | 858 | thorn | 						</iframe>
 | 
      
        | 171 |  |  | 					</td>
 | 
      
        | 172 |  |  | 					<td> = </td>
 | 
      
        | 173 | 756 | thorn | 					<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
 | 
      
        | 174 | 747 | thorn | 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
 | 
      
        | 175 |  |  | 					</tr></table><?php
 | 
      
        | 176 |  |  | 					break;
 | 
      
        | 177 |  |  | 				// normal images
 | 
      
        | 178 |  |  | 				case 'ttf_image': // captcha with varying background and ttf-font
 | 
      
        | 179 |  |  | 				case 'old_image': // old captcha
 | 
      
        | 180 | 1438 | DarkViper | 					?><table class="captcha_table" summary="captcha control"><tr>
 | 
      
        | 181 | 858 | thorn | 					<td class="image_captcha">
 | 
      
        | 182 | 1371 | Luisehahne | 						<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
 | 
      
        | 183 |  |  | 						<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
 | 
      
        | 184 | 858 | thorn | 						</iframe>
 | 
      
        | 185 |  |  | 					</td>
 | 
      
        | 186 |  |  | 					<td></td>
 | 
      
        | 187 | 756 | thorn | 					<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td>
 | 
      
        | 188 | 747 | thorn | 					<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
 | 
      
        | 189 |  |  | 					</tr></table><?php
 | 
      
        | 190 |  |  | 					break;
 | 
      
        | 191 |  |  | 			}
 | 
      
        | 192 |  |  | 		} elseif($action=='image') {
 | 
      
        | 193 |  |  | 			switch(CAPTCHA_TYPE) {
 | 
      
        | 194 |  |  | 				case 'text': // text-captcha
 | 
      
        | 195 |  |  | 				case 'calc_text': // calculation as text
 | 
      
        | 196 | 756 | thorn | 					echo ($style?"<span $style>":'');
 | 
      
        | 197 | 747 | thorn | 					include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
 | 
      
        | 198 | 756 | thorn | 					echo ($style?'</span>':'');
 | 
      
        | 199 | 747 | thorn | 					break;
 | 
      
        | 200 |  |  | 				case 'calc_image': // calculation with image (old captcha)
 | 
      
        | 201 |  |  | 				case 'calc_ttf_image': // calculation with varying background and ttf-font
 | 
      
        | 202 |  |  | 				case 'ttf_image': // captcha with varying background and ttf-font
 | 
      
        | 203 |  |  | 				case 'old_image': // old captcha
 | 
      
        | 204 | 1371 | Luisehahne | 					echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id\" />";
 | 
      
        | 205 | 747 | thorn | 					break;
 | 
      
        | 206 |  |  | 			}
 | 
      
        | 207 | 858 | thorn | 		} elseif($action=='image_iframe') {
 | 
      
        | 208 |  |  | 			switch(CAPTCHA_TYPE) {
 | 
      
        | 209 |  |  | 				case 'text': // text-captcha
 | 
      
        | 210 |  |  | 					echo ($style?"<span $style>":'');
 | 
      
        | 211 |  |  | 					include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
 | 
      
        | 212 |  |  | 					echo ($style?'</span>':'');
 | 
      
        | 213 |  |  | 					break;
 | 
      
        | 214 |  |  | 				case 'calc_text': // calculation as text
 | 
      
        | 215 |  |  | 					include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
 | 
      
        | 216 |  |  | 					break;
 | 
      
        | 217 |  |  | 				case 'calc_image': // calculation with image (old captcha)
 | 
      
        | 218 |  |  | 				case 'calc_ttf_image': // calculation with varying background and ttf-font
 | 
      
        | 219 |  |  | 				case 'ttf_image': // captcha with varying background and ttf-font
 | 
      
        | 220 |  |  | 				case 'old_image': // old captcha
 | 
      
        | 221 | 1371 | Luisehahne | 					?>
 | 
      
        | 222 |  |  | 					<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
 | 
      
        | 223 |  |  | 					<?php
 | 
      
        | 224 | 858 | thorn | 					echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
 | 
      
        | 225 |  |  | 					?></iframe><?php
 | 
      
        | 226 |  |  | 					break;
 | 
      
        | 227 |  |  | 			}
 | 
      
        | 228 | 747 | thorn | 		} elseif($action=='input') {
 | 
      
        | 229 |  |  | 			switch(CAPTCHA_TYPE) {
 | 
      
        | 230 |  |  | 				case 'text': // text-captcha
 | 
      
        | 231 | 756 | thorn | 					echo '<input type="text" name="captcha" '.($style?$style:'style="width:150px;" maxlength="50"').' />';
 | 
      
        | 232 | 747 | thorn | 					break;
 | 
      
        | 233 |  |  | 				case 'calc_text': // calculation as text
 | 
      
        | 234 |  |  | 				case 'calc_image': // calculation with image (old captcha)
 | 
      
        | 235 |  |  | 				case 'calc_ttf_image': // calculation with varying background and ttf-font
 | 
      
        | 236 | 756 | thorn | 					echo '<input type="text" name="captcha" '.($style?$style:'style="width:20px;" maxlength="10"').' />';
 | 
      
        | 237 | 747 | thorn | 					break;
 | 
      
        | 238 |  |  | 				case 'ttf_image': // captcha with varying background and ttf-font
 | 
      
        | 239 |  |  | 				case 'old_image': // old captcha
 | 
      
        | 240 | 756 | thorn | 					echo '<input type="text" name="captcha" '.($style?$style:'style="width:50px;" maxlength="10"').' />';
 | 
      
        | 241 | 747 | thorn | 					break;
 | 
      
        | 242 |  |  | 			}
 | 
      
        | 243 |  |  | 		} elseif($action=='text') {
 | 
      
        | 244 | 756 | thorn | 			echo ($style?"<span $style>":'');
 | 
      
        | 245 | 747 | thorn | 			switch(CAPTCHA_TYPE) {
 | 
      
        | 246 |  |  | 				case 'text': // text-captcha
 | 
      
        | 247 |  |  | 					echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST'];
 | 
      
        | 248 |  |  | 					break;
 | 
      
        | 249 |  |  | 				case 'calc_text': // calculation as text
 | 
      
        | 250 |  |  | 				case 'calc_image': // calculation with image (old captcha)
 | 
      
        | 251 |  |  | 				case 'calc_ttf_image': // calculation with varying background and ttf-font
 | 
      
        | 252 |  |  | 					echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
 | 
      
        | 253 |  |  | 					break;
 | 
      
        | 254 |  |  | 				case 'ttf_image': // captcha with varying background and ttf-font
 | 
      
        | 255 |  |  | 				case 'old_image': // old captcha
 | 
      
        | 256 |  |  | 					echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'];
 | 
      
        | 257 |  |  | 					break;
 | 
      
        | 258 |  |  | 			}
 | 
      
        | 259 | 756 | thorn | 			echo ($style?'</span>':'');
 | 
      
        | 260 | 596 | thorn | 		}
 | 
      
        | 261 |  |  | 	}
 | 
      
        | 262 |  |  | }
 |