<% Function String_GetFullPath( strVirtualPath ) String_GetFullPath = Server.MapPath( strVirtualPath ) String_GetFullPath = Replace(String_GetFullPath,"/","\") End Function Function PollMentor_GetDatabaseConn() Dim oRet Dim strDSN Set oRet = Server.CreateObject ("ADODB.Connection") strDSN = "provider=microsoft.jet.oledb.4.0;data source="& server.mappath("dados/dados.mdb")& ";Jet OLEDB:Database Password=wsbalaminut" oRet.Open strDSN Set PollMentor_GetDatabaseConn = oRet End Function Function PollMentor_GetTitle() PollMentor_GetTitle = "Enquete" End Function Function PollMentor_TryToVote( sID, nNumber ) Dim sRet, strSQL Dim oConn Set oConn = PollMentor_GetDatabaseConn() 'Get real id... Dim oRS If sID = -1 Then Set oRS = oConn.Execute("select id from Tab_Enquete_poll where active=true") sID = oRS("id").Value oRS.Close Set oRS= Nothing End If If PollMentor_CanUserVote( oConn, sID ) = False Then sRet = "Você já votou nesta enquete. Não é possível votar novamente." Else strSQL = "update Tab_Enquete_poll set count" & nNumber & " = count" & nNumber & " +1 where " If nNumber =-1 Then strSQL = strSQL & " active=true" Else strSQL = strSQL & " id=" & sID End If oConn.Execute strSQL oConn.Execute "insert into Tab_Enquete_votelog(poll_id, ip) values(" & sID & ",'" & Request.ServerVariables( "REMOTE_ADDR" ) & "')" sRet = "Obrigado por participar." End If oConn.Close Set oConn = Nothing PollMentor_TryToVote=sRet End Function Function PollMentor_CanUserVote( oConn, sID ) ' 'Check of user already has voted within 24 hours? 'If so then no voting can be done... ' Here's your chance to display some other content '1. Check IP address Dim strSQL, sTime, oRS sTime = DateAdd( "d", -Request.Form("time"), now() ) strSQL = "select id from Tab_Enquete_votelog where poll_id=" & sID & " AND datum < #"&sTime & "# AND ip='" & Request.ServerVariables( "REMOTE_ADDR" ) & "'" Set oRS = oConn.Execute(strSQL) If oRS.EOF Then PollMentor_CanUserVote = True Else PollMentor_CanUserVote = False End If oRS.Close Set oRS = Nothing End Function Function PollMentor_GetPollInfo ( ByVal nID, ByRef sTitle, ByRef sQuestion, ByRef vAnswers, ByRef vCount ) Dim sRet, strSQL Dim oConn, oRS, nCount Set oConn = PollMentor_GetDatabaseConn() strSQL = "select * from Tab_Enquete_poll where " If nID = -1 Then strSQL = strSQL & " active=true" Else strSQL = strSQL & " id=" & nID End If Set oRS = oConn.Execute(strSQL) If oRS.EOF Then PollMentor_GetPollInfo = False Else sTitle=PollMentor_GetTitle() sQuestion=oRS("question") For nCount=1 To 8 vAnswers(nCount)=oRS("answer" & CStr(nCount)) vCount(nCount)=oRS("count" & CStr(nCount)) Next PollMentor_GetPollInfo = True End If oRS.Close Set oRS = Nothing oConn.Close Set oConn = Nothing End Function %>