Your IP : 216.73.216.40


Current Path : /var/www/html/venkat/check3/
Upload File :
Current File : //var/www/html/venkat/check3/similar.php

<?php
?>
<html>
	<body bgcolor="#F0F8FF"> <center>
	<h2> <font color="blue"> Program Similarity check Portal</font> </h2>
	<form enctype="multipart/form-data" name="r" action="similar.php" method="post">
	<table width="35%" height="15%" cellspacing="1" cellpadding="1" border="1">
	<tr>
		<td>
		Choose the section You belongs to
		</td>
		<td>&nbsp; &nbsp; &nbsp;
			<select name="section">
  				<option value="cg2013">IGVC532C</option>
  				<option value="sec_a">Section: A</option>
  				<option value="sec_b">Section: B</option>
  				<option value="sec_c">Section: C</option>
  				<option value="rgiit">Section: RGIIT</option>
			</select>
		</td>
	</tr>
	</tr>
	<tr>
		<td> 
			<input type="submit" value="Submit">
		</td>
		<td>
			&nbsp;
		</td>
	</tr>
	</table>
	</center> </body>
</html>
<?php
if ($_POST["section"])
{
	ini_set('max_execution_time',160);
	ini_set('display_errors',1);
	ini_set('display_startup_errors',1);
	error_reporting(-1);
 	$section = $_POST["section"];
	$section1 = $section."dec.txt"; 
	$result = shell_exec("sort -f $section1");
	$result = explode("\n", $result);
	$comp = shell_exec("sort -f $section1");
	$comp = explode("\n", $comp);
	$sectionU = strtoupper($section);
	$i = 0;
	$uploaddir = "file/".$section."/";
	$myFile=$section."copy.txt";
	$myFile1=$section."graph.dot";
	$fh = fopen($myFile, 'w');
	$fh1 = fopen($myFile1, 'w');
	$stringdata1 = "digraph G {\n";
	fwrite($fh1, $stringdata1);
	while($result[$i])
	{
		$result1 =explode('|', $result[$i]);
		$k=0;
		$uploadfile2 = $uploaddir.$result1[0];
		$cc =  htmlspecialchars(shell_exec("cat $uploadfile2"));
		$cc = trim(preg_replace('/\s+/','', $cc));
		//$percent = round($percent);
		//$myFile=$section."copy.txt";
		//$myFile1=$section."graph.txt";
		//$fh = fopen($myFile, 'w');
		//$fh1 = fopen($myFile1, 'w');
		$percent1 = 0;
		$stringData = $result1[0] ;//new line
		while ($comp[$k])
		{
			$comp1 =explode('|', $comp[$k]);
			$uploadfile12 = $uploaddir.$comp1[0];
			$cc1= htmlspecialchars(shell_exec("cat $uploadfile12"));
			$cc1 = trim(preg_replace('/\s+/','', $cc1));
			similar_text($cc, $cc1, $percent);
			$percent = round($percent);
			if($percent >= 98 && $comp1[0] != $result1[0])
			{
				$percent1 = $percent;
				$stringData = $stringData. " | ".$comp1[0]. " : " . $percent;
				$str = strstr($result1[0], '.', true);
				$str1= strstr($comp1[0], '.', true);
				$stringdata1 = $str."->".$str1.";\n"; 
				fwrite($fh1, $stringdata1);
			}
			$k++; 
		}
		if ($percent1 >= 98)
		{

			$stringData = $stringData."\n" ;
			fwrite($fh, $stringData);
		}
		$i++;
	}	
	$stringdata1 = "}\n";
	fwrite($fh1, $stringdata1);
	$graph = $section."graph.dot";
	$graphout1 = "file/$section/graph.png";
	$graphout = "file/".$section."graph.png";
	echo"<center><font color='red'>Completed Successfully</font></center>";
	//shell_exec("dot -Tpng $graph -o $graphout");
	shell_exec("dot -Tpng $graph -o $graphout1");
}

?>