Help with Online KeyGen

Post here any topics that related to Enigma Protector, its functionality, your misunderstanding, offers to improvements etc etc etc
Post Reply
illmill
Posts: 4
Joined: Sat Nov 03, 2012 1:26 am

Help with Online KeyGen

Post by illmill »

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!
Enigma
Site Admin
Posts: 2939
Joined: Wed Aug 20, 2008 2:24 pm

Re: Help with Online KeyGen

Post by Enigma »

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.
illmill
Posts: 4
Joined: Sat Nov 03, 2012 1:26 am

Re: Help with Online KeyGen

Post by illmill »

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

Post by illmill »

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?
Enigma
Site Admin
Posts: 2939
Joined: Wed Aug 20, 2008 2:24 pm

Re: Help with Online KeyGen

Post by Enigma »

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.
bluemans
Posts: 3
Joined: Sun Nov 25, 2012 7:37 pm

Re: Help with Online KeyGen

Post by bluemans »

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?
perfectcode
Posts: 28
Joined: Tue Oct 30, 2012 8:15 am

Re: Help with Online KeyGen

Post by perfectcode »

.
Last edited by perfectcode on Sat Apr 20, 2019 8:10 am, edited 1 time in total.
bluemans
Posts: 3
Joined: Sun Nov 25, 2012 7:37 pm

Re: Help with Online KeyGen

Post by bluemans »

thanks a lot!
perfectcode
Posts: 28
Joined: Tue Oct 30, 2012 8:15 am

Re: Help with Online KeyGen

Post by perfectcode »

.
Last edited by perfectcode on Sat Apr 20, 2019 8:09 am, edited 1 time in total.
amin
Posts: 6
Joined: Mon May 09, 2011 1:48 pm

How Create mysql Online KeyGen

Post by amin »

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/manu ... 697d#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.
Post Reply