{"id":2439,"date":"2012-06-01T12:13:37","date_gmt":"2012-06-01T12:13:37","guid":{"rendered":"http:\/\/nycphantom.com\/journal\/?p=2439"},"modified":"2012-06-01T12:13:37","modified_gmt":"2012-06-01T12:13:37","slug":"ban-proxy-users","status":"publish","type":"post","link":"http:\/\/nycphantom.com\/journal\/?p=2439","title":{"rendered":"Ban proxy users"},"content":{"rendered":"<p>\nNow, looks like many spammers love to use proxy to put ads in people's sites under the comments section. By using proxy, shows that these don't mind revisiting the same site eventhough the site is aware of their spamming and banning them. As long as they get to put the ad, it would look like they've done their task and very likely are getting paid for that.\n<\/p>\n<p>\nSince proxy servers mostly use a kind of protocol, the majority of such usage can be blocked using simple coding. In .htaccess or <a href=\"http:\/\/psoug.org\/snippet\/PHP-Ban-Proxy-Servers_23.htm\" target=\"_blank\">php<\/a>. I opted for php because it is much simpler:\n<\/p>\n<p>\n<span><\/span>\n<\/p>\n<div id=\"cblock\" style=\"width: 540px; height: 100%; overflow: auto\">\n<pre class=\"php\" style=\"font-family: monospace; background: none repeat scroll 0% 0% #fefefe\">\r\n<span style=\"font-weight: bold; color: #000000\">&lt;?PHP<\/span>\r\n&nbsp;\r\n<span style=\"color: #b1b100\">IF<\/span><span style=\"color: #009900\">(<\/span><a href=\"http:\/\/www.php.net\/isset\"><span style=\"color: #990000\">ISSET<\/span><\/a><span style=\"color: #009900\">(<\/span><span style=\"color: #000088\">$_SERVER<\/span><span style=\"color: #009900\">[<\/span><span style=\"color: #0000ff\">'HTTP_X_FORWARDED_FOR'<\/span><span style=\"color: #009900\">]<\/span><span style=\"color: #009900\">)<\/span> <span style=\"color: #339933\">||<\/span> <span style=\"color: #009900\">(<\/span><span style=\"color: #000088\">$_SERVER<\/span><span style=\"color: #009900\">[<\/span><span style=\"color: #0000ff\">'HTTP_USER_AGENT'<\/span><span style=\"color: #009900\">]<\/span><span style=\"color: #339933\">==<\/span><span style=\"color: #0000ff\">''<\/span><span style=\"color: #009900\">)<\/span> <span style=\"color: #339933\">||<\/span> <span style=\"color: #009900\">(<\/span><span style=\"color: #000088\">$_SERVER<\/span><span style=\"color: #009900\">[<\/span><span style=\"color: #0000ff\">'HTTP_VIA'<\/span><span style=\"color: #009900\">]<\/span><span style=\"color: #339933\">!=<\/span><span style=\"color: #0000ff\">''<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #009900\">{<\/span>\r\n<a href=\"http:\/\/www.php.net\/die\"><span style=\"color: #990000\">DIE<\/span><\/a><span style=\"color: #009900\">(<\/span><span style=\"color: #0000ff\">&quot;Proxy servers not allowed.&quot;<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #339933\">;<\/span>\r\n<span style=\"color: #009900\">}<\/span>\r\n&nbsp;\r\n<span style=\"color: #000088\">$proxy_headers<\/span> <span style=\"color: #339933\">=<\/span> <a href=\"http:\/\/www.php.net\/array\"><span style=\"color: #990000\">ARRAY<\/span><\/a><span style=\"color: #009900\">(<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_VIA'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_X_FORWARDED_FOR'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_FORWARDED_FOR'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_X_FORWARDED'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_FORWARDED'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_CLIENT_IP'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_FORWARDED_FOR_IP'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'VIA'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'X_FORWARDED_FOR'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'FORWARDED_FOR'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'X_FORWARDED'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'FORWARDED'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'CLIENT_IP'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'FORWARDED_FOR_IP'<\/span><span style=\"color: #339933\">,<\/span>   \r\n<span style=\"color: #0000ff\">'HTTP_PROXY_CONNECTION'<\/span>   \r\n<span style=\"color: #009900\">)<\/span><span style=\"color: #339933\">;<\/span>\r\n<span style=\"color: #b1b100\">FOREACH<\/span><span style=\"color: #009900\">(<\/span><span style=\"color: #000088\">$proxy_headers<\/span> <span style=\"color: #b1b100\">AS<\/span> <span style=\"color: #000088\">$x<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #009900\">{<\/span>\r\n<span style=\"color: #b1b100\">IF<\/span> <span style=\"color: #009900\">(<\/span><a href=\"http:\/\/www.php.net\/isset\"><span style=\"color: #990000\">ISSET<\/span><\/a><span style=\"color: #009900\">(<\/span><span style=\"color: #000088\">$_SERVER<\/span><span style=\"color: #009900\">[<\/span><span style=\"color: #000088\">$x<\/span><span style=\"color: #009900\">]<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #009900\">)<\/span> <a href=\"http:\/\/www.php.net\/die\"><span style=\"color: #990000\">DIE<\/span><\/a><span style=\"color: #009900\">(<\/span><span style=\"color: #0000ff\">&quot;You are using a proxy.&quot;<\/span><span style=\"color: #009900\">)<\/span><span style=\"color: #339933\">;<\/span>\r\n<a href=\"http:\/\/www.php.net\/exit\"><span style=\"color: #990000\">EXIT<\/span><\/a><span style=\"color: #339933\">;<\/span>\r\n<span style=\"color: #009900\">}<\/span>\r\n&nbsp;\r\n<span style=\"font-weight: bold; color: #000000\">?&gt;<\/span>\r\n<\/pre>\n<\/div>\n<p>\n&nbsp;\n<\/p>\n<p>\nAfter this, I made a few modification, to have a counter for each of the 2 cases. <span style=\"font-size: xx-small; color: #808080\"><em>This is most efficient against those who use proxy in their own browsers.<\/em><\/span>\n<\/p>\n<p>\nAs for the rest, I may have to disable url in the comments in the future, because I do keep a spammer free site.\n<\/p>\n<p>\nThese spammers are really restless, in spite of the Captcha implementation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now, looks like many spammers love to use proxy to put ads in people's sites under the comments section. By using proxy, shows that these don't mind revisiting the same site eventhough the site is aware of their spamming and &hellip; <a href=\"http:\/\/nycphantom.com\/journal\/?p=2439\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2439","post","type-post","status-publish","format-standard","hentry","category-technical"],"_links":{"self":[{"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=\/wp\/v2\/posts\/2439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2439"}],"version-history":[{"count":0,"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=\/wp\/v2\/posts\/2439\/revisions"}],"wp:attachment":[{"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2439"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nycphantom.com\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}