Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *