Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function makeStringGood($str) {
- return str_replace(array("\r",' '),array('','_'),trim($str));
- }
- function isOid($str) {
- if($str[0]==='1')
- return true;
- else
- return false;
- }
- $file = file_get_contents('mibs.bin');
- $fileArray = explode(chr(0),$file);
- //print_r($fileArray);
- $infoArray = array();
- $bitArray = array();
- foreach($fileArray as $line0) {
- $line = makeStringGood($line0);
- if(strlen($line)>0) {
- //echo "$line\n";
- $infoArray[]=$line;
- $bitArray[]=isOid($line);
- }
- }
- //print_r($bitArray);
- $sections=array();
- //$sections2=array();//hashmap
- foreach($bitArray as $i => $oidFlag) {
- if($oidFlag) {
- if(isset($bitArray[$i-1])) {
- if($bitArray[$i]===true) {
- if($bitArray[$i-1]===true) {
- $sections[]=$i;
- } else {
- $sections[]=$i-1;
- }
- }
- }
- }
- }
- //print_r($sections);
- $unknownNum=0;
- foreach($sections as $i => $startSection) {
- if(isset($sections[$i+1]))
- $endSection = $sections[$i+1];
- else
- $endSection = $startSection;
- for($j = $startSection;$j<$endSection;$j++) {
- //echo $infoArray[$j]."\n";
- if($j===$startSection) {
- if(isOid($infoArray[$j]))
- echo 'unknown'.$unknownNum++.' '.$infoArray[$j];
- else
- echo $infoArray[$j];
- } else {
- echo ' '.$infoArray[$j];
- }
- }
- echo "\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement