Jun 19
I've never been a fan of using JavaScript to fix up an interface. That is the purpose of using CSS. However, with that being said, I developed a very elegant website login page with a resolution of 1024x768 in mind. All of the CSS had been meticulously measured using quite a few pixel-based measurements (over EMs, because I was sure it would be fine for the two horizontal elements taking up the page width). Unfortunately, I had confused our public facing site with our backend staff site's statistics. 32% of our backend site is viewed with a resolution of 800x600. Uh oh!

Times are changing, and computers get upgraded. Although the staff members with an 800x600 resolution might be used to scrolling on some pages to view content, it really wasn't good for the staff site's login to require a scroll (the main site is not yet redesigned, and I designed that for an 800x600 display). I didn't want to have to start from scratch, and even resize images to make them fit. As time progressed, I expected the percentage of 800x600 site views to drop, so this is more of a temporary band-aid that's needed anyway... JavaScript to the rescue.

Screen resolution is easy. screen.width and screen.height, respectively, will tell you about a visitor's monitor's current resolution, but in this case I needed to know the viewport.

Many people state that each of the major browsers use a different approach to determining the viewport, and this is true. But most people also create a function or IF/ELSE case for each possible outcome. I found some code that mixes all three in one line quite intuitively. Below is the actual JavaScript I used (jQuery methods found in there) to solve my issue (I pre-determined the width/height numbers manually for this specific layout).


Quite easy, quite nice, and the most important thing is that the login box is now clearly visible without any unnecessary scrolling (caused by CSS issues) at specific resolutions (tested at 600px width, minimum). If it's any less than that, I can assume it's a mobile browser and we don't (yet) support that; but when we do it'll be a completely different layout that's used.

I hope this might be helpful to someone else, but for the right reasons! (Credit to About.com for the viewport functions.)

Posted by Brendon Kozlowski

Jun 11
The title's a bit misleading, Server2Go also works on a USB drive as well (and like most portable webservers, runs better on a USB drive). However, that's not why I'm all excited about this.

Recently, our web host's newsletter stated that users with Wordpress-MU installed would no longer be able to run it on a shared webhosting plan, it was just too resource intensive. If it was desirable to continue running it, a private server plan would be required. We were using Wordpress-MU, only had 5 blogs, and it hadn't been touched in about 5 months. BYE BYE MU! However, there was a lot of useful information on 2 of the blogs, and I wanted to give the users an opportunity to save their work.

I had two choices:
1. Use a spider, like HTTrack to copy all of the rendered HTML viewable by random visitors, or...
2. Try to find a solution that would let the author log in, view any unpublished pages/posts, and still get some educational benefit out of using a well-known web-based product. (Note: I was only looking for something that works on Windows.)

There were a couple (2) hits from Google explaining how to do it all manually, and a few products that claimed they could do it (if you bought their product; the free version only worked for USB drives, not CD). Server2Go came up as my last opened tab from my search, and it was what I needed. It was free (I wasn't going to pay if I could do it myself manually - though I may donate), and even looked really slick, and was configurable.

It took me two tries to get Wordpress installed and working with Server2Go. I needed to change "localmirror" to 0 while installing it and change it when done, but I didn't do that...so I had to reinstall it all. Wordpress' export/import feature saved the hassle of moving from Wordpress-MU to a single, standalone install of Wordpress, and after that, it only took maybe 3 minutes to set everything up.

If you need to have a product presented on CD to a client, I'd highly recommend Server2Go. USB drives will always work, but run the risk of accidental editing/deletion. A backup plan is always good! ...this is just yet another tool for the arsenal.

Posted by Brendon Kozlowski

Apr 15


Language not really safe for work (NSFW) as it contains language which may offend people. It was very well done regardless, and (unfortunately?) very representative of certain areas on the internet.

Posted by Brendon Kozlowski

Mar 13
I needed a way to authenticate users from our library from a server outside our network, and therefore also not connected to Active Directory. At first I was thinking LDAP would be the best way...then I did my research and learned enough about LDAP to realize just how much information it gives out - WAY too much for it to be very secure. Even if I used SSL, created an account specifically for this access, set that account to read only...all it would take would be one person to hack our server and grab that information and all our organization's data is out there. Although it's about as much of a chance as getting hit by lightning in the middle of the desert in a sand storm, I wouldn't want to be responsible.

The only server with any sort of external web presence that is also touching the internet is our Exchange server's web access portal. I thought, "Ah HA! I can use cURL, or streams, or fsockopen or something to fake a login to this page to verify authentication!" After searching a bit (I'm terrible every time I attempt to write something using cURL to authenticate), I came across a few things.

  1. Exchange Server 2007 uses SOAP to provide a web service...AWESOME! We currently use 2003 though, but we will be upgrading later this year, so this may be helpful later on. [Link]
    1. HowToForge article on how to use PHP with 2007's SOAP Web Service
  2. I found this PHP script that I tested, which successfully contacted our OWA server and authenticated.
  3. I also found a PHP class on Google Code from Tyler Hall - it's not any particular project repository, just miscellaneous code he's hosting. It looks like it's slightly more feature rich, allowing info from address books and a user's inbox, for example.


I only needed to authenticate our building, so thankfully we had our own subdomain (not sure of the proper terminology) in the AD... If your domain was example.com (DC=example,DC=com), just getting OUR office (assume "Office1") was as easy as defining office1.example.com (DC=office1,DC=example,DC=com) after the @ symbol in the user's username (typically unnecessary information with OWA, but adding it explicitly was important here). It (seemingly) worked perfectly.

If you plan on doing something similar, just make sure that you cache (and encrypt) username/password information locally, hitting the OWA page continuously would probably make your System (or Email) Administrators a little unhappy with you.

Posted by Brendon Kozlowski

Mar 13
Occasionally I'm working on something that has to scrape data, either from an HTML file, XML, or something similar. I'll often think of XPath for its sheer simplicity over REGEX. Thankfully, while looking for a solution on how to "screen scrape" Outlook Web Access to verify login credentials (mimic internal authentication to AD externally), I accidentally came across a blog post discussing this Firefox plugin by Brian Slesinsky. It allows you to simply right click on a DOM node in a page (or source file) and visually test your XPath queries to see the matches it will give back.

Firefox Plugin: XPath Checker

Posted by Brendon Kozlowski

(Page 1 of 31, totaling 155 entries)