Internet Application Code Library

Server Admin Stuff

Most Internet applications share a lot of common, generic tasks such as

  • Connect to a database and work with data
  • Manage sessions
  • Password-protect content
  • Send email
  • Consume RSS feeds
  • Work with XML data
  • Screen-scraping
  • ...and much, much more
As I develop what I think is clean, efficient, and powerful code to perform these tasks in a generic fashion, I put it here in my library. I do this for myself as a reference, but you can enjoy these code examples, too.

Buy Troy a Latte

You wouldn't want me walking around decaffeinated would you? You can add any amount of money to my Latte Land card.

About the author

Troy Wolf is the author of SnippetEdit--a PHP application providing browser-based website editing that even non-technical people can use. Website editing as easy as it gets. Troy has been a professional Internet and database application developer for over 12 years. He has many years' experience with ASP, VBScript, PHP, Javascript, DHTML, CSS, SQL, and XML on Windows and Linux platforms.

Server Admin Stuff


Step-by-step guide to installing Apache, MySQL, PHP, and phpMyAdmin on your Windows XP Pro or Home computer.

PHP (server-side)

AJAX Cross-Domain Solution: proxy.php

Need to use AJAX (XmlHttpRequest) to make client-side requests to content on domains other than your own? Browser security prevents you from doing this, but there are a lot of legitimate reasons to do it. My proxy.php to the rescue! proxy.php is built on top of my popular class_http You simply pass a url to proxy.php, and it will go get the content then forward the headers and body to your client. The script supports posting a form--your form will be re-posted to the content page you requested.

Robust Server to Server Communication Class and Screen-Scraping with Caching: class_http.php

This is a PHP screen-scraping class with caching. It includes methods to access content protected by basic authentication and for caching images directly. It even cloaks itself as the User Agent of the user requesting your script. This may allow you to retreive content from sites that actively ban screen-scraping. Included are methods to extract data from HTML tables into arrays.

Turn Any XML Document Into an Easily Accessible PHP Array: class_xml.php

Pass in any standard XML, and an easily enumerated data object you can use in your PHP scripts is created.

PHP Session Replacement with Login Authentication and Caching: class_session.php

This is a PHP class that makes is very easy to maintain state between pages giving you control over the timeout. You are no longer limited by PHP's built-in session expiration. The class also makes it very easy to password-protect PHP pages.

Common Interface to Multiple Database Types with Caching: class_db.php

This is a PHP class that makes is very easy to work with a database. Actually, PHP already makes that easy. What this class offers is a common interface to multiple database types. It currently supports MySql, Postgres, and MSSQL, and adding additional database types is trivial. The other HUGE thing this class gives you is caching. With class_db, it's very simple to store datasets to a local cache file to preserve precious database resources. The class makes this process almost seamless to your code. Caching is perfect for applications that make a lot of queries for data that doesn't change often or where you just don't need fresh data more than say once an hour or maybe daily.

Easily Consume RSS Feeds: RSS Example

class_http.php can be combined with class_xml.php to create powerful RSS consumption tools. Here is an example function.

Use PHP to access Exchange Data: Microsoft Exchange WebDAV Examples

Use PHP to query your Exchange data using PHP. These examples incorporate class_http.php and class_xml.php.

Dynamically Generate VCards: class_vcard.php

This is a PHP class to generate version 3.0 vCards. Give your visitors a simple one-click link to import your contact information into their contact database.

ServerBeach DNS Tool API: class_sbdns.php

class_sbdns is a PHP class that provides an API that automates 100% of the ServerBeach DNS Tool functionality. It is for ServerBeach customers only. If you are looking for an excellent server hosting company with even better prices, look no further than ServerBeach.

If you want to know how to automate a browser session including authentication, SSL, cookies, and posting forms, the source for this class is your friend. class_sbdns uses my popular class_http for the server to server communications.

HTML/CSS/Javascript (client-side)

SiteShow - a website slideshow utility

I built this self-contained HTML/CSS/Javascript slideshow utility in response to the need to develop a presentation for a company's 50" Plasma TV mounted in their lobby. The company alread had some great content on their Intranet website and had also developed some pages specifically for the display. They wanted the web pages to automatically cycle as if someone was navigating the pages. They also wanted the ability to interact with any page or "slide" as a normal web page. That is, they wanted to be able to interrup the show on any page and use the page's links and menu navigation, etc. The result was SiteShow.