????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.48 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/fi2/scripts/ |
Upload File : |
<?php
require_once('connection.php');
$guid = $_GET['guid'];
$mac_id = $_GET['mac_id'];
$ip = $_GET['ip'];
$username = $_GET['username'];
$version_revit = $_GET['version_revit'];//added
$version_autocad = $_GET['version_autocad'];//added
$timestamp = date("Y-m-d H:i:s");
$returnValue = '';
$isDebug = false;
$sql = "SELECT Expirydate, Active, Payed FROM tblLicenses where GUID=$guid";
$result = mysqli_query($connection, $sql);
if ($result->num_rows > 0)
{
$row = mysqli_fetch_array($result);
$expirydate = $row['Expirydate'];
$active = $row['Active'];
$payed = $row['Payed'];
$currentdate = date("Y-m-d");
if ($active == 0 && $payed == 0)
{
echo 'Expired!';
return;
}
if ($isDebug)
{
echo 'expirydate = ' .$expirydate .'<br>';
echo 'currentdate = ' .$currentdate .'<br>';
}
$diffInDays = getTotalDaysBetweenTwoDates($expirydate, $currentdate);//Include end day
if ($isDebug)
{
echo "diffInDays: " .$diffInDays .'<br>';
}
if ($diffInDays <= 0)//Expired or Grace period
{
if ($diffInDays < -30)//Expired
{
echo 'Expired!';
include 'updateDBDataToZeros.php';
}
else//Grace period
{
include 'updateMac1_Mac2_2.php';
$val = strpos($returnValue, 'Already registered on 2 machines!');
if (($val > 0) === false)//Doesn't exist
{
updatePayedToZero($guid, $connection);
insertDataIntoTblUsage($guid, $ip, $username, $timestamp, $connection);
echo 'Renew within ' . (30 + $diffInDays) . ' days to continue with Astacus Toolbox';
}
else//Invalid license. Already registered on 2 machines.
{
echo $returnValue;
}
}
}
else//Active
{
updateVersionNo($guid, $connection, $version_revit, $version_autocad);
insertDataIntoTblUsage($guid, $ip, $username, $timestamp, $connection);
if ($isDebug)
{
echo 'Active before updateMac1_Mac2_2' .'<br>';
}
include 'updateMac1_Mac2_2.php';
echo $returnValue;
}
}
else
{
echo "Unregistered version";
}
function updatePayedToZero($guid, $connection)
{
$sqlUpdatePayed = "UPDATE tblLicenses SET Payed=0 WHERE GUID=$guid";
mysqli_query($connection, $sqlUpdatePayed);
}
function updateVersionNo($guid, $connection, $version_revit, $version_autocad)
{
if ($version_revit != "")
{
$sqlUpdateVersion = "UPDATE tblLicenses SET version_Revit=$version_revit WHERE GUID=$guid";
mysqli_query($connection, $sqlUpdateVersion);
}
else if ($version_autocad != "")
{
$sqlUpdateVersion = "UPDATE tblLicenses SET version_AutoCAD=$version_autocad WHERE GUID=$guid";
mysqli_query($connection, $sqlUpdateVersion);
}
}
function insertDataIntoTblUsage($guid, $ip, $username, $timestamp, $connection)
{
$sqlInsert = "INSERT INTO tblUsageLog VALUES(null, $guid, $ip, $username, '$timestamp')";
mysqli_query($connection, $sqlInsert);
}
function getTotalDaysBetweenTwoDates($date1, $date2)
{
//calulating the difference in timestamps
$difference = strtotime($date1) - strtotime($date2);
// 1 day = 24 hours
// 24 * 60 * 60 = 86400 seconds
return (ceil($difference / 86400));
}
mysqli_close($connection);
?>