Changed the naming convention of the setup wizard filename
[citadel.git] / webcit / auth.c
index 656dfdc6f40a45a92e5ce953dcb8fe083487dce2..76fb13dc1dfcf0b4eb80e6d7e2bd1a59cdb6465b 100644 (file)
@@ -433,16 +433,10 @@ void do_welcome(void)
                if (!setup_wizard) {
                        int len;
                        sprintf(wizard_filename, "setupwiz.%s.%s",
-                               ctdlhost, ctdlport);
-                       len = strlen(wizard_filename);
-                       for (i=0; i<len; ++i) {
-                               if (    (wizard_filename[i]==' ')
-                                       || (wizard_filename[i] == '/')
-                               ) {
-                                       wizard_filename[i] = '_';
-                               }
-                       }
-       
+                               abs(HashLittle(ctdlhost, strlen(ctdlhost))),
+                               abs(HashLittle(ctdlport, strlen(ctdlport)))
+                       );
+
                        fp = fopen(wizard_filename, "r");
                        if (fp != NULL) {
                                fgets(buf, sizeof buf, fp);
@@ -565,33 +559,20 @@ void do_logout(void)
  */
 void monitor(void)
 {
-       wcsession *WCC = WC;
-       char buf[SIZ];
-
-       FlushStrBuf(WCC->wc_username);
-       FlushStrBuf(WCC->wc_password);
-       FlushStrBuf(WCC->wc_fullname);
-       FlushRoomlist();
-
-       serv_puts("LOUT");
-       serv_getln(buf, sizeof buf);
-       WCC->logged_in = 0;
-
-       FlushStrBuf(WCC->CurRoom.name);
+       output_headers(0, 0, 0, 0, 0, 0);
 
-       /* Calling output_headers() this way causes the cookies to be un-set */
-       output_headers(1, 0, 0, 1, 1, 0);
+       hprintf("Content-type: text/plain\r\n"
+               "Server: " PACKAGE_STRING "\r\n"
+               "Connection: close\r\n"
+       );
+       begin_burst();
 
-       wc_printf("<html><body><tt>");
-       wc_printf("<strong>WebCit monitoring screen</strong><br>\n");
-       wc_printf("Connection to Citadel server at %s:%s : %s<br>\n",
+       wc_printf("Connection to Citadel server at %s:%s : %s\r\n",
                ctdlhost, ctdlport,
                (WC->connected ? "SUCCESS" : "FAIL")
        );
-       wc_printf("</body></html>\n");
 
-       wDumpContent(2);
-       end_webcit_session();
+       wDumpContent(0);
 }
 
 
@@ -793,6 +774,7 @@ void display_reg(int during_login)
  */
 void display_changepw(void)
 {
+       wcsession *WCC = WC;
        WCTemplputParams SubTP;
        char buf[SIZ];
        StrBuf *Buf;
@@ -806,10 +788,10 @@ void display_changepw(void)
 
        FreeStrBuf(&Buf);
 
-       if (!IsEmptyStr(WC->ImportantMessage)) {
+       if (StrLength(WCC->ImportantMsg) > 0) {
                wc_printf("<span class=\"errormsg\">"
-                       "%s</span><br>\n", WC->ImportantMessage);
-               safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
+                         "%s</span><br>\n", ChrPtr(WCC->ImportantMsg));
+               FlushStrBuf(WCC->ImportantMsg);
        }
 
        serv_puts("MESG changepw");
@@ -848,13 +830,11 @@ void display_changepw(void)
  */
 void changepw(void)
 {
-       char buf[SIZ];
+       StrBuf *Line;
        char newpass1[32], newpass2[32];
 
        if (!havebstr("change_action")) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("Cancelled.  Password was not changed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("Cancelled.  Password was not changed."), -1);
                display_main_menu();
                return;
        }
@@ -863,36 +843,37 @@ void changepw(void)
        safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
 
        if (strcasecmp(newpass1, newpass2)) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("They don't match.  Password was not changed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("They don't match.  Password was not changed."), -1);
                display_changepw();
                return;
        }
 
        if (IsEmptyStr(newpass1)) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("Blank passwords are not allowed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("Blank passwords are not allowed."), -1);
                display_changepw();
                return;
        }
 
+       Line = NewStrBuf();
        serv_printf("SETP %s", newpass1);
-       serv_getln(buf, sizeof buf);
-       sprintf(WC->ImportantMessage, "%s", &buf[4]);
-       if (buf[0] == '2') {
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 0) == 2) {
                if (WC->wc_password == NULL)
-                       WC->wc_password = NewStrBufPlain(buf, -1);
+                       WC->wc_password = NewStrBufPlain(
+                               ChrPtr(Line) + 4, 
+                               StrLength(Line) - 4);
                else {
                        FlushStrBuf(WC->wc_password);
-                       StrBufAppendBufPlain(WC->wc_password,  buf, -1, 0);
+                       StrBufAppendBufPlain(WC->wc_password,  
+                                            ChrPtr(Line) + 4, 
+                                            StrLength(Line) - 4, 0);
                }
                display_main_menu();
        }
        else {
                display_changepw();
        }
+       FreeStrBuf(&Line);
 }