"Story Code-O-Matic", "pageId" => "scom", "minimalist" => "no" ); renderXslt( "", $templateDir."scom.xsl", $params, null ); exit; } $out = pascalString( $query ); $xml = getCodeXml( $out ); $params = array( "pageTitle" => "Story Code-O-Matic", "pageId" => "scom", "minimalist" => $minimalist ); renderXslt( $xml, $templateDir."scom.xsl", $params, null ); function getCodeXml( $in ){ $count = 0; do { $remote = fsockopen( "127.0.0.1", "5050", $errno, $errstr, 2 ); } while( !$remote && $count++ < 3 && sleep( 1 ) ); if( !$remote ){ error_log( "Could not contact story code server after 3 tries: $errno: $errstr, cl: $in" ); $retval = "Error contacting backend server"; return $retval; } fputs( $remote, $in."\n" ); $result = ""; while( !feof( $remote ) && ( $in = fgets( $remote, 4096 ) ) ){ $result .= $in; } fclose( $remote ); return $result; } ?>