Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         captcha_control
6
 * @author          Independend-Software-Team
7
 * @author          WebsiteBaker Project
8
 * @copyright       2004-2009, Ryan Djurovich
9
 * @copyright       2009-2011, Website Baker Org. e.V.
10
 * @link            http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13
 * @requirements    PHP 5.2.2 and higher
14
 * @version         $Id: tool.php 1477 2011-07-21 02:47:28Z Luisehahne $
15
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/captcha_control/tool.php $
16
 * @lastmodified    $Date: 2011-07-21 04:47:28 +0200 (Thu, 21 Jul 2011) $
17
 *
18
 */
19

    
20
// Must include code to stop this file being access directly
21
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
22

    
23
// check if module language file exists for the language set by the user (e.g. DE, EN)
24
if(!file_exists(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
25
	// no module language file exists for the language set by the user, include default module language file EN.php
26
	require_once(WB_PATH .'/modules/captcha_control/languages/EN.php');
27
} else {
28
	// a module language file exists for the language defined by the user, load it
29
	require_once(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php');
30
}
31

    
32
$table = TABLE_PREFIX.'mod_captcha_control';
33
$js_back = ADMIN_URL.'/admintools/tool.php?tool=captcha_control';
34

    
35
// check if data was submitted
36
if(isset($_POST['save_settings'])) {
37
	if (!$admin->checkFTAN())
38
	{
39
		if(!$admin_header) { $admin->print_header(); }
40
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
41
	}
42
	
43
	// get configuration settings
44
	$enabled_captcha = ($_POST['enabled_captcha'] == '1') ? '1' : '0';
45
	$enabled_asp = ($_POST['enabled_asp'] == '1') ? '1' : '0';
46
	$captcha_type = $admin->add_slashes($_POST['captcha_type']);
47
	
48
	// update database settings
49
	$database->query("UPDATE $table SET
50
		enabled_captcha = '$enabled_captcha',
51
		enabled_asp = '$enabled_asp',
52
		captcha_type = '$captcha_type'
53
	");
54

    
55
	// save text-captchas
56
	if($captcha_type == 'text') { // ct_text
57
		$text_qa=$admin->add_slashes($_POST['text_qa']);
58
		if(!preg_match('/### .*? ###/', $text_qa)) {
59
			$database->query("UPDATE $table SET ct_text = '$text_qa'");
60
		}
61
	}
62
	
63
	// check if there is a database error, otherwise say successful
64
	if(!$admin_header) { $admin->print_header(); }
65
	if($database->is_error()) {
66
		$admin->print_error($database->get_error(), $js_back);
67
	} else {
68
		$admin->print_success($MESSAGE['PAGES']['SAVED'], $js_back);
69
	}
70

    
71
} else {
72
}
73
	
74
	// include captcha-file
75
	require_once(WB_PATH .'/include/captcha/captcha.php');
76

    
77
	// load text-captchas
78
	$text_qa='';
79
	if($query = $database->query("SELECT ct_text FROM $table")) {
80
		$data = $query->fetchRow();
81
		$text_qa = $data['ct_text'];
82
	}
83
	if($text_qa == '')
84
		$text_qa = $MOD_CAPTCHA_CONTROL['CAPTCHA_TEXT_DESC'];
85

    
86
// script to load image
87
?>
88
<script type="text/javascript">
89
	var pics = new Array();
90

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

    
94
	pics["calc_image"] = new Image();
95
	pics["calc_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_image.png'?>";
96

    
97
	pics["calc_ttf_image"] = new Image();
98
	pics["calc_ttf_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_ttf_image.png'?>";
99

    
100
	pics["old_image"] = new Image();
101
	pics["old_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/old_image.png'?>";
102
	
103
	pics["calc_text"] = new Image();
104
	pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>";
105
	
106
	pics["text"] = new Image();
107
	pics["text"].src = "<?php echo WB_URL.'/include/captcha/captchas/text.png'?>";
108

    
109
	function load_captcha_image() {
110
		document.captcha_example.src = pics[document.store_settings.captcha_type.value].src;
111
		toggle_text_qa();
112
	}
113
	
114
	function toggle_text_qa() {
115
		if(document.store_settings.captcha_type.value == 'text' ) {
116
			document.getElementById('text_qa').style.display = '';
117
		} else {
118
			document.getElementById('text_qa').style.display = 'none';
119
		}
120
	}
121

    
122
</script>
123
<?php
124

    
125
	// connect to database and read out captcha settings
126
	if($query = $database->query("SELECT * FROM $table")) {
127
		$data = $query->fetchRow();
128
		$enabled_captcha = $data['enabled_captcha'];
129
		$enabled_asp = $data['enabled_asp'];
130
		$captcha_type = $data['captcha_type'];
131
	} else {
132
		// something went wrong, use dummy value
133
		$enabled_captcha = '1';
134
		$enabled_asp = '1';
135
		$captcha_type = 'calc_text';
136
	}
137
		
138
	// write out heading
139
	echo '<h2>' .$MOD_CAPTCHA_CONTROL['HEADING'] .'</h2>';
140

    
141
	// output the form with values from the database
142
	echo '<p>' .$MOD_CAPTCHA_CONTROL['HOWTO'] .'</p>';
143
?>
144
<form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
145
	<?php echo $admin->getFTAN(); ?>
146
	<table width="98%" cellspacing="0" border="0" cellpadding="5px" class="row_a">
147
	<tr><td colspan="2"><strong><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_CONF'];?>:</strong></td></tr>
148
	<tr>
149
		<td width="30%"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
150
		<td>
151
		<select name="captcha_type" id="captcha_type" onchange="load_captcha_image()" style="width: 98%;">
152
			<?php foreach($useable_captchas AS $key=>$text) {
153
			echo "<option value=\"$key\" ".($captcha_type==$key ? ' selected="selected"' : '').">$text</option>";
154
			} ?>
155
		</select>
156
		</td>
157
	</tr>
158
	<tr>
159
		<td>&nbsp;</td>
160
		<td align="left" width="150px">
161
            <img alt="captcha_example" id="captcha_example" src="<?php echo WB_URL.'/include/captcha/captchas/'.$captcha_type.'.png'?>" />
162
        </td>
163
	</tr>
164
	<tr id="text_qa" style="display:<?php if($captcha_type=='text') echo ''; else echo 'none'; ;?>;">
165
		<td valign="top" class="setting_name"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT'];?>:</td>
166
		<td class="setting_value" colspan="2">
167
			<textarea name="text_qa" cols="60" rows="10"><?php echo $text_qa; ?></textarea>
168
		</td>
169
	</tr>
170
	<tr>
171
		<td><?php echo $MOD_CAPTCHA_CONTROL['USE_SIGNUP_CAPTCHA'];?>:</td>
172
		<td>
173
			<input type="radio" <?php echo ($enabled_captcha=='1') ?'checked="checked"' :'';?>
174
				name="enabled_captcha" value="1" /><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
175
			<input type="radio" <?php echo ($enabled_captcha=='0') ?'checked="checked"' :'';?>
176
				name="enabled_captcha" value="0" /><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
177
		</td>
178
	</tr>
179
	<tr><td>&nbsp;</td><td style="font-size:smaller;"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_EXP'];?></td></tr>
180
	<tr><td colspan="2"><br /><strong><?php echo $MOD_CAPTCHA_CONTROL['ASP_CONF'];?>:</strong></td></tr>
181
	<tr>
182
		<td><?php echo $MOD_CAPTCHA_CONTROL['ASP_TEXT'];?>:</td>
183
		<td>
184
			<input type="radio" <?php echo ($enabled_asp=='1') ?'checked="checked"' :'';?>
185
				name="enabled_asp" value="1" /><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
186
			<input type="radio" <?php echo ($enabled_asp=='0') ?'checked="checked"' :'';?>
187
				name="enabled_asp" value="0" /><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
188
		</td>
189
	</tr>
190
	<tr>
191
        <td>&nbsp;</td>
192
        <td style="font-size:smaller;"><?php echo $MOD_CAPTCHA_CONTROL['ASP_EXP'];?></td>
193
    </tr>
194
	</table>
195
	<input type="submit" name="save_settings" style="margin-top:10px; width:140px;" value="<?php echo $TEXT['SAVE']; ?>" />
196
</form>
(5-5/6)