Alpha DevCon 2018
Results 1 to 13 of 13

Thread: How to Get System IP Address in Alpha Five Web Application

  1. #1
    Member
    Real Name
    Vasan JS
    Join Date
    Nov 2007
    Posts
    68

    Default How to Get System IP Address in Alpha Five Web Application

    Hi
    I am working on Alpha five Web Application. I need to show a report of the current logged in users (user name & IP Address), few questions on this:

    1. I can track the login and insert the details in a database, and when the user logs out , i can delete the record, but how do i handle session expiry, i mean when a user logs in, i add a record to the database, then before the user logs out, the session expires, so the logout code doesnt get triggered, the record that i have inserted will remain in the table. Please advice.

    2. How do i get the IP address?

    Thanks in advance...



    Cheers
    Vasan.
    Last edited by Vasan; 03-20-2009 at 08:41 AM. Reason: Not clear

  2. #2
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,787

    Default Re: How to Get System IP Address in Alpha Five Web Application

    everything = request.raw gives you everything if you want it.

    ip=request.remote_addr give you just the IP.

    See this page for more goodies - http://support.alphasoftware.com/alp...rted_Title.htm
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    Member
    Real Name
    Vasan JS
    Join Date
    Nov 2007
    Posts
    68

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Thanks Steve for your swift response. That was helpful. Meanwhile I have refined my question requesting for additional details, please take a look at your ease.

  4. #4
    Member
    Real Name
    Antony Burden
    Join Date
    Mar 2009
    Posts
    1

    Default Re: How to Get System IP Address in Alpha Five Web Application

    This is ok for people not behind certain firewalls, it is very well documented over the web to use code like this vbscript:

    ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    if ipaddress = "" then
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    end if

    however I cannot find alpha supports HTTP_X_FORWARDED_FOR

    any idea how to achieve this?

    Antony

  5. #5
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Antony,
    Does that vbs work? I just tried it but probably out of context. Anyway, if the vbs does work and there is no equivalent in Alpha, then it is possible a couple of ways to run a vbs script from within Alpha (will be as though you double-clicked on it). Alpha has a function that runs a vbs or you can use sys_open().
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  6. #6
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,640

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Quote Originally Posted by Antony Burden View Post
    This is ok for people not behind certain firewalls, it is very well documented over the web to use code like this vbscript:

    ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    if ipaddress = "" then
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    end if

    however I cannot find alpha supports HTTP_X_FORWARDED_FOR

    any idea how to achieve this?

    Antony
    A5V9's equivalent would be Request.HTTP_X_FORWARDED_FOR if the header has been set. If not, the variable will not exist, so you will want to use eval_valid() to see if it was part of the request.

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  7. #7
    "Certified" Alphaholic chadbrown's Avatar
    Real Name
    Chad Brown
    Join Date
    Aug 2007
    Location
    Aurora, Ontario, Canada
    Posts
    1,395

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Is there anyway of getting the internal ip address from machines so that i can deny machines that are not in my mask of 192.168.1.255?

  8. #8
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,064

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Quote Originally Posted by chadbrown View Post
    Is there anyway of getting the internal ip address from machines so that i can deny machines that are not in my mask of 192.168.1.255?
    I have a file I include in the relevant pages using a5w_include() that does this:

    Code:
    <%a5
    Dim IpString as c
    IpString = Request.Remote_Addr
    
    If smatch(IpString,"pattern1.*") = .f.  then
        Response.Redirect("login.a5w")
    end if
    %>

  9. #9
    Member
    Real Name
    dicky.kurniawan2501
    Join Date
    Jul 2014
    Posts
    58

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Quote Originally Posted by Steve Wood View Post
    everything = request.raw gives you everything if you want it.

    ip=request.remote_addr give you just the IP.

    See this page for more goodies - http://support.alphasoftware.com/alp...rted_Title.htm


    This code is placed on what conditions? whether the "CanInsertRecord" or "CanUpdateRecord" or on page a5w?

    Thank You

  10. #10
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,787

    Default Re: How to Get System IP Address in Alpha Five Web Application

    It would work anywhere you placed it. What are you trying to accomplish?
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  11. #11
    Member
    Real Name
    dicky.kurniawan2501
    Join Date
    Jul 2014
    Posts
    58

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Quote Originally Posted by Steve Wood View Post
    It would work anywhere you placed it. What are you trying to accomplish?

    I want when user login then I will get the value of the username and ip address

    for the username I use session, but how do I get the IP address?

  12. #12
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,787

    Default Re: How to Get System IP Address in Alpha Five Web Application

    If you have a login dialog on an A5W page, you can use this syntax to only grab the login information when they click the Submit button. It will be stored in v_ip, and then you can do whatever you want with that information. The syntax below will work in V9 and beyond:

    <%a5
    'gets the username and IP address
    if eval_valid("submitbutton")
    if eval_valid("userid")
    v_userid = userid '== the username they used to login
    v_ip = request.remote_addr '== their IP address
    end if
    end if
    %>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  13. #13
    Member
    Real Name
    dicky.kurniawan2501
    Join Date
    Jul 2014
    Posts
    58

    Default Re: How to Get System IP Address in Alpha Five Web Application

    Quote Originally Posted by Steve Wood View Post
    If you have a login dialog on an A5W page, you can use this syntax to only grab the login information when they click the Submit button. It will be stored in v_ip, and then you can do whatever you want with that information. The syntax below will work in V9 and beyond:

    <%a5
    'gets the username and IP address
    if eval_valid("submitbutton")
    if eval_valid("userid")
    v_userid = userid '== the username they used to login
    v_ip = request.remote_addr '== their IP address
    end if
    end if
    %>
    thanks steve

Similar Threads

  1. Web Application Security for Alpha V7
    By ppham in forum Web Application Server v7
    Replies: 2
    Last Post: 05-13-2008, 01:16 PM
  2. Specifying the link address for a set in a web application
    By drowelf in forum Application Server Version 8
    Replies: 3
    Last Post: 11-01-2007, 07:41 PM
  3. re:Alpha Five Web Application Server
    By Adrian Boulay in forum Announcements
    Replies: 1
    Last Post: 06-05-2002, 05:16 AM
  4. Alpha WEB Application
    By Anthony Tampone in forum Announcements
    Replies: 4
    Last Post: 03-23-2001, 02:05 PM

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
  •