{"id":210425,"date":"2023-12-22T03:40:26","date_gmt":"2023-12-21T19:40:26","guid":{"rendered":"https:\/\/www.idc.net\/help\/210425\/"},"modified":"2023-12-22T03:40:26","modified_gmt":"2023-12-21T19:40:26","slug":"wordpress%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e9%99%90%e5%88%b6%e7%99%bb%e5%bd%95%e5%b0%9d%e8%af%95%e6%ac%a1%e6%95%b0%e3%80%82","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/210425\/","title":{"rendered":"WordPress\u5b89\u5168\u7b56\u7565\uff1a\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u3002"},"content":{"rendered":"<p><title id=\"wordpress%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e9%99%90%e5%88%b6%e7%99%bb%e5%bd%95%e5%b0%9d%e8%af%95%e6%ac%a1%e6%95%b0-AHjtDMGiTK\">WordPress\u5b89\u5168\u7b56\u7565\uff1a\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570<\/title><\/p>\n<h1 id=\"wordpress%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e9%99%90%e5%88%b6%e7%99%bb%e5%bd%95%e5%b0%9d%e8%af%95%e6%ac%a1%e6%95%b0-AHjtDMGiTK\">WordPress\u5b89\u5168\u7b56\u7565\uff1a\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570<\/h1>\n<p>WordPress\u662f\u76ee\u524d\u6700\u53d7\u6b22\u8fce\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\u4e4b\u4e00\uff0c\u4f46\u5b83\u4e5f\u662f\u9ed1\u5ba2\u653b\u51fb\u7684\u4e3b\u8981\u76ee\u6807\u4e4b\u4e00\u3002\u4e3a\u4e86\u4fdd\u62a4\u60a8\u7684WordPress\u7f51\u7ad9\u514d\u53d7\u6076\u610f\u767b\u5f55\u5c1d\u8bd5\u7684\u5f71\u54cd\uff0c\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u662f\u4e00\u79cd\u6709\u6548\u7684\u5b89\u5168\u7b56\u7565\u3002<\/p>\n<h2 id=\"%e4%b8%ba%e4%bb%80%e4%b9%88%e9%99%90%e5%88%b6%e7%99%bb%e5%bd%95%e5%b0%9d%e8%af%95%e6%ac%a1%e6%95%b0%e5%be%88%e9%87%8d%e8%a6%81%ef%bc%9f-AHjtDMGiTK\">\u4e3a\u4ec0\u4e48\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u5f88\u91cd\u8981\uff1f<\/h2>\n<p>\u6076\u610f\u767b\u5f55\u5c1d\u8bd5\u662f\u6307\u9ed1\u5ba2\u4f7f\u7528\u81ea\u52a8\u5316\u5de5\u5177\u5c1d\u8bd5\u4f7f\u7528\u4e0d\u540c\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u7ec4\u5408\u6765\u767b\u5f55\u60a8\u7684WordPress\u7f51\u7ad9\u3002\u4ed6\u4eec\u5e0c\u671b\u901a\u8fc7\u731c\u6d4b\u6b63\u786e\u7684\u51ed\u636e\u6765\u83b7\u53d6\u5bf9\u60a8\u7f51\u7ad9\u7684\u8bbf\u95ee\u6743\u9650\u3002\u5982\u679c\u60a8\u6ca1\u6709\u91c7\u53d6\u4efb\u4f55\u63aa\u65bd\u6765\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\uff0c\u9ed1\u5ba2\u53ef\u4ee5\u4e0d\u65ad\u5c1d\u8bd5\u4e0d\u540c\u7684\u7ec4\u5408\uff0c\u76f4\u5230\u4ed6\u4eec\u6210\u529f\u767b\u5f55\u4e3a\u6b62\u3002<\/p>\n<p>\u901a\u8fc7\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u963b\u6b62\u9ed1\u5ba2\u7684\u81ea\u52a8\u5316\u5de5\u5177\uff0c\u5e76\u589e\u52a0\u4ed6\u4eec\u6210\u529f\u767b\u5f55\u7684\u96be\u5ea6\u3002\u8fd9\u79cd\u5b89\u5168\u7b56\u7565\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u60a8\u7684WordPress\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e9%99%90%e5%88%b6%e7%99%bb%e5%bd%95%e5%b0%9d%e8%af%95%e6%ac%a1%e6%95%b0-AHjtDMGiTK\">\u5982\u4f55\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570<\/h2>\n<p>\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\uff0c\u4e0b\u9762\u662f\u5176\u4e2d\u4e24\u79cd\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8%e6%8f%92%e4%bb%b6-AHjtDMGiTK\">1. \u4f7f\u7528\u63d2\u4ef6<\/h3>\n<p>WordPress\u6709\u8bb8\u591a\u5b89\u5168\u63d2\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u60a8\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u3002\u5176\u4e2d\u4e00\u79cd\u5e38\u7528\u7684\u63d2\u4ef6\u662fLimit Login Attempts Reloaded\u3002\u8fd9\u4e2a\u63d2\u4ef6\u5141\u8bb8\u60a8\u8bbe\u7f6e\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u7684\u9650\u5236\uff0c\u5e76\u5728\u8fbe\u5230\u9650\u5236\u65f6\u6682\u65f6\u9501\u5b9a\u7528\u6237\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728WordPress\u4e2d\u5b89\u88c5\u548c\u914d\u7f6eLimit Login Attempts Reloaded\u63d2\u4ef6\uff1a<\/p>\n<ol>\n<li>\u767b\u5f55\u5230\u60a8\u7684WordPress\u4eea\u8868\u677f\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u201c\u63d2\u4ef6\u201d&gt;\u201c\u5b89\u88c5\u63d2\u4ef6\u201d\u3002<\/li>\n<li>\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165\u201cLimit Login Attempts Reloaded\u201d\u3002<\/li>\n<li>\u627e\u5230\u63d2\u4ef6\u5e76\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201c\u6fc0\u6d3b\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u201c\u8bbe\u7f6e\u201d&gt;\u201c\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u201d\u3002<\/li>\n<li>\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u7684\u9650\u5236\u548c\u9501\u5b9a\u65f6\u95f4\u3002<\/li>\n<\/ol>\n<h3 id=\"2-%e4%bf%ae%e6%94%b9wordpress%e4%b8%bb%e9%a2%98%e7%9a%84functions-php%e6%96%87%e4%bb%b6-AHjtDMGiTK\">2. \u4fee\u6539WordPress\u4e3b\u9898\u7684functions.php\u6587\u4ef6<\/h3>\n<p>\u5982\u679c\u60a8\u4e0d\u60f3\u4f7f\u7528\u63d2\u4ef6\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539WordPress\u4e3b\u9898\u7684functions.php\u6587\u4ef6\u6765\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff1a<\/p>\n<pre><code>&lt;?php\nfunction limit_login_attempts() {\n    $login_attempts = get_option( 'login_attempts', array() );\n    $ip_address = $_SERVER['REMOTE_ADDR'];\n    $current_time = time();\n    \n    \/\/ Remove old login attempts\n    foreach ( $login_attempts as $ip =&gt; $attempts ) {\n        if ( $current_time - $attempts['time'] &gt; 3600 ) {\n            unset( $login_attempts[$ip] );\n        }\n    }\n    \n    \/\/ Check if IP address is locked\n    if ( isset( $login_attempts[$ip_address] ) &amp;&amp; $current_time - $login_attempts[$ip_address]['time'] &lt; 3600 ) {\n        wp_die( '\u60a8\u5df2\u7ecf\u5c1d\u8bd5\u767b\u5f55\u592a\u591a\u6b21\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002' );\n    }\n    \n    \/\/ Add new login attempt\n    $login_attempts[$ip_address] = array(\n        'time' =&gt; $current_time,\n        'count' =&gt; isset( $login_attempts[$ip_address] ) ? $login_attempts[$ip_address]['count'] + 1 : 1,\n    );\n    \n    update_option( 'login_attempts', $login_attempts );\n}\nadd_action( 'wp_login_failed', 'limit_login_attempts' );\n?&gt;<\/code><\/pre>\n<p>\u5c06\u4e0a\u8ff0\u4ee3\u7801\u6dfb\u52a0\u5230\u60a8\u7684WordPress\u4e3b\u9898\u7684functions.php\u6587\u4ef6\u4e2d\uff0c\u4fdd\u5b58\u5e76\u4e0a\u4f20\u5230\u60a8\u7684\u670d\u52a1\u5668\u3002\u8fd9\u5c06\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\u4e3a\u6bcf\u5c0f\u65f6\u4e00\u6b21\uff0c\u5e76\u5728\u8fbe\u5230\u9650\u5236\u65f6\u663e\u793a\u4e00\u6761\u9519\u8bef\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-AHjtDMGiTK\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u62a4\u60a8\u7684WordPress\u7f51\u7ad9\u514d\u53d7\u6076\u610f\u767b\u5f55\u5c1d\u8bd5\u7684\u5f71\u54cd\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u63d2\u4ef6\u6216\u4fee\u6539WordPress\u4e3b\u9898\u7684functions.php\u6587\u4ef6\u6765\u5b9e\u73b0\u8fd9\u4e2a\u5b89\u5168\u7b56\u7565\u3002\u9009\u62e9\u9002\u5408\u60a8\u7684\u65b9\u6cd5\uff0c\u5e76\u786e\u4fdd\u60a8\u7684WordPress\u7f51\u7ad9\u59cb\u7ec8\u4fdd\u6301\u5b89\u5168\u3002<\/p>\n<h3 id=\"%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%a6%96%e9%80%89%e5%90%8e%e6%b5%aa%e4%ba%91-AHjtDMGiTK\">\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u63d0\u4f9b\u5546\uff0c\u540e\u6d6a\u4e91\u662f\u60a8\u7684\u9996\u9009\u3002\u540e\u6d6a\u4e91\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u4e3a\u60a8\u7684\u7f51\u7ad9\u63d0\u4f9b\u7a33\u5b9a\u7684\u6258\u7ba1\u73af\u5883\u3002\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95ee<a href=\"https:\/\/idc.net\">\u540e\u6d6a\u4e91\u5b98\u7f51<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u5b89\u5168\u7b56\u7565\uff1a\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570 WordPress\u5b89\u5168\u7b56\u7565\uff1a\u9650\u5236\u767b\u5f55\u5c1d\u8bd5\u6b21\u6570 WordPress [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"class_list":["post-210425","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/210425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=210425"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/210425\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=210425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=210425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=210425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}