add choices

This commit is contained in:
spirit 2019-12-05 18:12:31 +08:00
parent f2a96c3f71
commit d7e5af113f
4 changed files with 30 additions and 10 deletions

View File

@ -1620,12 +1620,16 @@ function change_avatar($avatar){
if ($comment) { if ($comment) {
if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true )){ if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true )){
$qq_number = 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 '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}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 '<img src="'.$matches[1].'" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}else{
openssl_public_encrypt($qq_number, $encrypted, openssl_pkey_get_public($sakura_pubkey)); openssl_public_encrypt($qq_number, $encrypted, openssl_pkey_get_public($sakura_pubkey));
$qq_number = urlencode(base64_encode($encrypted)); $qq_number = urlencode(base64_encode($encrypted));
return '<img src="'.rest_url("sakura/v1/qqinfo/avatar").'?qq='.$qq_number.'"class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">'; return '<img src="'.rest_url("sakura/v1/qqinfo/avatar").'?qq='.$qq_number.'"class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}else{
return '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
} }
}else{ }else{
return $avatar ; return $avatar ;

View File

@ -449,6 +449,7 @@ function update_database() {
/** /**
* QQ头像链接解密 * QQ头像链接解密
* https://sakura.2heng.xin/wp-json/sakura/v1/qqinfo/avatar
*/ */
function get_qq_avatar(){ function get_qq_avatar(){
global $sakura_privkey; global $sakura_privkey;
@ -457,8 +458,15 @@ function get_qq_avatar(){
openssl_private_decrypt($encrypted, $qq_number, openssl_pkey_get_private($sakura_privkey)); openssl_private_decrypt($encrypted, $qq_number, openssl_pkey_get_private($sakura_privkey));
preg_match('/^\d{3,}$/', $qq_number, $matches); preg_match('/^\d{3,}$/', $qq_number, $matches);
$imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100'; $imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100';
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 = new WP_REST_Response();
$response->set_status(302); $response->set_status(302);
$response->header('Location', $imgurl); $response->header('Location', $imgurl);
return $response; return $response;
}
} }

View File

@ -24,6 +24,8 @@ pip3 install Pillow
pip install Pillow --user pip install Pillow --user
``` ```
用同样的方法安装`requests`、`pycryptodome`
### 运行 ### 运行
把图片文件放到 `gallary` 目录Windows 可直接双击 manifest.py或者和其他操作系统一样在 Terminal、Powershell、CMD 中运行: 把图片文件放到 `gallary` 目录Windows 可直接双击 manifest.py或者和其他操作系统一样在 Terminal、Powershell、CMD 中运行:

View File

@ -1137,10 +1137,16 @@ function optionsframework_options() {
$options[] = array( $options[] = array(
'name' => __('QQ avatar link encryption', 'sakura'),/*QQ头像链接加密*/ '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', 'id' => 'qq_avatar_link',
'std' => '0', 'std' => "off",
'type' => 'checkbox'); '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 securityslow)', 'sakura'),/*后端获取数据(安全性高, 慢)*/
));
$options[] = array( $options[] = array(
'name' => __('Comment UA infomation', 'sakura'),/*评论UA信息*/ 'name' => __('Comment UA infomation', 'sakura'),/*评论UA信息*/