Browse Source

show active config in patchpanel

Jan Behrens 2 years ago
parent
commit
66eebb59d1
1 changed files with 31 additions and 10 deletions
  1. 31 10
      patchpanel/index.php

+ 31 - 10
patchpanel/index.php

@@ -68,7 +68,7 @@
 					$content = $content . $tempcontent . "\r\n";
 				}
 				fwrite($handle, $content);
-				fclose($handle);	
+				fclose($handle);
 			}
 		}
 	}
@@ -81,24 +81,42 @@
 
 	// load configuration
 
-	if ($_POST["configurationload"] != "" && $_POST["configurationload"] != "new configuration")
+    $check = array( 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+                    22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 );
+    if (!array_key_exists("configurationload", $_POST))
+        $_POST["configurationload"] = "(active configuration)";
+
+    #echo $_POST["configurationload"];
+
+    if ($_POST["configurationload"] == "(active configuration)")
+	{
+        $handle = fopen("data/activeIEconfig.txt", "r");
+        if ($handle)
+        {
+            $id = 0;
+            while (($buffer = fgets($handle, 4096)) !== false)
+            {
+                $buffer = trim($buffer);
+                $check[$id++] = $buffer;
+            }
+            fclose($handle);
+        }
+	}
+	else if ($_POST["configurationload"] != "(new configuration)")
 	{
 		$filename = $_POST["configurationload"] . ".conf";
 		$handle = fopen("data/" . $filename, "r");
 		if ($handle)
 		{
+            $id = 0;
 			while (($buffer = fgets($handle, 4096)) !== false)
 			{
 				$buffer = trim($buffer);
-				$check[count($check)] = $buffer;
+				$check[$id++] = $buffer;
 			}
 			fclose($handle);
 		}
 	}
-	else
-	{
-		$check = array( 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22 );
-	}
 
 ?>
 
@@ -114,8 +132,8 @@
 	}
 
 
-	$username = 'katrin';
-	$password = 'adei.F3rmi!2019';
+    $username = getenv('PHP_ADEI_USERNAME');
+    $password = getenv('PHP_ADEI_PASSWORD');
 	$context = stream_context_create(array(
 		'http' => array(
 			'header'  => "Authorization: Basic " . base64_encode("$username:$password")
@@ -165,8 +183,11 @@
 		<td><b>configuration</b></td>
 		<td>
 			<select name="configurationload" size="1" onchange="myform.submit();">
-				<option>new configuration</option>
+                <option>(active configuration)</option>
 				<?php
+                    if ($_POST["configurationload"] == "(new configuration)") echo '<option selected>'; else echo '<option>';
+                    echo '(new configuration)</option>';
+
 					foreach (glob("data/*.conf") as $filename)
 					{
 						$buffer = substr($filename, 5, strlen($filename) - 10);