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-02-15 18:21:38 +01:00
|
|
|
if ($action == "Load Vcard") {
|
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"noheader" => True, "nonavbar" => True,
|
|
|
|
"currentapp" => "addressbook",
|
|
|
|
"enable_contacts_class" => True
|
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
include("../header.inc.php");
|
|
|
|
} else {
|
2001-02-15 18:21:38 +01:00
|
|
|
$phpgw_info["flags"] = array(
|
|
|
|
"currentapp" => "addressbook",
|
|
|
|
"enable_contacts_class" => True
|
|
|
|
);
|
2001-02-10 13:56:49 +01:00
|
|
|
include("../header.inc.php");
|
|
|
|
echo '<body bgcolor="' . $phpgw_info["theme"]["bg_color"] . '">';
|
|
|
|
}
|
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
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-03-13 18:18:22 +01:00
|
|
|
//$sep = $phpgw->common->filesystem_separator();
|
|
|
|
$sep = SEP;
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
$uploaddir = $phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"] . $sep;
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
if ($action == "Load Vcard") {
|
|
|
|
if($uploadedfile == "none" || $uploadedfile == "") {
|
2001-03-08 14:31:05 +01:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/vcardin.php","action=GetFile"));
|
2001-02-10 13:56:49 +01:00
|
|
|
} else {
|
|
|
|
srand((double)microtime()*1000000);
|
|
|
|
$random_number = rand(100000000,999999999);
|
|
|
|
$newfilename = md5("$uploadedfile, $uploadedfile_name, " . $phpgw_info["user"]["sessionid"]
|
|
|
|
. 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);
|
|
|
|
$ftp = fopen($uploaddir . $newfilename . ".info","w");
|
|
|
|
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
|
|
|
// This has to be non-interactive in case of a multi-entry vcard.
|
|
|
|
$filename = $uploaddir . $newfilename;
|
2001-03-13 18:18:22 +01:00
|
|
|
//$n_groups = $phpgw->accounts->array_to_string($access,$n_groups);
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-03-13 18:18:22 +01:00
|
|
|
//if($access == "group")
|
|
|
|
// $access = $n_groups;
|
2001-02-10 13:56:49 +01:00
|
|
|
//echo $access . "<BR>";
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
parsevcard($filename,$access);
|
|
|
|
// Delete the temp file.
|
|
|
|
unlink($filename);
|
|
|
|
unlink($filename . ".info");
|
2001-03-08 14:31:05 +01:00
|
|
|
Header("Location: " . $phpgw->link("/addressbook/", "cd=14"));
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
if (! file_exists($phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"]))
|
|
|
|
mkdir($phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"],0700);
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
if ($action == "GetFile"){
|
|
|
|
echo "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>";
|
|
|
|
}
|
2000-11-03 22:11:39 +01:00
|
|
|
|
|
|
|
|
2001-02-15 18:21:38 +01:00
|
|
|
$t = new Template($phpgw->common->get_tpl_dir("addressbook"));
|
|
|
|
$t->set_file(array("vcardin" => "vcardin.tpl"));
|
|
|
|
|
|
|
|
$vcard_header = "<p> <b>" . lang("Address book - VCard in") . "</b><hr><p>";
|
|
|
|
|
|
|
|
$t->set_var(vcard_header,$vcard_header);
|
2001-03-08 14:31:05 +01:00
|
|
|
$t->set_var(action_url,$phpgw->link("/addressbook/vcardin.php"));
|
2001-02-15 18:21:38 +01:00
|
|
|
$t->set_var(lang_access,lang("Access"));
|
|
|
|
$t->set_var(lang_groups,lang("Which groups"));
|
2001-03-13 18:18:22 +01:00
|
|
|
/*
|
2001-02-15 18:21:38 +01:00
|
|
|
$access_option = "<option value=\"private\"";
|
|
|
|
if($access == "private")
|
|
|
|
$access_option .= "selected";
|
|
|
|
$access_option .= ">" . lang("private");
|
|
|
|
$access_option .= "</option>\n";
|
|
|
|
$access_option .= "<option value=\"public\"\n";
|
|
|
|
if($access == "public")
|
|
|
|
$access_option .= "selected";
|
|
|
|
$access_option .= ">" . lang("Global Public");
|
|
|
|
$access_option .= "</option>\n";
|
|
|
|
$access_option .= "<option value=\"group\"";
|
|
|
|
if($access != "private" && $access != "public" && $access != "")
|
|
|
|
$access_option .= "selected";
|
|
|
|
$access_option .= ">" . lang("Group Public");
|
|
|
|
$access_option .= "</option>\n";
|
2001-03-13 18:18:22 +01:00
|
|
|
*/
|
2001-02-15 18:21:38 +01:00
|
|
|
$t->set_var(access_option,$access_option);
|
2001-03-13 18:18:22 +01:00
|
|
|
/*
|
2001-02-15 18:21:38 +01:00
|
|
|
//$user_groups = $phpgw->accounts->read_group_names($fields["ab_owner"]);
|
|
|
|
for ($i=0;$i<count($user_groups);$i++) {
|
|
|
|
$group_option = "<option value=\"" . $user_groups[$i][0] . "\"";
|
|
|
|
if (ereg(",".$user_groups[$i][0].",",$access)) {
|
|
|
|
$group_option .= " selected";
|
|
|
|
$group_option .= ">" . $user_groups[$i][1];
|
|
|
|
$group_option .= "</option>\n";
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 18:18:22 +01:00
|
|
|
*/
|
2001-02-15 18:21:38 +01:00
|
|
|
$t->set_var(group_option,$group_option);
|
|
|
|
|
|
|
|
$t->pparse("out","vcardin");
|
2000-11-03 22:11:39 +01:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
if ($action != "Load Vcard")
|
|
|
|
$phpgw->common->phpgw_footer();
|
2000-11-03 22:11:39 +01:00
|
|
|
?>
|