<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!--#include file="f.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>自定义插件系统-By fycms</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
<script type='text/javascript' src='../../js/main.js'></script>
<script type="text/javascript" src="../../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../../fy_inc/js/lhg/lhgdialog.min.js'></script>
<script src="../../js/base.js"></script>
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 自定义插件系统</div>
    <div class="opers">
		<a href="?" class="btn<%If request("Action")="" Then echo " btn_primary" %>">查看插件</a>
		<a href="?Action=add" class="btn<%If request("Action")="add" Then echo " btn_primary" %>">新建插件</a> 
    </div>
<% 
	If Not fycms.fycms_QXYZ(0,"plus","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
dim Action,ID,ShowErr,titles,CID,files,rewrite,modeid
	Action = Request("Action")
 	ID=ChkNumeric(request("ID"))
 	modeid=ChkNumeric(request("modeid"))
	
	Select Case Action
			case "add"
				call add()
			Case "edit" 
				Call edit()
			Case "addsave"
				Call addsave()
			Case "editsave"
				Call editsave()
			Case "del"
				Call del()
			Case Else
				Call Main()
	End Select
	
	Sub Del()
		Conn.Execute ("Delete from diyplus_fy Where ID=" & ChkNumeric(Request.QueryString("ID")))		
		Conn.Execute ("Delete from plusget_fy Where cid=" & ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		Call fycms.ActErr("删除成功","Sys_fy/plus/Index.asp","")
 		Response.End
    End Sub
	Sub addsave()
	Dim Rs,content,title,i,dd,rs1,cid
		files=fycms.getfilepath(delAsp(request("filepath")),3)
		titles=delAsp(fycms.s("titles"))
 		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open "Select * from diyplus_fy",Conn,1,3

		If left(files,1)="/" Then 
			files="fycms101aae08dd2ea51b0c370a1241e9793d"&files
			If fycms.actsys="/" Then 
 				files=rep(files,"fycms101aae08dd2ea51b0c370a1241e9793d/","")
			Else 

				files=rep(files,"fycms101aae08dd2ea51b0c370a1241e9793d"&fycms.actsys,"")
 			End If 
		End if
		Rs.addnew
		Rs("title")= titles
 		Rs("templatepath")=delAsp(request("templatepath"))
 		Rs("filepath")=files
		Rs("rewrite")=ChkNumeric(request("rewrite"))
		Rs("isLock")=ChkNumeric(request("isLock"))
		Rs("ismake")=ChkNumeric(request("ismake"))
		Rs("modeid")=ChkNumeric(request("modeid"))
 		Rs("rewriteurl")=Trim(request("rewriteurl"))
 		Rs("addtime")=now()
		Rs.update
		Rs.Close
		Set rs=fycms.actexe("Select top 1 id  from diyplus_fy  order by id desc")
		If Not rs.eof Then ID = rs("ID")
		
		If ChkNumeric(request("ismake"))=1 Then  Call makelabel
 		Set Rs=Nothing
		Call fycms.ActErr("操作成功","Sys_fy/plus/Index.asp","")
 		Response.End
	End Sub	


	Sub editsave()
	Dim DiyPath,Rs,content,title,sql,rewrite,isLock,templatepath,i
		titles=fycms.s("titles")
		files=fycms.getfilepath(delAsp(request("filepath")),3)
		SQL = "Select * From diyplus_fy Where ID="&ID 
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		If left(files,1)="/" Then 
			files="fycms101aae08dd2ea51b0c370a1241e9793d"&files
			If fycms.actsys="/" Then 
 				files=rep(files,"fycms101aae08dd2ea51b0c370a1241e9793d/","")
			Else 

				files=rep(files,"fycms101aae08dd2ea51b0c370a1241e9793d"&fycms.actsys,"")

			End If 
		End if
 
		Rs.Open SQL,Conn,1,3
		If Not rs.eof Then 
			Rs("title")= delAsp(fycms.s("titles"))
			Rs("templatepath")=delAsp(request("templatepath"))
			Rs("filepath")=files
			Rs("rewriteurl")=delAsp(Trim(request("rewriteurl")))
			
			Rs("modeid")=ChkNumeric(request("modeid"))
			Rs("rewrite")=ChkNumeric(request("rewrite"))
			Rs("isLock")=ChkNumeric(request("isLock"))
			Rs("ismake")=ChkNumeric(request("ismake"))
			Rs.update:Rs.Close
			If ChkNumeric(request("ismake"))=1 Then  Call makelabel
		End If 
		Call fycms.ActErr("修改成功","Sys_fy/plus/Index.asp","")
 		Response.End
	End Sub	

	sub Main()
	Dim ShowErr
	ConnectionDatabase
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 20
 	Dim arrinfo, i
	Dim sql, sqlCount,Sqls,ChannelID
	sql = "SELECT [ID],[title],[rewrite],[isLock],[filepath]" & _
		" FROM [diyplus_fy] " & _
		"ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [diyplus_fy]   "
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"

		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID</th><th>插件名称</th><th>参数</th><th>状态</th><th>地址</th><th>插件名称</th>
	  </tr>
    </thead>
      <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
	%>
	     <tr>
      <td><%= arrinfo(0,i) %></td>
      <td><%= arrinfo(1,i) %></td>
      <td> <a href="list.asp?cid=<%= arrinfo(0,i) %>"><%=fycms.actexe("select count(id) from plusget_fy where cid="&arrinfo(0,i))(0)%>(查看)</a></td>
   
      <td>   <% if  arrinfo(3,i)="0" then 
	  	echo "<font color=green>正常</font>"
	  else
	  	echo "<font color=red>锁定</font>"
 	  end if   %></td>
	    <td  align="center" >
      
      <a  target="_blank" href="<%= rep(fycms.actsys&arrinfo(4,i),"//","/") %>"><%= rep(fycms.actsys&arrinfo(4,i),"//","/") %>&nbsp;</td>
      <td  align="center" >
      
      <a  target="_blank" href="<%= rep(fycms.actsys&arrinfo(4,i),"//","/") %>">预览&nbsp;</a>┆
      <a href="?Action=edit&ID=<%= arrinfo(0,i) %>">编辑&nbsp;</a>┆
	 <a href="?Action=del&ID=<%= arrinfo(0,i) %> " onClick="return confirm('确认删除吗?此操作不可恢复!')">删除</a></td>
    </tr>
	

	<% 
	Next
	End If
	%>
    </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>
     <% end sub
 
  sub add()
 
   %>
  
<form name="form1" method="post" action="Index.asp?Action=addsave">
<div class="divtable"> 
        <dl>
            <dt>插件名称</dt>
            <dd>
               <input name="titles" type="text" class="Ainput" size="40" value=""> 标签调用方法 {info:title}    
            </dd>
         </dl>
        <dl>
            <dt>模版</dt>
            <dd>
                 <input name="templatepath" type="text" class="ainput" id="templatepath"  value="" size="40">
				<input id="PicUrls3" class="btn btn_primary" onClick="javascript:stemp('<%=fycms.actsys&fycms.adminurl%>/include/TempLate/Select.asp?ShowPath=<%=fycms.ThisTheme%>&iname=templatepath');" name="button" type="button"   value="选择模板">
             </dd>
         </dl>
        <dl>
            <dt>插件访问路径</dt>
            <dd>
               <input name="filepath" type="text" class="Ainput" size="40" value=""><font color=red>如果需要更自由化的插件内容.可以直接修改这个文件</font>
             </dd>
         </dl>
        <dl>
            <dt>伪静态</dt>
            <dd>
               <input type="radio"  onClick="rewrites(1)" name="rewrite"  id="rewrite1" value="1"   Checked>否</label>
			  <label for="rewrite2"><input type="radio" name="rewrite"   onClick="rewrites(2)" id="rewrite2"  value="2"   >是</label>
             </dd>
         </dl>
        <dl id="rewrite1"	style="DISPLAY: none">
            <dt>伪静态规则：</dt>
            <dd>
               <input  class="Ainput"  size=30 name="rewriteurl" type="text" id="rewriteurl" value=""  />
             </dd>
         </dl>
        <dl>
            <dt>是否锁定</dt>
            <dd>
               <label for="isLock1"><input type="radio" name="isLock"  id="isLock1" value="0"   Checked>否</label>
		    <label for="isLock2"><input type="radio" name="isLock"  id="isLock2"  value="1"   >是</label>
             </dd>
         </dl>
        <dl>
            <dt>绑定模型</dt>
            <dd>
               <select name="modeid" size="1"  >
 <%
	   
	   Dim IF_NULL,ij,checked
		IF_NULL=fycms.Act_MXtab_Arr()
 		If IsArray(IF_NULL) Then
			For ij=0 To Ubound(IF_NULL,2)
			If modeid=IF_NULL(0,ij) Then checked="selected" Else checked=""
  			 echo "<option value='"&IF_NULL(0,ij)&"' "&checked&">"& IF_NULL(2,ij) & "模型</option>"& vbCrLf
 			Next
		End If
	    
	   %> </select>
             </dd>
         </dl>
        <dl>
            <dt>生成插件</dt>
            <dd>
               <input type="radio" name="ismake"  id="ismake1" value="0"   Checked>否</label>
     <label for="ismake2"><input type="radio" name="ismake"  id="ismake2"  value="1"   >是</label>
 <font color=red>注意.生成插件会覆盖这个文件,请确保这个文件没有被修改过</font>
             </dd>
         </dl>
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
 				<input class="btn" type="reset" name="Submit2" value="重置">
            </dd>
         </dl>
        
    </div>
    </form>

 

<%   end sub 
  
  
  
	sub edit()
	Dim Rs,title,frmAction,rewrite,isLock,rewriteurl
	
  		Set Rs=Conn.Execute("Select * from diyplus_fy Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 echo "不存在！"
				Exit Sub
			End IF	

  	  Dim rs2,strs,strurl,i,sql,strs3
 	Set rs2=fycms.actexe("Select id,entitle From plusget_fy Where cID="&ID)



 	  If Not  rs2.eof Then 
	  sql=rs2.getrows(-1)
 	  for i=0 to ubound(sql,2)
 				strs=strs&sql(1,i)&"-{"&sql(1,i)&"}/"
				If ubound(sql,2)=i Then 
					strurl=strurl&sql(1,i)&"=$"&i+2
				Else 
					strurl=strurl&sql(1,i)&"=$"&i+2&"&"
				End If 
  	  Next
	  strs=fycms.GetEn(fycms.PinYin(delhtml(rs("title"))))&"/"&strs
	Else 
		strurl="请添加参数"
		strs=fycms.actsys&fycms.GetEn(fycms.PinYin(delhtml(rs("title"))))
	End If 


 rewrite=rs("rewrite")
 modeid=rs("modeid")

   %>  
<form name="form1" method="post" action="Index.asp?Action=editsave&ID=<%=ID  %>"> 
<div class="divtable"> 
        <dl>
            <dt>插件名称</dt>
            <dd>
              <input name="titles" type="text" class="Ainput" size="40" value="<%= rs("title") %>"> 标签调用方法 {info:title}    
            </dd>
         </dl>
        
        <dl>
            <dt>模版</dt>
            <dd>
               <input name="templatepath" type="text" class="ainput" id="templatepath"  value="<%= rs("templatepath") %>" size="40">
<input id="PicUrls3" class="btn btn_primary" onClick="javascript:stemp('<%=fycms.actsys&fycms.adminurl%>/include/TempLate/Select.asp?ShowPath=<%=fycms.ThisTheme%>&iname=templatepath');" name="button" type="button"   value="选择模板">
             </dd>
         </dl>
 
        <dl>
            <dt>插件访问路径</dt>
            <dd>
               <input name="filepath" type="text" class="Ainput" size="40" value="<%= rs("filepath") %>"><font color=red>如果需要更自由化的插件内容.可以直接修改这个文件</font>
             </dd>
         </dl>
 
        <dl>
            <dt>伪静态</dt>
            <dd>
               <label for="rewrite11"><input type="radio"  onClick="rewrites(1)" name="rewrite"  id="rewrite11" value="1"   <% if rs("rewrite")="1" then echo "Checked" %> />否</label>
    <label for="rewrite2"><input type="radio" name="rewrite"   onClick="rewrites(2)" id="rewrite2"  value="2"   <% if rs("rewrite")="2" then echo "Checked" %>>是</label>
             </dd>
         </dl>
 
        <dl  id="rewrite1"	<%If rs("rewrite")<>"2" Then echo "style=""DISPLAY: none"""%>>
            <dt>伪静态规则：</dt>
            <dd>
               <input  class="Ainput"  size=80 name="rewriteurl" type="text" id="rewriteurl" value="<%= rs("rewriteurl") %>"  />
	  <input name="testbutton"  class="btn btn_primary"   type='button' value='查看规则' onclick='ajaxcheck();'>
	  <br /> 参考伪静态规则  <%=strs%>  <br /> <br />
	  httpd.ini参考 <span id="f"></span>
             </dd>
         </dl>
 <script language="javascript">


	function ajaxcheck()
	{
		
   var titless=document.form1.titles.value;
  var rewriteurls=document.form1.rewriteurl.value;
  var filepaths=document.form1.filepath.value;
  
 				  $.get("ajaxcheck.asp", { A: "c", cid: <%=id%>,titles: titless,rewriteurl:rewriteurls,filepath:filepaths },
				  function(data){
				
 					var fArr=data.split('|');
							switch (fArr[0])
							{
								 case "0":
									 alert(fArr[1]);
									 break;
									  default:
									  document.getElementById("f").innerHTML = fArr;
							}


				  });
			  } 

 





 
		</script>
        <dl>
            <dt>是否锁定</dt>
            <dd>
               <input type="radio" name="isLock"  id="isLock1" value="0"   <% if rs("isLock")="0" then echo "Checked" %>>否</label>
    <label for="isLock2"><input type="radio" name="isLock"  id="isLock2"  value="1"   <% if rs("isLock")="1" then echo "Checked" %>>是</label>
             </dd>
         </dl>
 
        <dl>
            <dt>绑定模型</dt>
            <dd>
               <select name="modeid" size="1"  >
 <%
	   
	   Dim IF_NULL,ij,checked
		IF_NULL=fycms.Act_MXtab_Arr()
 		If IsArray(IF_NULL) Then
			For ij=0 To Ubound(IF_NULL,2)
			If modeid=IF_NULL(0,ij) Then checked="selected" Else checked=""
  			 echo "<option value='"&IF_NULL(0,ij)&"' "&checked&">"& IF_NULL(2,ij) & "模型</option>"& vbCrLf
 			Next
		End If
	    
	   %> </select>
             </dd>
         </dl>
 
        <dl>
            <dt>生成插件</dt>
            <dd>
               <input type="radio" name="ismake"  id="ismake1" value="0"   <% if rs("ismake")="0" then echo "Checked" %>>否</label>
				<label for="ismake2"><input type="radio" name="ismake"  id="ismake2"  value="1"   <% if rs("ismake")="1" then echo "Checked" %>>是</label>
				<font color=red>注意.生成插件会覆盖这个文件,请确保这个文件没有被修改过</font>
             </dd>
         </dl>
 
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
 				<input class="btn" type="reset" name="Submit2" value="重置">
            </dd>
         </dl>
        
    </div>
    </form>

<script type="text/javascript">
<!--
	function rewrites(n){
	if (n == 1){
		rewrite1.style.display='';
 	}
	else{
		rewrite1.style.display='none';
 	}
} 
//-->
</script>

	<%end sub
CloseConn %>

<script language="javascript">
 
function CheckForm()
{ var form=document.form1;
	 if (form.title.value=='')
		{ alert("请输入插件名称!");   
		  form.title.focus();    
		   return false;
		} 
	 
	    form.submit();
        return true;
	}</script> 
 <script language="javascript">rewrites(<%if ChkNumeric(rewrite)=0 Then rewrite=1:echo rewrite %>);</script>
</div>
</body>
</html>
