Revision 153
Added by ryan about 19 years ago
trunk/wb/modules/form/install.php | ||
---|---|---|
56 | 56 |
. ' `email_subject` VARCHAR(255) NOT NULL ,' |
57 | 57 |
. ' `success_message` TEXT NOT NULL ,' |
58 | 58 |
. ' `stored_submissions` INT NOT NULL,' |
59 |
. ' `max_submissions` INT NOT NULL,' |
|
60 |
. ' `use_captcha` INT NOT NULL,' |
|
59 |
. ' `max_submissions` INT NOT NULL,' |
|
61 | 60 |
. ' PRIMARY KEY ( `section_id` ) )' |
62 | 61 |
. ' '; |
63 | 62 |
$database->query($mod_form); |
trunk/wb/modules/form/modify_settings.php | ||
---|---|---|
124 | 124 |
<td class="setting_name"> |
125 | 125 |
<input type="text" name="stored_submissions" style="width: 100%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['stored_submissions'])); ?>" /> |
126 | 126 |
</td> |
127 |
</tr> |
|
128 |
<?php if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ ?> |
|
129 |
<tr> |
|
130 |
<td class="setting_name"><?php echo $TEXT['USE_CAPTCHA']; ?>:</td> |
|
131 |
<td class="setting_name"> |
|
132 |
<input type="radio" name="use_captcha" id="use_captcha_true" value="true"<?php if($setting['use_captcha'] == true) { echo ' checked'; } ?> /> |
|
133 |
<label for="use_captcha_true"><?php echo $TEXT['YES']; ?></label> |
|
134 |
<input type="radio" name="use_captcha" id="use_captcha_false" value="false"<?php if($setting['use_captcha'] == false) { echo ' checked'; } ?> /> |
|
135 |
<label for="use_captcha_false"><?php echo $TEXT['NO']; ?></label> |
|
136 |
</td> |
|
137 |
</tr> |
|
138 |
<?php } ?> |
|
127 |
</tr> |
|
139 | 128 |
</table> |
140 | 129 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
141 | 130 |
<tr> |
trunk/wb/modules/form/view.php | ||
---|---|---|
113 | 113 |
$query_settings = $database->query("SELECT header,field_loop,footer FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'"); |
114 | 114 |
if($query_settings->numRows() > 0) { |
115 | 115 |
$fetch_settings = $query_settings->fetchRow(); |
116 |
$header = $fetch_settings['header'];
|
|
116 |
$header = str_replace('{WB_URL}',WB_URL,$fetch_settings['header']);
|
|
117 | 117 |
$field_loop = $fetch_settings['field_loop']; |
118 |
$footer = $fetch_settings['footer'];
|
|
118 |
$footer = str_replace('{WB_URL}',WB_URL,$fetch_settings['footer']);
|
|
119 | 119 |
} else { |
120 | 120 |
$header = ''; |
121 | 121 |
$field_loop = ''; |
... | ... | |
249 | 249 |
} |
250 | 250 |
} |
251 | 251 |
|
252 |
// Captcha |
|
253 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
|
254 |
if(isset($_POST['captcha']) AND is_numeric($_POST['captcha']) AND strlen($_POST['captcha']) == 5) { |
|
255 |
// User-supplied captcha |
|
256 |
$user_captcha = $_POST['captcha']; |
|
257 |
// Computer generated |
|
258 |
if(isset($_SESSION['captcha'])) { |
|
259 |
$system_captcha = $_SESSION['captcha']; |
|
260 |
} |
|
261 |
// Check for a mismatch |
|
262 |
if($user_captcha != $system_captcha) { |
|
263 |
exit('Captcha mismatch'); |
|
264 |
} else { |
|
265 |
unset($_SESSION['captcha']); |
|
266 |
} |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
252 | 270 |
// Addslashes to email body - proposed by Icheb in topic=1170.0 |
253 | 271 |
// $email_body = $wb->add_slashes($email_body); |
254 | 272 |
|
trunk/wb/modules/form/save_settings.php | ||
---|---|---|
61 | 61 |
// Make sure max submissions is not smaller than stored submissions |
62 | 62 |
if($max_submissions < $stored_submissions) { |
63 | 63 |
$max_submissions = $stored_submissions; |
64 |
} |
|
65 |
// Use Captcha |
|
66 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
|
67 |
if(isset($_POST['use_captcha']) AND $_POST['use_captcha'] == "true") { |
|
68 |
$use_captcha = true; |
|
69 |
} else { |
|
70 |
$use_captcha = false; |
|
71 |
} |
|
72 |
} else { |
|
73 |
$use_captcha = false; |
|
74 | 64 |
} |
75 | 65 |
|
76 | 66 |
// Update settings |
77 |
$database->query("UPDATE ".TABLE_PREFIX."mod_form_settings SET header = '$header', field_loop = '$field_loop', footer = '$footer', email_to = '$email_to', email_from = '$email_from', email_subject = '$email_subject', success_message = '$success_message', max_submissions = '$max_submissions', stored_submissions = '$stored_submissions', use_captcha = '$use_captcha' WHERE section_id = '$section_id'");
|
|
67 |
$database->query("UPDATE ".TABLE_PREFIX."mod_form_settings SET header = '$header', field_loop = '$field_loop', footer = '$footer', email_to = '$email_to', email_from = '$email_from', email_subject = '$email_subject', success_message = '$success_message', max_submissions = '$max_submissions', stored_submissions = '$stored_submissions' WHERE section_id = '$section_id'"); |
|
78 | 68 |
|
79 | 69 |
// Check if there is a db error, otherwise say successful |
80 | 70 |
if($database->is_error()) { |
trunk/wb/modules/form/add.php | ||
---|---|---|
30 | 30 |
|
31 | 31 |
// Insert an extra rows into the database |
32 | 32 |
$header = '<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\">'; |
33 |
$field_loop = '<tr><td class=\"field_title\">{TITLE}{REQUIRED}:</td><td>{FIELD}</td></tr>'; |
|
34 |
$footer = '<tr><td> </td> |
|
35 |
<td> |
|
36 |
<input type=\"submit\" name=\"submit\" value=\"Submit Form\" /> |
|
37 |
</td> |
|
38 |
</tr> |
|
33 |
$field_loop = '<tr><td class=\"field_title\">{TITLE}{REQUIRED}:</td><td>{FIELD}</td></tr>'; |
|
34 |
$footer = ''; |
|
35 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
|
36 |
$footer .= '<tr><td class=\"field_title\">Verification:</td><td> |
|
37 |
<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\"> |
|
38 |
<tr><td><img src=\"{WB_URL}/include/captcha.php\" alt=\"Captcha\" /></td> |
|
39 |
<td><input type=\"text\" name=\"captcha\" maxlength=\"5\" /></td> |
|
40 |
</tr></table> |
|
41 |
</td></tr> |
|
42 |
'; |
|
43 |
} |
|
44 |
$footer .= '<tr><td> </td> |
|
45 |
<td> |
|
46 |
<input type=\"submit\" name=\"submit\" value=\"Submit Form\" /> |
|
47 |
</td> |
|
48 |
</tr> |
|
39 | 49 |
</table>'; |
40 | 50 |
$email_to = $admin->get_email(); |
41 | 51 |
$email_from = ''; |
... | ... | |
43 | 53 |
$success_message = 'Thank-you.'; |
44 | 54 |
$max_submissions = 50; |
45 | 55 |
$stored_submissions = 100; |
46 |
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')) { /* Make's sure GD library is installed */ |
|
47 |
$use_captcha = true; |
|
48 |
} else { |
|
49 |
$use_captcha = false; |
|
50 |
} |
|
51 | 56 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_settings (page_id,section_id,header,field_loop,footer,email_to,email_from,email_subject,success_message,max_submissions,stored_submissions,use_captcha) VALUES ('$page_id','$section_id','$header','$field_loop','$footer','$email_to','$email_from','$email_subject','$success_message','$max_submissions','$stored_submissions','$use_captcha')"); |
52 | 57 |
|
53 | 58 |
?> |
Also available in: Unified diff
Updated Captcha code