Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_clientip()
- {
- if(isset($_SERVER["HTTP_CF_CONNECTING_IP"]))
- {
- $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
- $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
- }
- $client = @$_SERVER['HTTP_CLIENT_IP'];
- $remote = $_SERVER['REMOTE_ADDR'];
- $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
- if(filter_var($client, FILTER_VALIDATE_IP))
- {
- $ip = $client;
- }
- elseif(filter_var($forward, FILTER_VALIDATE_IP))
- {
- $ip = $forward;
- }
- else
- {
- $ip = $remote;
- }
- return $ip;
- }
- function save_comment_hostip($comment_id)
- {
- $hostIP = get_clientip();
- $partIP = explode('.', $clientIP);
- $hideIP = $partIP[0].'.'.$partIP[1].'***.***';
- if((isset($hideIP)) && ($hideIP != ''))
- {
- add_comment_meta($comment_id, 'host_ip', $hideIP);
- }
- }
- add_action('comment_post', 'save_comment_hostip', 5);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement