diff --git a/addressbook/inc/class.boaddressbook.inc.php b/addressbook/inc/class.boaddressbook.inc.php index f2d30dedfc..bb134b8239 100644 --- a/addressbook/inc/class.boaddressbook.inc.php +++ b/addressbook/inc/class.boaddressbook.inc.php @@ -288,30 +288,18 @@ function add_vcard($uploadedfile='') { - if($uploadedfile == 'none' || $uploadedfile == '') + if($uploadedfile == 'none' || $uploadedfile == '' || substr($uploadedfile['name'],-4) != '.vcf') { return False; } else { - $uploaddir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; - - srand((double)microtime() * 1000000); - $random_number = rand(100000000,999999999); - $newfilename = md5("$uploadedfile, $uploadedfile_name, " - . time() . getenv('REMOTE_ADDR') . $random_number); - - copy($uploadedfile, $uploaddir . $newfilename); - $ftp = fopen($uploaddir . $newfilename . '.info','w'); - fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n"); - fclose($ftp); - - $filename = $uploaddir . $newfilename; + $filename = $uploadedfile['tmp_name']; $vcard = CreateObject('phpgwapi.vcard'); $entry = $vcard->in_file($filename); /* _debug_array($entry);exit; */ - $entry['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; + $entry['owner'] = (int)$GLOBALS['phpgw_info']['user']['account_id']; $entry['access'] = 'private'; $entry['tid'] = 'n'; /* _debug_array($entry);exit; */ @@ -319,10 +307,6 @@ $this->so->add_entry($entry); $ab_id = $this->get_lastid(); - /* Delete the temp file. */ - unlink($filename); - unlink($filename . '.info'); - return(int)$ab_id; } } diff --git a/addressbook/inc/class.uivcard.inc.php b/addressbook/inc/class.uivcard.inc.php index c9f902d17e..9aac3e2177 100644 --- a/addressbook/inc/class.uivcard.inc.php +++ b/addressbook/inc/class.uivcard.inc.php @@ -46,20 +46,19 @@ $uploadedfile = get_var('uploadedfile','FILES'); $action = get_var('action',array('POST','GET')); - $GLOBALS['phpgw']->common->phpgw_header(); - echo parse_navbar(); - - echo ''; - if($uploadedfile) { $ab_id = $this->bo->add_vcard($uploadedfile); - if($done) + if($ab_id) { Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id)); } } + $GLOBALS['phpgw']->common->phpgw_header(); + echo parse_navbar(); + echo ''; + if($action == 'GetFile') { echo '
' . lang('You must select a vcard. (*.vcf)') . '


';