Bom estou tentando fazer da seguinte maneira:
authlicense.class.php
Código PHP:
<?php
class authLicense
{
public function __construct()
{
if(empty($_POST['license']))
return 0;
elseif(isset($_POST['license']))
$this->verifyLicense($_POST['license']);
}
private function verifyLicense($license)
{
global $dbmysql;
$getLicenseQ = $dbmysql->queryAuthLicense("SELECT license, active FROM `dblicense` WHERE license = '{$license}'");
if(mysql_num_rows($getLicenseQ) == 0)
return 1;
else
{
$getLicense = mysql_fetch_object($getLicenseQ);
if($getLicense->active == 0)
return 2;
else
return 3;
}
}
}
$dbauthLicense = new authLicense();
?>
validacao.php
Código PHP:
<?php
$key = file_get_contents("license/key.txt");
$ch = curl_init('http://meusite.com/authLicense.class.php');
$data = array("license" => $key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
curl_close($ch);
if($result == 0)
exit('Erro: O arquivo de licença está vazio.');
elseif($result == 1)
exit('Erro: Licença não registrada.');
elseif($result == 2)
exit('Erro: sua licença está desativada.');
?>
Mas eu não consigo fazer com que o servidor onde está o authlicense.class.php me retorne algum valor.