<?PHP
$auth = false;
$authID = 'EAE5972B-83F4-2760-1CCC-96C6F52BAF0D';
if (isset($_COOKIE["guid"])) {
    if ($_COOKIE["guid"] === $authID) {
        $auth = true;
    }
}
if (isset($_POST["username"]) && isset($_POST["password"])) {
    if ($_POST["username"] === 'sales' && $_POST["password"] === '7ab1f81c336ef987a09842fa12638631') {
        $auth = true;
    }
}
// $.md5(md5)
// $.cookie("guid")
// $.cookie("guid", 0, { path: '/projects/certificates', expires: 8000 });
if ($auth) {
    setcookie("guid",$authID,time() + (10 * 365 * 24 * 60 * 60));
?>
<!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>

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

    <script src="js/shared.js"></script>
<!-- 
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="style.css">
-->
	<style type="text/css">
		nav {
			font-size: 110%;
    		padding: 20px;
		}

		textarea {
		    width: 80vw;
		    height: 80vh;
		}

	</style>
    <title>edit pulldown</title>
</head>

<body>
<!-- -->
	<nav style="text-align: center;">
		<div id="home"> <a href="index.php?">certificates page</a> </div>
	</nav>
    <div id='main'>
    	<div id='content' style="text-align: center;">
    		<textarea><?

		        include('_functions2.php');
		        $pulldownFile = getFile( 'pulldown_dvalue.txt' );
    			echo $pulldownFile;

    		?></textarea>
    		<br/>
    		<button onclick="editPulldown.form.save();">save</button>
    	</div>
    </div>


    <script type="text/javascript">
    	editPulldown = {};
    	editPulldown.v = {};
		editPulldown.form = {
			record: 0,
			guid: '',
		    save: function() {
		    	
				$.post(
				    "editPulldownSave.php", {
				        'file': editPulldown.form.clean()
				    },
				    function(data) {
				    	console.log(data);
				    	alert('Saved');
				    }
				);
				// editPulldown.form.save();
		    }, //==============================================
		    clean: function() {
		    	var data = $('textarea').val();
		    	data = certificate.order.cleanString2(data);
		    	$('textarea').val(data);
		    	return data;
				// editPulldown.form.clean();
		    } //==============================================
		};
    </script>

    
    
</body>

</html>
<?
} else {
    @include('login.php');
}
?>