本文整理汇总了PHP中FrmAppHelper::get_ip_address方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmAppHelper::get_ip_address方法的具体用法?PHP FrmAppHelper::get_ip_address怎么用?PHP FrmAppHelper::get_ip_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmAppHelper
的用法示例。
在下文中一共展示了FrmAppHelper::get_ip_address方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create($values)
{
global $wpdb;
self::sanitize_entry_post($values);
$values = apply_filters('frm_pre_create_entry', $values);
if (!isset($values['item_key'])) {
$values['item_key'] = '';
}
$item_name = self::get_new_entry_name($values, $values['item_key']);
$new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => isset($values['frm_saving_draft']) && $values['frm_saving_draft'] == 1 || isset($values['is_draft']) && $values['is_draft'] == 1 ? 1 : 0, 'form_id' => isset($values['form_id']) ? (int) $values['form_id'] : null, 'post_id' => isset($values['post_id']) ? (int) $values['post_id'] : 0, 'parent_item_id' => isset($values['parent_item_id']) ? (int) $values['parent_item_id'] : 0, 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), 'updated_at' => isset($values['updated_at']) ? $values['updated_at'] : (isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1)));
if (is_array($new_values['name'])) {
$new_values['name'] = reset($new_values['name']);
}
if (isset($values['description']) && !empty($values['description'])) {
$new_values['description'] = maybe_serialize($values['description']);
} else {
$new_values['description'] = serialize(array('browser' => FrmAppHelper::get_server_value('HTTP_USER_AGENT'), 'referrer' => FrmAppHelper::get_server_value('HTTP_REFERER')));
}
//if(isset($values['id']) and is_numeric($values['id']))
// $new_values['id'] = $values['id'];
if (isset($values['frm_user_id']) && (is_numeric($values['frm_user_id']) || FrmAppHelper::is_admin())) {
$new_values['user_id'] = $values['frm_user_id'];
} else {
$user_ID = get_current_user_id();
$new_values['user_id'] = $user_ID ? $user_ID : 0;
}
$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
// don't create duplicate entry
if (self::is_duplicate($new_values, $values)) {
return false;
}
$query_results = $wpdb->insert($wpdb->prefix . 'frm_items', $new_values);
if (!$query_results) {
return false;
}
$entry_id = $wpdb->insert_id;
global $frm_vars;
if (!isset($frm_vars['saved_entries'])) {
$frm_vars['saved_entries'] = array();
}
$frm_vars['saved_entries'][] = (int) $entry_id;
if (isset($values['item_meta'])) {
FrmEntryMeta::update_entry_metas($entry_id, $values['item_meta']);
}
self::clear_cache();
// this is a child entry
$is_child = isset($values['parent_form_id']) && isset($values['parent_nonce']) && !empty($values['parent_form_id']) && wp_verify_nonce($values['parent_nonce'], 'parent');
do_action('frm_after_create_entry', $entry_id, $new_values['form_id'], compact('is_child'));
do_action('frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact('is_child'));
return $entry_id;
}
示例2: package_entry_data
/**
* Prepare the new values for inserting into the database
*
* @since 2.0.16
* @param array $values
* @return array $new_values
*/
private static function package_entry_data(&$values)
{
global $wpdb;
if (!isset($values['item_key'])) {
$values['item_key'] = '';
}
$item_name = self::get_new_entry_name($values, $values['item_key']);
$new_values = array('item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix . 'frm_items', 'item_key'), 'name' => FrmAppHelper::truncate($item_name, 255, 1, ''), 'ip' => FrmAppHelper::get_ip_address(), 'is_draft' => self::get_is_draft_value($values), 'form_id' => self::get_form_id($values), 'post_id' => self::get_post_id($values), 'parent_item_id' => self::get_parent_item_id($values), 'created_at' => self::get_created_at($values), 'updated_at' => self::get_updated_at($values), 'description' => self::get_entry_description($values), 'user_id' => self::get_entry_user_id($values));
if (is_array($new_values['name'])) {
$new_values['name'] = reset($new_values['name']);
}
$new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id'];
return $new_values;
}
示例3: get_frm_field_value_entry
/**
* Get entry object for frm_field_value shortcode
* Uses user_id, entry, or ip atts to fetch the entry
*
* @since 2.0.13
* @param object $field
* @param array $atts
* @return boolean|object $entry
*/
private static function get_frm_field_value_entry($field, &$atts)
{
$query = array('form_id' => $field->form_id);
if ($atts['user_id']) {
// make sure we are not getting entries for logged-out users
$query['user_id'] = (int) FrmAppHelper::get_user_id_param($atts['user_id']);
$query['user_id !'] = 0;
}
if ($atts['entry']) {
if (!is_numeric($atts['entry'])) {
$atts['entry'] = FrmAppHelper::simple_get($atts['entry'], 'sanitize_title', $atts['entry']);
}
if (empty($atts['entry'])) {
return;
}
if (is_numeric($atts['entry'])) {
$query[] = array('or' => 1, 'id' => $atts['entry'], 'parent_item_id' => $atts['entry']);
} else {
$query[] = array('item_key' => $atts['entry']);
}
}
if ($atts['ip']) {
$query['ip'] = $atts['ip'] == true ? FrmAppHelper::get_ip_address() : $atts['ip'];
}
$entry = FrmDb::get_row('frm_items', $query, 'post_id, id', array('order_by' => 'created_at DESC'));
return $entry;
}
示例4: parse_akismet_array
/**
* @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);
}
}
示例5: user_can_submit_form
/**
* @since 2.0.8
* @return boolean
*/
public static function user_can_submit_form($form)
{
$admin_entry = FrmAppHelper::is_admin();
$can_submit = true;
if ($form->options['single_entry_type'] == 'cookie' && isset($_COOKIE['frm_form' . $form->id . '_' . COOKIEHASH])) {
$can_submit = $admin_entry ? true : false;
} else {
if ($form->options['single_entry_type'] == 'ip') {
if (!$admin_entry) {
$prev_entry = FrmEntry::getAll(array('it.form_id' => $form->id, 'it.ip' => FrmAppHelper::get_ip_address()), '', 1);
if ($prev_entry) {
$can_submit = false;
}
}
} else {
if (($form->options['single_entry_type'] == 'user' || isset($form->options['save_draft']) && $form->options['save_draft'] == 1) && !$form->editable) {
$user_ID = get_current_user_id();
if ($user_ID) {
$meta = FrmProEntriesHelper::check_for_user_entry($user_ID, $form, $form->options['single_entry_type'] != 'user');
if ($meta) {
$can_submit = false;
}
}
}
}
}
return $can_submit;
}