[insert_php]
//If the form is submitted
if (isset($_POST[‘button1’]))
{
$request= $_POST[‘requesttext’];
$url = ‘http://licensingwebapplication.azurewebsites.net/verifylicense.aspx?action=connect’;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$pattern = “/([^<>]*)<\/sessid>/”;
preg_match($pattern, $response, $matches, PREG_OFFSET_CAPTURE);
$matches=explode(““,$matches[0][“0”]);
$matches=explode(“ “,$matches[“1”]);
$sessid =$matches[“0″];//’25e540ec5238497aa29814f1ca0d3aa8′;//str_replace(‘”‘,’ ‘,$sessid);
$body=’username=licenseclient&password=45gYMszc%22&sessid=’.$sessid;//25e540ec5238497aa29814f1ca0d3aa8′;
curl_close($ch);
$url = ‘http://licensingwebapplication.azurewebsites.net/verifylicense.aspx?action=login’;
$ch1 = curl_init($url);
curl_setopt($ch1, CURLOPT_POST, 1);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
$response1 = curl_exec($ch1);
curl_close($ch1);
$request1 = ‘sessid=’.$sessid.’&license_info=’.urlencode($request);
$url = ‘http://licensingwebapplication.azurewebsites.net/verifylicense.aspx?action=activate’;
$ch2 = curl_init($url);
curl_setopt($ch2, CURLOPT_POST, 1);
//curl_setopt($ch2, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $request1);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
$verification = curl_exec($ch2);
if ($verification==”)
{
$url = ‘http://licensingwebapplication.azurewebsites.net/verifylicense.aspx?action=verify_activation’;
$ch2 = curl_init($url);
curl_setopt($ch2, CURLOPT_POST, 1);
//curl_setopt($ch2, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $request1);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
$verification = curl_exec($ch2);
}
$pattern = “/([^<>]*)<\/result>/”;
preg_match($pattern, $verification, $matches, PREG_OFFSET_CAPTURE);
$matches=explode(““,$matches[0][“0”]);
$matches=explode(“ “,$matches[“1”]);
$_POST[‘responsetext’]=$matches[“0”];
curl_close($ch2);
} [/insert_php]