SoFunction
Updated on 2025-04-08

PHP's ASP firewall

<?

$ASPservername: This variable must have an IP in
Inside the /etc/hosts file.

$ASPport        : ASP file server port number.

$ASPpath: ASP file path on the server side.

$ASPfile: ASP file name

$ASPurlredirect : $ASP file parameters.

//Set variables
   $ASPservername  =  "WEB_SQLSERVER";
   $ASPport        = 80;
   $ASPpath        =  "/development/sqlserver/";
   $ASPfile        =  "?";
   $ASPurlredirect =  "clienthostpage=".strstr($SCRIPT_NAME, "/");

//Connect the IIS/ASP server
   $fp=fsockopen($ASPservername, $ASPport, &$errno, &$errstr);

   if($fp) {
//GET mode to server
      $sRequest = "GET ".$ASPpath.$ASPfile;
      $sProtocol= " HTTP/1.0 \n\n";

      if (!strlen(chop($QUERY_STRING))){
         $httpget=$sRequest.$ASPurlredirect.$sProtocol;
      } else {
         $httpget=$sRequest.$QUERY_STRING.$sProtocol;
      }

//Send request from the client to the ASP file
      fputs($fp,$httpget);

// Processing returns the result
      while(!feof($fp)) {
         $line=fgets($fp,128);

//Show the ASP file to return the result
         if ($bTripped){
            echo $line;
         } else {
//Processing IIS header information
            $bTripped=strstr(strtoupper($line), "<HTML>");
            if ($bTripped) echo $line;
         }
      }
      fclose($fp);
   } else {
      echo  "$errstr ($errno)<br>\n";  
   }
?>