<?php
/*
        session_start();

        if (isset($_GET['logout'])) {
                session_destroy();
                header("Location: logout.php");
                exit();
        }

        if (!isset($_SESSION['isloggedin']) || $_SESSION['isloggedin'] == false) {
                session_destroy();
                header("Location: login.php");
                exit();
        }

        if (isset($_POST['submit'])) {
		unset($_POST['submit']);
		echo "<script type='text/javascript'>alert('Repair has been logged.');window.location = 'index.php';</script>";
		exit();
	}

*/
?>
<!DOCTYPE html>
<html>
<head>
	<title>Sounus Script Generator</title>
	<link href='http://fonts.googleapis.com/css?family=Lekton' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Marvel' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Sorts+Mill+Goudy' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Shanti' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Andika' rel='stylesheet' type='text/css'>
	<link rel="stylesheet" type="text/css" href="css/reset.css" />
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/form.css" />
	<script language="JavaScript" src="js/hover.js"></script>
	<script language="JavaScript" src="js/jquery.js"></script>
	<script language="JavaScript" src="scripts/dropdown.js"></script>
	<script type="text/javascript">
		
		var counter = 1;

		function moreFields() 
		{
        
	        counter++;
	        var newFields = document.getElementById('readroot').cloneNode(true);
	        newFields.id = '';
	        newFields.style.display = 'block';
	        var newField = newFields.childNodes;
	        for (var i=0;i<newField.length;i++) {
	                var theName = newField[i].name
	                if (theName)
	                        newField[i].name = theName + counter;
	        }
	        var insertHere = document.getElementById('writeroot');
	        insertHere.parentNode.insertBefore(newFields,insertHere);
		}
		
		function getCounter()
		{
			return counter;		
		}
	
		function show_confirm()
		{
			var ans = confirm('Are you sure that you want to cancel the Sonus creation script?');
			if (ans == true ) 
			{
				window.location = 'index.php';
			}
		}
		
		function checkText(elem)
		{	
                  let newValue = elem.value.split("").filter(chr => /[a-zA-Z]/.test(chr)).join("")
                  elem.value = newValue;
		}	

		function checkContact(elem)
		{	
                  let newValue = elem.value.split("").filter(chr => /[a-z A-Z0-9-]/.test(chr)).join("")
                  elem.value = newValue;
		}	

		function checkNumber(elem)
		{	
                  let newValue = elem.value.split("").filter(chr => /([0-9)/.test(chr)).join("")
                  elem.value = newValue;
		}		

		function checkIP(elem){
        	    let newValue = elem.value.split("").filter(chr => /[0-9.]/.test(chr)).join("")
                    elem.value = newValue;
                }

                function checkInputP(elem){
                 let newValue = elem.value.split("").filter(chr => /[a-z A-Z]/.test(chr)).join("")
                 elem.value = newValue;
                }

		function carrierCheck() 
		{
    		if (document.getElementById('tgType').value == '33') 
    		{
        		document.getElementById('carrier').style.visibility = 'visible';
    		}
    		else document.getElementById('carrier').style.visibility = 'hidden';
		}

		function callLimCheck() 
		{                                                                                                                       
            if (document.getElementById('yes').checked) 
            {
                document.getElementById('callLim').style.visibility = 'visible';                                                                
            }                                                                                                                                       
                else document.getElementById('callLim').style.visibility = 'hidden';                                                            

        }    		

		window.onload = moreFields;

	</script>
</head>
<body>
	<header id='header'>
		Initial Sonus SBC Script Generator
	</header>
	<section id='container'>
		<section id='main' class='content'>
			<form action='template_gen.php' method='get' name='repair'>
				<fieldset>
					<legend>General Info:</legend>
					<ol>
						<li><label>SBC Info:</label><input id='sbcname' name='sbcname' type='text' onInput='checkInputP(this)' placeholder='sbcname' required></li>
						<li><label>Location:</label><input id='location' name='location' type='text' onInput='checkText(this)' placeholder='location'></li>
						<li><label>Contact:</label><input id='contact' name='contact' type='text' onInput='checkContact(this)' placeholder='contact'></li>
                                                </br>
			                        <li><label>NTP1 IP:</label><input id='ntp1IP' name='ntp1IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/>
			                        <label>NTP2 IP:</label><input id='ntp2IP' name='ntp2IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
                                                </br>
			                        <li><label>DNS1 IP:</label><input id='dns1IP' name='dns1IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/>
			                        <label>DNS2 IP:</label><input id='dns2IP' name='dns2IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
					</ol>
				</fieldset>
                                        <fieldset>
					<legend>IP Info:</legend>
                    	<ol>                                    
                            <li><label>Managment IP:</label><input id='mgmtIP' name='mgmtIP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
			    <li><label>Managment  Subnet:</label><input id='primarymask' name='primarymask' type='text' onInput='checkNumber(this)' placeholder='CDIR notation only ie 24' /></li>
			    <li><label>Managment Gateway:</label><input id='primaryGW' name='primaryGW' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
                            </br>
                            </br>
			    <li><label>External IP:</label><input id='pkt0IP' name='pkt0IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/>
			    <label>External IP 2:</label><input id='pkt1IP' name='pkt1IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
			    <li><label>External CDIR:</label><input id='extmask' name='extmask' type='text' onInput='checkNumber(this)' placeholder='CDIR notation only ie 24' />
			    <label>External Gateway:</label><input id='extGW' name='extGW' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
                            </br>
                            </br>
			    <li><label>Internal IP:</label><input id='pkt2IP' name='pkt2IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/>
			    <label>Internal IP2:</label><input id='pkt3IP' name='pkt3IP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
			    <li><label>Internal CDIR:</label><input id='intmask' name='intmask' type='text' onInput='checkNumber(this)' placeholder='CDIR notation only ie 24' />
			    <label>Internal Gateway:</label><input id='intGW' name='intGW' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
                            </br>
                            </br>
			    <li><label>Internal Sig Port:</label><input id='intSigIP' name='intSigIP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/>
			    <label>External Sig Port:</label><input id='extSigIP' name='extSigIP' type='text' onInput='checkIP(this)' placeholder='x.x.x.x'/></li>
                            </br>
                        </ol>                                                                                                               
				</fieldset>
				<fieldset>
					<legend>Note to self</legend>

					<ol>
						Add TCP functions and ACL's</br>
						Add Feature for multiple TG's</br>
						Fix Precedence no.</br>
						Validate input.</br>
						Some type of login</br>
						Add function to delete TG</br>

					</ol>
				</fieldset>
				<input id='submit' name='submit' type='submit' value='Submit' />
				<input id='cancel' name='cancel' type='button' value='Cancel' onclick='show_confirm()' />
			</form>             	 
		</section>                  	 
	</section>                          	 
	<footer>                            	 
			<p>Fusion &copy;Copyright all rights reserved 2019</p>
	</footer>                           	 
<body>                                     	 
</html>                                     	 

