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: save_field_new.php 1553 2011-12-31 15:03:03Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/tags/2.8.3/wb/modules/form/save_field_new.php $
|
14
|
* @lastmodified $Date: 2011-12-31 16:03:03 +0100 (Sat, 31 Dec 2011) $
|
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();
|