Hakinen Posted July 26, 2007 Share Posted July 26, 2007 ASP'den pek anlamıyorum.... Bu anket sisteminde, IP , Cookie ve Session kontrolü sadece FORM kısmına konulmuş. Yani, anket kullanma kısmını 10 yeni sayfada açınca hepsine oy kullanabiliyorsunuz... Benim istediğim... Form içinde IP, Session ve Cookie kontrolü Anket kayıt kısmında da kontrol edilsin. Uğraştım yapamadım... ASP Dosyası; <% On Error Resume Next Response.Buffer = True fff = f if not fff = "yama" then %> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> <title>Başlığı</title> <base target="_self"> </head> <body topmargin="20" leftmargin="20" bgcolor="#9DBFE2"> <% end if %> <!-- #include file = "ilave.asp" --> <% if not fff = "yama" then %> <% bic () %> <br><br><br> <% end if Dim yuzde, anket, scnk, toplamOy, izin, digerAnk, SQL(10) if REQUEST.QUERYSTRING( "a" ) <> "" Then If Not biseylerinkontrolu(REQUEST.QUERYSTRING( "a" )) = 0 Or _ Not IsNumeric(REQUEST.QUERYSTRING( "a" )) Then Response.redirect "default.asp" SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id = "& eleme(REQUEST.QUERYSTRING( "a" )) &";" elseif gosterilecek_anket_idSi <> "" then SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id = "& gosterilecek_anket_idSi &";" else SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket ORDER BY anket.anket_id DESC;" end if Set anket = ConnStr.Execute ( SQL(1) ) if anket.eof or anket.bof then 'gösterecek anket ya da ankey numarası kayıtlı değilse gerisi hikaye.. Response.write "Olmayan anket!.." Response.end end if SQL(2) = "SELECT scnk_id, anket_id, scnk_metni, scnk_oy FROM scnk " &_ "WHERE anket_id = "& anket( "anket_id" ) &" ORDER BY scnk.scnk_id ASC;" 'en son eklenen anketi anasayfada götsterir. Set scnk = ConnStr.Execute ( SQL(2) ) Dim aypibakisi Set aypibakisi = ConnStr.Execute ( "SELECT * FROM aypiler WHERE " &_ "ip = '"& Request.ServerVariables("REMOTE_ADDR") &"' AND anketaydi = "& anket( "anket_id" ) &";" ) if Request.Cookies( "anKet" )( ""& anket( "anket_id" ) &"" ) = "oyKullandi" or _ Session( "anKet" ) = anket( "anket_id" ) Or Not aypibakisi.eof then izin = false else izin = true 'eğer oykullanangil oyunu kullanmışsa bazı şeyleri gizleyeceğiz. if izin = true then %> <script language="javascript"> <!-- buooo function kabul(f) { if ( document.forms.oyVer.scnkOYat.checked == false ) { document.forms.oyVer.Gonder.disabled=true; return false; } else { document.forms.oyVer.Gonder.disabled=false; return true; } } // busuuu --> </script> <body OnLoad="self.focus(); document.forms.oyVer.Gonder.disabled=true;" bgcolor="#9DBFE2" > <% end if SQL(3) = "SELECT SUM(scnk_oy) FROM scnk WHERE anket_id = "& anket( "anket_id" ) &";" Set toplamOy = ConnStr.Execute ( SQL(3) ) if izin = true then if fff = "yama" then Response.write "<form name=""oyVer"" method=""post""" &_ "action=""default.asp?i=oyAt&a="& gosterilecek_anket_idSi &""">" else Response.write "<form name=""oyVer"" method=""post"" action=""default.asp?i=oyAt"">" end if end if 'kullanıcımız oyunu kullanmamışsa yukarıda satırı işlet. Response.write "<table border=""0"" cellspacing=""1"" cellpadding=""3""><tr><td></td><td colspan=""2"">" Response.write "<b>" & anket( "anket_basligi" ) & "</b> <i>("& anket( "anket_acilis_tarihi" ) &")</i><br><font size=""1"">Bu ankete</i> <b>"& FormatNumber(Int(toplamOy(0)),0) &"</b> <i>kişi tarafından oy verildi.</font>" Response.write "<hr size=""1"" color=""#C0C0C0""></td></tr>" dim n, nid, renk, muse do until scnk.eof 'seçeneklerin dibini görene kadar ilerle. if toplamOy(0) = 0 then yuzde = 0 else yuzde = ((scnk( "scnk_oy" ) / toplamOy(0)) * 100) 'çubukların büyüklüğüne(ya da uzunluğuna) böyle karar veriyoruz. 'seçeneğin aldığı oy bölü toplam oy çarpı yüz end if Response.write "<tr><td valign=""top"">" if izin = true then Response.write "<input type=""radio"" id="""& scnk( "scnk_id" ) &""" onclick=""kabul(this)"" " &_ "name=""scnkOYat"" value="""& scnk( "scnk_id" ) &""">" end If n=n + 1 nid=right(n,1) select case nid case "2","4","6","8" renk = "#FFFFFF" '1.renk case else renk = "#E1E0D9" '2. renk end Select Response.write "</td><td bgcolor="""& renk &""" style=""padding-right: 10px;""" if izin = false Then Response.write "align=""right""" Response.write ">" if izin = True Then Response.write "<label for="""& scnk( "scnk_id" ) &""">" set muse = new cilek muse.yaza = scnk( "scnk_metni" ) muse.satirKacKarakter = 40 'kaç karakterden sonra alt satıra geçeceğini buradan ayarlıyoruz. muse.yazit set muse = Nothing if izin = True Then Response.write "</label>" if izin = false then 'ancak oy kullananlar yüzdeleri ve verilen oyları görebilecek. Response.write "</td><td valign=""top"" bgcolor="""& renk &""" style=""padding-right: 30px;"">" Response.write "<img src=""krmz.gif"" width="""& FormatNumber(yuzde,3) + 1 &""" " Response.write "height=""12""> " Response.write "<font size=""1"">%"& FormatNumber(yuzde,1) &" ("& FormatNumber(scnk( "scnk_oy" ),0) &" oy)</font>" 'yüzde resimlerinin ve aldııkları oyların göründüğü yer. Response.write "</td></tr>" end if scnk.movenext loop if izin = true then 'oy kullanan bir daha oy kullanmasın diye "gönder" düğmesini kaldırıyoruz. Response.write "<tr><td></td><td colspan=""2""><hr size=""1"" color=""#C0C0C0""><input name=""Gonder"" type=""submit""" &_ "value=""gönder / sonuçları göster"" class=""form1""></td></tr>" end if if izin = true then Response.write "</form>" if izin = false then Response.write "<tr><td></td><td colspan=""2""><hr size=""1"" color=""#C0C0C0""><font size=""1""><i>" Response.write "Daha önce oy kullandığınız için bi'daha oy kullanamazsınız." 'daha önceden oy kullanmış olanlara söylenecek söz. Response.write "</i></font></td></tr>" end If Response.write "</table>" if fff = "yama" then Response.write "<br>- <a href=""default.asp?a="& gosterilecek_anket_idSi &""">Diğer anketler</a>" end if if not fff = "yama" then Response.write "<h2>Diğer Anketler:</h2><hr size=""1"" width=""200"" align=""left"">" if REQUEST.QUERYSTRING( "i" ) = "oyAt" then oyKaydet () SQL(6) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id <> "& anket( "anket_id" ) &";" 'görünen anket hariç, diğer anketleri göstermek için. Set digerAnk = ConnStr.Execute ( SQL(6) ) do until digerAnk.eof Response.write "<img src=""rats.gif"" align=""absbottom""> <a href=""default.asp?a=" & digerAnk( "anket_id" ) & """>" Response.write "" & digerAnk( "anket_basligi" ) & "" Response.write "</a> <i>("& digerAnk( "anket_acilis_tarihi" ) &")</i> <br>" digerAnk.movenext : loop Response.write "<hr size=""2"" width=""340"" align=""left"" color=""#000000"">" end if Private Sub oyKaydet () if Request.Form( "scnkOYat" ) = "" then Response.redirect "default.asp" Dim anketiNe SQL(4) = "SELECT * FROM scnk WHERE scnk_id = "& Request.Form( "scnkOYat" ) &";" Set anketiNe = ConnStr.Execute ( SQL(4) ) SQL(5) = "UPDATE scnk SET scnk_oy = (scnk_oy + 1) WHERE scnk_id = "& Request.Form( "scnkOYat" ) &"" ConnStr.Execute ( SQL(5) ) 'böylece oy sayısını bir artırdık. Response.Cookies( "anKet" )( ""& anketiNe( "anket_id" ) &"" ) = "oyKullandi" 'kullanan bir daha kullanmasın diye cookie attık. Response.Cookies( "anKet" ).expires = Now() + 365 'attığımız coookie'yi bir yıl - 6 saat sonra sileceğiz. Session( "anKet" ) = anketiNe( "anket_id" ) 'cookie'yi silerse ardında Session göz-kulak olsun. Set anketiNe = ConnStr.Execute ( "INSERT INTO aypiler (ip, anketaydi) VALUES " &_ "('"& Request.ServerVariables("REMOTE_ADDR") &"', "& anketiNe( "anket_id" ) &");" ) 'anketin, yeni sürümünün, yeni sürümünün çıkmasının asıl nedeni olan ip kontrolü yapmamasını kapatmış olduk arada. if fff = "yama" then Response.redirect "default.asp?a="& Int( gosterilecek_anket_idSi ) &"" else Response.redirect REQUEST.SERVERVARIABLES( "HTTP_REFERER" ) 'gelinen sayfaya ******ürme işlemi. end if End Sub %> <% if not fff = "yama" then sahip () %> <% if not fff = "yama" then %> </body> </html> <% end if %>[/CODE][b]ASP den iyi anlayan arkdaşların yardımlarını bekliyorum[/b] Link to comment Share on other sites More sharing options...
Hakinen Posted August 3, 2007 Author Share Posted August 3, 2007 Kendime teşekkür ederim... Sonunda azimle gururla kıvançla başarabildim. Bu ANket scripti elinde olan varsa kullanabilir. <% On Error Resume Next Response.Buffer = True fff = f if not fff = "yama" then %> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> <title>Başlık</title> <base target="_self"> </head> <body topmargin="20" leftmargin="20" bgcolor="#9DBFE2"> <% end if %> <!-- #include file = "ilave.asp" --> <% if not fff = "yama" then %> <% bic () %> <br><br><br> <% end if Dim yuzde, anket, scnk, toplamOy, izin, digerAnk, SQL(10) if REQUEST.QUERYSTRING( "a" ) <> "" Then If Not biseylerinkontrolu(REQUEST.QUERYSTRING( "a" )) = 0 Or _ Not IsNumeric(REQUEST.QUERYSTRING( "a" )) Then Response.redirect "default.asp" SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id = "& eleme(REQUEST.QUERYSTRING( "a" )) &";" elseif gosterilecek_anket_idSi <> "" then SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id = "& gosterilecek_anket_idSi &";" else SQL(1) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket ORDER BY anket.anket_id DESC;" end if Set anket = ConnStr.Execute ( SQL(1) ) if anket.eof or anket.bof then 'gösterecek anket ya da ankey numarası kayıtlı değilse gerisi hikaye.. Response.write "Olmayan anket!.." Response.end end if SQL(2) = "SELECT scnk_id, anket_id, scnk_metni, scnk_oy FROM scnk " &_ "WHERE anket_id = "& anket( "anket_id" ) &" ORDER BY scnk.scnk_id ASC;" 'en son eklenen anketi anasayfada götsterir. Set scnk = ConnStr.Execute ( SQL(2) ) Dim aypibakisi Set aypibakisi = ConnStr.Execute ( "SELECT * FROM aypiler WHERE " &_ "ip = '"& Request.ServerVariables("REMOTE_ADDR") &"' AND anketaydi = "& anket( "anket_id" ) &";" ) if Request.Cookies( "anKet" )( ""& anket( "anket_id" ) &"" ) = "oyKullandi" or _ Session( "anKet" ) = anket( "anket_id" ) Or Not aypibakisi.eof then izin = false else izin = true 'eğer oykullanangil oyunu kullanmışsa bazı şeyleri gizleyeceğiz. if izin = true then %> <script language="javascript"> <!-- buooo function kabul(f) { if ( document.forms.oyVer.scnkOYat.checked == false ) { document.forms.oyVer.Gonder.disabled=true; return false; } else { document.forms.oyVer.Gonder.disabled=false; return true; } } // busuuu --> </script> <body OnLoad="self.focus(); document.forms.oyVer.Gonder.disabled=true;" bgcolor="#9DBFE2" > <% end if SQL(3) = "SELECT SUM(scnk_oy) FROM scnk WHERE anket_id = "& anket( "anket_id" ) &";" Set toplamOy = ConnStr.Execute ( SQL(3) ) if izin = true then if fff = "yama" then Response.write "<form name=""oyVer"" method=""post""" &_ "action=""default.asp?i=oyAt&a="& gosterilecek_anket_idSi &""">" else Response.write "<form name=""oyVer"" method=""post"" action=""default.asp?i=oyAt"">" end if end if 'kullanıcımız oyunu kullanmamışsa yukarıda satırı işlet. Response.write "<table border=""0"" cellspacing=""1"" cellpadding=""3""><tr><td></td><td colspan=""2"">" Response.write "<b>" & anket( "anket_basligi" ) & "</b> <i>("& anket( "anket_acilis_tarihi" ) &")</i><br><font size=""1"">Bu ankete</i> <b>"& FormatNumber(Int(toplamOy(0)),0) &"</b> <i>kişi tarafından oy verildi.</font>" Response.write "<hr size=""1"" color=""#C0C0C0""></td></tr>" dim n, nid, renk, muse do until scnk.eof 'seçeneklerin dibini görene kadar ilerle. if toplamOy(0) = 0 then yuzde = 0 else yuzde = ((scnk( "scnk_oy" ) / toplamOy(0)) * 100) 'çubukların büyüklüğüne(ya da uzunluğuna) böyle karar veriyoruz. 'seçeneğin aldığı oy bölü toplam oy çarpı yüz end if Response.write "<tr><td valign=""top"">" if izin = true then Response.write "<input type=""radio"" id="""& scnk( "scnk_id" ) &""" onclick=""kabul(this)"" " &_ "name=""scnkOYat"" value="""& scnk( "scnk_id" ) &""">" end If n=n + 1 nid=right(n,1) select case nid case "2","4","6","8" renk = "#FFFFFF" '1.renk case else renk = "#E1E0D9" '2. renk end Select Response.write "</td><td bgcolor="""& renk &""" style=""padding-right: 10px;""" if izin = false Then Response.write "align=""right""" Response.write ">" if izin = True Then Response.write "<label for="""& scnk( "scnk_id" ) &""">" set muse = new cilek muse.yaza = scnk( "scnk_metni" ) muse.satirKacKarakter = 40 'kaç karakterden sonra alt satıra geçeceğini buradan ayarlıyoruz. muse.yazit set muse = Nothing if izin = True Then Response.write "</label>" if izin = false then 'ancak oy kullananlar yüzdeleri ve verilen oyları görebilecek. Response.write "</td><td valign=""top"" bgcolor="""& renk &""" style=""padding-right: 30px;"">" Response.write "<img src=""krmz.gif"" width="""& FormatNumber(yuzde,3) + 1 &""" " Response.write "height=""12""> " Response.write "<font size=""1"">%"& FormatNumber(yuzde,1) &" ("& FormatNumber(scnk( "scnk_oy" ),0) &" oy)</font>" 'yüzde resimlerinin ve aldııkları oyların göründüğü yer. Response.write "</td></tr>" end if scnk.movenext loop if izin = true then 'oy kullanan bir daha oy kullanmasın diye "gönder" düğmesini kaldırıyoruz. Response.write "<tr><td></td><td colspan=""2""><hr size=""1"" color=""#C0C0C0""><input name=""Gonder"" type=""submit""" &_ "value=""gönder / sonuçları göster"" class=""form1""></td></tr>" end if if izin = true then Response.write "</form>" if izin = false then Response.write "<tr><td></td><td colspan=""2""><hr size=""1"" color=""#C0C0C0""><font size=""1""><i>" Response.write "Daha önce oy kullandığınız için bi'daha oy kullanamazsınız." 'daha önceden oy kullanmış olanlara söylenecek söz. Response.write "</i></font></td></tr>" end If Response.write "</table>" if fff = "yama" then Response.write "<br>- <a href=""default.asp?a="& gosterilecek_anket_idSi &""">Diğer anketler</a>" end if if not fff = "yama" then Response.write "<h2>Diğer Anketler:</h2><hr size=""1"" width=""200"" align=""left"">" if REQUEST.QUERYSTRING( "i" ) = "oyAt" then oyKaydet () SQL(6) = "SELECT anket_id, anket_basligi, anket_acilis_tarihi " &_ "FROM anket WHERE anket_id <> "& anket( "anket_id" ) &";" 'görünen anket hariç, diğer anketleri göstermek için. Set digerAnk = ConnStr.Execute ( SQL(6) ) do until digerAnk.eof Response.write "<img src=""rats.gif"" align=""absbottom""> <a href=""default.asp?a=" & digerAnk( "anket_id" ) & """>" Response.write "" & digerAnk( "anket_basligi" ) & "" Response.write "</a> <i>("& digerAnk( "anket_acilis_tarihi" ) &")</i> <br>" digerAnk.movenext : loop Response.write "<hr size=""2"" width=""340"" align=""left"" color=""#000000"">" end if Private Sub oyKaydet () if Request.Form( "scnkOYat" ) = "" then Response.redirect "default.asp" Dim anketiNeSQL(4) = "SELECT * FROM scnk WHERE scnk_id = "& Request.Form( "scnkOYat" ) &";" Set anketiNe = ConnStr.Execute ( SQL(4) ) Set aypibakisi = ConnStr.Execute ( "SELECT * FROM aypiler WHERE " &_ "ip = '"& Request.ServerVariables("REMOTE_ADDR") &"' AND anketaydi = "& anketiNe( "anket_id" ) &";" ) if Request.Cookies( "anKet" )( ""& anketiNe( "anket_id" ) &"" ) = "oyKullandi" or _ Session( "anKet" ) = anketiNe ( "anket_id" ) Or Not aypibakisi.eof then izin = false else izin = true 'eğer oykullanangil oyunu kullanmışsa bazı şeyleri gizleyeceğiz. if izin = true then SQL(5) = "UPDATE scnk SET scnk_oy = (scnk_oy + 1) WHERE scnk_id = "& Request.Form( "scnkOYat" ) &"" ConnStr.Execute ( SQL(5) ) 'böylece oy sayısını bir artırdık. Response.Cookies( "anKet" )( ""& anketiNe( "anket_id" ) &"" ) = "oyKullandi" 'kullanan bir daha kullanmasın diye cookie attık. Response.Cookies( "anKet" ).expires = Now() + 365 'attığımız coookie'yi bir yıl - 6 saat sonra sileceğiz. Session( "anKet" ) = anketiNe( "anket_id" ) 'cookie'yi silerse ardında Session göz-kulak olsun. Set anketiNe = ConnStr.Execute ( "INSERT INTO aypiler (ip, anketaydi) VALUES " &_ "('"& Request.ServerVariables("REMOTE_ADDR") &"', "& anketiNe( "anket_id" ) &");" ) 'anketin, yeni sürümünün, yeni sürümünün çıkmasının asıl nedeni olan ip kontrolü yapmamasını kapatmış olduk arada.end If if fff = "yama" then Response.redirect "default.asp?a="& Int( gosterilecek_anket_idSi ) &"" else Response.redirect REQUEST.SERVERVARIABLES( "HTTP_REFERER" ) 'gelinen sayfaya ******ürme işlemi. end if End Sub %> <% if not fff = "yama" then sahip () %> <% if not fff = "yama" then %> </body> </html> <% end if %>[/CODE] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.