{
  "attachments": [],
  "comments_archived": true,
  "date": "2005-06-22T22:23:47.000Z",
  "layout": "post",
  "title": "Fun and not-so-fun",
  "wordpress_id": 655,
  "wordpress_slug": "fun-and-not-so-fun",
  "wordpress_url": "http://www.decafbad.com/blog/?p=655",
  "year": "2005",
  "month": "06",
  "day": "22",
  "isDir": false,
  "slug": "fun-and-not-so-fun",
  "type": "entry",
  "postName": "2005-06-22-fun-and-not-so-fun",
  "html": "<ul>\n<li><p>Last night's fun trick?  Say hello to <a href=\"aim:goim?Screenname=decafbot&amp;Message=help\">decafbot</a>!  </p>\n<p>I turned an IRC <a href=\"http://infobot.sourceforge.net\">Infobot</a> into an AIM chatbot via <a href=\"http://www.bitlbee.org/\">Bitlbee</a>.  It may or may not be online depending on how stable the rig is and how tolerant AIM's flood/spam triggers are.</p>\n<p>I've always been a fan of <code>purl</code> on the <code>#perl</code> IRC channel, so maybe I can try turning this little infobot into something useful.  At any rate, it was a quick hack involving two installs via DarwinPorts and a few config file tweaks.  So, send an IM on the AIM network to <a href=\"aim:goim?Screenname=decafbot&amp;Message=help\"><code>decafbot</code></a> and see what happens.</p>\n</li>\n</ul>\n<ul>\n<li><p>Today's not-so-fun trick?  (Well, the past 2 weeks' not-so-fun...)</p>\n<p>Imagine a crazy crapstorm web app project which features allowing visitors to upload pictures, presumably from their digital cameras.  Ignore for the moment any details of feasibility, scope, timing, or resource planning.</p>\n<p>Oh, and you're stuck working with classic ASP 3.0.  You have no access to write to the file system on the production web server, and you've been told not to stick big things in the database tables--like photos from digital cameras, for instance.  Also, did I mention that you can't register any new DLLs on the production servers?  At least, not without the consultation of a committee who only meets every quarter or so.  Oh, and did I mention this was due last week?</p>\n<p>So, you've got to <em>somehow</em> capture those images and the accompanying metadata and stash it all <em>somewhere</em>, despite being denied a filesystem or a database.  What to do, what to do?  Oh, I know: let's email all this crap off to an inbox somewhere that something (or someone (<em>sorry, intern</em>)) will be able to batch process!</p>\n<p>Great!  Except, well... er...  ASP 3.0 doesn't really particularly like processing forms with file uploads.  In fact, it doesn't support it at all.  Luckily, I was able to find some code <a href=\"http://aspzone.com/articles/160.aspx\">implementing file upload handling in pure VBScript</a>, although I had to scrape it off the HTML page itself since the .zip file had gone missing.</p>\n<p>With that, then, you can actually accept the form submission.  Now, how to fire off an email with the image as an attachment?  The only email support we have available is <a href=\"http://www.mostlylucid.co.uk/archive/2003/10/15/589.aspx\">CDONTS.DLL</a>, and it appears to only offer some support for attachments which are available in the filesystem--and all we have here is a stream of bytes in memory.  </p>\n<p>So, armed with a pure-ASP implementation of <a href=\"http://www.freevbcode.com/ShowCode.asp?ID=5248\">base64</a> and a decent understanding of SMTP and RFCs, I forged ahead to piece together a MIME multipart email the hard way in VBScript.  Remember to line break your stream of base64-encoded binary at 75 columns, and you'll need to trick CDONTS to allow you to inject a <code>Content-Type: multipart/mixed</code> header into the mix, and you're off!</p>\n<p>Whew... and, believe it or not, it all works.  I almost wish I could share the source code, ignoring that it's implemented with an obsolete set of technologies and that it's certainly not the prettiest code in the world.</p>\n</li>\n</ul>\n<div id=\"comments\" class=\"comments archived-comments\"><h3>Archived Comments</h3>\n<ul class=\"comments\">\n<li class=\"comment\" id=\"comment-221086027\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"http://rasterweb.net/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=db0fab74bcb564ebb09295498b892fb6&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"http://rasterweb.net/\">Pete Prodoehl</a>\n</div>\n\n\n<p><a href=\"#comment-221086027\" class=\"permalink\"><time datetime=\"2005-06-22T20:02:05\">2005-06-22T20:02:05</time></a></p>\n</div>\n\n\n<div class=\"content\">After \"classic ASP 3.0\" I just kept mutter \"poor bastard\" and couldn't even muster up the courage to read on. I've felt your pain...</div>\n\n\n</li>\n<li class=\"comment\" id=\"comment-221086029\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"http://www.nickfitz.co.uk/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=b09e3490d1406cd1d752c774f9d5e711&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"http://www.nickfitz.co.uk/\">Nick Fitzsimons</a>\n</div>\n\n\n<p><a href=\"#comment-221086029\" class=\"permalink\"><time datetime=\"2005-06-23T12:30:52\">2005-06-23T12:30:52</time></a></p>\n</div>\n\n\n<div class=\"content\">Ah, the pain... I had to do something similar a few years ago, and it's not fun at all - especially as I had to add in a scheduled task to automatically get the stuff from the mailbox (WSH POP3 client, anyone?), de-Base64 it and upload it onto an intranet server... those were the days :-)</div>\n\n\n</li>\n<li class=\"comment\" id=\"comment-221086032\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"http://therealadam.com\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=930993d33d2ce457bf871158e688a2fa&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"http://therealadam.com\">Adam Keys</a>\n</div>\n\n\n<p><a href=\"#comment-221086032\" class=\"permalink\"><time datetime=\"2005-06-28T20:46:30\">2005-06-28T20:46:30</time></a></p>\n</div>\n\n\n<div class=\"content\">All that and no felonies committed?  You are a saint!</div>\n\n\n</li>\n</ul>\n\n\n</div>\n\n\n",
  "body": "* Last night's fun trick?  Say hello to <a href=\"aim:goim?Screenname=decafbot&Message=help\">decafbot</a>!  \r\n\r\n  I turned an IRC [Infobot][ib] into an AIM chatbot via [Bitlbee][bb].  It may or may not be online depending on how stable the rig is and how tolerant AIM's flood/spam triggers are.\r\n\r\n  I've always been a fan of `purl` on the `#perl` IRC channel, so maybe I can try turning this little infobot into something useful.  At any rate, it was a quick hack involving two installs via DarwinPorts and a few config file tweaks.  So, send an IM on the AIM network to <a href=\"aim:goim?Screenname=decafbot&Message=help\">`decafbot`</a> and see what happens.\r\n\r\n[ib]: http://infobot.sourceforge.net\r\n[bb]: http://www.bitlbee.org/\r\n\r\n* Today's not-so-fun trick?  (Well, the past 2 weeks' not-so-fun...)\r\n\r\n  Imagine a crazy crapstorm web app project which features allowing visitors to upload pictures, presumably from their digital cameras.  Ignore for the moment any details of feasibility, scope, timing, or resource planning.\r\n\r\n  Oh, and you're stuck working with classic ASP 3.0.  You have no access to write to the file system on the production web server, and you've been told not to stick big things in the database tables--like photos from digital cameras, for instance.  Also, did I mention that you can't register any new DLLs on the production servers?  At least, not without the consultation of a committee who only meets every quarter or so.  Oh, and did I mention this was due last week?\r\n\r\n  So, you've got to *somehow* capture those images and the accompanying metadata and stash it all *somewhere*, despite being denied a filesystem or a database.  What to do, what to do?  Oh, I know: let's email all this crap off to an inbox somewhere that something (or someone (*sorry, intern*)) will be able to batch process!\r\n\r\n  Great!  Except, well... er...  ASP 3.0 doesn't really particularly like processing forms with file uploads.  In fact, it doesn't support it at all.  Luckily, I was able to find some code [implementing file upload handling in pure VBScript][file], although I had to scrape it off the HTML page itself since the .zip file had gone missing.\r\n\r\n  With that, then, you can actually accept the form submission.  Now, how to fire off an email with the image as an attachment?  The only email support we have available is [CDONTS.DLL][cdonts], and it appears to only offer some support for attachments which are available in the filesystem--and all we have here is a stream of bytes in memory.  \r\n\r\n  So, armed with a pure-ASP implementation of [base64][] and a decent understanding of SMTP and RFCs, I forged ahead to piece together a MIME multipart email the hard way in VBScript.  Remember to line break your stream of base64-encoded binary at 75 columns, and you'll need to trick CDONTS to allow you to inject a `Content-Type: multipart/mixed` header into the mix, and you're off!\r\n\r\n  Whew... and, believe it or not, it all works.  I almost wish I could share the source code, ignoring that it's implemented with an obsolete set of technologies and that it's certainly not the prettiest code in the world.\r\n\r\n[base64]: http://www.freevbcode.com/ShowCode.asp?ID=5248\r\n[file]: http://aspzone.com/articles/160.aspx\r\n[cdonts]: http://www.mostlylucid.co.uk/archive/2003/10/15/589.aspx\r\n\r\n<div id=\"comments\" class=\"comments archived-comments\">\r\n            <h3>Archived Comments</h3>\r\n            \r\n        <ul class=\"comments\">\r\n            \r\n        <li class=\"comment\" id=\"comment-221086027\">\r\n            <div class=\"meta\">\r\n                <div class=\"author\">\r\n                    <a class=\"avatar image\" rel=\"nofollow\" \r\n                       href=\"http://rasterweb.net/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=db0fab74bcb564ebb09295498b892fb6&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\r\n                    <a class=\"avatar name\" rel=\"nofollow\" \r\n                       href=\"http://rasterweb.net/\">Pete Prodoehl</a>\r\n                </div>\r\n                <a href=\"#comment-221086027\" class=\"permalink\"><time datetime=\"2005-06-22T20:02:05\">2005-06-22T20:02:05</time></a>\r\n            </div>\r\n            <div class=\"content\">After \"classic ASP 3.0\" I just kept mutter \"poor bastard\" and couldn't even muster up the courage to read on. I've felt your pain...</div>\r\n            \r\n        </li>\r\n    \r\n        <li class=\"comment\" id=\"comment-221086029\">\r\n            <div class=\"meta\">\r\n                <div class=\"author\">\r\n                    <a class=\"avatar image\" rel=\"nofollow\" \r\n                       href=\"http://www.nickfitz.co.uk/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=b09e3490d1406cd1d752c774f9d5e711&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\r\n                    <a class=\"avatar name\" rel=\"nofollow\" \r\n                       href=\"http://www.nickfitz.co.uk/\">Nick Fitzsimons</a>\r\n                </div>\r\n                <a href=\"#comment-221086029\" class=\"permalink\"><time datetime=\"2005-06-23T12:30:52\">2005-06-23T12:30:52</time></a>\r\n            </div>\r\n            <div class=\"content\">Ah, the pain... I had to do something similar a few years ago, and it's not fun at all - especially as I had to add in a scheduled task to automatically get the stuff from the mailbox (WSH POP3 client, anyone?), de-Base64 it and upload it onto an intranet server... those were the days :-)</div>\r\n            \r\n        </li>\r\n    \r\n        <li class=\"comment\" id=\"comment-221086032\">\r\n            <div class=\"meta\">\r\n                <div class=\"author\">\r\n                    <a class=\"avatar image\" rel=\"nofollow\" \r\n                       href=\"http://therealadam.com\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=930993d33d2ce457bf871158e688a2fa&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\r\n                    <a class=\"avatar name\" rel=\"nofollow\" \r\n                       href=\"http://therealadam.com\">Adam Keys</a>\r\n                </div>\r\n                <a href=\"#comment-221086032\" class=\"permalink\"><time datetime=\"2005-06-28T20:46:30\">2005-06-28T20:46:30</time></a>\r\n            </div>\r\n            <div class=\"content\">All that and no felonies committed?  You are a saint!</div>\r\n            \r\n        </li>\r\n    \r\n        </ul>\r\n    \r\n        </div>\r\n    ",
  "parentPath": "./content/posts/archives/2005",
  "path": "2005/06/22/fun-and-not-so-fun",
  "needsBuild": true,
  "prevPostPath": "2005/06/17/were-engaged",
  "prevPostTitle": "We're engaged!",
  "nextPostPath": "2005/06/23/quick-mind-interface-thoughts",
  "nextPostTitle": "Quick mind interface thoughts"
}