mirror of
https://github.com/mashirozx/sakura.git
synced 2024-11-22 06:48:12 +08:00
add choices
This commit is contained in:
parent
f2a96c3f71
commit
d7e5af113f
@ -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 '<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));
|
||||
$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)">';
|
||||
}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{
|
||||
return $avatar ;
|
||||
|
@ -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';
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ pip3 install Pillow
|
||||
pip install Pillow --user
|
||||
```
|
||||
|
||||
用同样的方法安装`requests`、`pycryptodome`
|
||||
|
||||
### 运行
|
||||
把图片文件放到 `gallary` 目录,Windows 可直接双击 manifest.py,或者和其他操作系统一样,在 Terminal、Powershell、CMD 中运行:
|
||||
|
||||
|
12
options.php
12
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信息*/
|
||||
|
Loading…
Reference in New Issue
Block a user