if ($row3) {
     $tower['required_fuelblock'] = ceil($row3['fuelblock'] * $tower['hasSov']);
     $tower['required_strontium'] = ceil($row3['strontium'] * $tower['hasSov']);
     $tower['required_charters'] = $charters_needed ? 1 : 0;
     $row3['charters'] = $tower['required_charters'];
     $tower['total_pg'] = $row3['pg'];
     $tower['total_cpu'] = $row3['cpu'];
     $tower['uptimecalc'] = $posmgmt->uptimecalc($row['pos_id']);
     $tower['pos_capacity'] = $tower['fuel_hangar'] = $row3['fuel_hangar'];
 }
 $row['result_uptimecalc'] = $posmgmt->uptimecalc($row['pos_id']);
 $row['result_online'] = $posmgmt->online($row['result_uptimecalc']);
 $row['last_update'] = gmdate("Y-m-d H:i:s", $row2['datetime']);
 $row['online'] = $posmgmt->daycalc($row['result_online']);
 $row['region'] = $posmgmt->getRegionNameFromMoonID($row['MoonName']);
 $row['system'] = $posmgmt->getSystemName($row['systemID']);
 $row['result_optimal'] = $posmgmt->posoptimaluptime($tower);
 $rows[$key] = $row;
 $characterInfo = $posmgmt->GetUserInfofromID($row['owner_id']);
 $secondary_characterInfo = $posmgmt->GetUserInfofromID($row['secondary_owner_id']);
 $diff = array('fuelblock' => $row['result_optimal']['optimum_fuelblock'] - $row['fuelblock'], 'charters' => $row['result_optimal']['optimum_charters'] - $row['charters']);
 if ($row['pos_status'] >= 2) {
     if ($characterInfo['away'] != 1 && isset($characterInfo['email'])) {
         if ($row['result_online'] < $config['minimal_fuel']) {
             $mail->posalert($characterInfo['email'], $characterInfo['name'], $row, $row3, $diff);
         }
     }
     if ($secondary_characterInfo['away'] != 1 && isset($secondary_characterInfo['email'])) {
         if ($row['result_online'] < $config['minimal_fuel']) {
             $mail->posalert($secondary_characterInfo['email'], $secondary_characterInfo['name'], $row, $row3, $diff);
         }
$tower = $posmgmt->GetTowerInfo($pos_id);
if ($tower) {
    $current_fuelblock = $tower['fuelblock'];
    $outpost_id = $tower['outpost_id'];
    $outpost_name = $tower['outpost_name'];
    $current_strontium = $tower['strontium'];
    $current_charters = $tower['charters'];
    $pos_size = $tower['pos_size'];
    $pos_race = $tower['pos_race'];
    $towerName = $tower['towerName'];
    $systemID = $tower['systemID'];
    $location = $tower['moonName'];
    $tower_cpu = $tower['cpu'];
    $tower_pg = $tower['powergrid'];
    $status = $tower['status'];
    $systemName = $posmgmt->getSystemName($systemID);
    //New Call to Function to get System Name from database
    $allianceid = $tower['allianceid'];
    //New Sovereingty Function to retrieve Sovereingty Status
    $tower['sovereignty'] = $posmgmt->getSovereignty($systemID);
    //$sovereignty              = $tower['sovereignty'] = $sov['sovereignty'];
    $allianceid = $tower['allianceid'];
    $tower['sovfriendly'] = $posmgmt->getSovereigntyStatus($systemID, $allianceid);
    $charters_needed = $tower['charters_needed'];
    //$system = $row['system'];
    $pos_id = $tower['pos_id'];
    // grabs the new allianceid off the table
    $owner_id = $tower['owner_id'];
    $sec_owner_id = $tower['secondary_owner_id'];
    $owner_info = $posmgmt->GetUserInfofromID($tower['owner_id']);
    $tower['owner_name'] = $owner_info['name'];