<?php
/*
 * This software is to enable displaying Axiom output 
 * on the Firefox web browser.  It falls under the 
 * GNU version 2 general public license and comes 
 * WITHOUT ANY WARRANTY WHATSOEVER.
 * COPYRIGHT : (C) 2006 Arthur C. Ralfs
 */

//need to strip slashes if magic quotes are turned on
              
	      $in = ini_get('magic_quotes_gpc')
                    ? stripslashes($_POST['command'])
                    : $_POST['command'];

	      $address = "127.0.0.1";
	      $service_port = 9876;
	      $ansize = 65536;

              $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	      if ($socket < 0)
	      {echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";}
	      else
	      {}//echo "OK socket created.\n";}

//	      echo "\nAttempting to connect to '$address' on port '$service_port'...";
              $result = socket_connect($socket, $address, $service_port);
	      if ($result < 0) {
	      echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
	      } else {
//	      echo "OK connected.\n";
	      }



//	     echo "Sending  command to axiom\n";
	     socket_write($socket, $in, strlen($in));
             $out = socket_read($socket, $ansize);
	     $out = trim($out);
	     echo $out;
	     socket_close($socket); ?>
