<?php
	
	$ve = 1;
	if (function_exists('ioncube_file_info'))
	{
		if ($a = ioncube_file_info())
		{
			$lic = $a['FILE_EXPIRY'] - time();
			$lic = ceil($lic / 84600);

			$msg= "Expires On ".date("F j, Y",$a['FILE_EXPIRY']);
		}
		
		$val = ioncube_license_properties();
		
		$owner = $val['Company']['value'];
		$serial = $val['Serial']['value'];
		
		global $license;
		if ($license->assettotal == -842)
			$maxassets = "Unlimited";
		else
			$maxassets = $license->assettotal;
			
		if (($license->usertotal >= 100) || ($license->usertotal == -842))
		{
			$maxusers = "Unlimited";
		}
		else
		{
			$maxusers = $license->usertotal;
		}
		
		if ($license->veenabled == false)
		{
			$ve = 0;
		}
	}
	else
	{
		$msg = "Does Not Expire (Unsecured Version)";
		$owner = "Unknown";
		$serial = "None";
		$maxassets = "Unlimited";
		$maxusers = "Unlimited";
	}
	
	
$apmultiplier = 10;

if (!class_exists('Sites'))
{
	require_once($installfolder.'/model/sites.php');
}

$acount = Sites::QueryAcrossAll("SELECT COUNT(*) as targ FROM (SELECT DISTINCT assets.id FROM assets JOIN assetvalues ON (assets.id = assetvalues.assetid)) Tbl",1,true);
$bcount = Sites::QueryAcrossAll("SELECT COUNT(*) as targ FROM (SELECT DISTINCT assetid,propertyid FROM datalinks) Tbl",1,true);

$mxcount = $acount;
if (($bcount / $apmultiplier) > $mxcount) $mxcount = $bcount / $apmultiplier;

	$points['License'] = array();
	$points['License']['owner'] = $owner;
	$points['License']['serial'] = $serial;
	$points['License']['user_max'] = $maxusers;
	$points['License']['asset_max'] = $maxassets;
	$points['License']['asset_count'] = $mxcount;
	$points['License']['expiry'] = $msg;
	$points['License']['ve'] = $ve;
	$points['License']['valid'] = 1;
	if ($maxassets != "Unlimited")
	{
		if ($mxcount > $maxassets)
		{
			$points['License']['critical'] = 1;
		}
	}
	if ($msg != "Does Not Expire (Unsecured Version)")
	{
		
	}

?>