Project

General

Profile

« Previous | Next » 

Revision 609

Added by thorn almost 17 years ago

Added preview-images for CAPTCHA. Improved security: CAPTCHAS can't be loaded from outside WB

View differences:

trunk/CHANGELOG
10 10
# = Bugfix
11 11
! = Update/Change
12 12

  
13
------------------------------------- 2.7.0 -------------------------------------
13
------------------------------------- 2.7.0 -------------------------------------
14
27-Jan-2008 Thomas Hornik
15
+	Added preview-images for CAPTCHA.
16
!	Improved security: CAPTCHAS can't be loaded from outside WB
14 17
26-Jan-2008 Christian Sommer
15 18
!	changed WYSIWYG content field from text to longtext (allows more than 65'534 characters) 
16 19
+	Added Javascript Admin module (developed by Stepan Riha, adapted for WB2.7 by Swen Uth)
trunk/wb/include/captcha/captchas/ttf_image.php
26 26
require_once("../../../config.php");
27 27
require_once(WB_PATH.'/include/captcha/captcha.php');
28 28

  
29
if(!isset($_SESSION['captcha_time']))
30
	exit;
31
unset($_SESSION['captcha_time']);
32

  
29 33
// get lists of fonts and backgrounds
30 34
require_once(WB_PATH.'/search/search_modext.php');
31 35
list($fonts, $dirs) = list_files_dirs(WB_PATH.'/include/captcha/fonts', false);
trunk/wb/include/captcha/captchas/old_image.php
26 26
require_once("../../../config.php");
27 27
require_once(WB_PATH.'/include/captcha/captcha.php');
28 28

  
29
if(!isset($_SESSION['captcha_time']))
30
	exit;
31
unset($_SESSION['captcha_time']);
32

  
29 33
// Captcha
30 34
srand((double)microtime()*100000);
31 35
$_SESSION['captcha'] = rand(10000,99999);
trunk/wb/include/captcha/captchas/calc_image.php
26 26
require_once("../../../config.php");
27 27
require_once(WB_PATH.'/include/captcha/captcha.php');
28 28

  
29
if(!isset($_SESSION['captcha_time']))
30
	exit;
31
unset($_SESSION['captcha_time']);
32

  
29 33
// Captcha
30 34
$_SESSION['captcha'] = '';
31 35
mt_srand((double)microtime()*100000);
trunk/wb/include/captcha/captcha.php
88 88
if(!function_exists('call_captcha')) {
89 89
	function call_captcha() {
90 90
		global $MOD_CAPTCHA;
91

  
91
		$t = time();
92
		$_SESSION['captcha_time'] = $t;
93
	
92 94
		switch(CAPTCHA_TYPE) {
93 95
			// two special cases
94 96
			case 'calc_text': // calculation as text
......
99 101
				break;
100 102
			case 'calc_image': // calculation with image (old captcha)
101 103
				?>
102
				<img src="<?php echo WB_URL.'/include/captcha/captchas/calc_image.php?t='.time(); ?>" align="middle" alt="Captcha" /> = 
104
				<img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" align="middle" alt="Captcha" /> = 
103 105
				<input type="text" name="captcha" maxlength="5" style="width:20px" />&nbsp;&nbsp;<?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></font>
104 106
				<?php
105 107
				break;
......
107 109
			case 'ttf_image': // captcha with varying background and ttf-font
108 110
			case 'old_image': // old captcha
109 111
				?>
110
				<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php?t='.time(); ?>" align="middle" alt="Captcha" />
112
				<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" align="middle" alt="Captcha" />
111 113
				<input type="text" name="captcha" maxlength="5" style="width:50px" />&nbsp;&nbsp;<?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></font>
112 114
				<?php
113 115
				break;
trunk/wb/modules/captcha_control/tool.php
63 63
	// include captcha-file
64 64
	require_once(WB_PATH .'/include/captcha/captcha.php');
65 65

  
66
// script to load image
67
?>
68
<script type="text/javascript">
69
	var pics = new Array();
70

  
71
	pics["ttf_image"] = new Image();
72
	pics["ttf_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/ttf_image.png'?>";
73

  
74
	pics["calc_image"] = new Image();
75
	pics["calc_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_image.png'?>";
76
	
77
	pics["old_image"] = new Image();
78
	pics["old_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/old_image.png'?>";
79
	
80
	pics["calc_text"] = new Image();
81
	pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>";
82

  
83
</script>
84
<?php
85

  
66 86
	// connect to database and read out captcha settings
67 87
	if($query = $database->query("SELECT * FROM $table")) {
68 88
		$data = $query->fetchRow();
......
85 105
<form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
86 106
	<table width="98%" cellspacing="0" cellpadding="5px" class="row_a">
87 107
	<tr><td colspan="2"><strong><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_CONF'];?>:</strong></td></tr>
88
	<tr>
89
		<td width="35%"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
108
	<tr><td>
109
		<table>
110
			<tr height="50px">
111
			<td><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
112
			<td align="right" width="150px"><img name="captcha_example" id="captcha_example" src="<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>" onload="javascript: document.captcha_example.src = pics[document.store_settings.captcha_type.value].src;"></td>
113
			</tr>
114
		</table>
90 115
		<td>
91
			<select name="captcha_type" id="captcha_type" style="width: 98%;">
116
			<select name="captcha_type" id="captcha_type" onchange="load_captcha_image()" style="width: 98%;">
92 117
			<?php foreach($useable_captchas AS $key=>$text) {
93 118
				echo "<option value=\"$key\" ".($captcha_type==$key?'selected':'').">$text</option>";
94 119
			} ?>

Also available in: Unified diff