Project

General

Profile

1
<?php
2

    
3
// $Id$
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, Ryan Djurovich
9

    
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
// direct access prevention
27
defined('WB_PATH') OR die(header('Location: ../index.php'));
28

    
29
// check if module language file exists for the language set by the user (e.g. DE, EN)
30
if(!file_exists(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
31
	// no module language file exists for the language set by the user, include default module language file EN.php
32
	require_once(WB_PATH .'/modules/captcha_control/languages/EN.php');
33
} else {
34
	// a module language file exists for the language defined by the user, load it
35
	require_once(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php');
36
}
37

    
38
$table = TABLE_PREFIX.'mod_captcha_control';
39

    
40
// check if data was submitted
41
if(isset($_POST['save_settings'])) {
42
	// get configuration settings
43
	$enabled_captcha = ($_POST['enabled_captcha'] == '1') ? '1' : '0';
44
	$enabled_asp = ($_POST['enabled_asp'] == '1') ? '1' : '0';
45
	$captcha_type = $admin->add_slashes($_POST['captcha_type']);
46
	
47
	// update database settings
48
	$database->query("UPDATE $table SET
49
		enabled_captcha = '$enabled_captcha',
50
		enabled_asp = '$enabled_asp',
51
		captcha_type = '$captcha_type'
52
	");
53

    
54
	// check if there is a database error, otherwise say successful
55
	if($database->is_error()) {
56
		$admin->print_error($database->get_error(), $js_back);
57
	} else {
58
		$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/admintools/tool.php?tool=captcha_control');
59
	}
60

    
61
} else {
62
	
63
	// include captcha-file
64
	require_once(WB_PATH .'/include/captcha/captcha.php');
65

    
66
	// connect to database and read out captcha settings
67
	if($query = $database->query("SELECT * FROM $table")) {
68
		$data = $query->fetchRow();
69
		$enabled_captcha = $data['enabled_captcha'];
70
		$enabled_asp = $data['enabled_asp'];
71
		$captcha_type = $admin->strip_slashes($data['captcha_type']);
72
	} else {
73
		// something went wrong, use dummy value
74
		$enabled_captcha = '1';
75
		$enabled_asp = '1';
76
		$captcha_type = 'calc_text';
77
	}
78
		
79
	// write out heading
80
	echo '<h2>' .$MOD_CAPTCHA_CONTROL['HEADING'] .'</h2>';
81

    
82
	// output the form with values from the database
83
	echo '<p>' .$MOD_CAPTCHA_CONTROL['HOWTO'] .'</p>';
84
?>
85
<form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
86
	<table width="98%" cellspacing="0" cellpadding="5px" class="row_a">
87
	<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>
90
		<td>
91
			<select name="captcha_type" id="captcha_type" style="width: 98%;">
92
			<?php foreach($useable_captchas AS $key=>$text) {
93
				echo "<option value=\"$key\" ".($captcha_type==$key?'selected':'').">$text</option>";
94
			} ?>
95
		</select>
96
		</td>
97
	</tr>
98
	<tr>
99
		<td><?php echo $MOD_CAPTCHA_CONTROL['USE_SIGNUP_CAPTCHA'];?>:</td>
100
		<td>
101
			<input type="radio" <?php echo ($enabled_captcha=='1') ?'checked="checked"' :'';?>
102
				name="enabled_captcha" value="1"><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
103
			<input type="radio" <?php echo ($enabled_captcha=='0') ?'checked="checked"' :'';?>
104
				name="enabled_captcha" value="0"><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
105
		</td>
106
	</tr>
107
	<tr><td colspan="2"><br /><strong><?php echo $MOD_CAPTCHA_CONTROL['ASP_CONF'];?>:</strong></td></tr>
108
	<tr>
109
		<td><?php echo $MOD_CAPTCHA_CONTROL['ASP_TEXT'];?>:</td>
110
		<td>
111
			<input type="radio" <?php echo ($enabled_asp=='1') ?'checked="checked"' :'';?>
112
				name="enabled_asp" value="1"><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
113
			<input type="radio" <?php echo ($enabled_asp=='0') ?'checked="checked"' :'';?>
114
				name="enabled_asp" value="0"><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
115
		</td>
116
	</tr>
117
	</table>
118
	<input type="submit" name="save_settings" style="margin-top:10px; width:140px;" value="<?php echo $TEXT['SAVE']; ?>" />
119
</form>
120
<?php
121
}
122

    
123
?>
(4-4/5)