<?php
/**
 * Template name:Report user

 */

get_header();
?>


<?php
session_start();

$wel2 = $_POST['wel2'];


//echo $_SESSION['uid'];
//echo $_SESSION['uname'];
//echo $_SESSION['uemail'];
//echo  $_GET['uid'];

$loginname=$_POST['login']; 
 $pass=$_POST['pass'];  
 $md5pass  = md5($pass);
/*$dbuser = "ezsmscan";
$dbpass = "sdnPRr6cXpQ5sASV";
$dbname = "ezsmscan";
$dbhost = "65.182.188.219";*/

$dbuser = "ezsmscan";
$dbpass = "sdnPRr6cXQ5sA";
$dbname = "ezsmscan";
$dbhost = "207.191.234.131";
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to database");
	mysql_select_db($dbname);

   /*Check email id */
//$queryEmail="SELECT * FROM reports";

//$reult=mysql_query($queryEmail);
//$data = mysql_fetch_array($reult);
//print_r($data);

//$querym="select * from portscan";
//$r=mysql_query($querym);
//$d= mysql_fetch_array($r);
						
//print_r($d);
  ?>

<!--Main Container Start Here-->
  <section id="content_wrapper_main">
    <section class="content_wrapper">
      <section class="form-area">
	    
        <article class="form-main">
		
		
			<article class="logoutbtn">
				<a href="<?php bloginfo('url');?>/logout">Logout?</a> 
			</article>
			<article class="back">
				<form action="/welcome-user" method="post">
				<input type="hidden" name="backid" value="<?php echo $_SESSION['uid']; ?>">
				<input type="submit" value="back">
				</form>
			</article>
		
		
          <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:20px; font-size:12px; font-family:arial; clear: both;">
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="2" class="scan_title" style="font-weight:bold;">Host Information:</td>
                  </tr>
                  <tr>
                    <td width="20%" style="font-weight:bold;">Customer</td>
                    <td width="80%"><?php echo $_SESSION['uname']; ?></td>
                  </tr>
                  <tr class="rowodd">
                    <td style="font-weight:bold;">E-mail Address</td>
                    <td><?php echo $_SESSION['uemail']; ?></td>
                  </tr>
                  <tr>
                    <td style="font-weight:bold;">Target IP</td>
					<?php 
					$queryEmail="SELECT * FROM reports where userid = '".$_SESSION['uid']."' and id = '".$wel2."'";
					//$queryEmail="SELECT * FROM reports where userid = '1269'";
							$reult=mysql_query($queryEmail);
						 $data = mysql_fetch_array($reult);
						 //print_r($data[0]);?>
                    <td><?php echo $data['ip']; ?></td>
                  </tr>
                  <tr class="rowodd">
                    <td style="font-weight:bold;">Target hostname</td>
                    <td><?php echo $data['hostname']; ?></td>
                  </tr>
                  <tr>
                    <td style="font-weight:bold;">Target Port</td>
                    <td><?php echo $data['port']; ?></td>
                  </tr>
                  <tr class="rowodd">
                    <td style="font-weight:bold;">HTTP Server</td>
                    <td><?php echo $data['banner']; ?></td>
                  </tr>
                  <tr>
                    <td style="font-weight:bold;">Site Link (Name)</td>
                    <td><a href="http://<?php echo $data['hostname']; ?>"><?php echo "http://".$data['hostname'].":".$data['port']; ?></a></td>
                  </tr>
                  <tr class="rowodd">
                    <td style="font-weight:bold;">Site Link (IP)</td>
                    <td><a href="http://<?php echo $data['ip']; ?>"><?php echo "http://".$data['ip'].":".$data['port']; ?></a></td>
                  </tr>
                </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                 
				<td colspan="5" class="scan_title">Service Summary</td>
  <?php 
				 $query2="select port, service, banner from portscan where id = '".$wel2."'";
						 $reult2=mysql_query($query2);
						 //$data2 = mysql_fetch_array($reult2);
						 ?>
                  <tr>
				   <td width='20%' style='font-weight:bold;'>Port</td>
                    <td width='20%' style='font-weight:bold;'>Status</td>
                    <td width='20%' style='font-weight:bold;'> TCP/UDP</td>
                    <td width='20%' style='font-weight:bold;'>Service</td>
                  </tr>
                  
				<?php
				  $row= 0;
						 while($row2 = mysql_fetch_array($reult2))
						{ 
							if($row%2==0)
							{$bg='background-color:#E0E0E0';}
							else
							{$bg='background-color:#fff';}

						  
echo "<tr class='rowodd' style='$bg'>
<td>".$row2['port']."</td><td>open</td><td>tcp</td><td>".$row2['service']."</td></tr>";
					$row++;	
		
				}
					?>
                 
                  
                </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="2" class="scan_title">Blacklist Check</td>
                  </tr>
				<?php 
				 $query3="select dnsbl, listed from dnsbl where id = '".$wel2."'";
			
						 $reult3=mysql_query($query3);
						 //$data3 = mysql_fetch_array($reult3);
						 ?>
                  </tr>
				  	<?php
					$row= 0;
						 while($row3 = mysql_fetch_array($reult3))
						  {
							   if($row%2==0)
							{
								 $bg='background-color:#E0E0E0';
							}
							else
							{
								$bg='background-color:#ffffff';
							}
							  if($row3['listed'] == '0')
							  {
								$unlisted = 'UNLISTED';
							  }
							   if($row3['listed'] == '1')
							  {
								$unlisted = 'LISTED';
							  }
							  echo "<tr class='rowodd' style='$bg'>
<td width='20%' style='font-weight:bold;'>RBL: ".$row3['dnsbl']."</td><td width='80%'>".$unlisted."</td></tr>";
					
		$row++;	
				}
					?>

                 
                </table></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="2" class="scan_title">Vulnerabilities</td>
                  </tr>

<?php  $query4="select hostname, port, osvdb, method, uri, message, ip  from nikto where reportid  = '".$wel2."'";
						 $reult4=mysql_query($query4);
						 //$data4 = mysql_fetch_array($reult4);
						 ?>

                  <tr>

					<?php
					 $row= 0;
					  while($row4 = mysql_fetch_array($reult4))
						  {
						  $uri=	str_replace("<script>","< script>",$row4['uri']);
						  $msg= str_replace("<script>","< script>",$row4['message']);
							 if($row%2==0)
							{
								 $bg='background-color:#ffffff';
							}
							else
							{
								$bg='background-color:#E0E0E0';
							}
echo "<tr class='rowodd' style='$bg'><td style='font-weight:bold;'>URI</td><td>".wordwrap($uri,115,"<br>\n",TRUE)."</td></tr>
	<tr class='rowodd' style='$bg'><td style='font-weight:bold;'>HTTP Method</td><td>".$row4['method']."</td></tr>
	<tr class='rowodd' style='$bg'><td style='font-weight:bold;'>Description</td><td>".wordwrap($msg,115,"<br>\n",TRUE)."</td></tr>
	<tr class='rowodd' style='$bg'><td style='font-weight:bold;'>Test Links</td><td> <a href='http://".$row4['hostname'].$row4['uri']."'>http://".$row4['hostname'].":".$row4['port'].wordwrap($uri,70,"<br>\n",TRUE)."</a><br><a href='http://".$row4['ip'].$row4['uri']."'>http://".$row4['ip'].":".$row4['port'].wordwrap($uri,70,"<br>\n",TRUE)."</a></td></tr>	
	<tr class='rowodd' style='$bg'><td style='font-weight:bold;'>OSVDB Entries</td><td><a href='http://osvdb.org/".$row4['osvdb']."' target='_blank'> 	OSVDB-".$row4['osvdb']."</td></tr>";

			$row++;	
				}
					?>

                </table></td>
            </tr>
            <tr>
              <td>
              
              <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="2" class="scan_title">Internal Scan</td>
                  </tr>
                  <tr>
                    <td width="20%" style="font-weight:bold;">Scan</td>
                    <td width="80%">Skipped</td>
                  </tr>
                  
                </table>
              
              
              </td>
            </tr>
            <tr>
              <td>
              
              <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="2" class="scan_title">Host Summary</td>
                  </tr>
                  <tr>
                    <td width="20%" style="font-weight:bold;">Start Time</td>
                    <td width="80%"><?php echo $data['date']; ?></td>
                  </tr>
                  
                   <tr class="rowodd">
                    <td width="20%" style="font-weight:bold;">End Time</td>
                    <td width="80%"><?php echo $data['endtime']; ?></td>
                  </tr>
                  
                   <tr>
                    <td width="20%" style="font-weight:bold;">Elapsed Time</td>
                    <td width="80%"><?php echo $data['elapsedtime']; ?></td>
                  </tr>
                  
                   <tr class="rowodd">
                    <td width="20%" style="font-weight:bold;">Statistics</td>
                    <td width="80%"><?php echo $data['stats']; ?></td>
                  </tr>
                  
                </table>
              
              
              </td>
            </tr>
          </table>

        </article>
        <!--form-main ends here -->
      </section>
      <!--form-area ends here -->
    </section>
  </section>
  <!--Main Container Ends Here-->

	<?php get_footer(); ?>
</div><!--wrapper ends here -->
