Project

General

Profile

1 2 Manuela
<?php
2
/**
3
 *
4
 * @category        module
5
 * @package         Form
6
 * @author          WebsiteBaker Project
7
 * @copyright       WebsiteBaker Org. e.V.
8
 * @link            http://websitebaker.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.3
11
 * @requirements    PHP 5.3.6 and higher
12
 * @version         $Id$
13
 * @filesource      $HeadURL$
14
 * @lastmodified    $Date$
15
 * @description
16
 */
17
18
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
19
20
$admin_header = false;
21
// Tells script to update when this page was last updated
22
$update_when_modified = true;
23
// Include WB admin wrapper script
24
require(WB_PATH.'/modules/admin.php');
25
26
$sBacklink = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
27
if (!$admin->checkFTAN())
28
{
29
    $admin->print_header();
30
    $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $sBacklink);
31
}
32
$admin->print_header();
33
34
if (!function_exists('emailAdmin')) {
35
    function emailAdmin() {
36
        global $database,$admin;
37
        $retval = $admin->get_email();
38
        if($admin->get_user_id()!='1') {
39
            $sql  = 'SELECT `email` FROM `'.TABLE_PREFIX.'users` '
40
                  . 'WHERE `user_id`=\'1\' ';
41
            $retval = $database->get_one($sql);
42
        }
43
        return $retval;
44
    }
45
}
46
47
// load module language file
48
$sAddonName = basename(__DIR__);
49
require(__DIR__.'/languages/EN.php');
50
if(file_exists(__DIR__.'/languages/'.LANGUAGE .'.php')) {
51
    require(__DIR__.'/languages/'.LANGUAGE .'.php');
52
}
53
54
// This code removes any <?php tags and adds slashes
55
$friendly = array('&lt;', '&gt;', '?php');
56
$raw = array('<', '>', '');
57
58
//$header     = CleanInput('header');
59
$header = $admin->StripCodeFromText($admin->get_post('header'),true);
60
//$field_loop = CleanInput('field_loop');
61
$field_loop = $admin->StripCodeFromText($admin->get_post('field_loop'),true);
62
$footer = $admin->StripCodeFromText($admin->get_post('footer'),true);
63
//$email_to   = CleanInput('email_to');
64
$email_to   = $admin->StripCodeFromText($admin->get_post('email_to'), true);
65
$email_to   = $admin->StripCodeFromText($email_to != '' ? $email_to : emailAdmin());
66
$email_from = SERVER_EMAIL;
67
//$use_captcha =CleanInput('use_captcha');
68
$use_captcha = $admin->StripCodeFromText($admin->get_post('use_captcha'),true);
69
70
if( isset($_POST['email_fromname_field']) && ($_POST['email_fromname_field'] != '')) {
71
    $email_fromname = $admin->StripCodeFromText($admin->get_post('email_fromname_field'),true);
72
} else {
73
    $email_fromname = $admin->StripCodeFromText($admin->get_post('email_fromname'),true);
74
}
75
76
$email_fromname = ($email_fromname != '' ? $email_fromname : WBMAILER_DEFAULT_SENDERNAME);
77
$email_subject = ($admin->StripCodeFromText($admin->get_post('email_subject'),true));
78
$success_page = ($admin->StripCodeFromText($admin->get_post('success_page'),true));
79
$success_email_to = ($admin->StripCodeFromText($admin->get_post('success_email_to'),true));
80
$success_email_from = (SERVER_EMAIL);
81
$success_email_fromname = ($admin->StripCodeFromText($admin->get_post('success_email_fromname'),true));
82
$success_email_fromname = ($success_email_fromname != '' ? $success_email_fromname : $email_fromname);
83
$success_email_text = ($admin->StripCodeFromText($admin->get_post('success_email_text'),true));
84
$success_email_text = (($success_email_text != '') ? $success_email_text : '');
85
$success_email_subject = ($admin->StripCodeFromText($admin->get_post('success_email_subject'),true));
86
$success_email_subject = (($success_email_subject  != '') ? $success_email_subject : '');
87
88
if(!is_numeric($_POST['max_submissions'])) {
89
    $max_submissions = 50;
90
} else {
91
    $max_submissions = intval($_POST['max_submissions']);
92
}
93
if(!is_numeric($_POST['stored_submissions'])) {
94
    $stored_submissions = 100;
95
} else {
96
    $stored_submissions = intval($_POST['stored_submissions']);
97
}
98
if(!is_numeric($_POST['perpage_submissions'])) {
99
    $perpage_submissions = 10;
100
} else {
101
    $perpage_submissions = intval($_POST['perpage_submissions']);
102
}
103
104
// Make sure max submissions is not greater than stored submissions if stored_submissions <>0
105
if($max_submissions > $stored_submissions) {
106
    $max_submissions = $stored_submissions;
107
}
108
$sSectionIdPrefix = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
109
110
$sBacklink = ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id;
111
112
// Update settings
113
$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_form_settings` SET '
114
      . '`header` = \''.$database->escapeString($header).'\', '
115
      . '`field_loop` = \''.$database->escapeString($field_loop).'\', '
116
      . '`footer` = \''.$database->escapeString($footer).'\', '
117
      . '`email_to` = \''.$database->escapeString($email_to).'\', '
118
      . '`email_from` = \''.$database->escapeString($email_from).'\', '
119
      . '`email_fromname` = \''.$database->escapeString($email_fromname).'\', '
120
      . '`email_subject` = \''.$database->escapeString($email_subject).'\', '
121
      . '`success_page` = '.(int)$success_page.', '
122
      . '`success_email_to` = \''.$database->escapeString($success_email_to).'\', '
123
      . '`success_email_from` = \''.$database->escapeString($success_email_from).'\', '
124
      . '`success_email_fromname` = \''.$database->escapeString($success_email_fromname).'\', '
125
      . '`success_email_text` = \''.$database->escapeString($success_email_text).'\', '
126
      . '`success_email_subject` = \''.$database->escapeString($success_email_subject).'\', '
127
      . '`max_submissions` = \''.$database->escapeString($max_submissions).'\', '
128
      . '`stored_submissions` = \''.$database->escapeString($stored_submissions).'\', '
129
      . '`perpage_submissions` = \''.$database->escapeString($perpage_submissions).'\', '
130
      . '`use_captcha` = \''.$database->escapeString($use_captcha).'\' '
131
      . 'WHERE `section_id` = '.(int)$section_id.' ';
132
133
if($database->query($sql)) {
134
135
    $admin->print_success($TEXT['SUCCESS'], $sBacklink);
136
}
137
// Check if there is a db error, otherwise say successful
138
if($database->is_error()) {
139
    $admin->print_error($database->get_error(), $sBacklink);
140
}
141
// Print admin footer
142
$admin->print_footer();