mirror of
https://github.com/Froxlor/Froxlor.git
synced 2024-09-21 10:27:29 +00:00
implement [ApiModule].listing() in frontend-module as sorting/limiting/searching is now possible via API call (partly untested)
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
parent
1955b5dd32
commit
d937029bf7
@ -43,67 +43,71 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
|
||||
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'deactivated' => $lng['admin']['deactivated']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_ADMINS, $fields);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Admins::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Admins::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$admins = '';
|
||||
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_ADMINS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
$numrows_admins = Database::num_rows();
|
||||
$paging->setEntries($numrows_admins);
|
||||
$sortcode = $paging->getHtmlSortCode($lng, true);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
$dec_places = Settings::Get('panel.decimal_places');
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
||||
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
||||
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
||||
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||
|
||||
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
||||
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
||||
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
||||
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||
|
||||
// percent-values for progressbar
|
||||
// For Disk usage
|
||||
if ($row['diskspace'] > 0) {
|
||||
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||
} else {
|
||||
$disk_percent = 0;
|
||||
$disk_doublepercent = 0;
|
||||
}
|
||||
// For Traffic usage
|
||||
if ($row['traffic'] > 0) {
|
||||
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
|
||||
$traffic_doublepercent = round($traffic_percent * 2, 2);
|
||||
} else {
|
||||
$traffic_percent = 0;
|
||||
$traffic_doublepercent = 0;
|
||||
}
|
||||
|
||||
// fix progress-bars if value is >100%
|
||||
if ($disk_percent > 100) {
|
||||
$disk_percent = 100;
|
||||
}
|
||||
if ($traffic_percent > 100) {
|
||||
$traffic_percent = 100;
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
|
||||
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
|
||||
|
||||
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";");
|
||||
$count ++;
|
||||
// percent-values for progressbar
|
||||
// For Disk usage
|
||||
if ($row['diskspace'] > 0) {
|
||||
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||
} else {
|
||||
$disk_percent = 0;
|
||||
$disk_doublepercent = 0;
|
||||
}
|
||||
$i ++;
|
||||
// For Traffic usage
|
||||
if ($row['traffic'] > 0) {
|
||||
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
|
||||
$traffic_doublepercent = round($traffic_percent * 2, 2);
|
||||
} else {
|
||||
$traffic_percent = 0;
|
||||
$traffic_doublepercent = 0;
|
||||
}
|
||||
|
||||
// fix progress-bars if value is >100%
|
||||
if ($disk_percent > 100) {
|
||||
$disk_percent = 100;
|
||||
}
|
||||
if ($traffic_percent > 100) {
|
||||
$traffic_percent = 100;
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
|
||||
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
|
||||
|
||||
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$admincount = $numrows_admins;
|
||||
$admincount = $paging->getEntries();
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
|
||||
} elseif ($action == 'su') {
|
||||
|
||||
|
@ -17,8 +17,7 @@
|
||||
define('AREA', 'admin');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Api\Commands\Cronjobs as Cronjobs;
|
||||
use Froxlor\Api\Commands\Cronjobs;
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
@ -31,45 +30,47 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed admin_cronjobs');
|
||||
|
||||
$fields = array(
|
||||
'c.module' => 'Module',
|
||||
'c.lastrun' => $lng['cron']['lastrun'],
|
||||
'c.interval' => $lng['cron']['interval'],
|
||||
'c.isactive' => $lng['cron']['isactive']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_CRONRUNS, $fields);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Cronjobs::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Cronjobs::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$crons = '';
|
||||
$result_stmt = Database::prepare("SELECT `c`.* FROM `" . TABLE_PANEL_CRONRUNS . "` `c` ORDER BY `module` ASC, `cronfile` ASC");
|
||||
Database::pexecute($result_stmt);
|
||||
$paging->setEntries(Database::num_rows());
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$cmod = '';
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
if ($cmod != $row['module']) {
|
||||
$_mod = explode("/", $row['module']);
|
||||
$module = ucfirst($_mod[1]);
|
||||
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjobmodule') . "\";");
|
||||
$cmod = $row['module'];
|
||||
}
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
|
||||
$row['isactive'] = ((int) $row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
$description = $lng['crondesc'][$row['desc_lng_key']];
|
||||
|
||||
$row['lastrun'] = date('d.m.Y H:i', $row['lastrun']);
|
||||
$row['isactive'] = ((int) $row['isactive'] == 1) ? $lng['panel']['yes'] : $lng['panel']['no'];
|
||||
|
||||
$description = $lng['crondesc'][$row['desc_lng_key']];
|
||||
|
||||
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjob') . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$i ++;
|
||||
eval("\$crons.=\"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs_cronjob') . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjobs') . "\";");
|
||||
|
@ -35,6 +35,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
||||
unset($_SESSION['requestData']);
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
|
||||
|
||||
$fields = array(
|
||||
'c.loginname' => $lng['login']['username'],
|
||||
'a.loginname' => $lng['admin']['admin'],
|
||||
@ -47,112 +48,109 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
||||
'c.traffic' => $lng['customer']['traffic'],
|
||||
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
|
||||
);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Customers::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Customers::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_CUSTOMERS, $fields);
|
||||
$customers = '';
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `c`.*, `a`.`loginname` AS `adminname`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` `c`, `" . TABLE_PANEL_ADMINS . "` `a`
|
||||
WHERE " . ($userinfo['customers_see_all'] ? '' : " `c`.`adminid` = :adminid AND ") . "
|
||||
`c`.`adminid` = `a`.`adminid` " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
'adminid' => $userinfo['adminid']
|
||||
));
|
||||
$num_rows = Database::num_rows();
|
||||
$paging->setEntries($num_rows);
|
||||
$sortcode = $paging->getHtmlSortCode($lng, true);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$domains_stmt = Database::prepare("
|
||||
SELECT COUNT(`id`) AS `domains`
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `customerid` = :cid
|
||||
AND `parentdomainid` = '0'
|
||||
AND `id`<> :stdd
|
||||
");
|
||||
Database::pexecute($domains_stmt, array(
|
||||
'cid' => $row['customerid'],
|
||||
'stdd' => $row['standardsubdomain']
|
||||
));
|
||||
$domains = $domains_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$row['domains'] = intval($domains['domains']);
|
||||
$dec_places = Settings::Get('panel.decimal_places');
|
||||
|
||||
$domains_stmt = Database::prepare("
|
||||
SELECT COUNT(`id`) AS `domains`
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `customerid` = :cid
|
||||
AND `parentdomainid` = '0'
|
||||
AND `id`<> :stdd");
|
||||
Database::pexecute($domains_stmt, array(
|
||||
'cid' => $row['customerid'],
|
||||
'stdd' => $row['standardsubdomain']
|
||||
));
|
||||
$domains = $domains_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$row['domains'] = intval($domains['domains']);
|
||||
$dec_places = Settings::Get('panel.decimal_places');
|
||||
// get disk-space usages for web, mysql and mail
|
||||
$usages_stmt = Database::prepare("
|
||||
SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "`
|
||||
WHERE `customerid` = :cid
|
||||
ORDER BY `stamp` DESC LIMIT 1
|
||||
");
|
||||
$usages = Database::pexecute_first($usages_stmt, array(
|
||||
'cid' => $row['customerid']
|
||||
));
|
||||
|
||||
// get disk-space usages for web, mysql and mail
|
||||
$usages_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DISKSPACE . "` WHERE `customerid` = :cid ORDER BY `stamp` DESC LIMIT 1");
|
||||
$usages = Database::pexecute_first($usages_stmt, array(
|
||||
'cid' => $row['customerid']
|
||||
));
|
||||
if ($usages) {
|
||||
$row['webspace_used'] = round($usages['webspace'] / 1024, $dec_places);
|
||||
$row['mailspace_used'] = round($usages['mail'] / 1024, $dec_places);
|
||||
$row['dbspace_used'] = round($usages['mysql'] / 1024, $dec_places);
|
||||
} else {
|
||||
$row['webspace_used'] = 0;
|
||||
$row['mailspace_used'] = 0;
|
||||
$row['dbspace_used'] = 0;
|
||||
}
|
||||
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
||||
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
||||
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
||||
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||
$last_login = ((int) $row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
|
||||
|
||||
if ($usages)
|
||||
{
|
||||
$row['webspace_used'] = round($usages['webspace'] / 1024, $dec_places);
|
||||
$row['mailspace_used'] = round($usages['mail'] / 1024, $dec_places);
|
||||
$row['dbspace_used'] = round($usages['mysql'] / 1024, $dec_places);
|
||||
} else {
|
||||
$row['webspace_used'] = 0;
|
||||
$row['mailspace_used'] = 0;
|
||||
$row['dbspace_used'] = 0;
|
||||
}
|
||||
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
|
||||
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
|
||||
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
|
||||
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
|
||||
$last_login = ((int) $row['lastlogin_succ'] == 0) ? $lng['panel']['neverloggedin'] : date('d.m.Y', $row['lastlogin_succ']);
|
||||
|
||||
/**
|
||||
* percent-values for progressbar
|
||||
*/
|
||||
// For Disk usage
|
||||
if ($row['diskspace'] > 0) {
|
||||
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||
} else {
|
||||
$disk_percent = 0;
|
||||
$disk_doublepercent = 0;
|
||||
}
|
||||
|
||||
if ($row['traffic'] > 0) {
|
||||
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
|
||||
$traffic_doublepercent = round($traffic_percent * 2, 2);
|
||||
} else {
|
||||
$traffic_percent = 0;
|
||||
$traffic_doublepercent = 0;
|
||||
}
|
||||
|
||||
$islocked = 0;
|
||||
if ($row['loginfail_count'] >= Settings::Get('login.maxloginattempts') && $row['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))) {
|
||||
$islocked = 1;
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'diskspace traffic mysqls emails email_accounts email_forwarders ftps subdomains');
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
|
||||
// fix progress-bars if value is >100%
|
||||
if ($disk_percent > 100) {
|
||||
$disk_percent = 100;
|
||||
}
|
||||
if ($traffic_percent > 100) {
|
||||
$traffic_percent = 100;
|
||||
}
|
||||
|
||||
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
|
||||
|
||||
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("customers/customers_customer") . "\";");
|
||||
$count ++;
|
||||
/**
|
||||
* percent-values for progressbar
|
||||
*/
|
||||
if ($row['diskspace'] > 0) {
|
||||
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
|
||||
$disk_doublepercent = round($disk_percent * 2, 2);
|
||||
} else {
|
||||
$disk_percent = 0;
|
||||
$disk_doublepercent = 0;
|
||||
}
|
||||
if ($row['traffic'] > 0) {
|
||||
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
|
||||
$traffic_doublepercent = round($traffic_percent * 2, 2);
|
||||
} else {
|
||||
$traffic_percent = 0;
|
||||
$traffic_doublepercent = 0;
|
||||
}
|
||||
|
||||
$i ++;
|
||||
$islocked = 0;
|
||||
if ($row['loginfail_count'] >= Settings::Get('login.maxloginattempts') && $row['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))) {
|
||||
$islocked = 1;
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'diskspace traffic mysqls emails email_accounts email_forwarders ftps subdomains');
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
|
||||
// fix progress-bars if value is >100%
|
||||
if ($disk_percent > 100) {
|
||||
$disk_percent = 100;
|
||||
}
|
||||
if ($traffic_percent > 100) {
|
||||
$traffic_percent = 100;
|
||||
}
|
||||
|
||||
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
|
||||
|
||||
eval("\$customers.=\"" . \Froxlor\UI\Template::getTemplate("customers/customers_customer") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$customercount = $num_rows;
|
||||
$customercount = $paging->getEntries();
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("customers/customers") . "\";");
|
||||
} elseif ($action == 'su' && $id != 0) {
|
||||
try {
|
||||
|
@ -21,6 +21,7 @@ require './lib/init.php';
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\Customers as Customers;
|
||||
use Froxlor\Api\Commands\Domains as Domains;
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
@ -31,14 +32,8 @@ if (isset($_POST['id'])) {
|
||||
|
||||
if ($page == 'domains' || $page == 'overview') {
|
||||
// Let's see how many customers we have
|
||||
$stmt = Database::prepare("
|
||||
SELECT COUNT(`customerid`) as `countcustomers` FROM `" . TABLE_PANEL_CUSTOMERS . "` " . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid"));
|
||||
$params = array();
|
||||
if ($userinfo['customers_see_all'] == '0') {
|
||||
$params['adminid'] = $userinfo['adminid'];
|
||||
}
|
||||
$countcustomers = Database::pexecute_first($stmt, $params);
|
||||
$countcustomers = (int) $countcustomers['countcustomers'];
|
||||
$json_result = Customers::getLocal($userinfo)->listingCount();
|
||||
$countcustomers = json_decode($json_result, true)['data'];
|
||||
|
||||
if ($action == '') {
|
||||
|
||||
@ -51,28 +46,27 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
'c.loginname' => $lng['login']['username'],
|
||||
'd.aliasdomain' => $lng['domains']['aliasdomain']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_DOMAINS, $fields);
|
||||
$domains = "";
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `d`.*, `c`.`loginname`, `c`.`deactivated`, `c`.`name`, `c`.`firstname`, `c`.`company`, `c`.`standardsubdomain`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`
|
||||
FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
||||
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`)
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id`
|
||||
WHERE `d`.`parentdomainid`='0' " . ($userinfo['customers_see_all'] ? '' : " AND `d`.`adminid` = :adminid ") . " " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
$params = array();
|
||||
if ($userinfo['customers_see_all'] == '0') {
|
||||
$params['adminid'] = $userinfo['adminid'];
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Domains::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Domains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
Database::pexecute($result_stmt, $params);
|
||||
$numrows_domains = Database::num_rows();
|
||||
$paging->setEntries($numrows_domains);
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$domains = '';
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$domain_array = array();
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
|
||||
formatDomainEntry($row, $idna_convert);
|
||||
|
||||
@ -100,11 +94,10 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
krsort($domain_array);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
foreach ($domain_array as $row) {
|
||||
|
||||
if (isset($row['domain']) && $row['domain'] != '' && $paging->checkDisplay($i)) {
|
||||
if (isset($row['domain']) && $row['domain'] != '') {
|
||||
$row['customername'] = \Froxlor\User::getCorrectFullUserDetails($row);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
// display a nice list of IP's
|
||||
@ -112,10 +105,9 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
|
||||
$domainscount = $numrows_domains;
|
||||
$domainscount = $paging->getEntries();
|
||||
|
||||
// Display the list
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
|
||||
|
@ -19,9 +19,8 @@
|
||||
define('AREA', 'admin');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\IpsAndPorts as IpsAndPorts;
|
||||
use Froxlor\Api\Commands\IpsAndPorts;
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
@ -43,29 +42,33 @@ if ($page == 'ipsandports' || $page == 'overview') {
|
||||
'ip' => $lng['admin']['ipsandports']['ip'],
|
||||
'port' => $lng['admin']['ipsandports']['port']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_IPSANDPORTS, $fields);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = IpsAndPorts::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = IpsAndPorts::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$ipsandports = '';
|
||||
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt);
|
||||
$paging->setEntries(Database::num_rows());
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$row['ip'] = '[' . $row['ip'] . ']';
|
||||
}
|
||||
eval("\$ipsandports.=\"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_ipandport") . "\";");
|
||||
$count ++;
|
||||
foreach ($result['list'] as $row) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
if (filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||
$row['ip'] = '[' . $row['ip'] . ']';
|
||||
}
|
||||
$i ++;
|
||||
eval("\$ipsandports.=\"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports_ipandport") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("ipsandports/ipsandports") . "\";");
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
define('AREA', 'admin');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Api\Commands\SysLog;
|
||||
|
||||
if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
||||
if ($action == '') {
|
||||
@ -29,20 +29,25 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
||||
'user' => $lng['logger']['user'],
|
||||
'text' => $lng['logger']['action']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_LOG, $fields, null, null, 0, 'desc', 30);
|
||||
$query = 'SELECT * FROM `' . TABLE_PANEL_LOG . '` ' . $paging->getSqlWhere(false) . ' ' . $paging->getSqlOrderBy();
|
||||
$result_stmt = Database::query($query . ' ' . $paging->getSqlLimit());
|
||||
$result_cnt_stmt = Database::query($query);
|
||||
$logs_count = $result_cnt_stmt->rowCount();
|
||||
$paging->setEntries($logs_count);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = SysLog::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$clog = array();
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
foreach ($result['list'] as $row) {
|
||||
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
|
||||
$clog[$row['action']] = array();
|
||||
}
|
||||
@ -55,7 +60,6 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
||||
ksort($clog);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$log_count = 0;
|
||||
$log = '';
|
||||
@ -100,23 +104,20 @@ if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
|
||||
$count ++;
|
||||
$_action = $action;
|
||||
// }
|
||||
$i ++;
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
|
||||
} elseif ($action == 'truncate') {
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$truncatedate = time() - (60 * 10);
|
||||
$trunc_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_LOG . "` WHERE `date` < :trunc");
|
||||
Database::pexecute($trunc_stmt, array(
|
||||
'trunc' => $truncatedate
|
||||
));
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_WARNING, 'truncated the system-log (mysql)');
|
||||
try {
|
||||
SysLog::getLocal($userinfo, array(
|
||||
'min_to_keep' => 10
|
||||
))->delete();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
\Froxlor\UI\Response::redirectTo($filename, array(
|
||||
'page' => $page,
|
||||
's' => $s
|
||||
|
@ -52,7 +52,7 @@ if ($page == 'overview') {
|
||||
$domains = "";
|
||||
$subdomains_count = count($row['subdomains']);
|
||||
foreach ($row['domains'] as $configdomain) {
|
||||
$domains .= $configdomain . "<br>";
|
||||
$domains .= $idna_convert->decode($configdomain) . "<br>";
|
||||
}
|
||||
$count ++;
|
||||
if ($subdomains_count == 0 && empty($domains)) {
|
||||
|
@ -38,33 +38,31 @@ if ($page == '' || $page == 'overview') {
|
||||
'adminname' => $lng['admin']['admin'],
|
||||
'p.ts' => $lng['admin']['plans']['last_update']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_PLANS, $fields);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = HostingPlans::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = HostingPlans::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$plans = '';
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT p.*, a.loginname as adminname
|
||||
FROM `" . TABLE_PANEL_PLANS . "` p, `" . TABLE_PANEL_ADMINS . "` a
|
||||
WHERE " . ($userinfo['customers_see_all'] ? '' : " `p`.`adminid` = :adminid AND ") . "
|
||||
`p`.`adminid` = `a`.`adminid` " . $paging->getSqlWhere(false) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
'adminid' => $userinfo['adminid']
|
||||
));
|
||||
$paging->setEntries(Database::num_rows());
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$row['ts_format'] = date("d.m.Y H:i", $row['ts']);
|
||||
eval("\$plans.=\"" . \Froxlor\UI\Template::getTemplate("plans/plans_plan") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
$i ++;
|
||||
foreach ($result['list'] as $row) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$row['ts_format'] = date("d.m.Y H:i", $row['ts']);
|
||||
eval("\$plans.=\"" . \Froxlor\UI\Template::getTemplate("plans/plans_plan") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("plans/plans") . "\";");
|
||||
|
@ -44,144 +44,74 @@ if ($page == 'overview') {
|
||||
$fields = array(
|
||||
'd.domain' => $lng['domains']['domainname']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_DOMAINS, $fields);
|
||||
$domains_stmt = Database::prepare("SELECT `d`.`id`, `d`.`customerid`, `d`.`domain`, `d`.`documentroot`, `d`.`isbinddomain`, `d`.`isemaildomain`, `d`.`caneditdomain`, `d`.`iswildcarddomain`, `d`.`parentdomainid`, `d`.`letsencrypt`, `d`.`registration_date`, `d`.`termination_date`, `ad`.`id` AS `aliasdomainid`, `ad`.`domain` AS `aliasdomain`, `da`.`id` AS `domainaliasid`, `da`.`domain` AS `domainalias` FROM `" . TABLE_PANEL_DOMAINS . "` `d`
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `ad` ON `d`.`aliasdomain`=`ad`.`id`
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `da` ON `da`.`aliasdomain`=`d`.`id`
|
||||
WHERE `d`.`customerid`= :customerid
|
||||
AND `d`.`email_only`='0'
|
||||
AND `d`.`id` <> :standardsubdomain " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($domains_stmt, array(
|
||||
"customerid" => $userinfo['customerid'],
|
||||
"standardsubdomain" => $userinfo['standardsubdomain']
|
||||
));
|
||||
$paging->setEntries(Database::num_rows());
|
||||
try {
|
||||
// get total count
|
||||
$json_result = SubDomains::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = SubDomains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$domains = '';
|
||||
$parentdomains_count = 0;
|
||||
$domains_count = 0;
|
||||
$domains_count = $paging->getEntries();
|
||||
$domain_array = array();
|
||||
|
||||
while ($row = $domains_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$row['domain'] = $idna_convert->decode($row['domain']);
|
||||
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']);
|
||||
$row['domainalias'] = $idna_convert->decode($row['domainalias']);
|
||||
|
||||
foreach ($result['list'] as $row) {
|
||||
formatDomainEntry($row, $idna_convert);
|
||||
if ($row['parentdomainid'] == '0' && $row['caneditdomain'] == '1') {
|
||||
$parentdomains_count ++;
|
||||
}
|
||||
$domain_array[$row['parentdomainid']][] = $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* check for set ssl-certs to show different state-icons
|
||||
*/
|
||||
// nothing (ssl_global)
|
||||
$row['domain_hascert'] = 0;
|
||||
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
|
||||
Database::pexecute($ssl_stmt, array(
|
||||
"domainid" => $row['id']
|
||||
));
|
||||
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
||||
// own certificate (ssl_customer_green)
|
||||
$row['domain_hascert'] = 1;
|
||||
} else {
|
||||
// check if it's parent has one set (shared)
|
||||
if ($row['parentdomainid'] != 0) {
|
||||
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
|
||||
Database::pexecute($ssl_stmt, array(
|
||||
"domainid" => $row['parentdomainid']
|
||||
));
|
||||
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
||||
// parent has a certificate (ssl_shared)
|
||||
$row['domain_hascert'] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']);
|
||||
if ($row['termination_date'] != "") {
|
||||
$cdate = strtotime($row['termination_date'] . " 23:59:59");
|
||||
$today = time();
|
||||
|
||||
if ($cdate < $today) {
|
||||
$row['termination_css'] = 'domain-expired';
|
||||
if (isset($domain_array[0])) {
|
||||
foreach ($domain_array[0] as $pdomain) {
|
||||
// PARENTDOMAIN
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($pdomain);
|
||||
if (Settings::Get('system.awstats_enabled') == '1') {
|
||||
$statsapp = 'awstats';
|
||||
} else {
|
||||
$row['termination_css'] = 'domain-canceled';
|
||||
$statsapp = 'webalizer';
|
||||
}
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";");
|
||||
// show docroot nicely
|
||||
if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot']));
|
||||
}
|
||||
// get ssl-ips if activated
|
||||
$show_ssledit = false;
|
||||
if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) {
|
||||
$show_ssledit = true;
|
||||
}
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
||||
|
||||
// every domain below the parentdomain
|
||||
if (isset($domain_array[$pdomain['id']])) {
|
||||
$mydomains = $domain_array[$pdomain['id']];
|
||||
foreach ($mydomains as $row) {
|
||||
// show docroot nicely
|
||||
if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot']));
|
||||
}
|
||||
// get ssl-ips if activated
|
||||
$show_ssledit = false;
|
||||
if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) {
|
||||
$show_ssledit = true;
|
||||
}
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$domains_count ++;
|
||||
$domain_array[$row['domain']] = $row;
|
||||
}
|
||||
|
||||
ksort($domain_array);
|
||||
$domain_id_array = array();
|
||||
foreach ($domain_array as $sortkey => $row) {
|
||||
$domain_id_array[$row['id']] = $sortkey;
|
||||
}
|
||||
|
||||
$domain_sort_array = array();
|
||||
foreach ($domain_array as $sortkey => $row) {
|
||||
if ($row['parentdomainid'] == 0) {
|
||||
$domain_sort_array[$sortkey][$sortkey] = $row;
|
||||
} else {
|
||||
// when searching and the results are subdomains only, we need to get
|
||||
// the parent domain to this subdomain
|
||||
if (! isset($domain_id_array[$row['parentdomainid']])) {
|
||||
$domain_id_array[$row['parentdomainid']] = "[parent-domain]";
|
||||
}
|
||||
$domain_sort_array[$domain_id_array[$row['parentdomainid']]][$sortkey] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$domain_array = array();
|
||||
|
||||
if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') {
|
||||
ksort($domain_sort_array);
|
||||
} elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') {
|
||||
krsort($domain_sort_array);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($domain_sort_array as $sortkey => $domain_array) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
|
||||
if (isset($domain_array[$sortkey])) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($domain_array[$sortkey]);
|
||||
if (Settings::Get('system.awstats_enabled') == '1') {
|
||||
$statsapp = 'awstats';
|
||||
} else {
|
||||
$statsapp = 'webalizer';
|
||||
}
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";");
|
||||
}
|
||||
|
||||
if ($paging->sortfield == 'd.domain' && $paging->sortorder == 'asc') {
|
||||
ksort($domain_array);
|
||||
} elseif ($paging->sortfield == 'd.domain' && $paging->sortorder == 'desc') {
|
||||
krsort($domain_array);
|
||||
}
|
||||
|
||||
foreach ($domain_array as $row) {
|
||||
if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot']));
|
||||
}
|
||||
|
||||
// get ssl-ips if activated
|
||||
$show_ssledit = false;
|
||||
if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) {
|
||||
$show_ssledit = true;
|
||||
}
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
$i += count($domain_array);
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domainlist") . "\";");
|
||||
@ -459,7 +389,9 @@ if ($page == 'overview') {
|
||||
}
|
||||
|
||||
$alias_stmt = Database::prepare("SELECT COUNT(`id`) AS count FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain`= :aliasdomain");
|
||||
$alias_check = Database::pexecute_first($alias_stmt, array("aliasdomain" => $result['id']));
|
||||
$alias_check = Database::pexecute_first($alias_stmt, array(
|
||||
"aliasdomain" => $result['id']
|
||||
));
|
||||
$alias_check = $alias_check['count'];
|
||||
|
||||
$domainip = $result_ipandport['ip'];
|
||||
@ -547,3 +479,53 @@ if ($page == 'overview') {
|
||||
|
||||
require_once __DIR__ . '/logfiles_viewer.php';
|
||||
}
|
||||
|
||||
function formatDomainEntry(&$row, &$idna_convert)
|
||||
{
|
||||
$row['domain'] = $idna_convert->decode($row['domain']);
|
||||
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']);
|
||||
$row['domainalias'] = $idna_convert->decode($row['domainalias']);
|
||||
|
||||
/**
|
||||
* check for set ssl-certs to show different state-icons
|
||||
*/
|
||||
// nothing (ssl_global)
|
||||
$row['domain_hascert'] = 0;
|
||||
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
|
||||
Database::pexecute($ssl_stmt, array(
|
||||
"domainid" => $row['id']
|
||||
));
|
||||
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
||||
// own certificate (ssl_customer_green)
|
||||
$row['domain_hascert'] = 1;
|
||||
} else {
|
||||
// check if it's parent has one set (shared)
|
||||
if ($row['parentdomainid'] != 0) {
|
||||
$ssl_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domainid");
|
||||
Database::pexecute($ssl_stmt, array(
|
||||
"domainid" => $row['parentdomainid']
|
||||
));
|
||||
$ssl_result = $ssl_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (is_array($ssl_result) && isset($ssl_result['ssl_cert_file']) && $ssl_result['ssl_cert_file'] != '') {
|
||||
// parent has a certificate (ssl_shared)
|
||||
$row['domain_hascert'] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']);
|
||||
|
||||
$row['termination_css'] = "";
|
||||
if ($row['termination_date'] != "") {
|
||||
$cdate = strtotime($row['termination_date'] . " 23:59:59");
|
||||
$today = time();
|
||||
|
||||
if ($cdate < $today) {
|
||||
$row['termination_css'] = 'domain-expired';
|
||||
} else {
|
||||
$row['termination_css'] = 'domain-canceled';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
define('AREA', 'customer');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Api\Commands\SubDomains;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\Emails as Emails;
|
||||
@ -47,23 +48,27 @@ if ($page == 'overview') {
|
||||
'm.email_full' => $lng['emails']['emailaddress'],
|
||||
'm.destination' => $lng['emails']['forwarders']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_MAIL_VIRTUAL, $fields);
|
||||
$result_stmt = Database::prepare('SELECT `m`.`id`, `m`.`domainid`, `m`.`email`, `m`.`email_full`, `m`.`iscatchall`, `u`.`quota`, `m`.`destination`, `m`.`popaccountid`, `d`.`domain`, `u`.`mboxsize` FROM `' . TABLE_MAIL_VIRTUAL . '` `m`
|
||||
LEFT JOIN `' . TABLE_PANEL_DOMAINS . '` `d` ON (`m`.`domainid` = `d`.`id`)
|
||||
LEFT JOIN `' . TABLE_MAIL_USERS . '` `u` ON (`m`.`popaccountid` = `u`.`id`)
|
||||
WHERE `m`.`customerid`= :customerid ' . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$emailscount = Database::num_rows();
|
||||
$paging->setEntries($emailscount);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Emails::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Emails::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$emails = array();
|
||||
$emailscount = $paging->getEntries();
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
if (! isset($emails[$row['domain']]) || ! is_array($emails[$row['domain']])) {
|
||||
$emails[$row['domain']] = array();
|
||||
}
|
||||
@ -77,7 +82,6 @@ if ($page == 'overview') {
|
||||
ksort($emails);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$accounts = '';
|
||||
$emails_count = 0;
|
||||
@ -90,53 +94,51 @@ if ($page == 'overview') {
|
||||
}
|
||||
|
||||
foreach ($emailaddresses as $row) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
if ($domainname != $idna_convert->decode($row['domain'])) {
|
||||
$domainname = $idna_convert->decode($row['domain']);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_domain") . "\";");
|
||||
}
|
||||
|
||||
$emails_count ++;
|
||||
$row['email'] = $idna_convert->decode($row['email']);
|
||||
$row['email_full'] = $idna_convert->decode($row['email_full']);
|
||||
$row['destination'] = explode(' ', $row['destination']);
|
||||
uasort($row['destination'], 'strcasecmp');
|
||||
|
||||
$dest_list = $row['destination'];
|
||||
foreach ($dest_list as $dest_id => $destination) {
|
||||
$row['destination'][$dest_id] = $idna_convert->decode($row['destination'][$dest_id]);
|
||||
|
||||
if ($row['destination'][$dest_id] == $row['email_full']) {
|
||||
unset($row['destination'][$dest_id]);
|
||||
}
|
||||
}
|
||||
|
||||
$destinations_count = count($row['destination']);
|
||||
$row['destination'] = implode(', ', $row['destination']);
|
||||
|
||||
if (strlen($row['destination']) > 35) {
|
||||
$row['destination'] = substr($row['destination'], 0, 32) . '... (' . $destinations_count . ')';
|
||||
}
|
||||
|
||||
$row['mboxsize'] = \Froxlor\PhpHelper::sizeReadable($row['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
||||
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_email") . "\";");
|
||||
$count ++;
|
||||
if ($domainname != $idna_convert->decode($row['domain'])) {
|
||||
$domainname = $idna_convert->decode($row['domain']);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_domain") . "\";");
|
||||
}
|
||||
|
||||
$i ++;
|
||||
$emails_count ++;
|
||||
$row['email'] = $idna_convert->decode($row['email']);
|
||||
$row['email_full'] = $idna_convert->decode($row['email_full']);
|
||||
$row['destination'] = explode(' ', $row['destination']);
|
||||
uasort($row['destination'], 'strcasecmp');
|
||||
|
||||
$dest_list = $row['destination'];
|
||||
foreach ($dest_list as $dest_id => $destination) {
|
||||
$row['destination'][$dest_id] = $idna_convert->decode($row['destination'][$dest_id]);
|
||||
|
||||
if ($row['destination'][$dest_id] == $row['email_full']) {
|
||||
unset($row['destination'][$dest_id]);
|
||||
}
|
||||
}
|
||||
|
||||
$destinations_count = count($row['destination']);
|
||||
$row['destination'] = implode(', ', $row['destination']);
|
||||
|
||||
if (strlen($row['destination']) > 35) {
|
||||
$row['destination'] = substr($row['destination'], 0, 32) . '... (' . $destinations_count . ')';
|
||||
}
|
||||
|
||||
$row['mboxsize'] = \Froxlor\PhpHelper::sizeReadable($row['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
||||
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_email") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
}
|
||||
|
||||
$emaildomains_count_stmt = Database::prepare("SELECT COUNT(`id`) AS `count` FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
WHERE `customerid`= :customerid
|
||||
AND `isemaildomain`='1' ORDER BY `domain` ASC");
|
||||
Database::pexecute($emaildomains_count_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$emaildomains_count = $emaildomains_count_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$emaildomains_count = $emaildomains_count['count'];
|
||||
$json_result = SubDomains::getLocal($userinfo, [
|
||||
'sql_search' => [
|
||||
'd.isemaildomain' => [
|
||||
'value' => 1,
|
||||
'op' => '='
|
||||
]
|
||||
]
|
||||
])->listing();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$emaildomains_count = $result['count'];
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";");
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
define('AREA', 'customer');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\DirOptions as DirOptions;
|
||||
use Froxlor\Api\Commands\DirProtections as DirProtections;
|
||||
@ -52,33 +51,34 @@ if ($page == 'overview') {
|
||||
'username' => $lng['login']['username'],
|
||||
'path' => $lng['panel']['path']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_HTPASSWDS, $fields);
|
||||
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "`
|
||||
WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$paging->setEntries(Database::num_rows());
|
||||
try {
|
||||
// get total count
|
||||
$json_result = DirProtections::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = DirProtections::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$htpasswds = '';
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
|
||||
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
|
||||
}
|
||||
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$htpasswds.=\"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_htpasswd") . "\";");
|
||||
$count ++;
|
||||
foreach ($result['list'] as $row) {
|
||||
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
|
||||
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
|
||||
}
|
||||
|
||||
$i ++;
|
||||
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$htpasswds.=\"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_htpasswd") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds") . "\";");
|
||||
@ -192,39 +192,40 @@ if ($page == 'overview') {
|
||||
'error500path' => $lng['extras']['error500path'],
|
||||
'options_cgi' => $lng['extras']['execute_perl']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_HTACCESS, $fields);
|
||||
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_HTACCESS . "`
|
||||
WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$paging->setEntries(Database::num_rows());
|
||||
try {
|
||||
// get total count
|
||||
$json_result = DirOptions::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = DirOptions::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$htaccess = '';
|
||||
|
||||
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
|
||||
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
|
||||
}
|
||||
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
|
||||
$row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']);
|
||||
$row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']);
|
||||
$row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']);
|
||||
$row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$htaccess.=\"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_htaccess") . "\";");
|
||||
$count ++;
|
||||
foreach ($result['list'] as $row) {
|
||||
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
|
||||
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
|
||||
}
|
||||
|
||||
$i ++;
|
||||
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
|
||||
$row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']);
|
||||
$row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']);
|
||||
$row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']);
|
||||
$row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$htaccess.=\"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_htaccess") . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess") . "\";");
|
||||
|
@ -46,39 +46,36 @@ if ($page == 'overview') {
|
||||
'homedir' => $lng['panel']['path'],
|
||||
'description' => $lng['panel']['ftpdesc']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_FTP_USERS, $fields);
|
||||
|
||||
$result_stmt = Database::prepare("SELECT `id`, `username`, `description`, `homedir`, `shell` FROM `" . TABLE_FTP_USERS . "`
|
||||
WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$ftps_count = Database::num_rows();
|
||||
$paging->setEntries($ftps_count);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Ftps::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Ftps::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$ftps_count = $paging->getEntries();
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$accounts = '';
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']);
|
||||
} else {
|
||||
$row['documentroot'] = $row['homedir'];
|
||||
}
|
||||
|
||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']);
|
||||
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";");
|
||||
$count ++;
|
||||
foreach ($result['list'] as $row) {
|
||||
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
|
||||
$row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']);
|
||||
} else {
|
||||
$row['documentroot'] = $row['homedir'];
|
||||
}
|
||||
|
||||
$i ++;
|
||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";");
|
||||
|
@ -19,6 +19,7 @@
|
||||
define('AREA', 'customer');
|
||||
require './lib/init.php';
|
||||
|
||||
use Froxlor\Api\Commands\SysLog;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
|
||||
@ -35,26 +36,25 @@ if ($page == 'log') {
|
||||
'user' => $lng['logger']['user'],
|
||||
'text' => $lng['logger']['action']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_LOG, $fields, null, null, 0, 'desc', 30);
|
||||
$query = 'SELECT * FROM `' . TABLE_PANEL_LOG . '` WHERE `user` = :loginname ' . $paging->getSqlWhere(true) . ' ' . $paging->getSqlOrderBy();
|
||||
$result_stmt = Database::prepare($query . ' ' . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"loginname" => $userinfo['loginname']
|
||||
));
|
||||
$result_cnt_stmt = Database::prepare($query);
|
||||
Database::pexecute($result_cnt_stmt, array(
|
||||
"loginname" => $userinfo['loginname']
|
||||
));
|
||||
$res_cnt = $result_cnt_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$logs_count = $result_cnt_stmt->rowCount();
|
||||
$paging->setEntries($logs_count);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = SysLog::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$clog = array();
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
foreach ($result['list'] as $row) {
|
||||
|
||||
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
|
||||
$clog[$row['action']] = array();
|
||||
@ -68,7 +68,6 @@ if ($page == 'log') {
|
||||
ksort($clog);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$log_count = 0;
|
||||
$log = '';
|
||||
@ -113,10 +112,7 @@ if ($page == 'log') {
|
||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
|
||||
$count ++;
|
||||
$_action = $action;
|
||||
// }
|
||||
$i ++;
|
||||
}
|
||||
$i ++;
|
||||
}
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
|
||||
|
@ -53,20 +53,24 @@ if ($page == 'overview') {
|
||||
'databasename' => $lng['mysql']['databasename'],
|
||||
'description' => $lng['mysql']['databasedescription']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_DATABASES, $fields);
|
||||
$result_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DATABASES . "`
|
||||
WHERE `customerid`= :customerid " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit());
|
||||
Database::pexecute($result_stmt, array(
|
||||
"customerid" => $userinfo['customerid']
|
||||
));
|
||||
$mysqls_count = Database::num_rows();
|
||||
$paging->setEntries($mysqls_count);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Mysqls::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Mysqls::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
$mysqls_count = $paging->getEntries();
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$i = 0;
|
||||
$count = 0;
|
||||
$mysqls = '';
|
||||
|
||||
@ -76,21 +80,18 @@ if ($page == 'overview') {
|
||||
|
||||
// Begin root-session
|
||||
Database::needRoot(true);
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($paging->checkDisplay($i)) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES
|
||||
foreach ($result['list'] as $row) {
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
$mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES
|
||||
WHERE table_schema = :table_schema
|
||||
GROUP BY table_schema");
|
||||
Database::pexecute($mbdata_stmt, array(
|
||||
"table_schema" => $row['databasename']
|
||||
));
|
||||
$mbdata = $mbdata_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
||||
eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
|
||||
$count ++;
|
||||
}
|
||||
$i ++;
|
||||
Database::pexecute($mbdata_stmt, array(
|
||||
"table_schema" => $row['databasename']
|
||||
));
|
||||
$mbdata = $mbdata_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
||||
eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
|
||||
$count ++;
|
||||
}
|
||||
Database::needRoot(false);
|
||||
// End root-session
|
||||
|
@ -37,11 +37,16 @@ $ttl = isset($_POST['record']['ttl']) ? (int) $_POST['record']['ttl'] : 18000;
|
||||
$domain = \Froxlor\Dns\Dns::getAllowedDomainEntry($domain_id, AREA, $userinfo);
|
||||
|
||||
// select all entries
|
||||
$sel_stmt = Database::prepare("SELECT * FROM `" . TABLE_DOMAIN_DNS . "` WHERE domain_id = :did");
|
||||
Database::pexecute($sel_stmt, array(
|
||||
'did' => $domain_id
|
||||
));
|
||||
$dom_entries = $sel_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
try {
|
||||
// get list
|
||||
$json_result = DomainZones::getLocal($userinfo, [
|
||||
'id' => $domain_id
|
||||
])->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$dom_entries = $result['list'];
|
||||
|
||||
$errors = "";
|
||||
$success_message = "";
|
||||
@ -117,7 +122,7 @@ $type_select_values = array(
|
||||
'RP',
|
||||
'SRV',
|
||||
'SSHFP',
|
||||
'TXT',
|
||||
'TXT'
|
||||
);
|
||||
asort($type_select_values);
|
||||
foreach ($type_select_values as $_type) {
|
||||
|
@ -4,6 +4,36 @@ namespace Froxlor;
|
||||
class PhpHelper
|
||||
{
|
||||
|
||||
private static $sort_key = 'id';
|
||||
|
||||
private static $sort_type = SORT_STRING;
|
||||
|
||||
/**
|
||||
* sort an array by either natural or string sort and a given index where the value for comparison is found
|
||||
*
|
||||
* @param array $list
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function sortListBy(&$list, $key = 'id')
|
||||
{
|
||||
self::$sort_type = Settings::Get('panel.natsorting') == 1 ? SORT_NATURAL : SORT_STRING;
|
||||
self::$sort_key = $key;
|
||||
return usort($list, array(
|
||||
'self',
|
||||
'sortListByGivenKey'
|
||||
));
|
||||
}
|
||||
|
||||
private static function sortListByGivenKey($a, $b)
|
||||
{
|
||||
if (self::$sort_type == SORT_NATURAL) {
|
||||
return strnatcasecmp($a[self::$sort_key], $b[self::$sort_key]);
|
||||
}
|
||||
return strcasecmp($a[self::$sort_key], $b[self::$sort_key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around htmlentities to handle arrays, with the advantage that you
|
||||
* can select which fields should be handled by htmlentities
|
||||
|
313
lib/Froxlor/UI/Pagination.php
Normal file
313
lib/Froxlor/UI/Pagination.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package API
|
||||
* @since 0.10.0
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage pagination, limiting and ordering
|
||||
*/
|
||||
class Pagination
|
||||
{
|
||||
|
||||
private $data = array();
|
||||
|
||||
private $fields = null;
|
||||
|
||||
public $sortorder = 'ASC';
|
||||
|
||||
public $sortfield = null;
|
||||
|
||||
private $searchtext = null;
|
||||
|
||||
private $searchfield = null;
|
||||
|
||||
private $is_search = false;
|
||||
|
||||
private $pageno = 0;
|
||||
|
||||
private $entries = 0;
|
||||
|
||||
/**
|
||||
* Create new pagination object to search/filter, limit and sort Api-listing() calls
|
||||
*
|
||||
* @param array $userinfo
|
||||
* @param array $fields
|
||||
* @param number $total_entries
|
||||
*/
|
||||
public function __construct($userinfo, $fields = array(), $total_entries = 0)
|
||||
{
|
||||
$this->fields = $fields;
|
||||
$this->entries = $total_entries;
|
||||
$this->pageno = 1;
|
||||
// add default limitation by settings
|
||||
$this->addLimit(\Froxlor\Settings::Get('panel.paging'));
|
||||
// check search request
|
||||
$this->searchtext = '';
|
||||
if (count($fields) > 0) {
|
||||
$orderfields = array_keys($fields);
|
||||
$this->searchfield = $orderfields[0];
|
||||
}
|
||||
if (isset($_REQUEST['searchtext']) && (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === '')) {
|
||||
$this->searchtext = trim($_REQUEST['searchtext']);
|
||||
}
|
||||
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
||||
$this->searchfield = $_REQUEST['searchfield'];
|
||||
}
|
||||
if (! empty($this->searchtext) && ! empty($this->searchfield)) {
|
||||
$this->addSearch($this->searchtext, $this->searchfield);
|
||||
}
|
||||
|
||||
// check other ordering requests
|
||||
if (isset($_REQUEST['sortorder']) && (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtoupper($_REQUEST['sortorder']);
|
||||
}
|
||||
if (isset($_REQUEST['sortfield']) && isset($fields[$_REQUEST['sortfield']])) {
|
||||
$this->sortfield = $_REQUEST['sortfield'];
|
||||
$this->addOrderBy($this->sortfield, $this->sortorder);
|
||||
} else {
|
||||
// add default ordering by given fields
|
||||
if (count($fields) > 0) {
|
||||
$orderfields = array_keys($fields);
|
||||
$this->addOrderBy($orderfields[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// check current page / pages
|
||||
if (isset($_REQUEST['pageno']) && intval($_REQUEST['pageno']) != 0) {
|
||||
$this->pageno = intval($_REQUEST['pageno']);
|
||||
}
|
||||
if (($this->pageno - 1) * \Froxlor\Settings::Get('panel.paging') > $this->entries) {
|
||||
$this->pageno = 1;
|
||||
}
|
||||
$this->addOffset(($this->pageno - 1) * \Froxlor\Settings::Get('panel.paging'));
|
||||
}
|
||||
|
||||
/**
|
||||
* add a field for ordering
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* optional, default 'ASC'
|
||||
*
|
||||
* @return \Froxlor\UI\Pagination
|
||||
*/
|
||||
public function addOrderBy($field = null, $order = 'ASC')
|
||||
{
|
||||
if (! isset($this->data['sql_orderby'])) {
|
||||
$this->data['sql_orderby'] = array();
|
||||
}
|
||||
$this->data['sql_orderby'][$field] = $order;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a limit
|
||||
*
|
||||
* @param number $limit
|
||||
* optional, default 0
|
||||
*
|
||||
* @return \Froxlor\UI\Pagination
|
||||
*/
|
||||
public function addLimit($limit = 0)
|
||||
{
|
||||
$this->data['sql_limit'] = (int) $limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* add an offset
|
||||
*
|
||||
* @param number $offset
|
||||
* optional, default 0
|
||||
*
|
||||
* @return \Froxlor\UI\Pagination
|
||||
*/
|
||||
public function addOffset($offset = 0)
|
||||
{
|
||||
$this->data['sql_offset'] = (int) $offset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a search operation
|
||||
*
|
||||
* @param string $searchtext
|
||||
* @param string $field
|
||||
* @param string $operator
|
||||
*
|
||||
* @return \Froxlor\UI\Pagination
|
||||
*/
|
||||
public function addSearch($searchtext = null, $field = null, $operator = null)
|
||||
{
|
||||
if (! isset($this->data['sql_search'])) {
|
||||
$this->data['sql_search'] = array();
|
||||
}
|
||||
$this->data['sql_search'][$field] = [
|
||||
'value' => $searchtext,
|
||||
'op' => $operator
|
||||
];
|
||||
// if a search is performed, the result-entries-count is irrelevant
|
||||
// we do not want pagination
|
||||
$this->is_search = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of total entries the user can access from the current resource
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
public function getEntries()
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting field
|
||||
*
|
||||
* @param array $lng
|
||||
* Language array
|
||||
* @return string the html sortcode
|
||||
*/
|
||||
public function getHtmlSortCode($lng, $break = false)
|
||||
{
|
||||
$sortcode = '';
|
||||
$fieldoptions = '';
|
||||
$orderoptions = '';
|
||||
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||
}
|
||||
|
||||
$breakorws = ($break ? '<br />' : ' ');
|
||||
foreach (array(
|
||||
'asc' => $lng['panel']['ascending'],
|
||||
'desc' => $lng['panel']['descending']
|
||||
) as $sortordertype => $sortorderdescription) {
|
||||
$orderoptions .= HTML::makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||
}
|
||||
|
||||
eval("\$sortcode =\"" . Template::getTemplate("misc/htmlsortcode", '1') . "\";");
|
||||
return $sortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting arrows
|
||||
*
|
||||
* @param string $baseurl
|
||||
* URL to use as base for links
|
||||
* @param string $field
|
||||
* If set, only this field will be returned
|
||||
*
|
||||
* @return mixed An array or a string (if field is set) of html code of arrows
|
||||
*/
|
||||
public function getHtmlArrowCode($baseurl, $field = '')
|
||||
{
|
||||
global $theme;
|
||||
if ($field != '' && isset($this->fields[$field])) {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$fieldname = htmlspecialchars($field);
|
||||
eval("\$arrowcode =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
} else {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$arrowcode = array();
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldname = htmlspecialchars($fieldname);
|
||||
eval("\$arrowcode[\$fieldname] =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
}
|
||||
}
|
||||
return $arrowcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for searching field
|
||||
*
|
||||
* @param array $lng
|
||||
* Language array
|
||||
*
|
||||
* @return string the html searchcode
|
||||
*/
|
||||
public function getHtmlSearchCode($lng)
|
||||
{
|
||||
$searchcode = '';
|
||||
$fieldoptions = '';
|
||||
$searchtext = htmlspecialchars($this->searchtext);
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||
}
|
||||
eval("\$searchcode =\"" . Template::getTemplate("misc/htmlsearchcode", '1') . "\";");
|
||||
return $searchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for paging
|
||||
*
|
||||
* @param string $baseurl
|
||||
* URL to use as base for links
|
||||
*
|
||||
* @return string the html pagingcode
|
||||
*/
|
||||
public function getHtmlPagingCode($baseurl)
|
||||
{
|
||||
if (\Froxlor\Settings::Get('panel.paging') == 0 || $this->is_search) {
|
||||
return '';
|
||||
} else {
|
||||
$pages = intval($this->getEntries() / \Froxlor\Settings::Get('panel.paging'));
|
||||
}
|
||||
|
||||
if ($this->getEntries() % \Froxlor\Settings::Get('panel.paging') != 0) {
|
||||
$pages ++;
|
||||
}
|
||||
|
||||
if ($pages > 1) {
|
||||
|
||||
$start = $this->pageno - 4;
|
||||
if ($start < 1) {
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
$stop = $this->pageno + 4;
|
||||
if ($stop > $pages) {
|
||||
$stop = $pages;
|
||||
}
|
||||
|
||||
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
||||
for ($i = $start; $i <= $stop; $i ++) {
|
||||
if ($i != $this->pageno) {
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||
} else {
|
||||
$pagingcode .= ' <strong>' . $i . '</strong> ';
|
||||
}
|
||||
}
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||
} else {
|
||||
$pagingcode = '';
|
||||
}
|
||||
|
||||
return $pagingcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* return parameter array for API command parameters $sql_search, $sql_limit, $sql_offset and $sql_orderby
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getApiCommandParams()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
@ -1,520 +0,0 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Classes
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to manage paging system
|
||||
*
|
||||
* @package Functions
|
||||
*/
|
||||
class Paging
|
||||
{
|
||||
|
||||
/**
|
||||
* Userinfo
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $userinfo = array();
|
||||
|
||||
/**
|
||||
* MySQL-Table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $table = '';
|
||||
|
||||
/**
|
||||
* Fields with description which should be selectable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $fields = array();
|
||||
|
||||
/**
|
||||
* Entries per page
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entriesperpage = 0;
|
||||
|
||||
/**
|
||||
* Number of entries of table
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $entries = 0;
|
||||
|
||||
/**
|
||||
* Sortorder, asc or desc
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortorder = 'asc';
|
||||
|
||||
/**
|
||||
* Sortfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $sortfield = '';
|
||||
|
||||
/**
|
||||
* Searchfield
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchfield = '';
|
||||
|
||||
/**
|
||||
* Searchtext
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $searchtext = '';
|
||||
|
||||
/**
|
||||
* Pagenumber
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pageno = 0;
|
||||
|
||||
/**
|
||||
* Switch natsorting on/off
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $natSorting = false;
|
||||
|
||||
private $limit = 0;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Loads settings from request or from userdata and saves them to session.
|
||||
*
|
||||
* @param
|
||||
* array userinfo
|
||||
* @param
|
||||
* string Name of Table
|
||||
* @param
|
||||
* array Fields, in format array( 'fieldname_in_mysql' => 'field_caption' )
|
||||
* @param
|
||||
* int *deprecated* entries per page
|
||||
* @param
|
||||
* bool *deprecated* Switch natsorting on/off (global, affects all calls of sort)
|
||||
* @param int $default_field
|
||||
* default sorting-field-index
|
||||
* @param string $default_order
|
||||
* default sorting order 'asc' or 'desc'
|
||||
*
|
||||
*/
|
||||
public function __construct($userinfo, $table, $fields, $entriesperpage = 0, $natSorting = false, $default_field = 0, $default_order = 'asc', $limit = 0)
|
||||
{
|
||||
|
||||
// entries per page and natsorting-flag are not
|
||||
// passed as parameter anymore, because these are
|
||||
// from the settings anyway
|
||||
$entriesperpage = \Froxlor\Settings::Get('panel.paging');
|
||||
$natSorting = \Froxlor\Settings::Get('panel.natsorting');
|
||||
|
||||
$this->userinfo = $userinfo;
|
||||
|
||||
if (! is_array($this->userinfo['lastpaging'])) {
|
||||
$this->userinfo['lastpaging'] = json_decode($this->userinfo['lastpaging'], true);
|
||||
}
|
||||
|
||||
$this->table = $table;
|
||||
$this->fields = $fields;
|
||||
$this->entriesperpage = $entriesperpage;
|
||||
$this->natSorting = $natSorting;
|
||||
$checklastpaging = (isset($this->userinfo['lastpaging']['table']) && $this->userinfo['lastpaging']['table'] == $this->table);
|
||||
$this->userinfo['lastpaging']['table'] = $this->table;
|
||||
|
||||
if (isset($_REQUEST['sortorder']) && (strtolower($_REQUEST['sortorder']) == 'desc' || strtolower($_REQUEST['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($_REQUEST['sortorder']);
|
||||
} else {
|
||||
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortorder']) && (strtolower($this->userinfo['lastpaging']['sortorder']) == 'desc' || strtolower($this->userinfo['lastpaging']['sortorder']) == 'asc')) {
|
||||
$this->sortorder = strtolower($this->userinfo['lastpaging']['sortorder']);
|
||||
} else {
|
||||
$this->sortorder = $default_order;
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['sortorder'] = $this->sortorder;
|
||||
|
||||
if (isset($_REQUEST['sortfield']) && isset($fields[$_REQUEST['sortfield']])) {
|
||||
$this->sortfield = $_REQUEST['sortfield'];
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['sortfield']) && isset($fields[$this->userinfo['lastpaging']['sortfield']])) {
|
||||
$this->sortfield = $this->userinfo['lastpaging']['sortfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
$this->sortfield = $fieldnames[$default_field];
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['sortfield'] = $this->sortfield;
|
||||
|
||||
if (isset($_REQUEST['searchfield']) && isset($fields[$_REQUEST['searchfield']])) {
|
||||
$this->searchfield = $_REQUEST['searchfield'];
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchfield']) && isset($fields[$this->userinfo['lastpaging']['searchfield']])) {
|
||||
$this->searchfield = $this->userinfo['lastpaging']['searchfield'];
|
||||
} else {
|
||||
$fieldnames = array_keys($fields);
|
||||
$this->searchfield = $fieldnames[0];
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['searchfield'] = $this->searchfield;
|
||||
|
||||
if (isset($_REQUEST['searchtext']) && (preg_match('/[-_@\p{L}\p{N}*.]+$/u', $_REQUEST['searchtext']) || $_REQUEST['searchtext'] === '')) {
|
||||
$this->searchtext = trim($_REQUEST['searchtext']);
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['searchtext']) && preg_match('/[-_@\p{L}\p{N}*.]+$/u', $this->userinfo['lastpaging']['searchtext'])) {
|
||||
$this->searchtext = $this->userinfo['lastpaging']['searchtext'];
|
||||
} else {
|
||||
$this->searchtext = '';
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['searchtext'] = $this->searchtext;
|
||||
|
||||
if (isset($_REQUEST['pageno']) && intval($_REQUEST['pageno']) != 0) {
|
||||
$this->pageno = intval($_REQUEST['pageno']);
|
||||
} else {
|
||||
if ($checklastpaging && isset($this->userinfo['lastpaging']['pageno']) && intval($this->userinfo['lastpaging']['pageno']) != 0) {
|
||||
$this->pageno = intval($this->userinfo['lastpaging']['pageno']);
|
||||
} else {
|
||||
$this->pageno = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->userinfo['lastpaging']['pageno'] = $this->pageno;
|
||||
$upd_stmt = \Froxlor\Database\Database::prepare("
|
||||
UPDATE `" . TABLE_PANEL_SESSIONS . "` SET
|
||||
`lastpaging` = :lastpaging
|
||||
WHERE `hash` = :hash AND `userid` = :userid
|
||||
AND `ipaddress` = :ipaddr AND `useragent` = :ua
|
||||
AND `adminsession` = :adminsession
|
||||
");
|
||||
$upd_data = array(
|
||||
'lastpaging' => json_encode($this->userinfo['lastpaging']),
|
||||
'hash' => $userinfo['hash'],
|
||||
'userid' => $userinfo['userid'],
|
||||
'ipaddr' => $userinfo['ipaddress'],
|
||||
'ua' => $userinfo['useragent'],
|
||||
'adminsession' => $userinfo['adminsession']
|
||||
);
|
||||
\Froxlor\Database\Database::pexecute($upd_stmt, $upd_data);
|
||||
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets number of entries and adjusts pageno if the number of entries doesn't correspond to the pageno.
|
||||
*
|
||||
* @param
|
||||
* int entries
|
||||
*/
|
||||
public function setEntries($entries)
|
||||
{
|
||||
$this->entries = $entries;
|
||||
|
||||
if (($this->pageno - 1) * $this->entriesperpage > $this->entries) {
|
||||
$this->pageno = 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a row should be displayed or not, used in loops
|
||||
*
|
||||
* @param
|
||||
* int number of row
|
||||
* @return bool to display or not to display, that's the question
|
||||
*/
|
||||
public function checkDisplay($count)
|
||||
{
|
||||
$begin = (intval($this->pageno) - 1) * intval($this->entriesperpage);
|
||||
$end = (intval($this->pageno) * intval($this->entriesperpage));
|
||||
return (($count >= $begin && $count < $end) || $this->entriesperpage == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns condition code for sql query
|
||||
*
|
||||
* @param
|
||||
* bool should returned condition code start with WHERE (false) or AND (true)?
|
||||
* @return string the condition code
|
||||
*/
|
||||
public function getSqlWhere($append = false)
|
||||
{
|
||||
if ($this->searchtext != '') {
|
||||
if ($append == true) {
|
||||
$condition = ' AND ';
|
||||
} else {
|
||||
$condition = ' WHERE ';
|
||||
}
|
||||
|
||||
$searchfield = explode('.', $this->searchfield);
|
||||
foreach ($searchfield as $id => $field) {
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field[0] != '`') {
|
||||
$field = '`' . $field;
|
||||
}
|
||||
|
||||
$searchfield[$id] = $field;
|
||||
}
|
||||
|
||||
$searchfield = implode('.', $searchfield);
|
||||
|
||||
$ops = array(
|
||||
'<',
|
||||
'>',
|
||||
'='
|
||||
);
|
||||
|
||||
// check if we use an operator or not
|
||||
$useOper = 0;
|
||||
$oper = "=";
|
||||
if (in_array(substr($this->searchtext, 0, 1), $ops)) {
|
||||
$useOper = 1;
|
||||
$oper = substr($this->searchtext, 0, 1);
|
||||
}
|
||||
|
||||
// check for diskspace and whether searchtext is a number
|
||||
// in any other case the logical-operators would make no sense
|
||||
if (strpos($searchfield, 'diskspace') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with diskspace is *1024
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024;
|
||||
$useOper = 1;
|
||||
} elseif (strpos($searchfield, 'traffic') > 0 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// anything with traffic is *1024*1024
|
||||
$searchtext = ((int) substr($this->searchtext, $useOper)) * 1024 * 1024;
|
||||
$useOper = 1;
|
||||
} else {
|
||||
// any other field
|
||||
$searchtext = substr($this->searchtext, $useOper);
|
||||
}
|
||||
|
||||
if ($useOper == 1 && is_numeric(substr($this->searchtext, $useOper))) {
|
||||
// now as we use >, < or = we use the given operator and not LIKE
|
||||
$condition .= $searchfield . " " . $oper . " " . \Froxlor\Database\Database::quote($searchtext);
|
||||
} else {
|
||||
$searchtext = str_replace('*', '%', $this->searchtext);
|
||||
// append wildcards if user did not enter any
|
||||
if (strpos($searchtext, '%') === false)
|
||||
$searchtext = '%' . $searchtext . '%';
|
||||
$condition .= $searchfield . " LIKE " . \Froxlor\Database\Database::quote($searchtext);
|
||||
}
|
||||
} else {
|
||||
$condition = '';
|
||||
}
|
||||
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns "order by"-code for sql query
|
||||
*
|
||||
* @param
|
||||
* bool Switch natsorting on/off (local, affects just this call)
|
||||
* @return string the "order by"-code
|
||||
*/
|
||||
public function getSqlOrderBy($natSorting = null)
|
||||
{
|
||||
$sortfield = explode('.', $this->sortfield);
|
||||
foreach ($sortfield as $id => $field) {
|
||||
if (substr($field, - 1, 1) != '`') {
|
||||
$field .= '`';
|
||||
}
|
||||
|
||||
if ($field[0] != '`') {
|
||||
$field = '`' . $field;
|
||||
}
|
||||
|
||||
$sortfield[$id] = $field;
|
||||
}
|
||||
|
||||
$sortfield = implode('.', $sortfield);
|
||||
$sortorder = strtoupper($this->sortorder);
|
||||
|
||||
if ($natSorting == true || ($natSorting === null && $this->natSorting == true)) {
|
||||
// Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556
|
||||
$sortcode = "ORDER BY CONCAT( IF( ASCII( LEFT( " . $sortfield . ", 5 ) ) > 57,
|
||||
LEFT( " . $sortfield . ", 1 ), 0 ),
|
||||
IF( ASCII( RIGHT( " . $sortfield . ", 1 ) ) > 57,
|
||||
LPAD( " . $sortfield . ", 255, '0' ),
|
||||
LPAD( CONCAT( " . $sortfield . ", '-' ), 255, '0' )
|
||||
)) " . $sortorder;
|
||||
} else {
|
||||
$sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder;
|
||||
}
|
||||
|
||||
return $sortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently not used
|
||||
*
|
||||
* @return string always empty
|
||||
*/
|
||||
public function getSqlLimit()
|
||||
{
|
||||
if ($this->limit > 0) {
|
||||
$_offset = ($this->pageno - 1) * $this->limit;
|
||||
return ' LIMIT ' . $_offset . ',' . $this->limit;
|
||||
}
|
||||
/**
|
||||
* currently not in use
|
||||
*/
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting field
|
||||
*
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html sortcode
|
||||
*/
|
||||
public function getHtmlSortCode($lng, $break = false)
|
||||
{
|
||||
$sortcode = '';
|
||||
$fieldoptions = '';
|
||||
$orderoptions = '';
|
||||
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->sortfield, true, true);
|
||||
}
|
||||
|
||||
$breakorws = ($break ? '<br />' : ' ');
|
||||
foreach (array(
|
||||
'asc' => $lng['panel']['ascending'],
|
||||
'desc' => $lng['panel']['descending']
|
||||
) as $sortordertype => $sortorderdescription) {
|
||||
$orderoptions .= HTML::makeoption($sortorderdescription, $sortordertype, $this->sortorder, true, true);
|
||||
}
|
||||
|
||||
eval("\$sortcode =\"" . Template::getTemplate("misc/htmlsortcode", '1') . "\";");
|
||||
return $sortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for sorting arrows
|
||||
*
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @param
|
||||
* string If set, only this field will be returned
|
||||
* @return mixed An array or a string (if field is set) of html code of arrows
|
||||
*/
|
||||
public function getHtmlArrowCode($baseurl, $field = '')
|
||||
{
|
||||
global $theme;
|
||||
|
||||
if ($field != '' && isset($this->fields[$field])) {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$fieldname = htmlspecialchars($field);
|
||||
eval("\$arrowcode =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
} else {
|
||||
$baseurl = htmlspecialchars($baseurl);
|
||||
$arrowcode = array();
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldname = htmlspecialchars($fieldname);
|
||||
eval("\$arrowcode[\$fieldname] =\"" . Template::getTemplate("misc/htmlarrowcode", '1') . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
return $arrowcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for searching field
|
||||
*
|
||||
* @param
|
||||
* array Language array
|
||||
* @return string the html searchcode
|
||||
*/
|
||||
public function getHtmlSearchCode($lng)
|
||||
{
|
||||
$searchcode = '';
|
||||
$fieldoptions = '';
|
||||
$searchtext = htmlspecialchars($this->searchtext);
|
||||
foreach ($this->fields as $fieldname => $fieldcaption) {
|
||||
$fieldoptions .= HTML::makeoption($fieldcaption, $fieldname, $this->searchfield, true, true);
|
||||
}
|
||||
eval("\$searchcode =\"" . Template::getTemplate("misc/htmlsearchcode", '1') . "\";");
|
||||
return $searchcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code for paging
|
||||
*
|
||||
* @param
|
||||
* string URL to use as base for links
|
||||
* @return string the html pagingcode
|
||||
*/
|
||||
public function getHtmlPagingCode($baseurl)
|
||||
{
|
||||
if ($this->entriesperpage == 0) {
|
||||
return '';
|
||||
} else {
|
||||
$pages = intval($this->entries / $this->entriesperpage);
|
||||
}
|
||||
|
||||
if ($this->entries % $this->entriesperpage != 0) {
|
||||
$pages ++;
|
||||
}
|
||||
|
||||
if ($pages > 1) {
|
||||
|
||||
$start = $this->pageno - 4;
|
||||
if ($start < 1) {
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
$stop = $this->pageno + 4;
|
||||
if ($stop > $pages) {
|
||||
$stop = $pages;
|
||||
}
|
||||
|
||||
$pagingcode = '<a href="' . htmlspecialchars($baseurl) . '&pageno=1">«</a> <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) - 1) == 0 ? '1' : intval($this->pageno) - 1) . '"><</a> ';
|
||||
for ($i = $start; $i <= $stop; $i ++) {
|
||||
if ($i != $this->pageno) {
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . $i . '">' . $i . '</a> ';
|
||||
} else {
|
||||
$pagingcode .= ' <strong>' . $i . '</strong> ';
|
||||
}
|
||||
}
|
||||
$pagingcode .= ' <a href="' . htmlspecialchars($baseurl) . '&pageno=' . ((intval($this->pageno) + 1) > $pages ? $pages : intval($this->pageno) + 1) . '">></a> <a href="' . $baseurl . '&pageno=' . $pages . '">»</a>';
|
||||
} else {
|
||||
$pagingcode = '';
|
||||
}
|
||||
|
||||
return $pagingcode;
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ if (! defined('AREA')) {
|
||||
*
|
||||
*/
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\Certificates as Certificates;
|
||||
|
||||
@ -47,35 +46,20 @@ $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed domains:
|
||||
$fields = array(
|
||||
'd.domain' => $lng['domains']['domainname']
|
||||
);
|
||||
$paging = new \Froxlor\UI\Paging($userinfo, TABLE_PANEL_DOMAIN_SSL_SETTINGS, $fields);
|
||||
|
||||
// select all my (accessable) certificates
|
||||
$certs_stmt_query = "SELECT s.*, d.domain, d.letsencrypt, c.customerid, c.loginname
|
||||
FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON `d`.`id` = `s`.`domainid`
|
||||
LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` c ON `c`.`customerid` = `d`.`customerid`
|
||||
WHERE ";
|
||||
|
||||
$qry_params = array();
|
||||
|
||||
if (AREA == 'admin' && $userinfo['customers_see_all'] == '0') {
|
||||
// admin with only customer-specific permissions
|
||||
$certs_stmt_query .= "d.adminid = :adminid ";
|
||||
$qry_params['adminid'] = $userinfo['adminid'];
|
||||
} elseif (AREA == 'customer') {
|
||||
// customer-area
|
||||
$certs_stmt_query .= "d.customerid = :cid ";
|
||||
$qry_params['cid'] = $userinfo['customerid'];
|
||||
} else {
|
||||
$certs_stmt_query .= "1 ";
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Certificates::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Certificates::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
|
||||
// sorting by domain-name
|
||||
$certs_stmt_query .= $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit();
|
||||
|
||||
$certs_stmt = Database::prepare($certs_stmt_query);
|
||||
Database::pexecute($certs_stmt, $qry_params);
|
||||
$all_certs = $certs_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$all_certs = $result['list'];
|
||||
$certificates = "";
|
||||
|
||||
if (count($all_certs) == 0) {
|
||||
@ -88,79 +72,73 @@ if (count($all_certs) == 0) {
|
||||
$pagingcode = "";
|
||||
eval("\$certificates.=\"" . \Froxlor\UI\Template::getTemplate("ssl_certificates/certs_error", true) . "\";");
|
||||
} else {
|
||||
$paging->setEntries(count($all_certs));
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
|
||||
foreach ($all_certs as $idx => $cert) {
|
||||
if ($paging->checkDisplay($idx)) {
|
||||
// respect froxlor-hostname
|
||||
if ($cert['domainid'] == 0) {
|
||||
$cert['domain'] = Settings::Get('system.hostname');
|
||||
$cert['letsencrypt'] = Settings::Get('system.le_froxlor_enabled');
|
||||
$cert['loginname'] = 'froxlor.panel';
|
||||
}
|
||||
|
||||
// respect froxlor-hostname
|
||||
if ($cert['domainid'] == 0) {
|
||||
$cert['domain'] = Settings::Get('system.hostname');
|
||||
$cert['letsencrypt'] = Settings::Get('system.le_froxlor_enabled');
|
||||
$cert['loginname'] = 'froxlor.panel';
|
||||
if (empty($cert['domain']) || empty($cert['ssl_cert_file'])) {
|
||||
// no domain found to the entry or empty entry - safely delete it from the DB
|
||||
try {
|
||||
Certificates::getLocal($userinfo, array(
|
||||
'id' => $cert['id']
|
||||
))->delete();
|
||||
} catch (Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$cert_data = openssl_x509_parse($cert['ssl_cert_file']);
|
||||
|
||||
$cert['domain'] = $idna_convert->decode($cert['domain']);
|
||||
|
||||
$adminCustomerLink = "";
|
||||
if (AREA == 'admin' && $cert['domainid'] > 0) {
|
||||
if (! empty($cert['loginname'])) {
|
||||
$adminCustomerLink = ' (<a href="' . $linker->getLink(array(
|
||||
'section' => 'customers',
|
||||
'page' => 'customers',
|
||||
'action' => 'su',
|
||||
'id' => $cert['customerid']
|
||||
)) . '" rel="external">' . $cert['loginname'] . '</a>)';
|
||||
}
|
||||
}
|
||||
|
||||
if ($cert_data) {
|
||||
$validFrom = date('d.m.Y H:i:s', $cert_data['validFrom_time_t']);
|
||||
$validTo = date('d.m.Y H:i:s', $cert_data['validTo_time_t']);
|
||||
|
||||
$isValid = true;
|
||||
if ($cert_data['validTo_time_t'] < time()) {
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
if (empty($cert['domain']) || empty($cert['ssl_cert_file'])) {
|
||||
// no domain found to the entry or empty entry - safely delete it from the DB
|
||||
try {
|
||||
Certificates::getLocal($userinfo, array(
|
||||
'id' => $cert['id']
|
||||
))->delete();
|
||||
} catch (Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$cert_data = openssl_x509_parse($cert['ssl_cert_file']);
|
||||
|
||||
$cert['domain'] = $idna_convert->decode($cert['domain']);
|
||||
|
||||
$adminCustomerLink = "";
|
||||
if (AREA == 'admin' && $cert['domainid'] > 0) {
|
||||
if (! empty($cert['loginname'])) {
|
||||
$adminCustomerLink = ' (<a href="' . $linker->getLink(array(
|
||||
'section' => 'customers',
|
||||
'page' => 'customers',
|
||||
'action' => 'su',
|
||||
'id' => $cert['customerid']
|
||||
)) . '" rel="external">' . $cert['loginname'] . '</a>)';
|
||||
}
|
||||
}
|
||||
|
||||
if ($cert_data) {
|
||||
$validFrom = date('d.m.Y H:i:s', $cert_data['validFrom_time_t']);
|
||||
$validTo = date('d.m.Y H:i:s', $cert_data['validTo_time_t']);
|
||||
|
||||
$isValid = true;
|
||||
if ($cert_data['validTo_time_t'] < time()) {
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
$san_list = "";
|
||||
if (isset($cert_data['extensions']['subjectAltName']) && ! empty($cert_data['extensions']['subjectAltName'])) {
|
||||
$SANs = explode(",", $cert_data['extensions']['subjectAltName']);
|
||||
$SANs = array_map('trim', $SANs);
|
||||
foreach ($SANs as $san) {
|
||||
$san = str_replace("DNS:", "", $san);
|
||||
if ($san != $cert_data['subject']['CN'] && strpos($san, "othername:") === false) {
|
||||
$san_list .= $san . "<br>";
|
||||
}
|
||||
$san_list = "";
|
||||
if (isset($cert_data['extensions']['subjectAltName']) && ! empty($cert_data['extensions']['subjectAltName'])) {
|
||||
$SANs = explode(",", $cert_data['extensions']['subjectAltName']);
|
||||
$SANs = array_map('trim', $SANs);
|
||||
foreach ($SANs as $san) {
|
||||
$san = str_replace("DNS:", "", $san);
|
||||
if ($san != $cert_data['subject']['CN'] && strpos($san, "othername:") === false) {
|
||||
$san_list .= $san . "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($cert);
|
||||
eval("\$certificates.=\"" . \Froxlor\UI\Template::getTemplate("ssl_certificates/certs_cert", true) . "\";");
|
||||
} else {
|
||||
$message = sprintf($lng['domains']['ssl_certificate_error'], $cert['domain']);
|
||||
eval("\$certificates.=\"" . \Froxlor\UI\Template::getTemplate("ssl_certificates/certs_error", true) . "\";");
|
||||
}
|
||||
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($cert);
|
||||
eval("\$certificates.=\"" . \Froxlor\UI\Template::getTemplate("ssl_certificates/certs_cert", true) . "\";");
|
||||
} else {
|
||||
continue;
|
||||
$message = sprintf($lng['domains']['ssl_certificate_error'], $cert['domain']);
|
||||
eval("\$certificates.=\"" . \Froxlor\UI\Template::getTemplate("ssl_certificates/certs_error", true) . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user