public static function get_browser($u_agent)
 {
     _deprecated_function(__FUNCTION__, '2.0.9', 'FrmEntryFormat::get_browser');
     return FrmEntryFormat::get_browser($u_agent);
 }
 public static function trigger_email($action, $entry, $form)
 {
     if (defined('WP_IMPORTING') && WP_IMPORTING) {
         return;
     }
     global $wpdb;
     $notification = $action->post_content;
     $email_key = $action->ID;
     // Set the subject
     if (empty($notification['email_subject'])) {
         $notification['email_subject'] = sprintf(__('%1$s Form submitted on %2$s', 'formidable'), $form->name, '[sitename]');
     }
     $plain_text = $notification['plain_text'] ? true : false;
     //Filter these fields
     $filter_fields = array('email_to', 'cc', 'bcc', 'reply_to', 'from', 'email_subject', 'email_message');
     add_filter('frm_plain_text_email', $plain_text ? '__return_true' : '__return_false');
     //Get all values in entry in order to get User ID field ID
     $values = FrmEntryMeta::getAll(array('it.field_id !' => 0, 'it.item_id' => $entry->id), ' ORDER BY fi.field_order');
     $user_id_field = $user_id_key = '';
     foreach ($values as $value) {
         if ($value->field_type == 'user_id') {
             $user_id_field = $value->field_id;
             $user_id_key = $value->field_key;
             break;
         }
         unset($value);
     }
     //Filter and prepare the email fields
     foreach ($filter_fields as $f) {
         //Don't allow empty From
         if ($f == 'from' && empty($notification[$f])) {
             $notification[$f] = '[admin_email]';
         } else {
             if (in_array($f, array('email_to', 'cc', 'bcc', 'reply_to', 'from'))) {
                 //Remove brackets
                 //Add a space in case there isn't one
                 $notification[$f] = str_replace('<', ' ', $notification[$f]);
                 $notification[$f] = str_replace(array('"', '>'), '', $notification[$f]);
                 //Switch userID shortcode to email address
                 if (strpos($notification[$f], '[' . $user_id_field . ']') !== false || strpos($notification[$f], '[' . $user_id_key . ']') !== false) {
                     $user_data = get_userdata($entry->metas[$user_id_field]);
                     $user_email = $user_data->user_email;
                     $notification[$f] = str_replace(array('[' . $user_id_field . ']', '[' . $user_id_key . ']'), $user_email, $notification[$f]);
                 }
             }
         }
         $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes($notification[$f], $form, $entry);
     }
     //Put recipients, cc, and bcc into an array if they aren't empty
     $to_emails = self::explode_emails($notification['email_to']);
     $cc = self::explode_emails($notification['cc']);
     $bcc = self::explode_emails($notification['bcc']);
     $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form'));
     // Stop now if there aren't any recipients
     if (empty($to_emails) && empty($cc) && empty($bcc)) {
         return;
     }
     $to_emails = array_unique((array) $to_emails);
     $prev_mail_body = $mail_body = $notification['email_message'];
     $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array('id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, 'user_info' => isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false));
     // Add the user info if it isn't already included
     if ($notification['inc_user_info'] && $prev_mail_body == $mail_body) {
         $data = maybe_unserialize($entry->description);
         $mail_body .= "\r\n\r\n" . __('User Information', 'formidable') . "\r\n";
         $mail_body .= __('IP Address', 'formidable') . ': ' . $entry->ip . "\r\n";
         $mail_body .= __('User-Agent (Browser/OS)', 'formidable') . ': ' . FrmEntryFormat::get_browser($data['browser']) . "\r\n";
         $mail_body .= __('Referrer', 'formidable') . ': ' . $data['referrer'] . "\r\n";
     }
     unset($prev_mail_body);
     // Add attachments
     $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key'));
     if (!empty($notification['email_subject'])) {
         $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key'));
     }
     // check for a phone number
     foreach ((array) $to_emails as $email_key => $e) {
         if ($e != '[admin_email]' && !is_email($e)) {
             $e = explode(' ', $e);
             //If to_email has name <*****@*****.**> format
             if (is_email(end($e))) {
                 continue;
             }
             do_action('frm_send_to_not_email', array('e' => $e, 'subject' => $notification['email_subject'], 'mail_body' => $mail_body, 'reply_to' => $notification['reply_to'], 'from' => $notification['from'], 'plain_text' => $plain_text, 'attachments' => $attachments, 'form' => $form, 'email_key' => $email_key));
             unset($to_emails[$email_key]);
         }
     }
     // Send the email now
     $sent_to = self::send_email(array('to_email' => $to_emails, 'subject' => $notification['email_subject'], 'message' => $mail_body, 'from' => $notification['from'], 'plain_text' => $plain_text, 'reply_to' => $notification['reply_to'], 'attachments' => $attachments, 'cc' => $cc, 'bcc' => $bcc));
     return $sent_to;
 }
 public static function entry_sidebar($entry)
 {
     $data = maybe_unserialize($entry->description);
     $date_format = get_option('date_format');
     $time_format = get_option('time_format');
     if (isset($data['browser'])) {
         $browser = FrmEntryFormat::get_browser($data['browser']);
     }
     include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
 }
 public static function replace_content_shortcodes($content, $entry, $shortcodes)
 {
     $shortcode_values = array('id' => $entry->id, 'key' => $entry->item_key, 'ip' => $entry->ip);
     foreach ($shortcodes[0] as $short_key => $tag) {
         $atts = shortcode_parse_atts($shortcodes[3][$short_key]);
         if (!empty($shortcodes[3][$short_key])) {
             $tag = str_replace(array('[', ']'), '', $shortcodes[0][$short_key]);
             $tags = explode(' ', $tag);
             if (is_array($tags)) {
                 $tag = $tags[0];
             }
         } else {
             $tag = $shortcodes[2][$short_key];
         }
         switch ($tag) {
             case 'id':
             case 'key':
             case 'ip':
                 $replace_with = $shortcode_values[$tag];
                 break;
             case 'user_agent':
             case 'user-agent':
                 $entry->description = maybe_unserialize($entry->description);
                 $replace_with = FrmEntryFormat::get_browser($entry->description['browser']);
                 break;
             case 'created_at':
             case 'created-at':
             case 'updated_at':
             case 'updated-at':
                 if (isset($atts['format'])) {
                     $time_format = ' ';
                 } else {
                     $atts['format'] = get_option('date_format');
                     $time_format = '';
                 }
                 $this_tag = str_replace('-', '_', $tag);
                 $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
                 unset($this_tag);
                 break;
             case 'created_by':
             case 'created-by':
             case 'updated_by':
             case 'updated-by':
                 $this_tag = str_replace('-', '_', $tag);
                 $replace_with = self::get_display_value($entry->{$this_tag}, (object) array('type' => 'user_id'), $atts);
                 unset($this_tag);
                 break;
             case 'admin_email':
             case 'siteurl':
             case 'frmurl':
             case 'sitename':
             case 'get':
                 $replace_with = self::dynamic_default_values($tag, $atts);
                 break;
             default:
                 $field = FrmField::getOne($tag);
                 if (!$field) {
                     break;
                 }
                 $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
                 $replace_with = FrmEntryMeta::get_meta_value($entry, $field->id);
                 $atts['entry_id'] = $entry->id;
                 $atts['entry_key'] = $entry->item_key;
                 //$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
                 if (is_array($replace_with)) {
                     $replace_with = implode($sep, $replace_with);
                 }
                 if (isset($atts['show']) && $atts['show'] == 'field_label') {
                     $replace_with = $field->name;
                 } else {
                     if (isset($atts['show']) && $atts['show'] == 'description') {
                         $replace_with = $field->description;
                     } else {
                         if (empty($replace_with) && $replace_with != '0') {
                             $replace_with = '';
                         } else {
                             $replace_with = self::get_display_value($replace_with, $field, $atts);
                         }
                     }
                 }
                 unset($field);
                 break;
         }
         if (isset($replace_with)) {
             $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
         }
         unset($atts, $conditional, $replace_with);
     }
     return $content;
 }
 public static function get_email_html()
 {
     check_ajax_referer('frm_ajax', 'nonce');
     echo FrmEntryFormat::show_entry(array('form_id' => FrmAppHelper::get_post_param('form_id', '', 'absint'), 'default_email' => true, 'plain_text' => FrmAppHelper::get_post_param('plain_text', '', 'absint')));
     wp_die();
 }
 public static function show_entry_shortcode($atts)
 {
     return FrmEntryFormat::show_entry($atts);
 }