Magellan Linux

Annotation of /alx-src/trunk/alx-web/import.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 355 - (hide annotations) (download)
Mon Oct 10 19:42:06 2005 UTC (18 years, 7 months ago) by niro
File size: 5100 byte(s)
cvs import: alx-web for alxconfig-ng
 - code clean up and
 - reorganized the whole structure

1 niro 355 <?
2     // INCLUDE UND TABELLEN-DEFINITIONEN
3     include('include/basesql.php');
4     $tabs = array('cfg_graphic', 'cfg_network', 'cfg_input', 'client_auth', 'cfg_autostart', 'cfg_comments', 'cfg_printers', 'cfg_sessions', 'cfg_modules', 'cfg_other_menuitems', 'cfg_screensaver');
5     $multi= array( 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0);
6     $data = array();
7    
8     // GGF IMPORTIEREN
9     if($_POST['do_import'])
10     {
11     function add_data($data, $t)
12     {
13     $data['serial']=$_POST['id'];
14     unset($data['id']);
15     sqladd($t, $data);
16     }
17    
18     foreach($tabs as $k=>$t)
19     {
20     if($_POST['import_'.$t])
21     {
22     if($multi[$k])
23     {
24     if(!$_POST['keep_'.$t]) mysql_query('DELETE FROM '.$t.' WHERE serial='.$_POST['id']);
25     sqlforeach('SELECT * FROM '.$t.' WHERE serial='.$_POST['id2'], 'add_data', $t);
26     }
27     else
28     {
29     $data = sqlfirst('SELECT * FROM '.$t.' WHERE serial='.$_POST['id2']);
30     $data['serial']=$_POST['id'];
31     mysql_query('UPDATE '.$t.' SET '.updatestr($data).' WHERE serial='.$_POST['id']);
32     }
33     }
34     }
35     }
36     else
37     {
38     // ANZEIGEN
39     echo '<form action="import.php" method=post>';
40     echo '<input type=hidden name="do_import" value="1">';
41     echo '<input type=hidden name="id" value="'.$id.'">';
42     }
43    
44     // ANZEIGEN => NON-MULTI TABELLEN
45     echo '<table><tr><td valign=top width=560>';
46    
47     if(!$_POST['do_import'])
48     {
49     echo '<b>TARGET:</b><br>';
50     echo '#'.$id.': '.sqlfirst('SELECT hostname FROM cfg_network WHERE serial='.$id,'hostname');
51     echo '<br><br>';
52    
53     echo '<b>IMPORT FROM ALX:</b><br>';
54     echo '<select name="id2">';
55    
56     function list_serial($data) { echo '<option value="'.$data['serial'].'"># '.$data['serial'].': '.$data['hostname']; }
57     sqlforeach('SELECT serial, hostname FROM cfg_network WHERE serial!='.$id.' ORDER BY serial ASC','list_serial',null);
58     echo '</select><br><br>';
59    
60     echo '<script language=JavaScript>';
61     echo 'function toggle(docheck) {';
62     foreach($tabs as $t) echo 'document.forms[0].elements[\'import_'.$t.'\'].checked = docheck;';
63     echo '} </script>';
64    
65     echo '<b>IMPORT TABLES:</b><br>';
66     echo '<table cellpadding=0 cellspacing=0>';
67     foreach($tabs as $k=>$t)
68     {
69     if(!$multi[$k]) echo '<tr><td colspan=2><input type=checkbox name="import_'.$t.'" value="1"> '.$t.'</td></tr>';
70     else echo '<tr><td width=170><input type=checkbox name="import_'.$t.'" value="1"> '.$t.'</td><td><input type=checkbox name="keep_'.$t.'" value="1"> Keep old data</td></tr>';
71     }
72     echo '<tr><td colspan=2><br><input type=checkbox name="import_all" onclick="toggle(this.checked)"> <b>ALL</b></td></tr>';
73     echo '</table><br><br>';
74    
75     echo '<input type=submit value="IMPORT">';
76     }
77     else echo '<b>IMPORT PROCESSED!<br><br><a href="show.php?id='.$id.'" style="text-decoration:none;color:#000000">[EDIT]</a> <a href="index.php" style="text-decoration:none;color:#000000">[INDEX]</a></b>';
78    
79     // ANZEIGEN => NAVI
80     echo '</td><td valign=top>';
81    
82     // STATUS BESTIMMEN (ON/OFF)
83     $conn = sqlfirst('SELECT * FROM state_connected WHERE serial='.$id);
84     $state = 'Off';
85     if(count($conn)>0)
86     {
87     passthru("/usr/sbin/fping -c 1 -i 50 -q ".$conn['ip']." &> /dev/null && exit 0 || exit 1",$retval);
88     if($retval==0) $state = 'On';
89     }
90    
91     echo '<img src="pics/logo2.jpg"><br><br>';
92    
93     $davor = sqlfirst('SELECT mac FROM client_serials WHERE serial='.($id-1),'mac')!=null; if($davor) $disdavor=''; else $disdavor = 'disabled=1';
94     $danach = sqlfirst('SELECT mac FROM client_serials WHERE serial='.($id+1),'mac')!=null; if($danach) $disdanach=''; else $disdanach = 'disabled=1';
95    
96     echo '<input type=button '.$disdavor.' value="<" style="width:30px" onclick="location.href=\'import.php?id='.($id-1).'\'">';
97     echo '<input type=button value="EDIT" style="width:90px;font-weight:bold" onclick="location.href=\'show.php?id='.$id.'\'">';
98     echo '<input type=button '.$disdanach.' value=">" style="width:30px" onclick="location.href=\'import.php?id='.($id+1).'\'">';
99    
100     echo '<br><input type=button value="INDEX" style="width:150px; font-weight:bold" onclick="location.href=\'index.php\'"><br><br>';
101    
102     echo '<br><br>';
103     echo '<div style="border:solid black 1px; padding:5px; background-color:#d5e5ff"><b>';
104     echo '<u>Serial:</u>&nbsp;&nbsp;#'.$id.'<br>';
105     echo '<u>Stand:</u>&nbsp;&nbsp;'.date('H:i:s').'<br>';
106     echo '<u>Status:</u> <img src="pics/'.strtolower($state).'line.gif" align=top> '.$state.'line<br>';
107     if($state=='On') echo '<u>IP:</u> '.$conn['ip'];
108    
109     echo '</b></div>';
110     //echo '<br><br>';
111    
112     if($state=='On')
113     {
114     echo '<input type=button value="REBOOT" style="width:150px" onclick="window.open(\'reboot.php?client='.$id.'&ip='.$conn['ip'].'&op=reboot\', \'ShutdownWin\', \'width=200,height=100\')"><br>';
115     echo '<input type=button value="SHUTDOWN" style="width:150px" onclick="window.open(\'reboot.php?client='.$id.'&ip='.$conn['ip'].'&op=halt\', \'ShutdownWin\', \'width=200,height=100\')"><br>';
116     }
117     else
118     echo '<input type=button value="WAKE ON LAN" style="width:150px" onclick="window.open(\'wake_on_lan.php?mac='.$data['client_serials']['mac'].'\', \'WakeWin\', \'width=200,height=100\')"><br>';
119    
120     echo '</td></tr></table>';
121    
122     if(!$_POST['do_import']) echo '</form>';
123     ?>

Properties

Name Value
svn:executable *