<?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('sitefoot',      get_foot_info()); // 底部信息

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

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

$sql="select * from tm_bq_setup where id=1";
$rs=mysql_fetch_object(mysql_query($sql));
if($rs->retsh==0)
   {
      $message=array();
      $message[sb]=0;
      $message[info]="博群功能已禁用!";
      $message[url]="javascript:history.go(-1);";
      $smarty->assign('message', $message);
      $smarty->display('message.dwt');
      exit();
   }



$sql="select * from tm_bq_list order by px ASC";
$rsql=mysql_query($sql);

    $bq_class = array();
	$i=0;
	while($res=mysql_fetch_object($rsql))
	     {
    $bq_class[$i]['title']= $res->name;
		$bq_class[$i]['url']="tmbq.php?id=".$res->id;
		$i++;
		}
$smarty->assign('bq_class',      $bq_class);
//博群归类结束


if(isset($_GET['id']))
   $id=$_GET['id'];

if($id<>"")
$rs=mysql_fetch_object(mysql_query("select * from tm_bq_list where id='$id'"));
else
$rs=mysql_fetch_object(mysql_query("select * from tm_bq_list order by px asc limit 1"));
if(!$rs)
$rs=mysql_fetch_object(mysql_query("select * from tm_bq_list order by px asc limit 1"));

$artinfo=array();
$artinfo['name']=$rs->name;
$artinfo['url']=$rs->url;
$artinfo['num']=$rs->num;

$smarty->assign('artinfo', $artinfo);

$artlist=array();

$contents = file_get_contents($artinfo['url']."/rss.php"); 
$handle=$contents;
$handle=strstr($handle,'<item>');
$temp=explode("<item>",$handle);   
for($m=0;$m<$artinfo['num'];$m++)
   {
   $tmblogcj=$temp[$m+1];
   $temp1=explode("</pubDate>",$tmblogcj);
   $tmblogcj=$temp1[0];
   $temp1=explode("<pubDate>",$tmblogcj);
   $artlist[$m]['date']=$temp1[1];
   $tmblogcj=$temp1[0];
   $temp1=explode("</link>",$tmblogcj);
   $tmblogcj=$temp1[0];
   $temp1=explode("<link>",$tmblogcj);
   $artlist[$m]['url']=$artinfo['url'].$temp1[1];
   $tmblogcj=$temp1[0];
   
   $temp1=explode("</title>",$tmblogcj);
   $tmblogcj=$temp1[0];
   $temp1=explode("<title>",$tmblogcj);
   $artlist[$m]['title']=$temp1[1];
   }


$smarty->assign('artlist', $artlist);

 
   
$smarty->assign('dhindex',      "http://".$_SERVER['SERVER_NAME'].request_uri()."tmbq.php");//当前页



$smarty->display('tmbq.dwt');
?>