本文整理汇总了PHP中STInput::ip_address方法的典型用法代码示例。如果您正苦于以下问题:PHP STInput::ip_address方法的具体用法?PHP STInput::ip_address怎么用?PHP STInput::ip_address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STInput
的用法示例。
在下文中一共展示了STInput::ip_address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _update_user_online
static function _update_user_online()
{
if (!self::$is_working) {
return;
}
if (is_admin()) {
return;
}
global $wpdb;
$table_name = $wpdb->prefix . self::$useronline;
$intIp = STInput::ip_address();
$item_id = 0;
if (is_singular()) {
$item_id = get_the_ID();
}
$where = '';
if ($item_id) {
$where .= ' AND item_id=' . sanitize_title_for_query($item_id);
}
$ip_exists = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name}\r\n WHERE ip=%d " . $where, $intIp));
if (!empty($ip_exists) and is_array($ip_exists)) {
$wpdb->query($wpdb->prepare("UPDATE {$table_name}\r\n SET dt=%d\r\n WHERE ip=%s " . $where, time(), $intIp));
} else {
$wpdb->query($wpdb->prepare("INSERT INTO {$table_name}\r\n (ip,dt,item_id)\r\n values(%s,%d,%d)", $intIp, time(), $item_id));
}
}
示例2: check_like
function check_like($comment_id)
{
// test if user liked before
if (is_user_logged_in()) {
// user is logged in
$user_id = get_current_user_id();
// current user
$meta_USERS = get_comment_meta($comment_id, "_user_liked");
// user ids from comment meta
$liked_USERS = "";
// set up array variable
if (count($meta_USERS) != 0) {
// meta exists, set up values
$liked_USERS = $meta_USERS[0];
}
if (!is_array($liked_USERS)) {
// make array just in case
$liked_USERS = array();
}
if (in_array($user_id, $liked_USERS)) {
// True if User ID in array
return true;
}
return false;
} else {
// user is anonymous, use IP address for voting
$meta_IPS = get_comment_meta($comment_id, "_user_IP");
// get previously voted IP address
$ip = STInput::ip_address();
$liked_IPS = "";
// set up array variable
if (count($meta_IPS) != 0) {
// meta exists, set up values
$liked_IPS = $meta_IPS[0];
}
if (!is_array($liked_IPS)) {
// make array just in case
$liked_IPS = array();
}
if (in_array($ip, $liked_IPS)) {
// True is IP in array
return true;
}
return false;
}
}
示例3: booking_form_submit
static function booking_form_submit($item_id = '')
{
if (STInput::post('st_payment_gateway') and wp_verify_nonce(STInput::post('travel_order'), 'submit_form_order')) {
$first_item_id = self::get_booking_id();
// All gateway available
$gateways = STPaymentGateways::get_payment_gateways();
if (empty($gateways)) {
return array('status' => false, 'message' => __('Sorry! No payment gateway available', ST_TEXTDOMAIN));
}
$payment_gateway_used = false;
$payment_gateway_id = false;
if (!empty($gateways)) {
foreach ($gateways as $key => $value) {
if (STInput::post('st_payment_gateway_' . $key)) {
$payment_gateway_id = $key;
$payment_gateway_used = STPaymentGateways::get_gateway($payment_gateway_id, $first_item_id);
}
}
}
if (!$payment_gateway_id or !$payment_gateway_used) {
$payment_gateway_name = apply_filters('st_payment_gateway_' . $payment_gateway_id . '_name', $payment_gateway_id);
return array('status' => false, 'message' => sprintf(__('Sorry! Payment Gateway: <code>%s</code> is not available for this item!', ST_TEXTDOMAIN), $payment_gateway_name));
}
// Action before submit form
do_action('st_before_form_submit_run');
$form_validate = true;
if (!self::check_cart()) {
return array('status' => false, 'message' => __('Your cart is currently empty.', ST_TEXTDOMAIN), 'code' => '1');
}
if ($coupon_code = STInput::request('coupon_code')) {
$status = self::do_apply_coupon($coupon_code);
if (!$status['status']) {
return array('status' => false, 'message' => $status['message']);
}
}
if (st()->get_option('booking_enable_captcha', 'on') == 'on') {
$st_security_key = STInput::request('st_security_key');
$allow_captcha = STInput::request('allow_capcha', 'off');
if ($allow_captcha == 'off') {
if (!$st_security_key) {
return array('status' => false, 'message' => __('You dose not enter the captcha', ST_TEXTDOMAIN));
}
$valid = STCoolCaptcha::validate_captcha($st_security_key);
if (!$valid) {
return array('status' => false, 'message' => __('Captcha is not correct', ST_TEXTDOMAIN), 'error_code' => 'invalid_captcha');
}
}
}
$default = array('st_note' => '', 'term_condition' => '', 'create_account' => false, 'paypal_checkout' => false);
extract(wp_parse_args($_POST, $default));
//Term and condition
if (!$term_condition) {
return array('status' => false, 'message' => __('Please accept our terms and conditions', ST_TEXTDOMAIN));
}
$form_validate = self::validate_checkout_fields();
if ($form_validate) {
$form_validate = $payment_gateway_used->_pre_checkout_validate();
}
if (!$form_validate) {
$message = array('status' => false, 'message' => STTemplate::get_message_content(), 'form_validate' => 'false');
STTemplate::clear();
return $message;
}
$post = array('post_title' => __('Order', ST_TEXTDOMAIN) . ' - ' . date(get_option('date_format')) . ' @ ' . date(get_option('time_format')), 'post_type' => 'st_order', 'post_status' => 'publish');
$data_price = STPrice::getDataPrice();
//save the order
$insert_post = wp_insert_post($post);
if ($insert_post) {
$cart = self::get_items();
$fields = self::get_checkout_fields();
if (!empty($fields)) {
foreach ($fields as $key => $value) {
update_post_meta($insert_post, $key, STInput::post($key));
}
}
update_post_meta($insert_post, 'st_tax', STPrice::getTax());
update_post_meta($insert_post, 'st_tax_percent', STPrice::getTax());
update_post_meta($insert_post, 'st_is_tax_included_listing_page', STCart::is_tax_included_listing_page() ? 'on' : 'off');
update_post_meta($insert_post, 'currency', TravelHelper::get_current_currency('symbol'));
update_post_meta($insert_post, 'currency_rate', TravelHelper::get_current_currency('rate'));
update_post_meta($insert_post, 'coupon_code', STCart::get_coupon_code());
update_post_meta($insert_post, 'coupon_amount', STCart::get_coupon_amount());
update_post_meta($insert_post, 'status', 'pending');
update_post_meta($insert_post, 'st_cart_info', $cart);
update_post_meta($insert_post, 'total_price', STPrice::getTotal());
update_post_meta($insert_post, 'ip_address', STInput::ip_address());
update_post_meta($insert_post, 'order_token_code', wp_hash($insert_post));
update_post_meta($insert_post, 'data_prices', $data_price);
update_post_meta($insert_post, 'booking_by', STInput::post('booking_by', ''));
self::saveOrderItems($insert_post);
if (!is_user_logged_in()) {
$user_name = STInput::post('st_email');
$user_id = username_exists($user_name);
//Now Create Account if user agree
if ($create_account) {
if (!$user_id and email_exists($user_name) == false) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
$userdata = array('user_login' => $user_name, 'user_pass' => $random_password, 'user_email' => $user_name, 'first_name' => STInput::post('st_first_name'), 'last_name' => STInput::post('st_last_name'));
$user_id = wp_insert_user($userdata);
//Create User Success, send the nofitication
//.........这里部分代码省略.........