#!/usr/bin/php -q 0) { if (($in_string != "quit") && ($in_string != "")) { // get file to be included $inc = substr($in_string,0,strpos($in_string," ")); $remainder = substr($in_string,strpos($in_string," ")+1); // parse function from command $cmd = substr($remainder,0,strpos($remainder," ")); // parse parameters from remainder of command $preparm = substr($remainder,strpos($remainder," ")+1); $parm = explode(" ",$preparm); if ($verbosity == DEBUG) { log_data("Include->".$inc."<-\n"); log_data("Command->".$cmd."<-\n"); log_data("Arguments->".$preparm."<-\n"); log_data("ArgV->".$parm[0]."-".$parm[1]."-".$parm[2]."-".$parm[3]."<-\n"); } // check for existance of function. If exists call it if ($cmd != "") { if (!function_exists($cmd)) { if (file_exists($inc)) { // quirk in php R5.0RC3, believe it or not.... // if (($environ == "cactid") || (getcwd() == dirname(__FILE__))) { $inc = strtolower($inc); // } include_once($inc); } else { log_data("ERROR: PHP Script File to be included, does not exist\n"); } } } else { log_data("ERROR: PHP Script Server encountered errors parsing the command\n"); } if (function_exists($cmd)) { $result = call_user_func_array($cmd, $parm); if (!is_numeric($result)) { $result = "U"; log_data("ERROR: Result from PHP Script Server was Invalid\n"); } if (strpos($result,"\n") != 0) { fputs(STDOUT, $result); } else { fputs(STDOUT, $result . "\n"); } if ($verbosity == HIGH) { log_data("PHPSERVER: CMD:" . $in_string . " output " . $result . "\n"); } } else { log_data("ERROR: Function does not exist\n"); fputs(STDOUT, "ERROR: Function does not exist\n"); } }elseif ($in_string == "quit") { fputs(STDOUT, "PHPSERVER: PHP Script Server Shutdown request received, exiting\n"); if ($verbosity == HIGH) { log_data("PHPSERVER: PHP Script Server Shutdown request received, exiting\n"); } break; }else { log_data("ERROR: Problems with input\n"); fputs(STDOUT, "ERROR: Problems with input\n"); } }else { log_data("ERROR: Input Expected\n"); fputs(STDOUT, "ERROR: Input expected\n"); } } ?>