Issue With Server-Side Validation - Advanced Installer Community
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Issue With Server-Side Validation

Hello,

I just purchased Advanced Installer, and I'm trying to implement server-side validation, however it isn't working. I have created my validation PHP file as well as the database, but I always get the "Invalid Serial" error message when I try to run the installer. I know the database info is correct and I can't figure out where the issue lies.

Can anyone help me out? I can provide my scripts if I need to.

Thanks!
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Issue With Server-Side Validation

Hi,

There was a bug in the serial validation support from Advanced Installer 10.5 and 10.6, we included a fix in version 10.7. Have you tried this version
of Advanced Installer?

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

Yes I am using 10.7, and I used the example PHP file from the help included in the software. Was the bug in the example PHP? Thanks!
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Issue With Server-Side Validation

No, the bug as in one our internal DLLs, that was handling the POST operations. There was an incorrect conversion of data which was leading to always getting an incorrect response code in the installer.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

So what should I do? Can you post the corrected DLL? I just bought the $300 version and would like to have it working today if possible.

Thank you!
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

Can anyone please help?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Issue With Server-Side Validation

The fixed/correct DLL is included in version 10.7, as the bug was fixed in this version.

Can you inspect your web server logs, to see that is replies with the correct response code to the installer when the
serial number is validated?

Also, please send us the URL you are trying and a valid test serial number, so we can try it too.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

I am not getting any server errors.

The link is http://slomobooths.com/validate.php and here is user information:

John Doe
User Comp.
233-421-752-325

Thanks for your help!
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

Here is my PHP code. Is everything in the beginning correct? I omitted my database info.

Code: Select all

// client information table
$clients_tbl_name = 'clients2';
$sn_tbl_col       = 'serial_no';
$lic_no_tbl_col   = 'license_no';
$val_no_tbl_col   = 'validations_no';

// serial validation results
$serial_invalid = 0;    // invalid serial
$serial_ok      = 1;    // valid serial
$val_exceeded   = 2;    // valid serial but maximum number of validations exceeded

/**
 * Server HTTP response to the query issued by Advanced Installer serial validation tool.
 * 
 * @param $valResult represents the result of the serial validation and has one of the 
 *                   above values: $serial_invalid, $serial_ok, $act_exceeded 
 */
function ServerResponse($valResult, $posted_serial = '', $lang_id = 1033)
{
  global $serial_invalid, $serial_ok, $val_exceeded;
  
  $msg_sep = "\n";
  
  // load error messages from your database, using "$lang_id" for localization (optional)
  
  if($posted_serial == '')
    return LICENSE_INVALID . $msg_sep . "This is a test";
  
  switch($valResult)
  {
    case $val_exceeded:
      return LICENSE_INVALID . $msg_sep . 'Maximum number of validations exceeded for Serial Number: ' . $posted_serial;
    case $serial_ok:
      return LICENSE_VALID;
    default:
      return LICENSE_INVALID . $msg_sep . 'Serial Number: ' . $posted_serial . ' is invalid !';
  }
}

// Variables POSTed by Advanced Installer serial validation tool to this web page: "sn", "languageid".
if(isset($_POST['sn']) && trim($_POST['sn']) != '')
{
  // get the serial number entered by the installing user in the "UserRegistrationDlg" dialog 
  $sn = trim($_POST['sn']);
  
  // get the system language ID of the user's machine
  // (you can use this parameter to display a localized error message taken from your database)
  $languageid = (int) $_POST['languageid'];
  
  // connect to database
  $db_conn = @mysql_connect($db_host, $db_user, $db_pass);
  if(!$db_conn)
  {
    // issue error response
    echo ServerResponse($serial_invalid, $sn, $languageid);
    die();
  }
  
  // select target database
  $db_selected = @mysql_select_db($db_name, $db_conn);
  if(!$db_selected)
  {
    // issue error response
    echo ServerResponse($serial_invalid, $sn, $languageid);
    die();
  }
  
  // prepare SQL statement
  $sn_query = sprintf("SELECT `%s`, `%s`, `%s` FROM `%s` WHERE `%s` = '%s'", 
    $sn_tbl_col, $lic_no_tbl_col, $val_no_tbl_col, 
    $clients_tbl_name, $sn_tbl_col, mysql_real_escape_string($sn));
  
  // execute query
  $result = @mysql_query($sn_query, $db_conn);
  
  // get result set size
  if(@mysql_num_rows($result) == 0)
  {
    // serial number NOT found in database => issue error response
    echo ServerResponse($serial_invalid, $sn, $languageid);
    die();
  }
  else // serial number was found in database
  {
    // fetch the result row as an associative array 
    $row = @mysql_fetch_array($result, MYSQL_ASSOC);
    if(!$row)
    {
      // issue error response
      echo ServerResponse($serial_invalid, $sn, $languageid);
      die();
    }
    
    // increment the validations_no column
    $inc_val_no_query = sprintf("UPDATE `%s` SET `%s` = `%s` + 1 WHERE `%s` = '%s'",
      $clients_tbl_name, $val_no_tbl_col, $val_no_tbl_col, 
      $sn_tbl_col, mysql_real_escape_string($sn));
    
    // execute the update query
    @mysql_query($inc_val_no_query, $db_conn);

    // check whether the user has reached maximum number of validations
    $license_no    = (int) $row[ $lic_no_tbl_col ];
    $validation_no = (int) $row[ $val_no_tbl_col ];
    
    if($validation_no >= $license_no)
    {
      // issue error response => maximum number of validations exceeded
      echo ServerResponse($val_exceeded, $sn, $languageid);
      die();
    }
    else
    {
     // issue SUCCESS response
     echo ServerResponse($serial_ok, $sn, $languageid);
     die();
    }
  }
}
else
{
  // issue error response
  echo ServerResponse($serial_invalid);
  die();
}

?>

jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

Does it not work on Windows 8?
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Issue With Server-Side Validation

The code is not OS dependent, it should work on all platforms.

I tried the serial at the URL you specified and it does not work neither with version 10.3 nor with version 10.7.

I mentioned version 10.3 because this was the last working version which we tested with working scripts, in version 10.5 it appeared the bug I mentioned above. This bug was fixed in version 10.7, so this version should also work.

Can you please first try our sample scripts? http://www.advancedinstaller.com/exampl ... dation.zip
Unfortunately we do not have the resources to debug your own scripts at this moment.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

I am using your example files. It seems as though the PHP is not pulling the serial from the installer. What do the file permissions need to be?
paboot
Posts: 1
Joined: Fri Nov 15, 2013 2:34 pm

Re: Issue With Server-Side Validation

I'm encountering the same problem. Does this have a solution already ? In my case, the PHP was unable to retrieve the serial number or email or even name, hence the 'Missing Serial Number' message. I'm thinking the POST values (i.e. sn, email, name) were not set yet / the installer failed to set them when the installer made the POST request. Any reply / solution / suggestion would be much appreciated, thanks :D
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Issue With Server-Side Validation

Hello,

Indeed, we have tested the scenario and this seems to be an Advanced Installer issue. Please give us some time to investigate it and we'll get back to you as soon as we have a conclusive answer.

Thank you for your patience and understanding.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jlh211
Posts: 18
Joined: Tue Nov 12, 2013 1:02 am

Re: Issue With Server-Side Validation

Do you guys have an ETA for this issue?

Return to “Common Problems”