|
| 1 | +<?php |
| 2 | + |
| 3 | +$PORT = '8080'; |
| 4 | +$IP = 'localhost'; |
| 5 | + |
| 6 | +$state = bin2hex(random_bytes(5)); |
| 7 | + |
| 8 | +$triggerUrl = "$argv[1]"; |
| 9 | + |
| 10 | +$socket = 'tcp://' . $IP . ':' . $PORT; |
| 11 | + |
| 12 | +$responseOk = "HTTP/1.0 200 OK\r\n" |
| 13 | + . "Content-Type: text/html\r\n\r\n" |
| 14 | + . " |
| 15 | + <!-- |
| 16 | + #ds-snippet-start:eSign44Step6 |
| 17 | + --> |
| 18 | + <br /> |
| 19 | + <h2>The document has been embedded with focused view.</h2> |
| 20 | + <br /> |
| 21 | +
|
| 22 | + <!DOCTYPE html> |
| 23 | + <html> |
| 24 | + <head> |
| 25 | + <meta charset=\"utf-8\" /> |
| 26 | + <title>Signing</title> |
| 27 | + <style> |
| 28 | + html, |
| 29 | + body { |
| 30 | + padding: 0; |
| 31 | + margin: 0; |
| 32 | + font: 13px Helvetica, Arial, sans-serif; |
| 33 | + } |
| 34 | + </style> |
| 35 | + </head> |
| 36 | + <body> |
| 37 | + <div> |
| 38 | + <iframe src=$triggerUrl width=800 height=600> |
| 39 | + </iframe> |
| 40 | + </div> |
| 41 | + </body> |
| 42 | + </html> |
| 43 | +
|
| 44 | + <p><a>Continue</a></p> |
| 45 | +
|
| 46 | + <!-- |
| 47 | + #ds-snippet-end:eSign44Step6 |
| 48 | + -->"; |
| 49 | + |
| 50 | +ini_set('default_socket_timeout', 60 * 5); |
| 51 | +$server = stream_socket_server($socket, $errno, $errstr); |
| 52 | +if (!$server) { |
| 53 | + Log::err('Error starting HTTP server'); |
| 54 | + return false; |
| 55 | +} |
| 56 | +do { |
| 57 | + $sock = stream_socket_accept($server); |
| 58 | + if (!$sock) { |
| 59 | + Log::err('Error accepting socket connection'); |
| 60 | + exit(1); |
| 61 | + } |
| 62 | + $contentLength = 0; |
| 63 | + $headers = []; |
| 64 | + $body = null; |
| 65 | + while (false !== ($line = trim(fgets($sock)))) { |
| 66 | + if ($line === '') break; |
| 67 | + $regex = '#^Content-Length:\s*([[:digit:]]+)\s*$#i'; |
| 68 | + if (preg_match($regex, $line, $matches)) { |
| 69 | + $contentLength = (int)$matches[1]; |
| 70 | + } |
| 71 | + $headers[] = $line; |
| 72 | + } |
| 73 | + if ($contentLength > 0) { |
| 74 | + $body = fread($sock, $contentLength); |
| 75 | + } |
| 76 | + list($method, $url, $httpver) = explode(' ', $headers[0]); |
| 77 | + if ($method == 'GET') { |
| 78 | + fwrite($sock, $responseOk); |
| 79 | + fclose($sock); |
| 80 | + return; |
| 81 | + } |
| 82 | +} while (true); |
| 83 | + |
| 84 | +?> |
0 commit comments