Avatar billede tusseballer Nybegynder
04. november 2003 - 23:30 Der er 1 kommentar og
1 løsning

Hvordan fjerner jeg password kontrol?

Hvordan fjerner jeg login funktionen i denne kode?

<%
'###################################################
'# Setup
'###################################################
' // Virtuel Path. (Where the poll files are located)
PollAdminpath = "/"

' // Where the database file is located
pollDBLocation=server.mappath(PollAdminpath&"poll.mDB")

' // Admin password. Make sure this is the same as set
' // in processpoll.asp
PollAdminPassword = "Admin"

' // Admin SessionVariable. If this is set, the script
' // will check the specified session variable and
' // skip the login process if <> "".
' // This makes it easy to allow access from a generic admin
' // script
AdminSessionVar="AdminAuthenticated"

'#####################################################################
'## Text used in script. Change this to your own words/Language    ##
'#####################################################################
'# Text for "Password not correct, Please try again" Error Text. Used in Login screen
pollTxtPasswordError="Forkert password, prøv igen"
'# Text for "FinPoll Admin Login" Used in Login screen
pollTxtAdminLogin="FinPoll Admin Login"
'# Text for "Password" Used in Login screen
pollTxtAdminLoginPassword="Password"
'# Text for "Password" Button Used in Login screen
pollTxtAdminLoginButton="Login"

'# Text for "Poll Question" Used in View all Polls screen And modify form
pollTxtPollQuestion="Poll Question"
'# Text for "View" Used in View all Polls screen
pollTxtView="View"
'# Text for "Active" Used in View all Polls screen
pollTxtActive="Active"
'# Text for "Modify" Used in View all Polls screen
pollTxtModify="Modify"
'# Text for "View Votes" Used in View all Polls screen
pollTxtViewVotes="View Votes"
'# Text for "Add new Poll" button. Used in View all Polls screen
pollTxtAddNewButton="Add new Poll"

'# Text for "Please enter a Question for you poll!" button. Used in modify form for validation
pollTxtNotValidQuestion="Please enter a Question for you poll!"
'# Text for "Please enter in at least 2 options!" button. Used in modify form for validation
pollTxtNotValidOptions="Please enter in at least 2 options!"
'# Text for "Option" Used in modify form screen
pollTxtOption="Option"
'# Text for "Save/Modify" button Used in modify form screen
pollTxtSaveModify="Save/Modify"
'# Text for "Delete Poll" button Used in modify form screen
pollTxtDeletePoll="Delete Poll"








'###################################################
'# Start
'###################################################
' // Make sure this page is not Cached
  Response.Buffer = True
  Response.ExpiresAbsolute = Now() - 1
  Response.Expires = 0
  Response.CacheControl = "no-cache"

' Security&Login check
if session(AdminSessionVar)="" then
    if request("pwd")<>"" then
        if lcase(request("pwd"))<>lcase(PollAdminPassword) then
            Response.write(pollTxtPasswordError&"<br><br>")
        else
            Session("PollAdminAuth")="valid"
        end if
    end if
    if Session("PollAdminAuth")<>"valid" then
        call GetAdminPassword()
        response.end
    end if
end if

' // We passed the security check
set DB=server.createobject("ADODB.Connection")
set RS=server.createobject("ADODB.Recordset")
Constr = "Provider=MICROSOFT.JET.OLEDB.4.0; Data Source="&pollDBLocation
PID = request("PID")
Mode = request("mode")

if (Mode="AddNew") then
    AddNewPoll()
elseif (Mode="UpdateActive") then
    UpdateActive(PID)
elseif (Mode="ModifyPoll") then
    ModifyPoll(PID)
elseif (Mode="UpdatePoll") then
    UpdatePoll(PID)
elseif (Mode="DeletePoll") then
    DeletePoll(PID)
else
    ShowAll()
end if

'Cleanup
set RS=nothing
set DB=nothing

'#######################
' // Functions //
'#######################
function ShowAll()
%>
<script language="javascript1.2">
function popitup(page,l,t,w,h)
{
  window.open (page,"_blank","height="+h+",width="+w+",left="+l+",top="+t+", status=no,toolbar=no,menubar=no,location=no,resizable=yes")
}
</script>
<form>
<table border="1" width="100%" cellspacing="1" bgcolor="#FFFFFF" cellpadding="2">
  <tr>
    <td width="35%" height="25" bgcolor="#215D84" class="NormT"><font color="#FFFFFF"><b><u><%=pollTxtPollQuestion%></u></b></font></td>
    <td width="22%" height="25" bgcolor="#215D84" class="NormT"><font color="#FFFFFF"><b><u><%=pollTxtView%></u></b></font> </td>
    <td width="20%" height="25" bgcolor="#215D84" class="NormT"><font color="#FFFFFF"><b><u><%=pollTxtActive%></u></b></font></td>
    <td width="23%" height="25" bgcolor="#215D84" class="NormT"><font color="#FFFFFF"><b><u><%=pollTxtModify%></u></b></font></td>
  </tr>
<%
    FinPollOpenDB()
    RS.open "select * from Questions",DB,1,2
    if not (RS.bof and RS.eof) then
        i=0
        rs.movefirst
        while not rs.eof
          i=i+1
        %>
        <tr>
            <td width="35%" height="25" valign="top" align="left" bgcolor="#DFEDF7" class="NormT"><font color="#000000"><%=RS("Question")%></font></td>
            <td width="22%" height="25" valign="top" align="left" bgcolor="#DFEDF7" class="NormT"><font color="#000000"><a href="java script:popitup('<%=PollAdminpath%>processpoll.asp?QID=<%=RS("QID")%>&AdminMode=<%=PollAdminPassword%>',10,200,200,300)"><%=pollTxtViewVotes%></a></font></td>
            <td width="20%" height="25" valign="top" align="left" bgcolor="#DFEDF7" class="NormT"><font color="#000000"><input type="radio" value="V1" name="Active" onclick="java script:document.location='<%=Request.ServerVariables("SCRIPT_NAME")%>?mode=UpdateActive&PID=<%=RS("QID")%>'" <% if RS("Active")=1 then Response.write("checked") end if%>></font></td>
            <td width="23%" height="25" valign="top" align="left" bgcolor="#DFEDF7" class="NormT"><font color="#000000"><a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?mode=ModifyPoll&PID=<%=RS("QID")%>"><%=pollTxtModify%></a></font></td>
        </tr>
        <%
        rs.movenext
        wend
    else
        call DBProcessError("Error : Could not find active poll")
    end if
    RS.close
    DB.close
%>
  <tr>
    <td colspan=4 align="right" bgcolor="#DFEDF7"><br><input class="NormT" type="button" onclick="java script:document.location='<%=Request.ServerVariables("SCRIPT_NAME")%>?mode=AddNew'" value="<%=pollTxtAddNewButton%>" class="NormT">&nbsp;&nbsp;<br>&nbsp;</td>
  </tr>
</form>
</table>
<%
end function

function AddNewPoll()

'Create new and get ID
FinPollOpenDB()
RS.Open "Questions", DB, 1, 3, 2
Rs.addnew
Rs.update
tmpQID=RS("QID")
Rs.close
db.close
call ModifyPoll(tmpQID)
end function

function UpdateActive(PID)
    FinPollOpenDB()
    RS.open "Update Questions set Active=0 where Active=1",DB,3,3
    RS.open "Update Questions set Active=1 where QID="&PID,DB,3,3
    DB.close
    call ShowAll()
end function

function ModifyPoll(PID)

' // Get the data from DB//
FinPollOpenDB()
RS.open "select Question from Questions where QID="&cstr(PID),DB,1,2
if not (RS.bof and RS.eof) then
    sQuestion=RS("Question")
else
    call DBProcessError("Error : Could not find poll")
end if
RS.close

Dim Counter,arrayObj(6)
Counter=0
RS.open "select * from Poll where QID="&cstr(PID),DB,1,2
Do While Counter < 5
    Counter=Counter+1
    RS.find ("AnID = "+cstr(Counter))
    if not (RS.bof OR RS.eof) then
        arrayObj(Counter)=cstr(RS("AnswerText"))
    end if
loop
RS.close
DB.close
%>
<Script language="Javascript">
function ValidateData(){
if (document.UpdateForm.sQuestion.value==""){
    alert("<%=pollTxtNotValidQuestion%>")
    document.UpdateForm.sQuestion.focus()
    return false;
}
answerCounn=0
for (i = 1; i < 6; i++) {
  if (eval("document.UpdateForm.A"+i+".value")!=""){
      answerCounn++;
  }}
if (answerCounn < 2) {
    alert("<%=pollTxtNotValidOptions%>")
    document.UpdateForm.A1.focus()
    return false;
}
return true;
}
</script>
<table border="1" width="100%" cellspacing="1" bgcolor="#DFEDF7" cellpadding="2">
<form name="UpdateForm" method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>?mode=UpdatePoll&PID=<%=PID%>" ONSUBMIT="return ValidateData();">
<tr>
    <td width="35%" align="right" class="NormT"><b><%=pollTxtPollQuestion%>:</b></td>
    <td width="65%"><input type="text" name="sQuestion" size="35" value="<%=sQuestion%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="left">&nbsp;</td>
    <td valign="top" align="left">&nbsp;</td>
</tr>
<tr>
    <td valign="top" align="right" class="NormT"><%=pollTxtOption%> 1:</td>
    <td valign="top" align="left"><input type="text" name="A1" size="35" value="<%=arrayObj(1)%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="right" class="NormT"><%=pollTxtOption%> 2:</td>
    <td valign="top" align="left"><input type="text" name="A2" size="35" value="<%=arrayObj(2)%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="right" class="NormT"><%=pollTxtOption%> 3:</td>
    <td valign="top" align="left"><input type="text" name="A3" size="35" value="<%=arrayObj(3)%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="right" class="NormT"><%=pollTxtOption%> 4:</td>
    <td valign="top" align="left"><input type="text" name="A4" size="35" value="<%=arrayObj(4)%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="right" class="NormT"><%=pollTxtOption%> 5:</td>
    <td valign="top" align="left"><input type="text" name="A5" size="35" value="<%=arrayObj(5)%>" class="NormT"></td>
</tr>
<tr>
    <td valign="top" align="left">&nbsp;</td>
    <td valign="top" align="right"><input type="submit" value="<%=pollTxtSaveModify%>" class="NormT">&nbsp;&nbsp;<input type="button" onclick="java script:document.location='<%=Request.ServerVariables("SCRIPT_NAME")%>?mode=DeletePoll&PID=<%=PID%>'" value="<%=pollTxtDeletePoll%>" class="NormT"></td>
</form></tr>
</table>

<%
end function

function UpdatePoll(PID)

dim Counter
Counter=1

'Get all updates
sQuestion=ValStr(request("sQuestion"))
sAID1=ValStr(request("A1"))
sAID2=ValStr(request("A2"))
sAID3=ValStr(request("A3"))
sAID4=ValStr(request("A4"))
sAID5=ValStr(request("A5"))

FinPollOpenDB()
RS.open "Update Questions set Question='"&sQuestion&"' where QID="&cstr(PID),DB,3,3

RS.open "select * from Poll where QID="&cstr(PID),DB,3,3,1

if not (RS.bof and RS.eof) then
    Do While ((Counter < 6) AND ( ValStr(request("A"&cstr(Counter)))<>""))
        RS.find ("AnID = "+cstr(Counter))
        if not (RS.bof OR RS.eof) then
            Rs("AnswerText")=ValStr(request("A"&cstr(Counter)))
            Rs.update
        else
            Rs.addnew
            Rs("AnID")=cstr(Counter)
            Rs("AnswerText")=ValStr(request("A"&cstr(Counter)))
            Rs("QID")=cstr(PID)
            Rs.update
        end if
        Counter=Counter+1
    loop
    Rs.close

    ' // Check and delete all where Text has been set to nothing //
    dim ToDeleteSQL
    Do While (Counter < 6)
        if ToDeleteSQL<>"" then
            ToDeleteSQL=ToDeleteSQL&" OR AnID="&cstr(Counter)
        else
            ToDeleteSQL=ToDeleteSQL&" AND (AnID="&cstr(Counter)
        end if
        Counter=Counter+1
    loop
    if ToDeleteSQL<>"" then
        RS.open "delete * from Poll where QID="&cstr(PID)&ToDeleteSQL&")",DB,3,3,1
    end if
else
    'Add all new
    Do While ((Counter < 6) AND (ValStr(request("A"&cstr(Counter)))<>""))
        Rs.addnew
        Rs("AnID")=cstr(Counter)
        Rs("AnswerText")=ValStr(request("A"&cstr(Counter)))
        Rs("QID")=cstr(PID)
        Rs("Answer")=0
        Rs.update
        Counter=Counter+1
    loop
end if
db.close
call ShowAll()
end function

function DeletePoll(PID)
FinPollOpenDB()
RS.open "DELETE * from Questions where QID="&cstr(PID),DB,3,3
db.close
call ShowAll()
end function

function GetAdminPassword()
%>
<b><u><%=pollTxtAdminLogin%></u></b><br><br>
<FORM METHOD="POST" ACTION="polladmin.asp">
<%=pollTxtAdminLoginPassword%>:<br>
<INPUT TYPE=PASSWORD NAME="pwd"><br><br>
<INPUT TYPE=SUBMIT name="Login" value="<%=pollTxtAdminLoginButton%>">
</FORM>
<%
end function

'############################################
'# FinPollOpenDB()
'# Open database, show error if any problems
'############################################
sub FinPollOpenDB()
On ERROR Resume next
DB.open Constr, "Admin",""
if Err.number<>0 then
    Response.write("PollAdmin Error : Could not open DataBase, make sure PollAdminpath are set correctly.")
    Response.end
end if
ON ERROR GOTO 0
end sub

function ValStr(myS)
ValStr = myS
end function
%>
Avatar billede dawin_dk Nybegynder
04. november 2003 - 23:40 #1
fjerner:

' Security&Login check
if session(AdminSessionVar)="" then
    if request("pwd")<>"" then
        if lcase(request("pwd"))<>lcase(PollAdminPassword) then
            Response.write(pollTxtPasswordError&"<br><br>")
        else
            Session("PollAdminAuth")="valid"
        end if
    end if
    if Session("PollAdminAuth")<>"valid" then
        call GetAdminPassword()
        response.end
    end if
end if
Avatar billede tusseballer Nybegynder
04. november 2003 - 23:46 #2
takker du er en guttermand
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester