Skip to content

Commit

Permalink
qq头像问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
wehaox authored Aug 6, 2024
1 parent 0b0956a commit 88434be
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,35 +519,12 @@ function getGravatar($email, $name, $comments_a, $s = 96, $d = 'mp', $r = 'g')
{
preg_match_all('/((\d)*)@qq.com/', $email, $vai);
if (empty($vai['1']['0'])) {
// $hasGravatar = hasGravatar($email);
// if($hasGravatar){
// $url = 'https://gravatar.loli.net/avatar/';
$url = Helper::options()->GravatarSelect;
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
$imga = '<img ' . $comments_a . ' src="' . GetLazyLoad() . '" data-lazy-src="' . $url . '" >';
// }else{
// $imga = '<img avatar="'.$name.'" color '.$comments_a.'>';
// }
} else {
$qquser = $vai['1']['0'];
$db = Typecho_Db::get();
if (!array_key_exists('qqk', $db->fetchRow($db->select()->from('table.comments')))) {
$db->query('ALTER TABLE `' . $db->getPrefix() . 'comments` ADD `qqk` varchar(64) DEFAULT NULL;');
}
$dbk = $db->fetchRow($db->select('qqk')->from('table.comments')->where('mail=?', $email))['qqk'];
if ($dbk == NULL) {
$geturl = 'http://qqk.wehao.org/?uin=' . $qquser;
$qqurl = file_get_contents($geturl);
$json = json_decode($qqurl, true);
if (isset($json['code']) && $json['code'] == 200) {
$k = $json['k'].'&kti='.$json['kti'];
$db->query($db->update('table.comments')->rows(array('qqk' => $k))->where('mail=?', $email));
}
$url = 'https://q1.qlogo.cn/headimg_dl?dst_uin=' . $qquser . '&spec=100';
} else {
$url = 'https://q1.qlogo.cn/g?b=qq&k=' . $dbk . '&s=100';
}
$url = 'https://cravatar.cn/avatar/'.md5(strtolower(trim($email)));
$imga = '<img ' . $comments_a . ' src="' . GetLazyLoad() . '" data-lazy-src="' . $url . '" >';
}
return $imga;
Expand Down Expand Up @@ -1194,4 +1171,4 @@ function darkTimeFunc(){
}
$timeSlot = explode('-', $time);
echo "e >= $timeSlot[0] || e <= $timeSlot[1]";
}
}

0 comments on commit 88434be

Please sign in to comment.