Emlog获取最近留言访客头像函数
刚才写个模板需要在底部加一个最新访客,顺手写了个函数,需要的可以借鉴借鉴
/** * 获取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; } }
调用方式:
comment($num) //$num为调用数量
本文源于舍力博客
发表评论