Only attempt to iterate through VPS list query results when the result isn't empty

feature/node-rewrite
Sven Slootweg 12 years ago
parent d6d1804fa2
commit 454d21946a

@ -15,36 +15,37 @@ if(!isset($_CVM)) { die("Unauthorized."); }
if($sLoggedIn === true)
{
$result = $database->CachedQuery("SELECT * FROM containers WHERE `UserId` = :UserId", array(":UserId" => $sUser->sId));
$sVpsList = array();
foreach($result->data as $row)
if($result = $database->CachedQuery("SELECT * FROM containers WHERE `UserId` = :UserId", array(":UserId" => $sUser->sId)))
{
$sVps = new Vps($row);
try
{
$sStatus = $sVps->sStatusText;
}
catch (SshException $e)
foreach($result->data as $row)
{
$sStatus = "unknown";
$sVps = new Vps($row);
try
{
$sStatus = $sVps->sStatusText;
}
catch (SshException $e)
{
$sStatus = "unknown";
}
$sVpsList[] = array(
'id' => $sVps->sId,
'hostname' => $sVps->sHostname,
'node' => $sVps->sNode->sName,
'node-hostname' => $sVps->sNode->sHostname,
'template' => $sVps->sTemplate->sName,
'diskspace' => number_format($sVps->sDiskSpace / 1024),
'diskspace-unit' => "GB",
'guaranteed-ram' => $sVps->sGuaranteedRam,
'guaranteed-ram-unit' => "MB",
'status' => $sStatus,
'virtualization-type' => $sVps->sVirtualizationType
);
}
$sVpsList[] = array(
'id' => $sVps->sId,
'hostname' => $sVps->sHostname,
'node' => $sVps->sNode->sName,
'node-hostname' => $sVps->sNode->sHostname,
'template' => $sVps->sTemplate->sName,
'diskspace' => number_format($sVps->sDiskSpace / 1024),
'diskspace-unit' => "GB",
'guaranteed-ram' => $sVps->sGuaranteedRam,
'guaranteed-ram-unit' => "MB",
'status' => $sStatus,
'virtualization-type' => $sVps->sVirtualizationType
);
}
$sMainContents = Templater::AdvancedParse("{$sTheme}/client/vps/list", $locale->strings, array(

Loading…
Cancel
Save