SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict thoresson's Avatar
    Join Date
    Dec 2002
    Location
    Gothenburg, Sweden
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto login for pre-defined ip's

    Hi,

    First a disclaimer: This question might be really easy to answer, but my programming skills are in PHP. Thing is, I've recently got a ASP site to handle as well, and need to make a quick addition to it.

    The site is for subscribers only. The frontpage is open to everyone, but when one clicks a link on the frontpage, the visitor is redirected to a login form. The code that processes the form checks the username and password. If they match, a session variable is set and the browser is forwarded to the link clicked in the first place.

    Now, I want to make a addition: When a user that is not logged in clicks on a link on the frontpage, before the login form is shown, I want to compare the browser ip address to a list with subscriber ip addresses. If the browser ip is in that list, the login form should not be shown. Instead should the session variable be set and the browser forwarded to the article requested.

    This is the code I want executed if the browser ip match:
    PHP Code:
                session("lasare") = true
                response
    .redirect "artikel.asp?" request.form("nextpage"
    And then I want some kind of if-statment in login.asp
    PHP Code:
        if (browserIp is in validList.txt)
                
    session("lasare") = true
                response
    .redirect "artikel.asp?" request.form("nextpage")
        else
                
    /** show html-form here **/
        
    endif 
    Finally, I would prefer if the list with ip-addresses could be in a textfile formatted something like this, with the possibility to add comments:
    PHP Code:
        Customer one
        123.123.123.120
        123.123.123.121
        
    ;Customer two
        124.124.124.120
        124.124.124.120 
    Is all this doable?
    //Anders

  2. #2
    SitePoint Member mcjimbo's Avatar
    Join Date
    Mar 2005
    Location
    Milwaukee
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plenty of well documentated ways to achieve this, try this article for a start:
    http://www.15seconds.com/issue/981104.htm

    If you need more, then try this:

    http://www.google.com/search?hl=en&l...n+by+ip%2C+asp

    Hope this helps.

    James

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, you sure you want to bother parsing text files? Maybe XML can come to the rescue.

    iplist.xml
    Code:
    <list>
    	<customer name="customer1">
    		<location ip="123.123.123.120" />
    		<location ip="123.123.123.121" />
    	</customer>
    	<customer name="customer2">
    		<location ip="123.123.123.122" />
    		<location ip="123.123.123.123" />
    	</customer>
    </list>
    asp page
    Code:
    <%
    Set oD = Server.CreateObject("MSXML2.DOMDocument.4.0")
    oD.async = false
    oD.load "c:\iplist.xml"
    
    If oD.selectNodes("list/customer/location[@ip='" & Request.ServerVariables("REMOTE_ADDR") & "']").length > 0 Then
    ' user is in the list
    End If
    %>

  4. #4
    eXtremE StorMeR
    Join Date
    Jan 2005
    Location
    Pakistan
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx jimfraser for help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •