mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 16:19:00 +01:00
Cleanup handling of vcard file import
This commit is contained in:
parent
2e69a4dfe8
commit
f3549ec4d8
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 '<body bgcolor="' . $GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
|
||||
|
||||
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 '<body bgcolor="' . $GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
|
||||
|
||||
if($action == 'GetFile')
|
||||
{
|
||||
echo '<b><center>' . lang('You must select a vcard. (*.vcf)') . '</b></center><br><br>';
|
||||
|
Loading…
Reference in New Issue
Block a user