2000-11-03 22:11:39 +01:00
|
|
|
<?php
|
2001-02-10 13:56:49 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - E-Mail *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* This file written by Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
/* $Id$ */
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
if ($action == 'Load Vcard')
|
|
|
|
{
|
|
|
|
$phpgw_info['flags'] = array(
|
|
|
|
'noheader' => True,
|
|
|
|
'nonavbar' => True,
|
|
|
|
'currentapp' => 'addressbook',
|
|
|
|
'enable_contacts_class' => True
|
2001-02-15 18:21:38 +01:00
|
|
|
);
|
2001-05-21 09:56:46 +02:00
|
|
|
include('../header.inc.php');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$phpgw_info['flags'] = array(
|
|
|
|
'currentapp' => 'addressbook',
|
|
|
|
'enable_contacts_class' => True
|
2001-02-15 18:21:38 +01:00
|
|
|
);
|
2001-05-21 09:56:46 +02:00
|
|
|
include('../header.inc.php');
|
|
|
|
echo '<body bgcolor="' . $phpgw_info['theme']['bg_color'] . '">';
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
// Some of the methods where borrowed from
|
|
|
|
// Squirrelmail <Luke Ehresman> http://www.squirrelmail.org
|
2001-03-21 23:51:37 +01:00
|
|
|
// (only the uploaddir naming anymore)
|
2001-03-13 18:18:22 +01:00
|
|
|
$sep = SEP;
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
$uploaddir = $phpgw_info['server']['temp_dir'] . $sep;
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
if ($action == 'Load Vcard')
|
|
|
|
{
|
|
|
|
if($uploadedfile == 'none' || $uploadedfile == '')
|
|
|
|
{
|
|
|
|
Header('Location: ' . $phpgw->link('/addressbook/vcardin.php','action=GetFile'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
srand((double)microtime()*1000000);
|
|
|
|
$random_number = rand(100000000,999999999);
|
2001-03-21 04:13:42 +01:00
|
|
|
$newfilename = md5("$uploadedfile, $uploadedfile_name, "
|
2001-02-10 13:56:49 +01:00
|
|
|
. time() . getenv("REMOTE_ADDR") . $random_number );
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
copy($uploadedfile, $uploaddir . $newfilename);
|
2001-05-21 09:56:46 +02:00
|
|
|
$ftp = fopen($uploaddir . $newfilename . '.info','w');
|
2001-02-10 13:56:49 +01:00
|
|
|
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
|
|
|
|
fclose($ftp);
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
$filename = $uploaddir . $newfilename;
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
$contacts = CreateObject('phpgwapi.contacts');
|
|
|
|
$vcard = CreateObject('phpgwapi.vcard');
|
2001-03-21 21:52:02 +01:00
|
|
|
$myimport = $vcard->import;
|
|
|
|
$buffer = array();
|
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
$fp=fopen($filename,'r');
|
|
|
|
while ($data = fgets($fp,8000))
|
|
|
|
{
|
2001-03-21 21:52:02 +01:00
|
|
|
list($name,$value,$extra) = split(':', $data);
|
2001-05-21 09:56:46 +02:00
|
|
|
if (substr($value,0,5) == 'http')
|
|
|
|
{
|
|
|
|
$value = $value . ':'.$extra;
|
2001-03-21 21:52:02 +01:00
|
|
|
}
|
2001-05-21 09:56:46 +02:00
|
|
|
if ($name && $value)
|
|
|
|
{
|
2001-03-21 21:52:02 +01:00
|
|
|
reset($vcard->import);
|
2001-05-21 09:56:46 +02:00
|
|
|
while ( list($fname,$fvalue) = each($vcard->import) )
|
|
|
|
{
|
|
|
|
if ( strstr(strtolower($name), $vcard->import[$fname]) )
|
|
|
|
{
|
2001-03-21 21:52:02 +01:00
|
|
|
$value = trim($value);
|
|
|
|
$value = ereg_replace("=0D=0A","\n",$value);
|
|
|
|
$buffer += array($name => $value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
|
|
|
|
$entry = $vcard->in($buffer);
|
2001-05-21 09:56:46 +02:00
|
|
|
$contacts->add($phpgw_info['user']['account_id'],$entry);
|
2001-03-21 21:52:02 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
// Delete the temp file.
|
|
|
|
unlink($filename);
|
2001-05-21 09:56:46 +02:00
|
|
|
unlink($filename . '.info');
|
|
|
|
Header('Location: ' . $phpgw->link('/addressbook/', 'cd=14'));
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
if ($action == 'GetFile')
|
|
|
|
{
|
|
|
|
echo '<b><center>You must select a vcard. (*.vcf)</b></center><br><br>';
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-10 14:21:16 +02:00
|
|
|
$t = new Template(PHPGW_APP_TPL);
|
2001-05-21 09:56:46 +02:00
|
|
|
$t->set_file(array('vcardin' => 'vcardin.tpl'));
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
$vcard_header = '<p> <b>' . lang('Address book - VCard in') . '</b><hr><p>';
|
2001-02-15 18:21:38 +01:00
|
|
|
|
|
|
|
$t->set_var(vcard_header,$vcard_header);
|
2001-05-21 09:56:46 +02:00
|
|
|
$t->set_var(action_url,$phpgw->link('/addressbook/vcardin.php'));
|
|
|
|
$t->set_var(lang_access,lang('Access'));
|
|
|
|
$t->set_var(lang_groups,lang('Which groups'));
|
2001-02-15 18:21:38 +01:00
|
|
|
$t->set_var(access_option,$access_option);
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-02-15 18:21:38 +01:00
|
|
|
$t->set_var(group_option,$group_option);
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
$t->pparse('out','vcardin');
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-05-21 09:56:46 +02:00
|
|
|
if ($action != 'Load Vcard')
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$phpgw->common->phpgw_footer();
|
2001-05-21 09:56:46 +02:00
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
?>
|