<?php




  $sigtype = strtolower( $_GET['sigtype'] );
  
  if ( $sigtype == "cades" ) {
    $pageid='upload1';
    $title='CAdES upload page';
  }
	
  if ( $sigtype == "xades" ) {
    $pageid='upload1';
    $title='XAdES upload page';
  }
  
///LVZ   to remove
  if ( $sigtype == "pades" ) {
    $pageid='upload4';
    $title='PAdES upload page';
  }
	
///LVZ   to remove
  if ( $sigtype == "esig" ) {
    $pageid='upload4';
    $title='Verification upload (TS 102 853)';
  }

///LVZ  2014-10-6
  if ( $sigtype == "upsig" ) {
    $pageid='upload4';
    $title='New signature upload';
  }
///LVZ 16-11-2011
  if ( $sigtype == "acert" ) {
    $pageid='acert';
    $title='Attribute Certificate Request page';
  }

///LVZ 16-11-2011
  if ( $sigtype == "xadesconf" ) {
    $pageid='xadesconf';
    $title='XAdES Conformance Checker';
  }

///LVZ 12-09-2013
  if ( $sigtype == "cadesconf" ) {
    $pageid='cadesconf';
    $title='CAdES Conformance Checker';
  }

///LVZ 14-04-2015
  if ( $sigtype == "padesconf" ) {
    $pageid='padesconf';
    $title='PAdES Baseline Conformance';
  }

///LVZ 12-09-2013
  if ( $sigtype == "asicconf" ) {
    $pageid='asicconf';
    $title='ASiC Conformance Checker';
  }

  if ( $sigtype == "asic" ) {
    $pageid='asic';
    $title='ASiC Container Upload';
  }
  if ( $sigtype == "rem" ) {
    $pageid='rem';
    $title='REM Upload';
  }
  if ( $sigtype == "erds" ) {
    $pageid='erds';
    $title='Evidence Upload';
  }

  $page_title = $title;
  require_once($_SERVER['DOCUMENT_ROOT'].'/protected/inc/'.'mainpage.inc.php');  
  getFirst();
?>
<script LANGUAGE="JavaScript">

var progressEnd = 15; // set to number of progress <span>'s.
var progressColor = 'blue'; // set to progress bar color
var progressInterval = 200; // set to time between updates (milli-seconds)

var progressAt = progressEnd;
var progressTimer;


      function confirmation() {
        var yesno = confirm ("Are you sure you want to procede to delete all your files?");
        if (yesno) {
          alert("Files have been deleted");
          return true;
        } else  {
          return false;
        }
      }

      function getValue(){
        var path = document.getElementById('thefile').value;
        if (path == ""){
          document.getElementById('formupload').action = 'http://signature-plugtests.etsi.org/protected/upload.php';
        }
        else{
          document.getElementById('hidpath').value = path;
        }
      }
      //check input
      function checkInput(){
        var finput = document.getElementById('thefile').value;
        if (finput == "") {
          alert('Please enter a valid file name and try again');
        }
      }

	  
function progress_clear() {
for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).style.backgroundColor = 'transparent';
progressAt = 0;
}
function progress_update() {
document.getElementById('showbar').style.visibility = 'visible';
progressAt++;
if (progressAt > progressEnd) progress_clear();
else document.getElementById('progress'+progressAt).style.backgroundColor = progressColor;
progressTimer = setTimeout('progress_update()',progressInterval);
}
function progress_stop() {
clearTimeout(progressTimer);
progress_clear();
document.getElementById('showbar').style.visibility = 'hidden';
}
//progress_update(); // start progress bar 

</script>
<style>
.card {
border: none;
border-radius: 0;
background-color: #a9dfea;
margin:0;

}
.card-body{
	margin-left: 30px;
	
}


.card-title {margin: 0;}
.card img {
position: relative;
display:block;
transition: all .2s ease-in-out;
}
.card-header{
	margin-left: 30px;
	padding: 1rem 0  0;
} 
.block:hover img {
transition: all .2s ease-in-out;
transform: scale(.95); /* CSS3 */
-moz-transform: scale(.95); /* Firefox */
-webkit-transform: scale(.95); /* Webkit */
-o-transform: scale(.95); /* Opera */
-ms-transform: scale(.95); /* IE 9 */
}
.card-footer {
padding: 0 1.25rem 1.25rem;
background-color: #f5f5f5;
border: none;
}
.card-footer {background-color: #f5f5f5;}


.btn {
	margin-bottom: 20px;
}
.btn-primary-outline {border-width:2px;}
</style>

	<!-- PAGE BODY STARTS -->

	<?php
	echo "<div class='margin'>&nbsp;</div>  "   ;
 	echo "<div class='jumbotron text-center'>";
  	echo "<p>$title</p>";
  	echo "</div>";

?>



	
<div class='row'>
   		<div class='col-sm-1'> </div>
		<div class='col-sm-7'> 
			<li><B>Please upload a zip file</B></li>
	
		

		<?php
			if ( $sigtype == "erds" ) {
				echo"<li>The structure of the file must be the same as it is in the initial package. In the root directory there shall be the scenario directories (ERDS-*)";	
			}
			else if ( $sigtype == "rem" ) {
				echo"<li>The structure of the file must be the same as it is in the initial package. In the root directory there shall be the scenario directories (REM-*)";	
			}
			else if ( $sigtype == "asic" ) {
				echo"<li>The structure of the file must be the same as it is in the initial package. In the root directory there shall be the scenario directories (ASIC-*)";	
			}
		?>

	
				<li>You only have write access to your own company's folder </li>
			
				<li>Existing files will be overwritten</li>
				<li>After uploading your files, a new downloadable zip file is generated</li>
		</div>
		<div class='col-sm-4'> </div>
	</div>
	
	</p>

	<div class='row'>

		<div class='col-sm-1'> </div>
		<div class='col-sm-9'>

			
		</div>
		<div class='col-sm-2'> </div>
	</div>

	<div class='row'>
		<div class='col-sm-1'> </div>
		
	
		<div class='col-sm-6'>

		<?php if ( ( $enable_upload_erds ) && ( $sigtype == "erds" ) ) {
		?>

			<form name= 'formupload' action='ERDS/upload_erds.php' method='post' enctype='multipart/form-data'>
				<div class="card"  style="background-color: #a9dfea;">
			<!-- 	style="width: 45rem" -->
			<!-- style="background-color: #74f9f9" -->
					<div class="card-header" text-xs-center><b>Select ERDS Zip file to upload</b></div>
					<div class="card-body">
							<div class="form-group" >
						
								<br><br>
								<input type="file" class="form-control-file" id="thefile" name='thefile'>
								<input type='hidden' name='hidpath'/>
								<br>
								<button type="submit" class="btn btn-primary" name='upload' onClick = 'checkInput(); progress_update(); getValue();' >Upload</button>

							</div>

							<!-- <h4>Select the XAdES Technical Specification on you wish to perform the test :</h4>
							<input type='radio' name='specification' value='TS101903v010402' checked>&nbsp;ETSI TS 101 903 v1.4.2<br> 
							<input type='radio' name='specification' value='TS103171v020101' >&nbsp;ETSI TS 103 171 v2.1.1 Baseline Profile<br> 
							<input type='radio' name='specification' value='EN31913201v010101' >&nbsp;ETSI pre EN 319 132-1 v1.0.0 Building Blocks and Baseline<br> 
							<input type='radio' name='specification' value='EN31913202v010101' >&nbsp;ETSI pre EN 319 132-2 v1.0.0 extended XAdES<br>  -->
							
							<br>
					</div>
				</div>
			</form>	

		</div>

		<?php
		} 
		else if ( ( $enable_upload_rem ) && ( $sigtype == "rem" ) ) {
			?>
	
			<form name= 'formupload' action='REM/upload_rem.php' method='post' enctype='multipart/form-data'>
				<div class="card"  style="background-color: #a9dfea;">
			<!-- 	style="width: 45rem" -->
			<!-- style="background-color: #74f9f9" -->
					<div class="card-header" text-xs-center><b>Select REM Zip file to upload</b></div>
					<div class="card-body">
							<div class="form-group" >
						
								<br><br>
								<input type="file" class="form-control-file" id="thefile" name='thefile'>
								<input type='hidden' name='hidpath'/>
								<br>
								<button type="submit" class="btn btn-primary" name='upload' onClick = 'checkInput(); progress_update(); getValue();' >Upload</button>

							</div>

					<!-- 		<h4>Select the PAdES Technical Specification on you wish to perform the test :</h4>
							<input type='radio' name='specification' value='EN31914201v010101' checked>&nbsp;ETSI EN 319 142-1 v1.1.1 Building Blocks and Baseline<br> 
							<input type='radio' name='specification' value='EN31914202v010101' >&nbsp;ETSI EN 319 142-2 v1.1.1 Additional PAdES signatures profiles<br> 

						 -->	
							<br>
					</div>
				</div>
			</form>	
	
			</div>
		
			<?php
		} 
		else if ( ( $enable_upload_asic ) && ( $sigtype == "asic" ) ) {
			?>
	
			<form name= 'formupload' action='ASiC/upload_asic.php' method='post' enctype='multipart/form-data'>
				<div class="card"  style="background-color: #a9dfea;">
			<!-- 	style="width: 45rem" -->
			<!-- style="background-color: #74f9f9" -->
					<div class="card-header" text-xs-center><b>Select ASiC Zip file to upload</b></div>
					<div class="card-body">
							<div class="form-group" >
						
								<br><br>
								<input type="file" class="form-control-file" id="thefile" name='thefile'>
								<input type='hidden' name='hidpath'/>
								<br>
								<button type="submit" class="btn btn-primary" name='upload' onClick = 'checkInput(); progress_update(); getValue();' >Upload</button>

							</div>

							<!-- <h4>Select the CAdES Technical Specification on you wish to perform the test :</h4>
							<input type='radio' name='specification' value='EN31912201v010101' checked>&nbsp;ETSI EN 319 122-1 v1.1.1 Building Blocks and Baseline<br>
							<input type='radio' name='specification' value='EN31912202v010101' >&nbsp;ETSI EN 319 122-2 v1.1.1 extended CAdES<br>  -->
							
							<br>
					</div>
				</div>
			</form>	
	
			</div>

			<?php
		} 
		?>
		
		<div class='col-sm-5'> </div>
	</div>


	<br>
		<div class='row'>
   			<div class='col-sm-1'> </div>
			<div class='col-sm-2'> 

			<table><tr><td class="noBorder">
		<!--	<div id="showbar" style="font-size:8pt;padding:2px;border:none;visibility:hidden;border-collapse: collapse; border: none;">		-->
			<div id="showbar" style="font-size:8pt;padding:2px;visibility:hidden;border: none">
			<span id="progress1">&nbsp; &nbsp;</span>
			<span id="progress2">&nbsp; &nbsp;</span>
			<span id="progress3">&nbsp; &nbsp;</span>
			<span id="progress4">&nbsp; &nbsp;</span>
			<span id="progress5">&nbsp; &nbsp;</span>
			<span id="progress6">&nbsp; &nbsp;</span>
			<span id="progress7">&nbsp; &nbsp;</span>
			<span id="progress8">&nbsp; &nbsp;</span>
			<span id="progress9">&nbsp; &nbsp;</span>
			<span id="progress10">&nbsp; &nbsp;</span>
			<span id="progress11">&nbsp; &nbsp;</span>
			<span id="progress12">&nbsp; &nbsp;</span>
			<span id="progress13">&nbsp; &nbsp;</span>
			<span id="progress14">&nbsp; &nbsp;</span>
			<span id="progress15">&nbsp; &nbsp;</span>
			</div>
			</td></tr></table>
			</div>
			<div class='col-sm-9'> </div>
		</div>



<?php

	echo "    <br>";

	$error_code = isset($_GET['error']) ? $_GET['error'] : NULL;

	// LVZ selection of the signature specification that is tested in the xades conf
	//$specification = isset($_GET['specification']) ? $_GET['specification'] : NULL;	
	
	echo '<div class="col-sm-1"> </div>';
	echo '<div class="col-sm-7">'; 


	if ($error_code == "ok"){


		
					
			
	
    if($sigtype == "acert"){
      	// LVZ / to recover attribute certificate file name generated by the script
      if(isset($_GET['acertreport'])){
      	$acertreport = $_GET['acertreport'];  
      	$acertreport_base = basename ($acertreport);
      }
      
      echo "<b><blockquote><font color=\"blue\">The certificate was uploaded successfully to the server. <br><br><a href='$acertreport'><font color=\"blue\">Click here to download the Attribute Certificate $acertreport_base</font></a></font></blockquote></b>";
      
    } else if($sigtype == "xadesconf"){
    
      if(isset($_GET['xadesconfreport'])){
      	$xadesconfreport = $_GET['xadesconfreport'];
      	$xadesconfreport_base = basename ($xadesconfreport);  
      }

      echo "<b><blockquote><font color=\"blue\">The XAdES was uploaded successfully to the server. <br><br><a href='$xadesconfreport' target='_blank'><font color=\"blue\">Click here to see the XAdES Conformance Report $xadesconfreport_base</font></a></font></blockquote></b>";

    }  else if($sigtype == "cadesconf"){
    
        if(isset($_GET['cadesconfreport'])){
        	// LVZ / to recover CAdES Conf report generated by the script
        	$cadesconfreport = $_GET['cadesconfreport'];
        	$cadesconfreport_base = basename ($cadesconfreport);
        }
        echo "<b><blockquote><font color=\"blue\">The CAdES was uploaded successfully to the server. <br><br><a href='$cadesconfreport' target='_blank'><font color=\"blue\">Click here to see the CAdES Conformance Report $cadesconfreport</font></a></font></blockquote></b>";
        
    }  else if($sigtype == "cadesconf"){
  
      if(isset($_GET['cadesconfreport'])){
      	// LVZ / to recover CAdES Conf report generated by the script
      	$cadesconfreport = $_GET['cadesconfreport'];
      	$cadesconfreport_base = basename ($cadesconfreport);
      }
      
      echo "<b><blockquote><font color=\"blue\">The CAdES was uploaded successfully to the server. <br><br><a href='$cadesconfreport' target='_blank'><font color=\"blue\">Click here to see the CAdES Conformance Report: :   $cadesconfreport_short</font></a></font></blockquote></b>";
  
    }  else if($sigtype == "padesconf"){
      // LVZ / to recover PAdES Conf report generated by the script
      if(isset($_GET['cadesconfreport'])){
        $padesconfreport = $_GET['padesconfreport'];
        //$padesconfreport_base = basename ($padesconfreport);
        
        $padesconfreport_short = substr($padesconfreport, 31); // remove the 31 first characters corresponding to /protected/PAdESConf/TestCases/
      }
      
      echo "<b><blockquote><font color=\"blue\">The PAdES was uploaded successfully to the server. <br><br><a href='$padesconfreport' target='_blank'><font color=\"blue\">Click here to see the PAdES Conformance Report: :   $padesconfreport_short</font></a></font></blockquote></b>";
      
    } else if($sigtype == "asicconf"){
    
      // 12-03-2014 LVZ / to recover ASiC Conf report generated by the script
      if(isset($_GET['asicconfreport'])){
      	$asicconfreport = $_GET['asicconfreport'];
      	$asicconfreport_base = basename ($asicconfreport);
      	$filename_original = $_GET['filename_original'];
      }

      // 12-03-2014 LVZ
      echo "<b><blockquote><font color=\"blue\">The ASiC $filename_original was uploaded successfully to the server. <br><br><a href='$asicconfreport' target='_blank'><font color=\"blue\">Click here to see the ASiC Conformance Report $asicconfreport_base</font></a></font></blockquote></b>";
      
    } else  {
      echo "<div align=\"center\" width=\"80%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
      echo "<b><blockquote><font color=\"blue\">The file was uploaded successfully to the server.</font></blockquote></b>";
  	}
  
  	echo "</div>";
  	echo "<br>";
    
	} else if ($error_code == "ko"){

	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	echo "<b><blockquote><font color=\"red\">The file was not uploaded to server.</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}

	else if ($error_code == "zip"){
	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	//echo "<b><blockquote><font color=\"red\">You must upload a zip file.</font></blockquote></b>";
	echo "<b><blockquote><font color=\"red\">Please use the correct file extension.</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}

	else if ($error_code == "rep"){
	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	echo "<b><blockquote><font color=\"red\">Zip file must contain directory beginning by \"XAdES-\".</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}

	else if ($error_code == "noup"){
	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	echo "<b><blockquote><font color=\"red\">Upload function is currently disabled</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}

	else if ($error_code == "delok"){
	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	echo "<b><blockquote><font color=\"red\">Your files have been deleted.</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}

	else if ($error_code == "delerr"){
	echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
	echo "<b><blockquote><font color=\"red\">Unable to delete your files (".$_GET['errloc'].").</font></blockquote></b>";
	echo "</div>";
	echo "<br>";
	}


echo '</div>'; 
echo '<div class="col-sm-4"> </div>'; 

/*
 //LVZ 2012-03-07  remove the option to delete all files as it could be source of error from participants

if ( $sigtype == "xades" ) {
  echo "    <form name= 'delete' action='XAdES/delete_xades.php' onSubmit='return confirmation();'";
echo "      Click on the button below to remove all your data in TestCases folder";
echo "      <br><br>";
echo "      <input type = 'submit' value = 'delete all my files'>";
echo "    </form>";
} else if ( $sigtype == "cades" ) {
  echo "    <form name= 'delete' action='CAdES/delete_cades.php' onSubmit='return confirmation();'";
echo "      Click on the button below to remove all your data in TestCases folder";
echo "      <br><br>";
echo "      <input type = 'submit' value = 'delete all my files'>";
echo "    </form>";
}

*/


/*
 ///LVZ
else if ( $sigtype == "pades" ) {
  echo "    <form name= 'delete' action='PAdES/delete_pades.php' onSubmit='return confirmation();'";
echo "      Click on the button below to remove all your data in TestCases folder";
echo "      <br><br>";
echo "      <input type = 'submit' value = 'delete all my files'>";
echo "    </form>";
}
else if ( $sigtype == "asic" ) {
  echo "    <form name= 'delete' action='ASiC/delete_asic.php' onSubmit='return confirmation();'";
echo "      Click on the button below to remove all your data in TestCases folder";
echo "      <br><br>";
echo "      <input type = 'submit' value = 'delete all my files'>";
echo "    </form>";
}

*/

?>

<?php
  getLast();
?>
