From a8146b2d5f5450e9ac1a3dea41fef8fb9f860bdf Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Thu, 19 Aug 2021 16:14:37 +0800 Subject: [PATCH] refactor: delete qcloud captcha --- inc/theme-core.php | 150 ++++----------------------------------------- 1 file changed, 12 insertions(+), 138 deletions(-) diff --git a/inc/theme-core.php b/inc/theme-core.php index 08ca987..472d9d4 100644 --- a/inc/theme-core.php +++ b/inc/theme-core.php @@ -1,11 +1,13 @@ * @license MIT License - * @version 2021.07.01 + * @version 2021.08.19 */ +// CDN 资源地址 if (kratos_option('g_cdn', false)) { $asset_path = 'https://cdn.jsdelivr.net/gh/vtrois/kratos@' . THEME_VERSION; } else { @@ -100,7 +102,7 @@ function theme_autoload() add_action('wp_enqueue_scripts', 'theme_autoload'); // 前台管理员导航 -if (! kratos_option('g_adminbar', true)) { +if (!kratos_option('g_adminbar', true)) { add_filter('show_admin_bar', '__return_false'); } @@ -214,7 +216,7 @@ if (kratos_option('g_removeimgsize', false)) { return $sizes; } add_filter('intermediate_image_sizes_advanced', 'remove_default_images'); - + remove_image_size('1536x1536'); remove_image_size('2048x2048'); } @@ -270,22 +272,19 @@ if (kratos_option('g_search', false)) { function search_enhancement($search, $wp_query) { - if (!empty($search) && !empty($wp_query->query_vars['search_terms'])) - { + if (!empty($search) && !empty($wp_query->query_vars['search_terms'])) { global $wpdb; - - $q = $wp_query->query_vars; + + $q = $wp_query->query_vars; $n = !empty($q['exact']) ? '' : '%'; - + $search = array(); - foreach ((array)$q['search_terms'] as $term) - { - $search[] = $wpdb->prepare("$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n); + foreach ((array)$q['search_terms'] as $term) { + $search[] = $wpdb->prepare("$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like($term) . $n); } - if (!is_user_logged_in()) - { + if (!is_user_logged_in()) { $search[] = "$wpdb->posts.post_password = ''"; } @@ -295,128 +294,3 @@ if (kratos_option('g_search', false)) { return $search; } } - -// 腾讯云验证码 -if (kratos_option('g_007', false)) { - add_action('login_head', 'add_login_head'); - function add_login_head() - { - echo ''; - } - - add_action('login_form', 'add_captcha_body'); - function add_captcha_body(){ ?> - - - - - - - $appid, - "AppSecretKey" => $appsecretkey, - "Ticket" => $ticket, - "Randstr" => $randstr, - "UserIP" => $userip - ); - $paramstring = http_build_query($params); - $content = txcurl($url, $paramstring); - $result = json_decode($content, true); - - if($result){ - if($result['response'] == 1){ - return array( - 'result' => 1, - 'message' => '' - ); - }else{ - return array( - 'result' => 0, - 'message' => $result['err_msg'] - ); - } - }else{ - return array( - 'result' => 0, - 'message' => '错误:请求异常,请稍后再试' - ); - } - } - - function txcurl($url, $params=false, $ispost=0) - { - $httpInfo = array(); - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); - curl_setopt($ch, CURLOPT_TIMEOUT, 60); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - - if($ispost) - { - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); - curl_setopt($ch, CURLOPT_URL, $url); - }else{ - if($params) - { - curl_setopt($ch, CURLOPT_URL, $url . '?' . $params); - }else{ - curl_setopt($ch, CURLOPT_URL, $url); - } - } - - $response = curl_exec($ch); - - if ($response === FALSE) - { - return false; - } - - $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $httpInfo = array_merge($httpInfo, curl_getinfo($ch)); - - curl_close($ch); - return $response; - } -}