write a script using php telnet to a server

Solutions on MaxInterview for write a script using php telnet to a server by the best coders in the world

showing results for - "write a script using php telnet to a server"
Lukas
21 Apr 2017
1<?php
2// configuration
3$file = '/var/log/apache2/access.log';
4$ip = '127.';
5// start of script
6$title = "\033[H\033[2K$file";
7if (strpos($_SERVER['REMOTE_ADDR'],$ip)!==0) die('Access Denied');
8$stream = fopen($file, 'r');
9if (!$stream) die("Could not open file: $file\n");
10echo "\033[m\033[2J";
11fseek($stream, 0, SEEK_END);
12echo str_repeat("\n",4500)."\033[s$title";
13flush();
14while(true){
15  $data = stream_get_contents($stream);
16  if ($data) {
17    echo "\033[32m\033[u".$data."\033[s".str_repeat("\033[m",1500)."$title";
18    flush();
19  }
20  usleep(100000);
21}
22fclose($stream);
23