include_once 'includes/class.posmailer.php';
$eveRender = new eveRender($config, $mod, false);
$colors = $eveRender->themeconfig;
$eve = new Eve();
$posmgmt = new POSMGMT();
$mail = new posMailer();
$mail->mailinit();
$userinfo = $posmgmt->GetUserInfo();
$eve->SessionSetVar('userlogged', 1);
$access = 5;
$eve->SessionSetVar('access', $access);
$eveRender->Assign('access', $access);
$args['pr'] = 2;
$rows = $posmgmt->GetAllPos2($args);
foreach ($rows as $key => $row) {
    $row2 = $posmgmt->GetLastPosUpdate($row['pos_id']);
    $tower = $posmgmt->GetTowerInfo($row['pos_id']);
    if ($tower) {
        $tower['current_cpu'] = $tower['cpu'];
        $tower['current_pg'] = $tower['powergrid'];
    }
    $charters_needed = $tower['charters_needed'];
    $pos_size = $row['pos_size'];
    $pos_race = $row['pos_race'];
    $systemID = $row['systemID'];
    $allianceid = $row['allianceid'];
    $tower['sovfriendly'] = $posmgmt->getSovereigntyStatus($systemID, $allianceid);
    $row3 = $posmgmt->GetStaticFBTowerInfo(array('pos_race' => $pos_race, 'pos_size' => $pos_size));
    if ($tower['sovfriendly'] == 1) {
        $tower['hasSov'] = 0.75;
    } else {
            $current_cpu = $current_cpu + $row['cpu'];
        }
    }
} else {
    $current_pg = 0;
    $current_cpu = 0;
}
if ($current_cpu <= 0 && $tower_cpu > 0) {
    $current_cpu = $tower_cpu;
}
if ($current_pg <= 0 && $tower_pg > 0) {
    $current_pg = $tower_pg;
}
$tower['current_pg'] = $current_pg;
$tower['current_cpu'] = $current_cpu;
$row2 = $posmgmt->GetLastPosUpdate($pos_id);
$last_update = gmdate("Y-m-d H:i:s", $row2['datetime']);
$hoursago = $posmgmt->hoursago($pos_id, 1);
$optimal = $posmgmt->posoptimaluptime($tower);
$optimalDiff = $posmgmt->getOptimalDifference($optimal, $tower);
$avail_fuelblock = $current_fuelblock;
$avail_strontium = $current_strontium;
$avail_charters = $current_charters;
if ($avail_charters <= 0 && $required_charters) {
    $avail_charters = $current_charters - $required_charters * floor($current_charters / $required_charters);
}
$tower['avail_fuelblock'] = $avail_fuelblock;
$tower['avail_strontium'] = $avail_strontium;
$tower['avail_charters'] = $avail_charters;
$res0 = $posmgmt->GetPosSilos($pos_id);
$silocap = array(1 => 30000, 2 => 20000, 3 => 40000, 4 => 20000, 5 => 20000, 6 => 30000, 7 => 30000, 8 => 20000, 9 => 20000, 10 => 20000, 11 => 30000, 12 => 40000, 13 => 40000, 14 => 30000);