Here is what I have so far.
The script to check it is here:
// License Check File
// Temp test file will be expanded to do actual check later.
// Make DB Connection
$link = mysql_connect(localhost, user, pass);
if (!$link)
{
die ("Couldn't Connect To Database");
}
if (!mysql_select_db (databasename, $link) )
{
die ("Couldn't open $db: ".mysql_error() );
}
// GET VARS
$ip = $GET['ip'];
$server = $GET['server'];
$license = $_GET['license'];
if((!$ip)||(!$server)||(!$license)){
echo"N";
exit;
}
// Pull Info From Database
$sql = "SELECT * FROM license WHERE LicenseNum = \"$license\"";
$result = @($sql,$link) or die("Couldn't execute query");
if($result){
$num = mysql_num_rows($result);
}
if($num > 0){
$row = mysql_fetch_array($result);
$L_IP = $row["IP"];
$L_server = $row["ServerName"];
// Check IP And Server Name Match
if(($ip != $L_IP)||($server != $L_server)){
echo"N";
}else{
echo"Y";
}
}else{
echo"N";
}
mysql_close($link);
It takes the license number IP and Server Name from $_GET
checks it against the license database and prints either Y or N.
Included in the app(encoded)
// License Check
$ip = $SERVER['SERVER_ADDR'];
$server = $SERVER['SERVER_NAME'];
// Check Authorization
$checkurl = "http://www.domain.com/licensecheck/lcheck.php?
license=$license&ip=$ip&server=$server&checkdate=$checkdate";
$in = @fopen ($checkurl, 'r');
if($in){
$source = fread ($in, 1);
fclose ($in);
}
if($source){
// If declined Notify and shutdown.
if($source == "N"){
echo"Invalid license text will be here";
exit;
}
}
This sends the license number, IP, and server name to the url
specified then reads the one character string. If Y it lets the
scripts run if N it will display the Invalid text message and call
exit; to stop execution.
I still have to add a way to handle database errors but it is working.
Does anyone have any ideas on how to set it up so it does not
do the check on every run? I though about setting a session
variable to flag that the check has been done. But if they figured
that out they could set the session variable themselves and
bypass the check.