欢迎访问 舍力博客(www.shuyong.net)
<?php //widget:最新文章 function widget_newlog($title){ $index_newlognum = Option::get('index_newlognum');?> <div class="cbl-one"><div class="title"><p><?php echo $title;?></p></div> <?php $db = MySql::getInstance(); $sql = $db->query ("SELECT * FROM ".DB_PREFIX."blog inner join ".DB_PREFIX."sort WHERE hide='n' AND type='blog' AND top='n' AND sortid=sid order by date DESC limit 0,$index_newlognum"); while($row = $db->fetch_array($sql)){ $logpost = !empty($row['excerpt']) ? $row['excerpt'] : ''.$row['content'].''; if (!empty($row['excerpt'])){preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $row['excerpt'], $match); if(empty($match[1][0])) { preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i",$row['content'],$match);}}else{preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $row['content'],$match);} $img = isset($match[0][0]) ? $match[0][0]:'<img src="图片地址" />';//无图片时显示 $date = gmdate('Y年m月d日', $row['date']); $content = strip_tags($logpost,''); $content = mb_substr($content,0,100,'utf-8');//摘要字数修改本代码中的100这个即可 $comment = ($row['comnum'] != 0) ? ''.$row['comnum'].'' : '0'; $gid = $row['gid']; $tag = $db -> query("SELECT * FROM ".DB_PREFIX."tag WHERE gid LIKE '%,$gid,%'");?> <a href="<?php echo Url::sort($row['sid']);?>" title="<?php echo $row['sortname'];?>" /><?php echo $row['sortname'];?></a><br /> <a href="<?php echo Url::log($row['gid']);?>" title="<?php echo $row['title'];?>" /><?php echo $row['title'];?></a><br /> <?php echo $img;?><br /> <?php echo $content;?> <?php };?></div><?php }?>
<?php //widget:热门文章 function widget_hotlog($title){ $index_hotlognum = Option::get('index_hotlognum');?> <div class="cbl-one"><div class="title"><p><?php echo $title;?></p></div> <?php $db = MySql::getInstance();$db = MySql::getInstance(); $time = time(); $sql = $db->query ("SELECT * FROM ".DB_PREFIX."blog inner join ".DB_PREFIX."sort WHERE hide='n' AND type='blog' AND date > $time - 30*24*60*60 AND top='n' AND sortid=sid order by `views` DESC limit 0,$index_hotlognum"); while($row = $db->fetch_array($sql)){ $logpost = !empty($row['excerpt']) ? $row['excerpt'] :''.$row['content'].''; if (!empty($row['excerpt'])){preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i",$row['excerpt'],$match);if(empty($match[1][0])){ preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i",$row['content'],$match);}}else{preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $row['content'],$match);} $img = isset($match[0][0]) ? $match[0][0]:'<img src="图片地址" />';//无图片时显示 $date = gmdate('Y年m月d日', $row['date']); $content = strip_tags($logpost,''); $content = mb_substr($content,0,100,'utf-8');//摘要字数修改本代码中的100这个即可 $comment = ($row['comnum'] != 0) ? ''.$row['comnum'].'' : '0'; $gid = $row['gid'];?> <li><a href="<?php echo Url::log($row['gid']);?>" title="<?php echo $row['title'];?>" /><?php echo $row['title'];?></a></li> <?php };?></div><?php }?>
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。