<?php
/**
 * TMBLOG 首页文件
 * ============================================================================
 * 版权所有 2008-2009 梧州腾马网络服务中心，并保留所有权利。
 * 网站地址: http://php.tmacn.cn；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: tm $
*/

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}

$smarty->assign('siteinfo',      get_site_info()); // 网站信息

$smarty->assign('tmbloggree',    get_gree_info()); // 导航栏

$smarty->assign('tmcategory',    get_category()); // 日志分类

$smarty->assign('tmpiccategory',    get_pic_category()); // 相册分类

$smarty->assign('tmarttj',         get_art_tj()); // 推荐文章

$smarty->assign('tmdate',        get_date_list()); // 文章归档

$smarty->assign('tmret',        get_ret_list()); // 最新评论

$smarty->assign('userlist',        get_user_px()); // 评论用户排名

$smarty->assign('adtoplist',        get_adtop_list()); // 顶部通栏广告

$smarty->assign('adflashlist',        get_adflash_list()); // 右边轮播广告

$smarty->assign('adrightlist',        get_adright_list()); // 右边广告

$smarty->assign('tmtag',        get_tag_list()); // 网站标签

$smarty->assign('sitefoot',      get_foot_info()); // 底部信息

$smarty->assign('tmblog_dir',      request_uri()); // 目录

$smarty->assign('gglist',      get_gg_list()); // 公告

$smarty->assign('tmrss',      "rss.php"); // 订阅

//判断文章分类是否存在
if(isset($_GET['s']))
   $id=trim($_GET['s']);
$cname="搜索前50条结果";
$smarty->assign('cname', $cname);
$smarty->assign('s', $id);

$sql="select tm_art.*,tm_art_class.art_name as cart_name,tm_art_class.filename from tm_art left join tm_art_class on tm_art.art_class=tm_art_class.art_id where tm_art.art_title like '%".$id."%' order by tm_art.art_id DESC limit 50";
$rsql=mysql_query($sql);

    $tmart = array();
	$i=0;
	while($res=mysql_fetch_object($rsql))
	     {
    $tmart[$i]['url']= $filename."/".substr(ereg_replace('-',"",$res->art_date),0,6)."/".ereg_replace('-',"",$res->art_date).$res->art_id.".html";
    if(!file_exists($tmart[$i]['url']))
    $tmart[$i]['url']="art.php?id=".$res->art_id;
    $tmart[$i]['curl']= "artlist.php?id=".$res->art_class;
    $tmart[$i]['title']= $res->art_title;
		$tmart[$i]['date']= $res->art_date;
		$tmart[$i]['name']=$res->art_name;
		$tmart[$i]['inname']=$res->art_zt;
		$tmart[$i]['year']= substr($res->art_date,0,7);
		$tmart[$i]['day']= substr($res->art_date,8,2);
		$tmart[$i]['cid']=$res->art_class;
		$tmart[$i]['cname']=$res->cart_name;
		$tmart[$i]['img']=$res->img;
		if(!file_exists($tmart[$i]['img']))
		   $tmart[$i]['img']="themes/default/images/nopic.jpg";
		$tmart[$i]['num']=$res->art_rq;
		$tmart[$i]['cont']=$res->art_key;
    $sql="select count(*) from tm_art_re where re_artid='$res->art_id'";
		$resultc=mysql_query($sql) or die(mysql_error());
		$rsc=mysql_fetch_array($resultc);
		$tmart[$i]['rnum']=$rsc[0];
    $sql="select * from tm_tag where tag_id='$res->art_tag'";
		$resultc=mysql_query($sql) or die(mysql_error());
		$rsc=mysql_fetch_object($resultc);
		$tmart[$i]['tag']=$rsc->tag_name;	
    $tmart[$i]['tag_id']=$res->art_tag;	
		$i++;
		}
$smarty->assign('tmart',      $tmart);
//文章列表结束
if($i==0)
   {
      $message=array();
      $message[sb]=1;
      $message[info]="找不到相关文章!";
      $message[url]="javascript:history.go(-1);";
      $smarty->assign('message', $message);
      $smarty->display('message.dwt');
      exit(); 
   }

$smarty->display('serch.dwt');

?>