Read..read…read…data inside file and file

nah dari judulnya memang sangat sulit untuk dimengerti sama dengan artikel yang akan saya tulis berikut ini. jika memang sulit dimengerti mohon maklum karena saya tidak jago dalam berkata-kata..:D. Nah langsung saja kita mulai apa yang dimaksud dari artikel ini. yang dimaksud dari artikel ini adalah bagaimana kita dapat membaca file yang berisi link kemudian didalam file tersebut terdapat link menuju file lain yang didalam file lain itu akan terdapat isi dari file yang lain pula..nah binggungkan…untuk memudahkannya saya akan memperlihatkannya dengan mengunakan struktur gambar.

nah penjelasannya gini..
didalam file host berisi :

www.detik.com
www.google.co.id

didalam file tampunghosts-17_06_2011-13-192.168.3.117-www.detik.com.txt

192.168.3.1    
10.10.248.1    
202.73.96.73   
202.73.96.73   
218.100.27.192 
203.190.244.6  
203.190.242.69 

didalam file hasilping-17_06_2011-14-192.168.3.117-218.100.27.192

debian,192.168.3.117,218.100.27.192,2011-5-17 14:0:20,50,0.94,0.85,3.19,0.0000,100.0000,0 
debian,192.168.3.117,218.100.27.192,2011-5-17 14:10:20,50,0.92,0.81,3.24,0.0000,100.0000,0 
debian,192.168.3.117,218.100.27.192,2011-5-17 14:20:21,50,0.91,0.82,3.31,0.0000,100.0000,0.01 

nah lalu bagaimana kita dapat membaca file yang berada di hasil_ping melalui file host..begini source codenya…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
/*
 * function to call data txt
 */
function explodeRows($data){
	$rowsArr = explode("\n",$data);
	return $rowsArr;
}
function explodeTabs($singleLine){
	$tabsArr = explode(",",$singleLine);
	return $tabsArr;
}
?>
<table width="100%" border="1">
  <tr>
    <th width="21%" bgcolor="#00CCFF" scope="col">IP LIST</th>
    <th width="79%" bgcolor="#00CCFF" scope="col">TRACEROUTE</th>
  </tr>
  <tr>
    <td height="317" valign="top" bgcolor="#00FFFF">
    <?php
		$iphost = "tampung_ping/hosts.txt";
		$handle = fopen($iphost,'r');
		$data = fread($handle,filesize($iphost));
		$rowsArrip1 = explodeRows($data);
		
		$hitungip = count($rowsArrip1);
		
		for($i=0;$i<$hitungip;$i++){
			$lineDetail = explodeTabs($rowsArrip1[$i]);

			$lines =  $lineDetail[0];//source 
			print "<a href='?ip=".$lines."'>".$lines."</a><br/>";
			
			$dhandle = glob('tampung_ping/tampung*');
			$hitung = count($dhandle); //menghitung jumlah file tampung
			for($a=0;$a<1;$a++){
				$han = explode('-', $dhandle[$a]);
				$variable =  $han[0]."-".$han[1]."-".$han[2]."-192.168.3.117-".trim($lines).".txt";
				
				$reading = fopen($variable,'r');
				$da = fread($reading,filesize($variable));
				$rowrow = explodeRows($da);
				
				$hitungrow = count($rowrow);
				for($c=0;$c<$hitungrow;$c++){
					$linedet = explodeTabs($rowrow[$c]);
					$lined = $linedet[0];
					
					print "<ul>";
					print "<li><a href=?ip=".$lined.">".$lined."</a><br/></li>";
					print "</ul>";
				}
			}
		}
	?>
    </td>
    <td valign="top" bgcolor="#FFFFFF">
    <?php
	/*
		 * get data from sending ip 
		 */
		if(!empty($_GET['ip'])){
			
			    $hand = glob('tampung_ping/hasilping*');
			    $total = count($hand);
			    for($a=0;$a<1;$a++){
			    	$handout = explode('-',$hand[$a]);
			    	$vari = $handout[0]."-".$handout[1]."-".$handout[2]."-192.168.3.117-".$_GET['ip'];
			    	//echo $vari;
			    	//reading file
			    	$reader = fopen($vari,'r');
			    	$do = fread($reader,filesize($vari));
			    	$rowro = explodeRows($do);
			    	
			    }
		}else{
			    echo "<blink>Warning!!! Anda Belum memilih IP di list</blink>";
		}
		?>

		
		<table id="rounded-corner">
            <thead>
					<tr>
							<th scope="col" class="rounded-company">IP Source</th>
							<th scope="col" class="rounded-q1">IP Destination</th>
							<th scope="col" class="rounded-q2">Date Timestamp</th>
							<th scope="col" class="rounded-q3">Count Integer</th>
							<th scope="col" class="rounded-q4">Rtt Avarage</th>
							<th scope="col" class="rounded-q5">Rtt Min</th>
							<th scope="col" class="rounded-q6">Rtt Max</th>
							<th scope="col" class="rounded-q7">PacketLoss</th>
							<th scope="col" class="rounded-q8">Reacilbility</th>
							<th scope="col" class="rounded-q9">Jitter</th>
						
					</tr>
		     </thead>
		     <tbody>
          <?php
		  if(!empty($rowro)){
						//$total = count($rowsArrip) - 1; //get total row with count and - 1
						$total = count($rowro) - 1;						
						//echo readLine( $filename,1);
						print "Table List Monitoring System";
						for($i=0;$i<$total;$i++){
							$lineDetails = explodeTabs($rowro[$i]);
							$line1  =  $lineDetails[0];
							$line2  =  $lineDetails[1];//source 
							$line3  =  $lineDetails[2];//destination
							$line4  =  $lineDetails[3];//collectime
							$line5  =  $lineDetails[4];//iterasi
							$line6  =  $lineDetails[5];//avarage
							$line7  =  $lineDetails[6];//packetloss
							$line8  =  $lineDetails[7];//min
							$line9  =  $lineDetails[8];//max
							$line10 =  $lineDetails[9];//avability
							$line11 =  $lineDetails[10];//jitter
							print "<tr>\n";
							print "<td>" .$line1. "</td>\n";
							print "<td>" .$line2. "</td>\n"; 
							print "<td>" .$line3. "</td>\n";
							print "<td>" .$line4. "</td>\n";
							print "<td>" .$line5. "</td>\n";
							print "<td>" .$line6. "</td>\n";
							print "<td>" .$line7. "</td>\n";
							print "<td>" .$line8. "</td>\n";
							print "<td>" .$line9. "</td>\n";
							print "<td>" .$line10. "</td>\n";
							print "<td>" .$line11. "</td>\n";
							print "</tr>\n";
						}
					}else{
						//print "Silahkan pilih list";
					}
				
				?>
				
			</tbody>
		</table>
   </td>
  </tr>
</table>
</body>
</html>

nah begitu caranya..,,,,kurang jelas silahkan bertanya jika bisa saya jawab pasti dibantu…:D

2 thoughts on “Read..read…read…data inside file and file

  1. mas,, gimana sih caranya internet mengunakan cmd hack pada win7,,,,,aku masih nggak ngerti,,,,,tolong dong….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s