Plus: Book Reviews, Product Reviews and much more Conquer JpGraphConquer JpGraph XML Transformation With PEAR Using PEAR::XML_Transformer Advanced Features Revealed Form Validation From the Outside In A New And Interesting Perspective Practical Web Services with PHP APRIL 2003 www.phparch.com VOLUME II - ISSUE 4 The Magazine For PHP Professionals php|architect Migrating WebMigrating Web Applications to PHPApplications to PHP Computer Science Concepts With PHPComputer Science Concepts With PHP Writing A Parser And Expression Evaluator As PHP’s importance grows on the IT scene—something that is happening every day—it’s clear that its true capabilities go well beyond what it’s being used for today. The PHP platform itself has a lot of potential as a general-purpose language, and not just a scripting tool; just its basic extensions, even discounting repositories like PEAR and PECL, provide a high- quality array of functionality that most of its commercial competitors can’t afford without expensive external components. At php|a, we’ve always felt that our mis- sion is not limited to try our best to pro- vide the PHP community with a publica- tion of the highest possible quality. We think that our role is also that of reinvest- ing in the community that we serve in a way that leads to tangible results. To that end, this month we’re launching the php|architect Grant Program, a new initiative that will see us award two $1,000 (US) grants to PHP-related proj- ects at the end of June. Participating to the program is easy. We invite all the leaders of PHP projects to register with our website at http://www .phparch.com/grant and submit their applications for a grant. Our goal is to provide a financial incentive to those projects that, in our opinion, have the opportunity to revolutionize PHP and its position in the IT world. In order to be eligible for the Grant Program, a project must be strictly related to PHP, but not necessarily written in PHP. For example, a new PHP extension written in C, or a new program in any language that lends itself to using PHP in new and interesting ways would also be acceptable. The only other important restriction is that the project must be released under either the LGPL, the GPL or the PHP/Zend license. Thus, commercial products are not eligible. Submit Your Project Today! Visit http://www .phparch.com/grant for more information Introducing the php|architect Grant Program 3 IINNDDEEXX Departments php|architect Features 10 Advanced Features in JpGraph By Jason E. Sweat 21 Form Validation From the Outside In A New Perspective on Form Validation By Peter James 30 The Realization of Freedom Migrating From Proprietary Tools to PHP By Dave Palmer 41 Practical Web ServicesWith PHP and XML-RPC By Stuart Herbert 52 Using The PEAR::XML_Transformer By Bruno Pedro 61 When A Meets B Writing a Parser and Expression Evaluator in PHP By Marco Tabini 5 EDITORIAL RANTS php|architect: A New Community 7 NEW STUFF 35 REVIEW From Electronic Microsystems PostgreSQL Manager and MySQL Manager 66 BOOK REVIEWS • MySQL • Administering and Securing the Apache Server 69 exit(0); PHP For Suits: The Neverending Saga By Marco Tabini TABLE OF CONTENT April 2003 · PHP Architect · www.phparch.com Technologies Ltd. Visit www.zend.com for evaluation version and ROI calculator Zend Performance Suite Reliable Performance Management for PHP Serve More. With Less. The designers of PHP offer you the full spectrum of PHP solutionsThe designers of PHP offer you the full spectrum of PHP solutions 5 EEDDIITTOORRIIAALL RRAANNTTSS php|architect Volume II - Issue 4 April, 2003 Publisher Marco Tabini Editor-in-Chief Brian K. Jones brian@phpar ch.com Editorial Team Arbi Arzoumani Brian Jones Peter James Marco Tabini Graphics & Layout Arbi Arzoumani Administration Emanuela Corso Authors Stuart Herbert, Peter James, Dave Palmer, Bruno Pedro, Jason E. Sweat, Marco Tabini php|architect (ISSN 1705-1142) is published twelve times a year by Marco Tabini & Associates, Inc., P.O. Box. 3342, Markham, ON L3R 6G6, 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 © 2002-2003 Marco Tabini & Associates, Inc. — All Rights Reserved pphhpp||aarrcchhiitteecctt:: AA NNeeww CCoommmmuunniittyy Since I first came on board as an editor here (only days after the launch of php|architect’s first issue), I’ve had the dis- tinct pleasure of forming relationships with some of the greatest minds in the PHP community. As a budding Editor in Chief, it has become quite clear to me that our ability to form synergistic, collabora- tive relationships with our authors is something of an anomaly in the magazine publishing industry. Lucky for me, it’s one that is a welcome change to the authors I’ve interacted with. I’m proud to have a part in creating this apparently new para- digm in publishing, and this seemingly new perspective on the editor-author rela- tionship. I like to think of the editorial process as the creation of what I am now dubbing ‘A New Community’; A new community of people from different walks of life, having vastly different views on how different technologies should work together, differ- ent experiences to share, and from dis- parate cultures and geographic regions of the Earth. A community bonding on the common goals of furthering both the development of PHP as a complete, stable, mature development platform, and the progress of other PHP developers. The end result of this highly iterative, interactive process is what is ultimately delivered to you by php|architect every month. Not just a magazine, but a some- what interactive experience in itself. Let’s not forget that in addition to working hard to produce the magazine each month, the members of our editorial staff are also con- sumers of this magazine! As a result, we experience along with all of you the feel- ing that we are really being taken by the hand through what seems like a tour of a particular project undertaken by a particu- EDITORIAL April 2003 · PHP Architect · www.phparch.com April 2003 · PHP Architect · www.phparch.com 6 EDITORIAL lar developer. At the end of the tour, we’re handed the bits of code which are out in production somewhere, making things tick. As a consumer, I find this amazingly useful. I hope anyone reading this agrees, or will send me email telling me how we can make things even better. In addition, I invite those who might cur- rently be passive consumers of information to get involved! If you’re reading this, you’re quite likely a PHP developer. Chances are also good that you have a unique opinion or perspective on some aspect of technology that touches us here in the PHP community. We invite you to participate more actively in the ‘New Community’ by sharing your knowledge, thoughts, and ideas with the rest of us. We’ve just released a new version of our author’ s guidelines, which can help get you started. Anything that this leaves you wondering about can be addressed by ask- ing our editorial staff at write@phpar ch.com. It could very well be that you haven’t participated yet because you haven’t seen a product offered by php|architect that looks like a good fit for your own work. Maybe you want to write a book, or start a new project of unforeseeable dimensions. I urge anyone in this position to write to editors@phpar ch.com with your concerns in this area. It’s quite possible that we have a project in the works that could benefit from your input. The plain and unequivocal fact is that php|architect is growing quite rapidly. This growth stems from the ideas of those col- laborating on the direction of php|archi- tect as a diversified company – not just a magazine. For example, php|architect has recently been translated and redistributed in Japanese for that market. This has been a successful venture for all of those involved, as well as the community at large, and we urge any other parties inter- ested in localized versions of php|architect to contact us – editors@phparch.com. What’s more, php|architect will soon see the release of our first full-fledged book, with more work in this area ongoing. I won’t use this space to divulge the details now, but stay tuned to my monthly edito- rial for more as things progress. In the wake of Wrox’s disappearance from the publishing world (a result of their parent company’s apparent insolvency), we at php|architect feel some obligation to at least partially fill the gap that will inevitably result in the area of authoritative PHP coverage. From someone who owns several Wrox books, I can sincerely say that their work is well appreciated, and will be sorely missed. We can only hope to do our best to keep up with the needs of a con- stantly growing developer base. Luckily, we don’t have to have the breadth of cov- erage in our books that Wrox had in theirs – I have no desire to work on a Java book! These are just a couple of the ideas we’re currently pursuing. Since no entity can claim monopoly ownership over all good ideas, it’s only natural that we reach out and make it known that we are a compa- ny which fosters and values ideas. If you have an idea for which an outlet has yet to be identified, we hope you’ll consider con- tacting us for help in discovering how best to pursue your goals. Now on with the show! I’m excited by what lies between this editorial and Marco’s exit(0) (actually, I kinda like the editorial and exit(0) as well). I hope you can find enlightenment and inspiration from the articles which follow. Let us know your thoughts: editors@phpar ch.com NNEEWW SSTTUUFFFF NEW STUFF The PHING is Loose! PHING (PHing Is Not Gnumake) is a make tool written in PHP and based on the ideas and con- cept of Apache Ant. It can basically do anything you could do with a build system like Gnumake, for example, but uses XML for storing the targets and commands. Using XML, Phing avoids prob- lems like the “Space before tab problem” in Gnumake. Current features include processing files while copying (e.g. do Token Replacement, XSLT transformation etc.) and various file system operations. Phing is written in the PHP scripting language and designed to be extensible. Thus, you can eas- ily add the behaviour you need for your project by adding a class (known as tasks). Additionally, Phing is platform independent and runs on Unix like systems and Windows. Phing is currently used to build binarycloud, a PHP Application Framework, and is maintained by its developers. For more information, or to download Phing, visit its website at http://binar ycloud.com/phing/. April 2003 · PHP Architect · www.phparch.com 7 PHP Architect Wo Yomitai! We’re happy to announce the introduction of the Japanese edition of php|architect! Published by Asial Corporation, the best PHP company in Japan, the publication is called PHP Programmer’s Magazine and it pro- vides all the great content of php|a, plus many localized features specif- ic to the Japanese market. Asial (http://www .asial.co.jp) is a Tokyo-based company that special- izes in the production of PHP sys- tems and the localization of soft- ware and documentation for the Japanese market. You can find the PHP Programmer’s Magazine website at http://www .phppro.jp If you are interested in localizing php|a in your language, don’t hesi- tate to drop us a note at info@phparch.com. What’s NNew! ionCube Announces Special Offer The ionCube standalone PHP encoder is a high per- formance and complete PHP encoding solution, employing the technique of compiled code encod- ing to maximize both runtime performance and code protection. Encoded scripts can be run by the free Loader product with a standard PHP server in one of two ways. The Loader can be installed in php.ini, and this delivers the best performance and is compatible with safe mode. For users with no access to php.ini, on many systems the Loader can be installed “on demand” by the scripts themselves. This requires no php.ini edits or server restart. The Base Edition comes with a single user license and, as with all current ionCube products, full sup- port and upgrades are included for Free. To download an evaluation or purchase of the standalone encoder, you can visit the ionCube web- site at http://www.ioncube.com . NEW STUFF eZ publish 3 Released ezPublish 3 is a professional open source content management system and development frame- work. As a CMS its most notable feature is its revolu- tionary, fully customizable and extendable content model. This is also what makes it suitable as a plat- form for general web development. Its stand- alone 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. For more info, visit the eZPublish website at http://ez.no . phpOpenTracker 1.1.1. Is Unleashed! phpOpenTracker is a framework solution for the analysis of Web site traffic and visitor behaviour. It features a logging engine that, either invoked as a Web bug by an HTML image tag or embed- ded with two lines of code into your PHP applica- tion, logs each request to a Web site into a data- base. One installation can track an arbitrary num- ber of Web sites. Through its API, you can easily access the gathered data and perform complex operations on it (for instance, the analysis of your visitors’ click paths). For more information, visit the phpOpenTracker website at http://www .phpopentracker.de/. MySQL AB Launches MySQL 4.0, Announces Certification Program MySQL AB, producers of the popular MySQL database management system, have announced the release of version 4.0 of their flagship product, which is now officially ready for production. Meanwhile, they have started development of version 4.1, which will include such long-awaited goodies as subqueries. Through the MySQL certification program, MySQL software developers can earn one or more formal credentials that validate their knowledge, experience and skill with the MySQL database and related MySQL AB products. The MySQL certification program consists of sev- eral unique certifications. The first, which is now generally available, is called the MySQL Core Certification. The Core Certification provides MySQL users with a formal credential that demon- strates proficiency in SQL, data entry and mainte- nance, data extraction for reporting and more. The MySQL Professional Certification, which will be available in Q3 of this year, is for the more experienced MySQL user who wants to certify his or her knowledge in MySQL database manage- ment, installation, security, disaster prevention and optimization. MySQL Core certification will be a prerequisite for taking the Professional Certification exam. MySQL also plans to offer a MySQL PHP Certification by the end of the year, which is designed for the MySQL and PHP developer who wants to simultaneously certify his knowledge of MySQL and of the PHP Web development tool. In addition, a MySQL DBA Certification, a top-level certification for the most accomplished MySQL gurus, will be offered in 2004. If you are interested and want to know more, check out the MySQL website at http://www .mysql.com. PHP 4.3.2RC1 Released The first public release candidate of the lat- est version of PHP was posted for down- load on the PHP.Net website earlier this month. The new version includes several bug fixes and a few new features com- pared to version 4.3.1, which was released in February in response to a CGI-related security issue. For more information, visit the PHP web- site at http://www .php.net. April 2003 · PHP Architect · www.phparch.com 8 php|a FFEEAATTUURREESS Advanced FFeatures iin JpGraph FEATURES April 2003 · PHP Architect · www.phparch.com 10 J pGraph (http://www .aditus.nu/jpgraph/) is a PHP class library that easily enables you to generate profes- sional quality graphs using a minimal amount of code. This article is a case study illustrating some of JpGraph’s advanced features; specifically, it covers the following: • a generalized methodology for JpGraph script development • the evolutionary process of developing a graph (in contrast to presenting only the final product) • the use of server-side caching with JpGraph for performance • the use of Client Side Image Maps (CSIM) to implement “drill-down” functionality in your graphs Installation and Environment The easiest way to get started with JpGraph is to down- load the source, available at http://www .aditus.nu/jpgraph/jpdownload.php. Next, unpack the source archive into a directory in PHP’s include path. Now you can modify the paths to your installed fonts, as well as to the cache directory. These settings are found in jpgraph.php. To verify that your installation is working, view the testsuit.php file in the examples directory. This page generates over 200 example graphs using JpGraph, and allows you to review the code for each of them. If you’re just learning JpGraph and exploring its capa- bilities, you will find the manual very handy. It’s avail- able at http://www .aditus.nu/jpgraph/jpdownload.php, and has both a narrative text and an excellent class refer- ence. You might also want to visit the JpGraph support forum at http://jpgraph.fan-atics.com/ . All of the scripts in this article were developed and tested using PHP 4.3.0 (with the built-in GD2 library) running as a module under Apache 1.3.27 on RedHat Linux 7.2. The code in this article was developed using MySQL (http://www .mysql.com/) as a database, and ADOdb (http://php.weblogs.com/adodb ) as a database abstraction layer. To this end, all of the scripts include a common file called phpa_db.inc.php, shown in Listing 1. Advanced FFeatures iin JpGraph By Jason E. Sweat This article originated as a case study in the newest book in the Wrox Handbook series: PHP Graphics (http://www.wrox.com/books/1861008368.htm). This material was omitted in the final publication of the book, and was modified for presentation here. PHP Version: 4.0.4 minimum, 4.1 recommended O/S: Any Additional Software: JpGraph, GD Enabled PHP REQUIREMENTS [...]... • Beginning PHP • Developing MySQL Applications with PHP • Performance Tuning PHP CHECK OUT THE PROGRAM & REGISTER TODAY! • XML with PHP http://www .php- con.com/pa • PHP Web Services with SOAP PHPCon East 2003 Park Central New York Hotel EAST2003 New York City, New York April 23 - 25, 2003 Tutorial and conference sessions are subject to change FEATURES FEATURES The Realization of Freedom Migrating From... intranet webmaster for a Fortune 100 company He has written several tutorials and articles for the Zend website, and has recently contributed to the Wrox "PHP Graphics" handbook He resides in Iowa with his wife and two children Click HERE To Discuss This Article https://www.phparch.com/discuss/viewforum .php? f=12 csim_stroke .php Connect with your database Publish your data fast with PHPLens PHPLens is... } return false; } ?> April 2003 · PHP Architect · www.phparch.com 28 Use PHP? Love PHP? Live PHP! PHP is an Open Source (for three days) scripting language with serious technical muscle No wonder it’s the language of choice for Yahoo, Inc and over 8 million domains worldwide Whether you’re a PHP pro or completely new to the language, PHPCon East 2003 will take you to the next level Meet and mingle... interest in open source web application development has led you to PHP (I believe I can safely assume this because you are, after all, reading a magazine focused on PHP! ) For myself, incorporating and utilizing PHP (and open source software in general) into my arsenal of tools was an evolutionary process It started slow, building steam to where I am now: a full blown open source /PHP advocate Of Zines... using nothing but PHP (on Linux with MySQL), and finally realized that this PHP stuff was for real It became clear to me that PHP (pardon the introduction of controversy) was technically (and in my mind politically) superior to ColdFusion With this minor revelation in hand, I set out to convert Diysearch from a collection of ColdFusion hacks into a unified and homogenous PHP- based web application Having... occurred to me The problem I was trying to solve had already been solved in a whole slew of different ways, many of which could be found in the open source universe After some deliberation, I settled on using PHPNuke (http://www.phpnuke.org) For those that are not aware, PHPNuke - or “Nuke” April 2003 · PHP Architect · www.phparch.com Porting and Migrating and the Move to PHP is an open source content management... constructor, it calls the 10 // button label parent constructor The submit button class has an 11 var $desc; extra variable, $desc, that holds the button title This 12 13 // constructor is also set in the constructor 14 function FormSubmit($name, $desc='Submit') The get_element() function is, again, a required 15 { implementation from the base class It simply returns 16 // call parent constructor 17... plot axes) 3 Create the Plots to add to the Graph object 4 Finalize the Graph object and output the April 2003 · PHP Architect · www.phparch.com graph Following this process for graph development, you first need to retrieve the sales and forecast data To see how you use ADOdb to retrieve the data for these graphs, please review lines 26-122 of the abc_reg_sales_graph .php file The focus of this article... $graph->Stroke(); region_pie_graphs .php Because there is now HTML information (the CSIM) in addition to the binary image content, you can't stream it back to the browser like you normally would The CSIM and the image depend on each other too much In order to make this work, you need to cache the image This allows you to output the image map, as well as the image tag used to fetch the cached image Instead... cache outlined above, we'll use another form of image caching and store it in a place where we can request it directly To accomplish this you will need to create a directory called img immediately below the script directory This directory must be writeable by the web server When you are creating the graph, treat it as if you were going to stream the image In the pie chart loop, add the CSIM information . Practical Web Services with PHP APRIL 2003 www.phparch.com VOLUME II - ISSUE 4 The Magazine For PHP Professionals php| architect Migrating WebMigrating Web Applications. Applications to PHPApplications to PHP Computer Science Concepts With PHPComputer Science Concepts With PHP Writing A Parser And Expression Evaluator As PHP s