Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default Simple License System

    Hey,

    I am designing a script and I want the users to need a license to run the script. Its a free script but I just want a quck and easy way for me to track usage.

    I have made a script but I cant get the dam thing to work.

    Here is thats is built into the script
    PHP Code:
    $check_license get_file_contant(http://URL/license.php?license=check&url=http://www.roizer.com&license=ipvdD563YjhPeS8); 
    Here is whats in the license file on my server:
    PHP Code:
    if($_GET['license'] == "check"){

    $url $_GET['url'];
    $license $_GET['license'];

    /* Setup MySQL Access */
    $DBhost "localhost";
    $DBuser "";
    $DBpass "";
    $DBname "";
    mysql_connect($DBhost$DBuser$DBpass) or die ("Cannot connect to database server");
    mysql_select_db($DBname) or die ("Cannot select site database");

    $date date("d-m-Y");

    $license_query mysql_query("SELECT * FROM `license` WHERE `key` = '$key'");
    $license_row mysql_fetch_array($license_query);
    $dbexpires $license_row['expires'];
    $dburl $license_row['url'];
    $dbkey $license_row['key'];
    echo 
    "$dbkey"<br>" "$dburl"<br>" "$dbexpires";


    if(
    $dbkey != $license){
    echo 
    "Error No License";
    return 
    "3";
    }else

    if(
    $dburl != $url){
    echo 
    "URL Wrong!";
    return 
    "4";
    }else

    if(
    $date >= $dbexpires){
    echo 
    "EXPIRED";
    return 
    "5";
    }else

    return 
    "6";


    (this is just a test script but I cant get it to work, if the domain is wrong it echos wrong license and if the license if wrong it still echos wrong license and if the license in the db expirery date is less then the date today it still says no license and will not work for anything!! Help!

    Dan


  2. #2
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    Change the first license to another variable, because the second one (where the key is ipvdD563YjhPeS8) over rights the first variable (check)

    Make a basic check first, like this (possibly not the best coding ever!):

    PHP Code:
    <?php

    $url 
    $_GET['url'];
    $license $_GET['license'];

    echo(
    "license: $license");
    echo(
    "<br>");
    echo(
    "url: $url");

    ?>
    edit: with the above code, go to the website like this "www.mysite.com/index.php?license=check&url=http://www.roizer.com" look at the output, it should be
    license: check
    url: http://www.roizer.com
    and if you go to http://www.mysite.com/index.php?lice...pvdD563YjhPeS8 , the output should be
    license: ipvdD563YjhPeS8
    url: http://www.roizer.com

    make any sense?
    Last edited by Blinger1; 02-10-2009 at 09:09 AM.

  3. #3
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    Yeahh thanks, saw that bug just after I posted! But yeah fixed now, thanks!!

    Dan


  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    Probably the best way todo it so you can handle error's script side is to have a license php script to return a JSON output. A lot easier than processing a html page as such.

    Sorry for such a crude example

    licenseCheck.php

    PHP Code:
    <?php

    $licenseID 
    $_GET['id'];
    $licenseURL $_GET['url'];

    // blah - processing code here

    $jsonArray['status'] = 'valid';
    $jsonArray['url'] = 'url it is licensed to';
    $jsonArray['name'] = 'license holder';

    echo 
    json_encode$jsonArray );

    ?>
    and the code to get the license info for script-side checking/processing

    PHP Code:
    <?php

    $licenseCheck 
    file_get_contents'http://url/licenseCheck.php?id=123143241&url=http://www.mysite.com' );
    $licenseInfo json_decode$licenseCheck );

    // this will echo "valid" in the current preview
    echo $licenseInfo->status;

    // this will echo "url it is licensed to"
    echo $licenseInfo->url;

    // etc

    ?>
    If it were a paid script you would have to try and take measures to stop people from nulling it, but because it's a free script you don't really have todo anything. Albeit the idea a bit pointless.

  5. #5
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    I tryed adding something like this into my script so it echos in the main script when it expires ect but I cant get it to work

    Dan


  6. #6
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    make it get the contents from that file, but on instalation make them input their details so that it inputs into their db. If it has expired or doesnt exist then it can execute something on their side.

    Lew.

  7. #7
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by Lewiie15 View Post
    make it get the contents from that file, but on instalation make them input their details so that it inputs into their db. If it has expired or doesnt exist then it can execute something on their side.

    Lew.
    If it is entering into their database, people can easily change it.

  8. #8
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    No, i meant enter their license into their db...

    Lew.

  9. #9
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    Quote Originally Posted by Lewiie15 View Post
    No, i meant enter their license into their db...

    Lew.
    Thats is what they do, but I want to send information back from the callback script.


  10. #10
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    yes, make the script on your server return true or false, then on their side make the script decide what to do if true or false is called bk.

Posting Permissions

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