/* There is an connection issue, repository can not be reached */
$update_text="<div class='text-danger'>Connection error</div><a href='' onclick='checkupdate()'>Click to retry now</a>";
}elseif(file_exists($file_repository)){
/* The repository is not corect */
$update_text="<div class='text-danger'>Repository error</div><a href='' onclick='checkupdate()'>Click to retry now</a>";
}elseif(file_exists($file_updates)){
/* There are updates available */
$updates=file_get_contents($file_updates);
$update_text="<div class='text-info'>There are <b>".$updates."</b> update(s) available</div><a href='/system_firmware.php'> Click to update </a>";
}elseif(file_exists($file_last_check)){
$last_check=file_get_contents($file_last_check);
$update_text="<div class='text-info'>No updates found (checked once a day) </div><div class='text-info'>last time on: ".$last_check."</div><a href='' onclick='checkupdate()'>Click to check now</a>";
if(file_exists($file_pkg_status)){
$json=file_get_contents($file_pkg_status);
$pkg_status=json_decode($json,true);
if($pkg_status["updates"]=="0"){
echo"Last check at (".$pkg_status["last_check"]."), you where up to date";
}else{
$update_text="<div class='text-info'>Daily cron has not yet run</div><a href='' onclick='checkupdate()'>Click here to try now</a>";
echo"<span class='text-danger'>A total of ".$pkg_status["updates"]." update(s) are available.</span>";
}
}else{
echo"Unknown<span class='btn-link' onclick='checkupdate()'>Click to check now</span>";