* user creation commandline tool
authorWilfried Göesgens <willi@citadel.org>
Sun, 27 Jan 2008 18:31:56 +0000 (18:31 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 27 Jan 2008 18:31:56 +0000 (18:31 +0000)
* some sample data

ctdlphp/CreateUserFromData.php [new file with mode: 0644]
ctdlphp/ctdlprotocol.php
ctdlphp/testuser/config.txt [new file with mode: 0644]
ctdlphp/testuser/vcard.txt [new file with mode: 0644]

diff --git a/ctdlphp/CreateUserFromData.php b/ctdlphp/CreateUserFromData.php
new file mode 100644 (file)
index 0000000..09ca5f5
--- /dev/null
@@ -0,0 +1,125 @@
+<?PHP
+
+define('CITADEL_DEBUG_HTML', FALSE);
+
+if ($_SERVER["argc"] < 3)
+       die("need at least two params Call me CreateUserFromData.php testuser opensesame.\n");
+
+
+$user = $_SERVER["argv"][1];
+$password = $_SERVER["argv"][1];
+echo "----------------------- Creating User $user -------------------\n";
+$vcardname = $user."/vcard.txt";
+if (! is_array(stat($vcardname)))
+       die("\nCouldn't find vcard in $vcardname\n");
+       
+$configname= $user."/config.txt";
+if (!is_array(stat($configname)))
+       die("\nCouldn't find users config in $configname\n");
+
+
+$vcardfh = fopen($vcardname, "r");
+$vcard = fread($vcardfh, filesize($vcardname));
+fclose($vcardfh);
+
+$configfh = fopen($configname, "r");
+$config = fread($configfh, filesize($configname));
+fclose($configfh);
+
+
+include "ctdlsession.php";
+include "ctdlprotocol.php";
+include "ctdlelements.php";
+
+//define(CITADEL_DEBUG_HTML, FALSE);
+establish_citadel_session();
+create_new_user($user, $password);
+
+ctdl_goto("My Citadel Config");
+list($num_msgs, $response, $msgs) = ctdl_msgs("", "");
+
+$Webcit_Preferences = array();
+$Webcit_PrefMsgid = 0;
+if ($num_msgs > 0) foreach ($msgs as $msgnum) {
+       print_r($msgnum);
+
+       // Fetch the message from the server
+       list($ok, $response, $fields) = ctdl_fetch_message($msgnum);
+
+       // Bail out gracefully if the message isn't there.
+       if (!$ok) {
+               echo "Error: " . $response . "\n";
+               return false;
+       }
+       if (isset($fields['part']))
+       {
+               $parts = explode('|', $fields['part']);
+               print_r($parts);
+               if ($parts[4]=="text/x-vcard")
+                       list($size, $OldVcard) = download_attachment($msgnum, $result[2]);
+               else
+                       ctdl_dele($msgnum);
+       }
+       else if ($fields['subj'] == "__ WebCit Preferences __")
+       {
+               $Webcit_PrefMsgid = $msgnum;
+               $Webcit_Preferences = $fields;
+       } 
+}
+
+"begin:vcard
+n:Surename;CName;mitte;Mrs;IV
+title:master
+fn:CName Surename
+org:citadel.org
+adr:blarg;Road To nowhere ;10;Metropolis;NRW;12345;Country
+tel;home:888888888
+tel;work:99999999999
+email;internet:user@samplecitadel.org
+email;internet:me@samplecitadel.org
+email;internet:myself@samplecitadel.org
+email;internet:i@samplecitadel.org
+FBURL;PREF:http://samplecitadel.org/Cname_Lastname.vfb
+UID:Citadel vCard: personal card for Cname Lastname at samplecitadel.org
+end:vcard
+";
+$entarray=array();
+$entarray['post']=1;
+$entarray['format_type']=FMT_RFC822;
+enter_message_0($entarray, "text/x-vcard; charset=UTF-8", $vcard);
+
+
+$Webcit_Preferences=$config;
+"
+iconbar|ib_displayas=0,ib_logo=0,ib_summary=1,ib_inbox=1,ib_calendar=1,ib_contacts=1,ib_notes=1,ib
+_tasks=1,ib_rooms=1,ib_users=2,ib_chat=1,ib_advanced=1,ib_logoff=0,ib_citadel=1
+roomlistview|rooms
+emptyfloors|yes
+weekstart|0
+use_sig|no
+startpage|dotskip&room=_BASEROOM_
+signature|
+daystart|8
+floordiv_expanded|
+current_iconbar|0
+calhourformat|24
+dayend|17
+";
+
+if ($Webcit_PrefMsgid != '0')
+{
+       ctdl_dele($Webcit_PrefMsgid);
+       
+}
+$entarray=array();
+$entarray['post']=1;
+$entarray['format_type']=FMT_FIXED;
+$entarray['subject'] = "__ WebCit Preferences __";
+$entarray['anon_flag'] = '0';
+enter_message_0($entarray,
+               "", 
+               "somevar|somevalue\r\n".$Webcit_Preferences);
+
+ctdl_end_session();
+
+?>
\ No newline at end of file
index 6f434822a946f0c6f4e96a4ff0b2ae0f344df122..6ce5381ddf78fc51401b68ea38061819e3197c4d 100644 (file)
@@ -26,7 +26,7 @@ function dbgprintf_wrapin($string, $html)
 {
        if (!CITADEL_DEBUG_HTML){
                if ($html)
-                       debugLog("<< ".$string);
+                       debugLog("<< ".$string."\n");
        }
        else 
                printf($string);
@@ -35,7 +35,7 @@ function dbgprintf_wrapout($string, $html)
 {
        if (!CITADEL_DEBUG_HTML){
                if ($html)
-                       debugLog("<< ".$string);
+                       debugLog("<< ".$string."\n");
        }
        else
                printf($string);
@@ -786,7 +786,7 @@ function ctdl_msg4_from_server() {
                        }
                        else if (!strcasecmp($msgformat, "text/plain")) {
                                $txt .= "\r\n".$buf;
-                               $modified_ .= "<TT>" . htmlspecialchars($buf) . "</TT><BR>\n" ;
+                               $modified_txt .= "<TT>" . htmlspecialchars($buf) . "</TT><BR>\n" ;
 
                        }
                        else if (!strcasecmp($msgformat, "text/x-citadel-variformat")) {
diff --git a/ctdlphp/testuser/config.txt b/ctdlphp/testuser/config.txt
new file mode 100644 (file)
index 0000000..f39b458
--- /dev/null
@@ -0,0 +1,14 @@
+iconbar|ib_displayas=0,ib_logo=0,ib_summary=1,ib_inbox=1,ib_calendar=1,ib_contacts=1,ib_notes=1,ib
+_tasks=1,ib_rooms=1,ib_users=2,ib_chat=1,ib_advanced=1,ib_logoff=0,ib_citadel=1
+roomlistview|rooms
+emptyfloors|yes
+weekstart|0
+use_sig|no
+startpage|dotskip&room=_BASEROOM_
+signature|
+daystart|8
+floordiv_expanded|
+current_iconbar|0
+calhourformat|24
+dayend|17
+
diff --git a/ctdlphp/testuser/vcard.txt b/ctdlphp/testuser/vcard.txt
new file mode 100644 (file)
index 0000000..710aa43
--- /dev/null
@@ -0,0 +1,16 @@
+begin:vcard
+n:Surename;CName;mitte;Mrs;IV
+title:master
+fn:CName Surename
+org:citadel.org
+adr:blarg;Road To nowhere ;10;Metropolis;NRW;12345;Country
+tel;home:888888888
+tel;work:99999999999
+email;internet:user@samplecitadel.org
+email;internet:me@samplecitadel.org
+email;internet:myself@samplecitadel.org
+email;internet:i@samplecitadel.org
+FBURL;PREF:http://samplecitadel.org/Cname_Lastname.vfb
+UID:Citadel vCard: personal card for Cname Lastname at samplecitadel.org
+end:vcard
+