{"id":1152,"date":"2021-01-05T16:16:40","date_gmt":"2021-01-05T10:46:40","guid":{"rendered":"https:\/\/myfreeonlinetools.com\/blog\/?p=1152"},"modified":"2021-01-05T16:19:24","modified_gmt":"2021-01-05T10:49:24","slug":"how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php","status":"publish","type":"post","link":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/","title":{"rendered":"Block a specific IP Address to execute, run rest code and View the Website or Web page"},"content":{"rendered":"<p>Sometimes we need to stop some specified IP Addresses to block the execute the code or stop to view our website or code so that I wrote that PHP code its help to doing that.<\/p>\n<p>By this code, you can also stop the spamming from any hacker IP Address, if you find the IP Address of the Spammer or hacker they can not make spam on your website or contact form. I also wrote this code when someone create spamming on my contact us page form after validation he successfully create spamming and I got 1000 spamming emails. With this code, I block that IP address and stop the code execution<\/p>\n<pre>&lt;!doctype html&gt;\r\n\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Page Title&lt;\/title&gt;\r\n&lt;meta charset=\"UTF-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"initial-scale=1.0\"&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;?php \r\n\r\n$ip = $_SERVER['REMOTE_ADDR'];\r\n\r\n$data = unserialize(file_get_contents('http:\/\/www.geoplugin.net\/php.gp?ip='.$ip));\r\n\r\n$ClientState = $data['geoplugin_city'];\r\n$ClientIPAddress = $data['geoplugin_request'];;\r\n\r\necho $ClientIPAddress; \r\n\r\nif($ClientIPAddress == '156.96.46.226'){\r\n\r\nexit(); \r\n\r\n}else{\r\necho 'Sorry We Offline know.';\r\n}\r\n\r\n?&gt;\r\n\r\n&lt;h1&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a>&lt;\/h1&gt;\r\n&lt;h2&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a> &lt;\/h2&gt;\r\n&lt;h3&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a>&lt;\/h3&gt;\r\n&lt;h4&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a>&lt;\/h4&gt;\r\n&lt;h5&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a>&lt;\/h5&gt;\r\n&lt;h6&gt;This PHP Code help to stop excuited code when Speicifed IP Address is dedected. <a href=\"https:\/\/myfreeonlinetools.com\/\">MyFreeOnlineTools<\/a>&lt;\/h6&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>Above I used GeoPlugin to find IP Location and IP Address Details it&#8217;s free to use. Link below<\/p>\n<p>https:\/\/www.geoplugin.com\/<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to stop some specified IP Addresses to block the execute the code or stop to view our website or code so that I wrote that PHP code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[18,29],"tags":[],"class_list":["post-1152","post","type-post","status-publish","format-standard","hentry","category-blog","category-php"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools<\/title>\n<meta name=\"description\" content=\"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools\" \/>\n<meta property=\"og:description\" content=\"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP\" \/>\n<meta property=\"og:url\" content=\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\" \/>\n<meta property=\"og:site_name\" content=\"MyFreeOnlineTools\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/LearnSchoolOnline\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-05T10:46:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-05T10:49:24+00:00\" \/>\n<meta name=\"author\" content=\"myfreeonlinetools\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"myfreeonlinetools\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\"},\"author\":{\"name\":\"myfreeonlinetools\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/b1eb72e57c554e3b33cfeec477efcc3c\"},\"headline\":\"Block a specific IP Address to execute, run rest code and View the Website or Web page\",\"datePublished\":\"2021-01-05T10:46:40+00:00\",\"dateModified\":\"2021-01-05T10:49:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\"},\"wordCount\":151,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#organization\"},\"articleSection\":[\"Blog\",\"PHP\"],\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\",\"url\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\",\"name\":\"Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools\",\"isPartOf\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#website\"},\"datePublished\":\"2021-01-05T10:46:40+00:00\",\"dateModified\":\"2021-01-05T10:49:24+00:00\",\"description\":\"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP\",\"breadcrumb\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/myfreeonlinetools.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Block a specific IP Address to execute, run rest code and View the Website or Web page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#website\",\"url\":\"https:\/\/myfreeonlinetools.com\/blog\/\",\"name\":\"MyFreeOnlineTools\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/myfreeonlinetools.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#organization\",\"name\":\"MyFreeOnlineTools\",\"url\":\"https:\/\/myfreeonlinetools.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/myfreeonlinetools.com\/blog\/wp-content\/uploads\/2019\/11\/myfreeonlinetools-blue.png\",\"contentUrl\":\"https:\/\/myfreeonlinetools.com\/blog\/wp-content\/uploads\/2019\/11\/myfreeonlinetools-blue.png\",\"width\":387,\"height\":79,\"caption\":\"MyFreeOnlineTools\"},\"image\":{\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/b1eb72e57c554e3b33cfeec477efcc3c\",\"name\":\"myfreeonlinetools\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b870b17c6c7e3b75d7fe0b8bebfc9cf5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b870b17c6c7e3b75d7fe0b8bebfc9cf5?s=96&d=mm&r=g\",\"caption\":\"myfreeonlinetools\"},\"description\":\"Live in Delhi, Working in Gurgaon as Web Designer and Graphic Designer. Developed and Design myfreeonlinetools for online free tools. Also having youtube channel Name with LearnSchoolOnline. Traveling, watching movies, coding are the hobbies.\",\"sameAs\":[\"https:\/\/myfreeonlinetools.com\/\",\"https:\/\/www.facebook.com\/LearnSchoolOnline\/\",\"https:\/\/www.youtube.com\/learnschoolonline\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools","description":"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/","og_locale":"en_US","og_type":"article","og_title":"Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools","og_description":"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP","og_url":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/","og_site_name":"MyFreeOnlineTools","article_author":"https:\/\/www.facebook.com\/LearnSchoolOnline\/","article_published_time":"2021-01-05T10:46:40+00:00","article_modified_time":"2021-01-05T10:49:24+00:00","author":"myfreeonlinetools","twitter_card":"summary_large_image","twitter_misc":{"Written by":"myfreeonlinetools","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#article","isPartOf":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/"},"author":{"name":"myfreeonlinetools","@id":"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/b1eb72e57c554e3b33cfeec477efcc3c"},"headline":"Block a specific IP Address to execute, run rest code and View the Website or Web page","datePublished":"2021-01-05T10:46:40+00:00","dateModified":"2021-01-05T10:49:24+00:00","mainEntityOfPage":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/"},"wordCount":151,"commentCount":0,"publisher":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/#organization"},"articleSection":["Blog","PHP"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/","url":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/","name":"Block a specific IP Address to execute, run rest code and View the Website or Web page - MyFreeOnlineTools","isPartOf":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/#website"},"datePublished":"2021-01-05T10:46:40+00:00","dateModified":"2021-01-05T10:49:24+00:00","description":"How Block a specific IP Address to execute, run rest of code and View the Website or Web page by help of PHP","breadcrumb":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/myfreeonlinetools.com\/blog\/how-to-block-a-specific-ip-address-to-execute-and-view-the-website-or-web-page-by-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/myfreeonlinetools.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Block a specific IP Address to execute, run rest code and View the Website or Web page"}]},{"@type":"WebSite","@id":"https:\/\/myfreeonlinetools.com\/blog\/#website","url":"https:\/\/myfreeonlinetools.com\/blog\/","name":"MyFreeOnlineTools","description":"","publisher":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/myfreeonlinetools.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/myfreeonlinetools.com\/blog\/#organization","name":"MyFreeOnlineTools","url":"https:\/\/myfreeonlinetools.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/myfreeonlinetools.com\/blog\/wp-content\/uploads\/2019\/11\/myfreeonlinetools-blue.png","contentUrl":"https:\/\/myfreeonlinetools.com\/blog\/wp-content\/uploads\/2019\/11\/myfreeonlinetools-blue.png","width":387,"height":79,"caption":"MyFreeOnlineTools"},"image":{"@id":"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/b1eb72e57c554e3b33cfeec477efcc3c","name":"myfreeonlinetools","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/myfreeonlinetools.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b870b17c6c7e3b75d7fe0b8bebfc9cf5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b870b17c6c7e3b75d7fe0b8bebfc9cf5?s=96&d=mm&r=g","caption":"myfreeonlinetools"},"description":"Live in Delhi, Working in Gurgaon as Web Designer and Graphic Designer. Developed and Design myfreeonlinetools for online free tools. Also having youtube channel Name with LearnSchoolOnline. Traveling, watching movies, coding are the hobbies.","sameAs":["https:\/\/myfreeonlinetools.com\/","https:\/\/www.facebook.com\/LearnSchoolOnline\/","https:\/\/www.youtube.com\/learnschoolonline"]}]}},"_links":{"self":[{"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/1152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/comments?post=1152"}],"version-history":[{"count":0,"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/1152\/revisions"}],"wp:attachment":[{"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/media?parent=1152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/categories?post=1152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myfreeonlinetools.com\/blog\/wp-json\/wp\/v2\/tags?post=1152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}