From 726d8f87b352b8203dcd47a7aa45005b7fd8e7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= <45513686+haoziz@users.noreply.github.com> Date: Mon, 4 May 2020 11:02:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.WordPress风格的设置页面 2.使用Nonce防止CSRF --- index.php | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 735f6a1..1ff89ce 100644 --- a/index.php +++ b/index.php @@ -142,16 +142,158 @@ class WP_CHINA_YES { } public function settings() { - $setting_page_url = plugins_url('settings.html', __FILE__) . '?v=2.2.0'; echo << - +
+

WP-China-Yes

+ + +

这是一个开源项目,她需要每个人的支持和贡献才能健康长久的发展。
项目地址:GitHub

+
+ EOT; } public function set_cookie() { - if ( ! isset($_COOKIE['wp-china-yes']) && current_user_can('manage_options')) { + if (current_user_can('manage_options')) { setcookie('wp-china-yes', json_encode([ 'get_config' => wp_create_nonce('wpcy_get_config'), 'set_config' => wp_create_nonce('wpcy_set_config') @@ -160,10 +302,12 @@ EOT; } public function get_config() { + check_ajax_referer('wpcy_get_config'); self::success('', $this->wp_china_yes_options); } public function set_config() { + check_ajax_referer('wpcy_set_config'); if ( ! array_key_exists('community', $_POST) || ( ! array_key_exists('custom_api_server', $_POST) && ! array_key_exists('custom_download_server', $_POST))) { self::error('参数错误', - 1);