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

 */

get_header();

session_start();
//echo $_SESSION['uid'];
if($_SESSION['uid'] == ''){
$_SESSION['uid'] = $_POST['backid'];
echo $_SESSION['uid'];
}
//echo $_SESSION['uname'];
//echo $_SESSION['uemail'];

$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 */
$sortingCode = "";
if (isset($_REQUEST['sort_element']) && $_REQUEST['sort_element'] != "") {
    $sort_element = " ORDER BY ".$_REQUEST['sort_element']." ";
} 
if (isset($_REQUEST['sort_type']) && $_REQUEST['sort_type'] != "") {
    $sort_type = " ".$_REQUEST['sort_type']." ";
} 
$sortingCode = "$sort_element $sort_type";

   $queryEmail="SELECT * FROM reports where userid = '".$_SESSION['uid']."' $sortingCode";
//$queryEmail="SELECT * FROM reports where userid = '1269'";
$result=mysql_query($queryEmail);


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


  ?>
<!--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>
          <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:20px; font-size: 12px; clear: both;">
            <tr>
              <td><table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#e0e0e0" class="scan_server">
                  <tr>
                    <td colspan="5" class="scan_title">Welcome <?php echo $_SESSION['uname']; ?> : </td>
                  </tr>
                  <tr>
				    
                    <td width="20%" height="25px" style="font-weight:bold;">Hostname</td>
                    <td width="20%" height="25px" style="font-weight:bold;">
				    <a title="Click to sort by IP" href="?sort_element=ip&sort_type=<?php echo ($_REQUEST["sort_element"] == "ip"  && $_REQUEST["sort_type"] == "asc") ? "desc" : "asc"; ?>">IP
					 <?php if ($_REQUEST["sort_element"] == "ip" ) {  
						if($_REQUEST["sort_type"] == "desc" ) { ?>
						<img style="float:right" class="sorting" src="http://www.easyservermanagement.com/wp-content/uploads/2015/08/arrowtop.png" alt="asc">
						<?php } else { ?>
						  <img style="float:right" class="sorting" src="http://www.easyservermanagement.com/wp-content/uploads/2015/08/arrowbottom.png" alt="desc"> 
						<?php }
						
						 } ?>
					</a>
					</td>
					
					 <td width="20%" height="25px" style="font-weight:bold;"><a title="Click to sort by Date" href="?sort_element=date&sort_type=<?php echo ($_REQUEST["sort_element"] == "date"  && $_REQUEST["sort_type"] == "asc") ? "desc" : "asc"; ?>">Date
					
					 <?php if ($_REQUEST["sort_element"] == "date" ) {  
						if($_REQUEST["sort_type"] == "desc" ) { ?>
						<img style="float:right" class="sorting" src="http://www.easyservermanagement.com/wp-content/uploads/2015/08/arrowtop.png" alt="asc">
						<?php } else { ?>
						  <img  style="float:right" class="sorting" src="http://www.easyservermanagement.com/wp-content/uploads/2015/08/arrowbottom.png" alt="desc"> 
						<?php }
						
						 } ?>
					
					</a></td>
                     <td width="20%" height="25px" style="font-weight:bold;">Status</td>
					  <td width="20%" height="25px" style="font-weight:bold;">View</td>
                  </tr>

				
				  <?php
				  $row= 0;
						 while($welcome = mysql_fetch_array($result))				 
						  {
						  
						 
						if($row%2==0)
							{$bg='background-color:#ffffff';}
							else
							{$bg='background-color:#fff';}



							if($welcome['complete'] == '0')
							  {
								$view = '<input type="button" name="view" value="View">';
							  }
							   if($welcome['complete'] == '1')
							  {
								$view = '<input type="submit" name="view" value="View">';
							  }


							echo "<tr class='rowodd' style='$bg'>
				
							<td width='20%'>".$welcome['hostname'].":".$welcome['port']."</td>
							<td width='20%'>".$welcome['ip'].":".$welcome['port']."</td>
							<td width='20%'>".$welcome['date']."</td>
							<td width='20%'>".($welcome['complete']==1 ? 'Finished' : 'Pending...')."</td>
							<td width='20%'>
							<form action='/proposal/' method='post'>
							<input type='hidden' name='welcome' value='".$welcome['id']."'>".$view."</form>
							</td>
								</tr>";
							$row++;	
						  }
						  ?>
						 
						
                 </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 -->
