From 32f034bb8016b17cefd0e80caec19fa75d6503bb Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 9 Oct 2012 15:55:35 -0500 Subject: [PATCH] move to roundcube --- derby/derby.mk | 6 ++++- derby/index.mdwn | 6 ++--- ilohamail.cgi.c | 25 ++++++++++++++++++ index.mdwn | 27 +++++++++++++++++++ mail.cgi.c | 68 ++++++++++++++++++++++++++++++++++++++++++------ woozle.mk | 4 +-- 6 files changed, 122 insertions(+), 14 deletions(-) create mode 100644 ilohamail.cgi.c diff --git a/derby/derby.mk b/derby/derby.mk index 00a2c20..423692e 100644 --- a/derby/derby.mk +++ b/derby/derby.mk @@ -1 +1,5 @@ -PLAIN += $(wildcard derby/*.mdwn) +PLAIN += derby +COPY += derby/scrimmage.pdf + +$(DESTDIR)/derby/scrimmage.pdf: derby/scrimmage.ps + ps2pdf $< $@ diff --git a/derby/index.mdwn b/derby/index.mdwn index 45cde85..63064f8 100644 --- a/derby/index.mdwn +++ b/derby/index.mdwn @@ -13,9 +13,9 @@ The Woozle Promise Software -------- -* [Scoreboard](/scoreboard/), works in any web browser -* [Penalty Timer (Android)](https://play.google.com/store/apps/details?id=org.woozle.penaltytimer) -* [Track](/track/) with movable players +* [Scoreboard](/scoreboard/), works in any web browser -- [source](http://woozle.org/~neale/g.cgi/scoreboard/) +* [Penalty Timer for Android](https://play.google.com/store/apps/details?id=org.woozle.penaltytimer) -- [source](http://woozle.org/~neale/g.cgi/ptimer/) +* [Track](/track/) with movable players -- [source](http://woozle.org/~neale/g.cgi/track/) Forms ----- diff --git a/ilohamail.cgi.c b/ilohamail.cgi.c new file mode 100644 index 0000000..3c7924f --- /dev/null +++ b/ilohamail.cgi.c @@ -0,0 +1,25 @@ +#include +#include +#include +#include + +const char *basepath = "/usr/share/IlohaMail/source"; + +int +main(int argc, char *argv[]) +{ + char *pathinfo = getenv("PATH_INFO"); + char filename[512]; + + if ((! pathinfo) || + (! strcmp(pathinfo, "/")) || + (0 == strcmp(pathinfo, "/index.html"))) { + pathinfo = "/index.php"; + } + snprintf(filename, sizeof filename, "%s%s", basepath, pathinfo); + setenv("SCRIPT_FILENAME", filename, 1); + setenv("REDIRECT_STATUS", "fuck me", 1); + execl("/usr/bin/php-cgi", filename, NULL); + + return 0; +} diff --git a/index.mdwn b/index.mdwn index c8d3db6..c1f4bb2 100644 --- a/index.mdwn +++ b/index.mdwn @@ -7,3 +7,30 @@ held by folks who know the right person to ask. + +October 9: New Webmail +---------------------- + +The October 2 change broke webmail. Again. Rather than fix it again, +I thought everyone would enjoy a more modern webmail client. You can +still get to [the old one](https://woozle.org/ilohamail.cgi) if you +want to pull your address book out or something, but I'm planning on +removing it in a few months unless someone asks me not to. + +Mail filtering is now available. You can +get to that under Settings. This uses a standard filtering language, +so your filters will stick around if I have to change the webmail +program again. These filters also apply to IMAP clients (like your +Android or iPhone, or Thunderbird). + + + +October 2: Kerboom +------------------ + +In trying to get my 2006 cell phone to sync with Google Calendar, I broke +(among other things) mail. I think it's all back up now. If you see any +other problems, please give me a call. + +I should mention that [eris HTTPd](http://woozle.org/~neale/src/eris.html) +was the only service that never went down; not even for a nanosecond. diff --git a/mail.cgi.c b/mail.cgi.c index ea9df69..f182565 100644 --- a/mail.cgi.c +++ b/mail.cgi.c @@ -3,22 +3,74 @@ #include #include -const char *basepath = "/usr/share/IlohaMail/source"; +const char *baseurl = "https://woozle.org/mail.cgi/"; +const char *basepath = "/opt/roundcubemail"; int main(int argc, char *argv[]) { char *pathinfo = getenv("PATH_INFO"); + char *remaddr = getenv("REMOTE_ADDR"); + size_t pathlen = pathinfo?strlen(pathinfo):0; char filename[512]; + char *ext; - if ((! pathinfo) || - (! strcmp(pathinfo, "/")) || - (0 == strcmp(pathinfo, "/index.html"))) { - pathinfo = "/index.php"; + if ((! pathinfo) || (! remaddr) || (0 != strncmp(remaddr, "127.0.0.1:", 10))) { + printf("%s\n", baseurl); + return 0; + } else if (0 == strcmp(pathinfo, "/index.html")) { + snprintf(filename, sizeof filename, "%s/index.php", basepath); + } else if (pathinfo[pathlen-1] == '/') { + snprintf(filename, sizeof filename, "%s%sindex.php", basepath, pathinfo); + } else { + snprintf(filename, sizeof filename, "%s%s", basepath, pathinfo); } - snprintf(filename, sizeof filename, "%s%s", basepath, pathinfo); - setenv("SCRIPT_FILENAME", filename, 1); - execl("/usr/bin/php-cgi", filename, NULL); + + ext = strrchr(filename, '.'); + if (! ext) { + ext = ""; + } + + if (0 == strcmp(ext, ".php")) { + setenv("SCRIPT_FILENAME", filename, 1); + setenv("REDIRECT_STATUS", "fuck me", 1); + execl("/usr/bin/php-cgi", filename, NULL); + } else if (strstr(filename, "/config/") || + strstr(filename, "/logs/") || + strstr(filename, "/temp/")) { + printf("Content-type: text/plain\n\n[MESSAGE REDACTED]\n"); + } else { + FILE *f = fopen(filename, "r"); + char *ct = "application/octet-stream"; + + if (0 == strcmp(ext, ".css")) { + ct = "text/css"; + } else if (0 == strcmp(ext, ".html")) { + ct = "text/html"; + } else if (0 == strcmp(ext, ".js")) { + ct = "application/javascript"; + } else if (0 == strcmp(ext, ".png")) { + ct = "image/png"; + } else if (0 == strcmp(ext, ".jpg")) { + ct = "image/jpeg"; + } else if (0 == strcmp(ext, ".gif")) { + ct = "image/gif"; + } + + printf("Content-type: %s\n\n", ct); + + while (! feof(f)) { + char buf[4096]; + size_t len; + + + len = fread(buf, 1, sizeof buf, f); + if (len) { + fwrite(buf, 1, len, stdout); + } + } + } + fflush(stdout); return 0; } diff --git a/woozle.mk b/woozle.mk index 3570b8c..161d8c2 100644 --- a/woozle.mk +++ b/woozle.mk @@ -1,11 +1,11 @@ PLAIN += . COPY += icon.png style.css style-black.css lists.cgi wishlist.cgi set.cgi $(TEMPLATE) -COPY += mail.cgi +COPY += mail.cgi ilohamail.cgi COPY += google7f698b9893809122.html HTML += people.html $(DESTDIR)/people.html: people.sh template.html.m4 sh $< | $(MDWNTOHTML) > $@ -$(DESTDIR)/mail.cgi: mail.cgi.c +$(DESTDIR)/%.cgi: %.cgi.c $(CC) -Wall -Werror -o $@ $<