<%
'乘风多用户计数器 Sql版
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，就没有放在程序里，请自己上网站上查看
'有完整版本的演示
%>
<%
'不进行action判断的话会漏洞备份文件名信息
If Action<>"dbdo" Then Response.End
%>

<table class="tb_1">
<tr class="tr_1"> 
    <td>执行Sql语句</td>
  </tr>
  <form name="form2" method="post" action="?action=sqlexesave">
    <tr> 
      <td><textarea name="sql" cols="80" rows="5" id="sqlcmd"></textarea> 
      </td>
    </tr>
    <tr>
      <td>请输入管理员密码确认执行：
        <input type="password" name="Pwd"></td>
    </tr>
    <tr>
      <td><input type="submit" name="Submit" value="确定执行以上Sql语句" onclick="return confirm('确定执行以上Sql语句吗?')">
        注：多行语句执行以回车换行，每一行要求为一完整语句</td>
    </tr>
  </form>

<tr class="tr_1"> 
<td>数据库表记录数查看</td>
</tr>

<script language=JavaScript>
function searchcheck_rsnumview()
{ 
 var searchurl ="?Action=<%=Action%>&DoType=rsnumview"
 searchurl += '&RsNum=' + document.getElementById('RsNum').value;
 location.href= searchurl ;
}
</script>
<tr> 
<td>查看记录数大于或等于
<%
If ChkStr(Request("RsNum"),2)="" Then
 RsNum = StoreRsTotal
Else
 RsNum = ChkStr(Request("RsNum"),2)
End If
%>
<input name="RsNum" id="RsNum" type="text" value="<%=RsNum%>" size="10" />
的表的名称
<input type="button" name="Submit2" value="查看" onclick="searchcheck_rsnumview()">
&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="Submit2" value="返回" onclick="location.href='?Action=<%=Action%>';">
</td>
</tr>


<%
If Request("DoType")="rsnumview" Then
%>
<tr> 
<td>

<table>
<%
RsNum=GoBack(ChkStr(Request("RsNum"),2),"请输入记录数")

Sql="select o.name,i.rows from sysobjects o,sysindexes i where o.id=i.id and o.Xtype='U' and i.indid<2 and i.rows>="&RsNum&" order by i.rows desc,o.name"
Set Rs=Conn.Execute(Sql)

If Rs.Eof Then Response.write "没有找到记录数大于"&RsNum&"的表"
While Not Rs.Eof
 Response.write "<tr><td>"&Rs(0)&"</td><td>"&Rs(1)&"</td></tr>"
Rs.MoveNext
Wend
%>
</table>

</td>
</tr>
<%
End If
%>

<tr class="tr_1"> 
<td>最大自动增长设置数和数据库实现数比较</td>
</tr>

<script language=JavaScript>
function searchcheck_maxmyidview()
{ 
 var searchurl ="?Action=<%=Action%>&DoType=maxmyidview"
 location.href = searchurl ;
}
</script>
<tr> 
<td><input type="button" name="Submit2" value="查看" onclick="searchcheck_maxmyidview()">
&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="Submit2" value="返回" onclick="location.href='?Action=dbdo';">
</td>
</tr>



<%
If Request("DoType")="maxmyidview" Then
%>
<tr> 
<td>

<table>
<%
Sql = "Select "
Sql = Sql & "'CFCount_Alexa_Day:'+ Convert(varchar,MaxMyID_Alexa_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Alexa_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Alexa_Month:'+ Convert(varchar,MaxMyID_Alexa_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Alexa_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Alexa_Week:'+ Convert(varchar,MaxMyID_Alexa_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Alexa_Week)) + '<br>' + "

Sql = Sql & "'CFCount_Area:'+ Convert(varchar,MaxMyID_Area) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Area)) + '<br>' + "
Sql = Sql & "'CFCount_Area_Day:'+ Convert(varchar,MaxMyID_Area_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Area_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Area_Month:'+ Convert(varchar,MaxMyID_Area_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Area_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Area_Week:'+ Convert(varchar,MaxMyID_Area_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Area_Week)) + '<br>' + "

Sql = Sql & "'CFCount_Back_Day:'+ Convert(varchar,MaxMyID_Back_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Back_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Back_Month:'+ Convert(varchar,MaxMyID_Back_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Back_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Back_Week:'+ Convert(varchar,MaxMyID_Back_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Back_Week)) + '<br>' + "

Sql = Sql & "'CFCount_Count_Day:'+ Convert(varchar,MaxMyID_Count_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Count_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Count_Hour:'+ Convert(varchar,MaxMyID_Count_Hour) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Count_Hour)) + '<br>' + "
Sql = Sql & "'CFCount_Count_Month:'+ Convert(varchar,MaxMyID_Count_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Count_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Count_Week:'+ Convert(varchar,MaxMyID_Count_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Count_Week)) + '<br>' + "

Sql = Sql & "'CFCount_IpHead:'+ Convert(varchar,MaxMyID_IpHead) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_IpHead)) + '<br>' + "
Sql = Sql & "'CFCount_IpHead_Day:'+ Convert(varchar,MaxMyID_IpHead_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_IpHead_Day)) + '<br>' + "
Sql = Sql & "'CFCount_IpHead_Month:'+ Convert(varchar,MaxMyID_IpHead_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_IpHead_Month)) + '<br>' + "
Sql = Sql & "'CFCount_IpHead_Week:'+ Convert(varchar,MaxMyID_IPHead_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_IpHead_Week)) + '<br>' + "

Sql = Sql & "'CFCount_Ly:'+ Convert(varchar,MaxMyID_Ly) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Ly)) + '<br>' + "
Sql = Sql & "'CFCount_Ly_Day:'+ Convert(varchar,MaxMyID_Ly_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Ly_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Ly_Month:'+ Convert(varchar,MaxMyID_Ly_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Ly_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Ly_Week:'+ Convert(varchar,MaxMyID_Ly_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Ly_Week)) + '<br>' + "

Sql = Sql & "'CFCount_Search:'+ Convert(varchar,MaxMyID_Search) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Search)) + '<br>' + "
Sql = Sql & "'CFCount_Search_Day:'+ Convert(varchar,MaxMyID_Search_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Search_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Search_Month:'+ Convert(varchar,MaxMyID_Search_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Search_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Search_Week:'+ Convert(varchar,MaxMyID_Search_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Search_Week)) + '<br>' + "

Sql = Sql & "'CFCount_SearchKeyword:'+ Convert(varchar,MaxMyID_SearchKeyword) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_SearchKeyword)) + '<br>' + "
Sql = Sql & "'CFCount_SearchKeyword_Day:'+ Convert(varchar,MaxMyID_SearchKeyword_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_SearchKeyword_Day)) + '<br>' + "
Sql = Sql & "'CFCount_SearchKeyword_Month:'+ Convert(varchar,MaxMyID_SearchKeyword_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_SearchKeyword_Month)) + '<br>' + "
Sql = Sql & "'CFCount_SearchKeyword_Week:'+ Convert(varchar,MaxMyID_SearchKeyword_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_SearchKeyword_Week)) + '<br>' + "


Sql = Sql & "'CFCount_Web:'+ Convert(varchar,MaxMyID_Web) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Web)) + '<br>' + "
Sql = Sql & "'CFCount_Web_Day:'+ Convert(varchar,MaxMyID_Web_Day) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Web_Day)) + '<br>' + "
Sql = Sql & "'CFCount_Web_Month:'+ Convert(varchar,MaxMyID_Web_Month) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Web_Month)) + '<br>' + "
Sql = Sql & "'CFCount_Web_Week:'+ Convert(varchar,MaxMyID_Web_Week) + '-' + Convert(varchar,(select Isnull(Max(myid),0) From CFCount_Web_Week)) + '<br>' "


Sql = Sql & " From CFCount_Admin "

Set Rs=Conn.Execute(Sql)


Response.write "<tr><td>"&Rs(0)&"</td></tr>"
Rs.Close
%>
</table>

</td>
</tr>
<%
End If
%>

<tr class="tr_1"> 
<td>清理设置最大保留记录外的记录</td>
</tr>

<tr> 
<td><a href="AdminUser.aspx?Action=outdatadel" onclick="return confirm('确定要清理吗?')" class="t_button">点击开始执行清理</a></td>
</tr>


<tr class="tr_1"> 
<td>优化索引</td>
</tr>
<tr> 
<td><a href="AdminUser.aspx?Action=indexoptimize" onclick="return confirm('确定要优化吗?')" class="t_button">点击开始执行优化</a></td>
</tr>

<tr class="tr_1"> 
<td>修正索引错误</td>
</tr>

<tr> 
<td><a href="AdminUser.aspx?Action=indexrecover" onclick="return confirm('确定要修正吗?')" class="t_button">点击开始执行修正</a></td>
</tr>

<tr class="tr_1"> 
      <td>数据库日志压缩</td>
  </tr>
    <tr> 
      <td>
<a href="AdminUser.aspx?Action=dbys" onclick="return confirm('确定要压缩数据库吗?')" class="t_button">点击压缩数据库</a>
        注：任何时候可以操作，但每次操作不要间隔太短，如一分钟内操作好几次</td>
    </tr>
<tr class="tr_1"> 
      <td> 数据库备份</td>
  </tr>
    <tr> 
      <td>
<a href="AdminUser.aspx?Action=dbbackup" onclick="return confirm('确定要备份数据库吗?此操作可能需要花费比较长的时间')" class="t_button">点击备份数据库</a>
      注：条件是程序和数据库放在一台服务器上，每次操作不要间隔太短，如一分钟内操作好几次，备份数据库放在程序的data目录里，以backup开头后面是备份的时间的文件格式命名，数据库大的话可此操作需要花费比较长的时间</td>
    </tr>

	
    <tr>
      <td><%
foldername=server.mappath("data")
path=foldername
If Instr(path,"\data")=0 Then Call AlertBack("不能浏览这个目录！",1)
ShowFolderList(path) 



Function ShowFolderList(folderspec) 
temp=request.ServerVariables("HTTP_REFERER") 
temp=left(temp,Instrrev(temp,"/")) 
temp1=len(folderspec)-len(server.MapPath("./"))-1 
if temp1>0 then 
temp1=right(folderspec,cint(temp1)) 
elseif temp1=-1 then 
temp1="" 
end if 
tempurl=temp+replace(temp1,"\","/")+"/" 
Set fso = CreateObject("Scripting.FileSystemObject") 
upfolderspec=fso.GetParentfoldername(folderspec&"\") 
%>
<table style="width:100%">
                  <tr> 
                    <td>名称</td>
                    
          <td>大小</td>
                    
          <td>类型</td>
                    <td><div>修改时间</td>
                  </tr>
                  <% 
'列出目录 
Set f = fso.GetFolder(folderspec) 
Set fc = f.SubFolders 
For Each f1 in fc 
%>
                  <tr> 
                    <td><%= f1.name%></td>
                    <td> 
                        <%MySize=f1.size/1024
	  If MySize<1024 Then Response.write FormatNumber(MySize,2,-1,0,0)&"K"
	  If MySize>=1024 Then Response.write FormatNumber(MySize/1024,2,-1,0,0)&"M"%>
                    </td>
                    <td>文件夹</td>
                    <td><%= f1.datelastmodified%></td>
                  </tr>
                  <% 
Next 
foldername=StrReverse(left(StrReverse(folderspec),instr(StrReverse(folderspec),"\")-1))&"/"
'列出文件 
Set fc = f.Files 
For Each f1 in fc 
%>
                  <tr> 
                    <td><%= f1.name%></td>
                    <td>
                        <%MySize=f1.size/1024
	  If MySize<1024 Then Response.write  FormatNumber(MySize,2,-1,0,0)&"K"
	  If MySize>=1024 Then Response.write  FormatNumber(MySize/1024,2,-1,0,0)&"M"%>
                    </td>
                    <td>文件</td>
                    <td><%= f1.datelastmodified%></td>
                  </tr>
                  <% 
Next 
set fso=nothing 
%>
        </table>
                <%End Function %></td>
  </tr>
</table>
        </td>
  </tr>
</table>