<%@ Language=VBScript %>
<%
SERVER_NAME=Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("HTTP_FreeHostAPISITE")<>"" Then SERVER_NAME=Request.ServerVariables("HTTP_FreeHostAPISITE")

hostNow="http://"&SERVER_NAME
if Request.ServerVariables("HTTP_FreeHostAPI")="7i24.com" Then hostNow=""
Function FixString(strWord, intByteLength, intPadDotAmount) 
        If strWord > "" Then 
'                If Length(strWord) <= intByteLength Then 
                If Get_TrueLen(strWord) <= intByteLength Then 
                        FixString = strWord 
                Else 
                        Dim i 
                        Dim intLength 
                        Dim strChar 
                        Dim bytChar 
                        intLength = 0 
                        For i = 1 to Len(strWord) 
                                strChar = Mid(strWord, i, 1) 
                                bytChar = Asc(Mid(strWord, i, 1)) 
                                If bytChar < 0 or bytChar > 255 Then 
                                        intLength = intLength + 2 
                                Else 
                                        intLength = intLength + 1 
                                End If 
                                If intLength > intByteLength Then Exit For 
                                FixString = FixString & strChar 
                        Next 
                        FixString = FixString & String(intPadDotAmount, ".") 
                End If 
        Else 
                FixString = "" 
        End If 
End Function

Function Get_TrueLen(str)
  Dim l, t, c, i
  l = Len(str)
  t = l
  For i = 1 To l
    c = Asc(Mid(str, i, 1))
    If c < 0 Then c = c + 65536
    If c > 255 Then t = t + 1
  Next
  Get_TrueLen = t
End Function

worldLen=500
If Request.QueryString("Len")<>"" Then worldLen=Clng(Request.QueryString("Len"))
%>
document.write("<%
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
		username=Application("superuser")
	if session("agentname")<>"n" then username=session("agentname")
	If session("agentusername")<>"" And session("agentusername")<>"n" then username=session("agentusername")
	Sql="Select top 10 * from FreeHost.FreeHost_News where username='"&username&"' and (type1=0 or type1=1) order by orderbyid desc,id desc"

if Request.QueryString ("typeid")<>"" and  IsNumeric(Request.QueryString("typeid")) then 	Sql="Select top 10 * from FreeHost.FreeHost_News where username='"&username&"'  and typeid='"&Request.QueryString("typeid")&"' and (type1=0 or type1=1) order by orderbyid desc,id desc"

if Request.QueryString ("type1")<>"" and  IsNumeric(Request.QueryString("type1"))  And (Request.QueryString ("type1")="0" Or Request.QueryString ("type1")="1") then 	Sql="Select top 10 * from FreeHost.FreeHost_News where username='"&username&"' and type1='"&Request.QueryString("type1")&"' and (type1=0 or type1=1) order by orderbyid desc,id desc"

if Request.QueryString ("type2")<>"" and  IsNumeric(Request.QueryString("type2")) then 	Sql="Select top 10 * from FreeHost.FreeHost_News where username='"&username&"' and type1=1 and type2='"&Request.QueryString("type2")&"' and (type1=0 or type1=1) order by orderbyid desc,id desc"

if Request.QueryString ("pagesize")<>"" and  IsNumeric(Request.QueryString("pagesize")) then sql = replace(sql,"10 *",Request.QueryString("pagesize")&" *")
	dsph.Open Sql,conn,1,1
X=1
while not dsph.eof
%><a href=<%=hostNow%>/style/info/shownews.asp?id=<%=dsph("id")%> target=_blank><font color=black><%=FixString(Replace(dsph("title"),"""","\"""), worldLen, 3)%></font></a><br><%X=X+1
dsph.movenext
wend
dsph.close
set dsph=nothing
%>");