diff --git a/functions.php b/functions.php index 1810e82..f832fe6 100644 --- a/functions.php +++ b/functions.php @@ -1620,12 +1620,16 @@ function change_avatar($avatar){ if ($comment) { if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true )){ $qq_number = get_comment_meta( $comment->comment_ID, 'new_field_qq', true ); - if(akina_option('qq_avatar_link')){ + if(akina_option('qq_avatar_link')=='off'){ + return '😀'; + }elseif(akina_option('qq_avatar_link')=='type_3'){ + $qqavatar = file_get_contents('http://ptlogin2.qq.com/getface?appid=1006102&imgtype=3&uin='.$qq_number); + preg_match('/:\"([^\"]*)\"/i',$qqavatar,$matches); + return '😀'; + }else{ openssl_public_encrypt($qq_number, $encrypted, openssl_pkey_get_public($sakura_pubkey)); $qq_number = urlencode(base64_encode($encrypted)); return '😀'; - }else{ - return '😀'; } }else{ return $avatar ; diff --git a/inc/api.php b/inc/api.php index 20db90c..ef77961 100644 --- a/inc/api.php +++ b/inc/api.php @@ -449,6 +449,7 @@ function update_database() { /** * QQ头像链接解密 + * https://sakura.2heng.xin/wp-json/sakura/v1/qqinfo/avatar */ function get_qq_avatar(){ global $sakura_privkey; @@ -457,8 +458,15 @@ function get_qq_avatar(){ openssl_private_decrypt($encrypted, $qq_number, openssl_pkey_get_private($sakura_privkey)); preg_match('/^\d{3,}$/', $qq_number, $matches); $imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100'; - $response = new WP_REST_Response(); - $response->set_status(302); - $response->header('Location', $imgurl); - return $response; + if(akina_option('qq_avatar_link')=='off'){ + $imgdata = file_get_contents($imgurl); + header("Content-type: image/jpeg"); + echo $imgdata; + }else{ + $response = new WP_REST_Response(); + $response->set_status(302); + $response->header('Location', $imgurl); + return $response; + } + } diff --git a/manifest/README.md b/manifest/README.md index c34eb2b..2209345 100644 --- a/manifest/README.md +++ b/manifest/README.md @@ -24,6 +24,8 @@ pip3 install Pillow pip install Pillow --user ``` +用同样的方法安装`requests`、`pycryptodome` + ### 运行 把图片文件放到 `gallary` 目录,Windows 可直接双击 manifest.py,或者和其他操作系统一样,在 Terminal、Powershell、CMD 中运行: diff --git a/options.php b/options.php index e659e49..4d1f00a 100644 --- a/options.php +++ b/options.php @@ -1137,10 +1137,16 @@ function optionsframework_options() { $options[] = array( 'name' => __('QQ avatar link encryption', 'sakura'),/*QQ头像链接加密*/ - 'desc' => __('Check to enable, do not display the user\'s qq avatar links directly.', 'sakura'),/*勾选开启,不直接暴露用户qq头像链接*/ + 'desc' => __('Do not display the user\'s qq avatar links directly.', 'sakura'),/*不直接暴露用户qq头像链接*/ 'id' => 'qq_avatar_link', - 'std' => '0', - 'type' => 'checkbox'); + 'std' => "off", + 'type' => "radio", + 'options' => array( + 'off' => __('Off (default)', 'sakura'),/*关闭(默认)*/ + 'type_1' => __('use redirect (general security)', 'sakura'),/*使用 重定向(安全性一般)'*/ + 'type_2' => __('fetch data at backend (high security)', 'sakura'),/*后端获取数据(安全性高)*/ + 'type_3' => __('fetch data at backend (high security,slow)', 'sakura'),/*后端获取数据(安全性高, 慢)*/ + )); $options[] = array( 'name' => __('Comment UA infomation', 'sakura'),/*评论UA信息*/