Exemple #1
0
 function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas["{$key}"] = $value;
         } else {
             $datas["{$key}"] = '';
         }
         unset($key, $value);
     }
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     if (is_callable('Akismet::http_post')) {
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         global $akismet_api_host, $akismet_api_port;
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     return (is_array($response) and $response[1] == 'true') ? true : false;
 }
 /**
  * Get the value to replace a few standard shortcodes
  *
  * @since 2.0
  * @return string
  */
 public static function dynamic_default_values($tag, $atts = array(), $return_array = false)
 {
     $new_value = '';
     switch ($tag) {
         case 'admin_email':
             $new_value = get_option('admin_email');
             break;
         case 'siteurl':
             $new_value = FrmAppHelper::site_url();
             break;
         case 'frmurl':
             $new_value = FrmAppHelper::plugin_url();
             break;
         case 'sitename':
             $new_value = FrmAppHelper::site_name();
             break;
         case 'get':
             $new_value = self::process_get_shortcode($atts, $return_array);
             break;
     }
     return $new_value;
 }
 /**
  * @since 2.0
  * @param string $content
  */
 private static function parse_akismet_array(&$datas, $content)
 {
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', FrmAppHelper::get_ip_address());
     $datas['user_agent'] = FrmAppHelper::get_server_value('HTTP_USER_AGENT');
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? FrmAppHelper::get_server_value('HTTP_REFERER') : false;
     $datas['comment_type'] = 'formidable';
     $datas['comment_content'] = $content;
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas[$key] = wp_strip_all_tags($value);
         } else {
             $datas[$key] = '';
         }
         unset($key, $value);
     }
 }
 public static function referer_session()
 {
     global $frm_settings;
     if (!isset($frm_settings->track) || !$frm_settings->track || defined('WP_IMPORTING')) {
         return;
     }
     // keep the page history below 100
     $max = 100;
     if (!isset($_SESSION)) {
         session_start();
     }
     if (!isset($_SESSION['frm_http_pages']) or !is_array($_SESSION['frm_http_pages'])) {
         $_SESSION['frm_http_pages'] = array("http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
     }
     if (!isset($_SESSION['frm_http_referer']) or !is_array($_SESSION['frm_http_referer'])) {
         $_SESSION['frm_http_referer'] = array();
     }
     if (!isset($_SERVER['HTTP_REFERER']) or isset($_SERVER['HTTP_REFERER']) and strpos($_SERVER['HTTP_REFERER'], FrmAppHelper::site_url()) === false and !in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'])) {
         if (!isset($_SERVER['HTTP_REFERER'])) {
             $direct = __('Type-in or bookmark', 'formidable');
             if (!in_array($direct, $_SESSION['frm_http_referer'])) {
                 $_SESSION['frm_http_referer'][] = $direct;
             }
         } else {
             $_SESSION['frm_http_referer'][] = $_SERVER['HTTP_REFERER'];
         }
     }
     if ($_SESSION['frm_http_pages'] and !empty($_SESSION['frm_http_pages']) and end($_SESSION['frm_http_pages']) != "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']) {
         $_SESSION['frm_http_pages'][] = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     }
     //keep the page history below the max
     if (count($_SESSION['frm_http_pages']) > $max) {
         foreach ($_SESSION['frm_http_pages'] as $pkey => $ppage) {
             if (count($_SESSION['frm_http_pages']) <= $max) {
                 break;
             }
             unset($_SESSION['frm_http_pages'][$pkey]);
         }
     }
 }
_e('Entry update date', 'formidable');
?>
</option>
    <?php 
if (is_numeric($post->frm_form_id) && !empty($post->frm_form_id)) {
    FrmProFieldsHelper::get_field_options($post->frm_form_id, $post->frm_edate_field_id, '', "'date', 'number'");
}
?>
</select>
<br/>

<label class="frm_left_label"><?php 
_e('Repeat', 'formidable');
?>
 <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php 
printf(__('Select a field from your form that contains values like 1 week, 2 weeks, 1 year, etc. This will set the repeat period for each event.', 'formidable'), FrmAppHelper::site_url());
?>
" ></span> </label>
<select id="repeat_event_field_id" name="options[repeat_event_field_id]">
    <option value=""><?php 
_e('No repeating events', 'formidable');
?>
</option>
    <?php 
if (is_numeric($post->frm_form_id) && !empty($post->frm_form_id)) {
    FrmProFieldsHelper::get_field_options($post->frm_form_id, $post->frm_repeat_event_field_id, '', "'radio', 'select'");
}
?>
</select>
<br/>
Exemple #6
0
</table>

<h3><?php 
_e('Advanced', 'formidable');
?>
</h3>
<table class="form-table frm-no-margin">
    <tr class="hide_dyncontent <?php 
echo in_array($post->frm_show_count, array('dynamic', 'calendar')) ? '' : 'frm_hidden';
?>
">
        <td><?php 
_e('Detail Page Slug', 'formidable');
?>
 <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php 
printf(__('Example: If parameter name is \'contact\', the url would be like %1$s/selected-page?contact=2. If this entry is linked to a post, the post permalink will be used instead.', 'formidable'), FrmAppHelper::site_url());
?>
" ></span></td>
        <td>
            <?php 
/*
			if ( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) { ?>
    <select id="type" name="type">
        <option value="id" <?php selected($post->frm_type, 'id') ?>><?php _e( 'ID', 'formidable' ); ?></option>
        <option value="display_key" <?php selected($post->frm_type, 'display_key') ?>><?php _e( 'Key', 'formidable' ); ?></option>
    </select>
    <p class="description"><?php printf(__( 'Select the value that will be added onto the page URL. This will create a pretty URL like %1$s/selected-page/entry-key', 'formidable' ), FrmAppHelper::site_url()); ?></p>
<?php }else{ ?>
*/
?>
                <input type="text" id="param" name="param" value="<?php 
 public static function replace_shortcodes($content, $entry, $shortcodes, $display = false, $show = 'one', $odd = '', $args = array())
 {
     global $frm_field, $frm_entry_meta, $post, $frmpro_settings;
     if ($display) {
         $param_value = $display->frm_type == 'id' ? $entry->id : $entry->item_key;
         if ($entry->post_id) {
             $detail_link = get_permalink($entry->post_id);
         } else {
             $param = isset($display->frm_param) && !empty($display->frm_param) ? $display->frm_param : 'entry';
             if ($post) {
                 $detail_link = add_query_arg($param, $param_value, get_permalink($post->ID));
             } else {
                 $detail_link = add_query_arg($param, $param_value);
             }
             //if( FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks )
             //    $detail_link = get_permalink($post->ID) .$param_value .'/';
         }
     }
     foreach ($shortcodes[0] as $short_key => $tag) {
         $conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false;
         $atts = shortcode_parse_atts($shortcodes[3][$short_key]);
         if (!empty($shortcodes[3][$short_key])) {
             $tag = str_replace($conditional ? '[if ' : '[', '', $shortcodes[0][$short_key]);
             $tag = str_replace(']', '', $tag);
             $tags = explode(' ', $tag);
             if (is_array($tags)) {
                 $tag = $tags[0];
             }
         } else {
             $tag = $shortcodes[2][$short_key];
         }
         switch ($tag) {
             case 'entry_count':
                 $content = str_replace($shortcodes[0][$short_key], isset($args['record_count']) ? $args['record_count'] : '', $content);
                 break;
             case 'detaillink':
                 if ($display and $detail_link) {
                     $content = str_replace($shortcodes[0][$short_key], $detail_link, $content);
                 }
                 break;
             case 'id':
                 $content = str_replace($shortcodes[0][$short_key], $entry->id, $content);
                 break;
             case 'post-id':
             case 'post_id':
                 $content = str_replace($shortcodes[0][$short_key], $entry->post_id, $content);
                 break;
             case 'key':
                 $content = str_replace($shortcodes[0][$short_key], $entry->item_key, $content);
                 break;
             case 'ip':
                 $content = str_replace($shortcodes[0][$short_key], $entry->ip, $content);
                 break;
             case 'user_agent':
             case 'user-agent':
                 $entry->description = maybe_unserialize($entry->description);
                 $content = str_replace($shortcodes[0][$short_key], $entry->description['browser'], $content);
                 break;
             case 'created_at':
             case 'created-at':
             case 'updated_at':
             case 'updated-at':
                 if (!isset($atts['format'])) {
                     $atts['format'] = get_option('date_format');
                     $time_format = false;
                 } else {
                     $time_format = ' ';
                 }
                 $this_tag = str_replace('-', '_', $tag);
                 if ($conditional) {
                     $atts['short_key'] = $shortcodes[0][$short_key];
                     $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag);
                 } else {
                     if (isset($atts['time_ago'])) {
                         $date = FrmProAppHelper::human_time_diff(strtotime($entry->{$this_tag}));
                     } else {
                         $date = FrmProAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format);
                     }
                     $content = str_replace($shortcodes[0][$short_key], $date, $content);
                 }
                 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);
                 if ($conditional) {
                     $atts['short_key'] = $shortcodes[0][$short_key];
                     $content = self::check_conditional_shortcode($content, $entry->{$this_tag}, $atts, $tag);
                 } else {
                     $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
                 }
                 unset($this_tag);
                 unset($replace_with);
                 break;
             case 'evenodd':
                 $content = str_replace($shortcodes[0][$short_key], $odd, $content);
                 break;
             case 'siteurl':
                 $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::site_url(), $content);
                 break;
             case 'frmurl':
                 $content = str_replace($shortcodes[0][$short_key], FrmAppHelper::plugin_url(), $content);
                 break;
             case 'sitename':
                 $content = str_replace($shortcodes[0][$short_key], get_option('blogname'), $content);
                 break;
             case 'get':
                 if (isset($atts['param'])) {
                     $param = $atts['param'];
                     $replace_with = FrmAppHelper::get_param($param);
                     if (is_array($replace_with)) {
                         $replace_with = implode(', ', $replace_with);
                     }
                     $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
                     unset($param);
                     unset($replace_with);
                 }
                 break;
             default:
                 if ($tag == 'deletelink') {
                     $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0);
                     if (!isset($atts['label'])) {
                         $atts['label'] = false;
                     }
                     $delete_atts = $atts;
                     $delete_atts['id'] = $entry->id;
                     $delete_atts['page_id'] = $page_id;
                     $replace_with = FrmProEntriesController::entry_delete_link($delete_atts);
                     unset($delete_atts);
                     $field = false;
                 } else {
                     if ($tag == 'editlink') {
                         $replace_with = '';
                         $link_text = isset($atts['label']) ? $atts['label'] : false;
                         if (!$link_text) {
                             $link_text = isset($atts['link_text']) ? $atts['link_text'] : __('Edit');
                         }
                         $class = isset($atts['class']) ? $atts['class'] : '';
                         $page_id = isset($atts['page_id']) ? $atts['page_id'] : ($post ? $post->ID : 0);
                         if (isset($atts['location']) && $atts['location'] == 'front' || isset($atts['prefix']) && !empty($atts['prefix']) || isset($atts['page_id']) && !empty($atts['page_id'])) {
                             $edit_atts = $atts;
                             $edit_atts['id'] = $entry->id;
                             $delete_atts['page_id'] = $page_id;
                             $replace_with = FrmProEntriesController::entry_edit_link($edit_atts);
                         } else {
                             if ($entry->post_id) {
                                 $replace_with = get_edit_post_link($entry->post_id);
                             } else {
                                 if (current_user_can('frm_edit_entries')) {
                                     $replace_with = esc_url(admin_url('admin.php?page=formidable-entries&frm_action=edit&id=' . $entry->id));
                                 }
                             }
                             if (!empty($replace_with)) {
                                 $replace_with = '<a href="' . $replace_with . '" class="frm_edit_link ' . $class . '">' . $link_text . '</a>';
                             }
                         }
                         unset($class);
                     } else {
                         $field = $frm_field->getOne($tag);
                     }
                 }
                 $sep = isset($atts['sep']) ? $atts['sep'] : ', ';
                 if (!isset($field)) {
                     $field = false;
                 }
                 if ($field) {
                     $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
                     $atts['entry_id'] = $entry->id;
                     $atts['entry_key'] = $entry->item_key;
                     $atts['post_id'] = $entry->post_id;
                     $replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
                 }
                 if ($field and $field->type == 'file') {
                     //size options are thumbnail, medium, large, or full, label
                     $size = isset($atts['size']) ? $atts['size'] : (isset($atts['show']) ? $atts['show'] : 'thumbnail');
                     $inc_html = (isset($atts['html']) and $atts['html']) ? true : false;
                     $inc_links = (isset($atts['links']) and $atts['links']) ? true : false;
                     $sep = isset($atts['sep']) ? $atts['sep'] : ' ';
                     $show_filename = (isset($atts['show_filename']) and $atts['show_filename']) ? true : false;
                     if ($size != 'id' && !empty($replace_with)) {
                         $replace_with = FrmProFieldsHelper::get_media_from_id($replace_with, $size, array('html' => $inc_html, 'links' => $inc_links, 'show_filename' => $show_filename));
                     } else {
                         if (is_array($replace_with)) {
                             $replace_with = array_filter($replace_with);
                         }
                     }
                     unset($size);
                 }
                 if (isset($replace_with) and is_array($replace_with)) {
                     $replace_with = implode($sep, $replace_with);
                 }
                 if ($conditional) {
                     if (!isset($replace_with)) {
                         $replace_with = '';
                     }
                     $replace_with = apply_filters('frm_conditional_value', $replace_with, $atts, $field, $tag);
                     $start_pos = strpos($content, $shortcodes[0][$short_key]);
                     if ($start_pos !== false) {
                         $start_pos_len = strlen($shortcodes[0][$short_key]);
                         $end_pos = strpos($content, '[/if ' . $tag . ']', $start_pos);
                         $end_pos_len = strlen('[/if ' . $tag . ']');
                         if ($end_pos !== false) {
                             if (empty($replace_with)) {
                                 $total_len = $end_pos + $end_pos_len - $start_pos;
                                 $content = substr_replace($content, '', $start_pos, $total_len);
                             } else {
                                 $content = substr_replace($content, '', $end_pos, $end_pos_len);
                                 $content = substr_replace($content, '', $start_pos, $start_pos_len);
                             }
                         }
                     }
                 } else {
                     if ($field) {
                         if (isset($atts['show']) and $atts['show'] == 'field_label') {
                             $replace_with = $field->name;
                         } else {
                             if (isset($atts['show']) and $atts['show'] == 'description') {
                                 $replace_with = $field->description;
                             } else {
                                 if (empty($replace_with) and $replace_with != '0') {
                                     $replace_with = '';
                                     if ($field->type == 'number') {
                                         $replace_with = '0';
                                     }
                                 } else {
                                     $replace_with = FrmProFieldsHelper::get_display_value($replace_with, $field, $atts);
                                 }
                             }
                         }
                     }
                     if (isset($atts['sanitize'])) {
                         $replace_with = sanitize_title_with_dashes($replace_with);
                     }
                     if (isset($atts['sanitize_url'])) {
                         if (seems_utf8($replace_with)) {
                             $replace_with = utf8_uri_encode($replace_with, 200);
                         }
                         $replace_with = urlencode(htmlentities($replace_with));
                     }
                     if (isset($atts['truncate'])) {
                         if (isset($atts['more_text'])) {
                             $more_link_text = $atts['more_text'];
                         } else {
                             $more_link_text = isset($atts['more_link_text']) ? $atts['more_link_text'] : '. . .';
                         }
                         if ($display and $display->frm_show_count == 'dynamic') {
                             $more_link_text = ' <a href="' . $detail_link . '">' . $more_link_text . '</a>';
                             $replace_with = FrmAppHelper::truncate($replace_with, (int) $atts['truncate'], 3, $more_link_text);
                         } else {
                             $replace_with = wp_specialchars_decode(strip_tags($replace_with), ENT_QUOTES);
                             $part_one = substr($replace_with, 0, (int) $atts['truncate']);
                             $part_two = substr($replace_with, (int) $atts['truncate']);
                             if (!empty($part_two)) {
                                 $replace_with = $part_one . '<a href="#" onclick="jQuery(this).next().css(\'display\', \'inline\');jQuery(this).css(\'display\', \'none\');return false;" class="frm_text_exposed_show"> ' . $more_link_text . '</a><span style="display:none;">' . $part_two . '</span>';
                             }
                         }
                     }
                     if (isset($atts['clickable'])) {
                         $replace_with = make_clickable($replace_with);
                     }
                     if (!isset($replace_with)) {
                         $replace_with = '';
                     }
                     $content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
                 }
                 unset($replace_with);
                 if (isset($field)) {
                     unset($field);
                 }
         }
         unset($atts);
         unset($conditional);
     }
     return $content;
 }
    selected($post->frm_type, 'id');
    ?>
><?php 
    _e('ID', 'formidable');
    ?>
</option>
                    <option value="display_key" <?php 
    selected($post->frm_type, 'display_key');
    ?>
><?php 
    _e('Key', 'formidable');
    ?>
</option>
                </select> 
                <p class="description"><?php 
    printf(__('Select the value that will be added onto the page URL. This will create a pretty URL like %1$s/selected-page/entry-key', 'formidable'), FrmAppHelper::site_url());
    ?>
</p>
            <?php 
} else {
    ?>
                <?php 
    _e('Parameter Name', 'formidable');
    ?>
: 
                <input type="text" id="param" name="param" value="<?php 
    echo esc_attr($post->frm_param);
    ?>
">

                <?php