Any questions? Ask us: support@enigmaprotector.com

Help with Online KeyGen

Post here any topics that related to Enigma Protector, its functionality, your misunderstanding, offers to improvements etc etc etc

Help with Online KeyGen

Postby illmill » Sat Nov 03, 2012 1:54 am

Hi, I'm new to enigma and just doing the trial of the 32 bits program to make sure it works before I buy. I am going to sell software online through paypal and I need them to be able to register a license key after making payment. I'm a complete newb, so please dumb down your directions for me.

I looked here: http://enigmaprotector.com/en/help/manu ... f6ec7d697d and tried using the "post" method as recommended and changed the "yoursite.com" to my actual site, but it's not working. I just get an internal server error. I uploaded the linux keygen to my hostgator reseller account under the cgi-bin directory, so I believe that should work. All I need is for people to enter their name or email (I would prefer email if they can use that as the unique item) and just click generate to get a key. Or a key is automatically emailed to them, but since I don't have the budget for an autoresponder right now, it's better if they can just be redirected to a page that lets them generate a key.

Thanks in advance!
illmill
 
Posts: 4
Joined: Sat Nov 03, 2012 1:26 am

Re: Help with Online KeyGen

Postby Enigma » Mon Nov 05, 2012 3:19 pm

Hi illmill,

You are really looking in correct direction.

Just summarize, you need an ability to send automatically the email to user who has bought your software from Paypal.

Initially, as you are correctly noticed, you need to set up the keys generator. You've uploaded keys generator to cgi-bin directory but perhaps, forgot to set execution permissions to this keygen file. By default, Linux sets read/write permissions to the fil, but we have to have execute permissions.
Also, make sure that the keygen file you uploaded is really located in cgi-bin folder. Note, it is not enough just create a folder with the name cgi-bin to allow execution of scripts inside it.

Next, based on the POST example of keygen: http://enigmaprotector.com/en/help/manu ... f6ec7d697d you are making/remaking this script to email a message (for eg, using standard php function mail) with the key to the user who bought the software.
Paypal carries payment details in the POST array. You may extract first and last names, and email address like following:
$_POST['first_name']
$_POST['last_name']
$_POST['payer_email']
I hope there is no problems at this stage.

Next stage - integration of keys generator and the php script that sends email to user into Paypal. For this, you have to use IPN (instant payment notification) system of paypal. You have to set the url of the php script to the paypal's IPN so it will call your script each time new order comes.
Enigma
Site Admin
 
Posts: 2199
Joined: Wed Aug 20, 2008 2:24 pm

Re: Help with Online KeyGen

Postby illmill » Tue Nov 06, 2012 3:09 am

Okay, thanks for the reply. Sorry about the multiple posts/emails, I was just in a hurry over the weekend to try and get this working.

Yes, I am positive the keygen is in the correct cgi-bin directory. I'm aware of this folder and I uploaded it there via ftp. I will contact my host to ask about the permissions and then post an update here.

Thanks again!
illmill
 
Posts: 4
Joined: Sat Nov 03, 2012 1:26 am

Re: Help with Online KeyGen

Postby illmill » Tue Nov 06, 2012 5:15 am

Okay, I'm going to spend some time playing with this to see if I can get it working, but to be honest, I don't really know php so this might be a challenge for me to set up.

I just set up the ipn listener url in my account preferences on paypal, but one thing I'm not sure of: is the URL supposed to be mysite.com/cgi-bin/keygen, or is it the url where I upload this script: http://enigmaprotector.com/en/help/manu ... f6ec7d697d (under POST php method).

UPDATE:
So I thought I would just post my code here. I named the file paypalipn.php and I uploaded it to mydomain.com/paypalipn.php and then there is mydomain.com/cgi-big/keygen. I have absolutely no idea if I'm even close, but here's the paypalipn.php script:

Code: Select all
<?php

 
 
  if (!function_exists('http_build_query')) {
      function http_build_query($data, $prefix='', $sep='', $key='') {
          $ret = array();
          foreach ((array)$data as $k => $v) {
              if (is_int($k) && $prefix != null) {
                  $k = urlencode($prefix . $k);
              }
              if ((!empty($key)) || ($key === 0))  $k = $key.'['.urlencode($k).']';
              if (is_array($v) || is_object($v)) {
                  array_push($ret, http_build_query($v, '', $sep, $k));
              } else {
                  array_push($ret, $k.'='.urlencode($v));
              }
          }
          if (empty($sep)) $sep = ini_get('arg_separator.output');
          return implode($sep, $ret);
      }// http_build_query
  }//if

  function do_post_request($url, $data, $optional_headers = null)
  {
   $params = array('http' => array(
                'method' => 'POST',
                'content' => $data
             ));
   if ($optional_headers !== null) {
      $params['http']['header'] = $optional_headers;
   }
   $ctx = stream_context_create($params);
   $fp = @fopen($url, 'rb', false, $ctx);
   if (!$fp) {
      throw new Exception("Problem with $url, $php_errormsg");
   }
   $response = @stream_get_contents($fp);
   if ($response === false) {
      throw new Exception("Problem reading data from $url, $php_errormsg");
   }
   return $response;
  }

  function generate_key_post($url, $data) {
    return do_post_request($url, http_build_query($data));
  }
 
  $data['Action'] = 'GenerateKey';
  $data['KeyMode'] = 512;
  $data['KeyBase'] = 32;
  $data['Hyphens'] = 1;
  $data['EncryptedConstant'] = 2113444489;
  $data['PrivateKey'] = '00C98B2SF9UBJA605AJX53GJFXJV8UH4A6PY2L6CV4MAMV7V3ERRVY99Y72V2P77Z2J3KBPGWR3WXKG5GF9Z6CKXJHY5VUMBTQ66H2MRZPCU00DLFJ675JTTTNEK00DLFJ675JTTTNEK';
  $data['PublicKey'] = '0201B810DA4A1ADD4351378790A98138533067CP4S86R7D8THS45GBCVUM635EPRQRMYRP3DAA5DUPZ6ABDSFP7F5ACP7ERGH4A7Y6B6NW6NMMBZF83WVER9Y4MMBNLBQDKR7KFVLGLV067CFDQCWCHGQVVRN24DECEPBL96YJQJTVDCRTNQG3E4WW4GK4GQ5X5L5H88D3XYHCBRBNASPD3P5CNYFKFHBCSDHHD6WPTCC4XVSM5S88067C2JSTCMVT48C8HC7SHKGTFJBM28P6XTBCNWHMV6J6KN6W5Q9TQLVR285U6GVCAAUTZLRTPSRGDQ742B4742XF4MACRR747YDP5FZZ9D';
  $data['RegName'] = '$_POST['payer_email']';

  $txt = "Hi $_POST['first_name'] $_POST['last_name'], thank you for registering.  Please see your license information below.

  $regkey = generate_key_post('http://mydomain.com/cgi-bin/keygen', $data);
  echo('Registration name: $_POST['payer_email']<br/>Registration Key: '.$regkey);";
 
  // Send email
  mail("$_POST['payer_email']","Registration",$txt);

?>


I just tested it by making a .01usd payment to the account, but didn't get any message at all - nothing from paypal and nothing from my email account that the receiving paypal is under.

Would the code here http://phpweby.com/software/php-paypal work for this application?
illmill
 
Posts: 4
Joined: Sat Nov 03, 2012 1:26 am

Re: Help with Online KeyGen

Postby Enigma » Tue Nov 06, 2012 8:10 am

In PayPal you should create a BuyNow button. Your customers will be using this button to make a payment.
Only such payments can be processed automatically. Instead, Paypal supports to send/receive variant amount payments, such can't be handled automatically.

Use this url to create a paypal buynow button: https://www.paypal.com/cgi-bin/webscr?c ... ype=buynow

At the Step 3 of button creating you will find the field "Add advanced variables", enable it, and add one variable:
Code: Select all
notify_url=https://www.mywebsite.com/PayPal_IPN

Replace https://www.mywebsite.com/PayPal_IPN with the url of your php script.

After customer make a payment, using this buy now button, paypal will call your php script where you will be able to generate a key, send email to customer and so on. No need to use additional php scripts, because it makes the procedure too complex.

Let me know if it helps.
Enigma
Site Admin
 
Posts: 2199
Joined: Wed Aug 20, 2008 2:24 pm

Re: Help with Online KeyGen

Postby bluemans » Sun Nov 25, 2012 7:42 pm

hello,
tried the script,work well in general but i am not able to send the information to the payer mail.
when i use mail("$_POST['payer_email']","Registration",$txt); ,nothing is received but if i change "$_POST['payer_email']" to and email address its works.
Any idea what can cause the problem?
bluemans
 
Posts: 3
Joined: Sun Nov 25, 2012 7:37 pm

Re: Help with Online KeyGen

Postby perfectcode » Sun Nov 25, 2012 8:54 pm

Thats because you have $_POST['payer_email'] in quotes. You are basically telling the function to send the e-mail to "$_POST['payer_email']", which is not a valid E-Mail address.

Change it to this:

Code: Select all
mail($_POST['payer_email'],"Registration",$txt);
perfectcode
 
Posts: 28
Joined: Tue Oct 30, 2012 8:15 am

Re: Help with Online KeyGen

Postby bluemans » Sun Nov 25, 2012 11:06 pm

thanks a lot!
bluemans
 
Posts: 3
Joined: Sun Nov 25, 2012 7:37 pm

Re: Help with Online KeyGen

Postby perfectcode » Mon Nov 26, 2012 12:00 am

No problem, glad I could help! :)
perfectcode
 
Posts: 28
Joined: Tue Oct 30, 2012 8:15 am

How Create mysql Online KeyGen

Postby amin » Sat Dec 20, 2014 5:10 am

Hi,
I have created a mysql with a table consist of these fields :Reg name,ID,email
But how I can use your sample code(http://enigmaprotector.com/en/help/manual/81ffd9d0173d967561bcf5f6ec7d697d#dummy) for this php page that after save valu fields in mysql then use reg name,ID for generat code and send email?
Please help me.
Fight Against Crackers By Science!
amin
 
Posts: 6
Joined: Mon May 09, 2011 1:48 pm


Return to Basic

Who is online

Users browsing this forum: No registered users and 3 guests