function bulkAddLocalForward($email, $destination) { if (!$email || !$destination) { return FALSE; } $emailParts = split('@', $email); $username = $emailParts[0]; $domain = $emailParts[1]; $domainId = getDomainId($domain); if (!$domainId) { return FALSE; } return addLocalForward($username, $domainId, $destination, TRUE, FALSE); }
} print json_encode(array('success' => TRUE)); } else { if ($mode == 'add') { $username = $_POST['username']; $domainId = $_POST['domain']; $destination = $_POST['destination']; $active = $_POST['active']; if ($active == 'true') { $active = TRUE; } else { $active = FALSE; } $username = trim($username); $destination = trim($destination); addLocalForward($username, $domainId, $destination, $active); } else { if ($mode == 'bulk-add') { $lines = split("\n", $_POST['local-forwards']); foreach ($lines as $line) { if (substr($line, ':') === FALSE) { continue; } $forwardParts = split(':', $line); $email = trim($forwardParts[0]); $destination = trim($forwardParts[1]); bulkAddLocalForward($email, $destination); } print json_encode(array('success' => TRUE)); } }