Example #1
0
$vnconv->set_from($_POST['encoding'] == "none" ? '' : $_POST['encoding']);
if ($task == 'import') {
    $contact_groups[''] = 0;
    $group_mode = isset($_POST['group_mode']) ? $_POST['group_mode'] : 'group_name';
    $group_id = isset($_POST['group_id']) ? $_POST['group_id'] : 'group_id';
    if ($group_mode == 'file') {
        $ab->get_groups($_POST['addressbook_id']);
        while ($ab->next_record()) {
            $contact_groups[$ab->f('name')] = $ab->f('id');
        }
    }
    switch ($_POST['file_type']) {
        case 'vcf':
            require_once $GO_MODULES->path . "classes/vcard.class.inc";
            $vcard = new vcard();
            $success = $vcard->import($_POST['import_file'], $GO_SECURITY->user_id, $_POST['addressbook_id'], $vnconv);
            unlink($_POST['import_file']);
            if ($success) {
                echo $contacts_import_success;
            } else {
                echo $ab_import_failed;
            }
            echo '<br /><br />';
            $button = new button($cmdOk, "javascript:document.location='" . $return_to . "'");
            break;
        case 'csv':
            $seperator = isset($_POST['seperator']) ? $_POST['seperator'] : ';';
            $fp = fopen($_POST['import_file'], "r");
            if (!$fp || !($addressbook = $ab->get_addressbook($_POST['addressbook_id']))) {
                unlink($_POST['import_file']);
                $feedback = "<p class=\"Error\">" . $strDataError . "</p>";