Custom Contact Forms - Version 4.0.0.b1

Version Description

Popover forms will be added in September 2010.

Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Custom Contact Forms
Version 4.0.0.b1
Comparing to
See all releases

Code changes from version 3.5.8 to 4.0.0.b1

css/custom-contact-forms-admin.css CHANGED
@@ -72,6 +72,15 @@
72
  #customcontactforms-admin #form-submissions table.second { margin-left:48%; border-collapse:collapse; width:48%; }
73
 
74
 
 
 
 
 
 
 
 
 
 
75
  #customcontactforms-admin #field-options {
76
  clear:both;
77
  width:1000px;
72
  #customcontactforms-admin #form-submissions table.second { margin-left:48%; border-collapse:collapse; width:48%; }
73
 
74
 
75
+ #customcontactforms-admin #import-export {
76
+ clear:both;
77
+ width:1000px;
78
+ margin:20px 1em 1em 5px;
79
+ }
80
+ #customcontactforms-admin #import-export .import { float:left; margin:0; padding:0; width:48%; }
81
+ #customcontactforms-admin #import-export .export { margin-left:50%; width:48%; }
82
+ #customcontactforms-admin #import-export p { padding:0 0 5px 0; margin:0; }
83
+
84
  #customcontactforms-admin #field-options {
85
  clear:both;
86
  width:1000px;
css/custom-contact-forms-standards.css CHANGED
@@ -11,4 +11,7 @@
11
  .floatleft { float:left; }
12
  .floatright { float:right; }
13
  .form-extra-options-table { margin:0 auto 0 auto; }
14
- .evenrow { background-color:#f5f5f5; }
 
 
 
11
  .floatleft { float:left; }
12
  .floatright { float:right; }
13
  .form-extra-options-table { margin:0 auto 0 auto; }
14
+ .evenrow { background-color:#f5f5f5; }
15
+ .alignright { text-align:right; }
16
+ .alignleft { text-align:right; }
17
+ .ccf-loading-icon { margin-left: 5px; margin-right:7px; }
custom-contact-forms-db.php CHANGED
@@ -6,34 +6,11 @@
6
  */
7
  if (!class_exists('CustomContactFormsDB')) {
8
  class CustomContactFormsDB {
9
- var $forms_table;
10
- var $fields_table;
11
- var $styles_table;
12
- var $field_options_table;
13
  var $cache = array();
14
- function CustomContactFormsDB() {
15
- global $wpdb;
16
- $table_prefix = $wpdb->prefix;
17
- $this->forms_table = $table_prefix . 'customcontactforms_forms';
18
- $this->fields_table = $table_prefix . 'customcontactforms_fields';
19
- $this->styles_table = $table_prefix . 'customcontactforms_styles';
20
- $this->field_options_table = $table_prefix . 'customcontactforms_field_options';
21
- }
22
-
23
- function encodeOption($option) {
24
- return htmlspecialchars(stripslashes($option), ENT_QUOTES);
25
- }
26
-
27
- function decodeOption($option, $strip_slashes = 1, $decode_html_chars = 1) {
28
- if ($strip_slashes == 1) $option = stripslashes($option);
29
- if ($decode_html_chars == 1) $option = html_entity_decode($option);
30
- return $option;
31
- }
32
-
33
  function createTables() {
34
  global $wpdb;
35
  if(!$this->formsTableExists()) {
36
- $sql1 = " CREATE TABLE `".$this->forms_table."` (
37
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
38
  `form_slug` VARCHAR( 100 ) NOT NULL ,
39
  `form_title` VARCHAR( 200 ) NOT NULL ,
@@ -45,8 +22,18 @@ if (!class_exists('CustomContactFormsDB')) {
45
  PRIMARY KEY ( `id` )
46
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
47
  $wpdb->query($sql1);
 
 
 
 
 
 
 
 
 
 
48
  } if(!$this->fieldOptionsTableExists()) {
49
- $sql5 = " CREATE TABLE `".$this->field_options_table."` (
50
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
51
  `option_slug` VARCHAR( 100 ) NOT NULL ,
52
  `option_label` VARCHAR( 200 ) NOT NULL ,
@@ -55,7 +42,7 @@ if (!class_exists('CustomContactFormsDB')) {
55
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
56
  $wpdb->query($sql5);
57
  } if(!$this->fieldsTableExists()) {
58
- $sql2 = "CREATE TABLE `".$this->fields_table."` (
59
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
60
  `field_slug` VARCHAR( 50 ) NOT NULL ,
61
  `field_label` VARCHAR( 100 ) NOT NULL ,
@@ -67,8 +54,7 @@ if (!class_exists('CustomContactFormsDB')) {
67
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
68
  $wpdb->query($sql2);
69
  } if(!$this->stylesTableExists()) {
70
- // Title, input, textarea, label, form, submit
71
- $sql3 = "CREATE TABLE `".$this->styles_table."` (
72
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
73
  `style_slug` VARCHAR( 30 ) NOT NULL ,
74
  `input_width` VARCHAR( 10 ) NOT NULL DEFAULT '200px',
@@ -83,13 +69,13 @@ if (!class_exists('CustomContactFormsDB')) {
83
  `title_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1.2em',
84
  `field_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1em',
85
  `submit_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1.1em',
86
- `field_bordercolor` VARCHAR( 10 ) NOT NULL DEFAULT 'blue',
87
  `form_borderstyle` VARCHAR( 30 ) NOT NULL DEFAULT 'dashed',
88
- `form_bordercolor` VARCHAR( 20 ) NOT NULL DEFAULT 'black',
89
- `field_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#000000',
90
- `label_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#333333',
91
- `title_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#333333',
92
- `submit_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#333333',
93
  `form_fontfamily` VARCHAR( 150 ) NOT NULL DEFAULT 'Verdana, Tahoma, Arial',
94
  PRIMARY KEY ( `id` )
95
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
@@ -104,52 +90,55 @@ if (!class_exists('CustomContactFormsDB')) {
104
 
105
  function updateTables() {
106
  global $wpdb;
107
- if (!$this->columnExists('user_field', $this->fields_table))
108
- $wpdb->query("ALTER TABLE `" . $this->fields_table . "` ADD `user_field` INT( 1 ) NOT NULL DEFAULT '1'");
109
- if (!$this->columnExists('form_style', $this->forms_table))
110
- $wpdb->query("ALTER TABLE `" . $this->forms_table . "` ADD `form_style` INT( 10 ) NOT NULL DEFAULT '0'");
111
- if (!$this->columnExists('form_email', $this->forms_table))
112
- $wpdb->query("ALTER TABLE `" . $this->forms_table . "` ADD `form_email` VARCHAR( 50 ) NOT NULL");
113
- if (!$this->columnExists('form_success_message', $this->forms_table))
114
- $wpdb->query("ALTER TABLE `" . $this->forms_table . "` ADD `form_success_message` TEXT NOT NULL");
115
- if (!$this->columnExists('form_thank_you_page', $this->forms_table))
116
- $wpdb->query("ALTER TABLE `" . $this->forms_table . "` ADD `form_thank_you_page` VARCHAR ( 200 ) NOT NULL");
117
- if (!$this->columnExists('field_backgroundcolor', $this->styles_table))
118
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `field_backgroundcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#efefef'");
119
- if (!$this->columnExists('field_borderstyle', $this->styles_table))
120
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `field_borderstyle` VARCHAR( 20 ) NOT NULL DEFAULT 'solid'");
121
- if (!$this->columnExists('form_success_title', $this->forms_table))
122
- $wpdb->query("ALTER TABLE `" . $this->forms_table . "` ADD `form_success_title` VARCHAR( 150 ) NOT NULL DEFAULT 'Form Success!'");
123
- if (!$this->columnExists('form_padding', $this->styles_table))
124
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `form_padding` VARCHAR( 20 ) NOT NULL DEFAULT '4px'");
125
- if (!$this->columnExists('form_margin', $this->styles_table))
126
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `form_margin` VARCHAR( 20 ) NOT NULL DEFAULT '4px'");
127
- if (!$this->columnExists('title_margin', $this->styles_table))
128
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `title_margin` VARCHAR( 20 ) NOT NULL DEFAULT '2px'");
129
- if (!$this->columnExists('label_margin', $this->styles_table))
130
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `label_margin` VARCHAR( 20 ) NOT NULL DEFAULT '3px'");
131
- if (!$this->columnExists('textarea_backgroundcolor', $this->styles_table))
132
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `textarea_backgroundcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#efefef'");
133
- if (!$this->columnExists('success_popover_bordercolor', $this->styles_table))
134
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_bordercolor` VARCHAR( 20 ) NOT NULL DEFAULT '#efefef'");
135
- if (!$this->columnExists('dropdown_width', $this->styles_table))
136
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `dropdown_width` VARCHAR( 20 ) NOT NULL DEFAULT 'auto'");
137
- if (!$this->columnExists('success_popover_fontsize', $this->styles_table))
138
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_fontsize` VARCHAR( 20 ) NOT NULL DEFAULT '12px'");
139
- if (!$this->columnExists('success_popover_title_fontsize', $this->styles_table))
140
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_title_fontsize` VARCHAR( 20 ) NOT NULL DEFAULT '1.3em'");
141
- if (!$this->columnExists('success_popover_height', $this->styles_table))
142
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_height` VARCHAR( 20 ) NOT NULL DEFAULT '200px'");
143
- if (!$this->columnExists('success_popover_fontcolor', $this->styles_table))
144
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#333333'");
145
- if (!$this->columnExists('success_popover_title_fontcolor', $this->styles_table))
146
- $wpdb->query("ALTER TABLE `" . $this->styles_table . "` ADD `success_popover_title_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '#333333'");
147
- if (!$this->columnExists('field_instructions', $this->fields_table))
148
- $wpdb->query("ALTER TABLE `" . $this->fields_table . "` ADD `field_instructions` TEXT NOT NULL");
149
- if (!$this->columnExists('field_options', $this->fields_table))
150
- $wpdb->query("ALTER TABLE `" . $this->fields_table . "` ADD `field_options` VARCHAR( 300 ) NOT NULL");
151
- if (!$this->columnExists('field_required', $this->fields_table))
152
- $wpdb->query("ALTER TABLE `" . $this->fields_table . "` ADD `field_required` INT( 1 ) NOT NULL DEFAULT '0'");
 
 
 
153
  }
154
 
155
  function insertFixedFields() {
@@ -157,12 +146,11 @@ if (!class_exists('CustomContactFormsDB')) {
157
  $ishuman = array('field_slug' => 'ishuman', 'field_label' => 'Check if you are human.', 'field_type' => 'Checkbox', 'field_value' => '1', 'field_maxlength' => '0', 'user_field' => 0, 'field_instructions' => 'This helps us prevent spam.');
158
  $fixedEmail = array('field_slug' => 'fixedEmail', 'field_label' => 'Your Email', 'field_type' => 'Text', 'field_value' => '', 'field_maxlength' => '100', 'user_field' => 0, 'field_instructions' => 'Please enter your email address.');
159
  if (!$this->fieldSlugExists('captcha'))
160
- $this->insertField($captcha);
161
  if (!$this->fieldSlugExists('ishuman'))
162
- $this->insertField($ishuman);
163
  if (!$this->fieldSlugExists('fixedEmail'))
164
- $this->insertField($fixedEmail);
165
-
166
  }
167
 
168
  /*function columnExists($column, $table) {
@@ -189,20 +177,20 @@ if (!class_exists('CustomContactFormsDB')) {
189
  global $wpdb;
190
  if (empty($form) or empty($form[form_slug]) or $this->formSlugExists($this->formatSlug($form[form_slug]))) return false;
191
  $form[form_slug] = $this->formatSlug($form[form_slug]);
192
- $form = array_map(array(&$this, 'encodeOption'), $form);
193
- $wpdb->insert($this->forms_table, $form);
 
194
  return $wpdb->insert_id;
195
  }
196
 
197
- function insertField($field) {
198
  global $wpdb;
199
- if (empty($field) or empty($field[field_slug]) or $this->fieldSlugExists($this->formatSlug($field[field_slug]))) return false;
 
200
  $field[field_slug] = $this->formatSlug($field[field_slug]);
201
- foreach ($field as $key => $value) {
202
- if ($key != 'field_slug')
203
- $field[$key] = $this->encodeOption($value);
204
- }
205
- $wpdb->insert($this->fields_table, $field);
206
  return $wpdb->insert_id;
207
  }
208
 
@@ -210,8 +198,9 @@ if (!class_exists('CustomContactFormsDB')) {
210
  global $wpdb;
211
  if (empty($option) or empty($option[option_slug]) or $this->fieldOptionsSlugExists($this->formatSlug($option[option_slug]))) return false;
212
  $option[option_slug] = $this->formatSlug($option[option_slug]);
213
- $option = array_map(array(&$this, 'encodeOption'), $option);
214
- $wpdb->insert($this->field_options_table, $option);
 
215
  return $wpdb->insert_id;
216
  }
217
 
@@ -219,33 +208,36 @@ if (!class_exists('CustomContactFormsDB')) {
219
  global $wpdb;
220
  if (empty($style) or empty($style[style_slug]) or $this->styleSlugExists($this->formatSlug($style[style_slug]))) return false;
221
  $style[style_slug] = $this->formatSlug($style[style_slug]);
222
- foreach ($style as $key => $value) {
223
- if ($key != 'style_slug')
224
- $style[$key] = $this->formatStyle($this->encodeOption($value));
225
- }
226
- $wpdb->insert($this->styles_table, $style);
227
  return $wpdb->insert_id;
228
  }
229
 
230
 
231
  function fieldsTableExists() {
232
  global $wpdb;
233
- return ($wpdb->get_var("show tables like '". $this->fields_table . "'") == $this->fields_table);
234
  }
235
 
236
  function formsTableExists() {
237
  global $wpdb;
238
- return ($wpdb->get_var("show tables like '". $this->forms_table . "'") == $this->forms_table);
239
  }
240
 
241
  function stylesTableExists() {
242
  global $wpdb;
243
- return ($wpdb->get_var("show tables like '". $this->styles_table . "'") == $this->styles_table);
244
  }
245
 
246
  function fieldOptionsTableExists() {
247
  global $wpdb;
248
- return ($wpdb->get_var("show tables like '". $this->field_options_table . "'") == $this->field_options_table);
 
 
 
 
 
249
  }
250
 
251
  function updateForm($form, $fid) {
@@ -255,8 +247,9 @@ if (!class_exists('CustomContactFormsDB')) {
255
  if (!empty($test) and $test->id != $fid) return false;
256
  $form[form_slug] = $this->formatSlug($form[form_slug]);
257
  }
258
- $form = array_map(array(&$this, 'encodeOption'), $form);
259
- $wpdb->update($this->forms_table, $form, array('id' => $fid));
 
260
  return true;
261
  }
262
 
@@ -264,12 +257,13 @@ if (!class_exists('CustomContactFormsDB')) {
264
  global $wpdb;
265
  if (!empty($field[field_slug])) {
266
  $test = $this->selectField('', $this->formatSlug($field[field_slug]));
267
- if (!empty($test) and $test->id != $fid)
268
  return false;
269
  $field[field_slug] = $this->formatSlug($field[field_slug]);
270
  }
271
- $field = array_map(array(&$this, 'encodeOption'), $field);
272
- $wpdb->update($this->fields_table, $field, array('id' => $fid));
 
273
  return true;
274
  }
275
 
@@ -281,8 +275,9 @@ if (!class_exists('CustomContactFormsDB')) {
281
  return false;
282
  $option[option_slug] = $this->formatSlug($option[option_slug]);
283
  }
284
- $option = array_map(array(&$this, 'encodeOption'), $option);
285
- $wpdb->update($this->field_options_table, $option, array('id' => $oid));
 
286
  return true;
287
  }
288
 
@@ -293,18 +288,16 @@ if (!class_exists('CustomContactFormsDB')) {
293
  if (!empty($test) and $test->id != $sid) // if style_slug is different then make sure it is unique
294
  return false;
295
  $style[style_slug] = $this->formatSlug($style[style_slug]);
296
- foreach ($style as $key => $value) {
297
- if ($key != 'style_slug')
298
- $style[$key] = $this->formatStyle($this->encodeOption($value));
299
- }
300
- $wpdb->update($this->styles_table, $style, array('id' => $sid));
301
  return true;
302
  }
303
 
304
  function deleteForm($fid, $slug = NULL) {
305
  global $wpdb;
306
  $where_params = ($slug == NULL) ? "id='$fid'" : "form_slug='$slug'";
307
- $wpdb->query("DELETE FROM " . $this->forms_table . ' WHERE ' . $where_params);
308
  return true;
309
  }
310
 
@@ -312,15 +305,21 @@ if (!class_exists('CustomContactFormsDB')) {
312
  global $wpdb;
313
  $this->dettachFieldAll($fid);
314
  $where_params = ($slug == NULL) ? "id='$fid'" : "field_slug='$slug'";
315
- $wpdb->query("DELETE FROM " . $this->fields_table . ' WHERE ' . $where_params);
316
  return false;
317
  }
318
 
 
 
 
 
 
 
319
  function deleteStyle($sid, $slug = NULL) {
320
  global $wpdb;
321
  $this->dettachStyleAll($sid);
322
  $where_params = ($slug == NULL) ? "id='$sid'" : "style_slug='$slug'";
323
- $wpdb->query("DELETE FROM " . $this->styles_table . ' WHERE ' . $where_params);
324
  return true;
325
  }
326
 
@@ -328,56 +327,80 @@ if (!class_exists('CustomContactFormsDB')) {
328
  global $wpdb;
329
  $this->dettachFieldOptionAll($oid);
330
  $where_params = ($slug == NULL) ? "id='$oid'" : "option_slug='$slug'";
331
- $wpdb->query("DELETE FROM " . $this->field_options_table . ' WHERE ' . $where_params);
 
 
 
 
 
 
332
  return true;
333
  }
334
 
 
 
 
 
 
335
  function selectAllForms() {
336
  global $wpdb;
337
- return $wpdb->get_results("SELECT * FROM " . $this->forms_table . " ORDER BY form_slug ASC");
338
  }
339
 
340
  function selectAllFields() {
341
  global $wpdb;
342
- return $wpdb->get_results("SELECT * FROM " . $this->fields_table . " ORDER BY field_slug ASC");
343
  }
344
 
345
  function selectAllFieldOptions() {
346
  global $wpdb;
347
- return $wpdb->get_results("SELECT * FROM " . $this->field_options_table . " ORDER BY option_slug ASC");
348
  }
349
 
350
  function selectAllStyles() {
351
  global $wpdb;
352
- return $wpdb->get_results("SELECT * FROM " . $this->styles_table . " ORDER BY style_slug ASC");
 
 
 
 
 
353
  }
354
 
355
  function selectForm($fid, $form_slug = '') {
356
  global $wpdb;
357
  $extra = (!empty($form_slug)) ? " or form_slug = '$form_slug'" : '';
358
- return $wpdb->get_row("SELECT * FROM " . $this->forms_table . " WHERE id='$fid' $extra");
359
  }
360
 
361
  function selectStyle($sid, $style_slug = '') {
362
  global $wpdb;
363
  $extra = (!empty($style_slug)) ? " or style_slug = '$style_slug'" : '';
364
- return $wpdb->get_row("SELECT * FROM " . $this->styles_table . " WHERE id='$sid' $extra");
365
  }
366
 
367
  function selectField($fid, $field_slug = '') {
368
  global $wpdb;
369
  $extra = (!empty($field_slug)) ? " or field_slug = '$field_slug'" : '';
370
- return $wpdb->get_row("SELECT * FROM " . $this->fields_table . " WHERE id='$fid'" . $extra);
371
  }
372
 
373
  function selectFieldOption($oid, $option_slug = '') {
374
  global $wpdb;
375
  $extra = (!empty($option_slug)) ? " or option_slug = '$option_slug'" : '';
376
- return $wpdb->get_row("SELECT * FROM " . $this->field_options_table . " WHERE id='$oid'" . $extra);
 
 
 
 
 
377
  }
378
 
379
  function addFieldToForm($field_id, $form_id) {
380
- $form = $this->selectForm($form_id, '');
 
 
 
381
  $fields = $this->getAttachedFieldsArray($form_id);
382
  if (!in_array($field_id, $fields)) {
383
  $new_fields = $form->form_fields . $field_id . ',';
@@ -388,7 +411,10 @@ if (!class_exists('CustomContactFormsDB')) {
388
  }
389
 
390
  function addFieldOptionToField($option_id, $field_id) {
 
 
391
  $field = $this->selectField($field_id);
 
392
  $options = $this->getAttachedFieldOptionsArray($field_id);
393
  if (!in_array($option_id, $options)) {
394
  $new_options = $field->field_options . $option_id . ',';
@@ -480,6 +506,14 @@ if (!class_exists('CustomContactFormsDB')) {
480
  return (!empty($test));
481
  }
482
 
 
 
 
 
 
 
 
 
483
  function insertDefaultContent($overwrite = false) {
484
  $field_slugs = array('name' => 'ccf_name', 'message' => 'ccf_message',
485
  'website' => 'ccf_website', 'phone' => 'ccf_phone', 'google' => 'ccf_google',
@@ -505,7 +539,7 @@ if (!class_exists('CustomContactFormsDB')) {
505
  'field_maxlength' => 30, 'field_type' => 'Text');
506
  $google_field = array('field_slug' => $field_slugs[google], 'field_label' => 'Did you find my website through Google?',
507
  'field_required' => 0, 'field_instructions' => 'If you found my website through Google, check this box.',
508
- 'field_maxlength' => 0, 'field_type' => 'Checkbox');
509
  $contact_method_field = array('field_slug' => $field_slugs[contact_method], 'field_label' => 'How should we contact you?',
510
  'field_required' => 1, 'field_instructions' => 'By which method we should contact you?',
511
  'field_maxlength' => 0, 'field_type' => 'Dropdown');
6
  */
7
  if (!class_exists('CustomContactFormsDB')) {
8
  class CustomContactFormsDB {
 
 
 
 
9
  var $cache = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  function createTables() {
11
  global $wpdb;
12
  if(!$this->formsTableExists()) {
13
+ $sql1 = " CREATE TABLE `".CCF_FORMS_TABLE."` (
14
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
15
  `form_slug` VARCHAR( 100 ) NOT NULL ,
16
  `form_title` VARCHAR( 200 ) NOT NULL ,
22
  PRIMARY KEY ( `id` )
23
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
24
  $wpdb->query($sql1);
25
+ } if(!$this->userDataTableExists()) {
26
+ $sql7 = " CREATE TABLE `".CCF_USER_DATA_TABLE."` (
27
+ `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
28
+ `data_time` INT( 11 ) NOT NULL DEFAULT '0',
29
+ `data_formid` INT( 11 ) NOT NULL ,
30
+ `data_formpage` VARCHAR ( 250 ) NOT NULL ,
31
+ `data_value` LONGTEXT NOT NULL ,
32
+ PRIMARY KEY ( `id` )
33
+ ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
34
+ $wpdb->query($sql7);
35
  } if(!$this->fieldOptionsTableExists()) {
36
+ $sql5 = " CREATE TABLE `".CCF_FIELD_OPTIONS_TABLE."` (
37
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
38
  `option_slug` VARCHAR( 100 ) NOT NULL ,
39
  `option_label` VARCHAR( 200 ) NOT NULL ,
42
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
43
  $wpdb->query($sql5);
44
  } if(!$this->fieldsTableExists()) {
45
+ $sql2 = "CREATE TABLE `".CCF_FIELDS_TABLE."` (
46
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
47
  `field_slug` VARCHAR( 50 ) NOT NULL ,
48
  `field_label` VARCHAR( 100 ) NOT NULL ,
54
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
55
  $wpdb->query($sql2);
56
  } if(!$this->stylesTableExists()) {
57
+ $sql3 = "CREATE TABLE `".CCF_STYLES_TABLE."` (
 
58
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
59
  `style_slug` VARCHAR( 30 ) NOT NULL ,
60
  `input_width` VARCHAR( 10 ) NOT NULL DEFAULT '200px',
69
  `title_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1.2em',
70
  `field_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1em',
71
  `submit_fontsize` VARCHAR( 10 ) NOT NULL DEFAULT '1.1em',
72
+ `field_bordercolor` VARCHAR( 10 ) NOT NULL DEFAULT '999999',
73
  `form_borderstyle` VARCHAR( 30 ) NOT NULL DEFAULT 'dashed',
74
+ `form_bordercolor` VARCHAR( 20 ) NOT NULL DEFAULT 'white',
75
+ `field_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '000000',
76
+ `label_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '333333',
77
+ `title_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '333333',
78
+ `submit_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '333333',
79
  `form_fontfamily` VARCHAR( 150 ) NOT NULL DEFAULT 'Verdana, Tahoma, Arial',
80
  PRIMARY KEY ( `id` )
81
  ) ENGINE = MYISAM AUTO_INCREMENT=1 ";
90
 
91
  function updateTables() {
92
  global $wpdb;
93
+ if (!$this->columnExists('user_field', CCF_FIELDS_TABLE))
94
+ $wpdb->query("ALTER TABLE `" . CCF_FIELDS_TABLE . "` ADD `user_field` INT( 1 ) NOT NULL DEFAULT '1'");
95
+ if (!$this->columnExists('form_style', CCF_FORMS_TABLE))
96
+ $wpdb->query("ALTER TABLE `" . CCF_FORMS_TABLE . "` ADD `form_style` INT( 10 ) NOT NULL DEFAULT '0'");
97
+ if (!$this->columnExists('form_email', CCF_FORMS_TABLE))
98
+ $wpdb->query("ALTER TABLE `" . CCF_FORMS_TABLE . "` ADD `form_email` VARCHAR( 50 ) NOT NULL");
99
+ if (!$this->columnExists('form_success_message', CCF_FORMS_TABLE))
100
+ $wpdb->query("ALTER TABLE `" . CCF_FORMS_TABLE . "` ADD `form_success_message` TEXT NOT NULL");
101
+ if (!$this->columnExists('form_thank_you_page', CCF_FORMS_TABLE))
102
+ $wpdb->query("ALTER TABLE `" . CCF_FORMS_TABLE . "` ADD `form_thank_you_page` VARCHAR ( 200 ) NOT NULL");
103
+ if (!$this->columnExists('field_backgroundcolor', CCF_STYLES_TABLE))
104
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `field_backgroundcolor` VARCHAR( 20 ) NOT NULL DEFAULT 'efefef'");
105
+ if (!$this->columnExists('field_borderstyle', CCF_STYLES_TABLE))
106
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `field_borderstyle` VARCHAR( 20 ) NOT NULL DEFAULT 'solid'");
107
+ if (!$this->columnExists('form_success_title', CCF_FORMS_TABLE))
108
+ $wpdb->query("ALTER TABLE `" . CCF_FORMS_TABLE . "` ADD `form_success_title` VARCHAR( 150 ) NOT NULL DEFAULT 'Form Success!'");
109
+ if (!$this->columnExists('form_padding', CCF_STYLES_TABLE))
110
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `form_padding` VARCHAR( 20 ) NOT NULL DEFAULT '4px'");
111
+ if (!$this->columnExists('form_margin', CCF_STYLES_TABLE))
112
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `form_margin` VARCHAR( 20 ) NOT NULL DEFAULT '4px'");
113
+ if (!$this->columnExists('title_margin', CCF_STYLES_TABLE))
114
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `title_margin` VARCHAR( 20 ) NOT NULL DEFAULT '2px'");
115
+ if (!$this->columnExists('label_margin', CCF_STYLES_TABLE))
116
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `label_margin` VARCHAR( 20 ) NOT NULL DEFAULT '3px'");
117
+ if (!$this->columnExists('textarea_backgroundcolor', CCF_STYLES_TABLE))
118
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `textarea_backgroundcolor` VARCHAR( 20 ) NOT NULL DEFAULT 'efefef'");
119
+ if (!$this->columnExists('success_popover_bordercolor', CCF_STYLES_TABLE))
120
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_bordercolor` VARCHAR( 20 ) NOT NULL DEFAULT 'efefef'");
121
+ if (!$this->columnExists('dropdown_width', CCF_STYLES_TABLE))
122
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `dropdown_width` VARCHAR( 20 ) NOT NULL DEFAULT 'auto'");
123
+ if (!$this->columnExists('success_popover_fontsize', CCF_STYLES_TABLE))
124
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_fontsize` VARCHAR( 20 ) NOT NULL DEFAULT '12px'");
125
+ if (!$this->columnExists('success_popover_title_fontsize', CCF_STYLES_TABLE))
126
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_title_fontsize` VARCHAR( 20 ) NOT NULL DEFAULT '1.3em'");
127
+ if (!$this->columnExists('success_popover_height', CCF_STYLES_TABLE))
128
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_height` VARCHAR( 20 ) NOT NULL DEFAULT '200px'");
129
+ if (!$this->columnExists('success_popover_fontcolor', CCF_STYLES_TABLE))
130
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '333333'");
131
+ if (!$this->columnExists('success_popover_title_fontcolor', CCF_STYLES_TABLE))
132
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `success_popover_title_fontcolor` VARCHAR( 20 ) NOT NULL DEFAULT '333333'");
133
+ if (!$this->columnExists('field_instructions', CCF_FIELDS_TABLE))
134
+ $wpdb->query("ALTER TABLE `" . CCF_FIELDS_TABLE . "` ADD `field_instructions` TEXT NOT NULL");
135
+ if (!$this->columnExists('field_options', CCF_FIELDS_TABLE))
136
+ $wpdb->query("ALTER TABLE `" . CCF_FIELDS_TABLE . "` ADD `field_options` VARCHAR( 300 ) NOT NULL");
137
+ if (!$this->columnExists('field_required', CCF_FIELDS_TABLE))
138
+ $wpdb->query("ALTER TABLE `" . CCF_FIELDS_TABLE . "` ADD `field_required` INT( 1 ) NOT NULL DEFAULT '0'");
139
+ if (!$this->columnExists('form_backgroundcolor', CCF_STYLES_TABLE))
140
+ $wpdb->query("ALTER TABLE `" . CCF_STYLES_TABLE . "` ADD `form_backgroundcolor` VARCHAR( 20 ) NOT NULL DEFAULT 'ffffff'");
141
+
142
  }
143
 
144
  function insertFixedFields() {
146
  $ishuman = array('field_slug' => 'ishuman', 'field_label' => 'Check if you are human.', 'field_type' => 'Checkbox', 'field_value' => '1', 'field_maxlength' => '0', 'user_field' => 0, 'field_instructions' => 'This helps us prevent spam.');
147
  $fixedEmail = array('field_slug' => 'fixedEmail', 'field_label' => 'Your Email', 'field_type' => 'Text', 'field_value' => '', 'field_maxlength' => '100', 'user_field' => 0, 'field_instructions' => 'Please enter your email address.');
148
  if (!$this->fieldSlugExists('captcha'))
149
+ $this->insertField($captcha, true);
150
  if (!$this->fieldSlugExists('ishuman'))
151
+ $this->insertField($ishuman, true);
152
  if (!$this->fieldSlugExists('fixedEmail'))
153
+ $this->insertField($fixedEmail, true);
 
154
  }
155
 
156
  /*function columnExists($column, $table) {
177
  global $wpdb;
178
  if (empty($form) or empty($form[form_slug]) or $this->formSlugExists($this->formatSlug($form[form_slug]))) return false;
179
  $form[form_slug] = $this->formatSlug($form[form_slug]);
180
+ foreach ($form as $key => $value)
181
+ $form[$key] = CustomContactFormsStatic::encodeOption($value);
182
+ $wpdb->insert(CCF_FORMS_TABLE, $form);
183
  return $wpdb->insert_id;
184
  }
185
 
186
+ function insertField($field, $fixed = false) {
187
  global $wpdb;
188
+ if (empty($field) or empty($field[field_slug]) or (array_key_exists($this->formatSlug($field[field_slug]), $GLOBALS[ccf_fixed_fields]) && !$fixed) or $this->fieldSlugExists($this->formatSlug($field[field_slug])))
189
+ return false;
190
  $field[field_slug] = $this->formatSlug($field[field_slug]);
191
+ foreach ($field as $key => $value)
192
+ $field[$key] = CustomContactFormsStatic::encodeOption($value);
193
+ $wpdb->insert(CCF_FIELDS_TABLE, $field);
 
 
194
  return $wpdb->insert_id;
195
  }
196
 
198
  global $wpdb;
199
  if (empty($option) or empty($option[option_slug]) or $this->fieldOptionsSlugExists($this->formatSlug($option[option_slug]))) return false;
200
  $option[option_slug] = $this->formatSlug($option[option_slug]);
201
+ foreach ($option as $key => $value)
202
+ $option[$key] = CustomContactFormsStatic::encodeOption($value);
203
+ $wpdb->insert(CCF_FIELD_OPTIONS_TABLE, $option);
204
  return $wpdb->insert_id;
205
  }
206
 
208
  global $wpdb;
209
  if (empty($style) or empty($style[style_slug]) or $this->styleSlugExists($this->formatSlug($style[style_slug]))) return false;
210
  $style[style_slug] = $this->formatSlug($style[style_slug]);
211
+ foreach ($style as $key => $value)
212
+ $style[$key] = CustomContactFormsStatic::encodeOption($value);
213
+ $wpdb->insert(CCF_STYLES_TABLE, $style);
 
 
214
  return $wpdb->insert_id;
215
  }
216
 
217
 
218
  function fieldsTableExists() {
219
  global $wpdb;
220
+ return ($wpdb->get_var("show tables like '". CCF_FIELDS_TABLE . "'") == CCF_FIELDS_TABLE);
221
  }
222
 
223
  function formsTableExists() {
224
  global $wpdb;
225
+ return ($wpdb->get_var("show tables like '". CCF_FORMS_TABLE . "'") == CCF_FORMS_TABLE);
226
  }
227
 
228
  function stylesTableExists() {
229
  global $wpdb;
230
+ return ($wpdb->get_var("show tables like '". CCF_STYLES_TABLE . "'") == CCF_STYLES_TABLE);
231
  }
232
 
233
  function fieldOptionsTableExists() {
234
  global $wpdb;
235
+ return ($wpdb->get_var("show tables like '". CCF_FIELD_OPTIONS_TABLE . "'") == CCF_FIELD_OPTIONS_TABLE);
236
+ }
237
+
238
+ function userDataTableExists() {
239
+ global $wpdb;
240
+ return ($wpdb->get_var("show tables like '". CCF_USER_DATA_TABLE . "'") == CCF_USER_DATA_TABLE);
241
  }
242
 
243
  function updateForm($form, $fid) {
247
  if (!empty($test) and $test->id != $fid) return false;
248
  $form[form_slug] = $this->formatSlug($form[form_slug]);
249
  }
250
+ foreach ($form as $key => $value)
251
+ $form[$key] = CustomContactFormsStatic::encodeOption($value);
252
+ $wpdb->update(CCF_FORMS_TABLE, $form, array('id' => $fid));
253
  return true;
254
  }
255
 
257
  global $wpdb;
258
  if (!empty($field[field_slug])) {
259
  $test = $this->selectField('', $this->formatSlug($field[field_slug]));
260
+ if ((!empty($test) and $test->id != $fid) or array_key_exists($this->formatSlug($field[field_slug]), $GLOBALS[ccf_fixed_fields]))
261
  return false;
262
  $field[field_slug] = $this->formatSlug($field[field_slug]);
263
  }
264
+ foreach ($field as $key => $value)
265
+ $field[$key] = CustomContactFormsStatic::encodeOption($value);
266
+ $wpdb->update(CCF_FIELDS_TABLE, $field, array('id' => $fid));
267
  return true;
268
  }
269
 
275
  return false;
276
  $option[option_slug] = $this->formatSlug($option[option_slug]);
277
  }
278
+ foreach ($option as $key => $value)
279
+ $option[$key] = CustomContactFormsStatic::encodeOption($value);
280
+ $wpdb->update(CCF_FIELD_OPTIONS_TABLE, $option, array('id' => $oid));
281
  return true;
282
  }
283
 
288
  if (!empty($test) and $test->id != $sid) // if style_slug is different then make sure it is unique
289
  return false;
290
  $style[style_slug] = $this->formatSlug($style[style_slug]);
291
+ foreach ($style as $key => $value)
292
+ $style[$key] = CustomContactFormsStatic::encodeOption($value);
293
+ $wpdb->update(CCF_STYLES_TABLE, $style, array('id' => $sid));
 
 
294
  return true;
295
  }
296
 
297
  function deleteForm($fid, $slug = NULL) {
298
  global $wpdb;
299
  $where_params = ($slug == NULL) ? "id='$fid'" : "form_slug='$slug'";
300
+ $wpdb->query("DELETE FROM " . CCF_FORMS_TABLE . ' WHERE ' . $where_params);
301
  return true;
302
  }
303
 
305
  global $wpdb;
306
  $this->dettachFieldAll($fid);
307
  $where_params = ($slug == NULL) ? "id='$fid'" : "field_slug='$slug'";
308
+ $wpdb->query("DELETE FROM " . CCF_FIELDS_TABLE . ' WHERE ' . $where_params);
309
  return false;
310
  }
311
 
312
+ function query($query) {
313
+ global $wpdb;
314
+ if (empty($query)) return false;
315
+ return ($wpdb->query($query) != false) ? $wpdb->insert_id : false;
316
+ }
317
+
318
  function deleteStyle($sid, $slug = NULL) {
319
  global $wpdb;
320
  $this->dettachStyleAll($sid);
321
  $where_params = ($slug == NULL) ? "id='$sid'" : "style_slug='$slug'";
322
+ $wpdb->query("DELETE FROM " . CCF_STYLES_TABLE . ' WHERE ' . $where_params);
323
  return true;
324
  }
325
 
327
  global $wpdb;
328
  $this->dettachFieldOptionAll($oid);
329
  $where_params = ($slug == NULL) ? "id='$oid'" : "option_slug='$slug'";
330
+ $wpdb->query("DELETE FROM " . CCF_FIELD_OPTIONS_TABLE . ' WHERE ' . $where_params);
331
+ return true;
332
+ }
333
+
334
+ function deleteUserData($uid) {
335
+ global $wpdb;
336
+ $wpdb->query("DELETE FROM " . CCF_USER_DATA_TABLE . " WHERE id='$uid'");
337
  return true;
338
  }
339
 
340
+ function selectAllFromTable($table, $output_type = OBJECT) {
341
+ global $wpdb;
342
+ return $wpdb->get_results('SELECT * FROM ' . $table, $output_type);
343
+ }
344
+
345
  function selectAllForms() {
346
  global $wpdb;
347
+ return $wpdb->get_results("SELECT * FROM " . CCF_FORMS_TABLE . " ORDER BY form_slug ASC");
348
  }
349
 
350
  function selectAllFields() {
351
  global $wpdb;
352
+ return $wpdb->get_results("SELECT * FROM " . CCF_FIELDS_TABLE . " ORDER BY field_slug ASC");
353
  }
354
 
355
  function selectAllFieldOptions() {
356
  global $wpdb;
357
+ return $wpdb->get_results("SELECT * FROM " . CCF_FIELD_OPTIONS_TABLE . " ORDER BY option_slug ASC");
358
  }
359
 
360
  function selectAllStyles() {
361
  global $wpdb;
362
+ return $wpdb->get_results("SELECT * FROM " . CCF_STYLES_TABLE . " ORDER BY style_slug ASC");
363
+ }
364
+
365
+ function selectAllUserData() {
366
+ global $wpdb;
367
+ return $wpdb->get_results("SELECT * FROM " . CCF_USER_DATA_TABLE . " ORDER BY data_time DESC");
368
  }
369
 
370
  function selectForm($fid, $form_slug = '') {
371
  global $wpdb;
372
  $extra = (!empty($form_slug)) ? " or form_slug = '$form_slug'" : '';
373
+ return $wpdb->get_row("SELECT * FROM " . CCF_FORMS_TABLE . " WHERE id='$fid' $extra");
374
  }
375
 
376
  function selectStyle($sid, $style_slug = '') {
377
  global $wpdb;
378
  $extra = (!empty($style_slug)) ? " or style_slug = '$style_slug'" : '';
379
+ return $wpdb->get_row("SELECT * FROM " . CCF_STYLES_TABLE . " WHERE id='$sid' $extra");
380
  }
381
 
382
  function selectField($fid, $field_slug = '') {
383
  global $wpdb;
384
  $extra = (!empty($field_slug)) ? " or field_slug = '$field_slug'" : '';
385
+ return $wpdb->get_row("SELECT * FROM " . CCF_FIELDS_TABLE . " WHERE id='$fid'" . $extra);
386
  }
387
 
388
  function selectFieldOption($oid, $option_slug = '') {
389
  global $wpdb;
390
  $extra = (!empty($option_slug)) ? " or option_slug = '$option_slug'" : '';
391
+ return $wpdb->get_row("SELECT * FROM " . CCF_FIELD_OPTIONS_TABLE . " WHERE id='$oid'" . $extra);
392
+ }
393
+
394
+ function selectUserData($uid) {
395
+ global $wpdb;
396
+ return $wpdb->get_row("SELECT * FROM " . CCF_USER_DATA_TABLE . " WHERE id='$uid'");
397
  }
398
 
399
  function addFieldToForm($field_id, $form_id) {
400
+ $field = $this->selectField($field_id);
401
+ if (empty($field)) return false;
402
+ $form = $this->selectForm($form_id);
403
+ if (empty($form)) return false;
404
  $fields = $this->getAttachedFieldsArray($form_id);
405
  if (!in_array($field_id, $fields)) {
406
  $new_fields = $form->form_fields . $field_id . ',';
411
  }
412
 
413
  function addFieldOptionToField($option_id, $field_id) {
414
+ $option = $this->selectFieldOption($option_id);
415
+ if (empty($option)) return false;
416
  $field = $this->selectField($field_id);
417
+ if (empty($field)) return false;
418
  $options = $this->getAttachedFieldOptionsArray($field_id);
419
  if (!in_array($option_id, $options)) {
420
  $new_options = $field->field_options . $option_id . ',';
506
  return (!empty($test));
507
  }
508
 
509
+ function insertUserData($data_object) {
510
+ global $wpdb;
511
+ $wpdb->show_errors();
512
+ $wpdb->insert(CCF_USER_DATA_TABLE, array('data_time' => $data_object->getDataTime(), 'data_formid' => $data_object->getFormID(), 'data_formpage' => $data_object->getFormPage(), 'data_value' => $data_object->getEncodedData()));
513
+ $wpdb->print_error();
514
+ return $wpdb->insert_id;
515
+ }
516
+
517
  function insertDefaultContent($overwrite = false) {
518
  $field_slugs = array('name' => 'ccf_name', 'message' => 'ccf_message',
519
  'website' => 'ccf_website', 'phone' => 'ccf_phone', 'google' => 'ccf_google',
539
  'field_maxlength' => 30, 'field_type' => 'Text');
540
  $google_field = array('field_slug' => $field_slugs[google], 'field_label' => 'Did you find my website through Google?',
541
  'field_required' => 0, 'field_instructions' => 'If you found my website through Google, check this box.',
542
+ 'field_maxlength' => 0, 'field_type' => 'Checkbox', 'field_value' => 'Yes');
543
  $contact_method_field = array('field_slug' => $field_slugs[contact_method], 'field_label' => 'How should we contact you?',
544
  'field_required' => 1, 'field_instructions' => 'By which method we should contact you?',
545
  'field_maxlength' => 0, 'field_type' => 'Dropdown');
custom-contact-forms-export.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Custom Contact Forms Plugin
4
+ By Taylor Lovett - http://www.taylorlovett.com
5
+ Plugin URL: http://www.taylorlovett.com/wordpress-plugins
6
+ */
7
+ class CustomContactFormsExport extends CustomContactFormsDB {
8
+
9
+ var $last_export_content;
10
+ var $last_export_file;
11
+ var $exports_path;
12
+
13
+ function CustomContactFormsExport() {
14
+ $this->exports_path = CCF_BASE_PATH . 'export/';
15
+ }
16
+
17
+ function exportAll() {
18
+ $out = '';
19
+ foreach ($GLOBALS[ccf_tables_array] as $table)
20
+ $out .= $this->exportTable($table);
21
+ $this->last_export_content = $out;
22
+ return $out;
23
+ }
24
+
25
+ function exportTable($table) {
26
+ $out = '';
27
+ $data = parent::selectAllFromTable($table, ARRAY_A);
28
+ foreach ($data as $row) {
29
+ $no_insert = 0;
30
+ $cols = '';
31
+ $vals = '';
32
+ foreach ($row as $k => $v) {
33
+ if (array_key_exists($k, $GLOBALS[ccf_fixed_fields])) {
34
+ $no_insert = 1;
35
+ break;
36
+ }
37
+ $v = str_replace(';', '\;', $v);
38
+ $cols .= "$k, ";
39
+ $vals .= "'$v', ";
40
+ } if ($no_insert != 1) {
41
+ $vals = substr($vals, 0, strlen($vals) - 2);
42
+ $cols = substr($cols, 0, strlen($cols) - 2);
43
+ $statement = 'INSERT INTO `' . $table . '` (' . $cols . ') VALUES (' . CustomContactFormsStatic::escapeSemiColons($vals) . ');';
44
+ $statement = $statement . "\n\n";
45
+ $out .= $statement;
46
+ }
47
+ }
48
+ return $out;
49
+ }
50
+
51
+ function exportToFile($export_content = NULL) {
52
+ if ($export_content == NULL) $export_content = $this->getLastExportContent();
53
+ $export_file = "ccf-export-" . strtolower(date('j-M-Y--h-i-s')) . '.sql';
54
+ if (($export_handle = @fopen($this->getExportsPath() . $export_file, 'w')) == false)
55
+ return false;
56
+ fwrite($export_handle, $export_content);
57
+ fclose($export_handle);
58
+ $this->last_export_file = $export_file;
59
+ return $export_file;
60
+ }
61
+
62
+ function getExportsPath() {
63
+ return $this->exports_path;
64
+ }
65
+
66
+ function getLastExportContent() {
67
+ return $this->last_export_content;
68
+ }
69
+
70
+ function importFromFile($file) {
71
+ $path = CCF_BASE_PATH. 'import/';
72
+ $file_name = basename(time() . $file['name']);
73
+ if (move_uploaded_file($file['tmp_name'], $path . $file_name)) {
74
+ $data = file_get_contents($path . $file_name);
75
+ $commands = $this->parseMultiQuery($data);
76
+ $errors = 0;
77
+ foreach($commands as $command) {
78
+ if (!parent::query($command)) $errors++;
79
+ }
80
+ return ($errors == 0) ? true : $errors;
81
+ }
82
+ return false;
83
+ }
84
+
85
+ function parseMultiQuery($sql, $unescape_semicolons = true) {
86
+ if (empty($sql)) return false;
87
+ $commands = preg_split('/\);[\n\r]*/ims', $sql);
88
+ foreach ($commands as $k => $v) {
89
+ $commands[$k] = $v . ')';
90
+ if ($unescape_semicolons)
91
+ $commands[$k] = CustomContactFormsStatic::unescapeSemiColons($commands[$k]);
92
+ }
93
+ array_pop($commands);
94
+ return $commands;
95
+ }
96
+
97
+ }
98
+ ?>
custom-contact-forms-mailer.php CHANGED
@@ -24,7 +24,7 @@ if (!class_exists('CustomContactFormsMailer')) {
24
  }
25
 
26
  function send(){
27
- $reply = ($this->reply_to != NULL) ? $this->reply_to : $this->from;
28
  $this->addHeader('From: '.$this->from."\r\n");
29
  $this->addHeader('Reply-To: '.$reply."\r\n");
30
  $this->addHeader('Return-Path: '.$this->from."\r\n");
24
  }
25
 
26
  function send(){
27
+ $reply = ($this->reply_to != NULL) ? $this->reply_to : $this->from;
28
  $this->addHeader('From: '.$this->from."\r\n");
29
  $this->addHeader('Reply-To: '.$reply."\r\n");
30
  $this->addHeader('Return-Path: '.$this->from."\r\n");
custom-contact-forms-popover.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
- require_once('custom-contact-forms.php');
3
- $customcontact = new CustomContactForms();
4
- ?>
5
- <html>
6
- <body>
7
- test
8
- </body>
9
- </html>
 
 
 
 
 
 
 
 
 
custom-contact-forms-static.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Custom Contact Forms Plugin
4
+ By Taylor Lovett - http://www.taylorlovett.com
5
+ Plugin URL: http://www.taylorlovett.com/wordpress-plugins
6
+ */
7
+ if (!class_exists('CustomContactFormsStatic')) {
8
+ class CustomContactFormsStatic {
9
+ function encodeOption($option) {
10
+ return htmlspecialchars(stripslashes($option), ENT_QUOTES);
11
+ }
12
+
13
+ function getWPTablePrefix() {
14
+ global $wpdb;
15
+ return $wpdb->prefix;
16
+ }
17
+
18
+ function encodeOptionArray($option_array) {
19
+ foreach ($option_array as $option) {
20
+ if (is_array($option))
21
+ $option = CustomContactFormsStatic::encodeOptionArray($option);
22
+ else
23
+ $option = CustomContactFormsStatic::encodeOption($option);
24
+ }
25
+ return $option_array;
26
+ }
27
+
28
+ function decodeOption($option, $strip_slashes = 1, $decode_html_chars = 1) {
29
+ if ($strip_slashes == 1) $option = stripslashes($option);
30
+ if ($decode_html_chars == 1) $option = html_entity_decode($option);
31
+ return $option;
32
+ }
33
+
34
+ function strstrb($h, $n){
35
+ return array_shift(explode($n, $h, 2));
36
+ }
37
+
38
+ function redirect($url) {
39
+ header('Location: ' . $url);
40
+ }
41
+
42
+ function definePluginConstants() {
43
+ $prefix = CustomContactFormsStatic::getWPTablePrefix();
44
+ define('CCF_FORMS_TABLE', $prefix . 'customcontactforms_forms');
45
+ define('CCF_FIELDS_TABLE', $prefix . 'customcontactforms_fields');
46
+ define('CCF_STYLES_TABLE', $prefix . 'customcontactforms_styles');
47
+ define('CCF_USER_DATA_TABLE', $prefix . 'customcontactforms_user_data');
48
+ define('CCF_FIELD_OPTIONS_TABLE', $prefix . 'customcontactforms_field_options');
49
+ define('CCF_BASE_PATH', ABSPATH . 'wp-content/plugins/custom-contact-forms/');
50
+ $GLOBALS[ccf_tables_array] = array(CCF_FORMS_TABLE, CCF_FIELDS_TABLE, CCF_STYLES_TABLE, CCF_USER_DATA_TABLE, CCF_FIELD_OPTIONS_TABLE);
51
+ $GLOBALS[ccf_fixed_fields] = array('customcontactforms_submit' => '',
52
+ 'fid' => '',
53
+ 'fixedEmail' => 'Use this field if you want the plugin to throw an error on fake emails.',
54
+ 'form_page' => '',
55
+ 'captcha' => 'This field requires users to type numbers in an image preventing spam.',
56
+ 'ishuman' => 'This field requires users to check a box to prove they aren\'t a spam bot.'
57
+ );
58
+ }
59
+
60
+ function escapeSemiColons($value) {
61
+ return str_replace(';', '\;', $value);
62
+ }
63
+
64
+ function unescapeSemiColons($value) {
65
+ return str_replace('\;', ';', $value);
66
+ }
67
+ }
68
+ }
69
+ ?>
custom-contact-forms-user-data.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Custom Contact Forms Plugin
4
+ By Taylor Lovett - http://www.taylorlovett.com
5
+ Plugin URL: http://www.taylorlovett.com/wordpress-plugins
6
+ */
7
+ if (!class_exists('CustomContactFormsUserData')) {
8
+ class CustomContactFormsUserData {
9
+ var $form_id = NULL;
10
+ var $data_time = NULL;
11
+ var $data_array = NULL;
12
+ var $encoded_data = NULL;
13
+ var $form_page = NULL;
14
+ function CustomContactFormsUserData($param_array) {
15
+ if (isset($param_array[form_id]))
16
+ $this->setFormID($param_array[form_id]);
17
+
18
+ if (isset($param_array[data_time]))
19
+ $this->setDataTime($param_array[data_time]);
20
+
21
+ if (isset($param_array[form_page]))
22
+ $this->setFormPage($param_array[form_page]);
23
+
24
+ if (isset($param_array[data_array])) {
25
+ $this->setDataArray($param_array[data_array]);
26
+ $this->encodeData();
27
+ }
28
+
29
+ if (isset($param_array[encoded_data])) {
30
+ $this->setEncodedData($param_array[encoded_data]);
31
+ $this->decodeData();
32
+ }
33
+ }
34
+
35
+ function encodeData() {
36
+ $data_array = $this->getDataArray();
37
+ $encoded_data = '';
38
+ foreach ($data_array as $key => $value) {
39
+ $encoded_data .= 's:'.strlen($key).':"'.$key.'";';
40
+ $encoded_data .= 's:'.strlen($value).':"'.$value.'";';
41
+ }
42
+ $this->setEncodedData($encoded_data);
43
+ }
44
+
45
+
46
+ function decodeData() {
47
+ $data = $this->getEncodedData();
48
+ $data_array = array();
49
+ while (!empty($data)) {
50
+ $key_length = CustomContactFormsStatic::strstrb($data, ':"');
51
+ $key_length = str_replace('s:', '', $key_length);
52
+ $piece_length = 6 + strlen($key_length) + (int) $key_length;
53
+ $key = substr($data, (4 + strlen($key_length)), (int) $key_length);
54
+ $data = substr($data, $piece_length);
55
+ $value_length = CustomContactFormsStatic::strstrb($data, ':"');
56
+ $value_length = str_replace('s:', '', $value_length);
57
+ $piece_length = 6 + strlen($value_length) + (int) $value_length;
58
+ $value = substr($data, (4 + strlen($value_length)), (int) $value_length);
59
+ $data = substr($data, $piece_length);
60
+ $data_array[$key] = $value;
61
+ }
62
+ $this->setDataArray($data_array);
63
+ }
64
+
65
+ /* Getters and Setters */
66
+ function setFormID($form_id) { $this->form_id = $form_id; }
67
+ function setFormPage($form_page) { $this->form_page = $form_page; }
68
+ function setDataTime($data_time) { $this->data_time = $data_time; }
69
+ function setDataArray($data_array) { $this->data_array = $data_array; }
70
+ function setEncodedData($encoded_data) { $this->encoded_data = $encoded_data; }
71
+ function getFormID() { return $this->form_id; }
72
+ function getFormPage() { return $this->form_page; }
73
+ function getDataTime() { return $this->data_time; }
74
+ function getDataArray() { return $this->data_array; }
75
+ function getEncodedData() { return $this->encoded_data; }
76
+
77
+ /* Debug function */
78
+
79
+ function printAll() {
80
+ ?><div style="margin-left:30px;">
81
+ <b>BEGIN User Data Object</b><br />
82
+ ---------------------------------<br />
83
+ Form ID: <?php echo $this->getFormID(); ?><br />
84
+ Form Page: <?php echo $this->getFormPage(); ?><br />
85
+ Data Time: <?php echo $this->getDataTime(); ?><br />
86
+ Data Array: <?php print_r($this->getDataArray()); ?><br />
87
+ Encoded Array: <?php print_r($this->getEncodedData()); ?><br />
88
+ ---------------------------------<br />
89
+ <b>END User Data Object</b></div>
90
+ <?php
91
+ }
92
+ }
93
+ }
94
+ ?>
custom-contact-forms.css DELETED
@@ -1,314 +0,0 @@
1
- /* Custom Contact Forms CSS */
2
- form.customcontactform {
3
- margin:8px;
4
- width:95%;
5
- max-width:600px;
6
- font-size:1em;
7
- padding:4px;
8
- color:#333333;
9
- }
10
- form.customcontactform-sidebar {
11
- width:100%;
12
- max-width:600px;
13
- padding:4px;
14
- color:#333333;
15
- font-size:1em;
16
- }
17
- form.customcontactform div, form.customcontactform-sidebar div {
18
- list-style-type:none;
19
- }
20
- form.customcontactform div p, form.customcontactform-sidebar div p {
21
- margin:0;
22
- padding:4px 0 4px 0;
23
- }
24
- form.customcontactform div p {
25
- border-bottom:1px dashed #999;
26
- }
27
- form.customcontactform h4, form.customcontactform-sidebar h4 {
28
- font-size:1.4em;
29
- font-weight:bold;
30
- }
31
- form.customcontactform div p label {
32
- display:block;
33
- padding:0;
34
- width:100%;
35
- }
36
- form.customcontactform-sidebar div p label { width:100%; }
37
- form.customcontactform div p label.checkbox, form.customcontactform-sidebar div p label.checkbox {
38
- display:inline;
39
- width:20%;
40
- }
41
- form.customcontactform div .show-field-instructions, form.customcontactform-sidebar div .show-field-instructions {
42
-
43
- }
44
- form.customcontactform div span.field-instructions, form.customcontactform-sidebar div span.field-instructions {
45
- display:none;
46
- }
47
- form.customcontactform div p input[type=text], form.customcontactform div p textarea, form.customcontactform-sidebar div p input[type=text], form.customcontactform-sidebar div p textarea {
48
- border-width:1px;
49
- border-style:solid;
50
- border-spacing:0;
51
- font-weight:normal;
52
- width:16em;
53
- padding:2px;
54
- clear:both;
55
- margin:0;
56
- font-size:1.1em;
57
- font-family:Verdana, Arial, Helvetica, sans-serif;
58
- -moz-border-radius:4px;
59
- -khtml-border-radius:4px;
60
- -webkit-border-radius:4px;
61
- border-radius:4px;
62
- word-wrap:break-word;
63
- }
64
- form.customcontactform p, form.customcontactform-sidebar p { padding:0 0 0px 17px; margin:0; }
65
- form.customcontactform div p input[type=submit], form.customcontactform div p .submit, form.customcontactform-sidebar div p .submit {
66
- font-size:1em; margin-left:2px;
67
- }
68
- form.customcontactform div p input[type=checkbox], form.customcontactform-sidebar div p input[type=checkbox] {
69
- width:20px;
70
- padding:0;
71
- margin:0;
72
- }
73
- form.customcontactform-sidebar div p input[type=text], form.customcontactform-sidebar div p textarea {
74
- width:90%;
75
- font-size:12px;
76
- margin:0;
77
- }
78
- /* ------------------ custom contact forms admin panel ---------------- */
79
- #customcontactforms-admin {
80
- vertical-align:top;
81
- margin:1em 0 30px 25px;
82
- }
83
- #customcontactforms-admin input, textarea, select {
84
- font-size:1em;
85
- }
86
- #customcontactforms-admin .icon32 {
87
- margin:-6px 6px 9px 5px;
88
- }
89
- #customcontactforms-admin .inside {
90
- padding:5px 10px 10px 10px;
91
- }
92
- #customcontactforms-admin h3 {
93
- margin:0 0 7px 0;
94
- height:25px;
95
- padding: 7px 0 0 9px;
96
- }
97
- #customcontactforms-admin #instructions {
98
- float:left;
99
- width:450px;
100
- margin:20px 1em 1em 1em;
101
- }
102
- #customcontactforms-admin #contact-author {
103
- float:left;
104
- width:450px;
105
- margin:5px 1em 1em 6px;
106
- }
107
-
108
- #customcontactforms-admin #custom-html {
109
- float:left;
110
- width:520px;
111
- margin:5px 1em 1em 6px;
112
- }
113
- #customcontactforms-admin #custom-html p { margin: 4px 0 4px 0 ; }
114
- #customcontactforms-admin #custom-html #custom_html_textarea {
115
- width:495px;
116
- height:220px;
117
- }
118
- #customcontactforms-admin #contact-author form label {
119
- display:block; font-weight:bold;
120
- }
121
- #customcontactforms-admin #instructions p:first-child {
122
- padding-top:0;
123
- margin-top:0;
124
- }
125
- #customcontactforms-admin #general-settings {
126
- float:left;
127
- clear:both;
128
- width:500px;
129
- margin:20px 1em 1em 5px;
130
- }
131
- #customcontactforms-admin #style-example {
132
- background:url(images/style-example.gif) no-repeat top left;
133
- width:405px;
134
- height:135px;
135
- padding-left:20px;
136
- margin:10px 0 0 10px;
137
- border:0;
138
- }
139
- #customcontactforms-admin #create-styles {
140
- clear:both;
141
- height:40em;
142
- width:1000px;
143
- margin:20px 1em 1em 5px;
144
- }
145
- #customcontactforms-admin #plugin-news {
146
- clear:both;
147
- width:1000px;
148
- margin:20px 1em 1em 5px;
149
- }
150
- #customcontactforms-admin #plugin-news ul li.first { border-bottom:1px dashed #666; }
151
- #customcontactforms-admin #manage-styles {
152
- margin:1px 1em 1em 5px;
153
- width:1000px;
154
- }
155
- #customcontactforms-admin #manage-styles label {
156
- display:block;
157
- }
158
- #customcontactforms-admin #manage-styles input[type=text], #customcontactforms-admin #manage-styles select, #customcontactforms-admin #manage-styles textarea {
159
- width:80px;
160
- }
161
- #customcontactforms-admin #create-styles .style_left { float:left; width:48% }
162
- #customcontactforms-admin #create-styles .style_right { float:right; width:48%; clear:none }
163
- #customcontactforms-admin #general-settings form div p.descrip {
164
- font-style:italic;
165
- padding-left:20px;
166
- }
167
- #customcontactforms-admin #general-settings form div p.show-widget {
168
- margin-top:1em;
169
- padding-top:.4em;
170
- border-top:1px solid #ccc;
171
- }
172
- #customcontactforms-admin #create-fields {
173
- float:left;
174
- clear:left;
175
- width:450px;
176
- margin:0 1em 1em 5px;
177
- }
178
- #customcontactforms-admin #create-forms {
179
- float:left;
180
- width:500px;
181
- border-left:1px solid #ccc;
182
- margin:0 1em 1em 1em;
183
- }
184
- #customcontactforms-admin #create-forms .inside div p {
185
- font-size:.8em;
186
- }
187
- #customcontactforms-admin .manage-h3 {
188
- clear:both;
189
- margin-top:20px;
190
- }
191
- #customcontactforms-admin #manage-fields {
192
- width:1000px;
193
- }
194
- #customcontactforms-admin #manage-forms {
195
- width:1000px;
196
- margin-right:10px;
197
- }
198
- #customcontactforms-admin #manage-fixed-fields {
199
- width:1000px;
200
- }
201
- #customcontactforms-admin .evenrow {
202
- background-color:#f5f5f5;
203
- }
204
- #customcontactforms-admin .nobordertop {
205
- border-top:none;
206
- }
207
- #customcontactforms-admin .borderbottom {
208
- border-bottom:2px solid black;
209
- }
210
- #customcontactforms-admin .attached_fields {
211
- float:left;
212
- width:400px;
213
- }
214
- #customcontactforms-admin .attach_field {
215
- float:left;
216
- width:300px;
217
- }
218
- #customcontactforms-admin .actions {
219
- float:right;
220
- width: 80px; padding:0 18px 0 8px;
221
- }
222
- #customcontactforms-admin .attach_styles {
223
- float:left;
224
- width:300px;
225
- }
226
- #customcontactforms-admin label span {
227
- font-weight:bold;
228
- }
229
-
230
- #customcontactforms-admin #plugin-nav {
231
- clear:both;
232
- }
233
- #customcontactforms-admin #plugin-nav { text-align:center; border-bottom:1px #ccc dashed; margin:0 0 10px 0; padding:0 0 6px 0; }
234
- #customcontactforms-admin #plugin-nav li {
235
- border-right:1px solid #666; display:inline; padding:0 8px 0 3px;
236
- }
237
- #customcontactforms-admin #plugin-nav li.last {
238
- border-right:none;
239
- }
240
- .width25 { width:25px; } .width50 { width:50px; } .width75 { width:75px; } .width100 { width:100px; }
241
- .width125 { width:125px; } .width150 { width:150px; } .width175 { width:175px; } .width200 { width:200px; }
242
- .width225 { width:225px; } .width250 { width:250px; } .width275 { width:275px; } .width300 { width:300px; }
243
-
244
- .red { color:#F00; }
245
- .bold { font-weight:bold; }
246
- .italic { font-style:italic; }
247
- .hide { display:none; }
248
- .clear { clear:both; }
249
- .textcenter { text-align:center; }
250
- .floatleft { float:left; }
251
- .floatright { float:right; }
252
- .form-extra-options-table { margin:0 auto 0 auto; }
253
-
254
- /* ----- popover box ---------- */
255
-
256
- .ccf-popover {
257
- position: absolute;
258
- top:25%;
259
- left:25%;
260
- width:500px;
261
- padding:10px;
262
- background-color:#fff;
263
- border:1px solid #666;
264
- display:none;
265
- }
266
-
267
- .ccf-popover .ccf-popover-close { position:absolute; top:1px; right:5px; }
268
- .tooltip {
269
- background-color:#000;
270
- border:1px solid #fff;
271
- padding:10px 15px;
272
- width:200px;
273
- display:none;
274
- color:#fff;
275
- text-align:left;
276
- font-size:12px;
277
-
278
- /* outline radius for mozilla/firefox only */
279
- -moz-box-shadow:0 0 10px #000;
280
- -webkit-box-shadow:0 0 10px #000;
281
- }
282
- /* --- form success popover -------------------- */
283
- #ccf-form-success {
284
- display:none;
285
- border: 9px solid #efefef;
286
- border-spacing:0;
287
- width:420px;
288
- height:200px
289
- padding:0px;
290
- margin:0;
291
- -moz-border-radius:35px;
292
- -khtml-border-radius:35px;
293
- -webkit-border-radius:35px;
294
- border-radius:305px;
295
- position:fixed;
296
- left:30%;
297
- background-color:white;
298
- top:30%;
299
- }
300
-
301
- #ccf-form-success h5 {
302
- background-color:#efefef; margin:0 0 15px 0;
303
- text-align:left;
304
- padding:9px;
305
- font-size:1.5em;
306
- font-weight:bold;
307
- }
308
- #ccf-form-success p { padding:8px; font-size:1.1em; text-align:center; }
309
- #ccf-form-success a.close {
310
- position:absolute;
311
- right:12px;
312
- font-size:1em;
313
- top:7px;
314
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
custom-contact-forms.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Custom Contact Forms
4
  Plugin URI: http://taylorlovett.com/wordpress-plugins
5
  Description: Guaranteed to be 1000X more customizable and intuitive than Fast Secure Contact Forms or Contact Form 7. Customize every aspect of your forms without any knowledge of CSS: borders, padding, sizes, colors. Ton's of great features. Required fields, captchas, tooltip popovers, unlimited fields/forms/form styles, use a custom thank you page or built-in popover with a custom success message set for each form. <a href="options-general.php?page=custom-contact-forms">Settings</a>
6
- Version: 3.5.8
7
  Author: Taylor Lovett
8
  Author URI: http://www.taylorlovett.com
9
  */
@@ -21,27 +21,17 @@
21
  You should have received a copy of the GNU General Public License
22
  along with this program. If not, see <http://www.gnu.org/licenses/>.
23
  */
 
 
24
  require_once('custom-contact-forms-db.php');
25
  if (!class_exists('CustomContactForms')) {
26
  class CustomContactForms extends CustomContactFormsDB {
27
  var $adminOptionsName = 'customContactFormsAdminOptions';
28
- var $version = '3.5.1';
29
- var $form_errors;
30
  var $error_return;
31
  var $current_form;
32
  var $current_thank_you_message;
33
- var $fixed_fields = array('customcontactforms_submit' => '',
34
- 'fid' => '',
35
- 'fixedEmail' => 'Use this field if you want the plugin to throw an error on fake emails.',
36
- 'form_page' => '',
37
- 'captcha' => 'This field requires users to type numbers in an image preventing spam.',
38
- 'ishuman' => 'This field requires users to check a box to prove they aren\'t a spam bot.'
39
- );
40
-
41
- function CustomContactForms() {
42
- parent::CustomContactFormsDB();
43
- $this->form_errors = array();
44
- }
45
 
46
  function activatePlugin() {
47
  $admin_options = $this->getAdminOptions();
@@ -56,7 +46,7 @@ if (!class_exists('CustomContactForms')) {
56
  $admin_email = get_option('admin_email');
57
  $customcontactAdminOptions = array('show_widget_home' => 1, 'show_widget_pages' => 1, 'show_widget_singles' => 1, 'show_widget_categories' => 1, 'show_widget_archives' => 1, 'default_to_email' => $admin_email, 'default_from_email' => $admin_email, 'default_form_subject' => 'Someone Filled Out Your Contact Form!',
58
  'remember_field_values' => 0, 'author_link' => 1, 'enable_widget_tooltips' => 1, 'wp_mail_function' => 1, 'form_success_message_title' => 'Form Success!', 'form_success_message' => 'Thank you for filling out our web form. We will get back to you ASAP.', 'enable_jquery' => 1, 'code_type' => 'XHTML',
59
- 'show_install_popover' => 0); // default general settings
60
  $customcontactOptions = get_option($this->adminOptionsName);
61
  if (!empty($customcontactOptions)) {
62
  foreach ($customcontactOptions as $key => $option)
@@ -69,6 +59,18 @@ if (!class_exists('CustomContactForms')) {
69
  if (!is_admin()) {
70
  $this->startSession();
71
  $this->processForms();
 
 
 
 
 
 
 
 
 
 
 
 
72
  }
73
  }
74
 
@@ -91,11 +93,20 @@ if (!class_exists('CustomContactForms')) {
91
  }
92
 
93
  function insertAdminScripts() {
94
- wp_enqueue_script('ccf-main', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/custom-contact-forms-admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'/*, 'jquery-ui-draggable', 'jquery-ui-resizable', 'jquery-ui-dialog'*/), '1.0');
95
- wp_enqueue_script('ccf-colorpicker', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/colorpicker.js');
96
- wp_enqueue_script('ccf-eye', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/eye.js');
97
- wp_enqueue_script('ccf-utils', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/utils.js');
98
- wp_enqueue_script('ccf-layout', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/layout.js?ver=1.0.2');
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
  function insertFrontEndScripts() {
@@ -133,15 +144,24 @@ if (!class_exists('CustomContactForms')) {
133
  <a href="javascript:void(0)" class="close">[close]</a>
134
  </div>
135
  <div class="popover-body">
 
 
 
 
 
 
 
 
 
136
  <p>CCF is an extremely intuitive plugin allowing you to create any type of contact form you can imagine. CCF is very user friendly but with possibilities comes complexity. It is recommend that you click the button below to create default fields, field options, and forms.
137
  The default content will help you get a feel for the amazing things you can accomplish with this plugin. This popover only shows automatically the first time you visit the admin page; <b>if you want to view this popover again, click the "Show Plugin Usage Popover"</b> in the instruction area of the admin page.</p>
138
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
139
  <input type="submit" class="insert-default-content-button" value="Insert Default Content" name="insert_default_content" />
140
  </form>
141
- <p>Below is a basic usage outline of the four pillars of this plugin: fields, field options, styles, and forms. Also explained below is the Custom HTML Feature which allows you to write the form HTML yourself using the plugin simply as a form processor; this is great if you are a web developer with HTML experience.</p>
142
  <ul>
143
  <li>
144
- <h3>Fields</h3>
145
  <p>Fields are the actual input boxes in which users enter their information. There are six types of fields that you can attach to your forms.</p>
146
  <ul>
147
  <li><span>Text:</span>
@@ -170,7 +190,7 @@ if (!class_exists('CustomContactForms')) {
170
  <p>The last important thing related to fields are <span>Fixed Fields</span>. Fixed Fields are special fields that come already created within the plugin such as the captcha spam blocker and email field. Fixed Fields do special things that you wouldn't be able to accomplish with normally; they cannot be deleted or created. If you use the fixedEmail field, as opposed to creating your own email field. the users email will be checked to make sure it is valid, if it isn't a form error will be displayed.</p>
171
  </li>
172
  <li>
173
- <h3>Field Options</h3>
174
  <p>In the field section above, look at the radio or dropdown fields. See how they have multiple options within the field? Those are called Field Options. Field Options have their own manager. There are only three things you must fill in to create a field option.</p>
175
  <ul>
176
  <li><span class="red">*</span> <span>Slug:</span> Used to identify the field option, solely for admin purposes; must be unique, and contain only letters, numbers, and underscores. Example: "slug_one".</li>
@@ -180,7 +200,7 @@ if (!class_exists('CustomContactForms')) {
180
  <p>Once you create field options, you can attach them (in the field manager) to radio and dropdown fields (that are already created). It is important to remember that after you create a dropdown or radio field, they will not work until you attach one or more field options.</p>
181
  </li>
182
  <li>
183
- <h3>Forms</h3>
184
  <p>Forms bring everything together. Each form you create in the form manager shows a code to display that form in posts/pages as well as theme files. The post/page form display code looks like: [customcontact id=FORMID]. There are a number of parameters that you can fill out when creating and managing each of your forms.</p>
185
  <ul>
186
  <li><span class="red">*</span> <span>Slug:</span> A slug is simply a way to identify your form. It can only contain underscores, letters, and numbers and must be unique. Example "my_contact_form"</li>
@@ -200,13 +220,13 @@ if (!class_exists('CustomContactForms')) {
200
  <div class="ccf-success-popover-example"></div>
201
  </li>
202
  <li>
203
- <h3>Style Manager</h3>
204
  <p>The style manager allows you to customize the appearance of forms without any knowledge of CSS. There are a ton of parameters you can fill out with each style and all of them are pretty self-explanitory. After you create a style, you need to go to the form manager and set the form style to the new style you created (the slug will be what shows in the "Form Style" dropdown).</p>
205
  <p>The image below will help you better understand how each style option will change your forms.</p>
206
  <div class="ccf-style-example"></div>
207
  </li>
208
  <li>
209
- <h3>Custom HTML Forms Feature (advanced)</h3>
210
  <p>If you know HTML and simply want to use this plugin to process form requests, this feature is for you. The following HTML is a the framework to which you must adhere. In order for your form to work you MUST do the following:</p>
211
  <ul>
212
  <li>Keep the form action/method the same (yes the action is supposed to be empty).</li>
@@ -215,6 +235,14 @@ if (!class_exists('CustomContactForms')) {
215
  </ul>
216
  <p>Just to be clear, you don't edit the code in the Custom HTML Forms feature within the admin panel. Instead, you copy the code in to the page, post, or theme file you want to display a form, then edit the code to look how you want following the guidelines provided above.</p>
217
  </li>
 
 
 
 
 
 
 
 
218
  </ul>
219
  </div>
220
  </div>
@@ -247,6 +275,7 @@ if (!class_exists('CustomContactForms')) {
247
  $admin_options[show_widget_archives] = $_POST[show_widget_archives];
248
  $admin_options[show_widget_home] = $_POST[show_widget_home];
249
  $admin_options[custom_thank_you] = $_POST[custom_thank_you];
 
250
  $admin_options[author_link] = $_POST[author_link];
251
  $admin_options[enable_jquery] = $_POST[enable_jquery];
252
  $admin_options[code_type] = $_POST[code_type];
@@ -289,6 +318,58 @@ if (!class_exists('CustomContactForms')) {
289
  parent::updateFieldOption($_POST[option], $_POST[oid]);
290
  } elseif ($_POST[create_field_option]) {
291
  parent::insertFieldOption($_POST[option]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
293
  $styles = parent::selectAllStyles();
294
  $style_options = '<option value="0">Default</option>';
@@ -306,12 +387,14 @@ if (!class_exists('CustomContactForms')) {
306
  <li><a href="#manage-fields">Manage Fields</a></li>
307
  <li><a href="#manage-fixed-fields">Manage Fixed Fields</a></li>
308
  <li><a href="#manage-forms">Manage Forms</a></li>
 
309
  <li><a href="#create-styles">Create Styles</a></li>
310
  <li><a href="#manage-styles">Manage Styles</a></li>
311
  <li><a href="#manage-field-options">Manage Field Options</a></li>
312
  <li><a href="#contact-author">Suggest a Feature</a></li>
313
  <li><a href="#contact-author">Bug Report</a></li>
314
- <li><a href="#custom-html">Custom HTML Forms (New!)</a></li>
 
315
  <li class="last"><a href="#plugin-news">Plugin News</a></li>
316
  </ul><a name="create-fields"></a>
317
  <div id="create-fields" class="postbox">
@@ -449,7 +532,7 @@ if (!class_exists('CustomContactForms')) {
449
 
450
  ?>
451
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
452
- <tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?> style="border-bottom">
453
 
454
  <td><input type="text" name="field[field_slug]" class="width100" maxlength="50" value="<?php echo $fields[$i]->field_slug; ?>" /></td>
455
  <td><input type="text" name="field[field_label]" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td>
@@ -465,14 +548,15 @@ if (!class_exists('CustomContactForms')) {
465
  <input type="text" class="width50" name="field[field_maxlength]" value="<?php echo $fields[$i]->field_maxlength; ?>" />
466
  <?php } ?>
467
  </td>
468
- <td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" />
 
469
  <span class="fields-options-expand"></span>
470
- <input type="submit" name="field_edit" value="Save" />
471
- <input type="submit" name="field_delete" class="delete_button" value="Delete" /></td>
472
 
473
  </tr>
474
  <tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?>>
475
- <td class="fields-extra-options" colspan="7" style="border-top:0; border-bottom:1px solid black;">
476
  <div class="field-instructions">
477
  <label for="field_instructions">Field Instructions:</label>
478
  <input type="text" class="width150" name="field[field_instructions]" value="<?php echo $fields[$i]->field_instructions; ?>" />
@@ -551,7 +635,7 @@ if (!class_exists('CustomContactForms')) {
551
 
552
  ?>
553
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
554
- <tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?> style="border:none;">
555
 
556
  <td><?php echo $fields[$i]->field_slug; ?></td>
557
  <td><input type="text" name="field[field_label]" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td>
@@ -577,12 +661,13 @@ if (!class_exists('CustomContactForms')) {
577
  <?php } ?>
578
  </td>
579
 
580
- <td><input type="hidden" name="fid" value="<?php echo $fields[$i]->id; ?>" />
 
581
  <span class="fixed-fields-options-expand"></span>
582
- <input type="submit" name="field_edit" value="Save" /></td>
583
  </tr>
584
- <tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?> style="border:none;">
585
- <td class="fixed-fields-extra-options" colspan="7" style="border-bottom:1px solid black;">Field Instructions: <input type="text" name="field[field_instructions]" class="width200" value="<?php echo $fields[$i]->field_instructions; ?>" /> - <?php echo $this->fixed_fields[$fields[$i]->field_slug]; ?></td>
586
  </tr>
587
  </form>
588
  <?php
@@ -622,10 +707,11 @@ if (!class_exists('CustomContactForms')) {
622
  <td class="label"><input type="text" name="option[option_label]" value="<?php echo $option->option_label; ?>" class="width100" /></td>
623
  <td class="option-value"><input type="text" name="option[option_value]" value="<?php echo $option->option_value; ?>" class="width100" /></td>
624
  <td class="action">
625
- <input type="submit" value="Save" name="edit_field_option" />
626
- <input type="submit"class="delete_button" value="Delete" name="delete_field_option" />
627
  </td>
628
- <input type="hidden" name="oid" value="<?php echo $option->id; ?>" />
 
629
  </form>
630
  </tr>
631
  <?php
@@ -644,6 +730,7 @@ if (!class_exists('CustomContactForms')) {
644
  <div class="action">Action</div>
645
  </div>
646
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
 
647
  <div class="create-field-options-header">Create a Field Option</div>
648
  <ul id="create-field-options">
649
  <li><label for="option[option_slug]">* Option Slug:</label> <input maxlength="20" type="text" name="option[option_slug]" /><br />
@@ -652,7 +739,7 @@ if (!class_exists('CustomContactForms')) {
652
  (This is what is shown to the user in the dropdown or radio field. Example:)</li>
653
  <li><label for="option[option_value]">Option Value:</label> <input type="text" name="option[option_value]" /><br />
654
  (This is the actual value of the option which isn't shown to the user. This can be the same thing as the label. An example pairing of label => value is: "The color green" => "green" or "Yes" => "1".)</li>
655
- <li><input type="submit" name="create_field_option" value="Create Field Option" /></li>
656
  </ul>
657
  <p id="edit-field-comments"><b>*</b> The option value is behind the scences; unseen by the user, but when a user fills out the form, the option value is what is actually sent in the email to you. For dropdown fields the option value is optional, for radio fields it is required.</p>
658
  </form>
@@ -688,14 +775,15 @@ if (!class_exists('CustomContactForms')) {
688
  <td><input type="text" class="width125" name="form[form_title]" value="<?php echo $forms[$i]->form_title; ?>" /></td>
689
  <td><input class="width100" type="text" name="form[submit_button_text]" value="<?php echo $forms[$i]->submit_button_text; ?>" /></td>
690
  <td><select name="form[form_style]"><?php echo $sty_opt; ?></select></td>
691
- <td><input type="hidden" name="fid" value="<?php echo $forms[$i]->id; ?>" />
 
692
  <span class="form-options-expand"></span>
693
- <input type="submit" name="form_edit" value="Save" />
694
- <input type="submit" name="form_delete" class="delete_button" value="Delete" />
695
  </td>
696
  </tr>
697
  <tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>">
698
- <td class="form-extra-options textcenter" colspan="8" style="border-bottom:1px solid black;">
699
  <table class="form-extra-options-table">
700
  <tbody>
701
  <tr>
@@ -768,12 +856,95 @@ if (!class_exists('CustomContactForms')) {
768
  </tr>
769
 
770
  </tfoot>
771
- </table><a name="general-settings"></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  <div id="general-settings" class="postbox">
773
  <h3 class="hndle"><span>General Settings</span></h3>
774
  <div class="inside">
775
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
776
  <ul>
 
 
 
 
 
 
777
  <li>
778
  <label for="default_to_email">Default Email:</label>
779
  <input name="default_to_email" value="<?php echo $admin_options[default_to_email]; ?>" type="text" maxlength="100" />
@@ -859,7 +1030,7 @@ if (!class_exists('CustomContactForms')) {
859
  On Archives</label>
860
  </li>
861
  <li>
862
- <input type="submit" value="Save Settings" name="general_settings" />
863
  </li>
864
  </ul>
865
  </form>
@@ -964,6 +1135,10 @@ if (!class_exists('CustomContactForms')) {
964
  <label for="success_popover_title_fontsize">Success Popover Title Font Size:</label>
965
  <input type="text" maxlength="20" value="12px" class="width75" name="style[success_popover_title_fontsize]" />
966
  (ex: 12px, 1em, 100%)</li>
 
 
 
 
967
  </ul>
968
  <ul class="style_right">
969
  <li>
@@ -1069,8 +1244,8 @@ if (!class_exists('CustomContactForms')) {
1069
  <label>Font Family:</label><input type="text" maxlength="20" value="<?php echo $style->form_fontfamily; ?>" name="style[form_fontfamily]" /><br />
1070
  <label>Textarea Background<br />Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->textarea_backgroundcolor; ?>" name="style[textarea_backgroundcolor]" /><br />
1071
  <label>Success Popover<br />Border Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->success_popover_bordercolor; ?>" name="style[success_popover_bordercolor]" /><br />
1072
- <input type="submit" class="submit-styles" name="style_edit" value="Save" /><br />
1073
- <input type="submit" class="submit-styles delete_button" name="style_delete" value="Delete Style" />
1074
  </td>
1075
 
1076
  <td>
@@ -1089,6 +1264,7 @@ if (!class_exists('CustomContactForms')) {
1089
  <label>Field Background Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->field_backgroundcolor; ?>" name="style[field_backgroundcolor]" /><br />
1090
  <label>Title Margin:</label><input type="text" maxlength="20" value="<?php echo $style->title_margin; ?>" name="style[title_margin]" /><br />
1091
  <label>Success Popover<br />Title Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->success_popover_title_fontsize; ?>" name="style[success_popover_title_fontsize]" />
 
1092
  </td>
1093
 
1094
  <td>
@@ -1115,7 +1291,8 @@ if (!class_exists('CustomContactForms')) {
1115
  <label>Field Border Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->field_bordercolor; ?>" name="style[field_bordercolor]" /><br />
1116
  <label>Field Border Style:</label><select name="style[field_borderstyle]"><?php echo str_replace('<option>'.$style->field_borderstyle.'</option>', '<option selected="selected">'.$style->field_borderstyle.'</option>', $border_style_options); ?></select><br />
1117
  <label>Success Popover<br />Title Font Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->success_popover_title_fontcolor; ?>" name="style[success_popover_title_fontcolor]" /><br />
1118
- <input name="sid" type="hidden" value="<?php echo $style->id; ?>" />
 
1119
  </td>
1120
 
1121
  </form>
@@ -1147,7 +1324,7 @@ if (!class_exists('CustomContactForms')) {
1147
  <input id="email" type="text" value="<?php echo get_option('admin_email'); ?>" name="email" maxlength="100" /></li>
1148
  <li><label for="message">* Your Message:</label>
1149
  <textarea id="message" name="message"></textarea></li>
1150
- <li><label for="type">* Purpose of this message:</label> <select id="type" name="type"><option>Bug Report</option><option>Suggest a Feature</option></select></li>
1151
  </ul>
1152
  <p><input type="submit" name="contact_author" value="Send Message" /></p>
1153
  </form>
@@ -1177,6 +1354,25 @@ the field names you want required by commas. Remember to use underscores instead
1177
  &lt;/form&gt;</textarea>
1178
  </div>
1179
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1180
  <a name="plugin-news"></a>
1181
  <div id="plugin-news" class="postbox">
1182
  <h3 class="hndle"><span>Custom Contact Forms Plugin News</span></h3>
@@ -1313,10 +1509,10 @@ the field names you want required by commas. Remember to use underscores instead
1313
  $style = parent::selectStyle($form->form_style, '');
1314
  $style_class = $style->style_slug;
1315
  }
1316
- $form_title = parent::decodeOption($form->form_title, 1, 1);
1317
  $action = (!empty($form->form_action)) ? $form->form_action : $_SERVER['REQUEST_URI'];
1318
  $out .= '<form id="'.$form_id.'" method="'.strtolower($form->form_method).'" action="'.$action.'" class="'.$style_class.'">' . "\n";
1319
- $out .= parent::decodeOption($form->custom_code, 1, 1) . "\n";
1320
  if (!empty($form_title)) $out .= '<h4 id="h4-' . $form->id . '-' . $form_key . '">' . $form_title . '</h4>' . "\n";
1321
  $fields = parent::getAttachedFieldsArray($fid);
1322
  $hiddens = '';
@@ -1325,8 +1521,8 @@ the field names you want required by commas. Remember to use underscores instead
1325
  $field = parent::selectField($field_id, '');
1326
  $req = ($field->field_required == 1 or $field->field_slug == 'ishuman') ? '* ' : '';
1327
  $req_long = ($field->field_required == 1) ? ' (required)' : '';
1328
- $input_id = 'id="'.parent::decodeOption($field->field_slug, 1, 1).'-'.$form_key.'"';
1329
- $field_value = parent::decodeOption($field->field_value, 1, 1);
1330
  $instructions = (empty($field->field_instructions)) ? '' : 'title="' . $field->field_instructions . $req_long . '" class="ccf-tooltip-field"';
1331
  if ($admin_options[enable_widget_tooltips] == 0 && $is_sidebar) $instructions = '';
1332
  if ($_SESSION[fields][$field->field_slug]) {
@@ -1336,13 +1532,13 @@ the field names you want required by commas. Remember to use underscores instead
1336
  $out .= '<div>' . "\n" . $this->getCaptchaCode($form->id) . "\n" . '</div>' . "\n";
1337
  } elseif ($field->field_type == 'Text') {
1338
  $maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"';
1339
- $out .= '<div>'."\n".'<label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'. $req .parent::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<input '.$instructions.' '.$input_id.' type="text" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'"'.$maxlength.''.$code_type.'>'."\n".'</div>' . "\n";
1340
  } elseif ($field->field_type == 'Hidden') {
1341
- $hiddens .= '<input type="hidden" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'" '.$input_id.''.$code_type.'>' . "\n";
1342
  } elseif ($field->field_type == 'Checkbox') {
1343
- $out .= '<div>'."\n".'<input '.$instructions.' type="checkbox" name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.parent::decodeOption($field->field_value, 1, 1).'" '.$input_id.''.$code_type.'> '."\n".'<label class="checkbox" for="'.parent::decodeOption($field->field_slug, 1, 1).'">' . $req .parent::decodeOption($field->field_label, 1, 1).'</label>'."\n".'</div>' . "\n";
1344
  } elseif ($field->field_type == 'Textarea') {
1345
- $out .= '<div>'."\n".'<label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'. $req .parent::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<textarea '.$instructions.' '.$input_id.' rows="5" cols="40" name="'.parent::decodeOption($field->field_slug, 1, 1).'">'.$field_value.'</textarea>'."\n".'</div>' . "\n";
1346
  } elseif ($field->field_type == 'Dropdown') {
1347
  $field_options = '';
1348
  $options = parent::getAttachedFieldOptionsArray($field->id);
@@ -1353,8 +1549,8 @@ the field names you want required by commas. Remember to use underscores instead
1353
  $field_options .= '<option'.$option_sel.''.$option_value.'>' . $option->option_label . '</option>' . "\n";
1354
  }
1355
  if (!empty($options)) {
1356
- if (!$is_sidebar) $out .= '<div>'."\n".'<select '.$instructions.' '.$input_id.' name="'.parent::decodeOption($field->field_slug, 1, 1).'">'."\n".$field_options.'</select>'."\n".'<label class="checkbox" for="'.parent::decodeOption($field->field_slug, 1, 1).'">'. $req .parent::decodeOption($field->field_label, 1, 1).'</label>'."\n".'</div>' . "\n";
1357
- else $out .= '<div>'."\n".'<label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'. $req .parent::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<select '.$instructions.' '.$input_id.' name="'.parent::decodeOption($field->field_slug, 1, 1).'">'."\n".$field_options.'</select>'."\n".'</div>' . "\n";
1358
  }
1359
  } elseif ($field->field_type == 'Radio') {
1360
  $field_options = '';
@@ -1362,13 +1558,13 @@ the field names you want required by commas. Remember to use underscores instead
1362
  foreach ($options as $option_id) {
1363
  $option = parent::selectFieldOption($option_id);
1364
  $option_sel = ($field->field_value == $option->option_slug) ? ' checked="checked"' : '';
1365
- $field_options .= '<div><input'.$option_sel.' type="radio" '.$instructions.' name="'.parent::decodeOption($field->field_slug, 1, 1).'" value="'.parent::decodeOption($option->option_value, 1, 1).'"'.$code_type.'> <label class="select" for="'.parent::decodeOption($field->field_slug, 1, 1).'">' . parent::decodeOption($option->option_label, 1, 1) . '</label></div>' . "\n";
1366
  }
1367
- $field_label = (!empty($field->field_label)) ? '<label for="'.parent::decodeOption($field->field_slug, 1, 1).'">'. $req .parent::decodeOption($field->field_label, 1, 1).'</label>' : '';
1368
  if (!empty($options)) $out .= '<div>'."\n".$field_label."\n".$field_options."\n".'</div>' . "\n";
1369
  }
1370
  }
1371
- $submit_text = (!empty($form->submit_button_text)) ? parent::decodeOption($form->submit_button_text, 1, 0) : 'Submit';
1372
  $out .= '<input name="form_page" value="'.$_SERVER['REQUEST_URI'].'" type="hidden"'.$code_type.'>'."\n".'<input type="hidden" name="fid" value="'.$form->id.'"'.$code_type.'>'."\n".$hiddens."\n".'<input type="submit" id="submit-' . $form->id . '-'.$form_key.'" class="submit" value="' . $submit_text . '" name="customcontactforms_submit"'.$code_type.'>' . "\n" . '</form>';
1373
  if ($admin_options[author_link] == 1) $out .= "\n".'<a class="hide" href="http://www.taylorlovett.com" title="Rockville Web Developer, Wordpress Plugins">Wordpress plugin expert and Rockville Web Developer Taylor Lovett</a>';
1374
 
@@ -1416,7 +1612,7 @@ the field names you want required by commas. Remember to use underscores instead
1416
  $body .= "Message: $message\n";
1417
  $body .= "Message Type: $type\n";
1418
  $body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1419
- $mailer = new CustomContactFormsMailer('admin@taylorlovett.com', $email, "CCF Message: $type", stripslashes($body), $admin_options[wp_mail_function], $admin_options[default_to_email]);
1420
  $mailer->send();
1421
  return true;
1422
  }
@@ -1478,17 +1674,22 @@ the field names you want required by commas. Remember to use underscores instead
1478
  if (in_array($key, $req_fields) && !empty($value))
1479
  unset($req_fields[array_search($key, $req_fields)]);
1480
  $body .= ucwords(str_replace('_', ' ', $key)) . ': ' . $value . "\n";
 
1481
  }
1482
  } foreach($req_fields as $err)
1483
  $this->setFormError($err, 'You left the "' . $err . '" field blank.');
1484
  $errors = $this->getAllFormErrors();
1485
  if (empty($errors)) {
 
1486
  require_once('custom-contact-forms-mailer.php');
 
 
1487
  $body .= "\n" . 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1488
- $mailer = new CustomContactFormsMailer($_POST[destination_email], $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body), $admin_options[wp_mail_function]);
1489
- $mailer->send();
1490
- if ($_POST[thank_you_page])
1491
- header("Location: " . $_POST[thank_you_page]);
 
1492
  $this->current_thank_you_message = (!empty($_POST[success_message])) ? $_POST[success_message] : $admin_options[form_success_message];
1493
  $this->current_form = 0;
1494
  add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
@@ -1522,31 +1723,38 @@ the field names you want required by commas. Remember to use underscores instead
1522
  $checks[] = $field->field_slug;
1523
  }
1524
  $body = '';
 
1525
  foreach ($_POST as $key => $value) {
1526
  $_SESSION[fields][$key] = $value;
1527
  $field = parent::selectField('', $key);
1528
- if (!array_key_exists($key, $this->fixed_fields) or $key == 'fixedEmail') {
1529
  $mail_field_label = (empty($field->field_label)) ? $field->field_slug : $field->field_label;
1530
  $body .= $mail_field_label . ': ' . $value . "\n";
 
1531
  } if (in_array($key, $checks)) {
1532
  $checks_key = array_search($key, $checks);
1533
  unset($checks[$checks_key]);
1534
  }
1535
  } foreach ($checks as $check_key) {
1536
  $field = parent::selectField('', $check_key);
1537
- $body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': 0' . "\n";
 
1538
  }
1539
  $errors = $this->getAllFormErrors();
1540
  if (empty($errors)) {
1541
  require_once('custom-contact-forms-mailer.php');
 
1542
  unset($_SESSION['captcha_' . $_POST[fid]]);
1543
  unset($_SESSION[fields]);
 
 
1544
  $body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1545
  $to_email = (!empty($form->form_email)) ? $form->form_email : $admin_options[default_to_email];
1546
- $mailer = new CustomContactFormsMailer($to_email, $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body), $admin_options[wp_mail_function], $reply);
1547
- $mailer->send();
1548
- if (!empty($form->form_thank_you_page)) {
1549
- header("Location: " . $form->form_thank_you_page);
 
1550
  }
1551
  $this->current_form = $form->id;
1552
  add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
3
  Plugin Name: Custom Contact Forms
4
  Plugin URI: http://taylorlovett.com/wordpress-plugins
5
  Description: Guaranteed to be 1000X more customizable and intuitive than Fast Secure Contact Forms or Contact Form 7. Customize every aspect of your forms without any knowledge of CSS: borders, padding, sizes, colors. Ton's of great features. Required fields, captchas, tooltip popovers, unlimited fields/forms/form styles, use a custom thank you page or built-in popover with a custom success message set for each form. <a href="options-general.php?page=custom-contact-forms">Settings</a>
6
+ Version: 4.0.0.b1
7
  Author: Taylor Lovett
8
  Author URI: http://www.taylorlovett.com
9
  */
21
  You should have received a copy of the GNU General Public License
22
  along with this program. If not, see <http://www.gnu.org/licenses/>.
23
  */
24
+ require_once('custom-contact-forms-static.php');
25
+ CustomContactFormsStatic::definePluginConstants();
26
  require_once('custom-contact-forms-db.php');
27
  if (!class_exists('CustomContactForms')) {
28
  class CustomContactForms extends CustomContactFormsDB {
29
  var $adminOptionsName = 'customContactFormsAdminOptions';
30
+ var $version = '4.0.0';
31
+ var $form_errors = array();
32
  var $error_return;
33
  var $current_form;
34
  var $current_thank_you_message;
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
  function activatePlugin() {
37
  $admin_options = $this->getAdminOptions();
46
  $admin_email = get_option('admin_email');
47
  $customcontactAdminOptions = array('show_widget_home' => 1, 'show_widget_pages' => 1, 'show_widget_singles' => 1, 'show_widget_categories' => 1, 'show_widget_archives' => 1, 'default_to_email' => $admin_email, 'default_from_email' => $admin_email, 'default_form_subject' => 'Someone Filled Out Your Contact Form!',
48
  'remember_field_values' => 0, 'author_link' => 1, 'enable_widget_tooltips' => 1, 'wp_mail_function' => 1, 'form_success_message_title' => 'Form Success!', 'form_success_message' => 'Thank you for filling out our web form. We will get back to you ASAP.', 'enable_jquery' => 1, 'code_type' => 'XHTML',
49
+ 'show_install_popover' => 0, 'email_form_submissions' => 1); // default general settings
50
  $customcontactOptions = get_option($this->adminOptionsName);
51
  if (!empty($customcontactOptions)) {
52
  foreach ($customcontactOptions as $key => $option)
59
  if (!is_admin()) {
60
  $this->startSession();
61
  $this->processForms();
62
+ } else {
63
+ $this->downloadExportFile();
64
+ }
65
+ }
66
+
67
+ function downloadExportFile() {
68
+ if ($_POST[ccf_export]) {
69
+ require_once('custom-contact-forms-export.php');
70
+ $transit = new CustomContactFormsExport();
71
+ $transit->exportAll();
72
+ $file = $transit->exportToFile();
73
+ CustomContactFormsStatic::redirect(get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/download.php?location=export/' . $file);
74
  }
75
  }
76
 
93
  }
94
 
95
  function insertAdminScripts() {
96
+ if (is_admin()) {
97
+ ?>
98
+ <script type="text/javascript" language="javascript">
99
+ var ccf_plugin_dir = "<?php echo get_option('siteurl') . '/wp-content/plugins/custom-contact-forms'; ?>";
100
+ var ccf_file = "<?php echo get_option('siteurl') . '/wp-admin/options-general.php?page=custom-contact-forms'; ?>";
101
+ </script>
102
+ <?php
103
+ wp_enqueue_script('ccf-admin-inc', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/custom-contact-forms-admin-inc.js', array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'/*, 'jquery-ui-draggable', 'jquery-ui-resizable', 'jquery-ui-dialog'*/), '1.0');
104
+ wp_enqueue_script('ccf-admin', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/custom-contact-forms-admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'/*, 'jquery-ui-draggable', 'jquery-ui-resizable', 'jquery-ui-dialog'*/), '1.0');
105
+ wp_enqueue_script('ccf-colorpicker', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/colorpicker.js');
106
+ wp_enqueue_script('ccf-eye', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/eye.js');
107
+ wp_enqueue_script('ccf-utils', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/utils.js');
108
+ wp_enqueue_script('ccf-layout', get_option('siteurl') . '/wp-content/plugins/custom-contact-forms/js/layout.js?ver=1.0.2');
109
+ }
110
  }
111
 
112
  function insertFrontEndScripts() {
144
  <a href="javascript:void(0)" class="close">[close]</a>
145
  </div>
146
  <div class="popover-body">
147
+ <ul id="popover-tof">
148
+ <li><a href="#pop-forms">Forms</a></li>
149
+ <li><a href="#pop-fields">Fields</a></li>
150
+ <li><a href="#pop-field-options">Field Options</a></li>
151
+ <li><a href="#pop-styles">Styles</a></li>
152
+ <li><a href="#pop-custom-html">Custom HTML Forms</a></li>
153
+ <li><a href="#pop-import-export">Import / Export</a></li>
154
+ <li><a href="#pop-form-submissions">Form Submissions</a></li>
155
+ </ul>
156
  <p>CCF is an extremely intuitive plugin allowing you to create any type of contact form you can imagine. CCF is very user friendly but with possibilities comes complexity. It is recommend that you click the button below to create default fields, field options, and forms.
157
  The default content will help you get a feel for the amazing things you can accomplish with this plugin. This popover only shows automatically the first time you visit the admin page; <b>if you want to view this popover again, click the "Show Plugin Usage Popover"</b> in the instruction area of the admin page.</p>
158
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
159
  <input type="submit" class="insert-default-content-button" value="Insert Default Content" name="insert_default_content" />
160
  </form>
161
+ <p>Below is a basic usage outline of the four pillars of this plugin: fields, field options, styles, and forms. Another useful part of the plugin is the "Custom HTML Feature" which allows you to write the form HTML yourself using the plugin simply as a form processor; this is great if you are a web developer with HTML experience. Also explained below is the "Saved Form Submissions" feature which displays all form submissions in the admin panel.</p>
162
  <ul>
163
  <li>
164
+ <h3>Fields<a name="pop-fields"></a></h3>
165
  <p>Fields are the actual input boxes in which users enter their information. There are six types of fields that you can attach to your forms.</p>
166
  <ul>
167
  <li><span>Text:</span>
190
  <p>The last important thing related to fields are <span>Fixed Fields</span>. Fixed Fields are special fields that come already created within the plugin such as the captcha spam blocker and email field. Fixed Fields do special things that you wouldn't be able to accomplish with normally; they cannot be deleted or created. If you use the fixedEmail field, as opposed to creating your own email field. the users email will be checked to make sure it is valid, if it isn't a form error will be displayed.</p>
191
  </li>
192
  <li>
193
+ <h3>Field Options<a name="pop-field-options"></a></h3>
194
  <p>In the field section above, look at the radio or dropdown fields. See how they have multiple options within the field? Those are called Field Options. Field Options have their own manager. There are only three things you must fill in to create a field option.</p>
195
  <ul>
196
  <li><span class="red">*</span> <span>Slug:</span> Used to identify the field option, solely for admin purposes; must be unique, and contain only letters, numbers, and underscores. Example: "slug_one".</li>
200
  <p>Once you create field options, you can attach them (in the field manager) to radio and dropdown fields (that are already created). It is important to remember that after you create a dropdown or radio field, they will not work until you attach one or more field options.</p>
201
  </li>
202
  <li>
203
+ <h3>Forms<a name="pop-forms"></a></h3>
204
  <p>Forms bring everything together. Each form you create in the form manager shows a code to display that form in posts/pages as well as theme files. The post/page form display code looks like: [customcontact id=FORMID]. There are a number of parameters that you can fill out when creating and managing each of your forms.</p>
205
  <ul>
206
  <li><span class="red">*</span> <span>Slug:</span> A slug is simply a way to identify your form. It can only contain underscores, letters, and numbers and must be unique. Example "my_contact_form"</li>
220
  <div class="ccf-success-popover-example"></div>
221
  </li>
222
  <li>
223
+ <h3>Style Manager<a name="pop-styles"></a></h3>
224
  <p>The style manager allows you to customize the appearance of forms without any knowledge of CSS. There are a ton of parameters you can fill out with each style and all of them are pretty self-explanitory. After you create a style, you need to go to the form manager and set the form style to the new style you created (the slug will be what shows in the "Form Style" dropdown).</p>
225
  <p>The image below will help you better understand how each style option will change your forms.</p>
226
  <div class="ccf-style-example"></div>
227
  </li>
228
  <li>
229
+ <h3>Custom HTML Forms Feature (advanced)<a name="pop-custom-html"></a></h3>
230
  <p>If you know HTML and simply want to use this plugin to process form requests, this feature is for you. The following HTML is a the framework to which you must adhere. In order for your form to work you MUST do the following:</p>
231
  <ul>
232
  <li>Keep the form action/method the same (yes the action is supposed to be empty).</li>
235
  </ul>
236
  <p>Just to be clear, you don't edit the code in the Custom HTML Forms feature within the admin panel. Instead, you copy the code in to the page, post, or theme file you want to display a form, then edit the code to look how you want following the guidelines provided above.</p>
237
  </li>
238
+ <li>
239
+ <h3>Saved Form Submissions<a name="pop-form-submissions"></a></h3>
240
+ <p>This features saves each user form submission. All the fields attached to the form along with the time of submission and form URL are saved in the database and displayed in a stylish format in the admin panel.</p>
241
+ </li>
242
+ <li>
243
+ <h3>Import / Export<a name="pop-import-export"></a></h3>
244
+ <p>Import/export is a new field that allows you to transfer forms, fields, field options, styles and everything else saved by the plugin between Wordpress installations. Clicking the Export All button will create a .SQL file for download. With the .SQL export file you can use the importer within the CCF plugin admin page to import the .SQL file. You can also use PHPMyAdmin or any other MySQL database administration tool to run the import file. Importing a .SQL file will never overwrite any existing data.</p>
245
+ </li>
246
  </ul>
247
  </div>
248
  </div>
275
  $admin_options[show_widget_archives] = $_POST[show_widget_archives];
276
  $admin_options[show_widget_home] = $_POST[show_widget_home];
277
  $admin_options[custom_thank_you] = $_POST[custom_thank_you];
278
+ $admin_options[email_form_submissions] = $_POST[email_form_submissions];
279
  $admin_options[author_link] = $_POST[author_link];
280
  $admin_options[enable_jquery] = $_POST[enable_jquery];
281
  $admin_options[code_type] = $_POST[code_type];
318
  parent::updateFieldOption($_POST[option], $_POST[oid]);
319
  } elseif ($_POST[create_field_option]) {
320
  parent::insertFieldOption($_POST[option]);
321
+ } elseif ($_POST[form_submission_delete]) {
322
+ parent::deleteUserData($_POST[uid]);
323
+ } elseif ($_POST[ccf_import]) {
324
+ require_once('custom-contact-forms-export.php');
325
+ $transit = new CustomContactFormsExport();
326
+ $transit->importFromFile($_FILES[import_file]);
327
+ } elseif ($_POST[ajax_action]) {
328
+ switch ($_POST[ajax_action]) {
329
+ case 'delete':
330
+ if (empty($_POST[object_id])) exit;
331
+ switch($_POST[object_type]) {
332
+ case 'form':
333
+ parent::deleteForm($_POST[object_id]);
334
+ break;
335
+ case 'field':
336
+ parent::deleteField($_POST[object_id]);
337
+ break;
338
+ case 'field_option':
339
+ parent::deleteFieldOption($_POST[object_id]);
340
+ break;
341
+ case 'form_submission':
342
+ parent::deleteUserData($_POST[object_id]);
343
+ break;
344
+ case 'style':
345
+ parent::deleteStyle($_POST[object_id]);
346
+ break;
347
+ }
348
+ break;
349
+ case 'create_field_option':
350
+ parent::insertFieldOption($_POST[option]);
351
+ break;
352
+ case 'edit':
353
+ echo '<div style="margin-left:100px">';
354
+ print_r($_POST);
355
+ echo '</div>';
356
+ if (empty($_POST[object_id])) exit;
357
+ switch($_POST[object_type]) {
358
+ case 'form':
359
+ if (!empty($_POST[form])) parent::updateForm($_POST[form], $_POST[object_id]);
360
+ break;
361
+ case 'field':
362
+ if (!empty($_POST[field])) parent::updateField($_POST[field], $_POST[object_id]);
363
+ break;
364
+ case 'field_option':
365
+ if (!empty($_POST[option])) parent::updateFieldOption($_POST[option], $_POST[object_id]);
366
+ break;
367
+ case 'style':
368
+ if (!empty($_POST[style])) parent::updateStyle($_POST[style], $_POST[object_id]);
369
+ break;
370
+ }
371
+ break;
372
+ }
373
  }
374
  $styles = parent::selectAllStyles();
375
  $style_options = '<option value="0">Default</option>';
387
  <li><a href="#manage-fields">Manage Fields</a></li>
388
  <li><a href="#manage-fixed-fields">Manage Fixed Fields</a></li>
389
  <li><a href="#manage-forms">Manage Forms</a></li>
390
+ <li><a href="#form-submissions">Saved Form Submissions (New!)</a></li>
391
  <li><a href="#create-styles">Create Styles</a></li>
392
  <li><a href="#manage-styles">Manage Styles</a></li>
393
  <li><a href="#manage-field-options">Manage Field Options</a></li>
394
  <li><a href="#contact-author">Suggest a Feature</a></li>
395
  <li><a href="#contact-author">Bug Report</a></li>
396
+ <li><a href="#custom-html">Custom HTML Forms</a></li>
397
+ <li><a href="#import-export">Import / Export (New!)</a></li>
398
  <li class="last"><a href="#plugin-news">Plugin News</a></li>
399
  </ul><a name="create-fields"></a>
400
  <div id="create-fields" class="postbox">
532
 
533
  ?>
534
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
535
+ <tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?>>
536
 
537
  <td><input type="text" name="field[field_slug]" class="width100" maxlength="50" value="<?php echo $fields[$i]->field_slug; ?>" /></td>
538
  <td><input type="text" name="field[field_label]" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td>
548
  <input type="text" class="width50" name="field[field_maxlength]" value="<?php echo $fields[$i]->field_maxlength; ?>" />
549
  <?php } ?>
550
  </td>
551
+ <td><input type="hidden" class="object-type" name="object_type" value="field" />
552
+ <input type="hidden" class="object-id" name="fid" value="<?php echo $fields[$i]->id; ?>" />
553
  <span class="fields-options-expand"></span>
554
+ <input type="submit" class="edit-button" name="field_edit" value="Save" />
555
+ <input type="submit" name="field_delete" class="delete-button" value="Delete" /></td>
556
 
557
  </tr>
558
  <tr<?php if ($z % 2 == 1) echo ' class="evenrow"'; ?>>
559
+ <td class="fields-extra-options" colspan="7">
560
  <div class="field-instructions">
561
  <label for="field_instructions">Field Instructions:</label>
562
  <input type="text" class="width150" name="field[field_instructions]" value="<?php echo $fields[$i]->field_instructions; ?>" />
635
 
636
  ?>
637
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
638
+ <tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?>>
639
 
640
  <td><?php echo $fields[$i]->field_slug; ?></td>
641
  <td><input type="text" name="field[field_label]" maxlength="100" value="<?php echo $fields[$i]->field_label; ?>" /></td>
661
  <?php } ?>
662
  </td>
663
 
664
+ <td><input type="hidden" class="object-type" name="object_type" value="field" />
665
+ <input type="hidden" class="object-id" name="fid" value="<?php echo $fields[$i]->id; ?>" />
666
  <span class="fixed-fields-options-expand"></span>
667
+ <input type="submit" name="field_edit" class="edit-button" value="Save" /></td>
668
  </tr>
669
+ <tr <?php if ($z % 2 == 0) echo ' class="evenrow"'; ?>>
670
+ <td class="fixed-fields-extra-options" colspan="7">Field Instructions: <input type="text" name="field[field_instructions]" class="width200" value="<?php echo $fields[$i]->field_instructions; ?>" /> - <?php echo $GLOBALS[ccf_fixed_fields][$fields[$i]->field_slug]; ?></td>
671
  </tr>
672
  </form>
673
  <?php
707
  <td class="label"><input type="text" name="option[option_label]" value="<?php echo $option->option_label; ?>" class="width100" /></td>
708
  <td class="option-value"><input type="text" name="option[option_value]" value="<?php echo $option->option_value; ?>" class="width100" /></td>
709
  <td class="action">
710
+ <input type="submit" value="Save" class="edit-button" name="edit_field_option" />
711
+ <input type="submit" class="delete-button" value="Delete" name="delete_field_option" />
712
  </td>
713
+ <input type="hidden" class="object-type" name="object_type" value="field_option" />
714
+ <input type="hidden" class="object-id" name="oid" value="<?php echo $option->id; ?>" />
715
  </form>
716
  </tr>
717
  <?php
730
  <div class="action">Action</div>
731
  </div>
732
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
733
+ <input type="hidden" name="object_type" value="field_option" />
734
  <div class="create-field-options-header">Create a Field Option</div>
735
  <ul id="create-field-options">
736
  <li><label for="option[option_slug]">* Option Slug:</label> <input maxlength="20" type="text" name="option[option_slug]" /><br />
739
  (This is what is shown to the user in the dropdown or radio field. Example:)</li>
740
  <li><label for="option[option_value]">Option Value:</label> <input type="text" name="option[option_value]" /><br />
741
  (This is the actual value of the option which isn't shown to the user. This can be the same thing as the label. An example pairing of label => value is: "The color green" => "green" or "Yes" => "1".)</li>
742
+ <li><input type="submit" class="create-button" name="create_field_option" value="Create Field Option" /></li>
743
  </ul>
744
  <p id="edit-field-comments"><b>*</b> The option value is behind the scences; unseen by the user, but when a user fills out the form, the option value is what is actually sent in the email to you. For dropdown fields the option value is optional, for radio fields it is required.</p>
745
  </form>
775
  <td><input type="text" class="width125" name="form[form_title]" value="<?php echo $forms[$i]->form_title; ?>" /></td>
776
  <td><input class="width100" type="text" name="form[submit_button_text]" value="<?php echo $forms[$i]->submit_button_text; ?>" /></td>
777
  <td><select name="form[form_style]"><?php echo $sty_opt; ?></select></td>
778
+ <td><input type="hidden" class="object-id" name="fid" value="<?php echo $forms[$i]->id; ?>" />
779
+ <input type="hidden" class="object-type" name="object_type" value="form" />
780
  <span class="form-options-expand"></span>
781
+ <input type="submit" name="form_edit" class="edit-button" value="Save" />
782
+ <input type="submit" name="form_delete" class="delete-button" value="Delete" />
783
  </td>
784
  </tr>
785
  <tr class="<?php if ($i % 2 == 0) echo 'evenrow'; ?>">
786
+ <td class="form-extra-options textcenter" colspan="8">
787
  <table class="form-extra-options-table">
788
  <tbody>
789
  <tr>
856
  </tr>
857
 
858
  </tfoot>
859
+ </table>
860
+ <?php
861
+ require_once('custom-contact-forms-user-data.php');
862
+ $user_data_array = parent::selectAllUserData();
863
+ ?>
864
+ <a name="form-submissions"></a>
865
+ <h3 class="manage-h3">Saved Form Submissions</h3>
866
+ <table class="widefat post" id="form-submissions" cellspacing="0">
867
+ <thead>
868
+ <tr>
869
+ <th scope="col" class="manage-column width250">Date Submitted</th>
870
+ <th scope="col" class="manage-column width150">Form Submitted</th>
871
+ <th scope="col" class="manage-column width250">Form Page</th>
872
+ <th scope="col" class="manage-column "><div class="alignright">Action</div></th>
873
+ </tr>
874
+ </thead>
875
+ <tbody>
876
+ <?php
877
+ $i = 0;
878
+ foreach ($user_data_array as $data_object) {
879
+ $data = new CustomContactFormsUserData(array('form_id' => $data_object->data_formid, 'data_time' => $data_object->data_time, 'form_page' => $data_object->data_formpage, 'encoded_data' => $data_object->data_value));
880
+ ?>
881
+ <tr class="submission-top <?php if ($i % 2 == 0) echo 'evenrow'; ?>">
882
+ <td><?php echo date('F d, Y h:i:s A', $data->getDataTime()); ?></td>
883
+ <td>
884
+ <?php
885
+ if ($data->getFormID() > 0) {
886
+ $data_form = parent::selectForm($data->getFormID());
887
+ echo $data_form->form_slug;
888
+ } else
889
+ echo 'Custom HTML Form'
890
+ ?>
891
+ </td>
892
+ <td>
893
+ <?php echo $data->getFormPage(); ?>
894
+ </td>
895
+ <td class="alignright">
896
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
897
+ <span class="submission-content-expand"></span>
898
+ <input type="submit" class="delete-button" value="Delete" name="form_submission_delete" />
899
+ <input type="hidden" class="object-type" name="object_type" value="form_submission" />
900
+ <input type="hidden" class="object-id" value="<?php echo $data_object->id; ?>" name="uid" />
901
+ </form>
902
+ </td>
903
+ </tr>
904
+ <tr class="submission-content <?php if ($i % 2 == 0) echo 'evenrow'; ?>">
905
+ <td colspan="4">
906
+ <ul>
907
+ <?php
908
+ $data_array = $data->getDataArray();
909
+ foreach ($data_array as $item_key => $item_value) {
910
+ ?>
911
+ <li>
912
+ <div><?php echo $item_key; ?></div>
913
+ <p><?php echo $item_value; ?></p>
914
+ </li>
915
+ <?php
916
+ }
917
+ ?>
918
+ </ul>
919
+ </td>
920
+ </tr>
921
+ <?php
922
+ $i++;
923
+ }
924
+ ?>
925
+ </tbody>
926
+ <tfoot>
927
+ <tr>
928
+ <th scope="col" class="manage-column width250">Date Submitted</th>
929
+ <th scope="col" class="manage-column width150">Form Submitted</th>
930
+ <th scope="col" class="manage-column width250">Form Page</th>
931
+ <th scope="col" class="manage-column "><div class="alignright">Action</div></th>
932
+ </tr>
933
+ </tfoot>
934
+ </table>
935
+
936
+ <a name="general-settings"></a>
937
  <div id="general-settings" class="postbox">
938
  <h3 class="hndle"><span>General Settings</span></h3>
939
  <div class="inside">
940
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
941
  <ul>
942
+ <li>
943
+ <label for="email_form_submissions">Email Form Submissions:</label>
944
+ <select name="email_form_submissions"><option value="1">Yes</option><option value="0" <?php if ($admin_options[email_form_submissions] == 0) echo 'selected="selected"'; ?>>No</option></select>
945
+ </li>
946
+ <li class="descrip">When a user fills out one of your forms, the info he submitted is saved in the Saved Form Submission section of the admin panel for you to view. If this is enabled, you will also be sent an email containing the submission info.</li>
947
+
948
  <li>
949
  <label for="default_to_email">Default Email:</label>
950
  <input name="default_to_email" value="<?php echo $admin_options[default_to_email]; ?>" type="text" maxlength="100" />
1030
  On Archives</label>
1031
  </li>
1032
  <li>
1033
+ <input type="submit" value="Update" name="general_settings" />
1034
  </li>
1035
  </ul>
1036
  </form>
1135
  <label for="success_popover_title_fontsize">Success Popover Title Font Size:</label>
1136
  <input type="text" maxlength="20" value="12px" class="width75" name="style[success_popover_title_fontsize]" />
1137
  (ex: 12px, 1em, 100%)</li>
1138
+ <li>
1139
+ <label for="form_backgroundcolor">Form Background Color:</label>
1140
+ <input type="text" maxlength="20" value="ffffff" class="width75" name="style[form_backgroundcolor]" />
1141
+ (ex: 12px, 1em, 100%)</li>
1142
  </ul>
1143
  <ul class="style_right">
1144
  <li>
1244
  <label>Font Family:</label><input type="text" maxlength="20" value="<?php echo $style->form_fontfamily; ?>" name="style[form_fontfamily]" /><br />
1245
  <label>Textarea Background<br />Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->textarea_backgroundcolor; ?>" name="style[textarea_backgroundcolor]" /><br />
1246
  <label>Success Popover<br />Border Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->success_popover_bordercolor; ?>" name="style[success_popover_bordercolor]" /><br />
1247
+ <input type="submit" class="submit-styles edit-button" name="style_edit" value="Save" /><br />
1248
+ <input type="submit" class="submit-styles delete-button" name="style_delete" value="Delete Style" />
1249
  </td>
1250
 
1251
  <td>
1264
  <label>Field Background Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->field_backgroundcolor; ?>" name="style[field_backgroundcolor]" /><br />
1265
  <label>Title Margin:</label><input type="text" maxlength="20" value="<?php echo $style->title_margin; ?>" name="style[title_margin]" /><br />
1266
  <label>Success Popover<br />Title Font Size:</label><input type="text" maxlength="20" value="<?php echo $style->success_popover_title_fontsize; ?>" name="style[success_popover_title_fontsize]" />
1267
+ <label>Form Background Color:</label><input type="text" maxlength="20" value="<?php echo $style->form_backgroundcolor; ?>" name="style[form_backgroundcolor]" />
1268
  </td>
1269
 
1270
  <td>
1291
  <label>Field Border Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->field_bordercolor; ?>" name="style[field_bordercolor]" /><br />
1292
  <label>Field Border Style:</label><select name="style[field_borderstyle]"><?php echo str_replace('<option>'.$style->field_borderstyle.'</option>', '<option selected="selected">'.$style->field_borderstyle.'</option>', $border_style_options); ?></select><br />
1293
  <label>Success Popover<br />Title Font Color:</label><input class="colorfield" type="text" maxlength="20" value="<?php echo $style->success_popover_title_fontcolor; ?>" name="style[success_popover_title_fontcolor]" /><br />
1294
+ <input type="hidden" class="object-type" name="object_type" value="style" />
1295
+ <input name="sid" type="hidden" class="object-id" value="<?php echo $style->id; ?>" />
1296
  </td>
1297
 
1298
  </form>
1324
  <input id="email" type="text" value="<?php echo get_option('admin_email'); ?>" name="email" maxlength="100" /></li>
1325
  <li><label for="message">* Your Message:</label>
1326
  <textarea id="message" name="message"></textarea></li>
1327
+ <li><label for="type">* Purpose of this message:</label> <select id="type" name="type"><option>Bug Report</option><option>Suggest a Feature</option><option>Plugin Question</option></select></li>
1328
  </ul>
1329
  <p><input type="submit" name="contact_author" value="Send Message" /></p>
1330
  </form>
1354
  &lt;/form&gt;</textarea>
1355
  </div>
1356
  </div>
1357
+ <a name="import-export"></a>
1358
+ <div id="import-export" class="postbox">
1359
+ <h3 class="hndle"><span>Import / Export</span></h3>
1360
+ <div class="inside">
1361
+ <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
1362
+ <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
1363
+ <div class="import">
1364
+ <p>Browse to a CCF .sql export file to import Custom Contact Form data from another Wordpress installation to this one.</p>
1365
+ <input type="file" name="import_file" /> <input name="ccf_import" type="submit" value="Import" />
1366
+ </div>
1367
+ <div class="export">
1368
+ <p>Preforming a Custom Contact Forms export will create a file of the form
1369
+ ccf-export-xxxx.sql on your web server. The file created contains SQL that
1370
+ will recreate all the plugin data on any Wordpress installation.</p>
1371
+ <input type="submit" name="ccf_export" value="Export All CCF Plugin Content" />
1372
+ </div>
1373
+ </form>
1374
+ </div>
1375
+ </div>
1376
  <a name="plugin-news"></a>
1377
  <div id="plugin-news" class="postbox">
1378
  <h3 class="hndle"><span>Custom Contact Forms Plugin News</span></h3>
1509
  $style = parent::selectStyle($form->form_style, '');
1510
  $style_class = $style->style_slug;
1511
  }
1512
+ $form_title = CustomContactFormsStatic::decodeOption($form->form_title, 1, 1);
1513
  $action = (!empty($form->form_action)) ? $form->form_action : $_SERVER['REQUEST_URI'];
1514
  $out .= '<form id="'.$form_id.'" method="'.strtolower($form->form_method).'" action="'.$action.'" class="'.$style_class.'">' . "\n";
1515
+ $out .= CustomContactFormsStatic::decodeOption($form->custom_code, 1, 1) . "\n";
1516
  if (!empty($form_title)) $out .= '<h4 id="h4-' . $form->id . '-' . $form_key . '">' . $form_title . '</h4>' . "\n";
1517
  $fields = parent::getAttachedFieldsArray($fid);
1518
  $hiddens = '';
1521
  $field = parent::selectField($field_id, '');
1522
  $req = ($field->field_required == 1 or $field->field_slug == 'ishuman') ? '* ' : '';
1523
  $req_long = ($field->field_required == 1) ? ' (required)' : '';
1524
+ $input_id = 'id="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'-'.$form_key.'"';
1525
+ $field_value = CustomContactFormsStatic::decodeOption($field->field_value, 1, 1);
1526
  $instructions = (empty($field->field_instructions)) ? '' : 'title="' . $field->field_instructions . $req_long . '" class="ccf-tooltip-field"';
1527
  if ($admin_options[enable_widget_tooltips] == 0 && $is_sidebar) $instructions = '';
1528
  if ($_SESSION[fields][$field->field_slug]) {
1532
  $out .= '<div>' . "\n" . $this->getCaptchaCode($form->id) . "\n" . '</div>' . "\n";
1533
  } elseif ($field->field_type == 'Text') {
1534
  $maxlength = (empty($field->field_maxlength) or $field->field_maxlength <= 0) ? '' : ' maxlength="'.$field->field_maxlength.'"';
1535
+ $out .= '<div>'."\n".'<label for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'. $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<input '.$instructions.' '.$input_id.' type="text" name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'"'.$maxlength.''.$code_type.'>'."\n".'</div>' . "\n";
1536
  } elseif ($field->field_type == 'Hidden') {
1537
+ $hiddens .= '<input type="hidden" name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'" value="'.$field_value.'" '.$input_id.''.$code_type.'>' . "\n";
1538
  } elseif ($field->field_type == 'Checkbox') {
1539
+ $out .= '<div>'."\n".'<input '.$instructions.' type="checkbox" name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'" value="'.CustomContactFormsStatic::decodeOption($field->field_value, 1, 1).'" '.$input_id.''.$code_type.'> '."\n".'<label class="checkbox" for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">' . $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>'."\n".'</div>' . "\n";
1540
  } elseif ($field->field_type == 'Textarea') {
1541
+ $out .= '<div>'."\n".'<label for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'. $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<textarea '.$instructions.' '.$input_id.' rows="5" cols="40" name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'.$field_value.'</textarea>'."\n".'</div>' . "\n";
1542
  } elseif ($field->field_type == 'Dropdown') {
1543
  $field_options = '';
1544
  $options = parent::getAttachedFieldOptionsArray($field->id);
1549
  $field_options .= '<option'.$option_sel.''.$option_value.'>' . $option->option_label . '</option>' . "\n";
1550
  }
1551
  if (!empty($options)) {
1552
+ if (!$is_sidebar) $out .= '<div>'."\n".'<select '.$instructions.' '.$input_id.' name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'."\n".$field_options.'</select>'."\n".'<label class="checkbox" for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'. $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>'."\n".'</div>' . "\n";
1553
+ else $out .= '<div>'."\n".'<label for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'. $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>'."\n".'<select '.$instructions.' '.$input_id.' name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'."\n".$field_options.'</select>'."\n".'</div>' . "\n";
1554
  }
1555
  } elseif ($field->field_type == 'Radio') {
1556
  $field_options = '';
1558
  foreach ($options as $option_id) {
1559
  $option = parent::selectFieldOption($option_id);
1560
  $option_sel = ($field->field_value == $option->option_slug) ? ' checked="checked"' : '';
1561
+ $field_options .= '<div><input'.$option_sel.' type="radio" '.$instructions.' name="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'" value="'.CustomContactFormsStatic::decodeOption($option->option_value, 1, 1).'"'.$code_type.'> <label class="select" for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">' . CustomContactFormsStatic::decodeOption($option->option_label, 1, 1) . '</label></div>' . "\n";
1562
  }
1563
+ $field_label = (!empty($field->field_label)) ? '<label for="'.CustomContactFormsStatic::decodeOption($field->field_slug, 1, 1).'">'. $req .CustomContactFormsStatic::decodeOption($field->field_label, 1, 1).'</label>' : '';
1564
  if (!empty($options)) $out .= '<div>'."\n".$field_label."\n".$field_options."\n".'</div>' . "\n";
1565
  }
1566
  }
1567
+ $submit_text = (!empty($form->submit_button_text)) ? CustomContactFormsStatic::decodeOption($form->submit_button_text, 1, 0) : 'Submit';
1568
  $out .= '<input name="form_page" value="'.$_SERVER['REQUEST_URI'].'" type="hidden"'.$code_type.'>'."\n".'<input type="hidden" name="fid" value="'.$form->id.'"'.$code_type.'>'."\n".$hiddens."\n".'<input type="submit" id="submit-' . $form->id . '-'.$form_key.'" class="submit" value="' . $submit_text . '" name="customcontactforms_submit"'.$code_type.'>' . "\n" . '</form>';
1569
  if ($admin_options[author_link] == 1) $out .= "\n".'<a class="hide" href="http://www.taylorlovett.com" title="Rockville Web Developer, Wordpress Plugins">Wordpress plugin expert and Rockville Web Developer Taylor Lovett</a>';
1570
 
1612
  $body .= "Message: $message\n";
1613
  $body .= "Message Type: $type\n";
1614
  $body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1615
+ $mailer = new CustomContactFormsMailer('admin@taylorlovett.com', $email, "CCF Message: $type", stripslashes($body), $admin_options[wp_mail_function]);
1616
  $mailer->send();
1617
  return true;
1618
  }
1674
  if (in_array($key, $req_fields) && !empty($value))
1675
  unset($req_fields[array_search($key, $req_fields)]);
1676
  $body .= ucwords(str_replace('_', ' ', $key)) . ': ' . $value . "\n";
1677
+ $data_array[$key] = $value;
1678
  }
1679
  } foreach($req_fields as $err)
1680
  $this->setFormError($err, 'You left the "' . $err . '" field blank.');
1681
  $errors = $this->getAllFormErrors();
1682
  if (empty($errors)) {
1683
+ require_once('custom-contact-forms-user-data.php');
1684
  require_once('custom-contact-forms-mailer.php');
1685
+ $data_object = new CustomContactFormsUserData(array('data_array' => $data_array, 'form_page' => $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'], 'form_id' => 0, 'data_time' => time()));
1686
+ parent::insertUserData($data_object);
1687
  $body .= "\n" . 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1688
+ if ($admin_options[email_form_submission] == 1) {
1689
+ $mailer = new CustomContactFormsMailer($_POST[destination_email], $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body), $admin_options[wp_mail_function]);
1690
+ $mailer->send();
1691
+ } if ($_POST[thank_you_page])
1692
+ CustomContactFormsStatic::redirect($_POST[thank_you_page]);
1693
  $this->current_thank_you_message = (!empty($_POST[success_message])) ? $_POST[success_message] : $admin_options[form_success_message];
1694
  $this->current_form = 0;
1695
  add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
1723
  $checks[] = $field->field_slug;
1724
  }
1725
  $body = '';
1726
+ $data_array = array();
1727
  foreach ($_POST as $key => $value) {
1728
  $_SESSION[fields][$key] = $value;
1729
  $field = parent::selectField('', $key);
1730
+ if (!array_key_exists($key, $GLOBALS[ccf_fixed_fields]) or $key == 'fixedEmail') {
1731
  $mail_field_label = (empty($field->field_label)) ? $field->field_slug : $field->field_label;
1732
  $body .= $mail_field_label . ': ' . $value . "\n";
1733
+ $data_array[$key] = $value;
1734
  } if (in_array($key, $checks)) {
1735
  $checks_key = array_search($key, $checks);
1736
  unset($checks[$checks_key]);
1737
  }
1738
  } foreach ($checks as $check_key) {
1739
  $field = parent::selectField('', $check_key);
1740
+ $data_array[$check_key] = 'Not Checked';
1741
+ $body .= ucwords(str_replace('_', ' ', $field->field_label)) . ': Not Checked' . "\n";
1742
  }
1743
  $errors = $this->getAllFormErrors();
1744
  if (empty($errors)) {
1745
  require_once('custom-contact-forms-mailer.php');
1746
+ require_once('custom-contact-forms-user-data.php');
1747
  unset($_SESSION['captcha_' . $_POST[fid]]);
1748
  unset($_SESSION[fields]);
1749
+ $data_object = new CustomContactFormsUserData(array('data_array' => $data_array, 'form_page' => $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], 'form_id' => $form->id, 'data_time' => time()));
1750
+ parent::insertUserData($data_object);
1751
  $body .= 'Sender IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
1752
  $to_email = (!empty($form->form_email)) ? $form->form_email : $admin_options[default_to_email];
1753
+ if ($admin_options[email_form_submission] == 1) {
1754
+ $mailer = new CustomContactFormsMailer($to_email, $admin_options[default_from_email], $admin_options[default_form_subject], stripslashes($body), $admin_options[wp_mail_function], $reply);
1755
+ $mailer->send();
1756
+ } if (!empty($form->form_thank_you_page)) {
1757
+ CustomContactFormsStatic::redirect($form->form_thank_you_page);
1758
  }
1759
  $this->current_form = $form->id;
1760
  add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
download.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Custom Contact Forms Plugin
4
+ By Taylor Lovett - http://www.taylorlovett.com
5
+ Plugin URL: http://www.taylorlovett.com/wordpress-plugins
6
+ */
7
+
8
+ header('Content-Description: File Transfer');
9
+ header('Content-Type: application/octet-stream');
10
+ header('Content-Disposition: attachment; filename=' . basename($_GET[location]));
11
+ header('Content-Transfer-Encoding: binary');
12
+ header('Expires: 0');
13
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
14
+ header('Pragma: public');
15
+ header('Content-Length: ' . filesize($_GET[location]));
16
+ ob_clean();
17
+ flush();
18
+ echo file_get_contents($_GET[location]);
19
+ ?>
export/index.htm ADDED
File without changes
images/wpspin_light.gif ADDED
Binary file
import/index.htm ADDED
File without changes
js/custom-contact-forms-admin-inc.js ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var $j = jQuery.noConflict();
2
+
3
+ function showCCFUsagePopover() {
4
+ $j("#ccf-usage-popover").delay(500).fadeIn('slow');
5
+ }
6
+
7
+ var fx = {
8
+ "initModal" : function() {
9
+ if ($j(".modal-window").length == 0) {
10
+ return $j("<div>")
11
+ .addClass("modal-window")
12
+ .appendTo("body");
13
+ } else {
14
+ return $j(".modal-window");
15
+ }
16
+ },
17
+
18
+ "initDebugWindow" : function() {
19
+ if ($j(".debug-window").length == 0) {
20
+ debug = $j("<div>").addClass("debug-window").appendTo("body");
21
+ debug.click(function() { debug.remove(); });
22
+ return debug;
23
+ } else {
24
+ return $j(".debug-window");
25
+ }
26
+ },
27
+
28
+ "initSaveBox" : function() {
29
+ if ($j(".save-box").length == 0) {
30
+ box = $j("<div>").addClass("save-box").appendTo("body");
31
+ $j("<a>")
32
+ .attr("href", "#")
33
+ .addClass("save-box-close-btn")
34
+ .html("&times")
35
+ .click(function(event) { event.preventDefault(); $j(".save-box").fadeOut("slow"); })
36
+ .appendTo(box);
37
+ $j("<p>").html('Saving <img src="' + ccf_plugin_dir + '/images/wpspin_light.gif" />').appendTo(".save-box");
38
+ return box;
39
+ } else {
40
+ return $j(".save-box");
41
+ }
42
+ },
43
+
44
+ "boxOut": function(event) {
45
+ if (event != undefined) event.preventDefault();
46
+ $j(".modal-window").fadeOut("slow", function() { $j(this).remove(); });
47
+ }
48
+ };
js/custom-contact-forms-admin.js CHANGED
@@ -1,9 +1,5 @@
1
- function showCCFUsagePopover() {
2
- $j("#ccf-usage-popover").delay(500).fadeIn('slow');
3
- }
4
-
5
- var $j = jQuery.noConflict();
6
  $j(document).ready(function(){
 
7
  $j('.form-extra-options').hide();
8
  $j('.form-options-expand').prepend('<input type="button" class="form-options-expand-link" value="More Options" />');
9
  $j('.form-options-expand-link').click(function() {
@@ -16,6 +12,18 @@ $j(document).ready(function(){
16
  .toggle();
17
  });
18
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  $j('.fixed-fields-extra-options').hide();
20
  $j('.fixed-fields-options-expand').prepend('<input type="button" class="fixed-fields-options-expand-link" value="More Options" />');
21
  $j('.fixed-fields-options-expand-link').click(function() {
@@ -45,4 +53,122 @@ $j(document).ready(function(){
45
  $j("#ccf-usage-popover .close").click(function() {
46
  $j("#ccf-usage-popover").fadeOut();
47
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  });
 
 
 
 
 
1
  $j(document).ready(function(){
2
+
3
  $j('.form-extra-options').hide();
4
  $j('.form-options-expand').prepend('<input type="button" class="form-options-expand-link" value="More Options" />');
5
  $j('.form-options-expand-link').click(function() {
12
  .toggle();
13
  });
14
 
15
+ $j('.submission-content').hide();
16
+ $j('.submission-content-expand').prepend('<input type="button" class="submission-content-expand-button" value="Expand" />');
17
+ $j('.submission-content-expand-button').click(function() {
18
+ $j(this)
19
+ .parent()
20
+ .parent()
21
+ .parent()
22
+ .parent()
23
+ .next()
24
+ .toggle();
25
+ });
26
+
27
  $j('.fixed-fields-extra-options').hide();
28
  $j('.fixed-fields-options-expand').prepend('<input type="button" class="fixed-fields-options-expand-link" value="More Options" />');
29
  $j('.fixed-fields-options-expand-link').click(function() {
53
  $j("#ccf-usage-popover .close").click(function() {
54
  $j("#ccf-usage-popover").fadeOut();
55
  });
56
+
57
+ $j(".delete-button").each(function(){
58
+ var name = $j(this).attr('name');
59
+ var value = $j(this).attr('value');
60
+ var html = '<input class="delete-button" type="button" name="'+name+'" value="'+value+'" />';
61
+ $j(this).after(html).remove(); // add new, then remove original input
62
+ });
63
+ $j(".delete-button").live("click", function(event) {
64
+ var object_id = $j(this).parents().find(".object-id").attr("value");
65
+ var object_type = $j(this).parents().find(".object-type").attr("value");
66
+ var parent_row = $j(this).parents("tr:eq(0)");
67
+ var modal = fx.initModal();
68
+ $j("<a>")
69
+ .attr("href", "#")
70
+ .addClass("modal-close-btn")
71
+ .html("&times")
72
+ .click(function(event) { fx.boxOut(event); })
73
+ .appendTo(modal);
74
+ $j("<p>")
75
+ .html("Are you sure you want to delete this " + object_type.replace("_", " ") + "?")
76
+ .appendTo(modal);
77
+ $j("<input>").attr({
78
+ type: "button",
79
+ value: "Click to Confirm"
80
+ }).addClass("delete-button-confirm").appendTo(modal);
81
+ $j(".delete-button-confirm").click(function() {
82
+ $j.ajax({
83
+ type: "POST",
84
+ url: ccf_file,
85
+ data: "ajax_action=delete&object_id=" + object_id + "&object_type=" + object_type,
86
+ success: function(data) {
87
+ if (object_type == "form" || object_type == "field" || object_type == "form_submission")
88
+ parent_row.next().remove();
89
+ parent_row.remove();
90
+ modal.remove();
91
+ },
92
+ error: function() {
93
+ modal.append("An error has occured, please try again later.");
94
+ }
95
+ });
96
+ });
97
+ });
98
+ $j(".edit-button").each(function(){
99
+ var name = $j(this).attr('name');
100
+ var value = $j(this).attr('value');
101
+ var html = '<input class="edit-button" type="button" name="'+name+'" value="'+value+'" />';
102
+ $j(this).after(html).remove(); // add new, then remove original input
103
+ });
104
+ $j(".edit-button").live("click", function(event) {
105
+ save_box = fx.initSaveBox();
106
+ //salert("sdf");
107
+ var object_id = $j(this).parents().find(".object-id").attr("value");
108
+ var object_type = $j(this).parents().find(".object-type").attr("value");
109
+ var values = "object_id=" + object_id + "&object_type=" + object_type + "&ajax_action=edit";
110
+ var object_rows = $j(this).parents("tr:eq(0)");
111
+ if (object_type == "form" || object_type == "field")
112
+ object_rows = object_rows.add(object_rows.next());
113
+ object_rows.find("input").each(function() {
114
+ if ($j(this).attr("name").match(/\[/)) {
115
+ key = $j(this).attr("name");;
116
+ values = values + "&" + key + "=" + $j(this).attr("value");
117
+ }
118
+ });
119
+ $j.ajax({
120
+ type: "POST",
121
+ url: ccf_file,
122
+ data: values,
123
+ success: function(data) {
124
+ //debug = fx.initDebugWindow();
125
+ //$j("<div>").html(data).appendTo(debug);
126
+ $j(".save-box").fadeOut().remove();
127
+ },
128
+ error: function() {
129
+ modal.append("An error has occured, please try again later.");
130
+ }
131
+ });
132
+ });
133
+ /*
134
+ $j(".create-button").each(function(){
135
+ var name = $j(this).attr('name');
136
+ var value = $j(this).attr('value');
137
+ var html = '<input class="create-button" type="button" name="'+name+'" value="'+value+'" />';
138
+ $j(this).after(html).remove(); // add new, then remove original input
139
+ });
140
+ $j(".create-button").live("click", function(event) {
141
+ var icon = fx.getLoadingIcon().insertBefore(this);
142
+ var object_type = $j(this).parents().find("input[name=object_type]").attr("value");
143
+ if (object_type == "field_option") {
144
+ var values = "ajax_action=create_field_option";
145
+ var value_array = [];
146
+ var new_row = $j('#edit-field-options tr:first').clone(true).addClass("new-object").hide().insertBefore('#edit-field-options tr:first');
147
+ $j(this).parents("form:eq(0)").find("input").each(function() {
148
+ if ($j(this).attr("name").match(/^option\[/)) {
149
+ values = values + "&" + $j(this).attr("name") + "=" + $j(this).attr("value");
150
+ key = $j(this).attr("name").replace(/^option\[(.*)\]$/, "$1");
151
+ value_array[key] = $j(this).attr("value");
152
+ $j(".new-object input[name=\"option[" + key + "]\"]").attr("value", value_array[key]);
153
+ }
154
+ });
155
+ // Try to get first row of field options table to use its html as a framework for new row
156
+ }
157
+ //new_row = $j("#edit-field-options tr:first").html().appendTo("body").hide();
158
+
159
+ // Create generic class of objects/functions to add delete/edit/insert capabilities on certain tables
160
+ $j.ajax({
161
+ type: "POST",
162
+ url: ccf_file,
163
+ data: values,
164
+ success: function(data) {
165
+
166
+ },
167
+ error: function() {
168
+ alert("An error has occured, please try again later.");
169
+ }
170
+ });
171
+ new_row.delay(400).fadeIn("slow").removeClass("new-object");
172
+ $j(".ccf-loading-icon").delay(1000).remove();
173
+ });*/
174
  });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.taylorlovett.com
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers
5
  Requires at least: 2.8.1
6
  Tested up to: 3.0.1
7
- Stable tag: 3.5.8
8
 
9
  Gauranteed to be the most customizable and intuitive contact form plugin for Wordpress.
10
 
@@ -14,12 +14,15 @@ Guaranteed to be 1000X more customizable and intuitive than Fast Secure Contact
14
 
15
  Special Features:
16
  ------------------
 
17
 
 
 
18
  * The most customizable form plugin for Wordpress, guaranteed
19
  * Create __unlimited__ forms
20
  * Create __unlimited__ fields
21
  * Required Fields (New!)
22
- * Create text fields, textareas, checkboxes, radio __(new)__ and dropdown __(new)__ fields!
23
  * Custom HTML Forms Feature - if you are a web developer you can write your own form html and __use this plugin simply to process your form requests__. Comes with a few useful features.
24
  * __Displays forms in theme files__ as well as pages and posts.
25
  * Set a different destination email address for each form
@@ -42,6 +45,7 @@ Special Features:
42
  * Manage options for your dropdowns and radio fields in an easy to use manager
43
  * Popover forms with Jquery (Coming soon!)
44
  * Free unlimited support
 
45
  * Ability to disable JQuery if it is conflicting with other plugins.
46
 
47
  == Installation ==
@@ -76,16 +80,12 @@ Visit http://www.taylorlovett.com/wordpress-plugins for screenshots. Right now a
76
 
77
  == Changelog ==
78
 
79
- = 3.5.8 =
80
- * custom-contact-forms-db.php - Table cache added and columnExists function redone to fix compadibility issues
81
-
82
- = 3.5.7 =
83
- * custom-contact-forms.php - fixed home page form redirect bug
84
- * css/custom-contact-forms-admin.css - manager tables restyled
85
-
86
- = 3.5.6 =
87
- * custom-contact-forms.php - fixed email field will set reply to on emails
88
- * custom-contact-forms-mailer.php - fixed email set as reply to on outgoing form emails
89
 
90
  = 3.5.5 =
91
  * custom-contact-forms.php - Plugin usage popover reworded
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers
5
  Requires at least: 2.8.1
6
  Tested up to: 3.0.1
7
+ Stable tag: 4.0.0.b1
8
 
9
  Gauranteed to be the most customizable and intuitive contact form plugin for Wordpress.
10
 
14
 
15
  Special Features:
16
  ------------------
17
+ Custom Contact Forms 4.0 will revolutionize the idea of a Wordpress plugin.
18
 
19
+ * __NEW!__ all form submissions saved and displayed in admin panel as well as emailed to you
20
+ * __NEW!__ import and export forms with ease!
21
  * The most customizable form plugin for Wordpress, guaranteed
22
  * Create __unlimited__ forms
23
  * Create __unlimited__ fields
24
  * Required Fields (New!)
25
+ * Create text fields, textareas, checkboxs, radio __(new)__ and dropdown __(new)__ fields!
26
  * Custom HTML Forms Feature - if you are a web developer you can write your own form html and __use this plugin simply to process your form requests__. Comes with a few useful features.
27
  * __Displays forms in theme files__ as well as pages and posts.
28
  * Set a different destination email address for each form
45
  * Manage options for your dropdowns and radio fields in an easy to use manager
46
  * Popover forms with Jquery (Coming soon!)
47
  * Free unlimited support
48
+ * AJAX enabled admin panel
49
  * Ability to disable JQuery if it is conflicting with other plugins.
50
 
51
  == Installation ==
80
 
81
  == Changelog ==
82
 
83
+ = 4.0.0 =
84
+ * custom-contact-forms.php - Saved form submissions manager, form background color added to style manager, import/export feature
85
+ * custom-contact-forms-user-data.php - Saved form submission
86
+ * custom-contact-forms-db.php - DB method reorganized for efficiency
87
+ * css/custom-contact-forms-admin.php - AJAX abilities added
88
+ * js/custom-contact-forms-admin.js - AJAX abilities added to admin panel
 
 
 
 
89
 
90
  = 3.5.5 =
91
  * custom-contact-forms.php - Plugin usage popover reworded