prefix . "a_form_forms"; $checktable = $wpdb->query("SHOW TABLES LIKE '$a_form_forms_table'"); if ($checktable == 0) { $sql = "CREATE TABLE $a_form_forms_table ( ID mediumint(9) NOT NULL AUTO_INCREMENT, form_name VARCHAR(255) DEFAULT '', to_email VARCHAR(255) DEFAULT '', to_cc_email VARCHAR(255) DEFAULT '', to_bcc_email VARCHAR(255) DEFAULT '', subject VARCHAR(255) DEFAULT '', show_section_names tinyint(4) NOT NULL DEFAULT 1, field_name_id mediumint(9), field_email_id mediumint(9), field_subject_id mediumint(9), send_confirmation_email tinyint(4) NOT NULL DEFAULT 0, confirmation_from_email VARCHAR(255) DEFAULT '', success_message longtext DEFAULT '', success_redirect_url VARCHAR(255) DEFAULT '', include_captcha tinyint(4) NOT NULL DEFAULT 0, tracking_enabled tinyint(4) NOT NULL DEFAULT 1, created_at DATETIME, updated_at DATETIME, PRIMARY KEY (ID), UNIQUE (form_name) )"; $wpdb->query($sql); $a_form_sections_table = $wpdb->prefix . "a_form_sections"; $sql = "CREATE TABLE $a_form_sections_table ( ID mediumint(9) NOT NULL AUTO_INCREMENT, section_name VARCHAR(255) DEFAULT '', section_order mediumint(9) NOT NULL DEFAULT 0, form_id mediumint(9) NOT NULL, created_at DATETIME, updated_at DATETIME, PRIMARY KEY (ID) )"; $wpdb->query($sql); $a_form_fields_table = $wpdb->prefix . "a_form_fields"; $sql = "CREATE TABLE $a_form_fields_table ( FID mediumint(9) NOT NULL AUTO_INCREMENT, field_type VARCHAR(255) DEFAULT '', field_label VARCHAR(255) DEFAULT '', value_options longtext DEFAULT '', field_order mediumint(9) NOT NULL DEFAULT 0, validation VARCHAR(255) DEFAULT '', file_ext_allowed VARCHAR(255) DEFAULT '', form_id mediumint(9) NOT NULL, section_id mediumint(9) NOT NULL, created_at DATETIME, updated_at DATETIME, PRIMARY KEY (FID) )"; $wpdb->query($sql); $a_form_tracks_table = $wpdb->prefix . "a_form_tracks"; $sql = "CREATE TABLE $a_form_tracks_table ( ID mediumint(9) NOT NULL AUTO_INCREMENT, content longtext NOT NULL, track_type VARCHAR(255) DEFAULT '', form_id mediumint(9) NOT NULL, referrer_url VARCHAR(255) DEFAULT '', fields_array mediumtext DEFAULT '', created_at DATETIME, updated_at DATETIME, PRIMARY KEY (ID) )"; $wpdb->query($sql); } $checkcol = $wpdb->query("SHOW COLUMNS FROM '$a_form_forms_table' LIKE 'enable_ajax'"); if ($checkcol == 0) { $sql = "ALTER TABLE $a_form_forms_table ADD enable_ajax VARCHAR(1)"; $wpdb->query($sql); } $checkcol = $wpdb->query("SHOW COLUMNS FROM '$a_form_forms_table' LIKE 'include_admin_in_emails'"); if ($checkcol == 0) { $sql = "ALTER TABLE $a_form_forms_table ADD include_admin_in_emails VARCHAR(1)"; $wpdb->query($sql); } $checkcol = $wpdb->query("SHOW COLUMNS FROM '$a_form_forms_table' LIKE 'captcha_type'"); if ($checkcol == 0) { $sql = "ALTER TABLE $a_form_forms_table ADD captcha_type VARCHAR(1) DEFAULT '0'"; $wpdb->query($sql); } if (!is_dir(get_template_directory()."/aforms_css")) { aform_copy_directory(AFormsPath::normalize(dirname(__FILE__)."/css"), get_template_directory()); } else { add_option("aform_current_css_file", "default.css"); } } register_activation_hook( __FILE__, 'a_forms_activate' ); //call register settings function add_action( 'admin_init', 'register_a_forms_settings' ); function register_a_forms_settings() { if (isset($_REQUEST['tomm8te_download']) && $_REQUEST['tomm8te_download'] != "" && wp_verify_nonce($_REQUEST['_tomm8te_nonce'], "tomm8te_download_file_nonce")) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Disposition: attachment; filename=".$_GET["file"].";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($_GET["file"])); echo file_get_contents($_GET["file"]); exit; } register_setting( 'a-forms-settings-group', 'a_forms_admin_email' ); register_setting( 'a-forms-settings-group', 'a_forms_mail_host' ); register_setting( 'a-forms-settings-group', 'a_forms_smtp_auth' ); register_setting( 'a-forms-settings-group', 'a_forms_smtp_port' ); register_setting( 'a-forms-settings-group', 'a_forms_enable_tls' ); register_setting( 'a-forms-settings-group', 'a_forms_enable_ssl' ); register_setting( 'a-forms-settings-group', 'a_forms_smtp_username' ); register_setting( 'a-forms-settings-group', 'a_forms_smtp_password' ); register_setting( 'a-forms-settings-group', 'aforms_include_securimage' ); global $wpdb; $a_form_forms_table = $wpdb->prefix . "a_form_forms"; $checkcol = $wpdb->query("SHOW COLUMNS FROM '$a_form_forms_table' LIKE 'multipage_sections'"); if ($checkcol == 0) { $sql = "ALTER TABLE $a_form_forms_table ADD multipage_sections VARCHAR(1) DEFAULT 1"; $wpdb->query($sql); } } function are_a_forms_dependencies_installed() { return is_plugin_active("jquery-ui-theme/jquery-ui-theme.php"); } add_action( 'admin_notices', 'a_forms_notice_notice' ); function a_forms_notice_notice(){ $activate_nonce = wp_create_nonce( "activate-a-forms-dependencies" ); $jquery_ui_theme_active = is_plugin_active("jquery-ui-theme/jquery-ui-theme.php"); if (!($jquery_ui_theme_active)) { ?>
Before you can use A Forms, please install/activate the following plugin(s):
$_POST["send_a_form"]); echo a_form_shortcode($atts); exit; } } } add_shortcode( 'a-form', 'a_form_shortcode' ); function a_form_shortcode($atts) { $captcha_valid = true; $form_valid = false; $nonce_passed = true; $mail_message = ""; $return_content = ""; $attachment_urls = array(); $form = AFormsTomM8::get_row_by_id("a_form_forms", "*", "ID", $atts["id"]); $form_name = "a_form_".str_replace(" ", "_", strtolower($form->form_name))."_"; // Check to see if User submits a form action. if (isset($_POST["send_a_form"]) && ($atts["id"] == $_POST["send_a_form"])) { // User has submitted an aform. $form_valid = AFormValidation::is_valid($atts); // Check to see if the user has clicked the Send button and check to see if the form is using a captcha. if (isset($_POST["action"]) && $_POST["action"] == "Send" && isset($_POST[$form_name."captcha"]) && $form->include_captcha) { $captcha_valid = AFormValidation::is_valid_captcha($atts); } // Check to see if form is valid. $nonce_passed = wp_verify_nonce($_REQUEST["_wpnonce"], "a-forms-contact-a-form"); if ($nonce_passed && $form_valid && $captcha_valid) { try { $attachment_urls = AFormController::formAction($atts); } catch(Exception $e) { $form_valid = false; } // Form is valid. if (($_POST["action"]) == "Send") { $mail_message = AFormController::submitAction($atts); } } else { // Check to see if the input field values are valid, but not the wpnonce value. if ($form_valid && $captcha_valid && $nonce_passed == false) { // The input field values are valid except the wpnonce value. Therefore there must have been a cross site spam attack. So display fail send email message. $return_content .= "