<?php
/**
* 侧边栏组件、页面模块
*/
if(!defined('EMLOG_ROOT')) {exit('error!');}
?>
<?php
//widget:随机文章
function shouqi_logs(){
$index_randlognum = 1;
$Log_Model = new Log_Model();
$randLogs = $Log_Model->getRandLog($index_randlognum);?>
<?php foreach($randLogs as $value): ?>
<a href="<?php echo Url::log($value['gid']); ?>">试试手气</a>
<?php endforeach; ?>
<?php }?>
<?php
//获取友链favicon站标
function favicon_file($site_url){
$site_url = strtolower(rtrim($site_url,'/'));
$site_md5 = md5($site_url);
$fav_url = TEMPLATE_URL.'favicon/';
$fav_path = TEMPLATE_PATH.'favicon/';
$t = 2592000; //30天,单位:秒
if(!is_file($fav_path.$site_md5.'.png') || (time() - filemtime($fav_path.$site_md5.'.png')) > $t) {
copy('http://www.google.com/s2/favicons?domain='.str_replace('http://','',$site_url),$fav_path.$site_md5.'.png');
}
return $fav_url.$site_md5.'.png';
}?>
<?php
function get_avatar($mail,$alt,$size = '60',$default='monsterid')
{
$alt = strip_tags($alt);
$email_md5=md5(strtolower($mail));//通过MD5加密邮箱
$cache_path=TEMPLATE_PATH."cache"; //缓存文件夹路径,ljie需要换上你的主题目录名称
if(!file_exists($cache_path))
{
mkdir($cache_path,0700);
}
$lazyimg=TEMPLATE_URL."images/loading.gif";
$avatar_url=TEMPLATE_URL."cache/".$email_md5.'.jpg'; //头像相对路径
$avatar_abs_url=$cache_path."/".$email_md5.'.jpg'; //头像绝对路径
$cache_time=24*3600*7; //缓存时间为7天
if (empty($default)) $default = $cache_path. '/default.jpg';
if(!file_exists($avatar_abs_url) || (time()-filemtime($avatar_abs_url)) > $cache_time)//过期或图片不存在
{
$new_avatar = getGravatar($mail,$size,$default);
copy($new_avatar,$avatar_abs_url);
}
return "<img class='lazy' src='{$lazyimg}' title='{$alt}' alt='{$alt}' data-original='{$avatar_url}' height='{$size}' width='{$size}' />";
}
//调用方法
//get_avatar($comment['mail'],"{$comment['poster']}{$comment['comment_nums']}")
?>
<?php
function Duzheqiang($log_num,$size){
$DB = MySql::getInstance($log_num,$size);
$sql = "SELECT count(*) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date >0 and mail !='' and mail !='w@lanyes.org' and poster != '蓝叶' and hide ='n' group by mail order by comment_nums DESC limit 0,$log_num";
$result = $DB->query($sql);
while($row = $DB->fetch_array($result)){
$img = get_avatar($row['mail'],"{$row['poster']}({$row['comment_nums']})",$size);
$tmp = " <li><a href='".$row['url']."' target='_blank' title='".$row['poster']." '>".$img."<span>".$row['poster']."<br />(".$row['comment_nums'].")</span><div class='toum'></div></a></li>";
$output .= $tmp;
}
$output = " <ul>".$output." </ul>";
echo $output;
}
?>
<?php
//widget:blogger
function widget_blogger($title){
global $CACHE;
$user_cache = $CACHE->readCache('user');
$name = $user_cache[1]['mail'] != '' ? "<a href=http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=".$user_cache[1]['mail']." target=_blank title=给站长写信>".$user_cache[1]['name']."</a>" : $user_cache[1]['name'];?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<p class="bloger_img">
<?php if (!empty($user_cache[1]['photo']['src'])): ?>
<img src="<?php echo BLOG_URL.$user_cache[1]['photo']['src']; ?>" width="<?php echo $user_cache[1]['photo']['width']; ?>" height="<?php echo $user_cache[1]['photo']['height']; ?>" alt="blogger" />
<?php endif;?>
</p>
<p class="bloger_name"><span><?php echo $name; ?></span></p>
<p class="bloger_des"><?php echo $user_cache[1]['des']; ?></p>
</div>
<?php }?>
<?php
//widget:日历
function widget_calendar($title){ ?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<ul><script>sendinfo('<?php echo Calendar::url(); ?>','calendar');</script></ul>
</div>
<?php }?>
<?php
//widget:标签
function widget_tag($title){
global $CACHE;
$tag_cache = $CACHE->readCache('tags');?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<ul>
<?php foreach($tag_cache as $value): ?>
<span style="font-size:12px; line-height:20px;background:#<?PHP $tagbg=array('5CB85C','428BCA','FF6600','D9534F','B37333','00ABA9');$show_tagbg = array_rand($tagbg, 1);echo $tagbg[$show_tagbg];?>;padding: 5px;border-radius:3px;display: inline-block;margin:0 0 10px">
<a style="color:#fff;" href="<?php echo Url::tag($value['tagurl']); ?>" title="<?php echo $value['usenum']; ?> 篇文章"><?php echo $value['tagname']; ?></a></span>
<?php endforeach; ?>
</ul>
</div>
<?php }?>
<?php
//widget:分类
function widget_sort($title){
global $CACHE;
$sort_cache = $CACHE->readCache('sort'); ?>
<div class="side2">
<div class="title_index">
<h3>栏目分类</h3>
</div>
<ul>
<?php foreach($sort_cache as $value): ?>
<li style="float:left;width:40%;">
<a href="<?php echo Url::sort($value['sid']); ?>"><?php echo $value['sortname']; ?>(<?php echo $value['lognum'] ?>)</a>
</li>
<?php endforeach; ?></ul>
</div>
<?php }?>
<?php
//widget:最新微语
function widget_twitter($title){
global $CACHE;
$newtws_cache = $CACHE->readCache('newtw');
$istwitter = Option::get('istwitter');
?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<ul>
<?php foreach($newtws_cache as $value): ?>
<?php $img = empty($value['img']) ? "" : '<a title="查看图片" class="t_img" href="'.BLOG_URL.str_replace('thum-', '', $value['img']).'" target="_blank"> </a>';?>
<li><?php echo $value['t']; ?><?php echo $img;?><p><?php echo smartDate($value['date']); ?></p></li>
<?php endforeach; ?>
<?php if ($istwitter == 'y') :?>
<p><a href="<?php echo BLOG_URL . 't/'; ?>">更多»</a></p>
<?php endif;?>
</ul>
</div>
<?php }?>
<?php
//widget:最新评论
function widget_newcomm($title){
global $CACHE;
$com_cache = $CACHE->readCache('comment');
?>
<div class="side_comm">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<ul>
<?php
foreach($com_cache as $value):
$url = Url::comment($value['gid'], $value['page'], $value['cid']);
?>
<li id="celanpl"><img style="float:left;margin:0 5px;border-radius:5px;border:1px solid #BBB;" width="40" height="40" src="<?php echo getGravatar($value['mail']); ?>" alt="评论者头像" /><?php echo $value['name']; ?> 说:
<br /><a href="<?php echo $url; ?>"><?php echo $value['content']; ?></a></li>
<?php endforeach; ?>
</ul>
</div>
<?php }?>
<?php
//widget:最新文章
function widget_newlog($title){
global $CACHE;
$newLogs_cache = $CACHE->readCache('newlog');
?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<div class="side_imgbox">
<ul>
<?php foreach($newLogs_cache as $value): ?>
<li>
<div class="side_img"><img src="<?php get_thum($value['gid']);?>" alt="<?php echo $row['title'];?>" /></a></div>
<div class="side_tit"><a href="<?php echo Url::log($value['gid']); ?>"><?php echo $value['title']; ?></a></div>
<div class="side_touming"></div>
<div class="side_more"><a href="<?php echo Url::log($value['gid']);?>" title="<?php echo $value['title'];?>"></a></div>
</li>
<?php endforeach; ?>
</ul></div>
</div>
<?php }?>
<?php
//widget:热门文章
function widget_hotlog($title){
$index_hotlognum = Option::get('index_hotlognum');
$Log_Model = new Log_Model();
$randLogs = $Log_Model->getHotLog($index_hotlognum);?>
<div class="side2">
<div class="title_index">
<h3><?php echo $title; ?></h3>
</div>
<div class="side_imgbox">
<ul>
<?php foreach($randLogs as $value): ?>
<li>
<div class="side_img"><img src="<?php get_thum($value['gid']);?>" alt="<?php echo $row['title'];?>" /></a></div>
<div class="side_tit"><a href="<?php echo Url::log($value['gid']); ?>">