The following blog entry was written by Larry Nies, president of NSC, Inc. He has been working with PHP on the IBM i since 2005, when he installed his first open-source PHP stack. The following year, he switched to the Zend Technologies PHP application server for IBM i.
During the six years I have been working with PHP on IBM i, I have seen it evolve into a sophisticated Web-application language. In 2006 one of my customers began using Zend Core and Zend Platform (from Zend Technologies) and has since moved to Zend Server.
I wrote my first application with nothing to guide me except a couple of samples that someone else wrote to run on a non-IBM i platform. For example, I was looking for an application to allow a customer’s customers to download/upload files (due to the email file size limitations). I found a UNIX open-source PHP script for FTP that was written by Edwin van Wijk. I downloaded Edwin's open-source PHP version and then decided that if I was going to change this script to work on the IBM i, I might as well have it work for Linux, Mac and Windows as well, to cover the customer’s other FTP servers.
Initially, I had to change the program to also allow public access without a login, as that was the method that my customer wanted to use. I then went about parsing the data received back from the various platforms--IBM i, Linux, Mac and Windows--when FTPed so as to provide a Windows Explorer look, similar to that which was in the original PHP script. Once I got the data stream parsed, based on the server platform, I began the task of streamlining the selection of the “FTP Hosts” using an array and a config.ini file that included all of the information needed to make the various server connections. It looked something like this:
; Variable List:
; host = Host IP or Server name
; srvname = Server Name to appear in Dropdown List
; port = Server FTP Port #
; passive = FTP Passive true/false depending on Server
; directory = Base Directory for User Login
; user = User for logging on to the FTP Server
; password = User password for logging on to the FTP Server
; adduserid = Add User ID to the Directory Path true/false
; navdelete = Ability to Delete files/folders from Navigation Menu
; navdownload = Ablility to download files from Navigation Menu
; publicaccess = Is this a PUBLIC access Y/N
; PublicFTP Additional Variable List:
; user = Default USER for PUBLIC Access
; password = Default PASSWORD for PUBLIC Access
; Note: You can have any number of Sets with information the PHP script will handle accordingly.
;== Set 1
Now that I had my config.ini file with all of the server information, I could add as many FTP platforms that I wanted to various FTP servers. Not only does this open-source code work with IBM i but it is also cross-platform enabled.
Have any scripts you’d like to share? Please add them in the Comments section below.