Our web site has grown over the years, and we've developed a number of very useful scripts such as our quotation system that's written in Perl and our live server test program in Tcl and Expect. Now we require to run those scripts within the current look and feel, with its printer friendly flexibility, customisation to reflect the country from whom our visitors arrive, and so on, all of which are facilities offered by PHP. This can't simply be done by adding PHP tags into the output of the Perl or Tcl programs - cgi output is NOT parsed by the PHP interpreter - so how have we done it?
* New PHP pages call up the cgi scripts, now using them as application servers, and extract the pertinant information they return.
* Our cgi-bin scripts are little changed, but we
have added markers in the form of HTML comments to indicate the start and end of the content generated.
* In the case of CGI scripts which use form inputs, we have also updated the scripts so that they can read parameters from the command line in addition to URL-encoding.
Try out our
new server status page and see how it works. You can see the
source code here and you can
still run it the old way here (Shhh - don't tell the look-and-feel team).
The extra code in the PHP page is just:
$howsit = implode("",file("http://$_SERVER[SERVER_NAME]/cgi-bin/net/livetest.exp"));
preg_match('/<!-- start -->(.*)<!-- end -->/is',$howsit,$gotten);
(written 2006-04-08, updated 2006-06-05)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
T212 - Tcl/Tk - Expect Processes [287] Checking that all our servers are up and accessible - (2005-04-22)
[1173] Cheat Sheet / Check list for Expect maintainers - (2007-05-02)
[1785] What is running on your network? (tcl and expect) - (2008-09-04)
[2474] Using Tcl and Expect to automate repetitive jobs - (2009-10-24)
[2489] Parallel Pinging, using Python Threads or Expect spawn lists - (2009-11-02)
[3448] Checking all the systems on a subnet, using Expect and Tk - (2011-09-18)
[4678] Expect with Ruby - a training example to get you started - (2016-05-18)
H112 - PHP - Further Web Page and Network Handling [220] When to use Frames - (2005-02-19)
[314] What language is this written in? - (2005-05-17)
[345] Spotting a denial of service attack - (2005-06-12)
[356] Sudoku helper or sudoku cheat - (2005-06-23)
[372] Time calculation in PHP - (2005-07-08)
[376] What brings people to my web site? - (2005-07-13)
[410] Reading a news or blog feed (RSS) in your PHP page - (2005-08-12)
[425] Caching an XML feed - (2005-08-26)
[443] Server side scripting of styles to suit the browser - (2005-09-12)
[451] Accessing a page via POST from within a PHP script - (2005-09-26)
[484] Setting the file name for a downloaded document - (2005-11-03)
[537] Daily Image Santafied - (2005-12-22)
[542] Morning image, afternoon image - (2005-12-26)
[565] Using PHP to output images, XML, Style sheets, etc - (2006-01-15)
[603] PHP - setting sort order with an associative array - (2006-02-13)
[767] Finding the language preference of a web site visitor - (2006-06-18)
[789] Hot answers in PHP - (2006-07-02)
[847] Image maps for navigation - a straightforward example - (2006-08-28)
[904] Of course I'll tell you by email - (2006-10-25)
[936] Global, Superglobal, Session variables - scope and persistance in PHP - (2006-11-21)
[1009] Passing GET parameters through Apache mod_rewrite - (2006-12-27)
[1114] PHP Image upload script - (2007-03-21)
[1183] Improving searches - from OR to AND? - (2007-05-11)
[1187] Updating a page strictly every minute (PHP, Perl) - (2007-05-14)
[1210] PHP header() function - uses and new restrictions - (2007-05-30)
[1355] .php or .html extension? Morally Static Pages - (2007-09-17)
[1379] Simple page password protection - PHP - (2007-10-04)
[1485] Copyright and theft of images, bandwidth and members. - (2007-12-26)
[1495] Single login and single threaded models - Java and PHP - (2008-01-04)
[1496] PHP / Web 2 logging - (2008-01-06)
[1505] Script to present commonly used images - PHP - (2008-01-13)
[1515] Keeping staff up to date on hotel room status - (2008-01-22)
[1518] Downloading data for use in Excel (from PHP / MySQL) - (2008-01-25)
[1549] http, https and ajp - comparison and choice - (2008-02-22)
[2632] Shipping a test harness with your class in PHP - (2010-02-12)
[2679] How to build a test harness into your PHP - (2010-03-16)
[2729] Uploading a document or image to its own URL via a browser - (2010-04-18)
[2918] Downloading a report from the web for further local analysis - (2010-08-13)
[3036] Sending out an email containing HTML from within a PHP page - (2010-11-07)
[3432] 3 digit HTTP status codes - what are they, which are most common, which should be a concern? - (2011-09-11)
[3540] Easy session example in PHP - keeping each customers data apart - (2011-12-06)
[3568] Telling which ServerAlias your visitor used - useful during merging domains - (2012-01-04)
[3918] Multiple page web applications - maintaining state - PHP - (2012-11-10)
[4070] Passing variable between PHP pages - hidden fields, cookies and sessions - (2013-04-26)
[4483] Moving from mysql to mysqli - simple worked example - (2015-05-03)
Some other Articles
More or less on the edge of the pageWhy are maps rarely to scale?Sympathetic developmentMelksham, WiltshireAdding PHP tags to an old cgi programWiltshire to get an extra MPHelicopter views and tartansKeeping your regular expressions simpleBoth ends of the animalArchitectural Heritage - Devizes