<?php
/* $Id: upload.php 52 2009-02-19 10:18:37Z kremer $ */
?>


<!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 name="Description" content="XAdES Remote Plugtest Portal, " />
<meta name="Name" content="XAdES Remote Plugtest Portal" />
<meta name="Author" content="Plugtests" />
<meta name="Owner" content="Plugtests" />
<meta name="Keyword"
	content="XAdES Remote Plugtest Portal, Development of electronic signatures related standards, " />

<title>Plugtests Portal for Electronic Signature</title>
<link rel="stylesheet" type="text/css" href="/common/css/master.css" />
<link rel="stylesheet" type="text/css" href="/common/css/template.css" />
<link rel="stylesheet" type="text/css" href="/common/css/etsi.css" />
<link rel="stylesheet" type="text/css"
	href="/common/css/microsite_blue.css" />
<link rel="stylesheet" href="/common/sifr/sIFR-screen.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="/common/sifr/sIFR-print.css"
	type="text/css" media="print" />

<SCRIPT LANGUAGE="JavaScript">
      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://212.234.160.9/protected/upload.shtml';
        }
        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');
        }
      }

    </SCRIPT>

</head>
<body>

<!-- HEADER STARTS -->
<!--#include virtual="/common/Header.html" -->
<!-- HEADER ENDS -->


<?php
$sigtype = strtolower ( $_GET['sigtype'] );

if ( $sigtype == "xades" ) {
  echo "<!-- MENUBAR STARTS -->";
  echo "<!--#include virtual='/protected/Menubar_protected.php?pageid=upload1' -->";
  echo "<!-- MENUBAR ENDS -->";
  echo "<!-- HEADER STARTS -->";
  echo "<!--#include virtual='/protected/Header_protected.php?title=XAdES%20upload%20page' -->";
  echo "<!-- HEADER ENDS -->";
} else if ( $sigtype == "tslplugtests" ) {
  echo "<!-- MENUBAR STARTS -->";
  echo "<!--#include virtual='/protected/Menubar_protected.php?pageid=upload3' -->";
    echo "<!-- MENUBAR ENDS -->";
  echo "<!-- HEADER STARTS -->";
  echo "<!--#include virtual='/protected/Header_protected.php?title=TSL%20Plugtest%20upload%20page' -->";
  echo "<!-- HEADER ENDS -->";
} else if ( $sigtype == "cert" ) {
  echo "<!-- MENUBAR STARTS -->";
  echo "<!--#include virtual='/protected/Menubar_protected.php?pageid=upload4' -->";
    echo "<!-- MENUBAR ENDS -->";
  echo "<!-- HEADER STARTS -->";
  echo "<!--#include virtual='/protected/Header_protected.php?title=Check%20Certificate%20page' -->";
  echo "<!-- HEADER ENDS -->";
 } else if ( $sigtype == "tsl" ) {
  echo "<!-- MENUBAR STARTS -->";
  echo "<!--#include virtual='/protected/Menubar_protected.php?pageid=upload2' -->";
    echo "<!-- MENUBAR ENDS -->";
  echo "<!-- HEADER STARTS -->";
  echo "<!--#include virtual='/protected/Header_protected.php?title=TSL%20upload%20page' -->";
  echo "<!-- HEADER ENDS -->";
  //ConformanceChecker
 } else if ( $sigtype == "confchecker" ) {
  echo "<!-- MENUBAR STARTS -->";
  echo "<!--#include virtual='/protected/Menubar_protected.php?pageid=upload5' -->";
    echo "<!-- MENUBAR ENDS -->";
  echo "<!-- HEADER STARTS -->";
  echo "<!--#include virtual='/protected/Header_protected.php?title=TSL%20Conformance%20Checker' -->";
  echo "<!-- HEADER ENDS -->";
  }

?>






<!-- PAGE BODY STARTS -->

<p>You can use this page to upload your files. The recommendations and
rules regarding uploading are the followings:</p>

<?php
echo "<ol>";
if ( $sigtype != "confchecker" ) {
  echo "<li>You must upload a zip file";
  echo "<li>The structure of the file must be the same as it is in the initial package";
} 
?>

<?php
if ( $sigtype == "xades" ) {
  echo"<li>In the root directory there shall be the scenario directories (XAdES-*)";
} else if ( $sigtype == "tsl" ) {
  echo"<li>In the root directory there shall be the scenario directories (TSL-*)";
}
?>
	<!--
	<li>Every participating company has its own directories in every
	scenario directory
	<li>You only have write access to your own company's folders
	<li>Existing files will be overwritten, the new files will be created
	<li>After uploading your files, a new downloadable zip file is created
	<li>Please only upload the necessary files to save bandwidth!
	-->
	
<?php
if ( $sigtype == "tslplugtests" ) {
  echo"<li>The files that you may upload here are:";
  echo"<ol><br>";
  echo "<li><B>TSL xml files.</B> Filename format: TSL-X-[SignatureForm]-0.xml";
  echo "<li><B>XAdES signatures.</B> Filename format: Signature-[TestDefinitionFilename].xml";
  echo "<li><B>Verification reports.</B> Filename format: Verification_of_[SignerCountryCode]_[SignatureFilename].xml";
  echo "</ol>";
} else if ( $sigtype == "tsl" ) {
  echo"<li>The files that you may upload here are:";
  echo"<ol><br>";
  echo "<li><B>TSL xml files.</B> Filename format: TSL-[LifecycleTestDefinitionFilename].xml";
  echo "</ol>";
}else if ( $sigtype == "cert" ) {
  echo"<li>The files that you may upload here are:";
  echo"<ol><br>";
  echo "<li><B>Certificates.</B> Filename format: Certificate_[TypeOfService]_of_[SigningCountryCode]_[SignatureFilename].der";
  echo "</ol>";
}else if ( $sigtype == "confchecker" ) {
 echo"<li>The files that you may upload here are:";
 echo"<ol><br>";
 echo "<li><B>TSL xml files.</B> Filename format: TSL-[Any].xml    (where Any must not contain underscore _ )";
 echo "</ol>";
}
?>
</ol>

<?php

include_once "portal_settings.php";

$sigtype = strtolower ( $_GET['sigtype'] );

if ( ( $enable_upload_xades ) && ( $sigtype == "xades" ) ) {
  echo "    <form name= 'formupload' action='XAdES/upload_xades.php' method='post' enctype='multipart/form-data'>";
} else if ( ( $enable_upload_tsl ) && ( $sigtype == "tsl" ) ) {
  echo "    <form name= 'formupload' action='TSLlifecycle/upload_tsl.php' method='post' enctype='multipart/form-data'>";
 } else if ( ( $enable_upload_tslplugtests ) && ( $sigtype == "cert" ) ) {
  echo "    <form name= 'formupload' action='TSLPlugtest/upload_cert.php' method='post' enctype='multipart/form-data'>";
} else if ( ( $enable_upload_tslplugtests ) && ( $sigtype == "confchecker" ) ) {
  echo "    <form name= 'formupload' action='TSLPlugtest/upload_confchecker.php' method='post' enctype='multipart/form-data'>";
 } else {//( ( $enable_upload_tslPlugtests ) && ( $sigtype == "tslplugtests" ) ) {
  echo "    <form name= 'formupload' action='TSLPlugtest/upload_tsl.php' method='post' enctype='multipart/form-data'>";
}


if ( ( $enable_upload_xades ) || ( $enable_upload_tsl ) || ($enable_upload_tslplugtests) ) {
  echo "      <table cellspacing='0' align='center' cellpadding='2' border='0' style='border-width:1px; border-color:black; border-style:solid;'>";
  echo "        <tr>";
  echo "          <td align='center' style='border-width:0px; border-style:solid;' bgcolor='#0099FF' colspan='3'><b><font color='#FFFFFF'>Uploading files</font></b><br><br></td>";
  echo "        </tr>";
  echo "        <tr>";
  echo "          <td align='center' nowrap>";
  echo "            <font size='-1'>Choose file to upload:</font>";
  echo "          </td>";
  echo "          <td><input type='file' size='40' name='thefile' id='thefile' style='font-family:Arial, Helvetica, sans-serif; margin:0px; font-size:11px; font-style:normal; font-weight:normal; height:20px; width:430px; border: 1px solid #666666; background-color:#99CCFF;color:#000000;'/></td>";
  echo "          <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  echo "            <input type='hidden' name='hidpath'/>";
  echo "            <input type='submit' name='upload' value='Upload' onClick = 'checkInput(); getValue();' style='font-family:Arial, Helvetica, sans-serif; margin:0px; font-size:11px; font-style:normal; font-weight:bold; height:20px; width:50px; border: 1px solid #666666; background-color:#99CCFF;color:#000000;'/>";
  echo "          </td>";
  echo "        </tr>";
  echo "      </table>";
  echo "    </form>";
}

echo "    <br>";

$error_code = $_GET['error'];
$certreport = $_GET['certreport'];
$confcheckerreport = $_GET['confcheckerreport'];
$confcheckerpretty = $_GET['confcheckerpretty'];
//$tslfile1 = substr($confcheckerpretty, -18);
//$tslfile2 = substr($tslfile1,0, 14);
$tslfile1 = explode ("_",$confcheckerpretty);
$tslfile2 = substr($tslfile1[1], 0,strlen($tslfile1[1])-4);
$tslfile = substr($tslfile1[0], 0, strlen($tslfile1[0])-13).$tslfile2;
$prettyprint_html = substr($confcheckerpretty, 0, strlen($confcheckerpretty)-3).html;
//$tslfile = substr($confcheckerpretty, 0, strlen($confcheckerpretty)-32).$tslfile2;



if ($error_code == "ok"){
  echo "<div align=\"center\" width=\"100%\" style=\"border:solid 2px blue; cursor:default; background:#FFFFFF;\">";
  if($sigtype == "cert"){
      echo "<b><blockquote><font color=\"blue\">The file was uploaded successfully to the server. <br><br><a href='TSLPlugtest/TestCases/$certreport'><font color=\"blue\">$certreport</font></a></font></blockquote></b>";
  } 
  if($sigtype == "confchecker"){
      //echo "<b><blockquote><font color=\"blue\">The file was uploaded successfully to the server. <br><br><a href='$confcheckerreport'><font color=\"blue\">$confcheckerreport</font></a></font></blockquote></b>";
        echo "<b>
			 <blockquote>
				 <font color=\"blue\">The file was uploaded successfully to the server. <br>
				 <br><a href='$confcheckerreport' target='_blank'><font color=\"blue\">Conformance Checker report $tslfile2</font></a><br />
				 <br><a href='$confcheckerpretty' target='_blank'><font color=\"blue\">PrettyPrint Pdf $tslfile2</font></a><br />
				 <br><a href='$prettyprint_html' target='_blank'><font color=\"blue\">PrettyPrint Html $tslfile2</font></a><br />
				 <br><a href='TSLlifecycle/Documentation/xmllint.php?inputfile=/var/www/html/xadesweb/protected/$tslfile' target='_blank'><font color=\"green\">Schema Check $tslfile2</font></a>
				 </font>
			 </blockquote>
		 </b>"; 
		
		// <br><a href='$confcheckerpretty'><font color=\"blue\">$confcheckerpretty</font></a><br />
   }
  else {
      echo "<b><blockquote><font color=\"blue\">The file was uploaded successfully to the server. </font></blockquote></b>";
  }
 //echo "<pre>$certreport</pre>";
  //echo "<b><blockquote><font color=\"blue\">TSLPlugtest/TestCases/$certreport</font></blockquote></b>";
  //echo "<a href='TSLPlugtest/TestCases/$certreport'>$certreport</a>";
  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 "</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>";
}

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 == "tsl" ) {
  echo "    <form name= 'delete' action='TSLlifecycle/delete_tsl.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 == "tslPlugtests" ) {
  echo "    <form name= 'delete' action='TSLPlugtest/delete_tsl.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>";
}


?>



<!--#include virtual="/common/Footer.html" -->
<!-- FOOTER ENDS -->

</body>
</html>
