Added a comma after each msgnum exported. The parser was globbing them all together...
[citadel.git] / ctdlphp / CreateUserFromData.php
1 <?PHP
2
3 define('CITADEL_DEBUG_HTML', FALSE);
4
5 if ($_SERVER["argc"] < 3)
6         die("need at least two params Call me CreateUserFromData.php testuser opensesame.\n");
7
8
9 $user = $_SERVER["argv"][1];
10 $password = $_SERVER["argv"][1];
11 echo "----------------------- Creating User $user -------------------\n";
12 $vcardname = $user."/vcard.txt";
13 if (! is_array(stat($vcardname)))
14         die("\nCouldn't find vcard in $vcardname\n");
15         
16 $configname= $user."/config.txt";
17 if (!is_array(stat($configname)))
18         die("\nCouldn't find users config in $configname\n");
19
20
21 $vcardfh = fopen($vcardname, "r");
22 $vcard = fread($vcardfh, filesize($vcardname));
23 fclose($vcardfh);
24
25 $configfh = fopen($configname, "r");
26 $config = fread($configfh, filesize($configname));
27 fclose($configfh);
28
29
30 include "ctdlsession.php";
31 include "ctdlprotocol.php";
32 include "ctdlelements.php";
33
34 //define(CITADEL_DEBUG_HTML, FALSE);
35 establish_citadel_session();
36 create_new_user($user, $password);
37
38 ctdl_goto("My Citadel Config");
39 list($num_msgs, $response, $msgs) = ctdl_msgs("", "");
40
41 $Webcit_Preferences = array();
42 $Webcit_PrefMsgid = 0;
43 if ($num_msgs > 0) foreach ($msgs as $msgnum) {
44         print_r($msgnum);
45
46         // Fetch the message from the server
47         list($ok, $response, $fields) = ctdl_fetch_message($msgnum);
48
49         // Bail out gracefully if the message isn't there.
50         if (!$ok) {
51                 echo "Error: " . $response . "\n";
52                 return false;
53         }
54         if (isset($fields['part']))
55         {
56                 $parts = explode('|', $fields['part']);
57                 print_r($parts);
58                 if ($parts[4]=="text/x-vcard")
59                         list($size, $OldVcard) = download_attachment($msgnum, $result[2]);
60                 else
61                         ctdl_dele($msgnum);
62         }
63         else if ($fields['subj'] == "__ WebCit Preferences __")
64         {
65                 $Webcit_PrefMsgid = $msgnum;
66                 $Webcit_Preferences = $fields;
67         } 
68 }
69
70 "begin:vcard
71 n:Surename;CName;mitte;Mrs;IV
72 title:master
73 fn:CName Surename
74 org:citadel.org
75 adr:blarg;Road To nowhere ;10;Metropolis;NRW;12345;Country
76 tel;home:888888888
77 tel;work:99999999999
78 email;internet:user@samplecitadel.org
79 email;internet:me@samplecitadel.org
80 email;internet:myself@samplecitadel.org
81 email;internet:i@samplecitadel.org
82 FBURL;PREF:http://samplecitadel.org/Cname_Lastname.vfb
83 UID:Citadel vCard: personal card for Cname Lastname at samplecitadel.org
84 end:vcard
85 ";
86 $entarray=array();
87 $entarray['post']=1;
88 $entarray['format_type']=FMT_RFC822;
89 enter_message_0($entarray, "text/x-vcard; charset=UTF-8", $vcard);
90
91
92 $Webcit_Preferences=$config;
93 "
94 iconbar|ib_displayas=0,ib_logo=0,ib_summary=1,ib_inbox=1,ib_calendar=1,ib_contacts=1,ib_notes=1,ib
95 _tasks=1,ib_rooms=1,ib_users=2,ib_chat=1,ib_advanced=1,ib_logoff=0,ib_citadel=1
96 roomlistview|rooms
97 emptyfloors|yes
98 weekstart|0
99 use_sig|no
100 startpage|dotskip&room=_BASEROOM_
101 signature|
102 daystart|8
103 floordiv_expanded|
104 current_iconbar|0
105 calhourformat|24
106 dayend|17
107 ";
108
109 if ($Webcit_PrefMsgid != '0')
110 {
111         ctdl_dele($Webcit_PrefMsgid);
112         
113 }
114 $entarray=array();
115 $entarray['post']=1;
116 $entarray['format_type']=FMT_FIXED;
117 $entarray['subject'] = "__ WebCit Preferences __";
118 $entarray['anon_flag'] = '0';
119 enter_message_0($entarray,
120                 "", 
121                 "somevar|somevalue\r\n".$Webcit_Preferences);
122
123 ctdl_end_session();
124
125 ?>