[services-cvs] CVS services/etc/misc

CVS User miham root at tempel.bibl.u-szeged.hu
2004. Nov. 20., Szo, 11:00:16 CET


Update of /var/lib/cvs/services/etc/misc
In directory tempel:/tmp/cvs-serv28960/etc/misc

Modified Files:
	hihi.php 
Log Message:
Nah, a szukseges plussz
Reszletezve:
a dhcp configok szetbontva vlanonkent
(majd apache2 modon ossze kell rakni 1 dhcpd.conf-a, de addig meg van vele dolog..)
geplista.m4 updated w/ IGA vlan machines


--- /var/lib/cvs/services/etc/misc/hihi.php	2004/11/19 20:50:28	1.2
+++ /var/lib/cvs/services/etc/misc/hihi.php	2004/11/20 10:00:16	1.3
@@ -1,19 +1,65 @@
 #!/usr/bin/php4 -q
 <?
 $data1 = @file('geplista.m4');
-$data2 = @file('geplista.txt');
+$data2 = @file('adm_geplista.txt');
+
+function getSubDomain($vlanname) {
+    $Subdomains = array('OLV'  => "rs",    # Readers' Services
+                        'TAJ'  => "info",  # Information
+                        'SZAK' => "szak",  # ???
+                        'FEL'  => "proc",  # Processing
+                        'ET'   => "igla",  # Induvidual & Grouped Learning Areas
+                        'KAB'  => "cab",   # Cabinet
+                        'BESZ' => "acq",   # Acquisition
+                        'KOL'  => "loan",  # Loan
+                        'IGA'  => "adm",   # Administration
+                        'RAK'  => "dep",   # Depot
+                        'GUE'  => "guest", # Guest
+                        'MUL'  => "mul",   # Multifunctional Rooms
+                        'KUL'  => "scoll", # Special Collections
+                        'OT'   => "rr",    # Readers' Room
+                        'OP'   => "rri",   # Readers' Room in Intranet
+                        'TEC'  => "tec",   # Technical
+                        'AFO'  => "afo",   # Kakukktojas: Automatizalasi & Fejlesztesi Osztaly
+                        );
+    if (!isset($Subdomains[$vlanname]))
+        die ("No Subdomain found for VLAN '{$vlanname}'!\n");
+
+    return $Subdomains[$vlanname];
+}
+
+function getFloorLevel($room) {
+    $Levels = array("-1" => "Pince",
+                    "0"  => "Földszint",
+                    "1"  => "I.Em.",
+                    "2"  => "II.Em.",
+                    "3"  => "III.Em.",
+                    "4"  => "IV.Em.");
+
+    list($ln,$junk) = explode(".", $room);
+    if (!isset($Levels[$ln]))
+        return '"??"';
+
+    return '"' . $Levels[$ln] . '"';
+}
 
 $gepstruct = array();
 foreach ($data2 as $actline) {
     $actgep = explode("\t", rtrim($actline));
     $actstruct = array();
-    $actstruct["num"] = array_shift($actgep);
-    $actstruct["sn"] = array_shift($actgep);
-    $actstruct["mac"] = array_shift($actgep);
+    $actstruct["room"] = array_shift($actgep);
+    $actstruct["num"]  = array_shift($actgep);
+    $actstruct["sn"]   = array_shift($actgep);
+    $actstruct["msn"]  = array_shift($actgep);
+    $actstruct["mac"]  = implode(":", explode(" ", array_shift($actgep)));
+    $actstruct["ren"]  = array_shift($actgep);
     $actstruct["port"] = array_shift($actgep);
-    $actstruct["ren"] = "R4";
+    $actstruct["vlan"] = array_shift($actgep);
+    $actstruct["user"] = array_shift($actgep);
 
-    $gepstruct['"' . $actstruct["port"] . '"'] = $actstruct;
+    if (!isset($gepstruct[$actstruct["ren"]])) 
+        $gepstruct[$actstruct["ren"]] = array();
+    $gepstruct[$actstruct["ren"]][$actstruct["port"]] = $actstruct;
 }
 
 $res = array();
@@ -21,21 +67,39 @@
     if (substr($actline,0,10) == 'ujGEPentry') {
         $actdata = substr($actline, 11, -4);
         $actdarr = explode(',', $actdata);
-        if (substr($actdarr[5], 1, -1) == "R4") {
-            if (isset($gepstruct[$actdarr[6]])) {
-                $dataused = $gepstruct[$actdarr[6]];
-                $actdarr[0] = $dataused["mac"];
-                $actdarr[1] = '"' . $dataused["sn"] . '"';
-                $actdarr[9] = '"User"';
-                $actdarr[10] = 'pc' . $dataused["num"];
-                $actdarr[11] = 'cab';
-                $actdarr[12] = "160.114.158." . (intval($dataused["num"]) + 10);
 
-                $actline = "ujGEPentry(" . implode(",", $actdarr) . ")dnl\n";
+        $local_room = substr($actdarr[4], 1, -1);
+        $local_ren  = substr($actdarr[5], 1, -1);
+        $local_port = substr($actdarr[6], 1, -1);
+        $local_vlan = substr($actdarr[8], 1, -1);
+        
+        if (isset($gepstruct[$local_ren]) && 
+            isset($gepstruct[$local_ren][$local_port])) {
+        
+            echo "DEBUG: $local_ren : $local_port found!\n";
+        
+            $dataused = $gepstruct[$local_ren][$local_port];
+            $actdarr[0] = $dataused["mac"];
+            $actdarr[1] = '"' . $dataused["sn"] . '"';
+            $actdarr[2] = '"' . $dataused["msn"] . '"';
+            $actdarr[3] = getFloorLevel($dataused["room"]);
+            $actdarr[4] = '"' . $dataused["room"] . '"';
+            $new_vlan = '"' . $dataused["vlan"] . '"';
+            if ($actdarr[8] != $new_vlan) { 
+                echo "Az {$local_ren}-beli {$local_port} átkerült a(z) {$actdarr[8]} VLAN-ból a(z) {$new_vlan} VLAN-ba!\n";
             }
+            $actdarr[8] = $new_vlan;
+            $actdarr[9] = '"' . $dataused["user"] . '"';
+            $actdarr[10] = 'pc' . $dataused["num"];
+            $actdarr[11] = getSubDomain($dataused["vlan"]);
+            $actdarr[12] = (intval($dataused["num"]) + 5);
+
+            $actline = "ujGEPentry(" . implode(",", $actdarr) . ")dnl\n";
         }
     }
-#    $res[] = $actline;
-    echo $actline;
+    $res[] = $actline;
 }
+$fd = fopen("geplista-uj.m4", "w");
+fwrite($fd, implode("", $res));
+fclose($fd);
 ?>





További információk a(z) Services-cvs levelezőlistáról