function processForms()
 {
     if (isset($_POST['ccf_customhtml']) || isset($_POST['customcontactforms_submit'])) {
         // BEGIN define common language vars
         $lang = array();
         $lang['field_blank'] = __('You left this field blank: ', 'custom-contact-forms');
         $lang['form_page'] = __('Form Displayed on Page: ', 'custom-contact-forms');
         $lang['sender_ip'] = __('Sender IP: ', 'custom-contact-forms');
         // END define common language vars
     }
     if (isset($_POST['ccf_customhtml'])) {
         $admin_options = parent::getAdminOptions();
         $fixed_customhtml_fields = array('required_fields', 'success_message', 'thank_you_page', 'destination_email', 'ccf_customhtml');
         $req_fields = $this->requiredFieldsArrayFromList($_POST['required_fields']);
         $req_fields = array_map('trim', $req_fields);
         $body = '';
         foreach ($_POST as $key => $value) {
             if (!in_array($key, $fixed_customhtml_fields)) {
                 if (in_array($key, $req_fields) && !empty($value)) {
                     unset($req_fields[array_search($key, $req_fields)]);
                 }
                 $body .= ucwords(str_replace('_', ' ', htmlspecialchars($key))) . ': ' . htmlspecialchars($value) . "<br /><br />\n";
                 $data_array[$key] = $value;
             }
         }
         foreach ($req_fields as $err) {
             $this->setFormError($err, $lang['field_blank'] . '"' . $err . '"');
         }
         $errors = $this->getAllFormErrors();
         if (empty($errors)) {
             ccf_utils::load_module('export/custom-contact-forms-user-data.php');
             $data_object = new CustomContactFormsUserData(array('data_array' => $data_array, 'form_page' => $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], 'form_id' => 0, 'data_time' => time()));
             parent::insertUserData($data_object);
             $body .= "<br />\n" . htmlspecialchars($lang['form_page']) . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "<br />\n" . $lang['sender_ip'] . $_SERVER['REMOTE_ADDR'] . "<br />\n";
             if ($admin_options['email_form_submissions'] == 1) {
                 if (!class_exists('PHPMailer')) {
                     require_once ABSPATH . "wp-includes/class-phpmailer.php";
                 }
                 $mail = new PHPMailer();
                 $mail->MailerDebug = false;
                 if ($admin_options['mail_function'] == 'smtp') {
                     $mail->IsSMTP();
                     $mail->Host = $admin_options['smtp_host'];
                     if ($admin_options['smtp_authentication'] == 1) {
                         $mail->SMTPAuth = true;
                         $mail->Username = $admin_options['smtp_username'];
                         $mail->Password = $admin_options['smtp_password'];
                         $mail->Port = $admin_options['smtp_port'];
                     } else {
                         $mail->SMTPAuth = false;
                     }
                 }
                 $mail->From = $admin_options['default_from_email'];
                 $mail->FromName = 'Custom Contact Forms';
                 $dest_email_array = $this->getDestinationEmailArray($_POST['destination_email']);
                 if (empty($dest_email_array)) {
                     $mail->AddAddress($admin_options['default_to_email']);
                 } else {
                     foreach ($dest_email_array as $em) {
                         $mail->AddAddress($em);
                     }
                 }
                 $mail->Subject = $admin_options['default_form_subject'];
                 $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
                 $mail->MsgHTML(stripslashes($body));
                 $mail->Send();
             }
             if ($_POST['thank_you_page']) {
                 ccf_utils::redirect($_POST['thank_you_page']);
             }
             $this->current_thank_you_message = !empty($_POST['success_message']) ? $_POST['success_message'] : $admin_options['form_success_message'];
             $this->current_form = 0;
             add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
         }
         unset($_POST);
     } elseif (isset($_POST['customcontactforms_submit'])) {
         ccf_utils::startSession();
         $this->error_return = $_POST['form_page'];
         $admin_options = parent::getAdminOptions();
         $fields = parent::getAttachedFieldsArray($_POST['fid']);
         $post_time = time();
         $form = parent::selectForm($_POST['fid']);
         $checks = array();
         $reply = isset($_POST['fixedEmail']) ? $_POST['fixedEmail'] : NULL;
         $fixed_subject = isset($_POST['emailSubject']) ? $_POST['emailSubject'] : NULL;
         $cap_name = 'ccf_captcha_' . $_POST['fid'];
         foreach ($fields as $field_id) {
             $field = parent::selectField($field_id, '');
             if ($field->field_slug == 'ishuman') {
                 if (!isset($_POST['ishuman']) || isset($_POST['ishuman']) && $_POST['ishuman'] != 1) {
                     if (empty($field->field_error)) {
                         $this->setFormError('ishuman', __('Only humans can use this form.', 'custom-contact-forms'));
                     } else {
                         $this->setFormError('ishuman', $field->field_error);
                     }
                 }
             } elseif ($field->field_slug == 'captcha') {
                 if ($_POST['captcha'] != $_SESSION[$cap_name]) {
                     if (empty($field->field_error)) {
                         $this->setFormError('captcha', __('You copied the number from the captcha field incorrectly.', 'custom-contact-forms'));
                     } else {
                         $this->setFormError('captcha', $field->field_error);
                     }
                 }
             } elseif ($field->field_slug == 'recaptcha') {
                 require_once CCF_BASE_PATH . 'modules/recaptcha/recaptchalib.php';
                 $resp = recaptcha_check_answer($admin_options['recaptcha_private_key'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
                 if (!$resp->is_valid) {
                     if (empty($field->field_error)) {
                         $this->setFormError('recaptcha', __('You copied the text from the captcha field incorrectly.', 'custom-contact-forms'));
                     } else {
                         $this->setFormError('recaptcha', $field->field_error);
                     }
                 }
             } elseif ($field->field_slug == 'fixedEmail' && $field->field_required == 1 && !empty($_POST['fixedEmail'])) {
                 if (!$this->validEmail($_POST['fixedEmail'])) {
                     if (empty($field->field_error)) {
                         $this->setFormError('fixedEmail', __('The email address you provided is not valid.', 'custom-contact-forms'));
                     } else {
                         $this->setFormError('fixedEmail', $field->field_error);
                     }
                 }
             } elseif ($field->field_slug == 'fixedWebsite' && $field->field_required == 1 && !empty($_POST['fixedWebsite'])) {
                 if (!$this->validWebsite($_POST['fixedWebsite'])) {
                     if (empty($field->field_error)) {
                         $this->setFormError('fixedWebsite', __('The website address you provided is not valid.', 'custom-contact-forms'));
                     } else {
                         $this->setFormError('fixedWebsite', $field->field_error);
                     }
                 }
             } else {
                 $field_error_label = empty($field->field_label) ? $field->field_slug : $field->field_label;
                 if ($field->field_required == 1 && $field->field_type != 'File' && !empty($_POST[$field->field_slug])) {
                     if ($field->field_type == 'Dropdown' || $field->field_type == 'Radio' || $field->field_type == 'Checkbox') {
                         // TODO: find better way to check for a dead state
                         if ($_POST[$field->field_slug] == CCF_DEAD_STATE_VALUE) {
                             if (empty($field->field_error)) {
                                 $this->setFormError($field->field_slug, $lang['field_blank'] . '"' . $field_error_label . '"');
                             } else {
                                 $this->setFormError($field->field_slug, $field->field_error);
                             }
                         }
                     }
                 } elseif ($field->field_required == 1 && $field->field_type != 'File' && empty($_POST[$field->field_slug])) {
                     if (empty($field->field_error)) {
                         $this->setFormError($field->field_slug, $lang['field_blank'] . '"' . $field_error_label . '"');
                     } else {
                         $this->setFormError($field->field_slug, $field->field_error);
                     }
                 } else {
                     // file field required and not found
                     if ($field->field_required == 1 && $field->field_type == 'File' && empty($_FILES[$field->field_slug]['name'])) {
                         if (empty($field->field_error)) {
                             $this->setFormError($field->field_slug, $lang['field_blank'] . '"' . $field_error_label . '"');
                         } else {
                             $this->setFormError($field->field_slug, $field->field_error);
                         }
                     } elseif ($field->field_type == 'File' && !empty($_FILES[$field->field_slug]['name'])) {
                         $upload_result = $this->processFileUpload($field, $post_time);
                         foreach ($upload_result as $err) {
                             $this->setFormError($field->field_slug, $err);
                         }
                     }
                 }
             }
             if ($field->field_type == 'Checkbox') {
                 $checks[] = $field->field_slug;
             }
         }
         $body = '';
         $data_array = array();
         foreach ($_POST as $key => $value) {
             $_SESSION['ccf_fields'][$key] = $value;
             //if (is_array($value)) $value = implode(', ', $value);
             $val2 = is_array($value) ? implode(', ', $value) : $value;
             $field = parent::selectField('', $key);
             if (!array_key_exists($key, $GLOBALS['ccf_fixed_fields']) || $key == 'fixedEmail' || $key == 'usaStates' || $key == 'fixedWebsite' || $key == 'emailSubject' || $key == 'allCountries') {
                 $mail_field_label = empty($field->field_label) ? $field->field_slug : $field->field_label;
                 $body .= htmlspecialchars($mail_field_label) . ' - ' . htmlspecialchars($val2) . "<br />\n";
                 $data_array[$key] = $value;
             }
             if (in_array($key, $checks)) {
                 $checks_key = array_search($key, $checks);
                 unset($checks[$checks_key]);
             }
         }
         foreach ($this->form_uploads as $name => $upload) {
             $file_url = preg_replace('/^.*(\\/custom-contact-forms\\/.*)$/i', plugins_url() . '$1', $upload);
             if (!array_key_exists($name, $GLOBALS['ccf_fixed_fields'])) {
                 $data_array[$name] = '[file link="' . $file_url . '"]' . basename($upload) . '[/file]';
             }
         }
         foreach ($checks as $check_key) {
             $field = parent::selectField('', $check_key);
             $lang['not_checked'] = __('Not Checked', 'custom-contact-forms');
             $data_array[$check_key] = $lang['not_checked'];
             $body .= ucwords(str_replace('_', ' ', htmlspecialchars($field->field_label))) . ' - ' . $lang['not_checked'] . "<br />\n";
         }
         $errors = $this->getAllFormErrors();
         if (empty($errors)) {
             ccf_utils::load_module('export/custom-contact-forms-user-data.php');
             unset($_SESSION['ccf_captcha_' . $_POST['fid']]);
             unset($_SESSION['ccf_fields']);
             $data_object = new CustomContactFormsUserData(array('data_array' => $data_array, 'form_page' => $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'], 'form_id' => $form->id, 'data_time' => $post_time));
             parent::insertUserData($data_object);
             if ($admin_options['email_form_submissions'] == '1') {
                 $body .= "<br />\n" . htmlspecialchars($lang['form_page']) . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . "<br />\n" . $lang['sender_ip'] . $_SERVER['REMOTE_ADDR'] . "<br />\n";
                 if (!class_exists('PHPMailer')) {
                     require_once ABSPATH . "wp-includes/class-phpmailer.php";
                 }
                 $mail = new PHPMailer(false);
                 $mail->MailerDebug = false;
                 if ($admin_options['mail_function'] == 'smtp') {
                     $mail->IsSMTP();
                     $mail->Host = $admin_options['smtp_host'];
                     if ($admin_options['smtp_authentication'] == 1) {
                         $mail->SMTPAuth = true;
                         $mail->Username = $admin_options['smtp_username'];
                         $mail->Password = $admin_options['smtp_password'];
                         $mail->Port = $admin_options['smtp_port'];
                     } else {
                         $mail->SMTPAuth = false;
                     }
                 }
                 $dest_email_array = $this->getDestinationEmailArray($form->form_email);
                 $from_name = empty($admin_options['default_from_name']) ? __('Custom Contact Forms', 'custom-contact-forms') : $admin_options['default_from_name'];
                 if (!empty($form->form_email_name)) {
                     $from_name = $form->form_email_name;
                 }
                 if (empty($dest_email_array)) {
                     $mail->AddAddress($admin_options['default_to_email']);
                 } else {
                     foreach ($dest_email_array as $em) {
                         $mail->AddAddress($em);
                     }
                 }
                 foreach ($this->form_uploads as $file_upload) {
                     $mail->AddAttachment($file_upload);
                 }
                 if ($reply != NULL && $this->validEmail($reply)) {
                     $mail->From = $reply;
                 } else {
                     $mail->From = $admin_options['default_from_email'];
                 }
                 $mail->FromName = $from_name;
                 $mail->Subject = !empty($form->form_email_subject) ? $form->form_email_subject : $admin_options['default_form_subject'];
                 if ($fixed_subject != NULL) {
                     $mail->Subject = $fixed_subject;
                 }
                 $mail->AltBody = __("To view the message, please use an HTML compatible email viewer.", 'custom-contact-forms');
                 $mail->CharSet = 'utf-8';
                 $mail->MsgHTML(stripslashes($body));
                 $mail->Send();
             }
             if (!empty($form->form_thank_you_page)) {
                 ccf_utils::redirect(str_replace('&amp;', '&', $form->form_thank_you_page));
             }
             $this->current_form = $form->id;
             add_action('wp_footer', array(&$this, 'insertFormSuccessCode'), 1);
         }
         unset($_POST);
         $_POST = array();
     }
 }
        function printFormSubmissionsPage()
        {
            $this->handleAdminPostRequests();
            if ($admin_options['show_install_popover'] == 1) {
                $admin_options['show_install_popover'] = 0;
                ?>
                <script type="text/javascript" language="javascript">
					$j(document).ready(function() {
						showCCFUsagePopover();
					});
				</script>
                <?php 
                update_option(parent::getAdminOptionsName(), $admin_options);
            }
            /*if ($_POST['form_submission_delete']) {
            			if (parent::deleteUserData($_POST['uid']) != false)
            				$this->action_complete = __('A form submission has be successfully deleted!', 'custom-contact-forms');
            		}*/
            ccf_utils::load_module('export/custom-contact-forms-user-data.php');
            $user_data_array = parent::selectAllUserData();
            ?>
			<div id="customcontactforms-admin">
			  <div class="plugin-header">
				<h2>
					<?php 
            _e("Custom Contact Forms", 'custom-contact-forms');
            ?>
				</h2>
             	<div class="links">
                	<a href="javascript:void(0)" class="quick-start-button">Quick Start Guide</a> - <a href="javascript:void(0)" class="usage-popover-button">Plugin Usage Manual</a>
              	</div>
              </div>
			  <a class="genesis" href="http://www.shareasale.com/r.cfm?b=241369&u=481196&m=28169&urllink=&afftrack=">Custom Contact Forms works best with any of the 20+ <span>Genesis</span> Wordpress child themes. The <span>Genesis Framework</span> empowers you to quickly and easily build incredible websites with WordPress.</a>
			
			<form class="blog-horizontal-form" method="post" action="http://www.aweber.com/scripts/addlead.pl">
            	<input type="hidden" name="meta_web_form_id" value="1578604781" />
				<input type="hidden" name="meta_split_id" value="" />
				<input type="hidden" name="listname" value="ccf-plugin" />
				<input type="hidden" name="redirect" value="http://www.taylorlovett.com/wordpress-plugins/tutorials-offers-tips/" id="redirect_5832e41084448adb07da67a35dc83c27" />
				<input type="hidden" name="meta_adtracking" value="CCF_-_Wordpress_Plugins_Horizontal" />
				<input type="hidden" name="meta_message" value="1" />
				<input type="hidden" name="meta_required" value="name,email" />
				<span>WP Blogging Tips, Downloads, SEO Tricks & Exclusive Tutorials</span>
                <input type="text" name="name" value="Your Name" onclick="value=''" />
                <input type="text" name="email" value="Your Email" onclick="value=''" />
                <input type="submit" value="Sign Up for Free" />
            </form>
			<?php 
            if (!empty($this->action_complete)) {
                ?>
			<div id="message" class="updated below-h2">
				<p><?php 
                echo $this->action_complete;
                ?>
</p>
			</div>
			<?php 
            }
            ?>
			  <h3 class="hndle"><span>
				  <?php 
            _e("Saved Form Submissions", 'custom-contact-forms');
            ?>
				  </span></h3>
			  <form class="ccf-edit-ajax" method="post" action="<?php 
            echo $_SERVER['REQUEST_URI'];
            ?>
">
			  <table class="widefat post" id="form-submissions-table" cellspacing="0">
				<thead>
				  <tr>
					<th scope="col" class="manage-column ccf-width25"><input type="checkbox" class="checkall" /></th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Date Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width150"><?php 
            _e("Form Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Form Page", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column "></th>
				  </tr>
				</thead>
				<tbody>
                  <?php 
            $i = 0;
            foreach ($user_data_array as $data_object) {
                $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));
                ?>
				  <tr class="row-form_submission-<?php 
                echo $data_object->id;
                ?>
 submission-top <?php 
                if ($i % 2 == 0) {
                    echo 'ccf-evenrow';
                }
                ?>
">
					<td><input type="checkbox" class="object-check" value="1" name="objects[<?php 
                echo $i;
                ?>
][object_do]" /></td>
					<td><?php 
                echo date('F d, Y h:i:s A', $data->getDataTime());
                ?>
</td>
					<td><?php 
                if ($data->getFormID() > 0) {
                    $data_form = parent::selectForm($data->getFormID());
                    $this_form = !empty($data_form->form_slug) ? $data_form->form_slug : '-';
                    echo $this_form;
                } else {
                    _e('Custom HTML Form', 'custom-contact-forms');
                }
                ?>
					</td>
					<td><?php 
                echo $data->getFormPage();
                ?>
 </td>
					<td class="ccf-alignright">
						<span class="submission-content-expand"></span>
						<input type="hidden" name="objects[<?php 
                echo $i;
                ?>
][object_type]" value="form_submission" />
						<input class="object-id" type="hidden" name="objects[<?php 
                echo $i;
                ?>
][object_id]" value="<?php 
                echo $data_object->id;
                ?>
" />
					 </td>
				  </tr>
				  <tr class="row-form_submission-<?php 
                echo $data_object->id;
                ?>
 submission-content <?php 
                if ($i % 2 == 0) {
                    echo 'ccf-evenrow';
                }
                ?>
">
					<td colspan="5"><ul>
						<?php 
                $data_array = $data->getDataArray();
                foreach ($data_array as $item_key => $item_value) {
                    ?>
						<li>
						  <div><?php 
                    echo $item_key;
                    ?>
</div>
						  <p><?php 
                    echo $data->parseUserData($item_value);
                    ?>
</p>
						</li>
						<?php 
                }
                ?>
					  </ul></td>
				  </tr>
				  <?php 
                $i++;
            }
            ?>
				</tbody>
				<tfoot>
				  <tr>
					<th scope="col" class="manage-column25"><input type="checkbox" class="checkall" /></th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Date Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width150"><?php 
            _e("Form Submitted", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column ccf-width250"><?php 
            _e("Form Page", 'custom-contact-forms');
            ?>
</th>
					<th scope="col" class="manage-column"></th>
				  </tr>
				</tfoot>
			  </table>
              
			  <select class="bulk-dropdown" name="object_bulk_action">
				<option value="0"><?php 
            _e('Bulk Actions', 'custom-contact-forms');
            ?>
</option>
				<option value="delete"><?php 
            _e('Delete', 'custom-contact-forms');
            ?>
</option>
			  </select> <input type="submit" class="bulk-apply" name="object_bulk_apply" value="<?php 
            _e('Apply', 'custom-contact-forms');
            ?>
" /> <img src="<?php 
            echo plugins_url();
            ?>
/custom-contact-forms/images/wpspin_light.gif" class="loading-img" width="16" height="16" />
			  
			  
			  
			  </form>
			  <?php 
            $this->insertUsagePopover();
            ?>
              <?php 
            $this->insertQuickStartPopover();
            ?>
			</div>
			<?php 
        }