Old Authorization System

Discussion in 'Code Snippets and Tutorials' started by ricky92, Nov 29, 2007.

  1. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    I have recently made a new authorization system to authorize a user. The page url is http://www.neofriends.net/auth.php?username={USERNAME}&password={PASSWORD}&program={PROGRAM_ID} . It will automatically log the user in and check if the user has permissions to use the program. The messages which can be returned (grab the text between '<td style="height: 100px;" align=center><h2>' and '</h2></td>' to retrieve the message) are:
    • The username {USERNAME} does not exist. - The username doesn't exist
    • The provided password is not correct. - Wrong Password
    • You didn't provide valid informations. - The password wasn't supplied
    • No program selected. - The Program ID is null or equal to 0
    • An unknown error occurred. - Unknown error logging in.
    • Authorized to use the program. - Authorized :)
    • Not Authorized to use the program. - Not Authorized :(

    Please use it in programs, cause it's the fastest way to authorize... And also, administrators can view a log of all the (logged in) users who attempt to authorize a program. (Including the IP, so we can check if users share their account.)
     
  2. tharoux

    tharoux Level IV

    Joined:
    Dec 30, 2006
    Messages:
    2,733
    Likes Received:
    126
    Location:
    In front of my PC, Montreal
    Re: New Authorization System

    This is getting me worried a bit....
    I'm using 2 computer at the same time with 2 different ip adresses almost all week long for the iglooab...
    Will I be in trouble ???
     
  3. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Re: New Authorization System

    Don't worry tharoux, people here have dynamic IPs too, so it wouldn't be a good thing to ban someone just for having them. We'll search for IPs used to post and, if one IP doesn't exist in that list, we'll ban him.
     
  4. expon

    expon Administrator
    Staff Member

    Joined:
    Oct 30, 2006
    Messages:
    1,393
    Likes Received:
    56
    Location:
    UK
    Re: New Authorization System

    I just made this VB.NET auth example which uses rickys new auth system :p

    It just checks for authorization, and checks to see if a new version of the program is available.

    I haven't added this new auth to my vb.net programs yet but will do soon :)

    Code (vb.net):
    1. <div class="vbnet" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #008080; font-style: italic;">'VB.NET neofriends.net authorization sample - (uses rickys auth.php system)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">Dim</span> bAuth <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> = <span style="color: #0600FF;">False</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">Dim</span> bNewVersion <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> = <span style="color: #0600FF;">False</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">Dim</span> ProgID <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span> = <span style="color: #FF0000;">222</span> <span style="color: #008080; font-style: italic;">'change to your program download id</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">Dim</span> ProgName <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = <span style="color: #808080;">"Your Program Name v1.x"</span> <span style="color: #008080; font-style: italic;">'must be exactly the same as in the nf download section</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">lblStatus</span>.<span style="color: #0000FF;">Text</span> =<span style="color: #808080;">"Checking Authorization..."</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #008080; font-style: italic;">'this auth uses mysticals wrapper, posted in the code snippets forum</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">Dim</span> strReturn <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = wrapper.<span style="color: #0000FF;">Request</span><span style="color: #000000;">(</span><span style="color: #808080;">"GET"</span>, <span style="color: #808080;">"http://www.neofriends.net/auth.php?username="</span> & txtNFUser.<span style="color: #0000FF;">Text</span> & <span style="color: #808080;">"&password="</span> & txtNFPass.<span style="color: #0000FF;">Text</span> & <span style="color: #808080;">"&program="</span> & ProgID, <span style="color: #808080;">"http://www.neofriends.net/"</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">If</span> strReturn.<span style="color: #0000FF;">contains</span><span style="color: #000000;">(</span><span style="color: #808080;">"Not Authorized to use the program"</span><span style="color: #000000;">)</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            bAuth = <span style="color: #0600FF;">False</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        ElseIf strReturn.<span style="color: #0000FF;">contains</span><span style="color: #000000;">(</span><span style="color: #808080;">"Authorized to use the program"</span><span style="color: #000000;">)</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            bAuth = <span style="color: #0600FF;">True</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #0600FF;">If</span> strReturn.<span style="color: #0000FF;">contains</span><span style="color: #000000;">(</span>progname<span style="color: #000000;">)</span> <> <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">                bNewVersion = <span style="color: #0600FF;">True</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #FF8000;">Else</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            bAuth = <span style="color: #0600FF;">False</span> <span style="color: #008080; font-style: italic;">'some unknown error if we end up here</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">If</span> bAuth = <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">lblStatus</span>.<span style="color: #0000FF;">Text</span> =<span style="color: #808080;">"Authorized!"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #0600FF;">If</span> bNewVersion = <span style="color: #0600FF;">True</span> <span style="color: #FF8000;">Then</span> <span style="color: #008080; font-style: italic;">'as long as you have the version as part of the progName, this check will work</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">                <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">lblStatus</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"New Version"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">                <span style="color: #0600FF;">MsgBox</span><span style="color: #000000;">(</span><span style="color: #808080;">"Authorized! However it appears a new version of this program is now available. Please download the latest version!"</span>, MsgBoxStyle.<span style="color: #0600FF;">Exclamation</span>, <span style="color: #808080;">"www.neofriends.net"</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">                <span style="color: #0600FF;">Exit</span> <span style="color: #0600FF;">Sub</span> <span style="color: #008080; font-style: italic;">'you can remove this if you wish to let the user use the program even though it is not the latest version</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #008080; font-style: italic;">'enable your controls here, now that the user is authorized</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #FF8000;">Else</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">lblStatus</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"Failed Authorization"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">            <span style="color: #0600FF;">MsgBox</span><span style="color: #000000;">(</span><span style="color: #808080;">"You are not authorized to use this program."</span>, MsgBoxStyle.<span style="color: #0600FF;">Exclamation</span>, <span style="color: #808080;">"www.neofriends.net"</span><span style="color: #000000;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"> </li></ol></div>
    When you call wrapper.Request is does DoEvents for a while, whilst it waits for the program HTML to be received from the server. This will cause the program to temporarily 'freeze up' since if you call it from the main program thread. So you will need to run this code in a separate thread if you don't want your program to freeze up for a few seconds.