Version Description
Download this release
Release Info
Developer | mmuro |
Plugin | Visual Form Builder |
Version | 2.6.4 |
Comparing to | |
See all releases |
Code changes from version 2.6.3 to 2.6.4
- readme.txt +4 -1
- visual-form-builder.php +2 -777
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=G87A9
|
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 2.6.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
@@ -210,6 +210,9 @@ To Export Selected:
|
|
210 |
|
211 |
== Changelog ==
|
212 |
|
|
|
|
|
|
|
213 |
**Version 2.6.3**
|
214 |
|
215 |
* Update CSS to now prefix all classes to help eliminate theme conflicts
|
4 |
Tags: form, forms, contact form, form to email, email form, email, input, validation, jquery, shortcode
|
5 |
Requires at least: 3.4.1
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 2.6.4
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Build beautiful, fully functional forms in only a few minutes without writing PHP, CSS, or HTML.
|
210 |
|
211 |
== Changelog ==
|
212 |
|
213 |
+
**Version 2.6.4**
|
214 |
+
* Fix bug where SVN commit mangled code
|
215 |
+
|
216 |
**Version 2.6.3**
|
217 |
|
218 |
* Update CSS to now prefix all classes to help eliminate theme conflicts
|
visual-form-builder.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Visual Form Builder
|
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
-
Version: 2.6.
|
8 |
*/
|
9 |
|
10 |
/*
|
@@ -31,7 +31,7 @@ $visual_form_builder = new Visual_Form_Builder();
|
|
31 |
// Visual Form Builder class
|
32 |
class Visual_Form_Builder{
|
33 |
|
34 |
-
protected $vfb_db_version = '2.6.
|
35 |
$add_scripts = false;
|
36 |
|
37 |
public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
|
@@ -1880,781 +1880,6 @@ class Visual_Form_Builder{
|
|
1880 |
}
|
1881 |
}
|
1882 |
|
1883 |
-
// On plugin activation, install the databases and add/update the DB version
|
1884 |
-
register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
|
1885 |
-
?>m may not function or display properly without one.</p></div><ul class="section section-' . $count . '">';
|
1886 |
-
|
1887 |
-
$count++;
|
1888 |
-
}
|
1889 |
-
|
1890 |
-
if ( $field->field_type == 'fieldset' ) {
|
1891 |
-
// Close each fieldset
|
1892 |
-
if ( $open_fieldset == true )
|
1893 |
-
$output .= '</ul><br /></fieldset>';
|
1894 |
-
|
1895 |
-
$output .= '<fieldset class="fieldset fieldset-' . $count . ' ' . $field->field_key . $css . '" id="' . $id_attr . '"><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="section section-' . $count . '">';
|
1896 |
-
$open_fieldset = true;
|
1897 |
-
$count++;
|
1898 |
-
}
|
1899 |
-
elseif ( $field->field_type == 'section' ) {
|
1900 |
-
$output .= '<div class="section-div vfb-' . esc_html( $field->field_key ) . '-' . $field->field_id . '"><h4>' . stripslashes( $field->field_name ) . '</h4>';
|
1901 |
-
|
1902 |
-
// Save section ID for future comparison
|
1903 |
-
$sec_id = $field->field_id;
|
1904 |
-
$open_section = true;
|
1905 |
-
}
|
1906 |
-
elseif ( !in_array( $field->field_type, array( 'verification', 'secret', 'submit' ) ) ) {
|
1907 |
-
|
1908 |
-
$columns_choice = ( in_array( $field->field_type, array( 'radio', 'checkbox' ) ) ) ? " $field->field_size" : '';
|
1909 |
-
|
1910 |
-
if ( $field->field_type !== 'hidden' ) {
|
1911 |
-
$output .= '<li class="item item-' . $field->field_type . $columns_choice . $layout . '" id="item-' . $id_attr . '"><label for="' . $id_attr . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
|
1912 |
-
}
|
1913 |
-
}
|
1914 |
-
elseif ( in_array( $field->field_type, array( 'verification', 'secret' ) ) ) {
|
1915 |
-
|
1916 |
-
if ( $field->field_type == 'verification' )
|
1917 |
-
$verification .= '<fieldset class="fieldset fieldset-' . $count . ' ' . $field->field_key . $css . '"><div class="legend"><h3>' . stripslashes( $field->field_name ) . '</h3></div><ul class="section section-' . $count . '">';
|
1918 |
-
|
1919 |
-
if ( $field->field_type == 'secret' ) {
|
1920 |
-
// Default logged in values
|
1921 |
-
$logged_in_display = '';
|
1922 |
-
$logged_in_value = '';
|
1923 |
-
|
1924 |
-
// If the user is logged in, fill the field in for them
|
1925 |
-
if ( is_user_logged_in() ) {
|
1926 |
-
// Hide the secret field if logged in
|
1927 |
-
$logged_in_display = ' style="display:none;"';
|
1928 |
-
$logged_in_value = 14;
|
1929 |
-
|
1930 |
-
// Get logged in user details
|
1931 |
-
$user = wp_get_current_user();
|
1932 |
-
$user_identity = ! empty( $user->ID ) ? $user->display_name : '';
|
1933 |
-
|
1934 |
-
// Display a message for logged in users
|
1935 |
-
$verification .= '<li class="item">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. Verification not required.', 'visual-form-builder' ), admin_url( 'profile.php' ), $user_identity ) . '</li>';
|
1936 |
-
}
|
1937 |
-
|
1938 |
-
$validation = ' {digits:true,maxlength:2,minlength:2}';
|
1939 |
-
$verification .= '<li class="item item-' . $field->field_type . '"' . $logged_in_display . '><label for="' . $id_attr . '" class="desc">'. stripslashes( $field->field_name ) . $required_span . '</label>';
|
1940 |
-
|
1941 |
-
// Set variable for testing if required is Yes/No
|
1942 |
-
if ( $required == '' )
|
1943 |
-
$verification .= '<input type="hidden" name="_vfb-required-secret" value="0" />';
|
1944 |
-
|
1945 |
-
$verification .= '<input type="hidden" name="_vfb-secret" value="vfb-' . $field->field_id . '" />';
|
1946 |
-
|
1947 |
-
if ( !empty( $field->field_description ) )
|
1948 |
-
$verification .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="text ' . $field->field_size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
1949 |
-
else
|
1950 |
-
$verification .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $logged_in_value . '" class="text ' . $field->field_size . $required . $validation . $css . '" />';
|
1951 |
-
}
|
1952 |
-
}
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
switch ( $field->field_type ) {
|
1957 |
-
case 'text' :
|
1958 |
-
case 'email' :
|
1959 |
-
case 'url' :
|
1960 |
-
case 'currency' :
|
1961 |
-
case 'number' :
|
1962 |
-
case 'phone' :
|
1963 |
-
|
1964 |
-
if ( !empty( $field->field_description ) )
|
1965 |
-
$output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="text ' . $field->field_size . $required . $validation . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
1966 |
-
else
|
1967 |
-
$output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="text ' . $field->field_size . $required . $validation . $css . '" />';
|
1968 |
-
|
1969 |
-
break;
|
1970 |
-
|
1971 |
-
case 'textarea' :
|
1972 |
-
|
1973 |
-
if ( !empty( $field->field_description ) )
|
1974 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
1975 |
-
|
1976 |
-
$output .= '<textarea name="vfb-' . $field->field_id . '" id="'. $id_attr . '" class="textarea ' . $field->field_size . $required . $css . '">' . $default . '</textarea>';
|
1977 |
-
|
1978 |
-
break;
|
1979 |
-
|
1980 |
-
case 'select' :
|
1981 |
-
if ( !empty( $field->field_description ) )
|
1982 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
1983 |
-
|
1984 |
-
$output .= '<select name="vfb-'. $field->field_id . '" id="' . $id_attr . '" class="select ' . $field->field_size . $required . $css . '">';
|
1985 |
-
|
1986 |
-
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
1987 |
-
|
1988 |
-
// Loop through each option and output
|
1989 |
-
foreach ( $options as $option => $value ) {
|
1990 |
-
$output .= '<option value="' . trim( stripslashes( $value ) ) . '"' . selected( $default, ++$option, 0 ) . '>'. trim( stripslashes( $value ) ) . '</option>';
|
1991 |
-
}
|
1992 |
-
|
1993 |
-
$output .= '</select>';
|
1994 |
-
|
1995 |
-
break;
|
1996 |
-
|
1997 |
-
case 'radio' :
|
1998 |
-
|
1999 |
-
if ( !empty( $field->field_description ) )
|
2000 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2001 |
-
|
2002 |
-
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
2003 |
-
|
2004 |
-
$output .= '<div>';
|
2005 |
-
|
2006 |
-
// Loop through each option and output
|
2007 |
-
foreach ( $options as $option => $value ) {
|
2008 |
-
// Increment the base index by one to match $default
|
2009 |
-
$option++;
|
2010 |
-
|
2011 |
-
$output .= '<span>
|
2012 |
-
<input type="radio" name="vfb-' . $field->field_id . '" id="'. $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="radio' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
|
2013 |
-
' <label for="' . $id_attr . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label>' .
|
2014 |
-
'</span>';
|
2015 |
-
}
|
2016 |
-
|
2017 |
-
$output .= '<div style="clear:both"></div></div>';
|
2018 |
-
|
2019 |
-
break;
|
2020 |
-
|
2021 |
-
case 'checkbox' :
|
2022 |
-
|
2023 |
-
if ( !empty( $field->field_description ) )
|
2024 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2025 |
-
|
2026 |
-
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : explode( ',', unserialize( $field->field_options ) );
|
2027 |
-
|
2028 |
-
$output .= '<div>';
|
2029 |
-
|
2030 |
-
// Loop through each option and output
|
2031 |
-
foreach ( $options as $option => $value ) {
|
2032 |
-
// Increment the base index by one to match $default
|
2033 |
-
$option++;
|
2034 |
-
|
2035 |
-
$output .= '<span><input type="checkbox" name="vfb-' . $field->field_id . '[]" id="' . $id_attr . '-' . $option . '" value="'. trim( stripslashes( $value ) ) . '" class="checkbox' . $required . $css . '"' . checked( $default, $option, 0 ) . ' />'.
|
2036 |
-
' <label for="' . $id_attr . '-' . $option . '" class="choice">' . trim( stripslashes( $value ) ) . '</label></span>';
|
2037 |
-
}
|
2038 |
-
|
2039 |
-
$output .= '<div style="clear:both"></div></div>';
|
2040 |
-
|
2041 |
-
break;
|
2042 |
-
|
2043 |
-
case 'address' :
|
2044 |
-
|
2045 |
-
if ( !empty( $field->field_description ) )
|
2046 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2047 |
-
|
2048 |
-
$output .= '<div>
|
2049 |
-
<span class="full">
|
2050 |
-
|
2051 |
-
<input type="text" name="vfb-' . $field->field_id . '[address]" id="' . $id_attr . '-address" maxlength="150" class="text medium' . $required . $css . '" />
|
2052 |
-
<label for="' . $id_attr . '-address">Address</label>
|
2053 |
-
</span>
|
2054 |
-
<span class="full">
|
2055 |
-
<input type="text" name="vfb-' . $field->field_id . '[address-2]" id="' . $id_attr . 'address-2" maxlength="150" class="text medium' . $css . '" />
|
2056 |
-
<label for="' . $id_attr . '-address-2">Address Line 2</label>
|
2057 |
-
</span>
|
2058 |
-
<span class="left">
|
2059 |
-
|
2060 |
-
<input type="text" name="vfb-' . $field->field_id . '[city]" id="' . $id_attr . '-city" maxlength="150" class="text medium' . $required . $css . '" />
|
2061 |
-
<label for="' . $id_attr . '-city">City</label>
|
2062 |
-
</span>
|
2063 |
-
<span class="right">
|
2064 |
-
<input type="text" name="vfb-' . $field->field_id . '[state]" id="' . $id_attr . '-state" maxlength="150" class="text medium' . $required . $css . '" />
|
2065 |
-
<label for="' . $id_attr . '-state">State / Province / Region</label>
|
2066 |
-
</span>
|
2067 |
-
<span class="left">
|
2068 |
-
<input type="text" name="vfb-' . $field->field_id . '[zip]" id="' . $id_attr . '-zip" maxlength="150" class="text medium' . $required . $css . '" />
|
2069 |
-
<label for="' . $id_attr . '-zip">Postal / Zip Code</label>
|
2070 |
-
</span>
|
2071 |
-
<span class="right">
|
2072 |
-
<select class="select' . $required . $css . '" name="vfb-' . $field->field_id . '[country]" id="' . $id_attr . '-country">
|
2073 |
-
<option selected="selected" value=""></option>';
|
2074 |
-
|
2075 |
-
foreach ( $this->countries as $country ) {
|
2076 |
-
$output .= "<option value=\"$country\" " . selected( $default, $country, 0 ) . ">$country</option>";
|
2077 |
-
}
|
2078 |
-
|
2079 |
-
$output .= '</select>
|
2080 |
-
<label for="' . $id_attr . '-country">Country</label>
|
2081 |
-
</span>
|
2082 |
-
</div>';
|
2083 |
-
|
2084 |
-
break;
|
2085 |
-
|
2086 |
-
case 'date' :
|
2087 |
-
|
2088 |
-
if ( !empty( $field->field_description ) )
|
2089 |
-
$output .= '<span><input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="text vfb-date-picker ' . $field->field_size . $required . $css . '" /><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2090 |
-
else
|
2091 |
-
$output .= '<input type="text" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="" class="text vfb-date-picker ' . $field->field_size . $required . $css . '" />';
|
2092 |
-
|
2093 |
-
break;
|
2094 |
-
|
2095 |
-
case 'time' :
|
2096 |
-
if ( !empty( $field->field_description ) )
|
2097 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2098 |
-
|
2099 |
-
// Get the time format (12 or 24)
|
2100 |
-
$time_format = str_replace( 'time-', '', $validation );
|
2101 |
-
$time_format = apply_filters( 'vfb_time_format', $time_format );
|
2102 |
-
|
2103 |
-
// Set whether we start with 0 or 1 and how many total hours
|
2104 |
-
$hour_start = ( $time_format == '12' ) ? 1 : 0;
|
2105 |
-
$hour_total = ( $time_format == '12' ) ? 12 : 23;
|
2106 |
-
|
2107 |
-
// Hour
|
2108 |
-
$output .= '<span class="time"><select name="vfb-' . $field->field_id . '[hour]" id="' . $id_attr . '-hour" class="select' . $required . $css . '">';
|
2109 |
-
for ( $i = $hour_start; $i <= $hour_total; $i++ ) {
|
2110 |
-
// Add the leading zero
|
2111 |
-
$hour = ( $i < 10 ) ? "0$i" : $i;
|
2112 |
-
$output .= "<option value='$hour'>$hour</option>";
|
2113 |
-
}
|
2114 |
-
$output .= '</select><label for="' . $id_attr . '-hour">HH</label></span>';
|
2115 |
-
|
2116 |
-
// Minute
|
2117 |
-
$output .= '<span class="time"><select name="vfb-' . $field->field_id . '[min]" id="' . $id_attr . '-min" class="select' . $required . $css . '">';
|
2118 |
-
|
2119 |
-
$total_mins = apply_filters( 'vfb_time_min_total', 55 );
|
2120 |
-
$min_interval = apply_filters( 'vfb_time_min_interval', 5 );
|
2121 |
-
|
2122 |
-
for ( $i = 0; $i <= $total_mins; $i += $min_interval ) {
|
2123 |
-
// Add the leading zero
|
2124 |
-
$min = ( $i < 10 ) ? "0$i" : $i;
|
2125 |
-
$output .= "<option value='$min'>$min</option>";
|
2126 |
-
}
|
2127 |
-
$output .= '</select><label for="' . $id_attr . '-min">MM</label></span>';
|
2128 |
-
|
2129 |
-
// AM/PM
|
2130 |
-
if ( $time_format == '12' )
|
2131 |
-
$output .= '<span class="time"><select name="vfb-' . $field->field_id . '[ampm]" id="' . $id_attr . '-ampm" class="select' . $required . $css . '"><option value="AM">AM</option><option value="PM">PM</option></select><label for="' . $id_attr . '-ampm">AM/PM</label></span>';
|
2132 |
-
$output .= '<div class="clear"></div>';
|
2133 |
-
break;
|
2134 |
-
|
2135 |
-
case 'html' :
|
2136 |
-
|
2137 |
-
if ( !empty( $field->field_description ) )
|
2138 |
-
$output .= '<span><label>' . html_entity_decode( stripslashes( $field->field_description ) ) . '</label></span>';
|
2139 |
-
|
2140 |
-
$output .= '<script type="text/javascript">edToolbar("' . $id_attr . '");</script>';
|
2141 |
-
$output .= '<textarea name="vfb-' . $field->field_id . '" id="' . $id_attr . '" class="textarea vfbEditor ' . $field->field_size . $required . $css . '"></textarea>';
|
2142 |
-
|
2143 |
-
break;
|
2144 |
-
|
2145 |
-
case 'file-upload' :
|
2146 |
-
|
2147 |
-
$options = ( is_array( unserialize( $field->field_options ) ) ) ? unserialize( $field->field_options ) : unserialize( $field->field_options );
|
2148 |
-
$accept = ( !empty( $options[0] ) ) ? " {accept:'$options[0]'}" : '';
|
2149 |
-
|
2150 |
-
if ( !empty( $field->field_description ) )
|
2151 |
-
$output .= '<span><input type="file" size="35" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="text ' . $field->field_size . $required . $validation . $accept . $css . '" /><label>' . stripslashes( $field->field_description ) . '</label></span>';
|
2152 |
-
else
|
2153 |
-
$output .= '<input type="file" size="35" name="vfb-' . $field->field_id . '" id="' . $id_attr . '" value="' . $default . '" class="text ' . $field->field_size . $required . $validation . $accept . $css . '" />';
|
2154 |
-
|
2155 |
-
|
2156 |
-
break;
|
2157 |
-
|
2158 |
-
case 'instructions' :
|
2159 |
-
|
2160 |
-
$output .= html_entity_decode( stripslashes( $field->field_description ) );
|
2161 |
-
|
2162 |
-
break;
|
2163 |
-
|
2164 |
-
case 'submit' :
|
2165 |
-
|
2166 |
-
$submit = stripslashes( $field->field_name );
|
2167 |
-
|
2168 |
-
break;
|
2169 |
-
|
2170 |
-
default:
|
2171 |
-
echo '';
|
2172 |
-
}
|
2173 |
-
|
2174 |
-
// Closing </li>
|
2175 |
-
$output .= ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit', 'fieldset', 'section' ) ) ) ? '</li>' : '';
|
2176 |
-
}
|
2177 |
-
|
2178 |
-
|
2179 |
-
// Close user-added fields
|
2180 |
-
$output .= '</ul><br /></fieldset>';
|
2181 |
-
|
2182 |
-
// Make sure the verification displays even if they have not updated their form
|
2183 |
-
if ( $verification == '' ) {
|
2184 |
-
$verification = '<fieldset class="fieldset verification">
|
2185 |
-
<div class="legend">
|
2186 |
-
<h3>' . __( 'Verification' , 'visual-form-builder') . '</h3>
|
2187 |
-
</div>
|
2188 |
-
<ul class="section section-' . $count . '">
|
2189 |
-
<li class="item item-text">
|
2190 |
-
<label for="vfb-secret" class="desc">' . __( 'Please enter any two digits with' , 'visual-form-builder') . ' <strong>' . __( 'no' , 'visual-form-builder') . '</strong> ' . __( 'spaces (Example: 12)' , 'visual-form-builder') . '<span>*</span></label>
|
2191 |
-
<div>
|
2192 |
-
<input type="text" name="vfb-secret" id="vfb-secret" class="text medium" />
|
2193 |
-
</div>
|
2194 |
-
</li>';
|
2195 |
-
}
|
2196 |
-
|
2197 |
-
// Output our security test
|
2198 |
-
$output .= $verification . '<li style="display:none;">
|
2199 |
-
<label for="vfb-spam">' . __( 'This box is for spam protection' , 'visual-form-builder') . ' - <strong>' . __( 'please leave it blank' , 'visual-form-builder') . '</strong>:</label>
|
2200 |
-
<div>
|
2201 |
-
<input name="vfb-spam" id="vfb-spam" />
|
2202 |
-
</div>
|
2203 |
-
</li>
|
2204 |
-
|
2205 |
-
<li class="item item-submit">
|
2206 |
-
<input type="submit" name="visual-form-builder-submit" value="' . $submit . '" class="submit" id="sendmail" />
|
2207 |
-
</li>
|
2208 |
-
</ul>
|
2209 |
-
</fieldset></form></div>';
|
2210 |
-
|
2211 |
-
endforeach;
|
2212 |
-
}
|
2213 |
-
|
2214 |
-
return $output;
|
2215 |
-
}
|
2216 |
-
|
2217 |
-
/**
|
2218 |
-
* Handle emailing the content
|
2219 |
-
*
|
2220 |
-
* @since 1.0
|
2221 |
-
* @uses wp_mail() E-mails a message
|
2222 |
-
*/
|
2223 |
-
public function email() {
|
2224 |
-
global $wpdb, $post;
|
2225 |
-
|
2226 |
-
$required = ( isset( $_REQUEST['_vfb-required-secret'] ) && $_REQUEST['_vfb-required-secret'] == '0' ) ? false : true;
|
2227 |
-
$secret_field = ( isset( $_REQUEST['_vfb-secret'] ) ) ? $_REQUEST['_vfb-secret'] : '';
|
2228 |
-
$honeypot = ( isset( $_REQUEST['vfb-spam'] ) ) ? $_REQUEST['vfb-spam'] : '';
|
2229 |
-
|
2230 |
-
// If the verification is set to required, run validation check
|
2231 |
-
if ( true == $required && !empty( $secret_field ) ) {
|
2232 |
-
if ( !empty( $honeypot ) )
|
2233 |
-
wp_die( __( 'Security check: hidden spam field should be blank.' , 'visual-form-builder'), '', array( 'back_link' => true ) );
|
2234 |
-
if ( !is_numeric( $_REQUEST[ $secret_field ] ) || strlen( $_REQUEST[ $secret_field ] ) !== 2 )
|
2235 |
-
wp_die( __( 'Security check: failed secret question. Please try again!' , 'visual-form-builder'), '', array( 'back_link' => true ) );
|
2236 |
-
}
|
2237 |
-
|
2238 |
-
// Basic security check before moving any further
|
2239 |
-
if ( isset( $_REQUEST['visual-form-builder-submit'] ) ) :
|
2240 |
-
$nonce = $_REQUEST['_wpnonce'];
|
2241 |
-
|
2242 |
-
// Security check to verify the nonce
|
2243 |
-
if ( ! wp_verify_nonce( $nonce, 'visual-form-builder-nonce' ) )
|
2244 |
-
wp_die( __( 'Security check: unable to verify nonce value.' , 'visual-form-builder') );
|
2245 |
-
|
2246 |
-
// Test if it's a known SPAM bot
|
2247 |
-
if ( $this->isBot() )
|
2248 |
-
wp_die( __( 'Security check: looks like you are a SPAM bot. If you think this is an error, please email the site owner.' , 'visual-form-builder') );
|
2249 |
-
|
2250 |
-
// Set submitted action to display success message
|
2251 |
-
$this->submitted = true;
|
2252 |
-
|
2253 |
-
// Tells us which form to get from the database
|
2254 |
-
$form_id = absint( $_REQUEST['form_id'] );
|
2255 |
-
|
2256 |
-
// Query to get all forms
|
2257 |
-
$order = sanitize_sql_orderby( 'form_id DESC' );
|
2258 |
-
$forms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->form_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
2259 |
-
|
2260 |
-
// Get sender and email details
|
2261 |
-
foreach ( $forms as $form ) {
|
2262 |
-
$form_settings = (object) array(
|
2263 |
-
'form_title' => stripslashes( html_entity_decode( $form->form_title, ENT_QUOTES, 'UTF-8' ) ),
|
2264 |
-
'form_subject' => stripslashes( html_entity_decode( $form->form_email_subject, ENT_QUOTES, 'UTF-8' ) ),
|
2265 |
-
'form_to' => ( is_array( unserialize( $form->form_email_to ) ) ) ? unserialize( $form->form_email_to ) : explode( ',', unserialize( $form->form_email_to ) ),
|
2266 |
-
'form_from' => stripslashes( $form->form_email_from ),
|
2267 |
-
'form_from_name' => stripslashes( $form->form_email_from_name ),
|
2268 |
-
'form_notification_setting' => stripslashes( $form->form_notification_setting ),
|
2269 |
-
'form_notification_email_name' => stripslashes( $form->form_notification_email_name ),
|
2270 |
-
'form_notification_email_from' => stripslashes( $form->form_notification_email_from ),
|
2271 |
-
'form_notification_subject' => stripslashes( html_entity_decode( $form->form_notification_subject, ENT_QUOTES, 'UTF-8' ) ),
|
2272 |
-
'form_notification_message' => stripslashes( $form->form_notification_message ),
|
2273 |
-
'form_notification_entry' => stripslashes( $form->form_notification_entry )
|
2274 |
-
);
|
2275 |
-
// Allow the form settings to be filtered (ex: return $form_settings->'form_title' = 'Hello World';)
|
2276 |
-
$form_settings = (object) apply_filters_ref_array( 'vfb_email_form_settings', array( $form_settings, $form_id ) );
|
2277 |
-
}
|
2278 |
-
|
2279 |
-
// Sender name override query
|
2280 |
-
$senders = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_email_from_name_override = fields.field_id WHERE forms.form_id = %d", $form_id ) );
|
2281 |
-
|
2282 |
-
// Sender email override query
|
2283 |
-
$emails = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_email_from_override = fields.field_id WHERE forms.form_id = %d", $form_id ) );
|
2284 |
-
|
2285 |
-
// Notification send to email override query
|
2286 |
-
$notification = $wpdb->get_results( $wpdb->prepare( "SELECT fields.field_id, fields.field_key FROM $this->form_table_name AS forms LEFT JOIN $this->field_table_name AS fields ON forms.form_notification_email = fields.field_id WHERE forms.form_id = %d", $form_id ) );
|
2287 |
-
|
2288 |
-
$reply_to_name = $form_settings->form_from_name;
|
2289 |
-
$reply_to_email = $form_settings->form_from;
|
2290 |
-
|
2291 |
-
// Loop through name results and assign sender name to override, if needed
|
2292 |
-
foreach( $senders as $sender ) {
|
2293 |
-
if ( !empty( $sender->field_key ) ) {
|
2294 |
-
$form_settings->form_from_name = $_POST[ 'vfb-' . $sender->field_id ];
|
2295 |
-
$reply_to_name = $form_settings->form_from_name;
|
2296 |
-
}
|
2297 |
-
}
|
2298 |
-
|
2299 |
-
// Loop through email results and assign sender email to override, if needed
|
2300 |
-
foreach ( $emails as $email ) {
|
2301 |
-
if ( !empty( $email->field_key ) ) {
|
2302 |
-
$form_settings->form_from = $_POST[ 'vfb-' . $email->field_id ];
|
2303 |
-
$reply_to_email = $form_settings->form_from;
|
2304 |
-
}
|
2305 |
-
}
|
2306 |
-
|
2307 |
-
// Loop through email results and assign as blind carbon copy, if needed
|
2308 |
-
foreach ( $notification as $notify ) {
|
2309 |
-
if ( !empty( $notify->field_key ) )
|
2310 |
-
$copy_email = $_POST[ 'vfb-' . $notify->field_id ];
|
2311 |
-
}
|
2312 |
-
|
2313 |
-
// Query to get all forms
|
2314 |
-
$order = sanitize_sql_orderby( 'field_sequence ASC' );
|
2315 |
-
$fields = $wpdb->get_results( $wpdb->prepare( "SELECT field_id, field_key, field_name, field_type, field_options, field_parent, field_required FROM $this->field_table_name WHERE form_id = %d ORDER BY $order", $form_id ) );
|
2316 |
-
|
2317 |
-
// Setup counter for alt rows
|
2318 |
-
$i = $points = 0;
|
2319 |
-
|
2320 |
-
// Setup HTML email vars
|
2321 |
-
$header = $body = $message = $footer = $html_email = $auto_response_email = $attachments = '';
|
2322 |
-
|
2323 |
-
// Prepare the beginning of the content
|
2324 |
-
$header = '<html>
|
2325 |
-
<head>
|
2326 |
-
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
2327 |
-
<title>HTML Email</title>
|
2328 |
-
</head>
|
2329 |
-
<body><table rules="all" style="border-color: #666;" cellpadding="10">' . "\n";
|
2330 |
-
|
2331 |
-
// Loop through each form field and build the body of the message
|
2332 |
-
foreach ( $fields as $field ) {
|
2333 |
-
// Handle attachments
|
2334 |
-
if ( $field->field_type == 'file-upload' ) {
|
2335 |
-
$value = ( isset( $_FILES[ 'vfb-' . $field->field_id ] ) ) ? $_FILES[ 'vfb-' . $field->field_id ] : '';
|
2336 |
-
|
2337 |
-
if ( $value['size'] > 0 ) {
|
2338 |
-
// 25MB is the max size allowed
|
2339 |
-
$size = apply_filters( 'vfb_max_file_size', 25 );
|
2340 |
-
$max_attach_size = $size * 1048576;
|
2341 |
-
|
2342 |
-
// Display error if file size has been exceeded
|
2343 |
-
if ( $value['size'] > $max_attach_size )
|
2344 |
-
wp_die( __( 'File size exceeds 25MB. Most email providers will reject emails with attachments larger than 25MB. Please decrease the file size and try again.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
2345 |
-
|
2346 |
-
// Options array for the wp_handle_upload function. 'test_form' => false
|
2347 |
-
$upload_overrides = array( 'test_form' => false );
|
2348 |
-
|
2349 |
-
// We need to include the file that runs the wp_handle_upload function
|
2350 |
-
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
2351 |
-
|
2352 |
-
// Handle the upload using WP's wp_handle_upload function. Takes the posted file and an options array
|
2353 |
-
$uploaded_file = wp_handle_upload( $value, $upload_overrides );
|
2354 |
-
|
2355 |
-
// If the wp_handle_upload call returned a local path for the image
|
2356 |
-
if ( isset( $uploaded_file['file'] ) ) {
|
2357 |
-
// Retrieve the file type from the file name. Returns an array with extension and mime type
|
2358 |
-
$wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );
|
2359 |
-
|
2360 |
-
// Return the current upload directory location
|
2361 |
-
$wp_upload_dir = wp_upload_dir();
|
2362 |
-
|
2363 |
-
$media_upload = array(
|
2364 |
-
'guid' => $wp_upload_dir['baseurl'] . _wp_relative_upload_path( $uploaded_file['file'] ),
|
2365 |
-
'post_mime_type' => $wp_filetype['type'],
|
2366 |
-
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),
|
2367 |
-
'post_content' => '',
|
2368 |
-
'post_status' => 'inherit'
|
2369 |
-
);
|
2370 |
-
|
2371 |
-
// Insert attachment into Media Library and get attachment ID
|
2372 |
-
$attach_id = wp_insert_attachment( $media_upload, $uploaded_file['file'] );
|
2373 |
-
|
2374 |
-
// Include the file that runs wp_generate_attachment_metadata()
|
2375 |
-
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
2376 |
-
|
2377 |
-
// Setup attachment metadata
|
2378 |
-
$attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
|
2379 |
-
|
2380 |
-
// Update the attachment metadata
|
2381 |
-
wp_update_attachment_metadata( $attach_id, $attach_data );
|
2382 |
-
|
2383 |
-
$attachments[ 'vfb-' . $field->field_id ] = $uploaded_file['file'];
|
2384 |
-
|
2385 |
-
$data[] = array(
|
2386 |
-
'id' => $field->field_id,
|
2387 |
-
'slug' => $field->field_key,
|
2388 |
-
'name' => $field->field_name,
|
2389 |
-
'type' => $field->field_type,
|
2390 |
-
'options' => $field->field_options,
|
2391 |
-
'parent_id' => $field->field_parent,
|
2392 |
-
'value' => $uploaded_file['url']
|
2393 |
-
);
|
2394 |
-
|
2395 |
-
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td><a href="' . $uploaded_file['url'] . '">' . $uploaded_file['url'] . '</a></td></tr>' . "\n";
|
2396 |
-
}
|
2397 |
-
}
|
2398 |
-
else {
|
2399 |
-
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
2400 |
-
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
|
2401 |
-
}
|
2402 |
-
}
|
2403 |
-
// Everything else
|
2404 |
-
else {
|
2405 |
-
$value = ( isset( $_POST[ 'vfb-' . $field->field_id ] ) ) ? $_POST[ 'vfb-' . $field->field_id ] : '';
|
2406 |
-
|
2407 |
-
// If time field, build proper output
|
2408 |
-
if ( is_array( $value ) && array_key_exists( 'hour', $value ) && array_key_exists( 'min', $value ) )
|
2409 |
-
$value = ( array_key_exists( 'ampm', $value ) ) ? substr_replace( implode( ':', $value ), ' ', 5, 1 ) : implode( ':', $value );
|
2410 |
-
// If address field, build proper output
|
2411 |
-
elseif ( is_array( $value ) && array_key_exists( 'address', $value ) && array_key_exists( 'address-2', $value ) ) {
|
2412 |
-
$address = '';
|
2413 |
-
|
2414 |
-
if ( !empty( $value['address'] ) )
|
2415 |
-
$address .= $value['address'];
|
2416 |
-
|
2417 |
-
if ( !empty( $value['address-2'] ) ) {
|
2418 |
-
if ( !empty( $address ) )
|
2419 |
-
$address .= '<br>';
|
2420 |
-
$address .= $value['address-2'];
|
2421 |
-
}
|
2422 |
-
|
2423 |
-
if ( !empty( $value['city'] ) ) {
|
2424 |
-
if ( !empty( $address ) )
|
2425 |
-
$address .= '<br>';
|
2426 |
-
$address .= $value['city'];
|
2427 |
-
}
|
2428 |
-
if ( !empty( $value['state'] ) ) {
|
2429 |
-
if ( !empty( $address ) && empty( $value['city'] ) )
|
2430 |
-
$address .= '<br>';
|
2431 |
-
else if ( !empty( $address ) && !empty( $value['city'] ) )
|
2432 |
-
$address .= ', ';
|
2433 |
-
$address .= $value['state'];
|
2434 |
-
}
|
2435 |
-
if ( !empty( $value['zip'] ) ) {
|
2436 |
-
if ( !empty( $address ) && ( empty( $value['city'] ) && empty( $value['state'] ) ) )
|
2437 |
-
$address .= '<br>';
|
2438 |
-
else if ( !empty( $address ) && ( !empty( $value['city'] ) || !empty( $value['state'] ) ) )
|
2439 |
-
$address .= ' ';
|
2440 |
-
$address .= $value['zip'];
|
2441 |
-
}
|
2442 |
-
if ( !empty( $value['country'] ) ) {
|
2443 |
-
if ( !empty( $address ) )
|
2444 |
-
$address .= '<br>';
|
2445 |
-
$address .= $value['country'];
|
2446 |
-
}
|
2447 |
-
|
2448 |
-
$value = html_entity_decode( stripslashes( esc_html( $address ) ), ENT_QUOTES, 'UTF-8' );
|
2449 |
-
}
|
2450 |
-
// If multiple values, build the list
|
2451 |
-
elseif ( is_array( $value ) )
|
2452 |
-
$value = esc_html( implode( ', ', $value ) );
|
2453 |
-
// Lastly, handle single values
|
2454 |
-
else
|
2455 |
-
$value = html_entity_decode( stripslashes( esc_html( $value ) ), ENT_QUOTES, 'UTF-8' );
|
2456 |
-
|
2457 |
-
// Setup spam catcher RegEx
|
2458 |
-
$exploits = '/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i';
|
2459 |
-
$profanity = '/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|fuck|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i';
|
2460 |
-
$spamwords = '/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i';
|
2461 |
-
|
2462 |
-
// Add up points for each spam hit
|
2463 |
-
if ( preg_match( $exploits, $value ) )
|
2464 |
-
$points += 2;
|
2465 |
-
elseif ( preg_match( $profanity, $value ) )
|
2466 |
-
$points += 1;
|
2467 |
-
elseif ( preg_match( $spamwords, $value ) )
|
2468 |
-
$points += 1;
|
2469 |
-
|
2470 |
-
//Sanitize input
|
2471 |
-
$value = $this->sanitize_input( $value, $field->field_type );
|
2472 |
-
|
2473 |
-
// Validate input
|
2474 |
-
$this->validate_input( $value, $field->field_name, $field->field_type, $field->field_required );
|
2475 |
-
|
2476 |
-
if ( !in_array( $field->field_type , array( 'verification', 'secret', 'submit' ) ) ) {
|
2477 |
-
if ( $field->field_type == 'fieldset' )
|
2478 |
-
$body .= '<tr style="background-color:#393E40;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
2479 |
-
elseif ( $field->field_type == 'section' )
|
2480 |
-
$body .= '<tr style="background-color:#6E7273;color:white;font-size:14px;"><td colspan="2">' . stripslashes( $field->field_name ) . '</td></tr>' . "\n";
|
2481 |
-
else
|
2482 |
-
$body .= '<tr><td><strong>' . stripslashes( $field->field_name ) . ': </strong></td><td>' . $value . '</td></tr>' . "\n";
|
2483 |
-
}
|
2484 |
-
|
2485 |
-
$data[] = array(
|
2486 |
-
'id' => $field->field_id,
|
2487 |
-
'slug' => $field->field_key,
|
2488 |
-
'name' => $field->field_name,
|
2489 |
-
'type' => $field->field_type,
|
2490 |
-
'options' => $field->field_options,
|
2491 |
-
'parent_id' => $field->field_parent,
|
2492 |
-
'value' => esc_html( $value )
|
2493 |
-
);
|
2494 |
-
}
|
2495 |
-
}
|
2496 |
-
|
2497 |
-
// Setup our entries data
|
2498 |
-
$entry = array(
|
2499 |
-
'form_id' => $form_id,
|
2500 |
-
'data' => serialize( $data ),
|
2501 |
-
'subject' => $form_settings->form_subject,
|
2502 |
-
'sender_name' => $form_settings->form_from_name,
|
2503 |
-
'sender_email' => $form_settings->form_from,
|
2504 |
-
'emails_to' => serialize( $form_settings->form_to ),
|
2505 |
-
'date_submitted' => date_i18n( 'Y-m-d G:i:s' ),
|
2506 |
-
'ip_address' => $_SERVER['REMOTE_ADDR']
|
2507 |
-
);
|
2508 |
-
|
2509 |
-
// Insert this data into the entries table
|
2510 |
-
$wpdb->insert( $this->entries_table_name, $entry );
|
2511 |
-
|
2512 |
-
// Close out the content
|
2513 |
-
$footer .= '<tr><td class="footer" height="61" align="left" valign="middle" colspan="2"><p style="font-size: 12px; font-weight: normal; margin: 0; line-height: 16px; padding: 0;">This email was built and sent using <a href="http://wordpress.org/extend/plugins/visual-form-builder/" style="font-size: 12px;">Visual Form Builder</a>.</p></td></tr></table></body></html>' . "\n";
|
2514 |
-
|
2515 |
-
// Build complete HTML email
|
2516 |
-
$message = $header . $body . $footer;
|
2517 |
-
|
2518 |
-
// Decode HTML for message so it outputs properly
|
2519 |
-
$notify_message = ( $form_settings->form_notification_message !== '' ) ? html_entity_decode( $form_settings->form_notification_message ) : '';
|
2520 |
-
|
2521 |
-
// Initialize header filter vars
|
2522 |
-
$this->header_from_name = stripslashes( $reply_to_name );
|
2523 |
-
$this->header_from = $reply_to_email;
|
2524 |
-
$this->header_content_type = 'text/html';
|
2525 |
-
|
2526 |
-
// Either prepend the notification message to the submitted entry, or send by itself
|
2527 |
-
if ( $form_settings->form_notification_entry !== '' )
|
2528 |
-
$auto_response_email = $header . $notify_message . $body . $footer;
|
2529 |
-
else
|
2530 |
-
$auto_response_email = $header . '<table cellspacing="0" border="0" cellpadding="0" width="100%"><tr><td colspan="2" class="mainbar" align="left" valign="top" width="600">' . $notify_message . '</td></tr>' . $footer;
|
2531 |
-
|
2532 |
-
|
2533 |
-
// Build email headers
|
2534 |
-
$from_name = ( $this->header_from_name == '' ) ? 'WordPress' : $this->header_from_name;
|
2535 |
-
$from_email = get_site_option( 'admin_email' );
|
2536 |
-
$reply_to = "\"$this->header_from_name\" <$this->header_from>";
|
2537 |
-
$headers = "From: \"$from_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
|
2538 |
-
|
2539 |
-
// Send the mail
|
2540 |
-
foreach ( $form_settings->form_to as $email ) {
|
2541 |
-
wp_mail( $email, wp_specialchars_decode( $form_settings->form_subject, ENT_QUOTES ), $message, $headers, $attachments );
|
2542 |
-
}
|
2543 |
-
|
2544 |
-
// Send auto-responder email
|
2545 |
-
if ( $form_settings->form_notification_setting !== '' ) :
|
2546 |
-
|
2547 |
-
$attachments = ( $form_settings->form_notification_entry !== '' ) ? $attachments : '';
|
2548 |
-
|
2549 |
-
// Reset headers for notification email
|
2550 |
-
$reply_name = stripslashes( $form_settings->form_notification_email_name );
|
2551 |
-
$reply_email = $form_settings->form_notification_email_from;
|
2552 |
-
$reply_to = "\"$reply_name\" <$reply_email>";
|
2553 |
-
$headers = "From: \"$reply_name\" <$from_email>\n" . "Reply-To: $reply_to\n" . "Content-Type: $this->header_content_type; charset=\"" . get_option('blog_charset') . "\"\n";
|
2554 |
-
|
2555 |
-
// Send the mail
|
2556 |
-
wp_mail( $copy_email, wp_specialchars_decode( $form_settings->form_notification_subject ), $auto_response_email, $headers, $attachments );
|
2557 |
-
endif;
|
2558 |
-
|
2559 |
-
endif;
|
2560 |
-
}
|
2561 |
-
|
2562 |
-
/**
|
2563 |
-
* Validate the input
|
2564 |
-
*
|
2565 |
-
* @since 2.2
|
2566 |
-
*/
|
2567 |
-
public function validate_input( $data, $name, $type, $required ) {
|
2568 |
-
|
2569 |
-
if ( 'yes' == $required && strlen( $data ) == 0 )
|
2570 |
-
wp_die( "<h1>$name</h1><br>" . __( 'This field is required and cannot be empty.', 'visual-form-builder' ), $name, array( 'back_link' => true ) );
|
2571 |
-
|
2572 |
-
if ( strlen( $data ) > 0 ) :
|
2573 |
-
switch( $type ) {
|
2574 |
-
|
2575 |
-
case 'email' :
|
2576 |
-
if ( !is_email( $data ) )
|
2577 |
-
wp_die( "<h1>$name</h1><br>" . __( 'Not a valid email address', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
2578 |
-
break;
|
2579 |
-
|
2580 |
-
case 'number' :
|
2581 |
-
case 'currency' :
|
2582 |
-
if ( !is_numeric( $data ) )
|
2583 |
-
wp_die( "<h1>$name</h1><br>" . __( 'Not a valid number', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
2584 |
-
break;
|
2585 |
-
|
2586 |
-
case 'phone' :
|
2587 |
-
if ( strlen( $data ) > 9 && preg_match( '/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/', $data ) )
|
2588 |
-
return true;
|
2589 |
-
else
|
2590 |
-
wp_die( "<h1>$name</h1><br>" . __( 'Not a valid phone number. Most US/Canada and International formats accepted.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
2591 |
-
break;
|
2592 |
-
|
2593 |
-
case 'url' :
|
2594 |
-
if ( !preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $data ) )
|
2595 |
-
wp_die( "<h1>$name</h1><br>" . __( 'Not a valid URL.', 'visual-form-builder' ), '', array( 'back_link' => true ) );
|
2596 |
-
break;
|
2597 |
-
|
2598 |
-
default :
|
2599 |
-
return true;
|
2600 |
-
break;
|
2601 |
-
}
|
2602 |
-
endif;
|
2603 |
-
}
|
2604 |
-
|
2605 |
-
/**
|
2606 |
-
* Sanitize the input
|
2607 |
-
*
|
2608 |
-
* @since 2.5
|
2609 |
-
*/
|
2610 |
-
public function sanitize_input( $data, $type ) {
|
2611 |
-
if ( strlen( $data ) > 0 ) :
|
2612 |
-
switch( $type ) {
|
2613 |
-
case 'text' :
|
2614 |
-
return sanitize_text_field( $data );
|
2615 |
-
break;
|
2616 |
-
|
2617 |
-
case 'textarea' :
|
2618 |
-
return wpautop( $data );
|
2619 |
-
break;
|
2620 |
-
|
2621 |
-
case 'email' :
|
2622 |
-
return sanitize_email( $data );
|
2623 |
-
break;
|
2624 |
-
|
2625 |
-
case 'username' :
|
2626 |
-
return sanitize_user( $data );
|
2627 |
-
break;
|
2628 |
-
|
2629 |
-
default :
|
2630 |
-
return $data;
|
2631 |
-
break;
|
2632 |
-
}
|
2633 |
-
endif;
|
2634 |
-
}
|
2635 |
-
|
2636 |
-
/**
|
2637 |
-
* Make sure the User Agent string is not a SPAM bot
|
2638 |
-
*
|
2639 |
-
* @since 1.3
|
2640 |
-
*/
|
2641 |
-
public function isBot() {
|
2642 |
-
$bots = apply_filters( 'vfb_blocked_spam_bots', array( 'archiver', 'binlar', 'casper', 'checkprivacy', 'clshttp', 'cmsworldmap', 'comodo', 'curl', 'diavol', 'dotbot', 'email', 'extract', 'feedfinder', 'flicky', 'grab', 'harvest', 'httrack', 'ia_archiver', 'jakarta', 'kmccrew', 'libwww', 'loader', 'miner', 'nikto', 'nutch', 'planetwork', 'purebot', 'pycurl', 'python', 'scan', 'skygrid', 'sucker', 'turnit', 'vikspider', 'wget', 'winhttp', 'youda', 'zmeu', 'zune' ) );
|
2643 |
-
|
2644 |
-
$isBot = false;
|
2645 |
-
|
2646 |
-
foreach ( $bots as $bot ) {
|
2647 |
-
if ( stripos( $_SERVER['HTTP_USER_AGENT'], $bot ) !== false )
|
2648 |
-
$isBot = true;
|
2649 |
-
}
|
2650 |
-
|
2651 |
-
if ( empty($_SERVER['HTTP_USER_AGENT'] ) || $_SERVER['HTTP_USER_AGENT'] == ' ' )
|
2652 |
-
$isBot = true;
|
2653 |
-
|
2654 |
-
return $isBot;
|
2655 |
-
}
|
2656 |
-
}
|
2657 |
-
|
2658 |
// On plugin activation, install the databases and add/update the DB version
|
2659 |
register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
|
2660 |
?>
|
4 |
Description: Dynamically build forms using a simple interface. Forms include jQuery validation, a basic logic-based verification system, and entry tracking.
|
5 |
Author: Matthew Muro
|
6 |
Author URI: http://matthewmuro.com
|
7 |
+
Version: 2.6.4
|
8 |
*/
|
9 |
|
10 |
/*
|
31 |
// Visual Form Builder class
|
32 |
class Visual_Form_Builder{
|
33 |
|
34 |
+
protected $vfb_db_version = '2.6.4',
|
35 |
$add_scripts = false;
|
36 |
|
37 |
public $countries = array( "", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombi", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States of America", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe" );
|
1880 |
}
|
1881 |
}
|
1882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1883 |
// On plugin activation, install the databases and add/update the DB version
|
1884 |
register_activation_hook( __FILE__, array( 'Visual_Form_Builder', 'install_db' ) );
|
1885 |
?>
|