Getting URL arguments

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Getting URL arguments

    I'm trying to read the arguments of the URL for the document. I'm new
    to PHP and can't figure it out. I've played around with $_SERVER but
    the closest I can get is the QUERY_STRING which doesn't include
    arguments.

    Essentially I'm configuring nuke, and want to block a user after two
    failed login attempts. I'm not sure of the most elegant way to do
    this. What I was thinking was to watch the URL. At first it is
    ?module.php=Your_Account, then after one failed attempt it is
    ?module.php=Your_Account&stop=1. I was going to read that and add a
    count, like '&try=2' so the code could follow attempts and block the
    user after n attempts.

    I really don't like how I'm doing this, but I'm not sure the best way.

    Any suggestions welcomed,

    Mark
    Mark Jensen Guest

  2. Similar Questions and Discussions

    1. JVM Arguments
      hello, I would like to know if we can define several directories for the "libPath" attribute in the coldfusion MX 7 administrator to have different...
    2. using 'do' with arguments
      hello im wondering if you can pass arguments with the 'do' command? like: on event h = "handler"
    3. [PHP] Function arguments
      Hello, If you are worried about this issue your best option is to switch to an object oriented approach. all the best Hardik Doshi wrote:
    4. showDialogModal and arguments
      Hi Group, I need to open a modal window (a search form) from a link on the main form. I'm also passing it a parameter - a table name, so the call...
    5. exec for EXE with arguments
      hi i'd like to call an exe with several parameters like this: the parameter -name= must have quotes from beginning til end because of the Spaces...
  3. #2

    Default Re: Getting URL arguments

    You might want to try $_GET and/or $_POST for queries. This easily
    allows your to easily play with any and all values passed to PHP from
    the user's web browser. As for checking how many times a user has
    failed at logging in, you may not want to depend solely on a GET value
    passed from the Earl. This would allow anybody to manipulate your
    system, possibly opening yourself up to attack, because they could
    just change stop and continue trying to log in.

    eGroupWare--a PHP software package for online enterprise
    collaboration--uses a method where they log all login attempts to
    their MySQL database. When a user logs in, it queries the login table
    and pools all the logins for that given user (based on username I
    believe and login times), and if the user has tried too many times
    based on that query, then it won't let that user login for however
    many minutes set up for blocking. Granted, their system is not perfect
    (as they offer no way to unblock someone manually), but maybe it could
    give you an idea of how you want to handle your situation.

    On Sat, 03 Jul 2004 02:27:13 GMT, Mark Jensen <a@a.a> wrote:
    >I'm trying to read the arguments of the URL for the document. I'm new
    >to PHP and can't figure it out. I've played around with $_SERVER but
    >the closest I can get is the QUERY_STRING which doesn't include
    >arguments.
    >
    >Essentially I'm configuring nuke, and want to block a user after two
    >failed login attempts. I'm not sure of the most elegant way to do
    >this. What I was thinking was to watch the URL. At first it is
    >?module.php=Your_Account, then after one failed attempt it is
    >?module.php=Your_Account&stop=1. I was going to read that and add a
    >count, like '&try=2' so the code could follow attempts and block the
    >user after n attempts.
    >
    >I really don't like how I'm doing this, but I'm not sure the best way.
    >
    >Any suggestions welcomed,
    >
    >Mark
    eclipsboi Guest

  4. #3

    Default Re: Getting URL arguments

    On Sat, 03 Jul 2004 02:40:39 GMT, eclipsboi <eclipsboi@hotmail.com>
    wrote:
    >You might want to try $_GET and/or $_POST for queries. This easily
    >allows your to easily play with any and all values passed to PHP from
    >the user's web browser. As for checking how many times a user has
    >failed at logging in, you may not want to depend solely on a GET value
    >passed from the Earl. This would allow anybody to manipulate your
    >system, possibly opening yourself up to attack, because they could
    >just change stop and continue trying to log in.
    >
    >eGroupWare--a PHP software package for online enterprise
    >collaboration--uses a method where they log all login attempts to
    >their MySQL database. When a user logs in, it queries the login table
    >and pools all the logins for that given user (based on username I
    >believe and login times), and if the user has tried too many times
    >based on that query, then it won't let that user login for however
    >many minutes set up for blocking. Granted, their system is not perfect
    >(as they offer no way to unblock someone manually), but maybe it could
    >give you an idea of how you want to handle your situation.
    >
    >On Sat, 03 Jul 2004 02:27:13 GMT, Mark Jensen <a@a.a> wrote:
    >
    >>I'm trying to read the arguments of the URL for the document. I'm new
    >>to PHP and can't figure it out. I've played around with $_SERVER but
    >>the closest I can get is the QUERY_STRING which doesn't include
    >>arguments.
    >>
    >>Essentially I'm configuring nuke, and want to block a user after two
    >>failed login attempts. I'm not sure of the most elegant way to do
    >>this. What I was thinking was to watch the URL. At first it is
    >>?module.php=Your_Account, then after one failed attempt it is
    >>?module.php=Your_Account&stop=1. I was going to read that and add a
    >>count, like '&try=2' so the code could follow attempts and block the
    >>user after n attempts.
    >>
    >>I really don't like how I'm doing this, but I'm not sure the best way.
    >>
    >>Any suggestions welcomed,
    >>
    >>Mark
    Yeah, I was thinking about using the DB or cookies. The site does not
    have to be secure, but the client thinks so. It really doesn't
    matter, so I'm trying to do it as quickly as possible. Well, I gotta
    jump in to creating sql querying transactions next, so I might as well
    go that route.

    Thanks!
    Mark Jensen Guest

  5. #4

    Default Re: Getting URL arguments

    Mark Jensen wrote:
    > I'm trying to read the arguments of the URL for the document. I'm new
    > to PHP and can't figure it out. I've played around with $_SERVER but
    > the closest I can get is the QUERY_STRING which doesn't include
    > arguments.
    the values that are passed through an URL are called GET, they are put
    in an array which you can access with $_GET['var']

    so if you use [url]http://sub.isp.com/dir/file.php?var=1[/url]

    you'll want to get the value of $var and to do so use:

    <?php
    $var = $_GET['var']; //alternatively you can also directly use
    //$_GET['var'] but it's just cleaner this way (imo)
    ?>
    >
    > Essentially I'm configuring nuke, and want to block a user after two
    > failed login attempts. I'm not sure of the most elegant way to do
    > this. What I was thinking was to watch the URL. At first it is
    > ?module.php=Your_Account, then after one failed attempt it is
    > ?module.php=Your_Account&stop=1. I was going to read that and add a
    > count, like '&try=2' so the code could follow attempts and block the
    > user after n attempts.
    What will you do if the user changes the url? He'll keep bruteforcing
    the login without problems...
    >
    > I really don't like how I'm doing this, but I'm not sure the best way.
    You could use sessions instead. The user hasn't got access to those vars.

    <?php
    session_start();
    if (isset ($_SESSION['attempts'])) {

    $attempts = $_SESSION['attempts'];
    if ($attempts >= "2") {

    echo 'Sorry, but you're not allowed anymore';

    }
    else {

    echo 'Login Form:'; //here goes your login form

    }
    }
    else {

    echo 'Login Form:'; //here goes your login form

    }
    if ("LOGIN_FAILED") //well you get the idea, if the logins fails...

    if (isset ($_SESSION['attempts'])) {

    $attempts = $_SESSION['attempts'];
    $_SESSION['attempts'] = $attempts + 1;

    }
    else {

    $_SESSION['attempts'] = 1;

    }
    }
    ?>

    Yeah well, i'm sure there are some errors, it's only a main idea.
    >
    > Any suggestions welcomed,
    Hope this fits as a suggestion you wanted,
    >
    > Mark
    Best regards,
    Sebastian

    --
    The most likely way for the world to be destroyed,
    most experts agree, is by accident.
    That's where we come in; we're computer professionals.
    We cause accidents.
    --Nathaniel Borenstein
    Sebastiaan Lauwers Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139