Hiding the PHP url arguments

19 replies
Hey,

I have this issue and I can't find anything decent on google.

I have this link here:

myurl.com/get.php?download=2&id=3

What I want to do is hide the bolded part in my source code. I want to pass the arguments info from the file, but I don't want to let the public see the actual arguments.

Any way of cloaking it, hiding it, encrypting?
#arguments #hiding #php #url
  • Profile picture of the author steve44
    hey!

    have you tried methods for hiding/encrypting email adresses in the source code?

    steve
    {{ DiscussionBoard.errors[3259544].message }}
  • Profile picture of the author SteveJohnson
    There are only two ways of passing info between page loads: GET and POST. From a link (as opposed to a form), you are limited to the GET query string, so you can't really cloak or hide it.

    If you don't want the public to see the actual arguments, encode them then decode on the receiving page.

    You can also use non-sensical keys and values that you 'decode' on the landing page: myurl.com/get.php?ab=awo30133&zzhti=alphie
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3259599].message }}
  • Profile picture of the author donnan
    What I do in these situations is I use my own little encryption technique.

    Code:
    myurl.com/get.php?download=2&id=3


    $t = 1
    $n = 2
    $m = 3
    $r = 4
    $L = 5
    $J = 6
    $G = 7
    $0 = 8
    $p = 9
    $s = 0

    then you just parse like this.myurl.com/get.php?download=n&id=m

    You can also use longer encryption such asmyurl.com/get.php?download=nm&id=mp

    But, you also need a bit more code to convert the characters you are parseing but that is not hard to do.

    Hope this helps.
    {{ DiscussionBoard.errors[3261160].message }}
  • Profile picture of the author stma
    If it's all on your site - why not send the info through in sessions instead? That way you show nothing. You also don't show any info on post - lot's of options.
    {{ DiscussionBoard.errors[3262539].message }}
    • Profile picture of the author jalicia18
      how about changing the dynamic url to static url by using a Rewrite rule? If you continue to use on dynamic url then use your hash url reading your variable and value... i.e:
      file.php?id=3&articleid=23

      id = 3 // generate the value in using hash function
      when calling the hash value, use the function to decode the hash value.
      {{ DiscussionBoard.errors[3263584].message }}
      • Profile picture of the author Adam Struve
        Originally Posted by jalicia18 View Post

        how about changing the dynamic url to static url by using a Rewrite rule? If you continue to use on dynamic url then use your hash url reading your variable and value... i.e:
        file.php?id=3&articleid=23

        id = 3 // generate the value in using hash function
        when calling the hash value, use the function to decode the hash value.
        This is what I was thinking too. If you know it'll always be the same variables just replace the $_GET variables with something static.
        {{ DiscussionBoard.errors[3265142].message }}
  • Profile picture of the author Emilis Strimaitis
    Thank you everyone for your replies!
    {{ DiscussionBoard.errors[3274851].message }}
  • Profile picture of the author zeeshi570
    Hi you can use simple htaccess rewrite rules for this,
    {{ DiscussionBoard.errors[3287877].message }}
  • Profile picture of the author Evan-M
    either use post, or pass the information along in a session.

    problem with both of these issues, is they need to be sent to the page from the page that creates the session or posts.

    another way would be to create a md5 sting that is unique to the user that has download access, then in the database link the string to the download information.

    then your link would look like
    myurl.com/get.php?download=d41d8cd98f00b204e9800998ecf8427e



    then lookup in the database where download = d41d8cd98f00b204e9800998ecf8427e ( or whatever there random string is for that user and download)

    then use that connection to pull from the database the download number and id #

    it would be very difficult for someone to guess the random string.
    then you could also set a limit,

    say you allow them to download 3 times, each time that string is accessed you could increase the limit, by 1, once it hits 3 it no longer will download but give a error that the limit has been reached ( to prevent them sharing the url)

    ex:

    <?php
    $download=$_GET[download];


    $userdata="SELECT download,id,file,limit FROM downloads WHERE download='$download'";
    $res=mysql_query($userdata) or die(mysql_error());;
    $userinforow=mysql_fetch_array($res);
    $string=$['download'];
    $fid=$['id'];
    $limit=$['limit'];
    $file=$['file'];

    if ($limit <= '3') {
    if ($download == $string) {
    file download here
    }else{
    echo 'sorry you have entered a invalid download string';
    }
    }else{
    echo ' download limit has been reached for this file string';
    }

    ?>



    on the page that they access to either pay, or get the download like do something like this to generate a random string

    function genRandomString() {
    $length = 100;
    $characters = ’0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&* ()_+=-’;
    $string = ”;
    for ($p = 0; $p < $length; $p++) {
    $string .= $characters[mt_rand(0, strlen($characters))];
    }
    return $string;
    }

    thin insert that string and download info to the database.


    thats a crude implementation but should give you the idea
    Signature

    Evan-M

    Easily The Worlds Best Wordpress Popup plugin

    Visit Website Design Firm For All Your Wordpress Coding Needs

    {{ DiscussionBoard.errors[3403724].message }}
  • Profile picture of the author jminkler
    Originally Posted by Emilis Strimaitis View Post

    Hey,

    I have this issue and I can't find anything decent on google.

    I have this link here:

    myurl.com/get.php?download=2&id=3

    What I want to do is hide the bolded part in my source code. I want to pass the arguments info from the file, but I don't want to let the public see the actual arguments.

    Any way of cloaking it, hiding it, encrypting?
    This is not how you do downloads. You want each customer to have a one time download link so it would be that link plus a one time token which is emailed to them when they request it from the member area.

    This url will get passed around so quickly your head will spin.
    {{ DiscussionBoard.errors[3403937].message }}
    • Profile picture of the author Evan-M
      Originally Posted by jminkler View Post

      This is not how you do downloads. You want each customer to have a one time download link so it would be that link plus a one time token which is emailed to them when they request it from the member area.

      This url will get passed around so quickly your head will spin.


      I totally agree, this makes it easy for a torrent site, don't need the torrent, let him host the file and pass the link lol
      Signature

      Evan-M

      Easily The Worlds Best Wordpress Popup plugin

      Visit Website Design Firm For All Your Wordpress Coding Needs

      {{ DiscussionBoard.errors[3403939].message }}
      • Profile picture of the author jminkler
        Originally Posted by Evan-M View Post

        I totally agree, this makes it easy for torrent site, don't need the torrent, let him host the file and pass the link lol
        Yeah just search for your favorite IM product and add "torrent" and see which IM'ers didn't do thier due-diligence and pay a decent programmer.
        {{ DiscussionBoard.errors[3403953].message }}
        • Profile picture of the author Evan-M
          Originally Posted by jminkler View Post

          Yeah just search for your favorite IM product and add "torrent" and see which IM'ers didn't do thier due-diligence and pay a decent programmer.

          could always save yourself allot of trouble, and just put,

          file downloads are on the sidebar, if you feel like paying, please click the pay now button below...I trust you all!

          lol
          Signature

          Evan-M

          Easily The Worlds Best Wordpress Popup plugin

          Visit Website Design Firm For All Your Wordpress Coding Needs

          {{ DiscussionBoard.errors[3404015].message }}
  • Profile picture of the author wayfarer
    No matter what the solution, this won't be a cut-and-paste method of implementing it. You'll need to understand programming methodologies to do this. It isn't too difficult, but it takes a bit of programming, as well as understanding of how the server works. The "one-time" download link is the right thing to do. You need something that is hashed together from a timestamp, a user id, and possibly an email, that is then added to a database after download to indicate that the link is no longer authorized.

    The other possibility is to put the resource in a location that is not public, then relay the (binary) data from a PHP page or whatever (PHP pages can deliver way more than just HTML), but only if the user is properly authenticated. Users are quick to share links, but will hardly ever share their user accounts.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[3404023].message }}
    • Profile picture of the author jminkler
      Originally Posted by wayfarer View Post

      No matter what the solution, this won't be a cut-and-paste method of implementing it. You'll need to understand programming methodologies to do this. It isn't too difficult, but it takes a bit of programming, as well as understanding of how the server works. The "one-time" download link is the right thing to do. You need something that is hashed together from a timestamp, a user id, and possibly an email, that is then added to a database after download to indicate that the link is no longer authorized.

      The other possibility is to put the resource in a location that is not public, then relay the (binary) data from a PHP page or whatever (PHP pages can deliver way more than just HTML), but only if the user is properly authenticated. Users are quick to share links, but will hardly ever share their user accounts.
      And even better, DONT GIVE OUT PDF'S! unless you want them distributed (maybe with some other affiliate link). Software? Have it phone home!

      This is what member areas are for.
      {{ DiscussionBoard.errors[3406701].message }}
      • Profile picture of the author sonia2012
        pass the variable to the link with encode id
        During the $_GET method, decode the encoded id
        then do the query and blahblah.
        {{ DiscussionBoard.errors[3426864].message }}
        • Profile picture of the author Evan-M
          Originally Posted by sonia2012 View Post

          pass the variable to the link with encode id
          During the Array method, decode the encoded id
          then do the query and blahblah.
          how would this help, if the customer has the encoded url, and posts it, its going to decode for whoever they send it to also, so really this would be pointless.

          you need to use a framework that enable you to make the url rewriting. Also tuning the web server as apache you can rewrite the urls
          just out of curiosity why is a framework needed again ? :confused: and what does it have to do with url rewrites or apache rewrite engine?
          Signature

          Evan-M

          Easily The Worlds Best Wordpress Popup plugin

          Visit Website Design Firm For All Your Wordpress Coding Needs

          {{ DiscussionBoard.errors[3429011].message }}
  • Profile picture of the author leva86
    you need to use a framework that enable you to make the url rewriting. Also tuning the web server as apache you can rewrite the urls
    {{ DiscussionBoard.errors[3428314].message }}

Trending Topics