Advertisement
Guest User

Untitled

a guest
Apr 5th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. $stdout = fopen( 'php://stdout', 'w' );
  2.  
  3. function execute_agi( $command )
  4. {
  5. GLOBAL $stdin, $stdout, $stdlog, $debug;
  6.  
  7. fputs( $stdout, $command . "\n" );
  8. fflush( $stdout );
  9. if ($debug)
  10. fputs( $stdlog, $command . "\n" );
  11.  
  12. $resp = fgets( $stdin, 4096 );
  13.  
  14. if ($debug)
  15. fputs( $stdlog, $resp );
  16.  
  17. if ( preg_match("/^([0-9]{1,3}) (.*)/", $resp, $matches) )
  18. {
  19. if (preg_match('/result=([-0-9a-zA-Z]*)(.*)/', $matches[2], $match))
  20. {
  21. $arr['code'] = $matches[1];
  22. $arr['result'] = $match[1];
  23. if (isset($match[3]) && $match[3])
  24. $arr['data'] = $match[3];
  25. return $arr;
  26. }
  27. else
  28. {
  29. if ($debug)
  30. fputs( $stdlog, "Couldn't figure out returned string, Returning code=$matches[1] result=0\n" );
  31. $arr['code'] = $matches[1];
  32. $arr['result'] = 0;
  33. return $arr;
  34. }
  35. }
  36. else
  37. {
  38. if ($debug)
  39. fputs( $stdlog, "Could not process string, Returning -1\n" );
  40. $arr['code'] = -1;
  41. $arr['result'] = -1;
  42. return $arr;
  43. }
  44. }
  45.  
  46.  
  47. $wsdl = "http://192.168.10.23:82?wsdl";
  48. $options = array(
  49. 'cache_wsdl' => 0);
  50. $client = new SoapClient($wsdl, $options);
  51. echo '<pre>'.print_r($client,true).'</pre>';
  52. $response = $client->__soapCall('About', array());
  53. echo '<pre>'.print_r($response,true).'</pre>';
  54.  
  55. #extract($agivars);
  56. $myFile = "/data/scripts/testCallerID.txt";
  57. $fh = fopen($myFile, 'w') or die("can't open file");
  58.  
  59.  
  60. $file_name = $argv[2]."-".$argv[1]."--".$client."---".$response;
  61.  
  62. $vartest= '123456';
  63. execute_agi("SET VARIABLE ScriptResult $vartest");
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement