{"id":74426,"date":"2022-04-28T13:00:27","date_gmt":"2022-04-28T17:00:27","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/from-very-old-code-geo-country-based-addvertisement-display\/"},"modified":"2022-04-28T13:00:27","modified_gmt":"2022-04-28T17:00:27","slug":"from-very-old-code-geo-country-based-addvertisement-display","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=74426","title":{"rendered":"From Very Old Code: Geo\/Country Based Addvertisement Display"},"content":{"rendered":"<p>&lt;?php<br \/>\nrequire_once &quot;geo\/geoip\/geoip.inc&quot;;<br \/>\nfunction main()<br \/>\n{<br \/>\nglobal $country, $ip, $currentTime;<br \/>\n$currentTime = time(); \/\/mktime();<br \/>\n$gi = geoip_open(&quot;geo\/geoip\/GeoIP.dat&quot;, GEOIP_STANDARD);<br \/>\n$ip = $_SERVER[<span style=\"color:rgb(163,21,21)\">&quot;REMOTE_ADDR&quot;<\/span>];<br \/>\n$country = geoip_country_code_by_addr($gi, $ip);<br \/>\n\/\/echo $country;<br \/>\ngeoip_close($gi);<br \/>\nsetcookie(&quot;geo&quot;, $country, time() + 15552000, &quot;\/&quot;, $base . $domain, 0); \/\/6 month cookie<br \/>\n$link = connect();<br \/>\ndisplayClientWebSite($ip, $country, $currentTime, $link);<br \/>\n}<\/p>\n<p>\/\/logic to decide whether to display a site or not<br \/>\n\/\/also display a site<\/p>\n<p>function displayClientWebSite($ip, $country, $currentTime, $link)<br \/>\n{<br \/>\n\/\/check if the ip is in our database<br \/>\n$sqlCheckIp = &quot; select * from ip_and_display_track where ip=&#8217;$ip&#8217; order by accessed desc limit 1&quot;;<br \/>\n$result = mysqli_query($link, $sqlCheckIp);<br \/>\nif (!$result) {<br \/>\n} else {<br \/>\nif (mysqli_num_rows($result) &gt; 0) {<br \/>\n$row = mysqli_fetch_assoc($result);<br \/>\n$accessed = $row[<span style=\"color:rgb(163,21,21)\">&#39;accessed&#39;<\/span>];<br \/>\nif (abs($currentTime &#8211; $accessed) &gt;= 0) {<br \/>\nrequire &#8216;geo\/campaign.php&#8217;;<br \/>\nexit;<br \/>\n} else {<br \/>\n\/\/die(&#8216;i am dead&#8217;);<br \/>\n\/\/exit;<br \/>\n}<br \/>\n} else {<br \/>\nrequire &#8216;geo\/campaign.php&#8217;;<br \/>\nexit;<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>\/* connect to database *\/<br \/>\nfunction connect()<br \/>\n{<br \/>\n\/\/ we connect to <a href=\"http:\/\/example.com\">example.com<\/a> and port 3307<br \/>\n$link = mysqli_connect(&#8216;localhost&#8217;, &quot;db&quot;, &quot;pass&quot;);<br \/>\nif (mysqli_connect_errno()) {<br \/>\ndie(&#8216;Could not connect: &#8216; . mysqli_connect_error());<br \/>\n}<\/p>\n<p>if (!mysqli_select_db($link, &quot;client_traffic&quot;)) {<br \/>\necho &quot;Unable to select mydbname: &quot; . mysqli_error($link);<br \/>\nexit;<br \/>\n}<\/p>\n<p>return $link;<br \/>\n}<\/p>\n<p>$country = &quot;&quot;;<br \/>\n$ip = &quot;&quot;;<br \/>\n$gi = &quot;&quot;;<br \/>\n$currentTime = &quot;&quot;;<br \/>\ntime();<br \/>\nmain();<br \/>\n\/*<br \/>\n* To change this template, choose Tools | Templates<br \/>\n* and open the template in the editor.<br \/>\n*\/<br \/>\n?&gt;<br \/>\n&lt;script src=&quot;\/\/<a href=\"http:\/\/rtb.adx1.com\/pixels\/pixel.js?id=166606&amp;event=conversion&amp;value=55\">rtb.adx1.com\/pixels\/pixel.js?id=166606&amp;event=conversion&amp;value=55<\/a>&quot;&gt;&lt;\/script&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php require_once &quot;geo\/geoip\/geoip.inc&quot;; function main() { global $country, $ip, $currentTime; $currentTime = time(); \/\/mktime(); $gi = geoip_open(&quot;geo\/geoip\/GeoIP.dat&quot;, GEOIP_STANDARD); $ip = $_SERVER[&quot;REMOTE_ADDR&quot;]; $country = geoip_country_code_by_addr($gi, $ip); \/\/echo $country; geoip_close($gi); setcookie(&quot;geo&quot;, $country, time() + 15552000, &quot;\/&quot;, $base . $domain, 0); \/\/6 month cookie $link = connect(); displayClientWebSite($ip, $country, $currentTime, $link); } \/\/logic to decide whether to display &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=74426\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[182],"tags":[],"class_list":["post-74426","post","type-post","status-publish","format-standard","hentry","category---blog","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69884,"url":"http:\/\/bangla.sitestree.com\/?p=69884","url_meta":{"origin":74426,"position":0},"title":"Razor, Web-page Model, Web-Application Development in C# #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"Razor, Web-page Model, Web-Application Development in C# Razor: a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = \"Hello World\"; } Inline expression or variable The message: @message Multi-statement block @{ var greeting\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70285,"url":"http:\/\/bangla.sitestree.com\/?p=70285","url_meta":{"origin":74426,"position":1},"title":"Razor, Web-page Model, Web-Application Development in C# #.Net Web Applications","author":"Author-Check- Article-or-Video","date":"August 31, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=1320&title=Razor,%20Web-page%20Model,%20Web-Application%20Development%20in%20C# (written long back) Razor, Web-page Model, Web-Application Development in C# Razor:a markup syntax to add server side code into ASP.net pages Razor example: Current time is @DateTime.Now Razor Code Syntax Single statement block @{ var message = \"Hello World\"; } Inline expression or variable The message: @message\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":78482,"url":"http:\/\/bangla.sitestree.com\/?p=78482","url_meta":{"origin":74426,"position":2},"title":"Understanding DNS on the Internet: Generic, Country, and Inverse Domains","author":"Sayed","date":"September 13, 2025","format":false,"excerpt":"Ref: AI Tools\/OpenAI\/ChatGPT Got it \ud83d\udc4d \u2014 here\u2019s a blog-ready, copyright-free article explaining DNS on the Internet, including generic domains, country domains, and the inverse domain. Understanding DNS on the Internet: Generic, Country, and Inverse Domains The Domain Name System (DNS) is often called the \u201cphonebook of the Internet.\u201d It\u2026","rel":"","context":"In &quot;Computer Networks&quot;","block_context":{"text":"Computer Networks","link":"http:\/\/bangla.sitestree.com\/?cat=1978"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/bangla.sitestree.com\/wp-content\/uploads\/2025\/09\/image-7.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":16105,"url":"http:\/\/bangla.sitestree.com\/?p=16105","url_meta":{"origin":74426,"position":3},"title":"GEO VISUALIZATION: Data Visualization","author":"Sayed","date":"September 6, 2019","format":false,"excerpt":"GEO VISUALIZATION spatial data https:\/\/searchsqlserver.techtarget.com\/definition\/spatial-data File:Latitude and Longitude of the Earth.svg https:\/\/en.wikipedia.org\/wiki\/File:Latitude_and_Longitude_of_the_Earth.svg Geographic coordinate system https:\/\/en.wikipedia.org\/wiki\/GWhy are all world maps wrong?eographic_coordinate_system How To Read GPS Coordinates https:\/\/www.ubergizmo.com\/how-to\/read-gps-coordinates\/ Geographic coordinate conversion https:\/\/en.wikipedia.org\/wiki\/Geographic_coordinate_conversion GPS coordinates converter https:\/\/www.gps-coordinates.net\/gps-coordinates-converter GPS coordinates converter https:\/\/www.gps-coordinates.net\/gps-coordinates-converter Map Projection https:\/\/en.wikipedia.org\/wiki\/Map_projection Why are all world maps wrong? https:\/\/www.quora.com\/Why-are-all-world-maps-wrong Map\u2026","rel":"","context":"In &quot;AI ML DS RL DL NN NLP Data Mining Optimization&quot;","block_context":{"text":"AI ML DS RL DL NN NLP Data Mining Optimization","link":"http:\/\/bangla.sitestree.com\/?cat=1910"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16321,"url":"http:\/\/bangla.sitestree.com\/?p=16321","url_meta":{"origin":74426,"position":4},"title":"Data Visualization Weekend Challenge: Go through all the resources mentioned in the following links.","author":"Sayed","date":"October 11, 2019","format":false,"excerpt":"Data Visualization Weekend Challenge: Go through all the resources mentioned in the following links. Learn the Concepts, and Implement\/try them in a Language\/Tool of your choice (also in demand). Irrespective, you go for Data Visualization Job or Go to study (Higher or not) Data Visualization - you will be very\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"http:\/\/bangla.sitestree.com\/?cat=1903"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8989,"url":"http:\/\/bangla.sitestree.com\/?p=8989","url_meta":{"origin":74426,"position":5},"title":"\u0985\u09cd\u09af\u09be\u09aa \u098f\u09ae \u098f\u09b2 \u09ae\u09cd\u09af\u09be\u09b8\u09c7\u099c (AppML Messages)","author":"Author-Check- Article-or-Video","date":"May 21, 2015","format":false,"excerpt":"\u09b0\u09bf\u09a6\u0993\u09df\u09be\u09a8 \u09ac\u09bf\u09a8 \u09b6\u09be\u09ae\u09c0\u09ae \u00a0 \u0985\u09cd\u09af\u09be\u09aa \u098f\u09ae \u098f\u09b2 \u09ae\u09cd\u09af\u09be\u09b8\u09c7\u099c \u098f\u09ac\u0982 \u0995\u09be\u09b0\u09cd\u09af\u09aa\u09cd\u09b0\u09a3\u09be\u09b2\u09c0 \u09af\u0996\u09a8 \u0985\u09cd\u09af\u09be\u09aa \u098f\u09ae \u098f\u09b2 \u0995\u09cb\u09a8\u0993 \u0995\u09be\u099c \u0995\u09b0\u09a4\u09c7 \u09af\u09be\u09df \u09a4\u0996\u09a8 \u098f\u099f\u09bf \u0995\u09a8\u09cd\u099f\u09cd\u09b0\u09cb\u09b2\u09be\u09b0\u09c7 \u098f\u0995\u099f\u09bf \u098f\u09aa\u09cd\u09b2\u09bf\u0995\u09c7\u09b6\u09a8 \u0985\u09ac\u099c\u09c7\u0995\u09cd\u099f ($appml) \u09aa\u09be\u09a0\u09be\u09df\u0964 \u098f\u09aa\u09cd\u09b2\u09bf\u0995\u09c7\u09b6\u09a8 \u0985\u09ac\u099c\u09c7\u0995\u09cd\u099f\u09c7\u09b0 \u098f\u0995\u099f\u09bf \u09ac\u09c8\u09b6\u09bf\u09b7\u09cd\u099f\u09cd\u09af \u09b9\u09b2 \u09ae\u09cd\u09af\u09be\u09b8\u09c7\u099c ($appml.message), \u09af\u09be \u098f\u09aa\u09cd\u09b2\u09bf\u0995\u09c7\u09b6\u09a8\u09c7\u09b0 \u0985\u09ac\u09b8\u09cd\u09a5\u09be \u09ac\u09b0\u09cd\u09a3\u09a8\u09be \u0995\u09b0\u09c7\u0964 \u098f\u0987 \u09ae\u09cd\u09af\u09be\u09b8\u09c7\u099c \u09aa\u09b0\u09c0\u0995\u09cd\u09b7\u09be \u0995\u09b0\u09c7 \u0995\u09be\u099c\u09c7\u09b0 \u09a7\u09b0\u09a3 \u0985\u09a8\u09c1\u09af\u09be\u09df\u09c0 \u099c\u09be\u09ad\u09be\u09b8\u09cd\u0995\u09cd\u09b0\u09bf\u09aa\u09cd\u099f \u0995\u09cb\u09a1 \u09ac\u09cd\u09af\u09ac\u09b9\u09be\u09b0 \u0995\u09b0\u09be \u09af\u09be\u09df\u0964\u2026","rel":"","context":"In &quot;AppML : Application Modeling Language&quot;","block_context":{"text":"AppML : Application Modeling Language","link":"http:\/\/bangla.sitestree.com\/?cat=796"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/74426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=74426"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/74426\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=74426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=74426"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=74426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}