PHP Classes

File: telnet_log.php

Recommend this page to a friend!
  Classes of Warren Jay Eggly   telnet_log   telnet_log.php   Download  
File: telnet_log.php
Role: ???
Content type: text/plain
Description: Class file that read a telnet tracelog file and output in readable format.
Class: telnet_log
Author: By
Last change:
Date: 22 years ago
Size: 2,604 bytes
 

Contents

Class file image Download
<?php /* // Class: telnet_log // // // Description: Reads a UNIX telnet tracefile's termdata which is saved in hex // and output it ASCII readable format. // // // Author: Warren Jay Eggly // Email: warren.eggly@sun.com // // Version: 0.1 // // .telnetrc file should look like this // // DEFAULT set tracefile <dir>/<filename> // DEFAULT set termdata // // // Usage: // // $text = new telnet_log( "<dir>/<filename>" ); // // echo $text->get(); // echo $text->get_html(); */ class telnet_log { var $text; function telnet_log( $file ) { if ( $this->open_file ( $fp, $file ) ) { $this->transfile ( $fp, $this->text ); $this->close_file ( $fp ); } } function get() { return $this->text; } function get_html() { return "\n<pre>" . htmlspecialchars( $this->text ) . "</pre>\n"; } // // // private function - do not call // // function transfile ( &$fp, &$text ) { while ( $this->getline ( $fp, $input )) { if ( $this->is_output_line( $input )) { $text .= $this->transdata ( $input ); } } } // // // private function - do not call // // function open_file ( &$fp, $file ) { $status = true; if ( is_file( $file ) && filesize( $file ) > 0 ) { $fp = fopen ( $file, "r" ); } else { $status = false; } if ( $fp && $status ) { return true; } else { return false; } } // // // private function - do not call // // function close_file ( &$fp ) { fclose ( $fp ); } // // // private function - do not call // // function transdata ( $input ) { $output = ""; $input = $this->getdata( $input ); for ( $i = 0; $i < strlen( $input ); $i += 2 ) { $output .= $this->getchar( substr($input, $i, 2 ) ); } return $output; } // // // private function - do not call // // function getchar( $char ) { return chr(hexdec($char)); } // // // private function - do not call // // function getline ( &$fp, &$input ) { if ( ! feof( $fp ) ) { $input = fgets ( $fp, 4096 ); return true; } else { return false; } } // // // private function - do not call // // function getdata( $line ) { $array = preg_split ( "/\s+/", $line ); return $array[2]; } // // // private function - do not call // // function is_output_line( $line ) { if ( preg_match ( "/^>/", $line ) ) { return true; } else { return false; } } } ?>