From f8fd3f7c7bde68e3a910823c3982e2cf88de4679 Mon Sep 17 00:00:00 2001 From: Ulrich Block Date: Sun, 14 Sep 2014 12:43:40 +0200 Subject: [PATCH] #30 new bootstrap 3 theme --- web/ajax.php | 164 ++-------------- web/stuff/admin/masterserver.php | 182 ++---------------- web/stuff/ajax/datatable_appmasterserver.php | 154 +++++++++++++++ web/stuff/ajax/datatable_appserver.php | 97 ++++++++++ web/stuff/ajax/datatable_userlog.php | 97 ++++++++++ web/stuff/ajax/stats_voicestats.php | 79 ++++++++ .../adminlte/admin/admin_master_add.tpl | 41 ++++ .../adminlte/admin/admin_master_dl.tpl | 41 ++++ .../adminlte/admin/admin_master_list.tpl | 39 ++++ .../adminlte/ajax/ajax_admin_buttons_add.tpl | 1 + .../adminlte/ajax/ajax_admin_master_list.tpl | 1 + 11 files changed, 581 insertions(+), 315 deletions(-) create mode 100644 web/stuff/ajax/datatable_appmasterserver.php create mode 100644 web/stuff/ajax/datatable_appserver.php create mode 100644 web/stuff/ajax/datatable_userlog.php create mode 100644 web/stuff/ajax/stats_voicestats.php create mode 100644 web/template/adminlte/admin/admin_master_add.tpl create mode 100644 web/template/adminlte/admin/admin_master_dl.tpl create mode 100644 web/template/adminlte/admin/admin_master_list.tpl create mode 100644 web/template/adminlte/ajax/ajax_admin_buttons_add.tpl create mode 100644 web/template/adminlte/ajax/ajax_admin_master_list.tpl diff --git a/web/ajax.php b/web/ajax.php index e217fb4e..c7934b9d 100644 --- a/web/ajax.php +++ b/web/ajax.php @@ -40,6 +40,8 @@ define('EASYWIDIR', dirname(__FILE__)); +define('AJAXINCLUDED', true); + if (is_dir(EASYWIDIR . '/install')) { die('Please remove the "install" folder'); } @@ -74,118 +76,17 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { if ($ui->smallletters('d', 7, 'get') == 'userlog' and isset($user_id) and $pa['log']) { - $sprache = getlanguagefile('logs', $user_language, $reseller_id); - $gssprache = getlanguagefile('gserver', $user_language, $reseller_id); - - $placeholders = array('%%', '%ad%', '%add%', '%dl%', '%del%', '%md%', '%mod%', '%start%', '%restart%', '%stop%', '%upd%', '%fail%', '%ok%', '%psw%', '%cfg%', '%import%', '%reinstall%', '%backup%', '%use%'); - $replace = array('', $gsprache->add, $gsprache->add, $gsprache->del, $gsprache->del, $gsprache->mod, $gsprache->mod, $gsprache->start, $gsprache->start, $gsprache->stop, $gsprache->update,'','', $gssprache->password, $gssprache->config, $gsprache->import, $gssprache->reinstall, $gsprache->backup, $gsprache->use); - $placeholders2 = array('%voserver%', '%gserver%', '%user%', '%fastdl%', '%master%', '%user%', '%root%', '%addon%', '%settings%', '%vserver%', '%ticket_subject%', '%reseller%', '%virtual%', '%eac%', '%resync%', '%virtualimage%', '%template%', '%voserver%', '%emailsettings%', '%dns%', '%tsdns%', '%pmode%', '%file%'); - $replace2 = array($gsprache->voiceserver, $gsprache->gameserver, $gsprache->user, $gsprache->fastdownload, $gsprache->master, $gsprache->user, $gsprache->root, $gsprache->addon2, $gsprache->settings, $gsprache->virtual, $gsprache->support, $gsprache->reseller, $gsprache->hostsystem,'Easy Anti Cheat', $gssprache->resync, $gsprache->virtual . ' ' . $gsprache->template, $gsprache->template, $gsprache->voiceserver,'E-Mail '.$gsprache->settings, 'TSDNS', 'TSDNS', $gssprache->protect, $gsprache->file); - - if ($sSearch) { - $sSearch = str_replace($replace, $placeholders, str_replace($replace2, $placeholders2, $sSearch)); - } - - $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userlog` WHERE `usertype`='user' AND `userid`=? AND `resellerid`=?"); - $query->execute(array($user_id, $reseller_id)); - $array['iTotalRecords'] = $query->fetchColumn(); - - if ($sSearch) { - $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype`='user' AND l.`userid`=:userid AND l.`resellerid`=:resellerid AND (`username` LIKE :search OR `cname` LIKE :search OR `ip` LIKE :search OR `logdate` LIKE :search OR `useraction` LIKE :search)"); - $query->execute(array(':search' => '%' . $sSearch . '%', ':userid' => $user_id, ':resellerid' => $reseller_id)); - $array['iTotalDisplayRecords'] = $query->fetchColumn(); - } else { - $array['iTotalDisplayRecords'] = $array['iTotalRecords']; - } - - $orderFields = array(0 => '`logdate`', 1 => array('`username`', '`cname`'), 2 => '`useraction`', 3 => '`ip`'); - - 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 `subuser`,`username`,`useraction`,`ip`,`logdate`,`cname` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype` IN ('user','cron') AND l.`userid`=:userid AND l.`resellerid`=:resellerid AND (`username` LIKE :search OR `cname` LIKE :search OR `ip` LIKE :search OR `logdate` LIKE :search OR `useraction` LIKE :search) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}"); - $query->execute(array(':search' => '%' . $sSearch . '%', ':userid' => $user_id, ':resellerid' => $reseller_id)); - } else { - $query = $sql->prepare("SELECT `subuser`,`username`,`useraction`,`ip`,`logdate`,`cname` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype` IN ('user','cron') AND l.`userid`=? AND l.`resellerid`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}"); - $query->execute(array($user_id, $reseller_id)); - } - - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - if ($row['subuser'] == 0) { - $username = $row['username']; - $ip = $row['ip']; - } else { - $username = $row['cname']; - $ip = (isanyadmin($row['subuser'])) ? 'admin' : $row['ip']; - } - - $array['aaData'][] = array($row['logdate'], $username, str_replace($placeholders2, $replace2, str_replace($placeholders, $replace, $row['useraction'])), $ip); - } + require_once(EASYWIDIR . '/stuff/ajax/datatable_userlog.php'); // App server } else if ($ui->smallletters('d', 9, 'get') =='appserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['roots']) { - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata`"); - $query->execute(); - } else { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` AS r WHERE `resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`)"); - $query->execute(array(':reseller_id' => $resellerLockupID)); - } + require_once(EASYWIDIR . '/stuff/ajax/datatable_appserver.php'); - $array['iTotalRecords'] = $query->fetchColumn(); + // App (GS + Tools) masterserver + } else if ($ui->smallletters('d', 15, 'get') =='appmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) { - if ($sSearch) { - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` WHERE `id` LIKE :search OR `ip` LIKE :search OR `description` LIKE :search"); - $query->execute(array(':search' => '%' . $sSearch . '%')); - } else { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` AS r WHERE (`resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`)) AND (`id` LIKE :search OR `ip` 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 => 'r.`ip`', 1 => 'r.`id`', 2 => 'r.`active`', 3 => 'r.`os`', 4 => '`gameserver_amount`', 5 => '`gameserver_ram`', 6 => 'r.`description`'); - - 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) { - 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['os'] == 'L') ? 'Linux' : 'Windows', (int) $row['gameserver_amount'] . '/' . (int) $row['maxserver'], (int) $row['gameserver_ram'] . '/' . (int) $row['ram'], $row['description'], 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)); - } + require_once(EASYWIDIR . '/stuff/ajax/datatable_appmasterserver.php'); // Code wise it seems odd, but this way we can get plausible userIDs for following queries up front } else { @@ -210,7 +111,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { $ipsAvailable = array(); } - require_once IncludeTemplate($template_to_use,'ajax_admin_roots_ips.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_admin_roots_ips.tpl', 'ajax'); die; @@ -239,7 +140,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { $dns = $row['defaultdns']; } - require_once IncludeTemplate($template_to_use,'ajax_admin_web_master.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_admin_web_master.tpl', 'ajax'); die; @@ -272,7 +173,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { } - require_once IncludeTemplate($template_to_use,'ajax_admin_voice_stats.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_admin_voice_stats.tpl', 'ajax'); die; @@ -288,7 +189,7 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { } } - require_once IncludeTemplate($template_to_use,'ajax_userpanel_voice_stats.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_userpanel_voice_stats.tpl', 'ajax'); die; @@ -318,48 +219,13 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { $table[$row['id']] = $topic; } - require_once IncludeTemplate($template_to_use,'ajax_userpanel_ticket_category.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_userpanel_ticket_category.tpl', 'ajax'); die; } else if (isset($user_id) and $pa['voiceserverStats'] and $ui->w('d', 14, 'get') == 'voiceUserStats') { - $usageArray = array(); - - $dateRange = ($ui->escaped('dateRange', 'get')) ? $ui->escaped('dateRange', 'get') : date('m/d/Y', strtotime("-6 days")) . ' - ' . date('m/d/Y'); - $accuracy = (in_array($ui->st('accuracy', 'get'), array('da', 'mo'))) ? $ui->st('accuracy', 'get') : 'da'; - - @list($startDate, $endDate) = explode('-', str_replace(' ', '', $dateRange)); - @list($startMonth, $startDay, $startYear) = explode('/', $startDate); - @list($endMonth, $endDay, $endYear) = explode('/', $endDate); - - if ($endYear > 2000 and $startYear > 2000) { - - $menuStart = round((strtotime("{$endYear}-{$endMonth}-{$endDay}") - strtotime("{$startYear}-{$startMonth}-{$startDay}")) / 86400); - - $extractOrNormal = ($accuracy == 'mo') ? "CONCAT(EXTRACT(YEAR FROM `date`),'-',EXTRACT(MONTH FROM `date`))" : '`date`'; - - $startDateFormatted = date('Y-m-d', strtotime($startYear . '-' . $startMonth . '-' . $startDay)); - $endDateFormatted = date('Y-m-d', strtotime($endYear . '-' . $endMonth . '-' . $endDay)); - - if ($ui->id('serverID', 10, 'get')) { - $query = $sql->prepare("SELECT $extractOrNormal AS `groupedDate`,SUM(`used`)/COUNT(`sid`) AS `averageused`,SUM(`traffic`)/1024 as `fileTrafficMB` FROM `voice_server_stats` WHERE `sid`=? AND `uid`=? AND `resellerid`=? AND `date` BETWEEN ? AND ? GROUP BY `groupedDate` ORDER BY `groupedDate`"); - $query->execute(array($ui->id('serverID', 10, 'get'), $user_id, $reseller_id, $startDateFormatted, $endDateFormatted)); - } else { - $query = $sql->prepare("SELECT $extractOrNormal AS `groupedDate`,SUM(`used`)/COUNT(`sid`) AS `averageused`,SUM(`traffic`)/1024 as `fileTrafficMB` FROM `voice_server_stats` WHERE `uid`=? AND `resellerid`=? AND `date` BETWEEN ? AND ? GROUP BY `groupedDate` ORDER BY `groupedDate`"); - $query->execute(array($user_id, $reseller_id, $startDateFormatted, $endDateFormatted)); - } - - while($row = $query->fetch(PDO::FETCH_ASSOC)) { - $usageArray[] = array('y' => $row['groupedDate'], 'slots' => ceil($row['averageused']), 'traffic' => ceil($row['fileTrafficMB'])); - } - } - - header('Cache-Control: no-cache, must-revalidate'); - header('Expires: Mon, 1 Jan 1900 00:00:00 GMT'); - header('Content-type: application/json'); - - die(json_encode($usageArray)); + require_once(EASYWIDIR . '/stuff/ajax/stats_voicestats.php'); } else if (isset($user_id) and ($pa['gserver'] or $pa['restart']) and $ui->username('mapgroup', 50, 'get')) { @@ -370,10 +236,10 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { $mapGroup = $query->fetchColumn(); if ($mapGroup != null) { - require_once IncludeTemplate($template_to_use,'ajax_userpanel_mapgroup.tpl', 'ajax'); + require_once IncludeTemplate($template_to_use, 'ajax_userpanel_mapgroup.tpl', 'ajax'); } die; } -die('No Access:'.$ui->smallletters('d', 200, 'get')); \ No newline at end of file +die('No Access:' . $ui->smallletters('d', 200, 'get')); \ No newline at end of file diff --git a/web/stuff/admin/masterserver.php b/web/stuff/admin/masterserver.php index ee1917c7..28c6dd70 100644 --- a/web/stuff/admin/masterserver.php +++ b/web/stuff/admin/masterserver.php @@ -115,25 +115,20 @@ if ($ui->w('action', 4, 'post') and !token(true)) { $table = array(); - $query = $sql->prepare("SELECT `ip`,`os` FROM `rserverdata` WHERE `active`='Y' AND `id`=? AND `resellerid`=? LIMIT 1"); + $query = $sql->prepare("SELECT `ip`,`os`,`description` FROM `rserverdata` WHERE `active`='Y' AND `id`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($id, $resellerLockupID)); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { $ip = $row['ip']; $os = $row['os']; + $description = $row['description']; } if (isset($ip) and isset($os)) { - $query = $sql->prepare("SELECT `id`,`shorten`,`steamgame`,`description` FROM `servertypes` WHERE `resellerid`=? AND (`os`='B' OR `os`=?) ORDER BY `description`"); - $query2 = $sql->prepare("SELECT r.`id` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`serverid`=? AND r.`resellerid`=? AND s.`shorten`=?"); - - $query->execute(array($resellerLockupID, $os)); + $query = $sql->prepare("SELECT `id`,`shorten`,`steamgame`,`description` FROM `servertypes` AS t WHERE `resellerid`=? AND (`os`='B' OR `os`=?) AND NOT EXISTS (SELECT 1 FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`serverid`=? AND s.`shorten`=t.`shorten`) ORDER BY `description`"); + $query->execute(array($resellerLockupID, $os, $id)); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - $query2->execute(array($id, $resellerLockupID, $row['shorten'])); - if ($query2->rowCount() < 1) { - $table[] = array('id' => $row['id'], 'shorten' => $row['shorten'], 'description' => $row['description']); - } + $table[] = array('id' => $row['id'], 'shorten' => $row['shorten'], 'description' => $row['description']); } $template_file = 'admin_master_add.tpl'; @@ -145,11 +140,11 @@ if ($ui->w('action', 4, 'post') and !token(true)) { } else if ($ui->st('d', 'get') == 'dl' and $ui->id('id',19, 'get')) { - if ($ui->smallletters('action',2, 'post') == 'dl') { + if ($ui->smallletters('action', 2, 'post') == 'dl') { - $serverid = $ui->id('id',19, 'get'); + $serverid = $ui->id('id', 19, 'get'); - $rdata = serverdata('root',$serverid,$aeskey); + $rdata = serverdata('root', $serverid, $aeskey); $sship = $rdata['ip']; if ($ui->id('id', 10, 'post')) { @@ -190,9 +185,12 @@ if ($ui->w('action', 4, 'post') and !token(true)) { $id = $ui->id('id',19, 'get'); - $query = $sql->prepare("SELECT `ip` FROM `rserverdata` WHERE `active`='Y' AND `id`=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($id,$resellerLockupID)); - $ip = $query->fetchColumn(); + $query = $sql->prepare("SELECT `ip`,`description` FROM `rserverdata` WHERE `active`='Y' AND `id`=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($id, $resellerLockupID)); + foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { + $ip = $row['ip']; + $description = $row['description']; + } $query = $sql->prepare("SELECT r.`id`,s.`shorten`,s.`description` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`serverid`=? AND r.`resellerid`=? ORDER BY `description`"); $query->execute(array($id,$resellerLockupID)); @@ -200,161 +198,14 @@ if ($ui->w('action', 4, 'post') and !token(true)) { $table[] = array('id' => $row['id'], 'shorten' => $row['shorten'], 'description' => $row['description']); } - $template_file = (count($table) > 0) ? 'admin_master_dl.tpl' : 'Error: No such ID!'; + $template_file = (isset($ip) and strlen($ip) > 0) ? 'admin_master_dl.tpl' : 'Error: No such ID!'; } } else if ($ui->st('d', 'get') == 'md') { - $table = array(); + configureDateTables('-1', '1, "asc"', 'ajax.php?w=datatable&d=appmasterserver'); - $o = $ui->st('o', 'get'); - - if ($ui->st('o', 'get') == 'ar') { - $orderby = '`resellerid` ASC'; - } else if ($ui->st('o', 'get') == 'dr') { - $orderby = '`resellerid` DESC'; - } else if ($ui->st('o', 'get') == 'ap') { - $orderby = '`ip` ASC'; - } else if ($ui->st('o', 'get') == 'dp') { - $orderby = '`ip` DESC'; - } else if ($ui->st('o', 'get') == 'as') { - $orderby = '`active` ASC'; - } else if ($ui->st('o', 'get') == 'ds') { - $orderby = '`active` DESC'; - } else if ($ui->st('o', 'get') == 'ad') { - $orderby = '`description` ASC'; - } else if ($ui->st('o', 'get') == 'dd') { - $orderby = '`description` DESC'; - } else if ($ui->st('o', 'get') == 'di') { - $orderby = '`id` DESC'; - } else { - $orderby = '`id` ASC'; - $o = 'ai'; - } - - $query = $sql->prepare("SELECT `id`,`ip`,`os`,`bitversion`,`description`,`active` FROM `rserverdata` WHERE `active`='Y' AND `resellerid`=? ORDER BY " . $orderby . " LIMIT " . $start . "," . $amount); - $query2 = $sql->prepare("SELECT s.`shorten`,r.`installing`,r.`updating`,r.`installstarted` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`serverid`=? AND r.`resellerid`=? GROUP BY s.`shorten`"); - $query3 = $sql->prepare("SELECT r.`id`,s.`steamgame`,s.`updates`,d.`updates` AS `rupdates` FROM `rservermasterg` r INNER JOIN `rserverdata` d ON r.`serverid`=d.`id` INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE s.`shorten`=? AND r.`resellerid`=? AND d.`ip`=? LIMIT 1"); - $query4 = $sql->prepare("UPDATE `rservermasterg` SET `installing`='N',`updating`='N' WHERE `id`=?"); - - $query->execute(array($resellerLockupID)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { - - $statusList = array(); - $sshcheck = array(); - - $id = $row['id']; - $description = $row['description']; - - if ($row['active'] == 'Y') { - $imgName = '16_ok'; - $imgAlt = 'Active'; - } else { - $imgName = '16_bad'; - $imgAlt = 'Inactive'; - } - - $query2->execute(array($id,$resellerLockupID)); - foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) { - - $shorten = $row2['shorten']; - - if ($row['active'] == 'N' or ($row2['installing'] == 'N' and $row2['updating'] == 'N')) { - $statusList[$row2['shorten']] = '16_ok'; - } else { - $toolong = date($row2['installstarted'], strtotime("+15 minutes")); - - if (strtotime($logdate) > strtotime($toolong) or $row2['updating'] == 'Y') { - $sshcheck[] = $row2['shorten']; - } else { - $statusList[$row2['shorten']] = '16_installing'; - } - } - } - - if (count($sshcheck) > 0) { - - $serverdata = serverdata('root', $id, $aeskey); - $ip = $serverdata['ip']; - - $check = ssh2_execute('gs', $id, './control.sh updatestatus "' . implode(' ', $sshcheck) . '"'); - - if ($check === false) { - - $description = 'The login data does not work'; - - } else if (preg_match('/^[\w\:\-\=]+$/', $check)) { - - $games = array(); - - foreach (preg_split('/\:/',$check,-1,PREG_SPLIT_NO_EMPTY) as $status) { - $ex = explode('=', $status); - if (isset($ex[1])) { - $games[$ex[0]] = $ex[1]; - } - } - - foreach ($games as $k => $v) { - - if (!in_array($k, array('steamcmd', 'sync'))) { - - $query3->execute(array($k, $resellerLockupID, $ip)); - foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row2) { - - if (($v == 0 and $row2['rupdates'] != 4 and $row2['updates'] != 4 and $row2['steamgame'] != 'S') or ($row2['steamgame'] == 'S' and (!isset($games['steamcmd']) or $games['steamcmd'] == 0)) or (($row2['rupdates'] == 4 or $row2['updates'] == 4) and (!isset($games['sync']) or $games['sync'] == 0))) { - - $statusList[$k] = '16_ok'; - - $query4->execute(array($row2['id'])); - - unset($sshcheck[array_search($k, $sshcheck)]); - } - } - } - } - } - - foreach ($sshcheck as $shorten) { - $statusList[$shorten] = '16_installing'; - } - } - - $table[] = array('id' => $row['id'], 'img' => $imgName, 'alt' => $imgAlt, 'ip' => $row['ip'], 'os' => $row['os'], 'bit' => $row['bitversion'], 'description' => $description, 'statusList' => $statusList, 'active' => $row['active']); - - } - - $next = $start + $amount; - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` WHERE `resellerid`=?"); - $query->execute(array($resellerLockupID)); - $colcount = $query->fetchColumn(); - - $vor = ($colcount > $next) ? $start + $amount : $start; - $back = $start - $amount; - $zur = ($back >= 0) ? $start - $amount : $start; - $pageamount = ceil($colcount / $amount); - - $link = '1' : '&p=0">1'; - - $pages[] = $link; - $i = 2; - - while ($i <= $pageamount) { - - $selectpage = ($i - 1) * $amount; - - if ($start == $selectpage) { - $pages[] = '' . $i . ''; - } else { - $pages[] = '' . $i . ''; - } - $i++; - } - - $pages = implode(', ',$pages); $template_file = 'admin_master_list.tpl'; } else if ($ui->st('d', 'get') == 'ud' and $ui->smallletters('action', 2, 'post') == 'ud') { @@ -369,7 +220,6 @@ if ($ui->w('action', 4, 'post') and !token(true)) { } } - if ((isset($ips))) { $query = $sql->prepare("SELECT s.`shorten` FROM `rservermasterg` r LEFT JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE s.`description`=? AND r.`serverid`=? AND r.`installing`='N' AND r.`resellerid`=?"); diff --git a/web/stuff/ajax/datatable_appmasterserver.php b/web/stuff/ajax/datatable_appmasterserver.php new file mode 100644 index 00000000..2a638a24 --- /dev/null +++ b/web/stuff/ajax/datatable_appmasterserver.php @@ -0,0 +1,154 @@ + + * + * This file is part of Easy-WI. + * + * Easy-WI is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy-WI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy-WI. If not, see . + * + * Diese Datei ist Teil von Easy-WI. + * + * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen + * der GNU General Public License, wie von der Free Software Foundation, + * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren + * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. + * + * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber + * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite + * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. + * Siehe die GNU General Public License fuer weitere Details. + * + * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem + * Programm erhalten haben. Wenn nicht, siehe . + */ + +if (!defined('AJAXINCLUDED')) { + die('Do not access directly!'); +} + +$query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` WHERE `resellerid`=?"); +$query->execute(array($resellerLockupID)); +$array['iTotalRecords'] = $query->fetchColumn(); + +if ($sSearch) { + + $query = $sql->prepare("SELECT COUNT(r.`id`) AS `amount` FROM `rserverdata` AS r WHERE r.`active`='Y' AND r.`resellerid`=:resellerID AND (r.`id` LIKE :search OR r.`ip` LIKE :search OR r.`description` LIKE :search OR EXISTS(SELECT 1 FROM `rservermasterg` AS m INNER JOIN `servertypes` s ON s.`id`=m.`servertypeid` WHERE m.`serverid`=r.`id` AND s.`shorten` LIKE :search))"); + $query->execute(array(':resellerID' => $resellerLockupID, ':search' => '%' . $sSearch . '%')); + $array['iTotalDisplayRecords'] = $query->fetchColumn(); + +} else { + $array['iTotalDisplayRecords'] = $array['iTotalRecords']; +} + +$orderFields = array(0 => '`ip`', 1 => '`id`', 2 => '`description`'); + +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'; +} + +$query2 = $sql->prepare("SELECT s.`shorten`,r.`installing`,r.`updating`,r.`installstarted` FROM `rservermasterg` r INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE r.`serverid`=? AND r.`resellerid`=? GROUP BY s.`shorten`"); +$query3 = $sql->prepare("SELECT r.`id`,s.`steamgame`,s.`updates`,d.`updates` AS `rupdates` FROM `rservermasterg` r INNER JOIN `rserverdata` d ON r.`serverid`=d.`id` INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE s.`shorten`=? AND r.`resellerid`=? AND d.`ip`=? LIMIT 1"); +$query4 = $sql->prepare("UPDATE `rservermasterg` SET `installing`='N',`updating`='N' WHERE `id`=? LIMIT 1"); + +if ($sSearch) { + $query = $sql->prepare("SELECT `id`,`ip`,`description` FROM `rserverdata` AS r WHERE `active`='Y' AND `resellerid`=:resellerID AND (`id` LIKE :search OR `ip` LIKE :search OR `description` LIKE :search OR EXISTS(SELECT 1 FROM `rservermasterg` AS m INNER JOIN `servertypes` s ON s.`id`=m.`servertypeid` WHERE m.`serverid`=r.`id` AND s.`shorten` LIKE :search)) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array(':resellerID' => $resellerLockupID, ':search' => '%' . $sSearch . '%')); +} else { + $query = $sql->prepare("SELECT `id`,`ip`,`description` FROM `rserverdata` WHERE `active`='Y' AND `resellerid`=? ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array($resellerLockupID)); +} + +while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + $statusList = array(); + $sshcheck = array(); + + $description = $row['description']; + + $query2->execute(array($row['id'], $resellerLockupID)); + foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row2) { + + $shorten = $row2['shorten']; + + if ($row2['installing'] == 'N' and $row2['updating'] == 'N') { + $statusList[$row2['shorten']] = true; + } else { + + $toolong = date($row2['installstarted'], strtotime("+15 minutes")); + + if (strtotime($logdate) > strtotime($toolong) or $row2['updating'] == 'Y') { + $sshcheck[] = $row2['shorten']; + } else { + $statusList[$row2['shorten']] = false; + } + } + } + + if (count($sshcheck) > 0) { + + $serverdata = serverdata('root', $row['id'], $aeskey); + $ip = $serverdata['ip']; + + $check = ssh2_execute('gs', $row['id'], './control.sh updatestatus "' . implode(' ', $sshcheck) . '"'); + + if ($check === false) { + + $description = 'The login data does not work'; + + } else if (preg_match('/^[\w\:\-\=]+$/', $check)) { + + $games = array(); + + foreach (preg_split('/\:/',$check,-1,PREG_SPLIT_NO_EMPTY) as $status) { + $ex = explode('=', $status); + if (isset($ex[1])) { + $games[$ex[0]] = $ex[1]; + } + } + + foreach ($games as $k => $v) { + + if (!in_array($k, array('steamcmd', 'sync'))) { + + $query3->execute(array($k, $resellerLockupID, $ip)); + foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row2) { + + if (($v == 0 and $row2['rupdates'] != 4 and $row2['updates'] != 4 and $row2['steamgame'] != 'S') or ($row2['steamgame'] == 'S' and (!isset($games['steamcmd']) or $games['steamcmd'] == 0)) or (($row2['rupdates'] == 4 or $row2['updates'] == 4) and (!isset($games['sync']) or $games['sync'] == 0))) { + + $statusList[$k] = true; + + $query4->execute(array($row2['id'])); + + unset($sshcheck[array_search($k, $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)); +} \ No newline at end of file diff --git a/web/stuff/ajax/datatable_appserver.php b/web/stuff/ajax/datatable_appserver.php new file mode 100644 index 00000000..32772897 --- /dev/null +++ b/web/stuff/ajax/datatable_appserver.php @@ -0,0 +1,97 @@ + + * + * This file is part of Easy-WI. + * + * Easy-WI is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy-WI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy-WI. If not, see . + * + * Diese Datei ist Teil von Easy-WI. + * + * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen + * der GNU General Public License, wie von der Free Software Foundation, + * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren + * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. + * + * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber + * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite + * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. + * Siehe die GNU General Public License fuer weitere Details. + * + * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem + * Programm erhalten haben. Wenn nicht, siehe . + */ + +if (!defined('AJAXINCLUDED')) { + die('Do not access directly!'); +} + +if ($reseller_id == 0) { + $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata`"); + $query->execute(); +} else { + $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` AS r WHERE `resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`)"); + $query->execute(array(':reseller_id' => $resellerLockupID)); +} + +$array['iTotalRecords'] = $query->fetchColumn(); + +if ($sSearch) { + if ($reseller_id == 0) { + $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` WHERE `id` LIKE :search OR `ip` LIKE :search OR `description` LIKE :search"); + $query->execute(array(':search' => '%' . $sSearch . '%')); + } else { + $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `rserverdata` AS r WHERE (`resellerid`=:reseller_id OR EXISTS (SELECT 1 FROM `userdata` WHERE `resellerid`=:reseller_id AND `id`=r.`resellerid`)) AND (`id` LIKE :search OR `ip` 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 => 'r.`ip`', 1 => 'r.`id`', 2 => 'r.`active`', 3 => 'r.`os`', 4 => '`gameserver_amount`', 5 => '`gameserver_ram`', 6 => 'r.`description`'); + +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) { + 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['os'] == 'L') ? 'Linux' : 'Windows', (int) $row['gameserver_amount'] . '/' . (int) $row['maxserver'], (int) $row['gameserver_ram'] . '/' . (int) $row['ram'], $row['description'], 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)); +} \ No newline at end of file diff --git a/web/stuff/ajax/datatable_userlog.php b/web/stuff/ajax/datatable_userlog.php new file mode 100644 index 00000000..9e119137 --- /dev/null +++ b/web/stuff/ajax/datatable_userlog.php @@ -0,0 +1,97 @@ + + * + * This file is part of Easy-WI. + * + * Easy-WI is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy-WI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy-WI. If not, see . + * + * Diese Datei ist Teil von Easy-WI. + * + * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen + * der GNU General Public License, wie von der Free Software Foundation, + * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren + * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. + * + * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber + * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite + * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. + * Siehe die GNU General Public License fuer weitere Details. + * + * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem + * Programm erhalten haben. Wenn nicht, siehe . + */ + +if (!defined('AJAXINCLUDED')) { + die('Do not access directly!'); +} + +$sprache = getlanguagefile('logs', $user_language, $reseller_id); +$gssprache = getlanguagefile('gserver', $user_language, $reseller_id); + +$placeholders = array('%%', '%ad%', '%add%', '%dl%', '%del%', '%md%', '%mod%', '%start%', '%restart%', '%stop%', '%upd%', '%fail%', '%ok%', '%psw%', '%cfg%', '%import%', '%reinstall%', '%backup%', '%use%'); +$replace = array('', $gsprache->add, $gsprache->add, $gsprache->del, $gsprache->del, $gsprache->mod, $gsprache->mod, $gsprache->start, $gsprache->start, $gsprache->stop, $gsprache->update,'','', $gssprache->password, $gssprache->config, $gsprache->import, $gssprache->reinstall, $gsprache->backup, $gsprache->use); +$placeholders2 = array('%voserver%', '%gserver%', '%user%', '%fastdl%', '%master%', '%user%', '%root%', '%addon%', '%settings%', '%vserver%', '%ticket_subject%', '%reseller%', '%virtual%', '%eac%', '%resync%', '%virtualimage%', '%template%', '%voserver%', '%emailsettings%', '%dns%', '%tsdns%', '%pmode%', '%file%'); +$replace2 = array($gsprache->voiceserver, $gsprache->gameserver, $gsprache->user, $gsprache->fastdownload, $gsprache->master, $gsprache->user, $gsprache->root, $gsprache->addon2, $gsprache->settings, $gsprache->virtual, $gsprache->support, $gsprache->reseller, $gsprache->hostsystem,'Easy Anti Cheat', $gssprache->resync, $gsprache->virtual . ' ' . $gsprache->template, $gsprache->template, $gsprache->voiceserver,'E-Mail '.$gsprache->settings, 'TSDNS', 'TSDNS', $gssprache->protect, $gsprache->file); + +if ($sSearch) { + $sSearch = str_replace($replace, $placeholders, str_replace($replace2, $placeholders2, $sSearch)); +} + +$query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userlog` WHERE `usertype`='user' AND `userid`=? AND `resellerid`=?"); +$query->execute(array($user_id, $reseller_id)); +$array['iTotalRecords'] = $query->fetchColumn(); + +if ($sSearch) { + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype`='user' AND l.`userid`=:userid AND l.`resellerid`=:resellerid AND (`username` LIKE :search OR `cname` LIKE :search OR `ip` LIKE :search OR `logdate` LIKE :search OR `useraction` LIKE :search)"); + $query->execute(array(':search' => '%' . $sSearch . '%', ':userid' => $user_id, ':resellerid' => $reseller_id)); + $array['iTotalDisplayRecords'] = $query->fetchColumn(); +} else { + $array['iTotalDisplayRecords'] = $array['iTotalRecords']; +} + +$orderFields = array(0 => '`logdate`', 1 => array('`username`', '`cname`'), 2 => '`useraction`', 3 => '`ip`'); + +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 `subuser`,`username`,`useraction`,`ip`,`logdate`,`cname` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype` IN ('user','cron') AND l.`userid`=:userid AND l.`resellerid`=:resellerid AND (`username` LIKE :search OR `cname` LIKE :search OR `ip` LIKE :search OR `logdate` LIKE :search OR `useraction` LIKE :search) ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array(':search' => '%' . $sSearch . '%', ':userid' => $user_id, ':resellerid' => $reseller_id)); +} else { + $query = $sql->prepare("SELECT `subuser`,`username`,`useraction`,`ip`,`logdate`,`cname` FROM `userlog` AS l LEFT JOIN `userdata` AS s ON s.`id`=l.`subuser` AND l.`subuser`!=0 WHERE l.`usertype` IN ('user','cron') AND l.`userid`=? AND l.`resellerid`=? ORDER BY {$orderBy} LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array($user_id, $reseller_id)); +} + +foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { + + if ($row['subuser'] == 0) { + $username = $row['username']; + $ip = $row['ip']; + } else { + $username = $row['cname']; + $ip = (isanyadmin($row['subuser'])) ? 'admin' : $row['ip']; + } + + $array['aaData'][] = array($row['logdate'], $username, str_replace($placeholders2, $replace2, str_replace($placeholders, $replace, $row['useraction'])), $ip); +} \ No newline at end of file diff --git a/web/stuff/ajax/stats_voicestats.php b/web/stuff/ajax/stats_voicestats.php new file mode 100644 index 00000000..68b9f485 --- /dev/null +++ b/web/stuff/ajax/stats_voicestats.php @@ -0,0 +1,79 @@ + + * + * This file is part of Easy-WI. + * + * Easy-WI is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy-WI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy-WI. If not, see . + * + * Diese Datei ist Teil von Easy-WI. + * + * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen + * der GNU General Public License, wie von der Free Software Foundation, + * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren + * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. + * + * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber + * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite + * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. + * Siehe die GNU General Public License fuer weitere Details. + * + * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem + * Programm erhalten haben. Wenn nicht, siehe . + */ + +if (!defined('AJAXINCLUDED')) { + die('Do not access directly!'); +} + +$usageArray = array(); + +$dateRange = ($ui->escaped('dateRange', 'get')) ? $ui->escaped('dateRange', 'get') : date('m/d/Y', strtotime("-6 days")) . ' - ' . date('m/d/Y'); +$accuracy = (in_array($ui->st('accuracy', 'get'), array('da', 'mo'))) ? $ui->st('accuracy', 'get') : 'da'; + +@list($startDate, $endDate) = explode('-', str_replace(' ', '', $dateRange)); +@list($startMonth, $startDay, $startYear) = explode('/', $startDate); +@list($endMonth, $endDay, $endYear) = explode('/', $endDate); + +if ($endYear > 2000 and $startYear > 2000) { + + $menuStart = round((strtotime("{$endYear}-{$endMonth}-{$endDay}") - strtotime("{$startYear}-{$startMonth}-{$startDay}")) / 86400); + + $extractOrNormal = ($accuracy == 'mo') ? "CONCAT(EXTRACT(YEAR FROM `date`),'-',EXTRACT(MONTH FROM `date`))" : '`date`'; + + $startDateFormatted = date('Y-m-d', strtotime($startYear . '-' . $startMonth . '-' . $startDay)); + $endDateFormatted = date('Y-m-d', strtotime($endYear . '-' . $endMonth . '-' . $endDay)); + + if ($ui->id('serverID', 10, 'get')) { + $query = $sql->prepare("SELECT $extractOrNormal AS `groupedDate`,SUM(`used`)/COUNT(`sid`) AS `averageused`,SUM(`traffic`)/1024 as `fileTrafficMB` FROM `voice_server_stats` WHERE `sid`=? AND `uid`=? AND `resellerid`=? AND `date` BETWEEN ? AND ? GROUP BY `groupedDate` ORDER BY `groupedDate`"); + $query->execute(array($ui->id('serverID', 10, 'get'), $user_id, $reseller_id, $startDateFormatted, $endDateFormatted)); + } else { + $query = $sql->prepare("SELECT $extractOrNormal AS `groupedDate`,SUM(`used`)/COUNT(`sid`) AS `averageused`,SUM(`traffic`)/1024 as `fileTrafficMB` FROM `voice_server_stats` WHERE `uid`=? AND `resellerid`=? AND `date` BETWEEN ? AND ? GROUP BY `groupedDate` ORDER BY `groupedDate`"); + $query->execute(array($user_id, $reseller_id, $startDateFormatted, $endDateFormatted)); + } + + while($row = $query->fetch(PDO::FETCH_ASSOC)) { + $usageArray[] = array('y' => $row['groupedDate'], 'slots' => ceil($row['averageused']), 'traffic' => ceil($row['fileTrafficMB'])); + } +} + +header('Cache-Control: no-cache, must-revalidate'); +header('Expires: Mon, 1 Jan 1900 00:00:00 GMT'); +header('Content-type: application/json'); + +die(json_encode($usageArray)); \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_master_add.tpl b/web/template/adminlte/admin/admin_master_add.tpl new file mode 100644 index 00000000..ce1d5d28 --- /dev/null +++ b/web/template/adminlte/admin/admin_master_add.tpl @@ -0,0 +1,41 @@ +
+

appRoot;?>

+ +
+ +
+
+
+
+ +
+ + + + +
+

+
+ +
+ +
+ + +
+ +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/web/template/adminlte/admin/admin_master_dl.tpl b/web/template/adminlte/admin/admin_master_dl.tpl new file mode 100644 index 00000000..2a864556 --- /dev/null +++ b/web/template/adminlte/admin/admin_master_dl.tpl @@ -0,0 +1,41 @@ +
+

appRoot;?>

+ +
+ +
+
+
+
+ +
+ + + + +
+

+
+ +
+ +
+ + +
+ +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/web/template/adminlte/admin/admin_master_list.tpl b/web/template/adminlte/admin/admin_master_list.tpl new file mode 100644 index 00000000..1cc3d11e --- /dev/null +++ b/web/template/adminlte/admin/admin_master_list.tpl @@ -0,0 +1,39 @@ +
+

appRoot;?>

+ +
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + +
haupt_ip;?>IDdesc;?>master;?>action;?>
haupt_ip;?>IDdesc;?>master;?>action;?>
+
+
+
+
+
\ No newline at end of file diff --git a/web/template/adminlte/ajax/ajax_admin_buttons_add.tpl b/web/template/adminlte/ajax/ajax_admin_buttons_add.tpl new file mode 100644 index 00000000..3f8585c6 --- /dev/null +++ b/web/template/adminlte/ajax/ajax_admin_buttons_add.tpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/template/adminlte/ajax/ajax_admin_master_list.tpl b/web/template/adminlte/ajax/ajax_admin_master_list.tpl new file mode 100644 index 00000000..ac31ed19 --- /dev/null +++ b/web/template/adminlte/ajax/ajax_admin_master_list.tpl @@ -0,0 +1 @@ +$v){ echo ($v==false) ? ''.$k.' ' : ''.$k.' '; };?> \ No newline at end of file