$jobPending = $gsprache->del;
                } else {
                    $jobPending = $gsprache->mod;
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['status'] = (is_object($json) and isset($json->newActive) and $json->newActive == 'N') ? 2 : 0;
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $resellerLockupID));
        }
    }
    if ($row['active'] == 'N') {
        $statusMessage = $gsprache->status_inactive;
    } else {
        if ($row['uptime'] == 1) {
            $statusMessage = $gsprache->status_stop;
        } else {
            if ($row['uptime'] < 1) {
                $statusMessage = $gsprache->status_crashed;
            } else {
                if ($row['password'] == 'Y' and $row['queryPassword'] == 'N') {
                    $statusMessage = $gsprache->status_password;
                }
            }
        }
    }
    $password = ($row['initialpassword'] != null and $row['initialpassword'] != '') ? '?password='******'initialpassword'] : '';
    $server = ($row['usedns'] == 'Y' and $row['dns'] != null or $row['dns'] != '') ? '<a href="ts3server://' . $row['dns'] . $password . '">' . $row['ip'] . ':' . $row['port'] . '</a> ( ' . $row['dns'] . ' )' : '<a href="ts3server://' . $row['ip'] . ':' . $row['port'] . $password . '">' . $row['ip'] . ':' . $row['port'] . '</a>';
    $array['aaData'][] = array($server, $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $row['status'], (string) $statusMessage), $row['localserverid'], returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userid'], ''), (int) $row['usedslots'] . '/' . (int) $row['slots'], (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'vo', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'vo', 'md', $row['id'], $gsprache->mod));
}
}
$query = $sql->prepare("SELECT COUNT(`newsID`) AS `amount` FROM `feeds_news` WHERE `resellerID`=?");
$query->execute(array($resellerLockupID));
$array['iTotalRecords'] = $query->fetchColumn();
if ($sSearch) {
    $query = $sql->prepare("SELECT COUNT(`newsID`) AS `amount` FROM `feeds_news` WHERE `resellerID`=:reseller_id AND (`newsID` LIKE :search OR `pubDate` LIKE :search OR ((LENGTH(`title`)<2 AND `link` LIKE :search) OR (LENGTH(`title`)>1 AND `title` LIKE :search)))");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => 'n.`title`', 1 => 'n.`newsID`', 2 => 'n.`pubDate`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'n.`newsID` ASC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT n.`newsID`,n.`title`,n.`link`,n.`pubDate`,n.`active` FROM `feeds_news` n LEFT JOIN `feeds_url` u ON n.`feedID`=u.`feedID` WHERE n.`resellerID`=:reseller_id AND (n.`newsID` LIKE :search OR n.`pubDate` LIKE :search OR ((LENGTH(n.`title`)<2 AND n.`link` LIKE :search) OR (LENGTH(n.`title`)>1 AND n.`title` LIKE :search))) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT n.`newsID`,n.`title`,n.`link`,n.`pubDate`,n.`active` FROM `feeds_news` n LEFT JOIN `feeds_url` u ON n.`feedID`=u.`feedID` WHERE n.`resellerID`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array(strlen($row['title']) < 2 ? $row['link'] : $row['title'], $row['newsID'], $row['pubDate'], returnButton($template_to_use, 'ajax_admin_feed_active.tpl', $row['active'], '', $row['newsID'], ''), returnButton($template_to_use, 'ajax_admin_feed_del.tpl', '', '', $row['newsID'], '') . returnButton($template_to_use, 'ajax_admin_feed_hidden.tpl', '', '', $row['newsID'], ''));
}
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['active'] = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N';
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $row['resellerid']));
        }
    }
    $statusMessage = $row['active'] == 'N' ? $gsprache->status_inactive : $gsprache->status_ok;
    if ($row['accounttype'] == 'a') {
        $accounttype = $sprache->accounttype_admin;
    } else {
        if ($row['accounttype'] == 'r') {
            $accounttype = $sprache->accounttype_reseller;
        } else {
            $accounttype = $sprache->accounttype_user;
        }
    }
    $actionString = '';
    if ($pa['userPassword'] and ($row['accounttype'] == 'a' and $pa['user'] or $row['accounttype'] != 'a')) {
        $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_pw.tpl', 'us', 'pw', $row['id'], $gsprache->password);
    }
    if ($row['id'] != $admin_id and ($row['accounttype'] == 'a' and $pa['user'] or $row['accounttype'] != 'a' and ($pa['user_users'] or $pa['user']))) {
        $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'us', 'dl', $row['id'], $gsprache->del);
    }
    if ($row['accounttype'] == 'a' and $pa['user'] or $row['accounttype'] != 'a' and ($pa['user_users'] or $pa['user'])) {
        $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'us', 'md', $row['id'], $gsprache->mod);
    }
    $array['aaData'][] = array(returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], '', $row['id'], ''), $row['id'], $row['full_name'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $row['active'] == 'N' ? 3 : 4, (string) $statusMessage), (string) $accounttype, (string) $jobPending, $actionString);
}
$failLogins = (int) $query->fetchColumn();
$query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `badips`");
$query->execute(array($resellerLockupID));
$array['iTotalRecords'] = $query->fetchColumn();
if ($sSearch) {
    $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `badips` WHERE `badip` LIKE :search OR `id` LIKE :search OR `bantime` LIKE :search OR `failcount` LIKE :search OR `reason` LIKE :search");
    $query->execute(array(':search' => '%' . $sSearch . '%'));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`badip`', 1 => '`id`', 2 => '`bantime`', 3 => '`failcount`', 4 => '`reason`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = '`logdate` DESC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT * FROM `badips` WHERE `badip` LIKE :search OR `id` LIKE :search OR `bantime` LIKE :search OR `failcount` LIKE :search OR `reason` LIKE :search ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%'));
} else {
    $query = $sql->prepare("SELECT * FROM `badips` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute();
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['badip'], $row['id'], $row['bantime'], $row['failcount'] . '/' . $failLogins, $row['reason'], returnButton($template_to_use, 'ajax_admin_job_checkbox.tpl', '', '', $row['id'], ''));
}
                    $jobPending = $gsprache->mod;
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['status'] = (is_object($json) and isset($json->newActive) and $json->newActive == 'N') ? 2 : 0;
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $resellerLockupID));
        }
    }
    if ($row['active'] == 'N') {
        $statusMessage = $gsprache->status_inactive;
    } else {
        if ($row['stopped'] == 'Y') {
            $statusMessage = $gsprache->status_stop;
        } else {
            if ($row['queryName'] == 'OFFLINE' and $row['notified'] >= $rSA['down_checks'] and $row['stopped'] == 'N') {
                $statusMessage = $gsprache->status_crashed;
            } else {
                if ($row['war'] == 'Y' and $row['queryPassword'] == 'N') {
                    $statusMessage = $gsprache->status_password;
                } else {
                    if ($row['brandname'] == 'Y' and $rSA['brandname'] != null and $rSA['brandname'] != '' and strpos(strtolower($row['queryName']), strtolower($rSA['brandname'])) === false) {
                        $statusMessage = $gsprache->status_server_tag;
                    }
                }
            }
        }
    }
    $array['aaData'][] = array(returnButton($template_to_use, 'ajax_admin_gameserver_icon.tpl', $row['shorten'], '', '', '') . ' ' . $row['address'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $row['status'], (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userid'], ''), (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_rs.tpl', 'gs', 'rs', $row['id'], $gsprache->start) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_st.tpl', 'gs', 'st', $row['id'], $gsprache->stop), returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'gs', 'ri', $row['id'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'gs', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'gs', 'md', $row['id'], $gsprache->mod));
}
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'm.`id` DESC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT m.*,COUNT(s.`id`) AS `installedserver`,SUM(s.`slots`) AS `installedslots`,SUM(s.`usedslots`) AS `uslots` FROM `voice_masterserver` AS m LEFT JOIN `voice_server` s ON m.`id`=s.`masterserver` WHERE (m.`resellerid`=:reseller_id OR m.`managedForID`=:reseller_id) AND (m.`ssh2ip` LIKE :search OR m.`id` LIKE :search OR m.`description` LIKE :search) GROUP BY m.`id` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT m.*,COUNT(s.`id`) AS `installedserver`,SUM(s.`slots`) AS `installedslots`,SUM(s.`usedslots`) AS `uslots` FROM `voice_masterserver` AS m LEFT JOIN `voice_server` s ON m.`id`=s.`masterserver` WHERE (m.`resellerid`=? OR m.`managedForID`=?) GROUP BY m.`id` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID, $resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['local_version'] != $row['latest_version']) {
        $status = 2;
        $statusMessage = $sprache->old_version . ' ' . $row['local_version'];
    }
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $installedslots = $row['installedslots'] == null ? 0 : $row['installedslots'];
    $aaDataArray = array($row['ssh2ip'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), $row['description'], $row['installedserver'] . '/' . $row['maxserver'], $installedslots . '/' . $row['maxslots']);
    $aaDataArray[] = ($row['managedServer'] == 'N' or $reseller_id == 0) ? returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'vm', 'ri', $row['id'], $sprache->import) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'vm', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'vm', 'md', $row['id'], $gsprache->mod) : '';
    $array['aaData'][] = $aaDataArray;
}
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`ip`', 1 => 'm.`webMasterID`', 2 => 'm.`active`', 3 => 'm.`description`', 4 => '`vhostsInstalled`', 5 => '`hddUsed`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'm.`webMasterID` DESC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT m.`webMasterID`,m.`ip`,m.`active`,m.`description`,m.`maxVhost`,m.`maxHDD`,COUNT(v.`webVhostID`) AS `vhostsInstalled`,SUM(v.`hdd`) AS `hddUsed` FROM `webMaster` AS m LEFT JOIN `webVhost` v ON m.`webMasterID`=v.`webMasterID` WHERE m.`resellerID`=:reseller_id AND (m.`ip` LIKE :search OR m.`webMasterID` LIKE :search OR m.`description` LIKE :search) GROUP BY m.`webMasterID` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT m.`webMasterID`,m.`ip`,m.`active`,m.`description`,m.`maxVhost`,m.`maxHDD`,COUNT(v.`webVhostID`) AS `vhostsInstalled`,SUM(v.`hdd`) AS `hddUsed` FROM `webMaster` AS m LEFT JOIN `webVhost` v ON m.`webMasterID`=v.`webMasterID` WHERE m.`resellerID`=? GROUP BY m.`webMasterID` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array($row['ip'], $row['webMasterID'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), $row['description'], (int) $row['vhostsInstalled'] . '/' . (int) $row['maxVhost'], (int) $row['hddUsed'] . '/' . (int) $row['maxHDD'], returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'wm', 'ri', $row['webMasterID'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'wm', 'dl', $row['webMasterID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'wm', 'md', $row['webMasterID'], $gsprache->mod));
}
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => 's.`ip`', 1 => 's.`id`', 2 => 's.`interface`', 3 => array('`installed_databases`', 's.`max_databases`'));
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 's.`id` ASC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT s.`id`,s.`active`,s.`ip`,s.`interface`,s.`max_databases`,(SELECT COUNT(1) AS `amount` FROM `mysql_external_dbs` AS d WHERE d.`sid`=s.`id`) AS `installed_databases` FROM `mysql_external_servers` AS s WHERE s.`resellerid`=:reseller_id AND (s.`id` LIKE :search OR s.`ip` LIKE :search OR s.`interface` LIKE :search {$statusQuery}) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT s.`id`,s.`active`,s.`ip`,s.`interface`,s.`max_databases`,(SELECT COUNT(1) AS `amount` FROM `mysql_external_dbs` AS d WHERE d.`sid`=s.`id`) AS `installed_databases` FROM `mysql_external_servers` AS s WHERE s.`resellerid`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array($row['ip'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), '<a href="' . $row['interface'] . '" target="_blank">' . $row['interface'] . '</a>', (int) $row['installed_databases'] . '/' . (int) $row['max_databases'], returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'my', 'ri', $row['id'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'my', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'my', 'md', $row['id'], $gsprache->mod));
}
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`ssh2ip`', 1 => 'm.`id`', 2 => 'm.`active`', 3 => '`description`', 4 => '`defaultdns`', 5 => '`installed_dns`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'm.`id` DESC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT m.*,COUNT(d.`dnsID`) AS `installed_dns` FROM `voice_tsdns` AS m LEFT JOIN `voice_dns` d ON d.`tsdnsID`=m.`id` WHERE m.`resellerid`=:reseller_id AND (m.`ssh2ip` LIKE :search OR m.`id` LIKE :search OR m.`description` LIKE :search OR `defaultdns` LIKE :search) GROUP BY m.`id` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT m.*,COUNT(d.`dnsID`) AS `installed_dns` FROM `voice_tsdns` AS m LEFT JOIN `voice_dns` d ON d.`tsdnsID`=m.`id` WHERE m.`resellerid`=? GROUP BY m.`id` ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array($row['ssh2ip'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), $row['description'], $row['defaultdns'], $row['installed_dns'] . '/' . $row['max_dns'], returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'vd', 'ip', $row['id'], $sprache->import) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'vd', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'vd', 'md', $row['id'], $gsprache->mod));
}
$query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='my' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1");
$query3 = $sql->prepare("UPDATE `mysql_external_dbs` SET `jobPending`='N' WHERE `id`=? AND `resellerid`=? LIMIT 1");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $jobPending = $gsprache->no;
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['jobPending'] == 'Y') {
        $query2->execute(array($row['id'], $resellerLockupID));
        while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
            if ($row2['action'] == 'ad') {
                $jobPending = $gsprache->add;
            } else {
                if ($row2['action'] == 'dl') {
                    $jobPending = $gsprache->del;
                } else {
                    $jobPending = $gsprache->mod;
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['status'] = (is_object($json) and isset($json->newActive) and $json->newActive == 'N') ? 2 : 0;
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $resellerLockupID));
        }
    }
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array($row['dbname'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), $row['description'], returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['uid'], ''), (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'md', 'ri', $row['id'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'md', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'md', 'md', $row['id'], $gsprache->mod));
}
        if (strpos(strtolower($value), strtolower($sSearch)) !== false) {
            $translationTypeKeys[] = $key;
        }
    }
    $translationInQuery .= count($translationTypeKeys) > 0 ? ' OR m.`type` IN (\'' . implode("','", $translationTypeKeys) . '\')' : '';
    $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `modules` AS m WHERE `id` LIKE :search {$translationInQuery}");
    $query->execute(array(':search' => '%' . $sSearch . '%'));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`name`', 1 => 'm.`id`', 2 => 'm.`active`', 3 => 'm.`type`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'm.`id` ASC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT m.*,(SELECT `text` FROM `translations` WHERE `type`='mo' AND `transID`=m.`id` AND `lang`=:lang LIMIT 1) AS `name` FROM `modules` AS m WHERE m.`id` LIKE :search {$translationInQuery} ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':lang' => $user_language, ':search' => '%' . $sSearch . '%'));
} else {
    $query = $sql->prepare("SELECT m.*,(SELECT `text` FROM `translations` WHERE `type`='mo' AND `transID`=m.`id` AND `lang`=? LIMIT 1) AS `name` FROM `modules` AS m ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($user_language));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['name'], $row['id'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $row['active'] == 'N' ? 2 : 4, ''), (string) $types[$row['type']], returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'mo', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'mo', 'md', $row['id'], $gsprache->mod));
}
$query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='wv' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1");
$query3 = $sql->prepare("UPDATE `webVhost` SET `jobPending`='N' WHERE `webVhostID`=? AND `resellerID`=? LIMIT 1");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $jobPending = $gsprache->no;
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['jobPending'] == 'Y') {
        $query2->execute(array($row['id'], $resellerLockupID));
        while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
            if ($row2['action'] == 'ad') {
                $jobPending = $gsprache->add;
            } else {
                if ($row2['action'] == 'dl') {
                    $jobPending = $gsprache->del;
                } else {
                    $jobPending = $gsprache->mod;
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['status'] = (is_object($json) and isset($json->newActive) and $json->newActive == 'N') ? 2 : 0;
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $resellerLockupID));
        }
    }
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array(strlen($row['description']) == 0 ? 'web-' . $row['webVhostID'] : $row['description'], $row['webVhostID'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userID'], ''), (int) $row['hddUsage'] . '/' . (int) $row['hdd'], (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'wv', 'ri', $row['webVhostID'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'wv', 'dl', $row['webVhostID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'wv', 'md', $row['webVhostID'], $gsprache->mod));
}
}
$query = $sql->prepare("SELECT COUNT(`feedID`) AS `amount` FROM `feeds_url` WHERE `resellerID`=?");
$query->execute(array($resellerLockupID));
$array['iTotalRecords'] = $query->fetchColumn();
if ($sSearch) {
    $query = $sql->prepare("SELECT COUNT(`feedID`) AS `amount` FROM `feeds_url` WHERE `resellerID`=:reseller_id AND (`feedID` LIKE :search OR `feedUrl` LIKE :search)");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`feedUrl`', 1 => '`feedID`', 2 => '`active`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = '`feedID` DESC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT `feedID`,`feedUrl` FROM `feeds_url` WHERE `resellerID`=:reseller_id AND (`feedID` LIKE :search OR `feedUrl` LIKE :search) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT `feedID`,`feedUrl` FROM `feeds_url` WHERE `resellerID`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['feedUrl'], $row['feedID'], returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'fe', 'dl', $row['feedID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'fe', 'md', $row['feedID'], $gsprache->mod));
}
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
        $addonShortenIDs[] = $row['addon_id'];
    }
    $addonInQuery = count($addonShortenIDs) > 0 ? ' OR `id` IN (' . implode(',', $addonShortenIDs) . ')' : '';
    $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `addons` WHERE `resellerid`=:reseller_id AND (`id` LIKE :search OR `type` LIKE :search OR `menudescription` LIKE :search {$addonInQuery})");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => 'a.`menudescription`', 1 => 'a.`id`', 2 => 'a.`type`', 3 => '`list`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'a.`id` ASC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT a.`id`,a.`menudescription`,a.`type`,(SELECT GROUP_CONCAT(DISTINCT s.`shorten` ORDER BY s.`shorten` ASC SEPARATOR ', ') AS `list` FROM `addons_allowed` AS al INNER JOIN `servertypes` AS s ON al.`servertype_id`=s.`id` WHERE al.`addon_id`=a.`id`) AS `list` FROM `addons` AS a WHERE a.`resellerid`=:reseller_id AND (`id` LIKE :search OR `type` LIKE :search OR `menudescription` LIKE :search {$addonInQuery}) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT a.`id`,a.`menudescription`,a.`type`,(SELECT GROUP_CONCAT(DISTINCT s.`shorten` ORDER BY s.`shorten` ASC SEPARATOR ', ') AS `list` FROM `addons_allowed` AS al INNER JOIN `servertypes` AS s ON al.`servertype_id`=s.`id` WHERE al.`addon_id`=a.`id`) AS `list` FROM `addons` AS a WHERE a.`resellerid`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['menudescription'], $row['id'], $row['type'] == 'map' ? (string) $sprache->map : (string) $sprache->tool, $row['list'], returnButton($template_to_use, 'ajax_admin_buttons_ex.tpl', 'ad', 'ex', $row['id'], $gsprache->export) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'ad', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'ad', 'md', $row['id'], $gsprache->mod));
}
}
$query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `servertypes` WHERE `resellerid`=?");
$query->execute(array($resellerLockupID));
$array['iTotalRecords'] = $query->fetchColumn();
if ($sSearch) {
    $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `servertypes` WHERE `resellerid`=:reseller_id AND (`id` LIKE :search OR `shorten` LIKE :search OR `description` LIKE :search)");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    $array['iTotalDisplayRecords'] = $query->fetchColumn();
} else {
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => '`description`', 1 => '`id`', 2 => '`shorten`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = '`id` ASC';
    }
}
if ($sSearch) {
    $query = $sql->prepare("SELECT `id`,`shorten`,`description` FROM `servertypes` WHERE `resellerid`=:reseller_id AND (`id` LIKE :search OR `shorten` LIKE :search OR `description` LIKE :search) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT `id`,`shorten`,`description` FROM `servertypes` WHERE `resellerid`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['description'], $row['id'], $row['shorten'], returnButton($template_to_use, 'ajax_admin_buttons_ex.tpl', 'im', 'ex', $row['id'], $gsprache->export) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'im', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'im', 'md', $row['id'], $gsprache->mod));
}
        if ($checkReturn === false) {
            $description = 'The login data does not work';
        } else {
            if (strlen($checkReturn) > 0) {
                $games = array();
                foreach (preg_split('/\\;/', $checkReturn, -1, PREG_SPLIT_NO_EMPTY) as $status) {
                    $ex = explode('=', $status);
                    if (isset($ex[1])) {
                        $games[$ex[0]] = $ex[1];
                    }
                }
                foreach ($games as $shorten => $v) {
                    // Check if the shorten exists and the update is done
                    $query3->execute(array($shorten, $resellerLockupID, $rootServer->sship));
                    while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) {
                        // If the update is no longer running, update db entry
                        if ($v == 0) {
                            $statusList[$shorten] = true;
                            $query4->execute(array($row3['id']));
                            unset($sshcheck[array_search($shorten, $sshcheck)]);
                        }
                    }
                }
            }
        }
        foreach ($sshcheck as $shorten) {
            $statusList[$shorten] = false;
        }
    }
    $array['aaData'][] = array($row['ip'], $row['id'], $description, returnButton($template_to_use, 'ajax_admin_master_list.tpl', $statusList, '', '', ''), returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'ma', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_add.tpl', 'ma', 'ad', $row['id'], $gsprache->add));
}
}
$orderFields = array(0 => 'r.`ip`', 1 => 'r.`id`', 2 => 'r.`active`', 3 => 'r.`description`', 4 => '`gameserver_amount`', 5 => '`gameserver_ram`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'r.`id` ASC';
    }
}
if ($sSearch) {
    if ($reseller_id == 0) {
        $query = $sql->prepare("SELECT r.`id`,r.`ip`,r.`active`,r.`description`,r.`maxserver`,r.`ram`,r.`os`,(SELECT COUNT(1) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_amount`,(SELECT SUM(`maxram`) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_ram` FROM `rserverdata` r WHERE r.`id` LIKE :search OR r.`ip` LIKE :search OR r.`description` LIKE :search ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
        $query->execute(array(':search' => '%' . $sSearch . '%'));
    } else {
        $query = $sql->prepare("SELECT r.`id`,r.`ip`,r.`active`,r.`description`,r.`maxserver`,r.`ram`,r.`os`,(SELECT COUNT(1) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_amount`,(SELECT SUM(`maxram`) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_ram` FROM `rserverdata` r WHERE (r.`resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`)) AND (r.`id` LIKE :search OR r.`ip` LIKE :search OR r.`description` LIKE :search) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
        $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
    }
} else {
    if ($reseller_id == 0) {
        $query = $sql->prepare("SELECT r.`id`,r.`ip`,r.`active`,r.`description`,r.`maxserver`,r.`ram`,r.`os`,(SELECT COUNT(1) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_amount`,(SELECT SUM(`maxram`) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_ram` FROM `rserverdata` r ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
        $query->execute();
    } else {
        $query = $sql->prepare("SELECT r.`id`,r.`ip`,r.`active`,r.`description`,r.`maxserver`,r.`ram`,r.`os`,(SELECT COUNT(1) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_amount`,(SELECT SUM(`maxram`) AS `amount` FROM `gsswitch` g WHERE g.`rootID`=r.`id`) AS `gameserver_ram` FROM `rserverdata` r WHERE r.`resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
        $query->execute(array(':reseller_id' => $resellerLockupID));
    }
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $array['aaData'][] = array($row['ip'], $row['id'], $row['active'] == 'Y' ? (string) $gsprache->yes : (string) $gsprache->no, $row['description'], (int) $row['gameserver_amount'] . '/' . (int) $row['maxserver'], (int) $row['gameserver_ram'] . '/' . (int) $row['ram'], returnButton($template_to_use, 'ajax_admin_buttons_ri.tpl', 'ro', 'ri', $row['id'], $gsprache->reinstall) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'ro', 'dl', $row['id'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'ro', 'md', $row['id'], $gsprache->mod));
}
    $array['iTotalDisplayRecords'] = $array['iTotalRecords'];
}
$orderFields = array(0 => 't.`title`', 1 => 'c.`commentID`', 2 => 'c.`authorname`', 3 => 'c.`date`', 4 => 'c.`moderateAccepted`', 5 => 'c.`markedSpam`');
if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) {
    $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir;
} else {
    if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) {
        $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir;
    } else {
        $orderBy = 'c.`commentID` DESC';
    }
}
$query = $sql->prepare("SELECT `seo` FROM `page_settings` WHERE `resellerid`=? LIMIT 1");
$query->execute(array($resellerLockupID));
$seoActive = $query->fetchColumn();
if ($sSearch) {
    $query = $sql->prepare("SELECT t.`pageid`,t.`language`,t.`title`,c.`commentID`,c.`date`,c.`authorname`,c.`markedSpam`,c.`moderateAccepted` FROM `page_comments` c LEFT JOIN `page_pages_text` t ON c.`pageTextID`=t.`id` WHERE c.`resellerID`=:reseller_id AND (t.`title` LIKE :search OR c.`commentID` LIKE :search OR c.`authorname` LIKE :search OR c.`date` LIKE :search {$statusQuery}) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array(':search' => '%' . $sSearch . '%', ':reseller_id' => $resellerLockupID));
} else {
    $query = $sql->prepare("SELECT t.`pageid`,t.`language`,t.`title`,c.`commentID`,c.`date`,c.`authorname`,c.`markedSpam`,c.`moderateAccepted` FROM `page_comments` c LEFT JOIN `page_pages_text` t ON c.`pageTextID`=t.`id` WHERE c.`resellerID`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}");
    $query->execute(array($resellerLockupID));
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    if (!isset($titleLanguages[$row['language']])) {
        $titleLanguages[$row['language']] = array('page' => getlanguagefile('page', $row['language'], 0), 'general' => getlanguagefile('general', $row['language'], 0));
    }
    $moderated = $row['moderateAccepted'] == 'N' ? $gsprache->yes : $gsprache->no;
    $spam = $row['markedSpam'] == 'Y' ? $gsprache->yes : $gsprache->no;
    $link = $seoActive == 'N' ? $page_url . '/index.php?site=news&amp;id=' . $row['pageid'] : $page_url . '/' . $row['language'] . '/' . szrp($titleLanguages[$row['language']]['general']->news) . '/' . szrp($row['title']) . '/';
    $array['aaData'][] = array('<a href="' . $link . '" target="_blank">' . $row['title'] . '</a>', $row['commentID'], $row['authorname'], $row['date'], (string) $moderated, (string) $spam, returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'pc', 'dl', $row['commentID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'pc', 'md', $row['commentID'], $gsprache->mod));
}
$query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='ds' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1");
$query3 = $sql->prepare("UPDATE `voice_dns` SET `jobPending`='N' WHERE `dnsID`=? AND `resellerID`=? LIMIT 1");
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    $jobPending = $gsprache->no;
    $status = 4;
    $statusMessage = $gsprache->status_ok;
    if ($row['jobPending'] == 'Y') {
        $query2->execute(array($row['id'], $resellerLockupID));
        while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) {
            if ($row2['action'] == 'ad') {
                $jobPending = $gsprache->add;
            } else {
                if ($row2['action'] == 'dl') {
                    $jobPending = $gsprache->del;
                } else {
                    $jobPending = $gsprache->mod;
                }
            }
            $json = @json_decode($row2['extraData']);
            $row['status'] = (is_object($json) and isset($json->newActive) and $json->newActive == 'N') ? 2 : 0;
        }
        if ($query2->rowCount() == 0) {
            $query3->execute(array($row['id'], $resellerLockupID));
        }
    }
    if ($row['active'] == 'N') {
        $status = 3;
        $statusMessage = $gsprache->status_inactive;
    }
    $array['aaData'][] = array('<a href="ts3server://' . $row['dns'] . '">' . $row['server'] . '</a>', $row['dnsID'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', $status, (string) $statusMessage), returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], $row['full_name'], $row['userID'], ''), (string) $jobPending, returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'vr', 'dl', $row['dnsID'], $gsprache->del) . ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'vr', 'md', $row['dnsID'], $gsprache->mod));
}