public function execute()
 {
     $task = WDW_CFM_Library::get('task');
     $id = WDW_CFM_Library::get('current_id', 0);
     $message = WDW_CFM_Library::get('message');
     echo WDW_CFM_Library::message_id($message);
     if (method_exists($this, $task)) {
         check_admin_referer('nonce_cfm', 'nonce_cfm');
         $this->{$task}($id);
     } else {
         $this->display();
     }
 }
function contact_form_maker_ajax()
{
    require_once WD_CFM_DIR . '/framework/WDW_CFM_Library.php';
    $page = WDW_CFM_Library::get('action');
    if ($page != 'ContactFormmakerwdcaptcha') {
        if (function_exists('current_user_can')) {
            if (!current_user_can('manage_options')) {
                die('Access Denied');
            }
        } else {
            die('Access Denied');
        }
    }
    if ($page != '') {
        require_once WD_CFM_DIR . '/admin/controllers/CFMController' . ucfirst($page) . '.php';
        $controller_class = 'CFMController' . ucfirst($page);
        $controller = new $controller_class();
        $controller->execute();
    }
}
 public function delete_all()
 {
     global $wpdb;
     $flag = FALSE;
     $isDefault = FALSE;
     $form_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'contactformmaker');
     foreach ($form_ids_col as $form_id) {
         if (isset($_POST['check_' . $form_id])) {
             $flag = TRUE;
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'contactformmaker WHERE id="%d"', $form_id));
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'contactformmaker_views WHERE form_id="%d"', $form_id));
             $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'contactformmaker_submits WHERE form_id="%d"', $form_id));
         }
     }
     if ($flag) {
         $message = 5;
     } else {
         $message = 6;
     }
     $page = WDW_CFM_Library::get('page');
     WDW_CFM_Library::spider_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
 }
    public function form_options($id)
    {
        $row = $this->model->get_row_data($id);
        $themes = $this->model->get_theme_rows_data();
        $page_title = $row->title . __(' form options', 'contact_form_maker');
        $label_id = array();
        $label_label = array();
        $label_type = array();
        $label_all = explode('#****#', $row->label_order_current);
        $label_all = array_slice($label_all, 0, count($label_all) - 1);
        foreach ($label_all as $key => $label_each) {
            $label_id_each = explode('#**id**#', $label_each);
            if ($label_id_each[0] == 22) {
                $default_subject = $key;
            }
            array_push($label_id, $label_id_each[0]);
            $label_order_each = explode('#**label**#', $label_id_each[1]);
            array_push($label_label, $label_order_each[0]);
            array_push($label_type, $label_order_each[1]);
        }
        $fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
        $fields_count = count($fields);
        $disabled_fields = explode(',', $row->disabled_fields);
        $disabled_fields = array_slice($disabled_fields, 0, count($disabled_fields) - 1);
        $field_exist = array();
        for ($i = 0; $i < count($label_label); $i++) {
            if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_send_copy" || in_array($label_id[$i], $disabled_fields)) {
                $field_exist[$i] = FALSE;
            } else {
                $field_exist[$i] = TRUE;
            }
        }
        ?>
    <script>
      gen = "<?php 
        echo $row->counter;
        ?>
";
      form_view_max = 20;
      function set_preview() {
        jQuery("#preview_form").attr("href", '<?php 
        echo add_query_arg(array('action' => 'ContactFormMakerPreview', 'form_id' => $row->id), admin_url('admin-ajax.php'));
        ?>
&test_theme=' + jQuery("#theme").val() + '&width=1000&height=500&TB_iframe=1');
        jQuery("#edit_css").attr("href", '<?php 
        echo add_query_arg(array('action' => 'ContactFormMakerEditCSS', 'form_id' => $row->id), admin_url('admin-ajax.php'));
        ?>
&id=' + jQuery("#theme").val() + '&width=800&height=500&TB_iframe=1');
      }
    </script>
    <div style="font-size: 14px; font-weight: bold;">
      <?php 
        echo __("This section allows you to edit form options", "contact_form_maker");
        ?>
.
      <a style="color: blue; text-decoration: none;" target="_blank" href="http://web-dorado.com/wordpress-contact-form-builder-guide-3.html"><?php 
        echo __("Read More in User Manual", "contact_form_maker");
        ?>
</a>
    </div>
    <form class="wrap" method="post" action="admin.php?page=manage_cfm" style="width: 99%;" name="adminForm" id="adminForm">
      <?php 
        wp_nonce_field('nonce_cfm', 'nonce_cfm');
        ?>
      <h2><?php 
        echo $page_title;
        ?>
</h2>
      <div style="float: right; margin: 0 5px 0 0;">
        <input class="button-secondary" type="submit" onclick="if (spider_check_email('mailToAdd') ||
                                                                   spider_check_email('mail_from_other') ||
                                                                   spider_check_email('reply_to_other') ||
                                                                   spider_check_email('mail_cc') ||
                                                                   spider_check_email('mail_bcc') ||
                                                                   spider_check_email('mail_from_user') ||
                                                                   spider_check_email('reply_to_user') ||
                                                                   spider_check_email('mail_cc_user') ||
                                                                   spider_check_email('mail_bcc_user') ||
                                                                   spider_check_email('mail_from') ||
                                                                   spider_check_email('reply_to')) { return false; }; spider_set_input_value('task', 'save_options')" value="<?php 
        echo __("Save", "contact_form_maker");
        ?>
"/>
        <input class="button-secondary" type="submit" onclick="if (spider_check_email('mailToAdd') ||
                                                                   spider_check_email('mail_from_other') ||
                                                                   spider_check_email('reply_to_other') ||
                                                                   spider_check_email('mail_cc') ||
                                                                   spider_check_email('mail_bcc') ||
                                                                   spider_check_email('mail_from_user') ||
                                                                   spider_check_email('reply_to_user') ||
                                                                   spider_check_email('mail_cc_user') ||
                                                                   spider_check_email('mail_bcc_user') ||
                                                                   spider_check_email('mail_from') ||
                                                                   spider_check_email('reply_to')) { return false; }; spider_set_input_value('task', 'apply_options')" value="<?php 
        echo __("Apply", "contact_form_maker");
        ?>
"/>
        <input class="button-secondary" type="submit" onclick="spider_set_input_value('task', 'cancel_options')" value="<?php 
        echo __("Cancel", "contact_form_maker");
        ?>
"/>
      </div>
      <div class="submenu-box" style="width: 99%; float: left; margin: 15px 0 0 0;">
        <div class="submenu-pad">
          <ul id="submenu" class="configuration">
            <li>
              <a id="general" class="fm_fieldset_tab" onclick="form_maker_options_tabs('general')" href="#"><?php 
        echo __("General Options", "contact_form_maker");
        ?>
</a>
            </li>
            <li>
              <a id="custom" class="fm_fieldset_tab" onclick="form_maker_options_tabs('custom')" href="#"><?php 
        echo __("Email Options", "contact_form_maker");
        ?>
</a>
            </li>
            <li>
              <a id="actions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('actions')" href="#"><?php 
        echo __("Actions after Submission", "contact_form_maker");
        ?>
</a>
            </li>
          </ul>
        </div>
      </div>
      <fieldset id="general_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color: #0B55C4; font-weight: bold;"><?php 
        echo __("General Options", "contact_form_maker");
        ?>
</legend>
        <table class="admintable" style="float: left;">
          <tr valign="top">
            <td class="fm_options_label">
              <label><?php 
        echo __("Published", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <input type="radio" name="published" id="published_yes" value="1" <?php 
        echo $row->published ? 'checked="checked"' : '';
        ?>
 /><label for="published_yes"><?php 
        echo __("Yes", "contact_form_maker");
        ?>
</label>
              <input type="radio" name="published" id="published_no" value="0" <?php 
        echo !$row->published ? 'checked="checked"' : '';
        ?>
 /><label for="published_no"><?php 
        echo __("No", "contact_form_maker");
        ?>
</label>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label><?php 
        echo __("Save data(to database)", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <input type="radio" name="savedb" id="savedb_yes" value="1" <?php 
        echo $row->savedb ? 'checked="checked"' : '';
        ?>
 /><label for="savedb_yes"><?php 
        echo __("Yes", "contact_form_maker");
        ?>
</label>
              <input type="radio" name="savedb" id="savedb_no" value="0" <?php 
        echo !$row->savedb ? 'checked="checked"' : '';
        ?>
 /><label for="savedb_no"><?php 
        echo __("No", "contact_form_maker");
        ?>
</label>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="theme"><?php 
        echo __("Theme", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <select id="theme" name="theme" style="width:260px;" onChange="set_preview()">
                <?php 
        foreach ($themes as $theme) {
            ?>
                  <option value="<?php 
            echo $theme->id;
            ?>
" <?php 
            echo $theme->id == $row->theme ? 'selected="selected"' : '';
            ?>
 <?php 
            echo $theme->id != 4 ? 'disabled="disabled" title="This theme is disabled in free version."' : '';
            ?>
><?php 
            echo $theme->title;
            ?>
</option>
                  <?php 
        }
        ?>
              </select>
              <a href="<?php 
        echo add_query_arg(array('action' => 'ContactFormMakerPreview', 'form_id' => $row->id, 'test_theme' => $row->theme, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php'));
        ?>
" class="button-primary thickbox thickbox-preview" id="preview_form" title="<?php 
        echo __("Form Preview", "contact_form_maker");
        ?>
" onclick="return false;">
                <?php 
        echo __("Preview", "contact_form_maker");
        ?>
              </a>
              <a onclick="alert('<?php 
        echo addslashes(__("This option is disabled in free version.", "contact_form_maker"));
        ?>
'); return false;" href="#" class="button-secondary" id="edit_css" title="Edit CSS">
                <?php 
        echo __("Edit CSS", "contact_form_maker");
        ?>
              </a>
              <div class="spider_description spider_free_desc"><?php 
        echo __("Themes are disabled in free version.", "contact_form_maker");
        ?>
</div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="requiredmark"><?php 
        echo __("Required fields mark", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <input type="text" id="requiredmark" name="requiredmark" value="<?php 
        echo $row->requiredmark;
        ?>
" style="width: 250px;" />
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="custom_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color: #0B55C4; font-weight: bold;"><?php 
        echo __("Email Options", "contact_form_maker");
        ?>
</legend>
        <table class="admintable">
          <tr valign="top">
            <td style="padding: 15px;">
              <label><?php 
        echo __("Send E-mail", "contact_form_maker");
        ?>
</label>
            </td>
            <td style="padding: 15px;">
              <input type="radio" name="sendemail" id="sendemail_yes" value="1" <?php 
        echo $row->sendemail ? 'checked="checked"' : '';
        ?>
 /><label for="sendemail_yes"><?php 
        echo __("Yes", "contact_form_maker");
        ?>
</label>
              <input type="radio" name="sendemail" id="sendemail_no" value="0" <?php 
        echo !$row->sendemail ? 'checked="checked"' : '';
        ?>
 /><label for="sendemail_no"><?php 
        echo __("No", "contact_form_maker");
        ?>
</label>
            </td>
          </tr>
          <tr>
            <td style="padding: 15px;">
              <label><?php 
        echo __("Mailer", "contact_form_maker");
        ?>
</label>
            </td>
            <td style="padding: 15px;">
              <input type="radio" name="wpmail" id="wpmail_yes" value="1" <?php 
        echo $row->wpmail ? 'checked="checked"' : '';
        ?>
 /><label for="wpmail_yes">wp_mail() <?php 
        echo __('function', 'contact_form_maker');
        ?>
</label>
              <input type="radio" name="wpmail" id="wpmail_no" value="0" <?php 
        echo !$row->wpmail ? 'checked="checked"' : '';
        ?>
 /><label for="wpmail_no">PHP mail() <?php 
        echo __('function', 'contact_form_maker');
        ?>
</label>
            </td>
          </tr>
        </table>
        <fieldset class="fm_mail_options">
          <legend style="color: #0B55C4; font-weight: bold;"><?php 
        echo __("Email to Administrator", "contact_form_maker");
        ?>
</legend>
          <table class="admintable">
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mailToAdd"><?php 
        echo __("Email to send submissions to", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mailToAdd" name="mailToAdd" style="width: 250px;" />
                <input type="hidden" id="mail" name="mail" value="<?php 
        echo $row->mail;
        ?>
" />
                <img src="<?php 
        echo WD_CFM_URL . '/images/add.png';
        ?>
"
                     style="vertical-align: middle; cursor: pointer;"
                     title="<?php 
        echo __("Add more emails", "contact_form_maker");
        ?>
"
                     onclick="if (spider_check_email('mailToAdd')) {return false;};cfm_create_input('mail', 'mailToAdd', 'cfm_mail_div', '<?php 
        echo WD_CFM_URL;
        ?>
')" />
                <div id="cfm_mail_div">
                  <?php 
        $mail_array = explode(',', $row->mail);
        foreach ($mail_array as $mail) {
            if ($mail && $mail != ',') {
                ?>
                      <div class="fm_mail_input">
                        <?php 
                echo $mail;
                ?>
                        <img src="<?php 
                echo WD_CFM_URL;
                ?>
/images/delete.png" class="fm_delete_img" onclick="fm_delete_mail(this, '<?php 
                echo $mail;
                ?>
')" title="<?php 
                echo __("Delete Email", "contact_form_maker");
                ?>
" />
                      </div>
                      <?php 
            }
        }
        ?>
                </div>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from"><?php 
        echo __("Email From", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <?php 
        $is_other = TRUE;
        $field_disabled = TRUE;
        for ($i = 0; $i < $fields_count - 1; $i++) {
            $field_id = substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i]));
            if (!in_array($field_id, $disabled_fields)) {
                $field_disabled = FALSE;
                ?>
                  <div>
                    <input type="radio" name="mail_from" id="mail_from<?php 
                echo $i;
                ?>
" value="<?php 
                echo $field_id;
                ?>
"  <?php 
                echo $field_id == $row->mail_from ? 'checked="checked"' : '';
                ?>
 onclick="wdhide('mail_from_other')" />
                    <label for="mail_from<?php 
                echo $i;
                ?>
"><?php 
                echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
                ?>
</label>
                  </div>
                    <?php 
                if ($field_id == $row->mail_from) {
                    $is_other = FALSE;
                }
            }
        }
        ?>
                <div style="<?php 
        echo $fields_count == 1 || $field_disabled ? 'display:none;' : '';
        ?>
">
                  <input type="radio" id="other" name="mail_from" value="other" <?php 
        echo $is_other ? 'checked="checked"' : '';
        ?>
 onclick="wdshow('mail_from_other')" />
                  <label for="other">Other</label>
                </div>
								<input type="text" style="width: <?php 
        echo $fields_count == 1 || $field_disabled ? '250px' : '235px; margin-left: 15px';
        ?>
; display: <?php 
        echo $is_other ? 'block;' : 'none;';
        ?>
" id="mail_from_other" name="mail_from_other" value="<?php 
        echo $is_other && !$field_disabled ? $row->mail_from : '';
        ?>
" />
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from_name"><?php 
        echo __("From Name", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mail_from_name" name="mail_from_name" value="<?php 
        echo $row->mail_from_name;
        ?>
" style="width: 250px;" />
                <img src="<?php 
        echo WD_CFM_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_from_labels').style.display='block';" style="vertical-align: middle; display:inline-block; margin:0px; float:none; cursor: pointer;" />
								<div style="position: relative; top: -3px;">
                  <div id="mail_from_labels" class="email_labels" style="display: none;">
                    <?php 
        $choise = "document.getElementById('mail_from_name')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = htmlspecialchars($label_label[$i]);
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap($fld_label, 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            ?>
                      <a onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
,'<?php 
            echo $param;
            ?>
'); document.getElementById('mail_from_labels').style.display='none';" style="display: block; text-decoration:none;"><?php 
            echo $fld_label;
            ?>
</a>
                      <?php 
        }
        ?>
                  </div>
                </div>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="reply_to"><?php 
        echo __("Reply to", "contact_form_maker");
        ?>
<br/>(<?php 
        echo __("if different from 'Email From'", "contact_form_maker");
        ?>
) </label>
              </td>
              <td class="fm_options_value">
                <?php 
        $is_other = TRUE;
        $field_disabled = TRUE;
        for ($i = 0; $i < $fields_count - 1; $i++) {
            $field_id = substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i]));
            if (!in_array($field_id, $disabled_fields)) {
                $field_disabled = FALSE;
                ?>
                  <div>
                    <input type="radio" name="reply_to" id="reply_to<?php 
                echo $i;
                ?>
" value="<?php 
                echo $field_id;
                ?>
"  <?php 
                echo $field_id == $row->reply_to ? 'checked="checked"' : '';
                ?>
 onclick="wdhide('reply_to_other')" />
                    <label for="reply_to<?php 
                echo $i;
                ?>
"><?php 
                echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
                ?>
</label>
                  </div>
                  <?php 
                if ($field_id == $row->reply_to) {
                    $is_other = FALSE;
                }
            }
        }
        ?>
								<div style="<?php 
        echo $fields_count == 1 || $field_disabled ? 'display: none;' : '';
        ?>
">
                  <input type="radio" id="other1" name="reply_to" value="other" <?php 
        echo $is_other ? 'checked="checked"' : '';
        ?>
 onclick="wdshow('reply_to_other')" />
                  <label for="other1"><?php 
        echo __("Other", "contact_form_maker");
        ?>
</label>
                </div>
								<input type="text" style="width: <?php 
        echo $fields_count == 1 || $field_disabled ? '250px' : '235px; margin-left: 15px';
        ?>
; display: <?php 
        echo $is_other ? 'block;' : 'none;';
        ?>
" id="reply_to_other" name="reply_to_other" value="<?php 
        echo $is_other && $row->reply_to && !$field_disabled ? $row->reply_to : '';
        ?>
" />
              </td>
            </tr>
            <tr valign="top">
							<td class="fm_options_label">
								<label for="mail_cc">CC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_cc" name="mail_cc" value="<?php 
        echo $row->mail_cc;
        ?>
" style="width: 250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="mail_bcc">BCC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_bcc" name="mail_bcc" value="<?php 
        echo $row->mail_bcc;
        ?>
" style="width: 250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="mail_subject"><?php 
        echo __("Subject", "contact_form_maker");
        ?>
: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_subject" name="mail_subject" value="<?php 
        echo $row->mail_subject == '' && !in_array($label_id[$default_subject], $disabled_fields) ? '%' . $label_label[$default_subject] . '%' : $row->mail_subject;
        ?>
" style="width: 250px;" />
								<img src="<?php 
        echo WD_CFM_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_subject_labels').style.display='block';" style="vertical-align: middle; display:inline-block; margin:0px; float:none; cursor: pointer;" />
								<div style="position: relative; top: -3px;">
                  <div id="mail_subject_labels" class="email_labels" style="display: none;" >
                    <?php 
        $choise = "document.getElementById('mail_subject')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = htmlspecialchars($label_label[$i]);
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap($fld_label, 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            ?>
                      <a onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
,'<?php 
            echo $param;
            ?>
'); document.getElementById('mail_subject_labels').style.display='none';" style="display: block; text-decoration: none;"><?php 
            echo $fld_label;
            ?>
</a>
                      <?php 
        }
        ?>
                  </div>
                </div>
							</td>
						</tr>
						<tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label><?php 
        echo __("Mode", "contact_form_maker");
        ?>
: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" name="mail_mode" id="htmlmode" value="1" <?php 
        if ($row->mail_mode == 1) {
            echo 'checked="checked"';
        }
        ?>
 /><label for="htmlmode">HTML</label>
                <input type="radio" name="mail_mode" id="textmode" value="0" <?php 
        if ($row->mail_mode == 0) {
            echo 'checked="checked"';
        }
        ?>
 /><label for="textmode"><?php 
        echo __("Text", "contact_form_maker");
        ?>
</label>
              </td>
            </tr>
            <tr>
              <td class="fm_options_label" valign="top">
                <label><?php 
        echo __("Custom Text in Email For Administrator", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <div style="margin-bottom:5px">
                  <?php 
        $choise = "document.getElementById('script_mail')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            ?>
                    <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php 
            echo htmlspecialchars($label_label[$i]);
            ?>
" onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
, '<?php 
            echo $param;
            ?>
')" />
                    <?php 
        }
        ?>
                  <input style="border: 1px solid silver; font-size: 11px; font-weight: bold; display: block;" type="button" value="<?php 
        echo __("All fields list", "contact_form_maker");
        ?>
" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
, 'all')" />
                </div>
                <?php 
        if (user_can_richedit()) {
            wp_editor($row->script_mail, 'script_mail', array('teeny' => FALSE, 'textarea_name' => 'script_mail', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                  <textarea name="script_mail" id="script_mail" cols="20" rows="10" style="width: 300px; height: 450px;"><?php 
            echo $row->script_mail;
            ?>
</textarea>
                  <?php 
        }
        ?>
              </td>
            </tr>
          </table>
        </fieldset>
        <fieldset class="fm_mail_options">
          <legend style="color: #0B55C4; font-weight: bold;"><?php 
        echo __("Email to User", "contact_form_maker");
        ?>
</legend>
          <table class="admintable">
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail"><?php 
        echo __("Send to", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <?php 
        $fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
        $fields_count = count($fields);
        if ($fields_count == 1) {
            echo __("There is no email field", "contact_form_maker");
        } else {
            for ($i = 0; $i < $fields_count - 1; $i++) {
                ?>
                    <div>
                      <input type="checkbox" name="send_to<?php 
                echo $i;
                ?>
" id="send_to<?php 
                echo $i;
                ?>
" value="<?php 
                echo substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i]));
                ?>
"  <?php 
                echo is_numeric(strpos($row->send_to, '*' . substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) . '*')) ? 'checked="checked"' : '';
                ?>
 />
                      <label for="send_to<?php 
                echo $i;
                ?>
"><?php 
                echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*'));
                ?>
</label>
                    </div>
                    <?php 
            }
        }
        ?>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from_user"><?php 
        echo __("Email From", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mail_from_user" name="mail_from_user" value="<?php 
        echo $row->mail_from_user;
        ?>
" style="width: 250px;" />
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="mail_from_name_user"><?php 
        echo __("From Name", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="mail_from_name_user" name="mail_from_name_user" value="<?php 
        echo $row->mail_from_name_user;
        ?>
" style="width: 250px;"/>
                <img src="<?php 
        echo WD_CFM_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_from_name_user_labels').style.display='block';" style="vertical-align: middle; display: inline-block; margin: 0px; float: none; cursor: pointer;" />
                <div style="position: relative; top: -3px;">
                  <div id="mail_from_name_user_labels" class="email_labels" style="display:none;">
                    <?php 
        $choise = "document.getElementById('mail_from_name_user')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = htmlspecialchars($label_label[$i]);
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap($fld_label, 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            ?>
                      <a onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
,'<?php 
            echo $param;
            ?>
'); document.getElementById('mail_from_name_user_labels').style.display='none';" style="display: block; text-decoration: none;"><?php 
            echo $fld_label;
            ?>
</a>
                      <?php 
        }
        ?>
                  </div>
                </div>
              </td>
            </tr>
            <tr valign="top">
              <td class="fm_options_label">
                <label for="reply_to_user"><?php 
        echo __("Reply to", "contact_form_maker");
        ?>
<br />(<?php 
        echo __("if different from 'Email From'", "contact_form_maker");
        ?>
)</label>
              </td>
              <td class="fm_options_value">
                <input type="text" id="reply_to_user" name="reply_to_user" value="<?php 
        echo $row->reply_to_user;
        ?>
" style="width: 250px;" />
              </td>
            </tr>
            <tr valign="top">
							<td class="fm_options_label">
								<label for="mail_cc_user">CC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_cc_user" name="mail_cc_user" value="<?php 
        echo $row->mail_cc_user;
        ?>
" style="width: 250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="mail_bcc_user">BCC: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_bcc_user" name="mail_bcc_user" value="<?php 
        echo $row->mail_bcc_user;
        ?>
" style="width: 250px;" />
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="mail_subject_user"><?php 
        echo __("Subject", "contact_form_maker");
        ?>
: </label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="mail_subject_user" name="mail_subject_user" value="<?php 
        echo $row->mail_subject_user == '' && !in_array($label_id[$default_subject], $disabled_fields) ? '%' . $label_label[$default_subject] . '%' : $row->mail_subject_user;
        ?>
" style="width: 250px;" />
								<img src="<?php 
        echo WD_CFM_URL . '/images/add.png';
        ?>
" onclick="document.getElementById('mail_subject_user_labels').style.display='block';" style="vertical-align: middle; display: inline-block; margin: 0px; float: none; cursor: pointer;" />
								<div style="position: relative; top: -3px;">
                  <div id="mail_subject_user_labels" class="email_labels" style="display: none;">
                  <?php 
        $choise = "document.getElementById('mail_subject_user')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            $fld_label = htmlspecialchars($label_label[$i]);
            if (strlen($fld_label) > 30) {
                $fld_label = wordwrap($fld_label, 30);
                $fld_label = explode("\n", $fld_label);
                $fld_label = $fld_label[0] . ' ...';
            }
            ?>
                    <a onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
,'<?php 
            echo $param;
            ?>
'); document.getElementById('mail_subject_user_labels').style.display='none';" style="display: block; text-decoration: none;"><?php 
            echo $fld_label;
            ?>
</a>
                    <?php 
        }
        ?>
                  </div>
                </div>
							</td>
						</tr>
						<tr valign="top">
              <td class="fm_options_label" style="vertical-align: middle;">
                <label><?php 
        echo __("Mode", "contact_form_maker");
        ?>
: </label>
              </td>
              <td class="fm_options_value">
                <input type="radio" name="mail_mode_user" id="htmlmode_user" value="1" <?php 
        if ($row->mail_mode_user == 1) {
            echo 'checked="checked"';
        }
        ?>
 /><label for="htmlmode_user">HTML</label>
                <input type="radio" name="mail_mode_user" id="textmode_user" value="0" <?php 
        if ($row->mail_mode_user == 0) {
            echo 'checked="checked"';
        }
        ?>
 /><label for="textmode_user"><?php 
        echo __("Text", "contact_form_maker");
        ?>
</label>
              </td>
            </tr>
            <tr>
              <td class="fm_options_label" valign="top">
                <label><?php 
        echo __("Custom Text in Email For User", "contact_form_maker");
        ?>
</label>
              </td>
              <td class="fm_options_value">
                <div style="margin-bottom:5px">
                  <?php 
        $choise = "document.getElementById('script_mail_user')";
        for ($i = 0; $i < count($label_label); $i++) {
            if (!$field_exist[$i]) {
                continue;
            }
            $param = htmlspecialchars(addslashes($label_label[$i]));
            ?>
                    <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php 
            echo htmlspecialchars($label_label[$i]);
            ?>
" onClick="insertAtCursor(<?php 
            echo $choise;
            ?>
, '<?php 
            echo $param;
            ?>
')" />
                    <?php 
        }
        ?>
                  <input style="border: 1px solid silver; font-size: 11px; font-weight: bold; display: block;" type="button" value="All fields list" onClick="insertAtCursor(<?php 
        echo $choise;
        ?>
, 'all')" />
                </div>
                <?php 
        if (user_can_richedit()) {
            wp_editor($row->script_mail_user, 'script_mail_user', array('teeny' => FALSE, 'textarea_name' => 'script_mail_user', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                  <textarea name="script_mail_user" id="script_mail_user" cols="20" rows="10" style="width: 300px; height: 450px;"><?php 
            echo $row->script_mail_user;
            ?>
</textarea>
                  <?php 
        }
        ?>
              </td>
            </tr>
          </table>
        </fieldset>
      </fieldset>
      <fieldset id="actions_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color: #0B55C4; font-weight: bold;"><?php 
        echo __("Actions after submission", "contact_form_maker");
        ?>
</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label><?php 
        echo __("Action type", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <div><input type="radio" name="submit_text_type" id="text_type_none" onclick="set_type('none')" value="1" <?php 
        echo $row->submit_text_type != 2 && $row->submit_text_type != 3 && $row->submit_text_type != 4 && $row->submit_text_type != 5 ? "checked" : "";
        ?>
 /><label for="text_type_none"><?php 
        echo __("Stay on Form", "contact_form_maker");
        ?>
</label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_post" onclick="set_type('post')" value="2" <?php 
        echo $row->submit_text_type == 2 ? "checked" : "";
        ?>
 /><label for="text_type_post"><?php 
        echo __("Post", "contact_form_maker");
        ?>
</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_page" onclick="set_type('page')" value="5" <?php 
        echo $row->submit_text_type == 5 ? "checked" : "";
        ?>
 /><label for="text_type_page"><?php 
        echo __("Page", "contact_form_maker");
        ?>
</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_custom_text" onclick="set_type('custom_text')" value="3" <?php 
        echo $row->submit_text_type == 3 ? "checked" : "";
        ?>
 /><label for="text_type_custom_text"><?php 
        echo __("Custom Text", "contact_form_maker");
        ?>
</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_url" onclick="set_type('url')" value="4" <?php 
        echo $row->submit_text_type == 4 ? "checked" : "";
        ?>
 /><label for="text_type_url">URL</div>
            </td>
          </tr>
          <tr id="none" <?php 
        echo $row->submit_text_type == 2 || $row->submit_text_type == 3 || $row->submit_text_type == 4 || $row->submit_text_type == 5 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label><?php 
        echo __("Stay on Form", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <img src="<?php 
        echo WD_CFM_URL . '/images/tick.png';
        ?>
" border="0">
            </td>
          </tr>
          <tr id="post" <?php 
        echo $row->submit_text_type != 2 ? 'style="display: none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="post_name"><?php 
        echo __("Post", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <select id="post_name" name="post_name" style="width: 153px; font-size: 11px;">
                <option value="0">- <?php 
        echo __("Select Post", "contact_form_maker");
        ?>
 -</option>
                <?php 
        // The Query.
        $args = array('posts_per_page' => 10000);
        query_posts($args);
        // The Loop.
        while (have_posts()) {
            the_post();
            ?>
                <option value="<?php 
            $x = get_permalink(get_the_ID());
            echo $x;
            ?>
" <?php 
            echo $row->article_id == $x ? 'selected="selected"' : '';
            ?>
><?php 
            the_title();
            ?>
</option>
                <?php 
        }
        // Reset Query.
        wp_reset_query();
        ?>
              </select>
            </td>
          </tr>
          <tr id="page" <?php 
        echo $row->submit_text_type != 5 ? 'style="display: none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="page_name"><?php 
        echo __("Page", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <select id="page_name" name="page_name" style="width: 153px; font-size: 11px;">
                <option value="0">- <?php 
        echo __("Select Page", "contact_form_maker");
        ?>
 -</option>
                <?php 
        // The Query.
        $pages = get_pages();
        // The Loop.
        foreach ($pages as $page) {
            $page_id = get_page_link($page->ID);
            ?>
                <option value="<?php 
            echo $page_id;
            ?>
" <?php 
            echo $row->article_id == $page_id ? 'selected="selected"' : '';
            ?>
><?php 
            echo $page->post_title;
            ?>
</option>
                  <?php 
        }
        // Reset Query.
        wp_reset_query();
        ?>
              </select>
            </td>
          </tr>
          <tr id="custom_text" <?php 
        echo $row->submit_text_type != 3 ? 'style="display: none;"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="submit_text"><?php 
        echo __("Text", "contact_form_maker");
        ?>
</label>
            </td>
            <td class="fm_options_value">
              <?php 
        if (user_can_richedit()) {
            wp_editor($row->submit_text, 'submit_text', array('teeny' => FALSE, 'textarea_name' => 'submit_text', 'media_buttons' => FALSE, 'textarea_rows' => 5));
        } else {
            ?>
                <textarea cols="36" rows="5" id="submit_text" name="submit_text" style="resize: vertical;">
                  <?php 
            echo $row->submit_text;
            ?>
                </textarea>
                <?php 
        }
        ?>
            </td>
          </tr>
          <tr id="url" <?php 
        echo $row->submit_text_type != 4 ? 'style="display:none"' : '';
        ?>
>
            <td class="fm_options_label">
              <label for="url">URL</label>
            </td>
            <td class="fm_options_value">
              <input type="text" id="url" name="url" style="width:300px" value="<?php 
        echo $row->url;
        ?>
" />
            </td>
          </tr>
        </table>
      </fieldset>

      <input type="hidden" name="fieldset_id" id="fieldset_id" value="<?php 
        echo WDW_CFM_Library::get('fieldset_id', 'general');
        ?>
" />
      <input type="hidden" id="task" name="task" value=""/>
      <input type="hidden" id="current_id" name="current_id" value="<?php 
        echo $row->id;
        ?>
" />
    </form>
    <script>
      jQuery(window).load(function () {
        form_maker_options_tabs(jQuery("#fieldset_id").val());
        spider_popup();
        jQuery("#mail_from_labels, #mail_from_name_user_labels, #mail_subject_labels, #mail_subject_user_labels").mouseleave(function() {
          jQuery(this).hide();
        });
      });
    </script>
    <?php 
    }