<%@ page contentType="text/html;charset=GBK" %>
<%@ include file="../checkLogin.jsp" %>
<%@ page import="gbase.db.*,java.util.*,gbase.util.*"%>
<%
	String content="";
	String old_content="";
	String message="操作失败";
	String web_project_sys_account = request.getParameter("web_project_sys_account")==null?"":request.getParameter("web_project_sys_account");
	String web_template_type_id=request.getParameter("web_template_type_id")==null?"":request.getParameter("web_template_type_id");
	String web_project_id=request.getParameter("web_project_id")==null?"":request.getParameter("web_project_id");
        String web_project_name=request.getParameter("web_project_name")==null?"":request.getParameter("web_project_name");
	String page_name=request.getParameter("page_name")==null?"":request.getParameter("page_name");
	String file_name=request.getParameter("file_name")==null?"":request.getParameter("file_name");
	String id=request.getParameter("id")==null?"":request.getParameter("id");
        String flag=request.getParameter("flag")==null?"":request.getParameter("flag");
	
	String url="page_top_content.jsp?page_name="+page_name+"&file_name="+file_name+"&web_project_id="+web_project_id+"&web_project_name="+web_project_name+"&web_project_sys_account="+web_project_sys_account+"&web_template_type_id="+web_template_type_id+"&id="+id+"&action=update";
	DBOperation theDBOperation = new DBOperation();
	
	//模板复制
        String sys_template_sql="select * from web_template where  web_account='"+web_project_sys_account+"' and id="+id;
        ResultSet rs =theDBOperation.getResultSet(sys_template_sql);
        if(rs.next())
         {
          ConvertSql theConvertSql=new ConvertSql();
          old_content=rs.getString("content");
          content=theConvertSql.convertSqlValue(old_content);
         
         }
        String template_sql="update web_template set content='"+content+"' where  web_account='"+web_account+"' and id="+id;
        int i=theDBOperation.executeSql(template_sql); 
        try {
         if(i>0)
          {
           ContentToFile theContentToFile=new ContentToFile();
           if(file_name.equals("page_top") || file_name.equals("page_bottom"))
           {
            theContentToFile.geneTemplateTopBottomFile(web_account,old_content,"/template",file_name+".jsp");
           }
           else
           { 
            theContentToFile.geneTemplateFile(web_account,old_content,"/template",file_name+".jsp");
           }
           message = "操作成功!";
          }
        else
          message = "操作失败!";
      }
      catch (Exception ex) {
        message = "操作失败!";
      }
	
%>
<script language="javascript">
	function process ( message,url){
		alert(message);
		self.location = url;
	}
</script>
<html>
	<head>
		<title></title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=url%>');">
	</body>
</html>