void Pages::oauth(Document *doc){ if(path != "/oauth/yt" && path != "/oauth/yt/unlink") return; if(!Session::user()) return doc->redirect("/login?redirect=/account"); Youtube yt(Session::user().id); if(path == "/oauth/yt"){ std::string error = cgi("error"); std::string code = cgi("code"); if (!error.empty() || code.empty()) return doc->redirect("/account"); doc->setHtml("html/bsod.tpl", "Linking your YouTube account"); if (!code.empty() && yt.link(code)){ doc->dict()->SetValue("TITLE", "Success"); doc->dict()->SetValue("MESSAGE", "Your YouTube account is now linked to your EqBeats account."); } else { doc->dict()->SetValue("TITLE", "There was a problem"); doc->dict()->SetValue("MESSAGE", "Try again in a few minutes. If it still doesn't work, drop us a note."); } } else if (path == "/oauth/yt/unlink"){ yt.unlink(); doc->redirect("/account"); } }
void spell_check_continue() { const char *filename=cgi("draftmessage"); unsigned parnum=atol(cgi("row")); unsigned pos=atol(cgi("col")); char *draftfilename; CHECKFILENAME(filename); draftfilename=maildir_find(DRAFTS, filename); if (!draftfilename) { output_form("folder.html"); return; } if (search_spell(draftfilename, parnum, pos) && *cgi("continue")) output_form("spellchk.html"); else { cgi_put("draft", cgi("draftmessage")); cgi_put("previewmsg","SPELLCHK"); output_form("newmsg.html"); } free(draftfilename); }
void sendmsg_done() { if ( *cgi("pos")) http_redirect_argss("&form=readmsg&pos=%s", cgi("pos"), ""); else if (*cgi("sendmsg")) http_redirect_argss("&form=folders&foldermsg=sent", "", ""); else http_redirect_argss("&form=folders", "", ""); }
void Pages::comment(Document *doc){ std::string sub, _sub; int tid = route("track", path, sub); int uid = route("user", path, _sub); if((tid && sub == "comment") || (uid && _sub == "comment")){ Track t(tid); User u(uid); if(!t && !u) return; bool bot = true; cgicc::form_iterator url = cgi.getElement("url"); if(url != cgi.getElements().end()) bot = !url->getValue().empty(); std::string msg = cgi("msg"); if(cgi.getEnvironment().getRequestMethod() != "POST" || msg.empty() || bot || (Session::user() && Session::nonce() != cgi("nonce"))) return doc->redirect(t ? t.url() : u.url()); Session::newNonce(); Event e; e.type = Event::Comment; e.source = Session::user() ? Session::user() : User(0, cgi("name")); e.target = u ? u : t.artist; e.track = t; e.message = msg; e.push(); Account dst = Account(e.target.id); if(dst != e.source && dst.notify){ std::string mail = (std::string) "From: EqBeats notification <*****@*****.**>\n" "Subject: EqBeats comment notification\n" "Precedence: bulk\n\n" + e.source.name + " posted a comment on " + (t ? t.title : "your user page") + ":\n\n" + e.message + "\n\n" "You can view it and answer here : " + eqbeatsUrl() + (t ? t.url() : u.url()) + "\n" "If you do not wish to recieve those notifications anymore, you can disable them here : " + eqbeatsUrl() + "/account"; sendMail(dst.email.c_str(), mail.c_str()); } doc->redirect(t ? t.url() : u.url()); } }
static const char *ispreviewmsg() { const char *p=cgi("previewmsg"); if (*p == 0) p=cgi("addressbook_to"); if (*p == 0) p=cgi("addressbook_cc"); if (*p == 0) p=cgi("addressbook_bcc"); return (p); }
void sendmsg_done() { /* by lfan, add send OK function */ if (*cgi("savedraft")) { if ( *cgi("pos")) http_redirect_argss("&form=readmsg&pos=%s", cgi("pos"), ""); else http_redirect_argss("&form=folders", "", ""); } else { if ( *cgi("pos") ) http_redirect_argss("&form=sendok&pos=%s", cgi("pos"), ""); else http_redirect_argss("&form=sendok&pos=%s", "-1", ""); } }
static void deleteAccount(Document *doc){ if(!Session::user()) return doc->redirect("/"); bool post = cgi.getEnvironment().getRequestMethod() == "POST"; if(!post || cgi("confirm") != "Delete" || Session::nonce() != cgi("nonce")){ Session::newNonce(); doc->setHtml("html/delete-account.tpl", "Account deletion"); doc->dict()->SetValue("CANCEL_URL", "/account"); } else{ Session::user().deleteAccount(); doc->redirect("/goodbye"); } }
static int spellignore(const char *word) { char buf[100]; const char *c; char *p, *q; FILE *fp=opendict("r"); if (!fp) return (0); while (fgets(buf, sizeof(buf), fp) != NULL) { if ((p=strchr(buf, '\n')) != 0) *p=0; if (strcmp(word, buf) == 0) { fclose(fp); return (1); } } fclose(fp); c=cgi("globignore"); p=malloc(strlen(c)+1); if (!p) enomem(); strcpy(p, c); for (q=p; (q=strtok(q, ":")) != 0; q=0) if (strcmp(q, word) == 0) { free(p); return (1); } return (0); }
void Pages::registration(Document *doc){ if(path != "/register") return; std::string name = cgi("name"), email = cgi("email"), pw = cgi("pw"); if(Session::user()) doc->redirect("/"); else if(cgi.getEnvironment().getRequestMethod() != "POST") form(doc); else if(name.empty()) form(doc, "Please specify a display name."); else if(email.empty()) form(doc, "Please specify an email address."); else if(!validEmail(email)) form(doc, "Invalid email address."); else if(pw.empty()) form(doc, "Please specify a password."); else if(pw != cgi("pwconf")) form(doc, "Passwords mismatch."); else{ if(DB::query("SELECT EXISTS (SELECT 1 FROM users WHERE lower(name) = lower($1) OR lower(email) = lower($2))", name, email)[0][0] == "t") return form(doc, "Sorry, name or email already in use."); DB::Result r = DB::query( "INSERT INTO users (name, password, email, registration, last_login) " "VALUES ($1, crypt($2, gen_salt('bf')), $3, 'now', 'now') " "RETURNING id", name, pw, email); if(r.empty()) return form(doc, "Erm, something went wrong. Please try again."); User u = User(number(r[0][0]), name); log("New user: "******" (" + number(u.id) + ")"); doc->addHttp("Set-Cookie: sid=" + Session::login(u) + ";Max-Age=2592000\n"); // 30 days doc->redirect(u.url() + "?welcome=1"); } }
void gpgcreate() { int linelen; const struct unicode_info *u=unicode_find(sqwebmail_content_charset); const char *newname=cgi("newname"); const char *newaddress=cgi("newaddress"); const char *newcomment=cgi("newcomment"); unsigned skl=atoi(cgi("skeylength")); unsigned ekl=atoi(cgi("ekeylength")); unsigned newexpire=atoi(cgi("newexpire")); char newexpirewhen=*cgi("newexpirewhen"); const char *passphrase, *p; if (!u) u= &unicode_ISO8859_1; if (*newname == 0 || *newaddress == 0 || strchr(newaddress, '@') == 0 || gpgbadarg(newname) || gpgbadarg(newaddress) || gpgbadarg(newcomment) || ekl < 512 || ekl > 2048 || skl < 512 || skl > 1024) { printf("%s\n", getarg("BADARGS")); return; } passphrase=cgi("passphrase"); if (strcmp(passphrase, cgi("passphrase2"))) { printf("%s\n", getarg("PASSPHRASEFAIL")); return; } for (p=passphrase; *p; p++) { if ((int)(unsigned char)*p < ' ') { printf("%s\n", getarg("PASSPHRASEFAIL")); return; } } printf("<PRE CLASS=\"gpgcreate\">"); linelen=0; gpg_genkey(GPGDIR, u, newname, newaddress, newcomment, skl, ekl, newexpire, newexpirewhen, passphrase, &dump_func, &timeout_func, &linelen); printf("</PRE>"); }
void testGetValue() { MockCgiInput input((char*)"CgiValuesTestInput.txt"); cgicc::Cgicc cgi(&input); CgiValues values(&cgi); ASSERT_STR_EQUAL_MESSAGE("Expected form value", "B", values.valueOf("A")); CPPUNIT_ASSERT_MESSAGE("Expected missing value", NULL == values.valueOf("NotInForm")); }
std::string Document::generate(){ if(getenv("EQBEATS_HTTPS")) addHttp("Strict-Transport-Security: max-age=15552000\n"); // six months if(!_redir.empty()){ if(_moved) return _http + Http::moved(_redir); else return _http + Http::redirect(_redir); } else if(dw) return _http + Http::download(dw, _attachment); if(!_content.empty()) return _http + Http::header(_mime, _code) + _content; std::string out; if(_tpl.empty()) setHtml("html/404.tpl", "404 Not Found", 404); if(_mime == "text/html" && _rootDict != _dict){ _dict->SetFilename(_tpl); _rootDict->SetValueAndShowSection("REDIRECT", path, "HAS_REDIRECT"); _rootDict->SetFormattedValue("GENERATION_TIME", "%lu µS", usecs()); _rootDict->SetFormattedValue("PID", "%d", getpid()); cache.ExpandWithData("html/page.tpl", ctemplate::STRIP_BLANK_LINES, _rootDict, NULL, &out); } else if(_mime == "application/json" && _rootDict != _dict){ addHttp("Access-Control-Allow-Origin: *\n"); if(!cgi("jsonp").empty()){ _mime = "text/javascript"; _rootDict->SetValueAndShowSection("FUNCTION", cgi("jsonp"), "JSONP"); } _dict->SetFilename(_tpl); cache.ExpandWithData("json/jsonp.tpl", ctemplate::STRIP_WHITESPACE, _rootDict, NULL, &out); } else cache.ExpandWithData(_tpl, ctemplate::STRIP_BLANK_LINES, _rootDict, NULL, &out); return _http + Http::header(_mime, _code) + out; }
int main() { char content_data[_SIZE_]={0}; if(cgi(content_data)!=0) { //cout<<falied<<endl; return -1; } char* start=content_data; char* cont[8]; int i=0; while(*start) { if(*start=='=') { cont[i++]=start+1; } else if(*start=='&') { *start='\0'; } start++; } int j=0; std::string str; for(j=0;j<i;j++) { str+="' "; str+=cont[j]; if(j==i-1) { str+="' "; } else { str+="',"; } } sql_api sql; sql.sql_connect(); sql.sql_insert(str); printf("<html>"); printf("<h1>"); printf("YES <insert success>"); printf("</h1>"); printf("</html>"); return 0; }
/** * main * @param argc * @param argv * @return */ int main(int argc, char** argv) { const std::string querystring = argv[1] ? argv[1]:""; udp::cgi::TycoCGI cgi(querystring); try { cgi.CheckParameter(); cgi.PrintHeader(); std::cout << cgi << std::endl; } catch(const udp::cgi::TycoError &e) { cgi.PrintHeader(); cgi.Print(e.what()); } catch(const std::exception &e) { std::cerr << e.what() << std::endl; } catch(...) { } return 0; }
void * client(void * sock) { int socket = (long) sock; // create a buffer to keep data from request char * buffer = (char *) malloc(BUFFER_SIZE); if (socket < 0) { exit(1); } // Receive data from client recv(socket, buffer, BUFFER_SIZE, 0); // extracting a method and a path from the first line char * method = strtok(buffer, " "); char * path = strtok(NULL, " "); printf("Socket: [%s] %s\n", method, path); char root[256] = ROOT; char url[256] = ""; strcat(url, root); strcat(url, path); int fd; if (is_file_executable(url)){ fd = cgi(url, NULL); } else { fd = open(url, O_RDONLY); } if (fd != -1){ FileReader(fd, &socket); } else { Http404Error(path, &socket); } // close the connection close(socket); }
static char *spellreplace(const char *word) { char *p, *q, *r; const char *c=cgi("globreplace"); p=malloc(strlen(c)+1); if (!p) enomem(); strcpy(p, c); for (q=p; (q=strtok(q, ":")) != 0 && (r=strtok(0, ":")) != 0; q=0) { if (strcmp(q, word) == 0) { q=malloc(strlen(r)+1); if (!q) enomem(); strcpy(q, r); free(p); return (q); } } free(p); return (0); }
static FILE *passphrasefp() { FILE *fp=NULL; const char *passphrase; passphrase=cgi("passphrase"); if (*passphrase) { fp=tmpfile(); if (fp) { fprintf(fp, "%s", passphrase); if (fflush(fp) || ferror(fp) || lseek(fileno(fp), 0L, SEEK_SET) < 0 || fcntl(fileno(fp), F_SETFD, 0) < 0) { fclose(fp); fp=NULL; } } } return (fp); }
void listrights() { maildir_aclt_list l; char buf[40]; char *owner; if (*cgi("do.update") || *cgi("delentity")) { struct maildir_info minfo; if (maildir_info_imap_find(&minfo, sqwebmail_folder, login_returnaddr()) == 0) { if (minfo.homedir) { struct maildirwatch *w; char *lock; int tryanyway; w=maildirwatch_alloc(minfo.homedir); if (!w) { maildir_info_destroy(&minfo); enomem(); return; } lock=maildir_lock(minfo.homedir, w, &tryanyway); maildir_info_destroy(&minfo); if (lock == NULL) { if (!tryanyway) { printf("%s", getarg("ACL_noaccess")); return; } } doupdate(); if (lock) { unlink(lock); free(lock); } maildirwatch_free(w); } } } if (acl_read(&l, sqwebmail_folder, &owner) < 0) { printf("%s", getarg("ACL_cantread")); return; } buf[0]=0; strncat(buf, getarg("ACL_all"), sizeof(buf)-2); acl_computeRights(&l, buf, owner); maildir_aclt_list_destroy(&l); if (owner) free(owner); if (!maildir_acl_canlistrights(buf)) { printf("%s", getarg("ACL_cantread")); return; } showrights(buf); }
void spell_show() { const char *draftmessage=cgi("draftmessage"); struct ispell_misspelled *msp; struct ispell_suggestion *isps; size_t p, l=strlen(ispellline), n; const char *ignorelab=getarg("IGNORE"); const char *ignorealllab=getarg("IGNOREALL"); const char *replacelab=getarg("REPLACE"); const char *replacealllab=getarg("REPLACEALL"); const char *insertlab=getarg("INSERT"); const char *continuelab=getarg("CONTINUE"); const char *finishlab=getarg("FINISH"); if (!ispellptr) enomem(); if (!ignorelab) ignorelab=""; if (!ignorealllab) ignorealllab=""; if (!replacelab) replacelab=""; if (!replacealllab) replacealllab=""; if (!continuelab) continuelab=""; if (!finishlab) finishlab=""; for (msp=ispellptr->first_misspelled; msp; msp=msp->next) if (msp->misspelled_word) break; if (!msp) enomem(); CHECKFILENAME(draftmessage); printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"spellchk\">\n"); printf("<INPUT TYPE=HIDDEN NAME=pos VALUE=\"%s\">\n", cgi("pos")); if (*cgi("globignore")) { printf("<INPUT TYPE=HIDDEN NAME=globignore VALUE=\""); output_attrencoded(cgi("globignore")); printf("\">\n"); } if (*cgi("globreplace")) { printf("<INPUT TYPE=HIDDEN NAME=globreplace VALUE=\""); output_attrencoded(cgi("globreplace")); printf("\">\n"); } printf("<INPUT TYPE=HIDDEN NAME=draftmessage VALUE=\""); output_attrencoded(draftmessage); printf("\">"); printf("<INPUT TYPE=HIDDEN NAME=row VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=col VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=word VALUE=\"", (unsigned)paragraph, (unsigned)msp->word_pos); output_attrencoded(msp->misspelled_word); printf("\"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 " "CLASS=\"box-small-outer\"><TR><TD>"); printf("<TABLE BORDER=0 CELLSPACING=0 CLASS=\"spellcheck-background\"><TR><TD>"); printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=8 CLASS=\"spellcheck-excerpt\"><TR><TD ALIGN=CENTER><TT><FONT COLOR=\"#000000\" class=\"spellcheck-excerpt\">"); if (msp->word_pos > 30) { p=msp->word_pos-30; for (n=p; n<msp->word_pos; n++) if (ispellline[n] == ' ') { while (n < p && ispellline[n] == ' ') ++n; p=n; break; } printf("... "); } else p=0; filter_start(FILTER_FOR_DISPLAY, &showfunc); filter(ispellline+p, msp->word_pos-p); filter_end(); printf("<B>"); filter_start(FILTER_FOR_DISPLAY, &showfunc); filter(ispellline+msp->word_pos, strlen(msp->misspelled_word)); filter_end(); printf("</B>"); p=msp->word_pos+strlen(msp->misspelled_word); if (l-p < 30) { n=l-p; } else n=30; while (n) { if (ispellline[n+p] != ' ') { --n; continue; } while (n && ispellline[n+p-1] == ' ') --n; break; } filter_start(FILTER_FOR_DISPLAY, &showfunc); filter(ispellline+p, n); filter_end(); if (n != l-p) printf(" ..."); printf("</FONT></TT></TD></TR></TABLE><BR>"); printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-main\"><TR><TD>"); printf("<TABLE BORDER=0><TR><TD>"); for (isps=msp->first_suggestion; isps; isps=isps->next) { printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"%s\"></TD><TD>%s</TD></TR>\n", replacelab, isps->suggested_word, isps->suggested_word); replacelab=" "; } printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#other\"></TD><TD><INPUT TYPE=TEXT NAME=OTHER WIDTH=20></TD></TR>\n", replacelab); printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#insert\"></TD><TD>%s</TD></TR>\n", insertlab); printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=CHECKBOX NAME=REPLACEALL></TD><TD>%s</TD></TR>\n", replacealllab); printf("<TR><TD> </TD><TD COLSPAN=2><HR WIDTH=\"100%%\"></TD></TR>\n"); printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignore\"></TD><TD>%s</TD></TR>\n", ignorelab); printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignoreall\"></TD><TD>%s</TD></TR>\n", ignorealllab); printf("</TABLE>"); printf("</TD></TR></TABLE><BR>"); printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-continue\"><TR><TD>"); printf("<INPUT TYPE=SUBMIT NAME=\"continue\" VALUE=\"%s\">\n", continuelab); printf("<INPUT TYPE=SUBMIT NAME=\"finish\" VALUE=\"%s\">\n", finishlab); printf("</TD></TR></TABLE>\n"); printf("</TD></TR></TABLE>\n"); printf("</TD></TR></TABLE>\n"); }
void spell_show() { const char *draftmessage=cgi("draftmessage"); struct ispell_misspelled *msp; struct ispell_suggestion *isps; size_t p, l=strlen(ispellline), n; const char *ignorelab=getarg("IGNORE"); const char *ignorealllab=getarg("IGNOREALL"); const char *replacelab=getarg("REPLACE"); const char *replacealllab=getarg("REPLACEALL"); const char *insertlab=getarg("INSERT"); const char *continuelab=getarg("CONTINUE"); const char *finishlab=getarg("FINISH"); if (!ispellptr) enomem(); if (!ignorelab) ignorelab=""; if (!ignorealllab) ignorealllab=""; if (!replacelab) replacelab=""; if (!replacealllab) replacealllab=""; if (!continuelab) continuelab=""; if (!finishlab) finishlab=""; for (msp=ispellptr->first_misspelled; msp; msp=msp->next) if (msp->misspelled_word) break; if (!msp) enomem(); CHECKFILENAME(draftmessage); printf("<input type=\"hidden\" name=\"form\" value=\"spellchk\" />\n"); printf("<input type=\"hidden\" name=\"pos\" value=\"%s\" />\n", cgi("pos")); if (*cgi("globignore")) { printf("<input type=\"hidden\" name=\"globignore\" value=\""); output_attrencoded(cgi("globignore")); printf("\" />\n"); } if (*cgi("globreplace")) { printf("<input type=\"hidden\" name=\"globreplace\" value=\""); output_attrencoded(cgi("globreplace")); printf("\" />\n"); } printf("<input type=\"hidden\" name=\"draftmessage\" value=\""); output_attrencoded(draftmessage); printf("\" />"); printf("<input type=\"hidden\" name=\"row\" value=\"%u\" /><input type=\"hidden\" name=\"col\" value=\"%u\" /><input type=\"hidden\" name=\"word\" value=\"", (unsigned)paragraph, (unsigned)msp->word_pos); output_attrencoded(msp->misspelled_word); printf("\" /><table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" " "class=\"box-small-outer\"><tr><td>"); printf("<table border=\"0\" cellspacing=\"0\" class=\"spellcheck-background\"><tr><td>"); printf("<table border=\"1\" cellspacing=\"0\" cellpadding=\"8\" class=\"spellcheck-excerpt\"><tr><td align=\"center\"><span style=\"color: #000000\" class=\"spellcheck-excerpt\">"); if (msp->word_pos > 30) { p=msp->word_pos-30; for (n=p; n<msp->word_pos; n++) if (ispellline[n] == ' ') { while (n < p && ispellline[n] == ' ') ++n; p=n; break; } printf("... "); } else p=0; show_part(ispellline+p, msp->word_pos-p); printf("<strong>"); show_part(ispellline+msp->word_pos, strlen(msp->misspelled_word)); printf("</strong>"); p=msp->word_pos+strlen(msp->misspelled_word); if (l-p < 30) { n=l-p; } else n=30; while (n) { if (ispellline[n+p] != ' ') { --n; continue; } while (n && ispellline[n+p-1] == ' ') --n; break; } show_part(ispellline+p, n); if (n != l-p) printf(" ..."); printf("</span></td></tr></table><br />"); printf("<table border=\"1\" cellpadding=\"8\" class=\"spellcheck-main\"><tr><td>"); printf("<table border=\"0\">"); for (isps=msp->first_suggestion; isps; isps=isps->next) { printf("<tr><td>%s</td><td><input type=\"radio\" name=\"REPLACE\" value=\"%s\" /></td><td>%s</td></tr>\n", replacelab, isps->suggested_word, isps->suggested_word); replacelab=" "; } printf("<tr><td>%s</td><td><input type=\"radio\" name=\"REPLACE\" value=\"#other\" /></td><td><input type=\"text\" name=\"OTHER\" size=\"20\" /></td></tr>\n", replacelab); printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#insert\" /></td><td>%s</td></tr>\n", insertlab); printf("<tr><td> </td><td><input type=\"checkbox\" name=\"REPLACEALL\" /></td><td>%s</td></tr>\n", replacealllab); printf("<tr><td> </td><td colspan=\"2\"><hr width=\"100%%\" /></td></tr>\n"); printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#ignore\" /></td><td>%s</td></tr>\n", ignorelab); printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#ignoreall\" /></td><td>%s</td></tr>\n", ignorealllab); printf("</table>"); printf("</td></tr></table><br />"); printf("<table border=\"1\" cellpadding=\"8\" class=\"spellcheck-continue\"><tr><td>"); printf("<input type=\"submit\" name=\"continue\" value=\"%s\" />\n", continuelab); printf("<input type=\"submit\" name=\"finish\" value=\"%s\" />\n", finishlab); printf("</td></tr></table>\n"); printf("</td></tr></table>\n"); printf("</td></tr></table>\n"); }
void newmsg_do(const char *folder) { const char *draftmessage=cgi("draftmessage"); if (*draftmessage) /* It's ok if it's blank */ { CHECKFILENAME(draftmessage); } if (*cgi("savedraft")) { char *newdraft=newmsg_createdraft(draftmessage); if (!newdraft) enomem(); free(newdraft); sendmsg_done(); return; } if (*cgi("sendmsg") && dosendmsg(draftmessage)) return; if (*cgi("doattachments")) { char *newdraft=newmsg_createdraft(draftmessage); char *base; if (!newdraft) enomem(); if (*cgi("error")) { cgi_put("previewmsg", "1"); output_form("newmsg.html"); return; } base=maildir_basename(newdraft); http_redirect_argss("&form=attachments&pos=%s&draft=%s", cgi("pos"), base); free(base); free(newdraft); return; } #ifdef ISPELL if (*cgi("startspellchk")) { char *newdraft=newmsg_createdraft(draftmessage); char *base; if (!newdraft) enomem(); base=maildir_basename(newdraft); free(newdraft); if (spell_start(base) == 0) { cgi_put("draftmessage", base); output_form("spellchk.html"); } else { http_redirect_argss("&form=newmsg&pos=%s&draft=%s&previewmsg=SPELLCHK", cgi("pos"), base); } free(base); return; } #endif if (*ispreviewmsg()||cgi("return")) { output_form("newmsg.html"); return; } http_redirect_argsss("&form=newmsg&pos=%s&draftmessage=%s&error=%s", cgi("pos"), draftmessage, cgi("error")); }
static int dosendmsg(const char *origdraft) { pid_t pid; const char *returnaddr; int pipefd1[2]; char *filename; const char *line; char *draftmessage; int isgpgerr; unsigned long filesize; struct stat stat_buf; int dsn; if (tokencheck()) /* Duplicate submission - message was already sent */ { sendmsg_done(); return (1); } if (strcmp(cgi("form"), "doattach") == 0) { /* When called from the attachment window, we do NOT create ** a new draft message */ draftmessage=strdup(origdraft); } else draftmessage=newmsg_createdraft(origdraft); if (!draftmessage) enomem(); filename=newmsg_createsentmsg(draftmessage, &isgpgerr, 1); if (!filename) { char *draftbase=maildir_basename(draftmessage); if (isgpgerr) { cgi_put("draftmessage", draftbase); output_form("gpgerr.html"); } else { http_redirect_argss("&form=newmsg&pos=%s" "&draft=%s&error=quota", cgi("pos"), draftbase); } free(draftmessage); free(draftbase); return (1); } if (pipe(pipefd1) != 0) { cgi_put("foldermsg", "ERROR: pipe() failed."); maildir_msgpurgefile(SENT, filename); free(filename); free(draftmessage); return (0); } returnaddr=login_returnaddr(); dsn= *cgi("dsn") != 0; pid=fork(); if (pid < 0) { cgi_put("foldermsg", "ERROR: fork() failed."); close(pipefd1[0]); close(pipefd1[1]); maildir_msgpurgefile(SENT, filename); free(filename); free(draftmessage); return (0); } if (pid == 0) { static const char noexec[]="ERROR: Unable to execute sendit.sh.\n"; static const char nofile[]="ERROR: Temp file not available - probably exceeded quota.\n"; char *tmpfile=maildir_find(SENT, filename); int fd; if (!tmpfile) { fwrite((char*)nofile, 1, sizeof(nofile)-1, stderr); _exit(1); } close(0); fd=maildir_safeopen(tmpfile, O_RDONLY, 0); close(1); close(2); dup(pipefd1[1]); dup(pipefd1[1]); close(pipefd1[0]); close(pipefd1[1]); if (dsn) putenv("DSN=-Nsuccess,delay,fail"); else putenv("DSN="); if (fd == 0) execl(SENDITSH, "sendit.sh", returnaddr, sqwebmail_mailboxid, NULL); fwrite(noexec, 1, sizeof(noexec)-1, stderr); _exit(1); } close(pipefd1[1]); line=geterrbuf(pipefd1[0]); close(pipefd1[0]); if (waitfor(pid)) { if (!*line) line="Unable to send message.\n"; } else line=""; if (*line == 0) /* Succesfully sent message */ { if (*draftmessage) { char *base=maildir_basename(draftmessage); char *draftfile=maildir_find(DRAFTS, base); free(base); /* Remove draft file */ if (draftfile) { char *replytofolder=0, *replytomsg=0; char *header, *value; FILE *fp; int x; fp=0; x=maildir_safeopen(draftfile, O_RDONLY, 0); if ( maildir_parsequota(draftfile, &filesize)) { if (x < 0 || fstat(x, &stat_buf)) stat_buf.st_size=0; filesize=stat_buf.st_size; } if (x >= 0) if ((fp=fdopen(x, "r")) == 0) close(x); /* First, look for a message that we should ** mark as replied */ while (fp && (header=maildir_readheader(fp, &value, 0)) != 0) { if (strcmp(header,"x-reply-to-folder") == 0 && !replytofolder) { replytofolder=strdup(value); if (!replytofolder) enomem(); } if (strcmp(header,"x-reply-to-msg") == 0 && !replytomsg) { replytomsg=strdup(value); if (!replytomsg) enomem(); } if (replytofolder && replytomsg) break; } if (fp) fclose(fp); if (replytofolder && replytomsg) maildir_markreplied(replytofolder, replytomsg); if (replytofolder) free(replytofolder); if (replytomsg) free(replytomsg); maildir_quota_deleted(".", -(long)filesize, -1); unlink(draftfile); free(draftfile); } } tokensave(); if (*cgi("fcc") == 0) { unsigned long filesize=0; char *tmpfile=maildir_find(SENT, filename); if (tmpfile) { maildir_parsequota(tmpfile, &filesize); unlink(tmpfile); maildir_quota_deleted(".", -(long)filesize,-1); free(tmpfile); } } free(filename); free(draftmessage); sendmsg_done(); return (1); } if (stat(filename, &stat_buf) == 0) maildir_quota_deleted(".", -(long)stat_buf.st_size, -1); maildir_msgpurgefile(SENT, filename); free(filename); { char *draftbase=maildir_basename(draftmessage); http_redirect_argsss("&form=newmsg&pos=%s&draft=%s&foldermsg=%s", cgi("pos"), draftbase, line); free(draftmessage); free(draftbase); } return (1); }
static void doupdate() { maildir_aclt_list l; char *owner; char buf[2]; char *p; struct maildir_info minfo; if (maildir_info_imap_find(&minfo, sqwebmail_folder, login_returnaddr()) < 0) return; if (acl_read2(&l, &minfo, &owner) < 0) { maildir_info_destroy(&minfo); return; } strcpy(buf, ACL_ADMINISTER); acl_computeRights(&l, buf, owner); if (!*buf) { if (owner) free(owner); maildir_aclt_list_destroy(&l); maildir_info_destroy(&minfo); return; } if (*cgi("delentity")) { if (maildir_aclt_list_del(&l, cgi("delentity"))) printf("%s", getarg("ACL_failed")); } if (*cgi("do.update")) { char *entity=NULL; const char *p; char new_acl[40]; p=cgi("entitytype"); if (strcmp(p, "anonymous") == 0 || strcmp(p, "owner") == 0) entity=strdup(p); else if (strcmp(p, "user") == 0) { p=cgi("entity"); if (*p) { entity=malloc(sizeof("user="******"user="******"group") == 0) { p=cgi("entity"); if (*p) { entity=malloc(sizeof("group=")+strlen(p)); if (entity) strcat(strcpy(entity, "group="), p); } } else { entity=strdup(cgi("entity")); } if (*cgi("negate") == '-' && entity) { char *p=malloc(strlen(entity)+2); if (p) strcat(strcpy(p, "-"), entity); free(entity); entity=p; } if (entity) { char *val= unicode_convert_toutf8(entity, sqwebmail_content_charset, NULL); if (val) { free(entity); entity=val; } } p=getarg("ACL_all"); new_acl[0]=0; while (*p && strlen(new_acl) < sizeof(new_acl)-2) { char b[40]; sprintf(b, "acl_%c", *p); if (*cgi(b)) { b[0]=*p; b[1]=0; strcat(new_acl, b); } ++p; } if (!entity || !*entity || maildir_aclt_list_add(&l, entity, new_acl, NULL) < 0) printf("%s", getarg("ACL_failed")); if (entity) free(entity); } p=maildir_name2dir(".", minfo.maildir); if (p) { const char *err_ident; if (maildir_acl_write(&l, minfo.homedir, strncmp(p, "./", 2) == 0 ? p+2:p, owner, &err_ident)) printf("%s", getarg("ACL_failed")); free(p); } if (owner) free(owner); maildir_aclt_list_destroy(&l); maildir_info_destroy(&minfo); }
int http_get(struct httpd * httpd, struct httpctl * ctl) { int (* cgi)(struct tcp_pcb * tp); char buf[128]; // int content_type; // int content_len; // char * opt; char * ext; struct stat sb; int type; int hash; int size; int ret; int fd; int n; strcpy(buf, httpd->root); strcat(buf, ctl->uri); // for (opt = buf; (*opt); opt++) { // if (*opt == '?') { // *opt++ = '\0'; // break; // } // } DBG(DBG_INFO, "path=%s", buf); if ((ret = stat(buf, &sb)) < 0) { DBG(DBG_ERROR, "404 File Not Found"); httpd_404(ctl->tp); return ret; } if (S_ISDIR(sb.st_mode)) { DBG(DBG_INFO, "is a directory"); strcat(buf, "/"); strcat(buf, httpd_page_default); if ((ret = stat(buf, &sb)) < 0) { strcpy(buf, httpd->root); strcat(buf, ctl->uri); return httpd_dirlist(httpd, ctl); } } if (!S_ISREG(sb.st_mode)) { DBG(DBG_ERROR, "403 Forbidden"); httpd_403(ctl->tp); return -1; } if ((fd = open(buf, O_RDONLY)) < 0) { DBG(DBG_ERROR, "404 File Not Found"); httpd_404(ctl->tp); return -1; } ret = 0; if ((ext = strrchr(buf, '.')) != NULL) { DBG(DBG_INFO, "extension=%s", ext); /* skip the '.' */ ext++; hash = mk_ext_hash(ext); switch (hash) { case EXT_CGI: DBG(DBG_INFO, "cgi"); goto dynamic_cgi; case EXT_TXT: DBG(DBG_INFO, "text"); type = text_plain; break; case EXT_JPEG: case EXT_JPG: DBG(DBG_INFO, "jpeg"); type = image_jpeg; break; case EXT_ICO: DBG(DBG_INFO, "ico"); case EXT_GIF: DBG(DBG_INFO, "gif"); type = image_gif; break; case EXT_PNG: DBG(DBG_INFO, "png"); type = image_png; break; case EXT_JS: DBG(DBG_INFO, "js"); type = application_x_javascript; break; case EXT_HTML: case EXT_HTM: DBG(DBG_INFO, "html"); default: type = text_html; break; } httpd_200(ctl->tp, type); while ((n = read(fd, buf, 128)) > 0) { if (tcp_send(ctl->tp, buf, n, 0) <= 0) { DBG(DBG_ERROR, "tcp_send()"); ret = -1; break; } } } else { dynamic_cgi: size = lseek(fd, 0, SEEK_END); DBG(DBG_TRACE, "size=%d", size); cgi = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); DBG(DBG_TRACE, "cgi=%p", cgi); ret = cgi(ctl->tp); } close(fd); #if 0 DBG(DBG_INFO, "file uid=%d", info.fi_uid); if (info.fi_uid < __httpd->uid) { unsigned int uid; DBG(DBG_INFO, "info.fi_uid=%d < httpd->uid=%d, auth required", info.fi_uid, __httpd->uid); uid = httpd_auth(__http->httpd, __http->usr, __http->pwd); if (info.fi_uid < uid) { DBG(DBG_ERROR, "401 Unauthorized, uid=%d", uid); httpd_401_auth(__tp); return -1; } } content_type = __http->ctype; content_len = __http->ctlen; if (info.fi_mime != _code_) { /* detach the PCB */ tcp_attach(__tp, NULL, __httpd); /* release the control structure */ httpd_free(__httpd, __http); httpd_send(__tp, info.fi_mime, (char *)info.fi_data, info.fi_size); tcp_close(__tp); return 0; } /* dynamic cgi */ DBG(DBG_INFO, "dynamic page"); cgi_call = (httpd_cgi_t)info.fi_data; /* reuse the allocated buffer */ cgi = (struct cgistate *)__http; /* XXX: */ cgi->httpd = __httpd; cgi->callback = NULL; /* attach the PCB to the CGI handler */ tcp_attach(__tp, (tcp_callback_t)httpd_cgi_handler, cgi); if (cgi_call(__tp, opt, content_type, content_len) < 0) { /* close the tcp pcb */ tcp_close(__tp); } else { /* if the CGI is still detached, close-it */ if (cgi->callback == NULL) tcp_close(__tp); } #endif return ret; }
char *newmsg_newdraft(const char *folder, const char *pos, const char *forwardsep, const char *replysalut) { char *filename=0; char *replymode; size_t pos_n; FILE *fp; const char *mimeidptr; char *draftfilename; struct rfc2045 *rfc2045p, *rfc2045partp; int x; if (*cgi(replymode="reply") || *cgi(replymode="replyall") || *cgi(replymode="replylist") || *cgi(replymode="forward") || *cgi(replymode="forwardatt")) { pos_n=atol(pos); filename=get_msgfilename(folder, &pos_n); } if (!filename) return (0); fp=0; x=maildir_semisafeopen(filename, O_RDONLY, 0); if (x >= 0) if ((fp=fdopen(x, "r")) == 0) close(x); if (fp == 0) { free(filename); return (0); } rfc2045p=rfc2045_fromfp(fp); if (!rfc2045p) { fclose(fp); enomem(); } mimeidptr=cgi("mimeid"); rfc2045partp=0; if (*mimeidptr) { rfc2045partp=rfc2045_find(rfc2045p, mimeidptr); if (rfc2045partp) { const char *content_type, *dummy; rfc2045_mimeinfo(rfc2045partp, &content_type, &dummy, &dummy); if (!content_type || strcmp(content_type, "message/rfc822")) rfc2045partp=0; else rfc2045partp=rfc2045partp->firstpart; } } if (!rfc2045partp) rfc2045partp=rfc2045p; draftfd=maildir_createmsg(DRAFTS, 0, &draftfilename); if (draftfd < 0) { fclose(fp); rfc2045_free(rfc2045p); enomem(); } maildir_writemsgstr(draftfd, "From: "); { const char *f=pref_from; if (!f || !*f) f=login_fromhdr(); if (!f) f=""; maildir_writemsgstr(draftfd, f); maildir_writemsgstr(draftfd, "\n"); } { char *ml=getmailinglists(); struct rfc2045_mkreplyinfo ri; int rc; memset(&ri, 0, sizeof(ri)); ri.fd=fileno(fp); ri.rfc2045partp=rfc2045partp; ri.replymode=replymode; ri.replysalut=replysalut; ri.forwardsep=forwardsep; ri.myaddr_func=ismyaddr; ri.write_func=writefunc; ri.writesig_func=newmsg_writesig; ri.mailinglists=ml; ri.charset=sqwebmail_content_charset; if (strcmp(replymode, "forward") == 0 || strcmp(replymode, "forwardatt") == 0) { #if HAVE_SQWEBMAIL_UNICODE rc=rfc2045_makereply_unicode(&ri); #else rc=rfc2045_makereply(&ri); #endif } else { char *basename=maildir_basename(filename); maildir_writemsgstr(draftfd, "X-Reply-To-Folder: "); maildir_writemsgstr(draftfd, folder); maildir_writemsgstr(draftfd, "\nX-Reply-To-Msg: "); maildir_writemsgstr(draftfd, basename); free(basename); maildir_writemsgstr(draftfd, "\n"); #if HAVE_SQWEBMAIL_UNICODE rc=rfc2045_makereply_unicode(&ri); #else rc=rfc2045_makereply(&ri); #endif } free(ml); if (rc) { fclose(fp); close(draftfd); rfc2045_free(rfc2045p); enomem(); } } fclose(fp); if (maildir_closemsg(draftfd, DRAFTS, draftfilename, 1, 0)) { free(draftfilename); draftfilename=0; cgi_put("error", "quota"); } free(filename); rfc2045_free(rfc2045p); return(draftfilename); }
static int search_spell(const char *filename, unsigned parnum, unsigned pos) { struct rfc2045 *rfcp, *textp; struct buf newtext, current_line; off_t start_pos, end_pos, start_body; int made_replacements, has_misspelling; char *new_line; unsigned paragraph; const char *ignoreword=""; const char *replacefrom=""; const char *replaceto=""; int checked=0; off_t dummy; FILE *fp=0; int x; x=maildir_safeopen(filename, O_RDONLY, 0); if (x >= 0) if ((fp=fdopen(x, "r")) == 0) close(x); if (!fp) return (0); rfcp=rfc2045_fromfp(fp); if (!rfcp) enomem(); textp=findtext(rfcp); if (!textp) { rfc2045_free(rfcp); fclose(fp); return (0); } buf_init(&newtext); buf_init(¤t_line); rfc2045_mimepos(textp, &start_pos, &end_pos, &start_body, &dummy, &dummy); if (fseek(fp, start_body, SEEK_SET) == -1) enomem(); made_replacements=0; has_misspelling=0; paragraph=0; for ( ; start_body < end_pos; start_body++) { int c=getc(fp); if (c < 0) enomem(); if (c != '\n') { buf_append(¤t_line, c); continue; } buf_append(¤t_line, '\0'); if (parnum) { --parnum; buf_cat(&newtext, current_line.ptr); buf_cat(&newtext, "\n"); current_line.cnt=0; ++paragraph; continue; } if (!checked) { int l; checked=1; if ((l=strlen(cgi("word"))) > 0) { /* Ok, what should we do? */ const char *newword=cgi("REPLACE"); if (!*newword || strcmp(newword, "#other") == 0) newword=cgi("OTHER"); /* ** Perhaps they entered the word without ** checking this checkmark. */ else if (*newword == '#') newword=""; if (*newword && pos + l <= strlen(current_line.ptr)) { struct buf tempbuf; buf_init(&tempbuf); buf_cpyn(&tempbuf, current_line.ptr, pos); buf_cat(&tempbuf, newword); buf_cat(&tempbuf, current_line.ptr+pos+l); pos += strlen(newword); if (*cgi("REPLACEALL")) { replacefrom=cgi("word"); replaceto=newword; } buf_append(&tempbuf, '\0'); buf_cpy(¤t_line, tempbuf.ptr); buf_append(¤t_line, '\0'); buf_free(&tempbuf); made_replacements=1; } else { pos += l; if (strcmp(cgi("REPLACE"), "#ignoreall") == 0) ignoreword=cgi("word"); } if (strcmp(cgi("REPLACE"), "#insert") == 0) { spelladd(cgi("word")); } } } if (*current_line.ptr == '>') { buf_cat(&newtext, current_line.ptr); buf_cat(&newtext, "\n"); pos=0; current_line.cnt=0; ++paragraph; continue; } if (!has_misspelling) { new_line=spell_check(current_line.ptr, paragraph, pos, ignoreword, replacefrom, replaceto, &has_misspelling); if (new_line) { buf_cat(&newtext, new_line); free(new_line); made_replacements=1; } else buf_cat(&newtext, current_line.ptr); } else buf_cat(&newtext, current_line.ptr); buf_cat(&newtext, "\n"); pos=0; current_line.cnt=0; ++paragraph; } if (current_line.cnt) buf_cat(&newtext, "\n"); rfc2045_free(rfcp); fclose(fp); if (made_replacements) { char *p=newmsg_createdraft_do(filename, newtext.ptr, NEWMSG_SQISPELL); if (p) free(p); if (*cgi("error")) { has_misspelling=0; /* Abort spell checking */ } } buf_free(&newtext); buf_free(¤t_line); if (*ignoreword) { static char *p=0; if (p) free(p); p=malloc(strlen(cgi("globignore")) + 2 + strlen(ignoreword)); if (!p) enomem(); strcpy(p, cgi("globignore")); if (*p) strcat(p, ":"); strcat(p, ignoreword); cgi_put("globignore", p); } if (*replacefrom) { static char *p=0; if (p) free(p); p=malloc(strlen(cgi("globreplace"))+3 +strlen(replacefrom)+strlen(replaceto)); if (!p) enomem(); strcpy(p, cgi("globreplace")); if (*p) strcat(p, ":"); strcat(strcat(strcat(p, replacefrom), ":"), replaceto); cgi_put("globreplace", p); free(p); } if (has_misspelling) return (1); return (0); }
void Pages::track(Document *doc){ std::string sub; int tid = route("track", path, sub); bool post = cgi.getEnvironment().getRequestMethod() == "POST"; if(!tid) return; if(sub == ""){ ExtendedTrack t(tid); if(!t) return; doc->setHtml("html/track.tpl", t.title); doc->rootDict()->SetValueAndShowSection("TID", number(t.id), "HAS_OEMBED"); t.fill(doc->dict()); t.player(doc->dict(), true); Audio(&t).fill(doc->dict()); doc->dict()->ShowSection(Youtube(t.artist.id) ? "HAS_YOUTUBE" : "NO_YOUTUBE"); Dict *embed = doc->dict()->AddIncludeDictionary("EMBED_CODE"); embed->SetFilename("html/embed-code.tpl"); embed->SetIntValue("WIDTH", 150); t.Track::fill(embed); Dict *uploader = doc->dict()->AddIncludeDictionary("UPLOADER"); uploader->SetFilename("html/uploader.tpl"); uploader->SetValue("ACTION", t.url() + "/upload"); int hits = Stat::push("trackView", t.artist.id, tid); doc->dict()->SetValue("HIT_COUNT", number(hits)); int unique_hits = Stat::get("trackView", 0, tid, true); doc->dict()->SetValue("UNIQUE_HIT_COUNT", number(unique_hits)); doc->rootDict()->ShowSection("REQUIRES_STATS_JS"); Session::fill(doc->dict()); EventList::track(t).fill(doc->dict(), "EVENTS", false); doc->dict()->ShowSection(Follower(Session::user().id).favorited(tid) ? "IS_FAVORITE" : "NOT_FAVORITE"); if(Session::user()){ DB::Result playlists = DB::query( "SELECT id, name FROM playlists WHERE user_id = " + number(Session::user().id) + " ORDER BY name ASC"); if(!playlists.empty()){ doc->dict()->ShowSection("HAS_PLAYLISTS"); for(DB::Result::const_iterator i=playlists.begin(); i!=playlists.end(); i++){ Dict *playlist = doc->dict()->AddSectionDictionary("PLAYLIST"); playlist->SetValue("PLAYLIST_ID", i->at(0)); playlist->SetValue("PLAYLIST_NAME", i->at(1)); } } } } else if(sub == "delete"){ Track t(tid); if(!t) return; if(!t.artist.self()) doc->redirect(t.url()); else if(!post || cgi("confirm") != "Delete" || Session::nonce() != cgi("nonce")){ Session::newNonce(); doc->setHtml("html/delete.tpl", "Track deletion"); doc->dict()->SetValue("WHAT", t.title); doc->dict()->SetValue("CANCEL_URL", t.url()); } else{ log("Deleting track: " + t.title + " (" + number(t.id) + ")"); Art art(t.id); if(art) art.remove(); Audio(&t).unlink(); Playlist::removeTrack(t.id); DB::query("DELETE FROM events WHERE track_id = " + number(t.id)); DB::query("DELETE FROM featured_tracks WHERE track_id = " + number(t.id)); DB::query("DELETE FROM favorites WHERE type = 'track' AND ref = " + number(t.id)); DB::query("DELETE FROM user_features WHERE type = 'track' AND ref = " + number(t.id)); DB::query("DELETE FROM tracks WHERE id = " + number(t.id)); doc->redirect(Session::user().url()); } } else if(sub == "publish"){ Track t(tid); if(!t) return; if(tid != number(cgi("tid"))) return doc->redirect(t.url()); if(t.artist.self() && !t.visible && post){ DB::query("UPDATE tracks SET visible = 't', date = 'now' WHERE id = " + number(t.id)); Event e; e.type = Event::Publish; e.source = t.artist; e.track = t; e.push(); std::vector<std::string> emails = Follower(t.artist.id).followers(); std::string maildata = "From: EqBeats notification <*****@*****.**>\n" "Message-ID: notify-t" + number(t.id) + "\n" "Subject: " + filter("EqBeats notification: " + t.artist.name + " - " + t.title) + "\n" "Precedence: bulk\n\n" + t.artist.name + " just published a new track : " + t.title + "\n" "Listen to it here : " + eqbeatsUrl() + t.url() + "\n\n" "You're receiving this email because you're following " + t.artist.name + " on EqBeats.\n" "If you don't want to receive these notifications anymore, go to " + eqbeatsUrl() + t.artist.url() + " and click \"Stop following\"."; for(std::vector<std::string>::const_iterator i = emails.begin(); i!=emails.end(); i++) sendMail(i->c_str(), maildata.c_str()); } doc->redirect(t.url()); } }
void newmsg_init(const char *folder, const char *pos) { const char *tolab=getarg("TOLAB"); const char *cclab=getarg("CCLAB"); const char *bcclab=getarg("BCCLAB"); const char *subjectlab=getarg("SUBJECTLAB"); const char *messagelab=getarg("MESSAGELAB"); const char *sendlab=getarg("SENDLAB"); const char *previewlab=getarg("PREVIEWLAB"); const char *forwardsep=getarg("FORWARDLAB"); const char *savedraft=getarg("SAVEDRAFT"); const char *uploadlab=getarg("UPLOAD"); const char *attachedlab=getarg("ATTACHMENTS"); const char *replysalutation=getarg("SALUTATION"); const char *checkspellingdone=getarg("SPELLCHECKDONE"); const char *checkspelling=getarg("CHECKSPELLING"); const char *quotaerr=getarg("QUOTAERR"); const char *fromlab=getarg("FROMLAB"); const char *replytolab=getarg("REPLYTOLAB"); const char *addressbooklab=getarg("ADDRESSBOOK"); char *draftmessage; char *draftmessagefilename; const char *p; FILE *fp; int attachcnt=0; char *cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto; /* Picking up an existing draft? */ p=cgi("draft"); if (*p) { CHECKFILENAME(p); } if (*p) { draftmessage=strdup(p); if (!draftmessage) enomem(); p=""; } else { draftmessage=newmsg_newdraft(folder, pos, forwardsep, replysalutation); if (!draftmessage) { if (*ispreviewmsg()) { p=cgi("draftmessage"); if (*p) { CHECKFILENAME(p); } draftmessage=newmsg_createdraft(p); } } } draftmessagefilename= draftmessage ? maildir_find(DRAFTS, draftmessage):0; if (*(p=cgi("previewmsg"))) { #ifdef ISPELL if (strcmp(p, "SPELLCHK") == 0) printf("%s<BR><BR>\n", checkspellingdone); #endif printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n"); printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"preview\"><TR><TD>\n"); if (draftmessagefilename) { const char *p=strrchr(draftmessagefilename, '/'); if (p) ++p; else p=draftmessagefilename; newmsg_preview(p); } printf("</TD></TR></TABLE>\n"); printf("</TD></TR></TABLE>\n"); printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD><HR WIDTH=\"80%%\"></TD></TR></TABLE>\n"); } printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"donewmsg\">\n"); newmsg_hiddenheader("pos", pos); newmsg_hiddenheader("focusto", *cgi("newmsg") ? "headers":"text"); /* Generate unique message token, to detect duplicate SUBMITs */ tokennew(); /* Display any error message */ if (*cgi("foldermsg")) { printf("<P><FONT CLASS=\"error\" COLOR=\"#FF0000\">"); output_attrencoded_nltobr(cgi("foldermsg")); printf("</FONT><BR>"); } if (strcmp(cgi("error"), "quota") == 0) printf("%s", quotaerr); /* Read message from the draft file */ cursubj=0; curto=0; curfrom=0; curreplyto=0; curcc=0; curbcc=0; fp=0; if (draftmessagefilename) { int x=maildir_safeopen(draftmessagefilename, O_RDONLY, 0); if (x >= 0) if ((fp=fdopen(x, "r")) == 0) close(x); } if (fp != 0) { char *header, *value; while ((header=maildir_readheader(fp, &value, 0)) != 0) { char **rfchp=0; if (strcmp(header, "subject") == 0) { if (!cursubj && !(cursubj=strdup(value))) enomem(); continue; } if (strcmp(header, "from") == 0) rfchp= &curfrom; if (strcmp(header, "reply-to") == 0) rfchp= &curreplyto; if (strcmp(header, "to") == 0) rfchp= &curto; if (strcmp(header, "cc") == 0) rfchp= &curcc; if (strcmp(header, "bcc") == 0) rfchp= &curbcc; if (rfchp) { char *newh=malloc ( (*rfchp ? strlen(*rfchp)+2:1) +strlen(value)); if (!newh) enomem(); strcpy(newh, value); if (*rfchp) strcat(strcat(newh, ","), *rfchp); if (*rfchp) free( *rfchp ); *rfchp=newh; } } } //printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n"); printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"new-message-box\"><TR><TD>\n"); printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%%\">\n"); /* by lfan if (access(NOCHANGINGFROM, 0)) newmsg_header(fromlab, "headerfrom", curfrom ? curfrom: *cgi("from") ? cgi("from"): pref_from && *pref_from ? pref_from: login_fromhdr()); printf("<TR VALIGN=MIDDLE><TH ALIGN=RIGHT>" "<P CLASS=\"new-message-header\">" "<FONT CLASS=\"new-message-header-addressbook\">" "%s</FONT></TD><TD WIDTH=6> </TH>", addressbooklab); */ printf("<TR VALIGN=MIDDLE><TD ALIGN=RIGHT CLASS=\"new-message-header\">" "%s</TD><TD WIDTH=6> </TD>", addressbooklab); printf("<TD VALIGN=MIDDLE>"); printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>"); //printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\" SIZE=4 MULTIPLE>\n"); printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\">\n"); ab_listselect(); printf("</select></TD><TD WIDTH=\"100%%\">"); printf(" <input type=submit class=mybtn name=\"addressbook_to\" value=\"%s\">", tolab); printf(" <input type=submit class=mybtn name=\"addressbook_cc\" value=\"%s\">", cclab); printf(" <input type=submit class=mybtn name=\"addressbook_bcc\" value=\"%s\">", bcclab); printf("</TD></TR></TABLE>"); printf("</TD></TR>\n"); newmsg_header(tolab, "headerto", curto ? curto:cgi("to")); newmsg_header(cclab, "headercc", curcc ? curcc:cgi("cc")); newmsg_header(bcclab, "headerbcc", curbcc ? curbcc:cgi("bcc")); // by lfan //newmsg_header(replytolab, "headerreply-to", curreplyto ? curreplyto:cgi("replyto")); newmsg_header(subjectlab, "headersubject", cursubj ? cursubj:cgi("subject")); if (curto) free(curto); if (curfrom) free(curfrom); if (curreplyto) free(curreplyto); if (curcc) free(curcc); if (curbcc) free(curbcc); if (cursubj) free(cursubj); printf("<TR><TD COLSPAN=3><HR WIDTH=\"100%%\"></TD></TR>"); /* by lfan printf("<TR><TH VALIGN=TOP ALIGN=RIGHT>" "<P CLASS=\"new-message-header\">" "<FONT CLASS=\"new-message-header-message\">" "%s</FONT></P></TD><TD WIDTH=6> </TD>", messagelab); */ printf("<TR><TD WIDTH=60 VALIGN=TOP ALIGN=RIGHT CLASS=\"ctype\">" "%s</TD><TD WIDTH=6> </TD>", messagelab); printf("<TD><TEXTAREA NAME=message COLS=%d ROWS=15 WRAP=soft>", MYLINESIZE); if (fp) { newmsg_showfp(fp, &attachcnt); } else { printf("%s", cgi("body")); if ((fp=fopen(SIGNATURE, "r")) != NULL) { char buf[256]; int n; printf("\n\n"); while ((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0) { buf[n]=0; output_attrencoded_oknl(buf); } fclose(fp); fp=NULL; } } printf("</TEXTAREA><BR>\n"); if (draftmessage && *draftmessage) { printf("<INPUT TYPE=HIDDEN NAME=draftmessage VALUE=\""); output_attrencoded(draftmessage); printf("\">"); } if (draftmessage) free(draftmessage); printf("</TD></TR>\n"); //by lfan printf("<TR><TD> </TD><TD> </TD><TD>"); printf("<INPUT TYPE=CHECKBOX " "NAME=fcc%s><FONT class=ctype>%s</FONT> \n", pref_noarchive ? "":" CHECKED", getarg("PRESERVELAB")); if (access(NODSN, R_OK)) printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX " "NAME=dsn></TD><TD>%s</TD></TR>\n", getarg("DSN")); #if HAVE_SQWEBMAIL_UNICODE if (has_gpg(GPGDIR) == 0) { char *all_addr; printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX " "NAME=sign></TD><TD>%s<SELECT NAME=signkey>", getarg("SIGNLAB")); gpgselectkey(); printf("</SELECT></TD></TR>\n"); all_addr=newmsg_alladdrs(fp); printf("<TR VALIGN=MIDDLE><TD COLSPAN=2 ALIGN=RIGHT>" "<INPUT TYPE=CHECKBOX NAME=encrypt></TD>" "<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 VALIGN=MIDDLE><TR><TD>%s</TD><TD><SELECT SIZE=4 MULTIPLE NAME=encryptkey>", getarg("ENCRYPTLAB")); gpgencryptkeys(all_addr); printf("</SELECT></TD></TR>\n"); printf("</TABLE></TD></TR>\n"); if (ishttps()) printf("<TR><TD COLSPAN=2 ALIGN> </TD><TD>%s<input type=password name=passphrase></TD></TR>\n", getarg("PASSPHRASE")); if (all_addr) free(all_addr); } #endif if (fp) fclose(fp); if (draftmessagefilename) free(draftmessagefilename); //printf("<TR><TD COLSPAN=2> </TD><TD>"); //printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\">", // previewlab); printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=sendmsg onclick=\"return check();\" VALUE=\"%s\"> ", sendlab); printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\"> ", previewlab); printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=savedraft VALUE=\"%s\"> ", savedraft); printf("<INPUT CLASS=\"mybtn\" TYPE=SUBMIT NAME=doattachments VALUE=\""); printf(uploadlab); printf("\"> "); printf(attachedlab, attachcnt); #ifdef ISPELL printf("<INPUT TYPE=SUBMIT NAME=startspellchk VALUE=\"%s\">", checkspelling); #endif printf("</TD></TR>\n"); printf("</TD></TABLE>\n"); printf("</TD></TR></TABLE>\n"); //printf("</TD></TR></TABLE>\n"); }
void getacl() { maildir_aclt_list l; char buf[2]; char *owner; const char *a; const char *editentity=cgi("editentity"); const char *editaccess=cgi("editaccess"); const char *entitytype=""; const char *entityval=""; int negate=0; if (acl_read(&l, sqwebmail_folder, &owner) < 0) { printf("%s", getarg("ACL_noaccess")); return; } strcpy(buf, ACL_ADMINISTER); acl_computeRights(&l, buf, owner); if (owner) free(owner); if (buf[0] == 0) { maildir_aclt_list_destroy(&l); return; } printf("<form method=\"post\" name=\"form1\" action=\""); output_scriptptr(); printf("\">"); output_scriptptrpostinfo(); printf("<input type=\"hidden\" name=\"update\" value=\"1\" />\n" "<input type=\"hidden\" name=\"form\" value=\"acl\" />\n"); printf("<table class=\"folder-acl-list\"><tbody>" "<tr><th align=\"left\">%s</th><th align=\"left\">%s</th></tr>\n", getarg("ENTITY"), getarg("ACCESSRIGHTS")); maildir_aclt_list_enum(&l, getacl_cb, NULL); if (*editentity == '-') { ++editentity; negate=1; } if (*editentity) { if (strncmp(editentity, "user="******"user"; entityval=editentity+5; } else if (strncmp(editentity, "group=", 6) == 0) { entitytype="group"; entityval=editentity+6; } else if (strcmp(editentity, "owner") == 0 || strcmp(editentity, "anonymous") == 0) { entitytype=editentity; } else { entitytype="other"; entityval=editentity; } } printf("<tr><td colspan=\"2\"><hr width=\"90%%\" />"); printf("<table><tbody>\n"); printf("<tr><th colspan=\"2\" align=\"left\">%s</th></tr>\n", getarg("UPDATEHDR")); printf("<tr align=\"top\"><td>" "<select name=\"negate\" id=\"negate\">\n" "<option value=\"\" > </option>\n" "<option value=\"-\" %s>-</option>\n" "</select>\n" "<select name=\"entitytype\" id=\"entitytype\" " "onchange=\"javascript:updent()\" >\n" "<option value=\"user\" %s >%s</option>\n" "<option value=\"group\" %s >%s</option>\n" "<option value=\"owner\" %s >%s</option>\n" "<option value=\"anonymous\" %s >%s</option>\n" "<option value=\"administrators\" %s >%s</option>\n" "<option value=\"other\" %s >%s</option>\n" "</select><input type=\"text\" name=\"entity\" " " id=\"entity\" value=\"", negate ? "selected=\"selected\"":"", strcmp(entitytype, "user") == 0 ? "selected=\"selected\"":"", getarg("USER"), strcmp(entitytype, "group") == 0 ? "selected=\"selected\"":"", getarg("GROUP"), strcmp(entitytype, "owner") == 0 ? "selected=\"selected\"":"", getarg("OWNER"), strcmp(entitytype, "anonymous") == 0 ? "selected=\"selected\"":"", getarg("ANONYMOUS"), strcmp(entitytype, "administrators") == 0 ? "selected=\"selected\"":"", getarg("ADMINISTRATORS"), strcmp(entitytype, "other") == 0 ? "selected=\"selected\"":"", getarg("OTHER")); p_ident_name(entityval); printf("\"/></td><td><table><tbody>"); a=getarg("ACL_all"); while (*a) { char buf2[40]; sprintf(buf2, "ACL_%c", *a); printf("<tr><td><input type=\"checkbox\" name=\"acl_%c\" " "id=\"acl_%c\" %s />" "</td><td>%s</td></tr>\n", *a, *a, strchr(editaccess, *a) ? "checked=\"checked\"":"", getarg(buf2)); ++a; } printf("</tbody></table></td></tr>\n" "<tr><td> </td>" "<td><input type=\"submit\" name=\"do.update\" value=\"%s\" />" "</td>" "</table></tbody></td></tr>\n", getarg("UPDATE")); printf("</tbody></table></form>\n"); }
void newmsg_init(const char *folder, const char *pos) { const char *tolab=getarg("TOLAB"); const char *cclab=getarg("CCLAB"); const char *bcclab=getarg("BCCLAB"); const char *subjectlab=getarg("SUBJECTLAB"); const char *messagelab=getarg("MESSAGELAB"); const char *sendlab=getarg("SENDLAB"); const char *previewlab=getarg("PREVIEWLAB"); const char *forwardsep=getarg("FORWARDLAB"); const char *savedraft=getarg("SAVEDRAFT"); const char *attachmentslab=getarg("ATTACHMENTS"); const char *uploadlab=getarg("UPLOAD"); const char *replysalutation=getarg("SALUTATION"); const char *checkspellingdone=getarg("SPELLCHECKDONE"); const char *checkspelling=getarg("CHECKSPELLING"); const char *quotaerr=getarg("QUOTAERR"); const char *fromlab=getarg("FROMLAB"); const char *replytolab=getarg("REPLYTOLAB"); const char *addressbooklab=getarg("ADDRESSBOOK"); const char *select1=getarg("SELECT1"); const char *select2=getarg("SELECT2"); const char *text1=getarg("TEXT1"); const char *text2=getarg("TEXT2"); char *draftmessage; char *draftmessagefilename; const char *p; FILE *fp; int attachcnt=0; char *cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto; int wbnochangingfrom; /* Picking up an existing draft? */ p=cgi("draft"); if (*p) { CHECKFILENAME(p); } if (*p) { draftmessage=strdup(p); if (!draftmessage) enomem(); p=""; } else { draftmessage=newmsg_newdraft(folder, pos, forwardsep, replysalutation); if (!draftmessage) { if (*ispreviewmsg()) { p=cgi("draftmessage"); if (*p) { CHECKFILENAME(p); } draftmessage=newmsg_createdraft(p); } } } draftmessagefilename= draftmessage ? maildir_find(INBOX "." DRAFTS, draftmessage):0; if (*(p=cgi("previewmsg"))) { #ifdef ISPELL if (strcmp(p, "SPELLCHK") == 0) printf("%s<br /><br />\n", checkspellingdone); #endif printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n"); printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"preview\"><tr><td>\n"); if (draftmessagefilename) { const char *p=strrchr(draftmessagefilename, '/'); if (p) ++p; else p=draftmessagefilename; newmsg_preview(p); } printf("</td></tr></table>\n"); printf("</td></tr></table>\n"); printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\"><tr><td><hr width=\"80%%\" /></td></tr></table>\n"); } printf("<input type=\"hidden\" name=\"form\" value=\"donewmsg\" />\n"); newmsg_hiddenheader("pos", pos); newmsg_hiddenheader("focusto", *cgi("newmsg") ? "headers":"text"); /* Generate unique message token, to detect duplicate SUBMITs */ tokennew(); /* Display any error message */ if (*cgi("foldermsg")) { printf("<p><span class=\"error\" style=\"color: #ff0000\">"); output_attrencoded_nltobr(cgi("foldermsg")); printf("</span></p>"); } if (strcmp(cgi("error"), "quota") == 0) printf("%s", quotaerr); /* Read message from the draft file */ cursubj=0; curto=0; curfrom=0; curreplyto=0; curcc=0; curbcc=0; fp=0; if (draftmessagefilename) { int x=maildir_safeopen(draftmessagefilename, O_RDONLY, 0); if (x >= 0) if ((fp=fdopen(x, "r")) == 0) close(x); } if (fp != 0) { char *header, *value; while ((header=maildir_readheader(fp, &value, 0)) != 0) { char **rfchp=0; if (strcmp(header, "subject") == 0) { if (!cursubj && !(cursubj=strdup(value))) enomem(); continue; } while (*value && isspace(*value)) ++value; if (strcmp(header, "from") == 0) rfchp= &curfrom; if (strcmp(header, "reply-to") == 0) rfchp= &curreplyto; if (strcmp(header, "to") == 0) rfchp= &curto; if (strcmp(header, "cc") == 0) rfchp= &curcc; if (strcmp(header, "bcc") == 0) rfchp= &curbcc; if (rfchp) { char *newh=malloc ( (*rfchp ? strlen(*rfchp)+2:1) +strlen(value)); if (!newh) enomem(); strcpy(newh, value); if (*rfchp) strcat(strcat(newh, ","), *rfchp); if (*rfchp) free( *rfchp ); *rfchp=newh; } } } printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n"); printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"new-message-box\"><tr><td>\n"); printf("<table border=\"0\" width=\"100%%\">\n"); wbnochangingfrom=auth_getoptionenvint("wbnochangingfrom"); if (wbnochangingfrom < 2) newmsg_header_rfc822(fromlab, "headerfrom", curfrom, *cgi("from") ? cgi("from"): pref_from && *pref_from ? pref_from: login_fromhdr(), wbnochangingfrom ? 1:0); printf("<tr valign=\"middle\"><th align=\"right\">" "<p class=\"new-message-header\">" "<span class=\"new-message-header-addressbook\">" "%s</span></p></th><td width=\"6\"> </td>", addressbooklab); printf("<td valign=\"middle\">"); printf("<table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">"); printf("<tr valign=\"middle\"><td>%s\n", select1); ab_listselect(); printf("%s</td><td width=\"100%%\">", select2); printf("<input type=\"submit\" name=\"addressbook_to\" value=\"%s\" />", tolab); printf("<input type=\"submit\" name=\"addressbook_cc\" value=\"%s\" />", cclab); printf("<input type=\"submit\" name=\"addressbook_bcc\" value=\"%s\" />", bcclab); printf("</td></tr></table>"); printf("</td></tr>\n"); #if 0 { FILE *fp; fp=fopen("/tmp/pid", "w"); fprintf(fp, "%d", getpid()); fclose(fp); sleep(10); } #endif newmsg_header_rfc822(tolab, "headerto", curto, cgi("to"), 0); newmsg_header_rfc822(cclab, "headercc", curcc, cgi("cc"), 0); newmsg_header_rfc822(bcclab, "headerbcc", curbcc, cgi("bcc"), 0); newmsg_header_rfc822(replytolab, "headerreply-to", curreplyto, cgi("replyto"), 0); newmsg_header(subjectlab, "headersubject", cursubj, cgi("subject")); if (curto) free(curto); if (curfrom) free(curfrom); if (curreplyto) free(curreplyto); if (curcc) free(curcc); if (curbcc) free(curbcc); if (cursubj) free(cursubj); printf("<tr><td colspan=\"3\"><hr width=\"100%%\" /></td></tr>"); printf("<tr>" "<th valign=\"top\" align=\"right\">" "<p class=\"new-message-header\">" "<span class=\"new-message-header-message\">" "%s</span></p></th><td width=\"6\"> </td>" "<td><select name=\"textformat\">" "<option value=\"plain\" %s>%s</option>" "<option value=\"wiki\" %s>%s</option></select>" "<small>(<a href='%s/wikifmt.html' target='_blank'>%s</a>)</small>" "</td></tr>" "<tr><th valign=\"top\" align=\"right\">" "<p class=\"new-message-header\">" "<span class=\"new-message-header-message\">" "%s</span></p></th><td width=\"6\"> </td>", getarg("FMTNAME"), pref_wikifmt ? "":"selected='selected'", getarg("FMTTEXTPLAIN"), pref_wikifmt ? "selected='selected'":"", getarg("FMTTEXTWIKI"), get_imageurl(), getarg("FMTHELP"), messagelab); printf("<td>%s\n", text1); if (fp) { newmsg_showfp(fp, &attachcnt); } else { printf("%s", cgi("body")); } printf("%s\n", text2); if (draftmessage && *draftmessage) { printf("<input type=\"hidden\" name=\"draftmessage\" value=\""); output_attrencoded(draftmessage); printf("\" />"); } if (draftmessage) free(draftmessage); printf("</td></tr>\n"); printf("<tr><th valign=\"top\" align=\"right\">" "<p class=\"new-message-header\">" "<span class=\"new-message-header-message\">" "%s</span></p></th><td> </td>" "<td>%d <input type=\"submit\" name=\"doattachments\" value=\"%s\" /></td></tr>", attachmentslab, attachcnt, uploadlab); printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" " "name=\"fcc\" id=\"fcc\"%s /></td><td><label for=\"fcc\">%s</label></td></tr>\n", pref_noarchive ? "":" checked=\"checked\"", getarg("PRESERVELAB")); if (auth_getoptionenvint("wbnodsn") == 0) printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" " "name=\"dsn\" id=\"dsn\" /></td><td><label for=\"dsn\">%s</label></td></tr>\n", getarg("DSN")); if (libmail_gpg_has_gpg(GPGDIR) == 0) { char *all_addr; printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" " "name=\"sign\" id=\"sign\" /></td><td><label for=\"sign\">%s</label><select name=\"signkey\">", getarg("SIGNLAB")); gpgselectkey(); printf("</select></td></tr>\n"); all_addr=newmsg_alladdrs(fp); printf("<tr valign=\"middle\"><td colspan=\"2\" align=\"right\">" "<input type=\"checkbox\" name=\"encrypt\" id=\"encrypt\" /></td>" "<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr valign=\"middle\"><td><label for=\"encrypt\">%s</label></td><td><select size=\"4\" multiple=\"multiple\" name=\"encryptkey\">", getarg("ENCRYPTLAB")); gpgencryptkeys(all_addr); printf("</select></td></tr>\n"); printf("</table></td></tr>\n"); if (ishttps()) printf("<tr><td colspan=\"2\" align=\"left\"> </td><td>%s<input type=\"password\" name=\"passphrase\" /></td></tr>\n", getarg("PASSPHRASE")); if (all_addr) free(all_addr); } if (fp) fclose(fp); if (draftmessagefilename) free(draftmessagefilename); printf("<tr><td colspan=\"2\"> </td><td>"); printf("<input type=\"submit\" name=\"previewmsg\" value=\"%s\" />", previewlab); printf("<input type=\"submit\" name=\"sendmsg\" value=\"%s\" />", sendlab); printf("<input type=\"submit\" name=\"savedraft\" value=\"%s\" />", savedraft); #ifdef ISPELL printf("<input type=\"submit\" name=\"startspellchk\" value=\"%s\" />", checkspelling); #endif printf("</td></tr>\n"); printf("</table>\n"); printf("</td></tr></table>\n"); printf("</td></tr></table>\n"); }