<?php

$pagesize = 10;
$pagestart = 0;

$extension = $_REQUEST['id'];

$title = "ARDI Extension Details";

include($installfolder.'/include/tmpl.php');

function cmp($a, $b)
{
    if ($a == $b) {
        return 0;
    }
    return version_compare($b, $a);
}

function GetBuildNo($str)
{
	$str = str_replace("_x64","",$str);
	$str = str_replace("_x86","",$str);
	$str = str_replace("_lin","",$str);
	
	$lastnumber = 0;
	$bits = explode('_',$str);
	foreach($bits as $b)
	{
		if ((0+$b) != 0)
		{
			$lastnumber = 0+$b;
		}
	}
	return $lastnumber;
}
$platform = "windows";

$securitycontext = [
	'ssl' => [
		'cafile' => $installfolder.'/addons/extender/cacert.pem',
		'verify_peer'=>true,
		'verify_peer_name'=>true
	]
];

$info = file_get_contents("https://ardi.optrix.com.au/extensions/".$extension.'/info.json',false,stream_context_create($securitycontext));
$inf = json_decode($info);


$full = @file_get_contents("https://ardi.optrix.com.au/extensions/".$extension.'/details.html',false,stream_context_create($securitycontext));

//ksort($set);

global $db;

T('header-basic','title='.$title);

$localversions = "";

ST('section','class=content');
	ST('row');
	
		ST('half');
			ST('box','title=Extension Details');				
				echo '<h2>'.$inf->name.' ('.$inf->version.')</h2>';
				echo $full;				
			ET();
		ET();

		ST('half');
			ST('box','title=Actions');
			
				ST('buttonmenu');
					?>
					<li><a href="<?php echo $siteroot;?>/extender/install?id=<?php echo $inf->code;?>"><button style="width: 100%;" class="btn btn-success">Install/Update Extension</button></a></li>
					<li><a href="https://ardi.optrix.com.au/extensions/download.php?code=<?php echo $inf->code;?>"><button style="width: 100%;" class="btn btn-default">Download Package</button></a></li>					
					<?php if ($inf->type == "addon") { ?>
					<li><a href="<?php echo $siteroot;?>/extender/remove?id=<?php echo $inf->code;?>"><button style="width: 100%;" class="btn btn-warning">Remove Extension</button></a></li>
					<?php
					}
				ET();
			
			ET();
		ET();	
	ET();
ET();

?>
