<?php
session_start();
/**
 *  梧州腾马网络建站系统
 * ============================================================================
 * 版权所有 2009-2010 梧州腾马网络服务中心，并保留所有权利。
 * 网站地址: http://www.wztm.net；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在受权的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: tm $
*/

define('IN_ECS', true);

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

if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}
$code=$_POST[code];
if($code<>$_SESSION['tmcode'])
{
echo "<script>alert('验证码错误!');location.href='index.php';</script>";
exit();
}
$user=$_POST[user];
$pass=md5($_POST[pass]);
$sql="select * from tm_admin where user='$user' and pass='$pass' and show1=1";
$result=mysql_fetch_object(mysql_query($sql));
if($result)
 {
 $_SESSION["tm_admin"]=$user;
 $_SESSION["tm_name"]=$result->name;
 $_SESSION["tm_id"]=$result->id;
 $_SESSION["tm_qs"]=$result->qs;
 $date=date('Y-m-d');
 $ip=$_SERVER["REMOTE_ADDR"];
 mysql_query("update tm_admin set indate='$date',ip='$ip' where user='$user'");
   $tm_user_login['login']=1;
   $tm_user_login['tm_admin']=$_SESSION["tm_admin"];
   $tm_user_login['tm_name']=$_SESSION["tm_name"];
   $tm_user_login['tm_id']=$_SESSION["tm_id"];
   $tm_user_login['tm_qs']=$_SESSION["tm_qs"];
   $qs=array();
   $qs=explode(",",$_SESSION["tm_qs"]);
 $smarty->assign('tm_user_login',       $tm_user_login);
 
$clist=array();
$sql="select * from tm_setup_c order by px asc";
$rsql=mysql_query($sql);
$i=0;
$j=0;
while($rs=mysql_fetch_object($rsql))
      {
      if($qs[$i]==1)
      {
      $clist[$j]['title']=$rs->title;
      $clist[$j]['url']="left.php?id=".$rs->id;
      $j++;
      }
      $i++;
      }
$smarty->assign('clist', $clist);

 $smarty->display('admin_index.dwt');
 exit();
 }
else
 {
  $smarty->display('admin_logo.dwt');
  exit();
 }
?>