Ejemplo n.º 1
0
 protected function read_from_db_postprocess($db_result)
 {
     foreach ($db_result as $key => $value) {
         # split comma-separated 'goto' into an array
         $db_result[$key]['goto'] = explode(',', $db_result[$key]['goto']);
         # Vacation enabled?
         list($db_result[$key]['on_vacation'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $this->getVacationAlias());
         # if it is a mailbox, does the alias point to the mailbox?
         if ($db_result[$key]['is_mailbox']) {
             # this intentionally does not match mailbox targets with recipient delimiter.
             # if it would, we would have to make goto_mailbox a text instead of a bool (which would annoy 99% of the users)
             list($db_result[$key]['goto_mailbox'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $key);
         } else {
             # not a mailbox
             $db_result[$key]['goto_mailbox'] = 0;
         }
         # editing a default alias (postmaster@ etc.) is only allowed if special_alias_control is allowed or if the user is a superadmin
         $tmp = preg_split('/\\@/', $db_result[$key]['address']);
         if (!$this->is_superadmin && !Config::bool('special_alias_control') && array_key_exists($tmp[0], Config::Read('default_aliases'))) {
             $db_result[$key]['_can_edit'] = 0;
             $db_result[$key]['_can_delete'] = 0;
         }
         if ($this->struct['status']['display_in_list'] && Config::Bool('show_status')) {
             $db_result[$key]['status'] = gen_show_status($db_result[$key]['address']);
         }
     }
     return $db_result;
 }
Ejemplo n.º 2
0
function logout($mode)
{
    global $conn, $tabl, $username, $debug;
    if ($mode == "all") {
        // Clear sessions
        $sql = "UPDATE {$tabl} SET sidip='' WHERE username='******';";
        $result = $conn->query($sql);
        if ($result === FALSE) {
            stop('E5', "Can't set required value.");
        }
        stop(0, "Succesfully logged out.");
    } else {
        if ($mode == "me") {
            // Get all sessions
            $sql = "SELECT sidip FROM {$tabl} WHERE username='******';";
            $result = $conn->query($sql);
            if ($result === FALSE) {
                stop('E6', "Can't get required value.");
            }
            if ($result->num_rows == 0) {
                stop('E7', "Username not known.");
            }
            if ($result->num_rows > 1) {
                stop('E8', "Internal error.");
            }
            $line = $result->fetch_assoc();
            // Only one item, so safe to do this.
            // Remove current session
            // Magic!~
            $newarray = remove_from_array(explode(';', $line['sidip']), sidip());
            $newsessions = implode(';', $newarray);
            $sql = "UPDATE {$tabl} SET sidip='{$newsessions}' WHERE username='******';";
            $result = $conn->query($sql);
            if ($result === FALSE) {
                stop('E9', "Failed to set new value.");
            }
            stop(0, "Succesfully logged out.");
        } else {
            stop('E10', "Invalid mode.");
        }
    }
}