<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<!--
<!DOCTYPE html>
 -->
<html lang="en">

<head>
        <meta charset="utf-8">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!--
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="style.css">
        <script src="script.js"></script>
        <style type="text/css">
                .name {
                        font-size: 110%;
                }
        </style>
-->
        <title>emails</title>

	    <script>
	        certificate = {};
	        certificate.v = {};
	    </script>

        <script type="text/javascript" src="../js/shared.js"></script>

</head>

<body>
<!--
        <nav style="text-align: center;">
                <div id="home">home</div>
        </nav>
        <div id='main'>
                <div id='content' style="text-align: center;">
                        <div id='' class=''></div>
                </div>
        </div>
-->

		<?
			date_default_timezone_set('America/New_York');
			// var_dump( $_SERVER );
			if ( isset($_GET['repository']) && $_GET['repository'] == 'A521DCAC-AC19-4E10-AEC0-D1CA3566729D' ) {
			// echo ;





	date_default_timezone_set('America/New_York');
	$epoch = time();
	file_put_contents( $_SERVER['REMOTE_ADDR']."__.txt", $epoch );

				$temp_files = glob(__dir__.'/*');



				$IPs = array();
				foreach($temp_files as $file) {
					$file = str_replace( getcwd().'/', '' , $file );
					if ( stripos($file,'.txt') !== false ) {
						// echo $file . '<br/>';
						$ex = explode('__', $file);
						array_push($IPs,$ex[0]);
					}
				}




				echo '<br/>';
				echo '<h1>File Cleanup</h1>';
				echo '<br/>';
				echo '<div>';

				if ( isset($_POST["delete"]) ) {

					// echo $_POST["delete"];

					$deleteList = explode( "\n", $_POST["delete"] );

					foreach ($deleteList as $key) {
						echo "<div>  $key </div>";

					}
					echo "<br/><br/>";
					$temp_files = array_reverse( $temp_files );
					$i = 0;
					$ii = 0;
					foreach($temp_files as $file) {
						$filename = str_replace( getcwd().'/', '' , $file );
						foreach ($deleteList as $key) {
							$findThis = "CARDS-$key";

							// if ( strpos( $file, $findThis ) !== false  ) {
							if ( strpos( $filename, $key ) !== false && strpos( $filename, '.htm' ) !== false  ) {
								echo "<div> DELETING: $filename </div>";
								unlink( $file );
								$ii++;
							}
						}

						$i++;
					}
					echo "<br/><br/>";
					echo "Deleted: $ii";

				} else {

					echo '<form id="theForm" action="delete.php?repository=A521DCAC-AC19-4E10-AEC0-D1CA3566729D" method="post" name="delete_list" >';
					echo '	<br/>Past a list of test order numbers to delete <br/>';
					echo '	<textarea rows="20" cols="50" name="delete" ></textarea>';
					echo '	<br/>';
					echo '	<button onclick="dataClean.form.clean(); setTimeout(function(){$(\'#theForm\').submit();}, 1500);" >Submit</button>';
					echo '</form>';

				}

				echo '</div>';


			} else {
				echo "not authorized";
			}
		?>




    <script type="text/javascript">


    	dataClean = {};
    	dataClean.v = {};
		dataClean.form = {
		    clean: function() {
		    	var data = $('textarea').val();
		    	data = certificate.order.cleanString2(data);
		    	$('textarea').val(data);
		    	return data;
				// dataClean.form.clean();
		    } //==============================================
		};


    </script>

</body>

</html>


