mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-12-13 18:06:01 +00:00
Domains datatable - server side processing
Signed-off-by: Kristian Feldsam <feldsam@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@ function api_log($_data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = json_decode($value, true);
|
||||
$value = json_decode($value, true);
|
||||
if ($value) {
|
||||
if (is_array($value)) unset($value["csrf_token"]);
|
||||
foreach ($value as $key => &$val) {
|
||||
@@ -23,7 +23,7 @@ function api_log($_data) {
|
||||
$val = '*';
|
||||
}
|
||||
}
|
||||
$value = json_encode($value);
|
||||
$value = json_encode($value);
|
||||
}
|
||||
$data_var[] = $data . "='" . $value . "'";
|
||||
}
|
||||
@@ -44,7 +44,7 @@ function api_log($_data) {
|
||||
'msg' => 'Redis: '.$e
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['query'])) {
|
||||
@@ -178,12 +178,12 @@ if (isset($_GET['query'])) {
|
||||
// parse post data
|
||||
$post = trim(file_get_contents('php://input'));
|
||||
if ($post) $post = json_decode($post);
|
||||
|
||||
|
||||
// process registration data from authenticator
|
||||
try {
|
||||
// decode base64 strings
|
||||
$clientDataJSON = base64_decode($post->clientDataJSON);
|
||||
$attestationObject = base64_decode($post->attestationObject);
|
||||
$attestationObject = base64_decode($post->attestationObject);
|
||||
|
||||
// processCreate($clientDataJSON, $attestationObject, $challenge, $requireUserVerification=false, $requireUserPresent=true, $failIfRootMismatch=true)
|
||||
$data = $WebAuthn->processCreate($clientDataJSON, $attestationObject, $_SESSION['challenge'], false, true);
|
||||
@@ -250,7 +250,7 @@ if (isset($_GET['query'])) {
|
||||
default:
|
||||
process_add_return(mailbox('add', 'domain', $attr));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "resource":
|
||||
process_add_return(mailbox('add', 'resource', $attr));
|
||||
@@ -470,7 +470,7 @@ if (isset($_GET['query'])) {
|
||||
// false, if only internal is allowed
|
||||
// null, if internal and cross-platform is allowed
|
||||
$createArgs = $WebAuthn->getCreateArgs($_SESSION["mailcow_cc_username"], $_SESSION["mailcow_cc_username"], $_SESSION["mailcow_cc_username"], 30, false, $GLOBALS['WEBAUTHN_UV_FLAG_REGISTER'], null, $excludeCredentialIds);
|
||||
|
||||
|
||||
print(json_encode($createArgs));
|
||||
$_SESSION['challenge'] = $WebAuthn->getChallenge();
|
||||
return;
|
||||
@@ -523,9 +523,44 @@ if (isset($_GET['query'])) {
|
||||
|
||||
case "domain":
|
||||
switch ($object) {
|
||||
case "datatables":
|
||||
$table = ['domain', 'd'];
|
||||
$primaryKey = 'domain';
|
||||
$columns = [
|
||||
['db' => 'domain', 'dt' => 2],
|
||||
['db' => 'aliases', 'dt' => 3],
|
||||
['db' => 'mailboxes', 'dt' => 4],
|
||||
['db' => 'quota', 'dt' => 5],
|
||||
];
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/lib/ssp.class.php';
|
||||
global $pdo;
|
||||
if($_SESSION['mailcow_cc_role'] === 'admin') {
|
||||
$data = SSP::simple($_GET, $pdo, $table, $primaryKey, $columns);
|
||||
} elseif ($_SESSION['mailcow_cc_role'] === 'domainadmin') {
|
||||
$data = SSP::complex($_GET, $pdo, $table, $primaryKey, $columns,
|
||||
'INNER JOIN domain_admins as da ON da.domain = d.domain',
|
||||
[
|
||||
'condition' => 'da.active = 1 and da.username = :username',
|
||||
'bindings' => ['username' => $_SESSION['mailcow_cc_username']]
|
||||
]);
|
||||
}
|
||||
|
||||
if (!empty($data['data'])) {
|
||||
$domainsData = [];
|
||||
foreach ($data['data'] as $domain) {
|
||||
if ($details = mailbox('get', 'domain_details', $domain[2])) {
|
||||
$domainsData[] = $details;
|
||||
}
|
||||
}
|
||||
$data['data'] = $domainsData;
|
||||
}
|
||||
|
||||
process_get_return($data);
|
||||
break;
|
||||
case "all":
|
||||
$tags = null;
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
$tags = explode(',', $_GET['tags']);
|
||||
|
||||
$domains = mailbox('get', 'domains', null, $tags);
|
||||
@@ -1014,7 +1049,7 @@ if (isset($_GET['query'])) {
|
||||
case "all":
|
||||
case "reduced":
|
||||
$tags = null;
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
$tags = explode(',', $_GET['tags']);
|
||||
|
||||
if (empty($extra)) $domains = mailbox('get', 'domains');
|
||||
@@ -1048,7 +1083,7 @@ if (isset($_GET['query'])) {
|
||||
break;
|
||||
default:
|
||||
$tags = null;
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
if (isset($_GET['tags']) && $_GET['tags'] != '')
|
||||
$tags = explode(',', $_GET['tags']);
|
||||
|
||||
if ($tags === null) {
|
||||
@@ -1058,7 +1093,7 @@ if (isset($_GET['query'])) {
|
||||
$mailboxes = mailbox('get', 'mailboxes', $object, $tags);
|
||||
if (is_array($mailboxes)) {
|
||||
foreach ($mailboxes as $mailbox) {
|
||||
if ($details = mailbox('get', 'mailbox_details', $mailbox))
|
||||
if ($details = mailbox('get', 'mailbox_details', $mailbox))
|
||||
$data[] = $details;
|
||||
}
|
||||
}
|
||||
@@ -1557,15 +1592,15 @@ if (isset($_GET['query'])) {
|
||||
'solr_size' => $solr_size,
|
||||
'solr_documents' => $solr_documents
|
||||
));
|
||||
break;
|
||||
break;
|
||||
case "host":
|
||||
if (!$extra){
|
||||
$stats = docker("host_stats");
|
||||
echo json_encode($stats);
|
||||
}
|
||||
}
|
||||
else if ($extra == "ip") {
|
||||
// get public ips
|
||||
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_POST, 0);
|
||||
@@ -1972,7 +2007,7 @@ if (isset($_GET['query'])) {
|
||||
exit();
|
||||
}
|
||||
}
|
||||
if ($_SESSION['mailcow_cc_api'] === true) {
|
||||
if (array_key_exists('mailcow_cc_api', $_SESSION) && $_SESSION['mailcow_cc_api'] === true) {
|
||||
if (isset($_SESSION['mailcow_cc_api']) && $_SESSION['mailcow_cc_api'] === true) {
|
||||
unset($_SESSION['return']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user