Revision 1553
Added by Luisehahne almost 14 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
|
| 13 | 13 |
=========================== add small Features 2.8.2 ========================== |
| 14 |
31 Dez-2011 Build 1553 Dietmar Woellbrink (Luisehahne) |
|
| 15 |
! recoded formmodul, add dropdown email_fromname_field |
|
| 14 | 16 |
31 Dez-2011 Build 1552 Dietmar Woellbrink (Luisehahne) |
| 15 | 17 |
# fix mdcr.js $scriptLink to absolute url |
| 16 | 18 |
! change separator breadcrumb admintools |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 52 | 52 |
|
| 53 | 53 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 54 | 54 |
if(!defined('VERSION')) define('VERSION', '2.8.2');
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1552');
|
|
| 55 |
if(!defined('REVISION')) define('REVISION', '1553');
|
|
| 56 | 56 |
if(!defined('SP')) define('SP', 'SP2');
|
| branches/2.8.x/wb/modules/form/modify_field.php | ||
|---|---|---|
| 22 | 22 |
$update_when_modified = false; |
| 23 | 23 |
// Include WB admin wrapper script |
| 24 | 24 |
require(WB_PATH.'/modules/admin.php'); |
| 25 |
|
|
| 26 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 25 | 27 |
/* */ |
| 26 | 28 |
// Get id |
| 27 |
$field_id = $admin->checkIDKEY('field_id', false, 'GET');
|
|
| 29 |
$field_id = intval($admin->checkIDKEY('field_id', false, 'GET'));
|
|
| 28 | 30 |
if (!$field_id) {
|
| 29 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']." MF: $field_id :-(", ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
|
| 31 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 30 | 32 |
} |
| 33 |
// load module language file |
|
| 34 |
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php'; |
|
| 35 |
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang ); |
|
| 31 | 36 |
|
| 37 |
$type = 'none'; |
|
| 32 | 38 |
// Get header and footer |
| 33 |
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE field_id = '$field_id'");
|
|
| 34 |
$form = $query_content->fetchRow(); |
|
| 35 |
$type = $form['type']; |
|
| 36 |
if($type == '') {
|
|
| 37 |
$type = 'none'; |
|
| 39 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 40 |
$sql .= 'WHERE `field_id` = '.$field_id.''; |
|
| 41 |
$sql .= ''; |
|
| 42 |
if($query_content = $database->query($sql)) {
|
|
| 43 |
$form = $query_content->fetchRow(MYSQL_ASSOC); |
|
| 44 |
$type = (($form['type'] == '') ? 'none' : $form['type']); |
|
| 38 | 45 |
} |
| 39 |
|
|
| 40 |
// set new token |
|
| 46 |
// set new idkey for save_field |
|
| 41 | 47 |
$field_id = $admin->getIDKEY($form['field_id']); |
| 42 | 48 |
// Set raw html <'s and >'s to be replaced by friendly html code |
| 43 | 49 |
$raw = array('<', '>');
|
| 44 | 50 |
$friendly = array('<', '>');
|
| 45 | 51 |
?> |
| 46 | 52 |
|
| 47 |
<form name="modify" action="<?php echo WB_URL; ?>/modules/form/save_field.php" method="post" style="margin: 0;"> |
|
| 53 |
<form name="modify" action="<?php echo WB_URL; ?>/modules/form/save_field_new.php" method="post" style="margin: 0;">
|
|
| 48 | 54 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" /> |
| 49 | 55 |
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" /> |
| 50 | 56 |
<input type="hidden" name="field_id" value="<?php echo $field_id; ?>" /> |
| 51 | 57 |
<?php echo $admin->getFTAN(); ?> |
| 52 | 58 |
|
| 53 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%"> |
|
| 59 |
<table summary="" class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
|
|
| 54 | 60 |
<tr> |
| 55 | 61 |
<td colspan="2"><strong><?php echo $TEXT['MODIFY'].' '.$TEXT['FIELD']; ?></strong></td> |
| 56 | 62 |
</tr> |
| ... | ... | |
| 66 | 72 |
<select name="type" style="width: 98%;"> |
| 67 | 73 |
<option value=""><?php echo $TEXT['PLEASE_SELECT']; ?>...</option> |
| 68 | 74 |
<option value="heading"<?php if($type == 'heading') { echo ' selected="selected"'; } ?>><?php echo $TEXT['HEADING']; ?></option>
|
| 69 |
<option value="textfield"<?php if($type == 'textfield') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SHORT'].' '.$TEXT['TEXT']; ?> (Textfield)</option>
|
|
| 70 |
<option value="textarea"<?php if($type == 'textarea') { echo ' selected="selected"'; } ?>><?php echo $TEXT['LONG'].' '.$TEXT['TEXT']; ?> (Textarea)</option>
|
|
| 71 |
<option value="select"<?php if($type == 'select') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SELECT_BOX']; ?></option>
|
|
| 72 |
<option value="checkbox"<?php if($type == 'checkbox') { echo ' selected="selected"'; } ?>><?php echo $TEXT['CHECKBOX_GROUP']; ?></option>
|
|
| 73 |
<option value="radio"<?php if($type == 'radio') { echo ' selected="selected"'; } ?>><?php echo $TEXT['RADIO_BUTTON_GROUP']; ?></option>
|
|
| 75 |
<option value="textfield"<?php if($type == 'textfield') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SHORT'].' '.$TEXT['TEXT']; ?> (input)</option>
|
|
| 76 |
<option value="textarea"<?php if($type == 'textarea') { echo ' selected="selected"'; } ?>><?php echo $TEXT['LONG'].' '.$TEXT['TEXT']; ?> (textarea)</option>
|
|
| 77 |
<option value="select"<?php if($type == 'select') { echo ' selected="selected"'; } ?>><?php echo $TEXT['SELECT_BOX']; ?> (select)</option>
|
|
| 78 |
<option value="checkbox"<?php if($type == 'checkbox') { echo ' selected="selected"'; } ?>><?php echo $TEXT['CHECKBOX_GROUP']; ?> (checkbox)</option>
|
|
| 79 |
<option value="radio"<?php if($type == 'radio') { echo ' selected="selected"'; } ?>><?php echo $TEXT['RADIO_BUTTON_GROUP']; ?> (radiobox)</option>
|
|
| 74 | 80 |
<option value="email"<?php if($type == 'email') { echo ' selected="selected"'; } ?>><?php echo $TEXT['EMAIL_ADDRESS']; ?></option>
|
| 75 | 81 |
</select> |
| 76 | 82 |
</td> |
| ... | ... | |
| 107 | 113 |
<tr> |
| 108 | 114 |
<td valign="top"><?php echo $TEXT['LIST_OPTIONS']; ?>:</td> |
| 109 | 115 |
<td> |
| 116 |
<table summary="<?php echo $TEXT['LIST_OPTIONS']; ?>" cellpadding="3" cellspacing="0" width="100%" border="0"> |
|
| 110 | 117 |
<?php |
| 111 | 118 |
$option_count = 0; |
| 112 | 119 |
$list = explode(',', $form['value']);
|
| 113 | 120 |
foreach($list AS $option_value) {
|
| 114 | 121 |
$option_count = $option_count+1; |
| 115 | 122 |
?> |
| 116 |
<table cellpadding="3" cellspacing="0" width="100%" border="0"> |
|
| 117 | 123 |
<tr> |
| 118 | 124 |
<td width="70"><?php echo $TEXT['OPTION'].' '.$option_count; ?>:</td> |
| 119 | 125 |
<td> |
| 120 | 126 |
<input type="text" name="value<?php echo $option_count; ?>" value="<?php echo $option_value; ?>" style="width: 250px;" /> |
| 121 | 127 |
</td> |
| 122 | 128 |
</tr> |
| 123 |
</table> |
|
| 124 | 129 |
<?php |
| 125 | 130 |
} |
| 126 | 131 |
for($i = 0; $i < 2; $i++) {
|
| 127 | 132 |
$option_count = $option_count+1; |
| 128 | 133 |
?> |
| 129 |
<table cellpadding="3" cellspacing="0" width="100%" border="0"> |
|
| 130 | 134 |
<tr> |
| 131 | 135 |
<td width="70"><?php echo $TEXT['OPTION'].' '.$option_count; ?>:</td> |
| 132 | 136 |
<td> |
| 133 | 137 |
<input type="text" name="value<?php echo $option_count; ?>" value="" style="width: 250px;" /> |
| 134 | 138 |
</td> |
| 135 | 139 |
</tr> |
| 136 |
</table> |
|
| 137 | 140 |
<?php |
| 138 | 141 |
} |
| 139 | 142 |
?> |
| 143 |
</table> |
|
| 140 | 144 |
<input type="hidden" name="list_count" value="<?php echo $option_count; ?>" /> |
| 141 | 145 |
</td> |
| 142 | 146 |
</tr> |
| ... | ... | |
| 190 | 194 |
<?php } ?> |
| 191 | 195 |
</table> |
| 192 | 196 |
|
| 193 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
| 197 |
<table summary="" cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
| 194 | 198 |
<tr> |
| 195 | 199 |
<td align="left"> |
| 196 | 200 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" /> |
| ... | ... | |
| 200 | 204 |
if ($type<>'none') {
|
| 201 | 205 |
?> |
| 202 | 206 |
<td align="center"> |
| 203 |
<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['FIELD']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/add_field.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>';" style="width: 200px; margin-top: 5px;" /> |
|
| 207 |
<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['FIELD']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/form/add_field.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 200px; margin-top: 5px;" />
|
|
| 204 | 208 |
</td> |
| 205 | 209 |
<?php } |
| 206 | 210 |
// end addition |
| 207 | 211 |
?> |
| 208 | 212 |
<td align="right"> |
| 209 |
<input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" /> |
|
| 213 |
<input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id.$sec_anchor; ?>';" style="width: 100px; margin-top: 5px;" />
|
|
| 210 | 214 |
</td> |
| 211 | 215 |
</tr> |
| 212 | 216 |
</table> |
| branches/2.8.x/wb/modules/form/add_field.php | ||
|---|---|---|
| 20 | 20 |
// Include WB admin wrapper script |
| 21 | 21 |
require(WB_PATH.'/modules/admin.php'); |
| 22 | 22 |
|
| 23 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 24 |
|
|
| 23 | 25 |
// Include the ordering class |
| 24 | 26 |
require(WB_PATH.'/framework/class.order.php'); |
| 25 | 27 |
// Get new order |
| branches/2.8.x/wb/modules/form/save_field.php | ||
|---|---|---|
| 25 | 25 |
require(WB_PATH.'/modules/admin.php'); |
| 26 | 26 |
/* */ |
| 27 | 27 |
|
| 28 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 29 |
|
|
| 28 | 30 |
// check FTAN |
| 29 | 31 |
if (!$admin->checkFTAN()) |
| 30 | 32 |
{
|
| 31 | 33 |
$admin->print_header(); |
| 32 |
$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
|
| 34 |
$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 33 | 35 |
} |
| 34 |
// After check print the header |
|
| 35 |
$admin->print_header(); |
|
| 36 | 36 |
|
| 37 |
|
|
| 38 |
/* */ |
|
| 39 | 37 |
// Get id |
| 40 | 38 |
$field_id = intval($admin->checkIDKEY('field_id', false ));
|
| 41 | 39 |
if (!$field_id) {
|
| 42 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'].'::', ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
| 40 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'].'::', ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 43 | 41 |
} |
| 42 |
// After check print the header to get a new FTAN |
|
| 43 |
$admin->print_header(); |
|
| 44 |
|
|
| 44 | 45 |
/* |
| 45 | 46 |
// Get id |
| 46 | 47 |
if(!isset($_POST['field_id']) OR !is_numeric($_POST['field_id'])) {
|
| ... | ... | |
| 69 | 70 |
$value = ''; |
| 70 | 71 |
|
| 71 | 72 |
// Update row |
| 72 |
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET title = '$title', type = '$type', required = '$required' WHERE field_id = '$field_id'");
|
|
| 73 |
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_form_fields SET` '; |
|
| 74 |
$sql .= 'title = \''.$title.'\', '; |
|
| 75 |
$sql .= 'type = \''.$type.'\', '; |
|
| 76 |
$sql .= 'required = \''.$required.'\' '; |
|
| 77 |
$sql .= 'WHERE field_id = '.(int)$field_id.' '; |
|
| 78 |
if($database->query($sql)) { }
|
|
| 73 | 79 |
|
| 74 | 80 |
// If field type has multiple options, get all values and implode them |
| 75 | 81 |
$list_count = $admin->get_post('list_count');
|
| ... | ... | |
| 93 | 99 |
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '$value', extra = '' WHERE field_id = '$field_id'");
|
| 94 | 100 |
} elseif($admin->get_post('type') == 'heading') {
|
| 95 | 101 |
$extra = str_replace(array("[[", "]]"), '', $admin->get_post('template'));
|
| 96 |
if(trim($extra) == '') $extra = '<tr><td class="field_heading" colspan="2">{TITLE}{FIELD}</td></tr>';
|
|
| 102 |
if(trim($extra) == '') $extra = '<tr><td class="frm-field_heading" colspan="2">{TITLE}{FIELD}</td></tr>';
|
|
| 97 | 103 |
$extra = $admin->add_slashes($extra); |
| 98 | 104 |
$database->query("UPDATE ".TABLE_PREFIX."mod_form_fields SET value = '', extra = '$extra' WHERE field_id = '$field_id'");
|
| 99 | 105 |
} elseif($admin->get_post('type') == 'select') {
|
| branches/2.8.x/wb/modules/form/delete_field.php | ||
|---|---|---|
| 22 | 22 |
require(WB_PATH.'/modules/admin.php'); |
| 23 | 23 |
|
| 24 | 24 |
// Get id |
| 25 |
$field_id = $admin->checkIDKEY('field_id', false, 'GET');
|
|
| 25 |
$field_id = intval($admin->checkIDKEY('field_id', false, 'GET'));
|
|
| 26 | 26 |
if (!$field_id) {
|
| 27 | 27 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 31 |
|
|
| 30 | 32 |
// Delete row |
| 31 | 33 |
$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_fields WHERE field_id = '$field_id'");
|
| 32 | 34 |
|
| ... | ... | |
| 36 | 38 |
// Create new order object an reorder |
| 37 | 39 |
$order = new order(TABLE_PREFIX.'mod_form_fields', 'position', 'field_id', 'section_id'); |
| 38 | 40 |
|
| 39 |
if($order->clean($section_id)) {
|
|
| 40 |
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
| 41 |
if(!$order->clean($section_id)) {
|
|
| 42 |
$admin->print_error($database->get_error(), ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 41 | 43 |
} else {
|
| 42 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
| 44 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 43 | 45 |
} |
| 44 | 46 |
|
| 45 | 47 |
// Print admin footer |
| branches/2.8.x/wb/modules/form/modify_settings.php | ||
|---|---|---|
| 30 | 30 |
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php'; |
| 31 | 31 |
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang ); |
| 32 | 32 |
|
| 33 |
// Get header and footer |
|
| 34 |
$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
|
|
| 35 |
$setting = $query_content->fetchRow(); |
|
| 33 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 36 | 34 |
|
| 35 |
// Get Settings from DB |
|
| 36 |
$sql = 'SELECT * FROM '.TABLE_PREFIX.'mod_form_settings '; |
|
| 37 |
$sql .= 'WHERE `section_id` = '.(int)$section_id.''; |
|
| 38 |
if($query_content = $database->query($sql)) {
|
|
| 39 |
$setting = $query_content->fetchRow(MYSQL_ASSOC); |
|
| 40 |
$setting['email_to'] = ($setting['email_to'] != '' ? $setting['email_to'] : SERVER_EMAIL); |
|
| 41 |
$setting['email_subject'] = ($setting['email_subject'] != '') ? $setting['email_subject'] : $MOD_FORM['EMAIL_SUBJECT']; |
|
| 42 |
$setting['success_email_subject'] = ($setting['success_email_subject'] != '') ? $setting['success_email_subject'] : $MOD_FORM['SUCCESS_EMAIL_SUBJECT']; |
|
| 43 |
$setting['success_email_from'] = ($setting['success_email_from'] != '' ? $setting['success_email_from'] : SERVER_EMAIL); |
|
| 44 |
$setting['success_email_fromname'] = ($setting['success_email_fromname'] != '' ? $setting['success_email_fromname'] : WBMAILER_DEFAULT_SENDERNAME); |
|
| 45 |
$setting['success_email_subject'] = ($setting['success_email_subject'] != '') ? $setting['success_email_subject'] : $MOD_FORM['SUCCESS_EMAIL_SUBJECT']; |
|
| 46 |
|
|
| 47 |
} |
|
| 48 |
|
|
| 37 | 49 |
// Set raw html <'s and >'s to be replace by friendly html code |
| 38 | 50 |
$raw = array('<', '>');
|
| 39 | 51 |
$friendly = array('<', '>');
|
| ... | ... | |
| 62 | 74 |
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" /> |
| 63 | 75 |
<?php echo $admin->getFTAN(); ?> |
| 64 | 76 |
|
| 65 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%"> |
|
| 77 |
<table summary="" class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
|
|
| 66 | 78 |
<tr> |
| 67 | 79 |
<td colspan="2"><strong><?php echo $HEADING['GENERAL_SETTINGS']; ?></strong></td> |
| 68 | 80 |
</tr> |
| 69 | 81 |
<tr> |
| 70 |
<td class="setting_name"><?php echo $TEXT['CAPTCHA_VERIFICATION']; ?>:</td> |
|
| 82 |
<td class="frm-setting_name"><?php echo $TEXT['CAPTCHA_VERIFICATION']; ?>:</td>
|
|
| 71 | 83 |
<td> |
| 72 | 84 |
<input type="radio" name="use_captcha" id="use_captcha_true" value="1"<?php if($setting['use_captcha'] == true) { echo ' checked="checked"'; } ?> />
|
| 73 | 85 |
<label for="use_captcha_true"><?php echo $TEXT['ENABLED']; ?></label> |
| ... | ... | |
| 76 | 88 |
</td> |
| 77 | 89 |
</tr> |
| 78 | 90 |
<tr> |
| 79 |
<td class="setting_name"><?php echo $TEXT['MAX_SUBMISSIONS_PER_HOUR']; ?>:</td> |
|
| 80 |
<td class="setting_value"> |
|
| 91 |
<td class="frm-setting_name"><?php echo $TEXT['MAX_SUBMISSIONS_PER_HOUR']; ?>:</td>
|
|
| 92 |
<td class="frm-setting_value">
|
|
| 81 | 93 |
<input type="text" name="max_submissions" style="width: 30px;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['max_submissions'])); ?>" /> |
| 82 | 94 |
</td> |
| 83 | 95 |
</tr> |
| 84 | 96 |
<tr> |
| 85 |
<td class="setting_name"><?php echo $TEXT['SUBMISSIONS_STORED_IN_DATABASE']; ?>:</td> |
|
| 86 |
<td class="setting_value"> |
|
| 97 |
<td class="frm-setting_name"><?php echo $TEXT['SUBMISSIONS_STORED_IN_DATABASE']; ?>:</td>
|
|
| 98 |
<td class="frm-setting_value">
|
|
| 87 | 99 |
<input type="text" name="stored_submissions" style="width: 30px;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['stored_submissions'])); ?>" /> |
| 88 | 100 |
</td> |
| 89 | 101 |
</tr> |
| 90 | 102 |
<tr> |
| 91 |
<td class="setting_name"><?php echo $TEXT['HEADER']; ?>:</td> |
|
| 92 |
<td class="setting_value"> |
|
| 103 |
<td class="frm-setting_name"><?php echo $TEXT['HEADER']; ?>:</td>
|
|
| 104 |
<td class="frm-setting_value">
|
|
| 93 | 105 |
<textarea name="header" cols="80" rows="6" style="width: 98%; height: 80px;"><?php echo ($setting['header']); ?></textarea> |
| 94 | 106 |
</td> |
| 95 | 107 |
</tr> |
| 96 | 108 |
<tr> |
| 97 |
<td class="setting_name"><?php echo $TEXT['FIELD'].' '.$TEXT['LOOP']; ?>:</td> |
|
| 98 |
<td class="setting_value"> |
|
| 109 |
<td class="frm-setting_name"><?php echo $TEXT['FIELD'].' '.$TEXT['LOOP']; ?>:</td>
|
|
| 110 |
<td class="frm-setting_value">
|
|
| 99 | 111 |
<textarea name="field_loop" cols="80" rows="6" style="width: 98%; height: 80px;"><?php echo ($setting['field_loop']); ?></textarea> |
| 100 | 112 |
</td> |
| 101 | 113 |
</tr> |
| 102 | 114 |
<tr> |
| 103 |
<td class="setting_name"><?php echo $TEXT['FOOTER']; ?>:</td> |
|
| 104 |
<td class="setting_value"> |
|
| 115 |
<td class="frm-setting_name"><?php echo $TEXT['FOOTER']; ?>:</td>
|
|
| 116 |
<td class="frm-setting_value">
|
|
| 105 | 117 |
<textarea name="footer" cols="80" rows="6" style="width: 98%; height: 80px;"><?php echo str_replace($raw, $friendly, ($setting['footer'])); ?></textarea> |
| 106 | 118 |
</td> |
| 107 | 119 |
</tr> |
| 108 | 120 |
</table> |
| 109 |
|
|
| 110 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%" style="margin-top: 3px;"> |
|
| 121 |
<!-- E-Mail Optionen --> |
|
| 122 |
<table summary="<?php echo $TEXT['EMAIL'].' '.$TEXT['SETTINGS']; ?>" class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%" style="margin-top: 3px;">
|
|
| 111 | 123 |
<tr> |
| 112 | 124 |
<td colspan="2"><strong><?php echo $TEXT['EMAIL'].' '.$TEXT['SETTINGS']; ?></strong></td> |
| 113 | 125 |
</tr> |
| 114 | 126 |
<tr> |
| 115 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['TO']; ?>:</td>
|
|
| 116 |
<td class="setting_value"> |
|
| 127 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$MOD_TEXT['TO']; ?>:</td>
|
|
| 128 |
<td class="frm-setting_value">
|
|
| 117 | 129 |
<input type="text" name="email_to" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['email_to'])); ?>" /> |
| 118 | 130 |
</td> |
| 119 | 131 |
</tr> |
| 120 | 132 |
<tr> |
| 121 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['FROM']; ?>:</td>
|
|
| 122 |
<td class="setting_value"> |
|
| 133 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$MOD_TEXT['FROM']; ?>:</td>
|
|
| 134 |
<td class="frm-setting_value">
|
|
| 123 | 135 |
<select name="email_from_field" style="width: 98%;"> |
| 124 | 136 |
<option value="" onclick="javascript: document.getElementById('email_from').style.display = 'block';"><?php echo $TEXT['CUSTOM']; ?>:</option>
|
| 125 | 137 |
<?php |
| 138 |
$selected = false; |
|
| 126 | 139 |
$email_from_value = str_replace($raw, $friendly, ($setting['email_from'])); |
| 127 |
$query_email_fields = $database->query("SELECT field_id,title FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' AND ( type = 'textfield' OR type = 'email' ) ORDER BY position ASC");
|
|
| 128 |
if($query_email_fields->numRows() > 0) {
|
|
| 129 |
while($field = $query_email_fields->fetchRow()) {
|
|
| 130 |
?> |
|
| 131 |
<option value="field<?php echo $field['field_id']; ?>"<?php if($email_from_value == 'field'.$field['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
|
|
| 132 |
<?php echo $TEXT['FIELD'].': '.$field['title']; ?> |
|
| 133 |
</option> |
|
| 134 |
<?php |
|
| 140 |
// $query_email_fields = $database->query("SELECT field_id,title FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' AND ( type = 'textfield' OR type = 'email' ) ORDER BY position ASC");
|
|
| 141 |
$sql = 'SELECT `field_id`, `title` FROM `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 142 |
$sql .= 'WHERE `section_id` = '.(int)$section_id.' '; |
|
| 143 |
$sql .= ' AND ( `type` = \'textfield\' OR `type` = \'email\' )'; |
|
| 144 |
$sql .= 'ORDER BY `position` ASC '; |
|
| 145 |
if($query_email_fields = $database->query($sql)) {
|
|
| 146 |
if($query_email_fields->numRows() > 0) {
|
|
| 147 |
while($field = $query_email_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 148 |
?> |
|
| 149 |
<option value="field<?php echo $field['field_id']; ?>"<?php if($email_from_value == 'field'.$field['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
|
|
| 150 |
<?php echo $TEXT['FIELD'].': '.$field['title']; ?> |
|
| 151 |
</option> |
|
| 152 |
<?php |
|
| 153 |
} |
|
| 135 | 154 |
} |
| 136 | 155 |
} |
| 137 | 156 |
?> |
| ... | ... | |
| 140 | 159 |
</td> |
| 141 | 160 |
</tr> |
| 142 | 161 |
<tr> |
| 143 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td> |
|
| 144 |
<td class="setting_value"> |
|
| 145 |
<input type="text" name="email_fromname" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['email_fromname'])); ?>" /> |
|
| 162 |
<td class="frm-setting_name"><?php echo $TEXT['DISPLAY_NAME']; ?>:</td> |
|
| 163 |
<td class="frm-setting_value"> |
|
| 164 |
<select name="email_fromname_field" style="width: 98%;"> |
|
| 165 |
<option value="" onclick="javascript: document.getElementById('email_fromname').style.display = 'block';" ><?php echo $TEXT['CUSTOM']; ?>:</option>
|
|
| 166 |
<?php |
|
| 167 |
$selected = false; |
|
| 168 |
$email_fromname_value = str_replace($raw, $friendly, ($setting['email_fromname'])); |
|
| 169 |
if($query_email_fields->rewind()) {
|
|
| 170 |
if($query_email_fields->numRows() > 0) {
|
|
| 171 |
//!-- LOOP email_from_name --> |
|
| 172 |
while($fieldFrom = $query_email_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 173 |
?> |
|
| 174 |
<option value="field<?php echo $fieldFrom['field_id']; ?>"<?php if($email_fromname_value == 'field'.$fieldFrom['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_fromname').style.display = 'none';">
|
|
| 175 |
<?php echo $TEXT['FIELD'].': '.$fieldFrom['title']; ?> |
|
| 176 |
</option> |
|
| 177 |
<?php |
|
| 178 |
} |
|
| 179 |
//!-- ENDLOOP --> |
|
| 180 |
} |
|
| 181 |
} |
|
| 182 |
?> |
|
| 183 |
</select> |
|
| 184 |
<input type="text" name="email_fromname" id="email_fromname" style="width: 98%; display: <?php if(isset($selected) AND $selected == true) { echo 'none'; } else { echo 'block'; } ?>;" maxlength="255" value="<?php if(substr($email_fromname_value, 0, 5) != 'field') { echo $email_fromname_value; } ?>" />
|
|
| 146 | 185 |
</td> |
| 147 | 186 |
</tr> |
| 148 | 187 |
<tr> |
| 149 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td> |
|
| 150 |
<td class="setting_value"> |
|
| 188 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td>
|
|
| 189 |
<td class="frm-setting_value">
|
|
| 151 | 190 |
<input type="text" name="email_subject" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['email_subject'])); ?>" /> |
| 152 | 191 |
</td> |
| 153 | 192 |
</tr> |
| 154 | 193 |
</table> |
| 155 |
|
|
| 156 |
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%" style="margin-top: 3px;"> |
|
| 194 |
<!-- Erfolgreich Optionen --> |
|
| 195 |
<table summary="<?php echo $TEXT['SUCCESS'].' '.$TEXT['SETTINGS']; ?>" class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%" style="margin-top: 3px;">
|
|
| 157 | 196 |
<tr> |
| 158 | 197 |
<td colspan="2"><strong><?php echo $TEXT['SUCCESS'].' '.$TEXT['SETTINGS']; ?></strong></td> |
| 159 | 198 |
</tr> |
| 160 | 199 |
<tr> |
| 161 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['TO']; ?>:</td>
|
|
| 162 |
<td class="setting_value"> |
|
| 200 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$MOD_TEXT['TO']; ?>:</td>
|
|
| 201 |
<td class="frm-setting_value">
|
|
| 163 | 202 |
<select name="success_email_to" style="width: 98%;"> |
| 164 | 203 |
<option value="" onclick="javascript: document.getElementById('success_email_to').style.display = 'block';"><?php echo $TEXT['NONE']; ?></option>
|
| 165 | 204 |
<?php |
| 166 | 205 |
$success_email_to = str_replace($raw, $friendly, ($setting['success_email_to'])); |
| 167 |
$query_email_fields = $database->query("SELECT field_id,title FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' AND ( type = 'textfield' OR type = 'email' ) ORDER BY position ASC");
|
|
| 168 |
if($query_email_fields->numRows() > 0) {
|
|
| 169 |
while($field = $query_email_fields->fetchRow()) {
|
|
| 170 |
?> |
|
| 171 |
<option value="field<?php echo $field['field_id']; ?>"<?php if($success_email_to == 'field'.$field['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
|
|
| 172 |
<?php echo $TEXT['FIELD'].': '.$field['title']; ?> |
|
| 173 |
</option> |
|
| 174 |
<?php |
|
| 206 |
$sql = 'SELECT `field_id`, `title` FROM `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 207 |
$sql .= 'WHERE `section_id` = '.(int)$section_id.' '; |
|
| 208 |
$sql .= ' AND ( `type` = \'textfield\' OR `type` = \'email\' )'; |
|
| 209 |
$sql .= 'ORDER BY `position` ASC '; |
|
| 210 |
if($query_email_fields = $database->query($sql)) {
|
|
| 211 |
if($query_email_fields->numRows() > 0) {
|
|
| 212 |
while($field = $query_email_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 213 |
?> |
|
| 214 |
<option value="field<?php echo $field['field_id']; ?>"<?php if($success_email_to == 'field'.$field['field_id']) { echo ' selected'; $selected = true; } ?> onclick="javascript: document.getElementById('email_from').style.display = 'none';">
|
|
| 215 |
<?php echo $TEXT['FIELD'].': '.$field['title']; ?> |
|
| 216 |
</option> |
|
| 217 |
<?php |
|
| 218 |
} |
|
| 175 | 219 |
} |
| 176 | 220 |
} |
| 177 | 221 |
?> |
| ... | ... | |
| 179 | 223 |
</td> |
| 180 | 224 |
</tr> |
| 181 | 225 |
<tr> |
| 182 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['FROM']; ?>:</td>
|
|
| 183 |
<td class="setting_value"> |
|
| 226 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$MOD_TEXT['FROM']; ?>:</td>
|
|
| 227 |
<td class="frm-setting_value">
|
|
| 184 | 228 |
<input type="text" name="success_email_from" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['success_email_from'])); ?>" /> |
| 185 | 229 |
</td> |
| 186 | 230 |
</tr> |
| 187 | 231 |
<tr> |
| 188 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['NAME']; ?>:</td> |
|
| 189 |
<td class="setting_value"> |
|
| 232 |
<td class="frm-setting_name"><?php echo $TEXT['DISPLAY_NAME']; ?>:</td> |
|
| 233 |
<td class="frm-setting_value"> |
|
| 234 |
<?php $setting['success_email_fromname'] = ($setting['success_email_fromname'] != '' ? $setting['success_email_fromname'] : WBMAILER_DEFAULT_SENDERNAME); ?> |
|
| 190 | 235 |
<input type="text" name="success_email_fromname" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['success_email_fromname'])); ?>" /> |
| 191 | 236 |
</td> |
| 192 | 237 |
</tr> |
| 193 | 238 |
<tr> |
| 194 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td> |
|
| 195 |
<td class="setting_value"> |
|
| 239 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['SUBJECT']; ?>:</td>
|
|
| 240 |
<td class="frm-setting_value">
|
|
| 196 | 241 |
<input type="text" name="success_email_subject" style="width: 98%;" maxlength="255" value="<?php echo str_replace($raw, $friendly, ($setting['success_email_subject'])); ?>" /> |
| 197 | 242 |
</td> |
| 198 | 243 |
</tr> |
| 199 | 244 |
<tr> |
| 200 |
<td class="setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['TEXT']; ?>:</td> |
|
| 201 |
<td class="setting_value"> |
|
| 245 |
<td class="frm-setting_name"><?php echo $TEXT['EMAIL'].' '.$TEXT['TEXT']; ?>:</td>
|
|
| 246 |
<td class="frm-setting_value">
|
|
| 202 | 247 |
<textarea name="success_email_text" cols="80" rows="1" style="width: 98%; height: 80px;"><?php echo str_replace($raw, $friendly, ($setting['success_email_text'])); ?></textarea> |
| 203 | 248 |
</td> |
| 204 | 249 |
</tr> |
| 205 | 250 |
<tr> |
| 206 |
<td class="newsection"><?php echo $TEXT['SUCCESS'].' '.$TEXT['PAGE']; ?>:</td> |
|
| 207 |
<td class="newsection"> |
|
| 251 |
<td class="frm-newsection"><?php echo $TEXT['SUCCESS'].' '.$TEXT['PAGE']; ?>:</td>
|
|
| 252 |
<td class="frm-newsection">
|
|
| 208 | 253 |
<select name="success_page"> |
| 209 | 254 |
<option value="none"><?php echo $TEXT['NONE']; ?></option> |
| 210 | 255 |
<?php |
| 211 | 256 |
// Get exisiting pages and show the pagenames |
| 212 | 257 |
$query = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE visibility <> 'deleted'");
|
| 213 |
while($mail_page = $query->fetchRow()) {
|
|
| 258 |
while($mail_page = $query->fetchRow(MYSQL_ASSOC)) {
|
|
| 214 | 259 |
if(!$admin->page_is_visible($mail_page)) |
| 215 | 260 |
continue; |
| 216 | 261 |
$mail_pagename = $mail_page['menu_title']; |
| ... | ... | |
| 218 | 263 |
// echo $success_page.':'.$setting['success_page'].':'; not vailde |
| 219 | 264 |
if($setting['success_page'] == $success_page) {
|
| 220 | 265 |
$selected = ' selected="selected"'; |
| 221 |
} else {
|
|
| 266 |
} else {
|
|
| 222 | 267 |
$selected = ''; |
| 223 | 268 |
} |
| 224 | 269 |
echo '<option value="'.$success_page.'"'.$selected.'>'.$mail_pagename.'</option>'; |
| ... | ... | |
| 229 | 274 |
</tr> |
| 230 | 275 |
</table> |
| 231 | 276 |
|
| 232 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
| 277 |
<table summary="" cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
| 233 | 278 |
<tr> |
| 234 | 279 |
<td align="left"> |
| 235 | 280 |
<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;"> |
| 236 | 281 |
</td> |
| 237 | 282 |
<td align="right"> |
| 238 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" /> |
|
| 283 |
<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id.$sec_anchor; ?>';" style="width: 100px; margin-top: 5px;" />
|
|
| 239 | 284 |
</td> |
| 240 | 285 |
</tr> |
| 241 | 286 |
</table> |
| branches/2.8.x/wb/modules/form/save_field_new.php | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
/** |
|
| 3 |
* |
|
| 4 |
* @category module |
|
| 5 |
* @package Form |
|
| 6 |
* @author WebsiteBaker Project |
|
| 7 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
| 8 |
* @link http://www.websitebaker2.org/ |
|
| 9 |
* @license http://www.gnu.org/licenses/gpl.html |
|
| 10 |
* @platform WebsiteBaker 2.8.x |
|
| 11 |
* @requirements PHP 5.2.2 and higher |
|
| 12 |
* @version $Id$ |
|
| 13 |
* @filesource $HeadURL$ |
|
| 14 |
* @lastmodified $Date$ |
|
| 15 |
* @description |
|
| 16 |
* http://devzone.zend.com/703/php-built-in-input-filtering/ |
|
| 17 |
*/ |
|
| 18 |
|
|
| 19 |
require('../../config.php');
|
|
| 20 |
|
|
| 21 |
// suppress to print the header, so no new FTAN will be set |
|
| 22 |
$admin_header = false; |
|
| 23 |
// Tells script to update when this page was last updated |
|
| 24 |
$update_when_modified = true; |
|
| 25 |
// Include WB admin wrapper script |
|
| 26 |
require(WB_PATH.'/modules/admin.php'); |
|
| 27 |
/* */ |
|
| 28 |
|
|
| 29 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 30 |
|
|
| 31 |
// check FTAN |
|
| 32 |
if (!$admin->checkFTAN()) |
|
| 33 |
{
|
|
| 34 |
$admin->print_header(); |
|
| 35 |
$admin->print_error('::'.$MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor);
|
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
// Get id |
|
| 39 |
$field_id = intval($admin->checkIDKEY('field_id', false ));
|
|
| 40 |
if (!$field_id) {
|
|
| 41 |
$admin->print_header(); |
|
| 42 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'].'::', ADMIN_URL.'/pages/modify.php?page_id='.$page_id.$sec_anchor); |
|
| 43 |
} |
|
| 44 |
// After check print the header to get a new FTAN |
|
| 45 |
$admin->print_header(); |
|
| 46 |
|
|
| 47 |
// Validate all fields |
|
| 48 |
if($admin->get_post('title') == '' OR $admin->get_post('type') == '') {
|
|
| 49 |
$admin->print_error($MESSAGE['GENERIC']['FILL_IN_ALL'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id)); |
|
| 50 |
} else {
|
|
| 51 |
$title = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->get_post_escaped('title'), ENT_QUOTES));
|
|
| 52 |
$type = $admin->add_slashes($admin->get_post('type'));
|
|
| 53 |
$required = (int) $admin->add_slashes($admin->get_post('required'));
|
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
// If field type has multiple options, get all values and implode them |
|
| 57 |
$value = $extra = ''; |
|
| 58 |
$list_count = $admin->get_post('list_count');
|
|
| 59 |
if(is_numeric($list_count)) {
|
|
| 60 |
$values = array(); |
|
| 61 |
for($i = 1; $i <= $list_count; $i++) {
|
|
| 62 |
if($admin->get_post('value'.$i) != '') {
|
|
| 63 |
$values[] = str_replace(",",",",$admin->get_post('value'.$i));
|
|
| 64 |
} |
|
| 65 |
} |
|
| 66 |
$value = implode(',', $values);
|
|
| 67 |
} |
|
| 68 |
// prepare sql-update |
|
| 69 |
switch($admin->get_post('type')):
|
|
| 70 |
case 'textfield': |
|
| 71 |
$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
|
|
| 72 |
$extra = $admin->get_post_escaped('length');
|
|
| 73 |
break; |
|
| 74 |
case 'textarea': |
|
| 75 |
$value = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('value'));
|
|
| 76 |
$extra = ''; |
|
| 77 |
break; |
|
| 78 |
case 'heading': |
|
| 79 |
$extra = str_replace(array("[[", "]]"), '', $admin->get_post('template'));
|
|
| 80 |
if(trim($extra) == '') $extra = '<tr><td class="frm-field_heading" colspan="2">{TITLE}{FIELD}</td></tr>';
|
|
| 81 |
$extra = $admin->add_slashes($extra); |
|
| 82 |
break; |
|
| 83 |
case 'select': |
|
| 84 |
$extra = $admin->get_post_escaped('size').','.$admin->get_post_escaped('multiselect');
|
|
| 85 |
break; |
|
| 86 |
case 'checkbox': |
|
| 87 |
$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
|
|
| 88 |
break; |
|
| 89 |
case 'radio': |
|
| 90 |
$extra = str_replace(array("[[", "]]"), '', $admin->get_post_escaped('seperator'));
|
|
| 91 |
break; |
|
| 92 |
default: |
|
| 93 |
$value = ''; |
|
| 94 |
$extra = ''; |
|
| 95 |
break; |
|
| 96 |
endswitch; |
|
| 97 |
// Update row |
|
| 98 |
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 99 |
$sql .= 'SET `title`=\''.$title.'\', '; |
|
| 100 |
$sql .= '`type`=\''.$type.'\', '; |
|
| 101 |
$sql .= '`required`=\''.$required.'\', '; |
|
| 102 |
$sql .= '`extra`=\''.$extra.'\', '; |
|
| 103 |
$sql .= '`value`=\''.$value.'\' '; |
|
| 104 |
$sql .= 'WHERE field_id = '.(int)$field_id.' '; |
|
| 105 |
if( $database->query($sql) ) {
|
|
| 106 |
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id)); |
|
| 107 |
}else {
|
|
| 108 |
$admin->print_error($database->get_error(), WB_URL.'/modules/form/modify_field.php?page_id='.$page_id.'§ion_id='.$section_id.'&field_id='.$admin->getIDKEY($field_id)); |
|
| 109 |
} |
|
| 110 |
// Print admin footer |
|
| 111 |
$admin->print_footer(); |
|
| 0 | 112 | |
| branches/2.8.x/wb/modules/form/view.php | ||
|---|---|---|
| 12 | 12 |
* @version $Id$ |
| 13 | 13 |
* @filesource $HeadURL$ |
| 14 | 14 |
* @lastmodified $Date$ |
| 15 |
* @description
|
|
| 15 |
* @description |
|
| 16 | 16 |
*/ |
| 17 | 17 |
|
| 18 | 18 |
// Must include code to stop this file being access directly |
| ... | ... | |
| 24 | 24 |
} |
| 25 | 25 |
/* -------------------------------------------------------- */ |
| 26 | 26 |
|
| 27 |
// check if frontend.css file needs to be included into the <body></body> of view.php |
|
| 28 |
if((!function_exists('register_frontend_modfiles') || !defined('MOD_FRONTEND_CSS_REGISTERED')) &&
|
|
| 29 |
file_exists(WB_PATH .'/modules/form/frontend.css')) {
|
|
| 30 |
echo '<style type="text/css">'; |
|
| 31 |
include(WB_PATH .'/modules/form/frontend.css'); |
|
| 32 |
echo "\n</style>\n"; |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
| 36 |
|
|
| 37 |
// obtain the settings of the output filter module |
|
| 38 |
if(file_exists(WB_PATH.'/modules/output_filter/filter-routines.php')) {
|
|
| 39 |
include_once(WB_PATH.'/modules/output_filter/filter-routines.php'); |
|
| 40 |
$filter_settings = getOutputFilterSettings(); |
|
| 41 |
} else {
|
|
| 42 |
// no output filter used, define default settings |
|
| 43 |
$filter_settings['email_filter'] = 0; |
|
| 27 |
// load module language file |
|
| 28 |
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php'; |
|
| 29 |
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang ); |
|
| 30 |
/* |
|
| 31 |
function removebreaks($value) {
|
|
| 32 |
return trim(preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', null, $value));
|
|
| 44 | 33 |
} |
| 45 |
|
|
| 34 |
function checkbreaks($value) {
|
|
| 35 |
return $value === removebreaks($value); |
|
| 36 |
} |
|
| 37 |
*/ |
|
| 46 | 38 |
// Function for generating an optionsfor a select field |
| 47 | 39 |
if (!function_exists('make_option')) {
|
| 48 |
function make_option(&$n, $k, $values) {
|
|
| 49 |
// start option group if it exists |
|
| 50 |
if (substr($n,0,2) == '[=') {
|
|
| 51 |
$n = '<optgroup label="'.substr($n,2,strlen($n)).'">'; |
|
| 52 |
} elseif ($n == ']') {
|
|
| 53 |
$n = '</optgroup>'; |
|
| 54 |
} else {
|
|
| 55 |
if(in_array($n, $values)) {
|
|
| 56 |
$n = '<option selected="selected" value="'.$n.'">'.$n.'</option>'; |
|
| 40 |
function make_option(&$n, $k, $values) {
|
|
| 41 |
// start option group if it exists |
|
| 42 |
if (substr($n,0,2) == '[=') {
|
|
| 43 |
$n = '<optgroup label="'.substr($n,2,strlen($n)).'">'.PHP_EOL; |
|
| 44 |
} elseif ($n == ']') {
|
|
| 45 |
$n = '</optgroup>'.PHP_EOL; |
|
| 57 | 46 |
} else {
|
| 58 |
$n = '<option value="'.$n.'">'.$n.'</option>'; |
|
| 47 |
if(in_array($n, $values)) {
|
|
| 48 |
$n = '<option selected="selected" value="'.$n.'">'.$n.'</option>'.PHP_EOL; |
|
| 49 |
} else {
|
|
| 50 |
$n = '<option value="'.$n.'">'.$n.'</option>'.PHP_EOL; |
|
| 51 |
} |
|
| 59 | 52 |
} |
| 60 | 53 |
} |
| 61 | 54 |
} |
| 62 |
} |
|
| 63 | 55 |
// Function for generating a checkbox |
| 64 | 56 |
if (!function_exists('make_checkbox')) {
|
| 65 |
function make_checkbox(&$n, $idx, $params) {
|
|
| 66 |
$field_id = $params[0][0]; |
|
| 67 |
$seperator = $params[0][1]; |
|
| 68 |
$label_id = 'wb_'.preg_replace('/[^a-z0-1]/i', '_', $n);
|
|
| 69 |
if(in_array($n, $params[1])) {
|
|
| 70 |
$n = '<input class="field_checkbox" type="checkbox" id="'.$label_id.'" name="field'.$field_id.'['.$idx.']" value="'.$n.'" checked="checked" />'.'<label for="'.$label_id.'" class="checkbox_label">'.$n.'</lable>'.$seperator; |
|
| 71 |
} else {
|
|
| 72 |
$n = '<input class="field_checkbox" type="checkbox" id="'.$label_id.'" name="field'.$field_id.'['.$idx.']" value="'.$n.'" />'.'<label for="'.$label_id.'" class="checkbox_label">'.$n.'</label>'.$seperator; |
|
| 73 |
} |
|
| 57 |
function make_checkbox(&$key, $idx, $params) {
|
|
| 58 |
$field_id = $params[0][0]; |
|
| 59 |
$seperator = $params[0][1]; |
|
| 60 |
|
|
| 61 |
$label_id = 'wb_'.preg_replace('/[^a-z0-1]/i', '_', $key).$field_id;
|
|
| 62 |
if(in_array($key, $params[1])) {
|
|
| 63 |
$key = '<input class="frm-field_checkbox" type="checkbox" id="'.$label_id.'" name="field'.$field_id.'['.$idx.']" value="'.$key.'" />'.'<label for="'.$label_id.'" class="frm-checkbox_label">'.$key.'</lable>'.$seperator.PHP_EOL; |
|
| 64 |
} else {
|
|
| 65 |
$key = '<input class="frm-field_checkbox" type="checkbox" id="'.$label_id.'" name="field'.$field_id.'['.$idx.']" value="'.$key.'" />'.'<label for="'.$label_id.'" class="frm-checkbox_label">'.$key.'</label>'.$seperator.PHP_EOL; |
|
| 66 |
} |
|
| 67 |
} |
|
| 74 | 68 |
} |
| 75 |
} |
|
| 76 | 69 |
// Function for generating a radio button |
| 77 | 70 |
if (!function_exists('make_radio')) {
|
| 78 |
function make_radio(&$n, $idx, $params) {
|
|
| 79 |
$field_id = $params[0]; |
|
| 80 |
$group = $params[1]; |
|
| 81 |
$seperator = $params[2]; |
|
| 82 |
$label_id = 'wb_'.preg_replace('/[^a-z0-1]/i', '_', $n);
|
|
| 83 |
if($n == $params[3]) {
|
|
| 84 |
$n = '<input class="field_radio" type="radio" id="'.$label_id.'" name="field'.$field_id.'" value="'.$n.'" checked="checked" />'.'<label for="'.$label_id.'" class="radio_label">'.$n.'</label>'.$seperator; |
|
| 85 |
} else {
|
|
| 86 |
$n = '<input class="field_radio" type="radio" id="'.$label_id.'" name="field'.$field_id.'" value="'.$n.'" />'.'<label for="'.$label_id.'" class="radio_label">'.$n.'</label>'.$seperator; |
|
| 71 |
function make_radio(&$n, $idx, $params) {
|
|
| 72 |
$field_id = $params[0]; |
|
| 73 |
$group = $params[1]; |
|
| 74 |
$seperator = $params[2]; |
|
| 75 |
$label_id = 'wb_'.preg_replace('/[^a-z0-1]/i', '_', $n).$field_id;
|
|
| 76 |
if($n == $params[3]) {
|
|
| 77 |
$n = '<input class="frm-field_checkbox" type="radio" id="'.$label_id.'" name="field'.$field_id.'" value="'.$n.'" checked="checked" />'.'<label for="'.$label_id.'" class="frm-checkbox_label">'.$n.'</label>'.$seperator.PHP_EOL; |
|
| 78 |
} else {
|
|
| 79 |
$n = '<input class="frm-field_checkbox" type="radio" id="'.$label_id.'" name="field'.$field_id.'" value="'.$n.'" />'.'<label for="'.$label_id.'" class="frm-checkbox_label">'.$n.'</label>'.$seperator.PHP_EOL; |
|
| 80 |
} |
|
| 87 | 81 |
} |
| 88 | 82 |
} |
| 89 |
} |
|
| 90 | 83 |
|
| 91 | 84 |
if (!function_exists("new_submission_id") ) {
|
| 92 | 85 |
function new_submission_id() {
|
| ... | ... | |
| 106 | 99 |
|
| 107 | 100 |
// Work-out if the form has been submitted or not |
| 108 | 101 |
if($_POST == array()) {
|
| 102 |
require_once(WB_PATH.'/include/captcha/captcha.php'); |
|
| 109 | 103 |
|
| 110 |
// Set new submission ID in session |
|
| 111 |
$_SESSION['form_submission_id'] = new_submission_id(); |
|
| 112 |
|
|
| 113 |
// Get settings |
|
| 114 |
$query_settings = $database->query("SELECT header,field_loop,footer,use_captcha FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
|
|
| 115 |
if($query_settings->numRows() > 0) {
|
|
| 116 |
$fetch_settings = $query_settings->fetchRow(); |
|
| 117 |
$header = str_replace('{WB_URL}',WB_URL,$fetch_settings['header']);
|
|
| 118 |
$field_loop = $fetch_settings['field_loop']; |
|
| 119 |
$footer = str_replace('{WB_URL}',WB_URL,$fetch_settings['footer']);
|
|
| 120 |
$use_captcha = $fetch_settings['use_captcha']; |
|
| 121 |
$form_name = 'form'; |
|
| 122 |
$use_xhtml_strict = false; |
|
| 123 |
} else {
|
|
| 104 |
// Set new submission ID in session |
|
| 105 |
$_SESSION['form_submission_id'] = new_submission_id(); |
|
| 106 |
$out = ''; |
|
| 124 | 107 |
$header = ''; |
| 125 | 108 |
$field_loop = ''; |
| 126 | 109 |
$footer = ''; |
| 127 | 110 |
$form_name = 'form'; |
| 128 | 111 |
$use_xhtml_strict = false; |
| 129 |
} |
|
| 112 |
// Get settings |
|
| 113 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_settings` '; |
|
| 114 |
$sql .= 'WHERE section_id = '.$section_id.' '; |
|
| 115 |
if($query_settings = $database->query($sql)) {
|
|
| 116 |
if($query_settings->numRows() > 0) {
|
|
| 117 |
$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC); |
|
| 118 |
$header = str_replace('{WB_URL}',WB_URL,$fetch_settings['header']);
|
|
| 119 |
$field_loop = $fetch_settings['field_loop']; |
|
| 120 |
$footer = str_replace('{WB_URL}',WB_URL,$fetch_settings['footer']);
|
|
| 121 |
$use_captcha = $fetch_settings['use_captcha']; |
|
| 122 |
$form_name = 'form'; |
|
| 123 |
$use_xhtml_strict = false; |
|
| 124 |
} |
|
| 125 |
} |
|
| 130 | 126 |
|
| 131 |
?> |
|
| 132 |
<form <?php echo ( ( (strlen($form_name) > 0) AND (false == $use_xhtml_strict) ) ? "name=\"".$form_name."\"" : ""); ?> action="<?php echo htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])); ?>#wb_<?PHP echo $section_id;?>" method="post"> |
|
| 133 |
<div> |
|
| 134 |
<input type="hidden" name="submission_id" value="<?php echo $_SESSION['form_submission_id']; ?>" /> |
|
| 135 |
<?php echo $admin->getFTAN(); ?> |
|
| 136 |
</div> |
|
| 137 |
<?php |
|
| 138 |
if(ENABLED_ASP) { // first add some honeypot-fields
|
|
| 139 |
?> |
|
| 140 |
<div> |
|
| 141 |
<input type="hidden" name="submitted_when" value="<?php $t=time(); echo $t; $_SESSION['submitted_when']=$t; ?>" /> |
|
| 142 |
</div> |
|
| 143 |
<p class="nixhier"> |
|
| 144 |
email address: |
|
| 145 |
<label for="email">Leave this field email-address blank:</label> |
|
| 146 |
<input id="email" name="email" size="56" value="" /><br /> |
|
| 147 |
Homepage: |
|
| 148 |
<label for="homepage">Leave this field homepage blank:</label> |
|
| 149 |
<input id="homepage" name="homepage" size="55" value="" /><br /> |
|
| 150 |
URL: |
|
| 151 |
<label for="url">Leave this field url blank:</label> |
|
| 152 |
<input id="url" name="url" size="61" value="" /><br /> |
|
| 153 |
Comment: |
|
| 154 |
<label for="comment">Leave this field comment blank:</label> |
|
| 155 |
<textarea id="comment" name="comment" cols="50" rows="10"></textarea><br /> |
|
| 156 |
</p> |
|
| 127 |
// do not use sec_anchor, can destroy some layouts |
|
| 128 |
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? '#'.SEC_ANCHOR.$section['section_id'] : '' ); |
|
| 157 | 129 |
|
| 158 |
<?php } |
|
| 130 |
// Get list of fields |
|
| 131 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 132 |
$sql .= 'WHERE section_id = '.$section_id.' '; |
|
| 133 |
$sql .= 'ORDER BY position ASC '; |
|
| 159 | 134 |
|
| 160 |
// Print header |
|
| 161 |
echo $header; |
|
| 135 |
if($query_fields = $database->query($sql)) {
|
|
| 136 |
if($query_fields->numRows() > 0) {
|
|
| 137 |
?> |
|
| 138 |
<form <?php echo ( ( (strlen($form_name) > 0) AND (false == $use_xhtml_strict) ) ? "name=\"".$form_name."\"" : ""); ?> action="<?php echo htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'';?>" method="post"> |
|
| 139 |
<input type="hidden" name="submission_id" value="<?php echo $_SESSION['form_submission_id']; ?>" /> |
|
| 140 |
<?php // echo $admin->getFTAN(); ?> |
|
| 141 |
<?php |
|
| 142 |
if(ENABLED_ASP) { // first add some honeypot-fields
|
|
| 143 |
?> |
|
| 144 |
<input type="hidden" name="submitted_when" value="<?php $t=time(); echo $t; $_SESSION['submitted_when']=$t; ?>" /> |
|
| 145 |
<p class="frm-nixhier"> |
|
| 146 |
email address: |
|
| 147 |
<label for="email">Leave this field email-address blank:</label> |
|
| 148 |
<input id="email" name="email" size="56" value="" /><br /> |
|
| 149 |
Homepage: |
|
| 150 |
<label for="homepage">Leave this field homepage blank:</label> |
|
| 151 |
<input id="homepage" name="homepage" size="55" value="" /><br /> |
|
| 152 |
URL: |
|
| 153 |
<label for="url">Leave this field url blank:</label> |
|
| 154 |
<input id="url" name="url" size="61" value="" /><br /> |
|
| 155 |
Comment: |
|
| 156 |
<label for="comment">Leave this field comment blank:</label> |
|
| 157 |
<textarea id="comment" name="comment" cols="50" rows="10"></textarea><br /> |
|
| 158 |
</p> |
|
| 159 |
<?php } |
|
| 162 | 160 |
|
| 163 |
// Get list of fields |
|
| 164 |
$query_fields = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' ORDER BY position ASC");
|
|
| 165 |
|
|
| 166 |
if($query_fields->numRows() > 0) {
|
|
| 167 |
while($field = $query_fields->fetchRow()) {
|
|
| 168 |
// Set field values |
|
| 169 |
$field_id = $field['field_id']; |
|
| 170 |
$value = $field['value']; |
|
| 171 |
// Print field_loop after replacing vars with values |
|
| 172 |
$vars = array('{TITLE}', '{REQUIRED}');
|
|
| 173 |
if (($field['type'] == "radio") || ($field['type'] == "checkbox")) {
|
|
| 174 |
$field_title = $field['title']; |
|
| 175 |
} else {
|
|
| 176 |
$field_title = '<label for="field'.$field_id.'">'.$field['title'].'</label>'; |
|
| 177 |
} |
|
| 178 |
$values = array($field_title); |
|
| 179 |
if ($field['required'] == 1) {
|
|
| 180 |
$values[] = '<span class="required">*</span>'; |
|
| 181 |
} else {
|
|
| 182 |
$values[] = ''; |
|
| 183 |
} |
|
| 184 |
if($field['type'] == 'textfield') {
|
|
| 185 |
$vars[] = '{FIELD}';
|
|
| 186 |
$max_lenght_para = (intval($field['extra']) ? ' maxlenght="'.intval($field['extra']).'"' : ''); |
|
| 187 |
$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'"'.$max_lenght_para.' value="'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:$value).'" class="textfield" />'; |
|
| 188 |
} elseif($field['type'] == 'textarea') {
|
|
| 189 |
$vars[] = '{FIELD}';
|
|
| 190 |
$values[] = '<textarea name="field'.$field_id.'" id="field'.$field_id.'" class="textarea" cols="25" rows="5">'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:$value).'</textarea>'; |
|
| 191 |
} elseif($field['type'] == 'select') {
|
|
| 192 |
$vars[] = '{FIELD}';
|
|
| 193 |
$options = explode(',', $value);
|
|
| 194 |
array_walk($options, 'make_option', (isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:array())); |
|
| 195 |
$field['extra'] = explode(',',$field['extra']);
|
|
| 196 |
$values[] = '<select name="field'.$field_id.'[]" id="field'.$field_id.'" size="'.$field['extra'][0].'" '.$field['extra'][1].' class="select">'.implode($options).'</select>'; |
|
| 197 |
} elseif($field['type'] == 'heading') {
|
|
| 198 |
$vars[] = '{FIELD}';
|
|
| 199 |
$str = '<input type="hidden" name="field'.$field_id.'" id="field'.$field_id.'" value="===['.$field['title'].']===" />'; |
|
| 200 |
$values[] = ( true == $use_xhtml_strict) ? "<div>".$str."</div>" : $str; |
|
| 201 |
$tmp_field_loop = $field_loop; // temporarily modify the field loop template |
|
| 202 |
$field_loop = $field['extra']; |
|
| 203 |
} elseif($field['type'] == 'checkbox') {
|
|
| 204 |
$vars[] = '{FIELD}';
|
|
| 205 |
$options = explode(',', $value);
|
|
| 206 |
array_walk($options, 'make_checkbox', array(array($field_id,$field['extra']),(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:array()))); |
|
| 207 |
$options[count($options)-1]=substr($options[count($options)-1],0,strlen($options[count($options)-1])-strlen($field['extra'])); |
|
| 208 |
$values[] = implode($options); |
|
| 209 |
} elseif($field['type'] == 'radio') {
|
|
| 210 |
$vars[] = '{FIELD}';
|
|
| 211 |
$options = explode(',', $value);
|
|
| 212 |
array_walk($options, 'make_radio', array($field_id,$field['title'],$field['extra'], (isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:''))); |
|
| 213 |
$options[count($options)-1]=substr($options[count($options)-1],0,strlen($options[count($options)-1])-strlen($field['extra'])); |
|
| 214 |
$values[] = implode($options); |
|
| 215 |
} elseif($field['type'] == 'email') {
|
|
| 216 |
$vars[] = '{FIELD}';
|
|
| 217 |
$max_lenght_para = (intval($field['extra']) ? ' maxlenght="'.intval($field['extra']).'"' : ''); |
|
| 218 |
$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'" value="'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:'').'"'.$max_lenght_para.' class="email" />'; |
|
| 219 |
} |
|
| 220 |
if(isset($_SESSION['field'.$field_id])) unset($_SESSION['field'.$field_id]); |
|
| 221 |
if($field['type'] != '') {
|
|
| 222 |
echo str_replace($vars, $values, $field_loop); |
|
| 223 |
} |
|
| 224 |
if (isset($tmp_field_loop)) $field_loop = $tmp_field_loop; |
|
| 225 |
} |
|
| 226 |
} |
|
| 227 |
|
|
| 228 |
// Captcha |
|
| 229 |
if($use_captcha) { ?>
|
|
| 230 |
<tr> |
|
| 231 |
<td class="field_title"><?php echo $TEXT['VERIFICATION']; ?>:</td> |
|
| 232 |
<td><?php call_captcha(); ?></td> |
|
| 233 |
</tr> |
|
| 234 |
<?php |
|
| 235 |
} |
|
| 236 |
|
|
| 237 |
// Print footer |
|
| 238 |
echo $footer; |
|
| 161 |
// Print header MYSQL_ASSOC |
|
| 162 |
echo $header.PHP_EOL; |
|
| 163 |
while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 164 |
// Set field values |
|
| 165 |
$field_id = $field['field_id']; |
|
| 166 |
$value = $field['value']; |
|
| 167 |
// Print field_loop after replacing vars with values |
|
| 168 |
$vars = array('{TITLE}', '{REQUIRED}');
|
|
| 169 |
if (($field['type'] == "radio") || ($field['type'] == "checkbox")) {
|
|
| 170 |
$field_title = $field['title']; |
|
| 171 |
} else {
|
|
| 172 |
$field_title = '<label for="field'.$field_id.'">'.$field['title'].'</label>'.PHP_EOL; |
|
| 173 |
} |
|
| 174 |
$values = array($field_title); |
|
| 175 |
if ($field['required'] == 1) {
|
|
| 176 |
$values[] = '<span class="frm-required">*</span>'.PHP_EOL; |
|
| 177 |
} else {
|
|
| 178 |
$values[] = ''; |
|
| 179 |
} |
|
| 180 |
if($field['type'] == 'textfield') {
|
|
| 181 |
$vars[] = '{FIELD}';
|
|
| 182 |
$max_lenght_para = (intval($field['extra']) ? ' maxlenght="'.intval($field['extra']).'"' : ''); |
|
| 183 |
$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'"'.$max_lenght_para.' value="'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:$value).'" class="frm-textfield" />'.PHP_EOL; |
|
| 184 |
} elseif($field['type'] == 'textarea') {
|
|
| 185 |
$vars[] = '{FIELD}';
|
|
| 186 |
$values[] = '<textarea name="field'.$field_id.'" id="field'.$field_id.'" class="frm-textarea" cols="30" rows="8">'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:$value).'</textarea>'.PHP_EOL; |
|
| 187 |
} elseif($field['type'] == 'select') {
|
|
| 188 |
$vars[] = '{FIELD}';
|
|
| 189 |
$options = explode(',', $value);
|
|
| 190 |
array_walk($options, 'make_option', (isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:array())); |
|
| 191 |
$field['extra'] = explode(',',$field['extra']);
|
|
| 192 |
$values[] = '<select name="field'.$field_id.'[]" id="field'.$field_id.'" size="'.$field['extra'][0].'" '.$field['extra'][1].' class="frm-select">'.implode($options).'</select>'.PHP_EOL; |
|
| 193 |
} elseif($field['type'] == 'heading') {
|
|
| 194 |
$vars[] = '{FIELD}';
|
|
| 195 |
$str = '<input type="hidden" name="field'.$field_id.'" id="field'.$field_id.'" value="===['.$field['title'].']===" />'; |
|
| 196 |
$values[] = ( true == $use_xhtml_strict) ? "<div>".$str."</div>" : $str; |
|
| 197 |
$tmp_field_loop = $field_loop; // temporarily modify the field loop template |
|
| 198 |
$field_loop = $field['extra']; |
|
| 199 |
} elseif($field['type'] == 'checkbox') {
|
|
| 200 |
$vars[] = '{FIELD}';
|
|
| 201 |
$options = explode(',', $value);
|
|
| 202 |
array_walk($options, 'make_checkbox', array(array($field_id,$field['extra']),(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:array()))); |
|
| 203 |
$x = sizeof($options)-1; |
|
| 204 |
$options[$x]=substr($options[$x],0,strlen($options[$x])); |
|
| 205 |
$values[] = implode($options); |
|
| 206 |
} elseif($field['type'] == 'radio') {
|
|
| 207 |
$vars[] = '{FIELD}';
|
|
| 208 |
$options = explode(',', $value);
|
|
| 209 |
array_walk($options, 'make_radio', array($field_id,$field['title'],$field['extra'], (isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:''))); |
|
| 210 |
$x = sizeof($options)-1; |
|
| 211 |
$options[$x]=substr($options[$x],0,strlen($options[$x])); |
|
| 212 |
$values[] = implode($options); |
|
| 213 |
} elseif($field['type'] == 'email') {
|
|
| 214 |
$vars[] = '{FIELD}';
|
|
| 215 |
$max_lenght_para = (intval($field['extra']) ? ' maxlenght="'.intval($field['extra']).'"' : ''); |
|
| 216 |
$values[] = '<input type="text" name="field'.$field_id.'" id="field'.$field_id.'" value="'.(isset($_SESSION['field'.$field_id])?$_SESSION['field'.$field_id]:'').'"'.$max_lenght_para.' class="frm-email" />'.PHP_EOL; |
|
| 217 |
} |
|
| 218 |
if(isset($_SESSION['field'.$field_id])) unset($_SESSION['field'.$field_id]); |
|
| 219 |
if($field['type'] != '') {
|
|
| 220 |
echo str_replace($vars, $values, $field_loop); |
|
| 221 |
} |
|
| 222 |
if (isset($tmp_field_loop)){ $field_loop = $tmp_field_loop; }
|
|
| 223 |
} |
|
| 224 |
// Captcha |
|
| 225 |
if($use_captcha) { ?>
|
|
| 226 |
<tr> |
|
| 227 |
<td class="frm-field_title"><?php echo $TEXT['VERIFICATION']; ?>:</td> |
|
| 228 |
<td><?php call_captcha(); ?></td> |
|
| 229 |
</tr> |
|
| 230 |
<?php |
|
| 231 |
} |
|
| 232 |
// Print footer |
|
| 233 |
// $out = $footer.PHP_EOL; |
|
| 234 |
$out .= str_replace('{SUBMIT_FORM}', $MOD_FORM['SUBMIT_FORM'], $footer);
|
|
| 235 |
echo $out; |
|
| 239 | 236 |
// Add form end code |
| 240 | 237 |
?> |
| 241 | 238 |
</form> |
| 242 | 239 |
<?php |
| 240 |
} |
|
| 241 |
} |
|
| 243 | 242 |
|
| 244 | 243 |
} else {
|
| 245 | 244 |
|
| 246 | 245 |
// Check that submission ID matches |
| 247 | 246 |
if(isset($_SESSION['form_submission_id']) AND isset($_POST['submission_id']) AND $_SESSION['form_submission_id'] == $_POST['submission_id']) {
|
| 248 |
|
|
| 247 |
|
|
| 249 | 248 |
// Set new submission ID in session |
| 250 | 249 |
$_SESSION['form_submission_id'] = new_submission_id(); |
| 251 |
|
|
| 250 |
|
|
| 252 | 251 |
if(ENABLED_ASP && ( // form faked? Check the honeypot-fields. |
| 253 |
(!isset($_POST['submitted_when']) OR !isset($_SESSION['submitted_when'])) OR
|
|
| 252 |
(!isset($_POST['submitted_when']) OR !isset($_SESSION['submitted_when'])) OR |
|
| 254 | 253 |
($_POST['submitted_when'] != $_SESSION['submitted_when']) OR |
| 255 | 254 |
(!isset($_POST['email']) OR $_POST['email']) OR |
| 256 | 255 |
(!isset($_POST['homepage']) OR $_POST['homepage']) OR |
| 257 | 256 |
(!isset($_POST['comment']) OR $_POST['comment']) OR |
| 258 | 257 |
(!isset($_POST['url']) OR $_POST['url']) |
| 259 | 258 |
)) {
|
| 260 |
exit(header("Location: ".WB_URL.PAGES_DIRECTORY.""));
|
|
| 259 |
// spam |
|
| 260 |
header("Location: ".WB_URL.PAGES_DIRECTORY."");
|
|
| 261 |
exit(); |
|
| 261 | 262 |
} |
| 262 |
/* |
|
| 263 |
if (!$admin->checkFTAN()) |
|
| 264 |
{
|
|
| 265 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']); |
|
| 266 |
exit(); |
|
| 267 |
} |
|
| 268 |
*/ |
|
| 269 | 263 |
// Submit form data |
| 270 | 264 |
// First start message settings |
| 271 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_settings WHERE section_id = '$section_id'");
|
|
| 272 |
if($query_settings->numRows() > 0) {
|
|
| 273 |
$fetch_settings = $query_settings->fetchRow(); |
|
| 274 |
$email_to = $fetch_settings['email_to']; |
|
| 275 |
$email_from = $fetch_settings['email_from']; |
|
| 276 |
if(substr($email_from, 0, 5) == 'field') {
|
|
| 277 |
// Set the email from field to what the user entered in the specified field |
|
| 278 |
$email_from = htmlspecialchars($wb->add_slashes($_POST[$email_from])); |
|
| 265 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_settings` '; |
|
| 266 |
$sql .= 'WHERE `section_id` = '.(int)$section_id.''; |
|
| 267 |
if($query_settings = $database->query($sql) ) {
|
|
| 268 |
if($query_settings->numRows() > 0) {
|
|
| 269 |
$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC); |
|
| 270 |
|
|
| 271 |
$email_to = $fetch_settings['email_to']; |
|
| 272 |
$email_from = $fetch_settings['email_from']; |
|
| 273 |
if(substr($email_from, 0, 5) == 'field') {
|
|
| 274 |
// Set the email from field to what the user entered in the specified field |
|
| 275 |
$email_from = htmlspecialchars($wb->add_slashes($_POST[$email_from])); |
|
| 276 |
} |
|
| 277 |
$email_fromname = $fetch_settings['email_fromname']; |
|
| 278 |
if(substr($email_fromname, 0, 5) == 'field') {
|
|
| 279 |
// Set the email_fromname to field to what the user entered in the specified field |
|
| 280 |
$email_fromname = htmlspecialchars($wb->add_slashes($_POST[$email_fromname])); |
|
| 281 |
} |
|
| 282 |
$email_subject = $fetch_settings['email_subject']; |
|
| 283 |
$success_page = $fetch_settings['success_page']; |
|
| 284 |
$success_email_to = $fetch_settings['success_email_to']; |
|
| 285 |
if(substr($success_email_to, 0, 5) == 'field') {
|
|
| 286 |
// Set the success_email to field to what the user entered in the specified field |
|
| 287 |
$success_email_to = htmlspecialchars($wb->add_slashes($_POST[$success_email_to])); |
|
| 288 |
} |
|
| 289 |
$success_email_from = $fetch_settings['success_email_from']; |
|
| 290 |
$success_email_fromname = $fetch_settings['success_email_fromname']; |
|
| 291 |
$success_email_text = htmlspecialchars($wb->add_slashes($fetch_settings['success_email_text'])); |
|
| 292 |
$success_email_text = (($success_email_text != '') ? $success_email_text : $MOD_FORM['SUCCESS_EMAIL_TEXT']); |
|
| 293 |
$success_email_subject = $fetch_settings['success_email_subject']; |
|
| 294 |
$max_submissions = $fetch_settings['max_submissions']; |
|
| 295 |
$stored_submissions = $fetch_settings['stored_submissions']; |
|
| 296 |
$use_captcha = $fetch_settings['use_captcha']; |
|
| 297 |
} else {
|
|
| 298 |
exit($TEXT['UNDER_CONSTRUCTION']); |
|
| 279 | 299 |
} |
| 280 |
$email_fromname = $fetch_settings['email_fromname']; |
|
| 281 |
$email_subject = $fetch_settings['email_subject']; |
|
| 282 |
$success_page = $fetch_settings['success_page']; |
|
| 283 |
$success_email_to = $fetch_settings['success_email_to']; |
|
| 284 |
if(substr($success_email_to, 0, 5) == 'field') {
|
|
| 285 |
// Set the success_email to field to what the user entered in the specified field |
|
| 286 |
$success_email_to = htmlspecialchars($wb->add_slashes($_POST[$success_email_to])); |
|
| 287 |
} |
|
| 288 |
$success_email_from = $fetch_settings['success_email_from']; |
|
| 289 |
$success_email_fromname = $fetch_settings['success_email_fromname']; |
|
| 290 |
$success_email_text = $fetch_settings['success_email_text']; |
|
| 291 |
$success_email_subject = $fetch_settings['success_email_subject']; |
|
| 292 |
$max_submissions = $fetch_settings['max_submissions']; |
|
| 293 |
$stored_submissions = $fetch_settings['stored_submissions']; |
|
| 294 |
$use_captcha = $fetch_settings['use_captcha']; |
|
| 295 |
} else {
|
|
| 296 |
exit($TEXT['UNDER_CONSTRUCTION']); |
|
| 297 | 300 |
} |
| 298 | 301 |
$email_body = ''; |
| 299 |
|
|
| 302 |
|
|
| 300 | 303 |
// Create blank "required" array |
| 301 | 304 |
$required = array(); |
| 302 |
|
|
| 305 |
|
|
| 303 | 306 |
// Captcha |
| 304 | 307 |
if($use_captcha) {
|
| 305 | 308 |
if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
|
| ... | ... | |
| 315 | 318 |
|
| 316 | 319 |
// Loop through fields and add to message body |
| 317 | 320 |
// Get list of fields |
| 318 |
$query_fields = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id' ORDER BY position ASC");
|
|
| 319 |
if($query_fields->numRows() > 0) {
|
|
| 320 |
while($field = $query_fields->fetchRow()) {
|
|
| 321 |
// Add to message body |
|
| 322 |
if($field['type'] != '') {
|
|
| 323 |
if(!empty($_POST['field'.$field['field_id']])) {
|
|
| 324 |
// do not allow droplets in user input! |
|
| 325 |
if (is_array($_POST['field'.$field['field_id']])) {
|
|
| 326 |
$_SESSION['field'.$field['field_id']] = str_replace(array("[[", "]]"), array("[[", "]]"), $_POST['field'.$field['field_id']]);
|
|
| 327 |
} else {
|
|
| 328 |
$_SESSION['field'.$field['field_id']] = str_replace(array("[[", "]]"), array("[[", "]]"), htmlspecialchars($_POST['field'.$field['field_id']]));
|
|
| 329 |
} |
|
| 330 |
// if the output filter is active, we need to revert (dot) to . and (at) to @ (using current filter settings) |
|
| 331 |
// otherwise the entered mail will not be accepted and the recipient would see (dot), (at) etc. |
|
| 332 |
if ($filter_settings['email_filter']) {
|
|
| 333 |
$field_value = $_POST['field'.$field['field_id']]; |
|
| 334 |
$field_value = str_replace($filter_settings['at_replacement'], '@', $field_value); |
|
| 335 |
$field_value = str_replace($filter_settings['dot_replacement'], '.', $field_value); |
|
| 336 |
$_POST['field'.$field['field_id']] = $field_value; |
|
| 337 |
} |
|
| 338 |
if($field['type'] == 'email' AND $admin->validate_email($_POST['field'.$field['field_id']]) == false) {
|
|
| 339 |
$email_error = $MESSAGE['USERS']['INVALID_EMAIL']; |
|
| 340 |
} |
|
| 341 |
if($field['type'] == 'heading') {
|
|
| 342 |
$email_body .= $_POST['field'.$field['field_id']]."\n\n"; |
|
| 343 |
} elseif (!is_array($_POST['field'.$field['field_id']])) {
|
|
| 344 |
$email_body .= $field['title'].': '.$_POST['field'.$field['field_id']]."\n\n"; |
|
| 345 |
} else {
|
|
| 346 |
$email_body .= $field['title'].": \n"; |
|
| 347 |
foreach ($_POST['field'.$field['field_id']] as $k=>$v) {
|
|
| 348 |
$email_body .= $v."\n"; |
|
| 321 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_form_fields` '; |
|
| 322 |
$sql .= 'WHERE `section_id` = '.(int)$section_id.' '; |
|
| 323 |
$sql .= 'ORDER BY position ASC'; |
|
| 324 |
if($query_fields = $database->query($sql)) {
|
|
| 325 |
if($query_fields->numRows() > 0) {
|
|
| 326 |
while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 327 |
// Add to message body |
|
| 328 |
if($field['type'] != '') {
|
|
| 329 |
if(!empty($_POST['field'.$field['field_id']])) {
|
|
| 330 |
// do not allow droplets in user input! |
|
| 331 |
if (is_array($_POST['field'.$field['field_id']])) {
|
|
| 332 |
$_SESSION['field'.$field['field_id']] = str_replace(array("[[", "]]"), array("[[", "]]"), $_POST['field'.$field['field_id']]);
|
|
| 333 |
} else {
|
|
| 334 |
$_SESSION['field'.$field['field_id']] = str_replace(array("[[", "]]"), array("[[", "]]"), htmlspecialchars($_POST['field'.$field['field_id']]));
|
|
| 349 | 335 |
} |
| 350 |
$email_body .= "\n"; |
|
| 336 |
if($field['type'] == 'email' AND $admin->validate_email($_POST['field'.$field['field_id']]) == false) {
|
|
| 337 |
$email_error = $MESSAGE['USERS']['INVALID_EMAIL']; |
|
| 338 |
} |
|
| 339 |
if($field['type'] == 'heading') {
|
|
| 340 |
$email_body .= $_POST['field'.$field['field_id']]."\n\n"; |
|
| 341 |
} elseif (!is_array($_POST['field'.$field['field_id']])) {
|
|
| 342 |
$email_body .= $field['title'].': '.$_POST['field'.$field['field_id']]."\n\n"; |
|
| 343 |
} else {
|
|
| 344 |
$email_body .= $field['title'].": \n"; |
|
| 345 |
foreach ($_POST['field'.$field['field_id']] as $k=>$v) {
|
|
| 346 |
$email_body .= $v."\n"; |
|
| 347 |
} |
|
| 348 |
$email_body .= "\n"; |
|
| 349 |
} |
|
| 350 |
} elseif($field['required'] == 1) {
|
|
| 351 |
$required[] = $field['title']; |
|
| 351 | 352 |
} |
| 352 |
} elseif($field['required'] == 1) {
|
|
| 353 |
$required[] = $field['title']; |
|
| 354 | 353 |
} |
| 355 |
} |
|
| 356 |
} |
|
| 357 |
} |
|
| 358 |
|
|
| 359 |
// Check if the user forgot to enter values into all the required fields
|
|
| 360 |
if($required != array()) {
|
|
| 361 |
if(!isset($MESSAGE['MOD_FORM']['REQUIRED_FIELDS'])) {
|
|
| 362 |
echo 'You must enter details for the following fields';
|
|
| 354 |
} // while
|
|
| 355 |
} // numRows
|
|
| 356 |
} // query
|
|
| 357 |
// Check if the user forgot to enter values into all the required fields |
|
| 358 |
if(sizeof($required )) {
|
|
| 359 |
|
|
| 360 |
if(!isset($MESSAGE['MOD_FORM_REQUIRED_FIELDS'])) {
|
|
| 361 |
echo '<h3>You must enter details for the following fields</h3>';
|
|
| 363 | 362 |
} else {
|
| 364 |
echo $MESSAGE['MOD_FORM']['REQUIRED_FIELDS'];
|
|
| 363 |
echo '<h3>'.$MESSAGE['MOD_FORM_REQUIRED_FIELDS'].'</h3>';
|
|
| 365 | 364 |
} |
| 366 |
echo ':<br /><ul>';
|
|
| 365 |
echo '<ul>'.PHP_EOL;
|
|
| 367 | 366 |
foreach($required AS $field_title) {
|
| 368 |
echo '<li>'.$field_title; |
|
| 367 |
echo '<li>'.$field_title.PHP_EOL;
|
|
| 369 | 368 |
} |
| 370 | 369 |
if(isset($email_error)) {
|
| 371 |
echo '<li>'.$email_error.'</li>'; |
|
| 370 |
echo '<li>'.$email_error.'</li>'.PHP_EOL;
|
|
| 372 | 371 |
} |
| 373 | 372 |
if(isset($captcha_error)) {
|
| 374 |
echo '<li>'.$captcha_error.'</li>'; |
|
| 373 |
echo '<li>'.$captcha_error.'</li>'.PHP_EOL;
|
|
| 375 | 374 |
} |
| 376 |
echo '</ul><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a>'; |
|
| 375 |
// Create blank "required" array |
|
| 376 |
$required = array(); |
|
| 377 |
echo '</ul>'.PHP_EOL; |
|
| 378 |
echo '<p> </p>'.PHP_EOL.'<p><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a></p>'.PHP_EOL; |
|
| 377 | 379 |
} else {
|
| 378 | 380 |
if(isset($email_error)) {
|
| 379 |
echo '<br /><ul>'; |
|
| 380 |
echo '<li>'.$email_error.'</li>'; |
|
| 381 |
echo '</ul><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a>'; |
|
| 381 |
echo '<br /><ul>'.PHP_EOL; |
|
| 382 |
echo '<li>'.$email_error.'</li>'.PHP_EOL; |
|
| 383 |
echo '</ul>'.PHP_EOL; |
|
| 384 |
echo '<a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a>'; |
|
| 382 | 385 |
} elseif(isset($captcha_error)) {
|
| 383 |
echo '<br /><ul>'; |
|
| 384 |
echo '<li>'.$captcha_error.'</li>'; |
|
| 385 |
echo '</ul><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a>'; |
|
| 386 |
echo '<br /><ul>'.PHP_EOL; |
|
| 387 |
echo '<li>'.$captcha_error.'</li>'.PHP_EOL; |
|
| 388 |
echo '</ul>'.PHP_EOL; |
|
| 389 |
echo '<p> </p>'.PHP_EOL.'<p><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a></p>'.PHP_EOL; |
|
| 386 | 390 |
} else {
|
| 387 | 391 |
// Check how many times form has been submitted in last hour |
| 388 | 392 |
$last_hour = time()-3600; |
| 389 |
$query_submissions = $database->query("SELECT submission_id FROM ".TABLE_PREFIX."mod_form_submissions WHERE submitted_when >= '$last_hour'");
|
|
| 390 |
if($query_submissions->numRows() > $max_submissions) {
|
|
| 391 |
// Too many submissions so far this hour |
|
| 392 |
echo $MESSAGE['MOD_FORM']['EXCESS_SUBMISSIONS']; |
|
| 393 |
$success = false; |
|
| 394 |
} else {
|
|
| 395 |
/** |
|
| 396 |
* Adding the IP to the body and try to send the email |
|
| 397 |
*/ |
|
| 398 |
// $email_body .= "\n\nIP: ".$_SERVER['REMOTE_ADDR']; |
|
| 393 |
$sql = 'SELECT `submission_id` FROM `'.TABLE_PREFIX.'mod_form_submissions` '; |
|
| 394 |
$sql .= 'WHERE `submitted_when` >= '.$last_hour.''; |
|
| 395 |
$sql .= ''; |
|
| 396 |
if($query_submissions = $database->query($sql)){
|
|
| 397 |
if($query_submissions->numRows() > $max_submissions) {
|
|
| 398 |
// Too many submissions so far this hour |
|
| 399 |
echo $MESSAGE['MOD_FORM_EXCESS_SUBMISSIONS']; |
|
| 400 |
$success = false; |
|
| 401 |
} else {
|
|
| 402 |
// Adding the IP to the body and try to send the email |
|
| 403 |
// $email_body .= "\n\nIP: ".$_SERVER['REMOTE_ADDR']; |
|
| 404 |
$recipient = preg_replace( "/[^a-z0-9 !?:;,.\/_\-=+@#$&\*\(\)]/im", "", $email_fromname ); |
|
| 405 |
$email_fromname = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $recipient ); |
|
| 406 |
$email_body = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $email_body ); |
|
| 407 |
if($email_to != '') {
|
|
| 408 |
if($email_from != '') {
|
|
| 409 |
if($wb->mail($email_from,$email_to,$email_subject,$email_body,$email_fromname)) {
|
|
| 410 |
$success = true; |
|
| 411 |
} |
|
| 412 |
} else {
|
|
| 413 |
if($wb->mail('',$email_to,$email_subject,$email_body,$email_fromname)) {
|
|
| 414 |
$success = true; |
|
| 415 |
} |
|
| 416 |
} |
|
| 417 |
} |
|
| 399 | 418 |
|
| 400 |
if($email_to != '') {
|
|
| 401 |
if($email_from != '') {
|
|
| 402 |
if($wb->mail($email_from,$email_to,$email_subject,$email_body,$email_fromname)) {
|
|
| 403 |
$success = true; |
|
| 419 |
$recipient = preg_replace( "/[^a-z0-9 !?:;,.\/_\-=+@#$&\*\(\)]/im", "", $success_email_fromname ); |
|
| 420 |
$success_email_fromname = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $recipient ); |
|
| 421 |
$success_email_text = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $success_email_text ); |
|
| 422 |
if($success_email_to != '') {
|
|
| 423 |
if($success_email_from != '') {
|
|
| 424 |
if($wb->mail($success_email_from,$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
|
|
| 425 |
$success = true; |
|
| 426 |
} |
|
| 427 |
} else {
|
|
| 428 |
if($wb->mail('',$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
|
|
| 429 |
$success = true; |
|
| 430 |
} |
|
| 404 | 431 |
} |
| 405 |
} else {
|
|
| 406 |
if($wb->mail('',$email_to,$email_subject,$email_body,$email_fromname)) {
|
|
| 407 |
$success = true; |
|
| 408 |
} |
|
| 409 | 432 |
} |
| 410 |
} |
|
| 411 |
if($success_email_to != '') {
|
|
| 412 |
if($success_email_from != '') {
|
|
| 413 |
if($wb->mail($success_email_from,$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
|
|
| 414 |
$success = true; |
|
| 415 |
} |
|
| 433 |
|
|
| 434 |
// Write submission to database |
|
| 435 |
if(isset($admin) AND $admin->is_authenticated() AND $admin->get_user_id() > 0) {
|
|
| 436 |
$submitted_by = $admin->get_user_id(); |
|
| 416 | 437 |
} else {
|
| 417 |
if($wb->mail('',$success_email_to,$success_email_subject,$success_email_text,$success_email_fromname)) {
|
|
| 418 |
$success = true; |
|
| 419 |
} |
|
| 438 |
$submitted_by = 0; |
|
| 420 | 439 |
} |
| 421 |
} |
|
| 422 |
|
|
| 423 |
// Write submission to database |
|
| 424 |
if(isset($admin) AND $admin->is_authenticated() AND $admin->get_user_id() > 0) {
|
|
| 425 |
$submitted_by = $admin->get_user_id(); |
|
| 426 |
} else {
|
|
| 427 |
$submitted_by = 0; |
|
| 428 |
} |
|
| 429 |
$email_body = htmlspecialchars($wb->add_slashes($email_body)); |
|
| 430 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_submissions (page_id,section_id,submitted_when,submitted_by,body) VALUES ('".PAGE_ID."','$section_id','".time()."','$submitted_by','$email_body')");
|
|
| 431 |
// Make sure submissions table isn't too full |
|
| 432 |
$query_submissions = $database->query("SELECT submission_id FROM ".TABLE_PREFIX."mod_form_submissions ORDER BY submitted_when");
|
|
| 433 |
$num_submissions = $query_submissions->numRows(); |
|
| 434 |
if($num_submissions > $stored_submissions) {
|
|
| 435 |
// Remove excess submission |
|
| 436 |
$num_to_remove = $num_submissions-$stored_submissions; |
|
| 437 |
while($submission = $query_submissions->fetchRow()) {
|
|
| 438 |
if($num_to_remove > 0) {
|
|
| 439 |
$submission_id = $submission['submission_id']; |
|
| 440 |
$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_submissions WHERE submission_id = '$submission_id'");
|
|
| 441 |
$num_to_remove = $num_to_remove-1; |
|
| 440 |
$email_body = htmlspecialchars($wb->add_slashes($email_body)); |
|
| 441 |
$sql = 'INSERT INTO '.TABLE_PREFIX.'mod_form_submissions '; |
|
| 442 |
$sql .= 'SET '; |
|
| 443 |
$sql .= 'page_id='.$wb->page_id.','; |
|
| 444 |
$sql .= 'section_id='.$section_id.','; |
|
| 445 |
$sql .= 'submitted_when='.time().','; |
|
| 446 |
$sql .= 'submitted_by=\''.$submitted_by.'\', '; |
|
| 447 |
$sql .= 'body=\''.$email_body.'\' '; |
|
| 448 |
if($database->query($sql)) {
|
|
| 449 |
/* |
|
| 450 |
// Make sure submissions table isn't too full |
|
| 451 |
$query_submissions = $database->query("SELECT submission_id FROM ".TABLE_PREFIX."mod_form_submissions ORDER BY submitted_when");
|
|
| 452 |
$num_submissions = $query_submissions->numRows(); |
|
| 453 |
if($num_submissions > $stored_submissions) {
|
|
| 454 |
// Remove excess submission |
|
| 455 |
$num_to_remove = $num_submissions-$stored_submissions; |
|
| 456 |
while($submission = $query_submissions->fetchRow(MYSQL_ASSOC)) {
|
|
| 457 |
if($num_to_remove > 0) {
|
|
| 458 |
$submission_id = $submission['submission_id']; |
|
| 459 |
$database->query("DELETE FROM ".TABLE_PREFIX."mod_form_submissions WHERE submission_id = '$submission_id'");
|
|
| 460 |
$num_to_remove = $num_to_remove-1; |
|
| 461 |
} |
|
| 442 | 462 |
} |
| 443 | 463 |
} |
| 444 |
} |
|
| 445 |
if(!$database->is_error()) {
|
|
| 446 |
$success = true; |
|
| 447 |
} |
|
| 448 |
} |
|
| 449 |
} |
|
| 450 |
} |
|
| 464 |
*/ |
|
| 465 |
if(!$database->is_error()) {
|
|
| 466 |
$success = true; |
|
| 467 |
} |
|
| 468 |
} // numRows |
|
| 469 |
} |
|
| 470 |
} |
|
| 471 |
} |
|
| 472 |
} // email_error |
|
| 473 |
} else {
|
|
| 474 |
|
|
| 475 |
echo '<p> </p>'.PHP_EOL.'<p><a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.$TEXT['BACK'].'</a></p>'.PHP_EOL; |
|
| 451 | 476 |
} |
| 452 |
|
|
| 477 |
|
|
| 453 | 478 |
// Now check if the email was sent successfully |
| 454 | 479 |
if(isset($success) AND $success == true) {
|
| 455 | 480 |
if ($success_page=='none') {
|
| ... | ... | |
| 457 | 482 |
} else {
|
| 458 | 483 |
$query_menu = $database->query("SELECT link,target FROM ".TABLE_PREFIX."pages WHERE `page_id` = '$success_page'");
|
| 459 | 484 |
if($query_menu->numRows() > 0) {
|
| 460 |
$fetch_settings = $query_menu->fetchRow(); |
|
| 485 |
$fetch_settings = $query_menu->fetchRow(MYSQL_ASSOC);
|
|
| 461 | 486 |
$link = WB_URL.PAGES_DIRECTORY.$fetch_settings['link'].PAGE_EXTENSION; |
| 462 | 487 |
echo "<script type='text/javascript'>location.href='".$link."';</script>"; |
| 463 |
}
|
|
| 488 |
} |
|
| 464 | 489 |
} |
| 465 | 490 |
// clearing session on success |
| 466 | 491 |
$query_fields = $database->query("SELECT field_id FROM ".TABLE_PREFIX."mod_form_fields WHERE section_id = '$section_id'");
|
| 467 |
while($field = $query_fields->fetchRow()) {
|
|
| 468 |
$field_id = $field[0];
|
|
| 492 |
while($field = $query_fields->fetchRow(MYSQL_ASSOC)) {
|
|
| 493 |
$field_id = $field['field_id'];
|
|
| 469 | 494 |
if(isset($_SESSION['field'.$field_id])) unset($_SESSION['field'.$field_id]); |
| 470 | 495 |
} |
| 471 | 496 |
} else {
|
| ... | ... | |
| 473 | 498 |
echo $TEXT['ERROR']; |
| 474 | 499 |
} |
| 475 | 500 |
} |
| 501 |
|
|
| 476 | 502 |
} |
| branches/2.8.x/wb/modules/form/delete_submission.php | ||
|---|---|---|
| 22 | 22 |
require(WB_PATH.'/modules/admin.php'); |
| 23 | 23 |
|
| 24 | 24 |
// Get id |
| 25 |
$submission_id = $admin->checkIDKEY('submission_id', false, 'GET');
|
|
| 25 |
$submission_id = intval($admin->checkIDKEY('submission_id', false, 'GET'));
|
|
| 26 | 26 |
if (!$submission_id) {
|
| 27 | 27 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
| 28 | 28 |
} |
Also available in: Unified diff
! recoded formmodul, add dropdown email_fromname_field