<?
$C_126cmsadmin_tname = 'article_config';

include(dirname(__FILE__)."/global.php");


include("../../include/pinyin.php");

include("./article_modify/fun.php");

@$job = $submitted_vars["job"];

if($job == "modify"){
  $postdb = $_POST['postdb'];
  $postdb['title'] = $_POST['title'];
  $postdb['content'] = $_POST['content'];
  
   
  $postdb['fname'] = mysql_result(mysql_query("SELECT * FROM `w6_sort` WHERE `id` = '".$postdb['parentId']."'"),"0","name");

  
  $query="UPDATE `w6_article` 
          SET `fid`='".$postdb['parentId']."' ,`fname`='".$postdb['fname']."' ,`fid`='".$postdb['parentId']."' , `title`='".$postdb['title']."' , `titlecolor`='".$postdb['titlecolor']."' , `fonttype`='".$postdb['fonttype']."'
		  WHERE `aid`=".$postdb['aid']; 
  $result = mysql_query($query) or die(mysql_error());
  
  $query="UPDATE `w6_reply` 
          SET `content`='".$postdb['content']."'
		  WHERE `aid`=".$postdb['aid']; 
  $result = mysql_query($query) or die(mysql_error());
  
  if ($result)
     {
       $showmsg = "文章修改成功！";
	   $formurl = "article_modify.php?aid=".$postdb['aid'];
     }
  else
     {
       $showmsg = "文章修改失败！";
	   $formurl = "article_modify.php?aid=".$postdb['aid'];
     }
	 
  include('showmsg.php');
  exit;
  
}

//从数据库中读出 产品的内容

$aid          =  $submitted_vars["aid"];
$mid          =  $submitted_vars["mid"];
$fid          =  $submitted_vars["fid"];


//取得当前内容页的内容
$show_db=get_showdb( $aid , $mid );
//print_r($show_db);


//模块设置 读取显示
  $query="SELECT * FROM `w6_module` WHERE `module_id`='".$mid."'";
  $result=mysql_query($query);
  $f_module_config       =  mysql_result($result,"0","module_config");
  $f_array = unserialize($f_module_config);
  $field_set = $f_array['field_set'];
  

foreach($f_array AS $key=>$rs){

	$aa = "\$show_db[".$rs['field_id']."]";
	$bb = $show_db[$rs['field_id']];
	$wnTpl .= str_replace($aa,$bb,  formMoudleModify( $rs )  );
	
}

$tplFile_0 = './tpl/mother/modify.htm';
$tplFile_1 = "./tpl/wn_tpl/modify_$mid.htm";
if ( !file_exists( $tplFile_1 ) ) {
	$tplFile = $tplFile_0;
}else{
	$tplFile = $tplFile_1;
}
	
//生成静态页
ob_start();
//require($tpl_head);
require( $tplFile );
//require($tpl_foot);
$html = ob_get_contents();
ob_end_clean();

echo $html;

?>