殷德瑶博客
喜欢的歌,静静地听!喜欢的人,远远地看!

Emlog最近访客调用代码

殷德瑶 2016-6-5 emlog教程 评论 1394 次


将下面的代码粘贴到module.php文件里面:

<?php
/**
 * 获取Gravatar头像
 */
function getGravatar_fk($email, $s = 40, $d = 'mm', $g = 'g') {
 $hash = md5($email);
 $avatar = "http://gravatar.duoshuo.com/avatar/$hash?s=$s&d=$d&r=$g";
 return $avatar;
}
//获取最新评论访客
function comment($num){
 $t = MySql::getInstance();
 $sql = "SELECT * FROM ".DB_PREFIX."comment WHERE mail != '' ORDER BY `cid` DESC LIMIT $num";
 $list = $t->query($sql);
 while($row = $t->fetch_array($list)){
  $i = '<li><a rel="nofollow" href="'.$row['url'].'"><img src="'.getGravatar_fk($row['mail']).'"></a></li>';
  echo $i;
 }
}
?>

在需要的地方调用:<?php comment($num) //$num为调用数量 ?>



发表评论


粤ICP备15078261号 Powered by 黑暗之夜
Theme by 殷德瑶博客