{"id":516,"date":"2024-07-24T23:35:04","date_gmt":"2024-07-24T20:35:04","guid":{"rendered":"https:\/\/www.metinpolat.net\/blog\/?p=516"},"modified":"2024-07-24T23:35:39","modified_gmt":"2024-07-24T20:35:39","slug":"php-ile-ip-adresi-ogrenme","status":"publish","type":"post","link":"https:\/\/www.metinpolat.net\/blog\/php-ile-ip-adresi-ogrenme\/","title":{"rendered":"Php ile IP Adresi \u00d6\u011frenme"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PHP ile kullan\u0131c\u0131n\u0131n IP adresini almak i\u00e7in genellikle <code>$_SERVER<\/code> s\u00fcper global de\u011fi\u015fkeni kullan\u0131l\u0131r. A\u015fa\u011f\u0131da bu i\u015flemi nas\u0131l yapabilece\u011finizi g\u00f6steren basit bir \u00f6rnek bulunmaktad\u0131r:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\/\/ Kullan\u0131c\u0131n\u0131n IP adresini al\u0131r\n$ip_address = $_SERVER&#x5B;'REMOTE_ADDR'];\n\n\/\/ IP adresini ekrana yazd\u0131r\u0131r\necho &quot;Kullan\u0131c\u0131n\u0131n IP adresi: &quot; . $ip_address;\n?&gt;\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Bu kod, kullan\u0131c\u0131n\u0131n IP adresini al\u0131r ve ekrana yazd\u0131r\u0131r. Ancak, kullan\u0131c\u0131 bir proxy sunucusu veya load balancer (y\u00fck dengeleyici) \u00fczerinden ba\u011flan\u0131yorsa, <code>$_SERVER['REMOTE_ADDR']<\/code> kullan\u0131c\u0131n\u0131n ger\u00e7ek IP adresini vermeyebilir. Bu durumlarda, IP adresini elde etmek i\u00e7in ek kontrol ve do\u011frulama yapmak gerekebilir:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\nfunction getUserIP() {\n    if (isset($_SERVER&#x5B;'HTTP_CLIENT_IP']) &amp;&amp; !empty($_SERVER&#x5B;'HTTP_CLIENT_IP'])) {\n        $ip_address = $_SERVER&#x5B;'HTTP_CLIENT_IP'];\n    } elseif (isset($_SERVER&#x5B;'HTTP_X_FORWARDED_FOR']) &amp;&amp; !empty($_SERVER&#x5B;'HTTP_X_FORWARDED_FOR'])) {\n        $ip_address = $_SERVER&#x5B;'HTTP_X_FORWARDED_FOR'];\n    } else {\n        $ip_address = $_SERVER&#x5B;'REMOTE_ADDR'];\n    }\n    return $ip_address;\n}\n\n\/\/ Kullan\u0131c\u0131n\u0131n IP adresini al\u0131r\n$ip_address = getUserIP();\n\n\/\/ IP adresini ekrana yazd\u0131r\u0131r\necho &quot;Kullan\u0131c\u0131n\u0131n IP adresi: &quot; . $ip_address;\n?&gt;\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Bu kod, kullan\u0131c\u0131 IP adresini belirlemek i\u00e7in farkl\u0131 HTTP ba\u015fl\u0131klar\u0131n\u0131 kontrol eder ve daha g\u00fcvenilir bir sonu\u00e7 elde etmeye \u00e7al\u0131\u015f\u0131r. Ancak, HTTP ba\u015fl\u0131klar\u0131 kullan\u0131c\u0131 taraf\u0131ndan manip\u00fcle edilebilece\u011finden, elde edilen IP adresinin do\u011frulu\u011fu garanti edilemez.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP ile kullan\u0131c\u0131n\u0131n IP adresini almak i\u00e7in genellikle $_SERVER s\u00fcper global de\u011fi\u015fkeni kullan\u0131l\u0131r. A\u015fa\u011f\u0131da bu i\u015flemi nas\u0131l yapabilece\u011finizi g\u00f6steren basit bir \u00f6rnek bulunmaktad\u0131r: Bu kod, kullan\u0131c\u0131n\u0131n IP adresini al\u0131r ve ekrana yazd\u0131r\u0131r. Ancak, kullan\u0131c\u0131 bir proxy sunucusu veya load balancer (y\u00fck dengeleyici) \u00fczerinden ba\u011flan\u0131yorsa, $_SERVER[&#8216;REMOTE_ADDR&#8217;] kullan\u0131c\u0131n\u0131n ger\u00e7ek IP adresini vermeyebilir. Bu durumlarda, IP adresini elde [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":517,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,23],"tags":[42,31],"class_list":["post-516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-yazilim","tag-ip-adres","tag-php"],"_links":{"self":[{"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/posts\/516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/comments?post=516"}],"version-history":[{"count":2,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/posts\/516\/revisions\/519"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/media\/517"}],"wp:attachment":[{"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.metinpolat.net\/blog\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}