VOLUME III - ISSUE JUNE 2004 TM The Magazine For PHP Professionals NEURAL NETWORKS > Artificial Intelligence made easy with PHP and FANN < Automatic language detection Make your script determine the language of written text Spell checking with PHP www.phparch.com Efficient Oracle Programming Portable and stable GUI applications with PHP and XUL Incredible-looking forms with PHP, PDF and FDF Plus: Tips & Tricks, Product Reviews, Security Corner and much more This copy is registered to: YOU Jump Right To It Sign up before July 20th and save up to $100! Christian Mayaud — Getting Your OSS Business Funded, Rasmus Lerdorf — Best Practices for PHP Developers, Jim Elliott — Open Source: The View from IBM, Daniel Kushner — Attacking the PHP Market, Andrei Zmievski — Andrei’s Regex Clinic, Wez Furlong — Introducing PDO, Regina Mullen — OSS in Legal Technology, Derick Rethans — Multilingual Development with PHP, George Schlossnagle — PHP Design Patterns and many, many more! php|w rks Toronto, Sept 22-24, 2004 Three days of pure PHP http://www.phparch.com/phpworks TABLE OF CONTENTS php|architect Departments I N D E X Features 10 Editorial TM Low-impact Programming with PHP and Oracle by John Neil What’s New! 19 Spell checking with PHP by Ilia Alshanetsky 42 Product Review 26 PHP | FDF by Richard Lynch Maguma Workbench 2.0.4.1 by Peter B MacIntyre 36 62 Cyber-PHP Neural Networks with FANN and PHP by Evan Nemerson Tips & Tricks By John W Holmes 47 PHP and XUL by Jonathan Protzenko 65 exit(0); PHP And the What-if Machine by Andi Gutmans and Marco Tabini 55 PHP File Management—An Introduction by Peter B MacIntyre June 2004 ● PHP Architect ● www.phparch.com You’ll never know what we’ll come up with next EXCLUSIVE! For existing subscribers Subscribe to the print edition and get a copy of Lumen's LightBulb — a $99 value absolutely FREE †! Upgrade to the Print edition and save! In collaboration with: Login to your account for more details † Lightbulb Lumination offer is valid until 12/31/2004 on the purchase of a 12-month print subscription php|architect Visit: http://www.phparch.com/print for more information or to subscribe online The Magazine For PHP Professionals php|architect Subscription Dept P.O Box 54526 1771 Avenue Road Toronto, ON M5M 4N5 Canada Name: Address: _ City: _ State/Province: Your charge will appear under the name "Marco Tabini & Associates, Inc." Please allow up to to weeks for your subscription to be established and your first issue to be mailed to you *US Pricing is approximate and for illustration purposes only Choose a Subscription type: Canada/USA International Air Combo edition add-on (print + PDF edition) $ 97.99 CAD $139.99 CAD $ 14.00 CAD ($69.99 US*) ($99.99 US*) ($10.00 US) ZIP/Postal Code: _ Country: _ Payment type: VISA Mastercard American Express Credit Card Number: Expiration Date: _ Signature: Date: *By signing this order form, you agree that we will charge your account in Canadian dollars for the “CAD” amounts indicated above Because of fluctuations in the exchange rates, the actual amount charged in your currency on your credit card statement may vary slightly E-mail address: Phone Number: To subscribe via snail mail - please detach/copy this form, fill it out and mail to the address above or fax to +1-416-630-5057 EDITORIAL E D I T O R I A L R A N T S T his month’s issue marks the first time, at least to my knowledge, that a topic such as artificial intelligence has been discussed on a PHP publication AI is one of those topics most people talk about without really understanding its capabilities—and this has resulted in a lot of confusion out there If you’re worried that your server will become sentient and try to take over the world (or, worse, spend all your money), you can rest assured that that will not be the case (at least until you run Internet Explorer—that’ll the trick) However, a technology like neural networks can come in very handy for a website developer Ad-hoc predictive solutions for tasks such as fraud prevention and customer enticement already exist out there and are well available for everyone to use—at an often steep price As a PHP developer, however, you are both luckier and less fortunate at the same time The FANN library extension that is now available through PECL provides you with the facility needed to create, train and execute a generic neural network, which means that you can not only build applications similar, or even better, to the ones available commercially, but that you can also build new and exciting ones On the other hand, designing and training a neural network is a bit of a “black art” that requires a lot of trial and error, so that you’ll have to be very creative with it It’s excellent news for us that Evan Nemerson, who is the author and maintainer of the extension (as well as one of the original authors of the library) has agreed to tackle the problem of creating a neural net from a practical perspective—building a simple script that is capable of automatically determining the language in which a string of text is written Even with surprisingly little training (and, even better, very little actual PHP code), the network can reach surprisingly high levels of accuracy Still, I’m fairly convinced that, once more people start appreciating the abilities of the FANN library in finer detail, we’ll see applications built on top of it become available for everyone to use and tweak—and before you know it, your computer will shut down at the sound of “I’ll be back” Neural networks are not all we’re doing this month, of course Ilia Alshanetsky covers spell checking—a topic that can be helpful to everyone who runs a website As it turns out (but not surprisingly), PHP has excellent facilities that support spell-checking operations We also have a great article on optimizing Oracle-based websites—now that Oracle is placing more and more interest in open-source projects, this is likely to come in handy to more and more developers, even if they are not in the enterprise arena If you ever wanted to create beautiful-looking forms but dreaded the prospect of converting them to PDF, you’ll likely be Continued on page June 2004 ● PHP Architect ● www.phparch.com php|architect Volume III - Issue June, 2004 Publisher Marco Tabini Editorial Team Arbi Arzoumani Peter MacIntyre Eddie Peloke Graphics & Layout Arbi Arzoumani Managing Editor Emanuela Corso Director of Marketing J Scott Johnson scott@phparch.com Account Executive Shelley Johnston shelley@phparch.com Authors Ilia Alshanetsky, Andi Gutmans, Richard Lynch, John Neil, Evan Nemerson, Peter B MacIntyre, Jonathan Protzenko php|architect (ISSN 1709-7169) is published twelve times a year by Marco Tabini & Associates, Inc., P.O Box 54526, 1771 Avenue Road, Toronto, ON M5M 4N5, Canada Although all possible care has been placed in assuring the accuracy of the contents of this magazine, including all associated source code, listings and figures, the publisher assumes no responsibilities with regards of use of the information contained herein or in all associated material Contact Information: General mailbox: info@phparch.com Editorial: editors@phparch.com Subscriptions: subs@phparch.com Sales & advertising: sales@phparch.com Technical support: support@phparch.com Copyright © 2003-2004 Marco Tabini & Associates, Inc — All Rights Reserved NEW STUFF eZ publish 3.4 eZ.no announces the release of eZ publish 3.4 N E W S T U F F What’s New! “eZ publish is an open source content management system and development framework As a content management system (CMS) it’s most notable feature is its revolutionary, fully customizable, and extendable content model This is also what makes it suitable as a platform for general Web development Its standalone libraries can be used for cross-platform, database independent PHP projects eZ publish is also well suited for news publishing, e-commerce (B2B and B2C), portals, and corporate Web sites, intranets, and extranets eZ publish is dual licensed between GPL and the eZ publish professional license.” View more information at eZ.no phpPgAdmin 3.4 Released Postgresql.com announces the phpPgAdmin 3.4 release of “phpPgAdmin is a web-based administration tool for all 7.x versions of PostgreSQL.” Some new features include: • Add CACHE and CYCLE parameters in sequence creation • View, add, edit and delete comments on tables, views, schemas, aggregates, conversions, operators, functions, types, opclasses, sequences and columns (Dan Boren & ChrisKL) • Add config file option for turning off the display of comments • Allow creating array columns in tables • Allow adding array columns to tables • many more… Zend Technologies and Apollo Interactive Unite Thursday, May 27th 2004 13:48:55 GMT “Apollo Interactive®, America's leading Interactive Agency, and Zend Technologies, the PHP company, today announced a partnership to promote excellence in open source development Through the alliance, the companies will share their varied technology perspectives to improve the functionality of the PHP language ¾ which was developed by the founders of Zend ¾ and refine PHP implementation for large, high-volume enterprise Web sites The combination of Apollo’s significant PHP site development experience and Zend’s technological expertise will help drive the continued evolution of PHP, an open source Web scripting language that is gaining momentum as the most popular language to power dynamic Web sites.The alliance will further the development of PHP’s infrastructure and enable Zend to establish best practices for its implementation in large enterprise environments.” Get all the info at Postgresql.com For more information visit: www.zend.com June 2004 ● PHP Architect ● www.phparch.com NEW STUFF PHP5 Coding Contest Want to put your PHP5 Skills to the test? Zend has announced its PHP5 coding contest, of which php|architect is also a sponsor “We’ve got lots of Prizes to give out just for entering, as well as the Grand Prizes: a top-of-the-range Dell laptop for a developer working by himself or an Apple iPod Mini for each member of your team! Your application will be rated both by your peers and by the panel of Judges we’ve assembled from among the most known and well-respected names in the PHP community.” PHP 4.3.7 Released PHP.net announced the release of PHP 4.3.7 The PHP Development Team is proud to announce the release of PHP PHP 4.3.7 This is a maintenance release that, in addition to several non-critical bug fixes, addresses an input validation vulnerability in escapeshellcmd() and escapeshellarg() functions on the Windows platform Users of PHP on Windows are encouraged to upgrade to this release as soon as possible For more information visit: http://qa.php.net/ Get all the Contest information from Zend.com Looking for a new PHP Extension? Check out some of the lastest offerings from PECL BLENC 1.0alpha BLENC is an extension that hooks into the Zend Engine, allowing for transparent encryption and execution of PHP scripts using the blowfish algorithm It is not designed for complete security (it is still possible to disassemble the script into op codes using a package such as XDebug), however it does keep people out of your code and make reverse engineering difficult odbtp 1.1.1 This extension provides a set of ODBTP, Open Database Transport Protocol, client functions ODBTP allows any platform to remotely access Win32-based databases Linux and UNIX clients can use this extension to access Win32 databases like MS SQL Server, MS Access and Visual FoxPro Fileinfo 0.2 This extension allows retrieval of information regarding vast majority of file This information may include dimensions, quality, length, and so on Additionally it can also be used to retrieve the mime type for a particular file and for text files proper language encoding PDO_ODBC 0.1.1 This extension provides an ODBC v3 driver for PDO It supports unixODBC and IBM DB2 libraries, and will support more in future releases Windows binary available from: http://snaps.php.net/win32/PECL_STABLE/php_sqlite.dll PDO_MYSQL 0.1 This extension provides a Mysql 3.x/4.0 driver for PDO June 2004 ● PHP Architect ● www.phparch.com NEW STUFF php|architect New at php|a: PayPal support and single prints Monday, June 7th 2004 13:22:00 GMT You asked for it! php|architect's purchasing system now accepts PayPal as a valid payment method! You can use your PayPal account safely and securely to pay for all your php|a purchases Also, effective immediately you can now purchase individual print issues that will be delivered directly to your doorstep Expect more past issues to become available as we update our inventory and introduce new shipping methods to get the magazines out to you faster! PHP Release Candidate Released! Tuesday, June 8th 2004 12:48:09 GMT PHP.net announces the third release candidate of PHP5! The third (and hopefully final) Release Candidate of PHP is now available! This mostly bug fix release improves PHP 5's stability and irons out some of the remaining issues before PHP can be deemed release quality Everyone is now encouraged to start playing with it! There are few changes changes since Release Candidate 2, which can be found here For more information visit: www.php.net php|a Check out some of the hottest new releases from PEAR Config 1.10.1 The Config package provides methods for configuration manipulation • Creates configurations from scratch • Parses and outputs different formats (XML, PHP, INI, Apache ) • Edits existing configurations • Converts configurations to other formats • Allows manipulation of sections, comments, directives • Parses configurations into a tree structure • Provides XPath-like access to directives PHP_Beautifier 0.0.6.1 This program reformats and beautifies PHP source code files automatically The program is Open Source and distributed under the terms of PHP License It is written in PHP and has a command line tool XML_HTMLSax3 3.0.0RC1 XML_HTMLSax3 is a SAX-based XML parser for badly formed XML documents, such as HTML The original code base was developed by Alexander Zhukov and published at http://sourceforge.net/projects/phpshelve/ Alexander kindly gave permission to modify the code and license for inclusion in PEAR PEAR::XML_HTMLSax3 provides an API very similar to the native PHP XML extension (http://www.php.net/xml), allowing handlers using one to be easily adapted to the other The key difference is HTMLSax will not break on badly formed XML, allowing it to be used for parsing HTML documents Otherwise HTMLSax supports all the handlers available from Expat except namespace and external entity handlers Provides methods for handling XML escapes as well as JSP/ASP opening and close tags DB_DataObject 1.6.1 DataObject performs tasks: It builds SQL statements based on the objects vars and the builder methods It acts as a datastore for a table row The core class is designed to be extended for each of your tables so that you put the data logic inside the data classes June 2004 ● PHP Architect ● www.phparch.com NEW STUFF Editorial: Contiuned from page LightBulb 5.02 Lumen Software announces the release of LightBulb 5.02 “LightBulb is a complete, browser-based, WYSIWYG PHP development suite which includes a PHP application generator, a code editor (with context and classes prompting and highlighting), a complete middleware/framework environment (Lumenation), a GUI application interface, record locking, HIPPA application compliance, user application logging, transaction logging, current user monitoring, a library of PHP classes and data access security, DB compatibility, a report builder, a query builder, an SQL builder, a source code manager, an application management system, and a virtual desktop system metaphor, and many other features.” interested in this month’s article on FDF forms—PHP provides an excellent interface to Adobe’s FDF library that lets you combine a PDF form with POST data and create a print-quality document with little or no effort Elsewhere, we cover XUL, the interface development language that must have been born out of one Mozilla developer asking the others “and now, how we it in Windows?” XUL is great for building a GUI application that can be ported across several operating systems and that requires almost no programming—and, certainly, no code in C, Visual Basic et similia Finally, this issue also marks the debut of our very own Peter MacIntyre in the role of reviewer and author Peter is a great help in the editorial process—and, as it turns out, an incredibly gifted reviewer Now, if I could only interest him in some Italian food… For more information or to download, visit ezsdk.com php|a June 2004 ● PHP Architect ● www.phparch.com ... Cyber -PHP Neural Networks with FANN and PHP by Evan Nemerson Tips & Tricks By John W Holmes 47 PHP and XUL by Jonathan Protzenko 65 exit(0); PHP And the What-if Machine by Andi Gutmans and Marco... ezsdk.com php| a June 2004 ● PHP Architect ● www.phparch.com Low-impact Programming with PHP and Oracle by John Neil F E A T U R E PHP and Oracle are an excellent combination for creating powerful and. .. most known and well-respected names in the PHP community.” PHP 4.3.7 Released PHP. net announced the release of PHP 4.3.7 The PHP Development Team is proud to announce the release of PHP PHP 4.3.7