public function ajax_refresh_captcha()
 {
     $length = 5;
     $charset = 'abcdefghijklmnpqrstuvwxyz123456789';
     $phrase = '';
     $chars = str_split($charset);
     for ($i = 0; $i < $length; $i++) {
         $phrase .= $chars[array_rand($chars)];
     }
     $resp = $resp2 = array();
     $resp['txt_color_st'] = isset($_POST['txt_color_st']) ? Uiform_Form_Helper::sanitizeInput($_POST['txt_color_st']) : '';
     $resp['txt_color'] = isset($_POST['txt_color']) ? Uiform_Form_Helper::sanitizeInput($_POST['txt_color']) : '';
     $resp['background_st'] = isset($_POST['background_st']) ? Uiform_Form_Helper::sanitizeInput($_POST['background_st']) : '';
     $resp['background_color'] = isset($_POST['txt_color_st']) ? Uiform_Form_Helper::sanitizeInput($_POST['background_color']) : '';
     $resp['distortion'] = isset($_POST['distortion']) ? Uiform_Form_Helper::sanitizeInput($_POST['distortion']) : '';
     $resp['behind_lines_st'] = isset($_POST['behind_lines_st']) ? Uiform_Form_Helper::sanitizeInput($_POST['behind_lines_st']) : '';
     $resp['behind_lines'] = isset($_POST['behind_lines']) ? Uiform_Form_Helper::sanitizeInput($_POST['behind_lines']) : '';
     $resp['front_lines_st'] = isset($_POST['front_lines_st']) ? Uiform_Form_Helper::sanitizeInput($_POST['front_lines_st']) : '';
     $resp['front_lines'] = isset($_POST['front_lines']) ? Uiform_Form_Helper::sanitizeInput($_POST['front_lines']) : '';
     $resp['ca_txt_gen'] = $phrase;
     $captcha_options = Uiform_Form_Helper::base64url_encode(json_encode($resp));
     $resp2 = array();
     $resp2['rkver'] = $captcha_options;
     //return data to ajax callback
     header('Content-Type: application/json');
     echo json_encode($resp2);
     wp_die();
 }
 public function ajax_save_options()
 {
     $opt_language = isset($_POST['language']) && $_POST['language'] ? Uiform_Form_Helper::sanitizeInput($_POST['language']) : '';
     $data = array();
     $data['language'] = $opt_language;
     $where = array('id' => 1);
     $result = $this->wpdb->update($this->model_settings->table, $data, $where);
     $json = array();
     if ($result > 0) {
         $json['success'] = 1;
     } else {
         $json['success'] = 0;
     }
     header('Content-Type: application/json');
     echo json_encode($json);
     wp_die();
 }
 /**
  * Sanitize recursive
  * 
  * @param string $data array
  * 
  * @return array
  */
 public static function sanitizeRecursive($data)
 {
     if (is_array($data)) {
         return array_map(array('Uiform_Form_Helper', 'sanitizeRecursive'), $data);
     } else {
         return Uiform_Form_Helper::sanitizeInput($data);
     }
 }
 public function list_records()
 {
     require_once UIFORM_FORMS_DIR . '/classes/Pagination.php';
     $this->pagination = new CI_Pagination();
     $offset = isset($_GET['offset']) && $_GET['offset'] ? Uiform_Form_Helper::sanitizeInput($_GET['offset']) : 0;
     //list all forms
     $data = $config = array();
     $config['base_url'] = admin_url() . '?page=uiform_form_builder&mod=formbuilder&controller=records&action=list_records';
     $config['total_rows'] = $this->model_record->CountRecords();
     $config['per_page'] = $this->per_page;
     $config['first_link'] = 'First';
     $config['last_link'] = 'Last';
     $config['full_tag_open'] = '<ul class="pagination pagination-sm">';
     $config['full_tag_close'] = '</ul>';
     $config['first_tag_open'] = '<li>';
     $config['first_tag_close'] = '</li>';
     $config['last_tag_open'] = '<li>';
     $config['last_tag_close'] = '</li>';
     $config['cur_tag_open'] = '<li><span>';
     $config['cur_tag_close'] = '</span></li>';
     $config['next_tag_open'] = '<li>';
     $config['next_tag_close'] = '</li>';
     $config['prev_tag_open'] = '<li>';
     $config['prev_tag_close'] = '</li>';
     $config['num_tag_open'] = '<li>';
     $config['num_tag_close'] = '</li>';
     $config['page_query_string'] = true;
     $config['query_string_segment'] = 'offset';
     $this->pagination->initialize($config);
     // If the pagination library doesn't recognize the current page add:
     $this->pagination->cur_page = $offset;
     $data['query'] = $this->model_record->getListRecords($this->per_page, $offset);
     $data['pagination'] = $this->pagination->create_links();
     echo self::loadPartial('layout.php', 'formbuilder/views/records/list_records.php', $data);
 }
    window.onload = function () {
    rocketform.loadForm_globalSettings();
    <?php 
if (isset($form_id) && intval($form_id) > 0) {
    ?>
    rocketform.loadFormSaved(<?php 
    echo $form_id;
    ?>
);
  <?php 
} else {
    ?>
  
     rocketform.loadNewForm();
     <?php 
    if (isset($_GET['opt']) && Uiform_Form_Helper::sanitizeInput($_GET['opt']) === 'import') {
        ?>
          rocketform.importForm_openModal(); 
      <?php 
    } else {
        ?>
          rocketform.formsetting_setFieldName(); 
      <?php 
    }
    ?>
    
 <?php 
}
?>
   
};
 public function load_data_option()
 {
     switch (Uiform_Form_Helper::sanitizeInput($_GET['page'])) {
         case 'rocket_forms_record':
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder&mod=formbuilder&controller=records&action=info_records_byforms';
             break;
         case 'rocket_forms_import':
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder&mod=formbuilder&controller=forms&action=create_uiform&opt=import';
             break;
         case 'rocket_forms_export':
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder&mod=formbuilder&controller=forms&action=export_form';
             break;
         case 'rocket_forms_charts':
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder&mod=formbuilder&controller=records&action=view_charts';
             break;
         case 'rocket_forms_settings':
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder&mod=formbuilder&controller=settings&action=view_settings';
             break;
         default:
             $redirect = UIFORM_ADMINPATH . '?page=uiform_form_builder';
     }
     wp_redirect($redirect);
     die;
 }
            <li><a href="#"><?php 
echo __('Save', 'FRocket_admin');
?>
</a></li>
            <li class="divider"></li>
            <li><a href="<?php 
echo admin_url() . '?page=uiform_form_builder&mod=formbuilder&controller=forms&action=list_uiforms';
?>
"><?php 
echo __('List forms', 'FRocket_admin');
?>
</a></li>
          </ul>
        </li>
        <?php 
if (isset($_GET['action']) && Uiform_Form_Helper::sanitizeInput($_GET['action']) === 'create_uiform') {
    ?>
        <li class="divider-menu"></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-file-text-o"></span> <?php 
    echo __('Templates', 'FRocket_admin');
    ?>
 <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
              <li><a onclick="javascript:rocketform.templates_load(1);" 
                   href="javascript:void(0);"><?php 
    echo __('Contact us', 'FRocket_admin');
    ?>
</a>
              </li>
              <li><a onclick="javascript:rocketform.templates_load(2);" 
 public function create_uiform()
 {
     $data = array();
     $data['form_id'] = isset($_GET['form_id']) && $_GET['form_id'] ? Uiform_Form_Helper::sanitizeInput(trim($_GET['form_id'])) : 0;
     echo self::loadPartial('layout_editform.php', 'formbuilder/views/forms/create_form.php', $data);
 }
 public function process_form()
 {
     $form_id = $_POST['_rockfm_form_id'] ? Uiform_Form_Helper::sanitizeInput(trim($_POST['_rockfm_form_id'])) : 0;
     $form_fields = isset($_POST['uiform_fields']) && $_POST['uiform_fields'] ? array_map(array('Uiform_Form_Helper', 'sanitizeRecursive'), $_POST['uiform_fields']) : array();
     $form_f_tmp = array();
     $attachments = array();
     // initialize attachment array
     if (!empty($form_fields)) {
         foreach ($form_fields as $key => $value) {
             if (is_array($value)) {
                 $tmp_options = array();
                 foreach ($value as $value2) {
                     $tmp_options[] = $value2;
                 }
                 $form_f_tmp[$key] = implode('^,^', $tmp_options);
             } else {
                 if ((string) $value === 'uifm_fileinput') {
                     if (isset($_FILES['uiform_fields']['name'][$key]) && !empty($_FILES['uiform_fields']['name'][$key])) {
                         $upload_data = wp_upload_dir();
                         // look for this function in wordpress documentation at codex
                         $upload_dir = $upload_data['path'];
                         $upload_dirurl = $upload_data['baseurl'];
                         $upload_subdir = $upload_data['subdir'];
                         $rename = "file_" . md5(uniqid($_FILES['uiform_fields']['name'][$key], true));
                         $ext = substr($_FILES['uiform_fields']['name'][$key], strrpos($_FILES['uiform_fields']['name'][$key], '.') + 1);
                         $_FILES['uiform_fields']['name'][$key] = $rename . "." . strtolower($ext);
                         $form_f_tmp[$key] = $upload_dirurl . $upload_subdir . '/' . $_FILES['uiform_fields']['name'][$key];
                         $form_fields[$key] = $upload_dirurl . $upload_subdir . '/' . $_FILES['uiform_fields']['name'][$key];
                         //attachment
                         if ($_FILES['uiform_fields']['error'][$key] == UPLOAD_ERR_OK) {
                             $tmp_name = $_FILES['uiform_fields']['tmp_name'][$key];
                             // Get temp name of uploaded file
                             $name = $_FILES['uiform_fields']['name'][$key];
                             // rename it to whatever
                             move_uploaded_file($tmp_name, "{$upload_dir}/{$name}");
                             // move file to new location
                             $attachments[] = "{$upload_dir}/{$name}";
                             //  push the new uploaded file in attachment array
                         }
                     } else {
                         unset($form_fields[$key]);
                     }
                 } else {
                     $form_f_tmp[$key] = $value;
                 }
             }
         }
     }
     //save to form records
     $agent = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : '';
     $referer = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
     $data = array();
     $data['fbh_data'] = json_encode($form_f_tmp);
     $data['created_ip'] = $_SERVER['REMOTE_ADDR'];
     $data['form_fmb_id'] = $form_id;
     $data['fbh_data_xml'] = Uiform_Form_Helper::array2xml($form_f_tmp);
     $data['fbh_user_agent'] = $agent;
     $data['fbh_page'] = $_SERVER['REQUEST_URI'];
     $data['fbh_referer'] = $referer;
     $this->wpdb->insert($this->model_formrecords->table, $data);
     $idActivate = $this->wpdb->insert_id;
     $json = array();
     $json['status'] = 'created';
     $json['id'] = $idActivate;
     $this->flag_submitted = $idActivate;
     //get data from form
     $form_data = $this->formsmodel->getFormById_2($form_id);
     $form_data_onsubm = json_decode($form_data->fmb_data2, true);
     $form_data_name = $form_data->fmb_name;
     $contact_errors = false;
     // get the posted data
     $email_recipient = $form_data_onsubm['mail_recipient'] ? $form_data_onsubm['mail_recipient'] : get_option('admin_email');
     $email_cc = $form_data_onsubm['mail_cc'] ? $form_data_onsubm['mail_cc'] : '';
     $email_bcc = $form_data_onsubm['mail_bcc'] ? $form_data_onsubm['mail_bcc'] : '';
     //prepare message
     $tmp_template_msg = $form_data_onsubm['mail_template_msg'] ? urldecode($form_data_onsubm['mail_template_msg']) : '';
     $message = $tmp_template_msg;
     //process fields
     $message_fields = '';
     $mail_replyto = '';
     foreach ($form_fields as $key => $value) {
         $tmp_field_name = $this->model_fields->getFieldNameByUniqueId($key, $form_id);
         if (is_array($value)) {
             $message_fields .= '</br>' . $tmp_field_name->fieldname . ' : </br>';
             $message_fields .= '<table cellspacing="0" cellpadding="0">';
             foreach ($value as $value2) {
                 $message_fields .= '<tr>';
                 $message_fields .= '<td width="20" align="center" valign="top">&bull;</td>';
                 $message_fields .= '<td width="200" align="left" valign="top">' . $value2 . '</td>';
                 $message_fields .= '</tr>';
             }
             $message_fields .= '</table>';
         } else {
             $message_fields .= '<table cellspacing="0" cellpadding="0">';
             $message_fields .= '<tr>';
             $message_fields .= '<td align="center" valign="top">' . $tmp_field_name->fieldname . '</td>';
             $message_fields .= '<td width="20" align="center" valign="top">:</td>';
             $message_fields .= '<td width="200" align="left" valign="top"> ' . $value . '</td>';
             $message_fields .= '</tr>';
             $message_fields .= '</table>';
         }
         switch (intval($tmp_field_name->type)) {
             case 6:
                 /*textbox*/
             /*textbox*/
             case 28:
             case 29:
             case 30:
                 $tmp_fdata = json_decode($tmp_field_name->data, true);
                 if (isset($tmp_fdata['validate']) && isset($tmp_fdata['validate']['typ_val']) && intval($tmp_fdata['validate']['typ_val']) === 4) {
                     $mail_replyto = $value;
                 }
                 break;
         }
     }
     $subject = $form_data_onsubm['mail_subject'] ? $form_data_onsubm['mail_subject'] : __('New form request', 'FRocket_front');
     $message = str_replace("[CONTENT]", $message_fields, $message);
     $message = str_replace("[FORM_NAME]", $form_data_name, $message);
     $referer = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
     $message = str_replace("[URL_CLIENT]", $referer, $message);
     // write the email content
     $header1 = "MIME-Version: 1.0\r\n";
     $header1 .= "Content-Type: text/html; charset=utf-8\r\n";
     if (!empty($mail_replyto)) {
         $header1 .= "From: " . substr($mail_replyto, 0, strrpos($mail_replyto, '@')) . " <" . $mail_replyto . ">\r\n";
         $header1 .= "Reply-To: " . $mail_replyto . "\r\n";
         $subject .= " - " . $mail_replyto;
     } else {
         $header1 .= "From: " . $email_recipient . "\r\n";
     }
     if (!empty($email_cc)) {
         $header1 .= "Cc: " . $email_cc . "\r\n";
     }
     if (!empty($email_bcc)) {
         $header1 .= "Bcc: " . $email_bcc . "\r\n";
     }
     $to = $email_recipient;
     // send the email using wp_mail()
     add_filter('wp_mail_content_type', 'set_html_content_type');
     function set_html_content_type()
     {
         return 'text/html';
     }
     if (!wp_mail($to, $subject, $message, $header1, $attachments)) {
         $contact_errors = true;
     }
     //pending option to delete attachment
     if (false && !empty($attachments)) {
         foreach ($attachments as $attachment) {
             @unlink($attachment);
             // delete files after sending them
         }
     }
 }