Exemplo n.º 1
0
function domainExists($domain)
{
    $domainId = getDomainId($domain);
    if ($domainId) {
        return TRUE;
    }
    return FALSE;
}
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);
}
Exemplo n.º 3
0
function processDomains($urls)
{
    $return = array();
    for ($i = 0; $i < count($urls); $i++) {
        $url = $urls[$i];
        $domainId = getDomainId($url['domain'], $url['ip']);
        $data = json_decode(getData($url['domain']));
        $results = $data->DataTables->Results->Data;
        for ($x = 0; $x < count($results); $x++) {
            $result = $results[$x];
            $domain = $result->Domain;
            $rank = $result->AlexaRank;
            $ip = $result->IP;
            $trust = $result->TrustFlow;
            $refId = getDomainId($domain, $ip);
            addRefDomain($domainId, $refId, $rank, $trust);
            $return[] = array('domain' => $domain, 'ip' => $ip);
        }
    }
    return $return;
}
Exemplo n.º 4
0
function setUserLocal($value, $email = FALSE)
{
    if (!$email) {
        $email = $_SESSION['user']['email'];
    }
    if (!validEmailAddress($email)) {
        return;
    } else {
        if (!userExists($email)) {
            return;
        } else {
            if (isSiteAdmin(getUserId($email))) {
                ## site admin should not manipulate own delivery
                return;
            }
        }
    }
    $parts = split('@', $email);
    if ($email != $_SESSION['user']['email']) {
        $adminDomains = getAdminDomains();
        if (!in_array($parts[1], $adminDomains)) {
            return;
        }
    }
    if ($value !== 't' && $value !== 'f') {
        if (!$value) {
            $value = 'f';
        } else {
            $value = 't';
        }
    }
    $count = 0;
    if ($value == 'f') {
        ## user must have at least one active forward to disable local delivery
        $count = count(getActiveUserForwards($email));
    }
    if ($value == 'f' && $count == 0) {
        ## TODO notify user
        $value = 't';
    }
    $conditions = array('username' => $parts[0], 'domain_id' => getDomainId($parts[1]), 'destination' => $email);
    db_update('virtual_aliases', array('active' => $value), $conditions);
}