{"id":5200,"date":"2025-12-01T16:34:59","date_gmt":"2025-12-01T16:34:59","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=5200"},"modified":"2025-12-01T16:35:31","modified_gmt":"2025-12-01T16:35:31","slug":"get-client-ip-address","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/platforms\/cloudflare\/user-information\/get-client-ip-address","title":{"rendered":"Get client IP address"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\n\/\/*******************************************\n\/\/*******************************************\n\/\/********** GET CLIENT IP ADDRESS **********\n\/\/*******************************************\n\/\/*******************************************\nfunction GetClientIpAddress()\n{\n  \/\/Cloudflare real client IP header\n  if(!empty($_SERVER&#91;\"HTTP_CF_CONNECTING_IP\"]))\n  {\n    return $_SERVER&#91;\"HTTP_CF_CONNECTING_IP\"];\n  }\n\n  \/\/Generic reverse proxy header (first IP in list)\n  if(!empty($_SERVER&#91;\"HTTP_X_FORWARDED_FOR\"]))\n  {\n    $Parts = explode(\",\", $_SERVER&#91;\"HTTP_X_FORWARDED_FOR\"]);\n    $Ip    = trim($Parts&#91;0]);\n    if(filter_var($Ip, FILTER_VALIDATE_IP))\n    {\n      return $Ip;\n    }\n  }\n\n  \/\/Fallback: direct connection\n  if(!empty($_SERVER&#91;\"REMOTE_ADDR\"]) &amp;&amp; filter_var($_SERVER&#91;\"REMOTE_ADDR\"], FILTER_VALIDATE_IP))\n  {\n    return $_SERVER&#91;\"REMOTE_ADDR\"];\n  }\n\n  return NULL;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[389],"tags":[],"class_list":["post-5200","post","type-post","status-publish","format-standard","hentry","category-user-information"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=5200"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5200\/revisions"}],"predecessor-version":[{"id":5202,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5200\/revisions\/5202"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=5200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=5200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=5200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}