Annotation of /alx-src/tags/alx-web-0_7_0_20160208_3/import.php
Parent Directory | Revision Log
Revision 8550 -
(hide annotations)
(download)
Mon Feb 8 13:16:35 2016 UTC (8 years, 7 months ago) by niro
File size: 4992 byte(s)
Mon Feb 8 13:16:35 2016 UTC (8 years, 7 months ago) by niro
File size: 4992 byte(s)
tagged 'alx-web-0_7_0_20160208_3'
1 | niro | 1600 | <? |
2 | |||
3 | niro | 2193 | // 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 | niro | 1600 | { |
14 | niro | 2193 | $data['serial']=$_POST['id']; |
15 | unset($data['id']); | ||
16 | sqladd($t, $data); | ||
17 | } | ||
18 | niro | 1600 | |
19 | niro | 2193 | foreach($tabs as $k=>$t) |
20 | { | ||
21 | if($_POST['import_'.$t]) | ||
22 | niro | 1600 | { |
23 | niro | 2193 | if($multi[$k]) |
24 | niro | 1600 | { |
25 | niro | 2193 | 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 | niro | 1600 | } |
28 | niro | 2193 | 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 | niro | 1600 | } |
35 | } | ||
36 | niro | 2193 | } |
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 | niro | 1600 | |
45 | niro | 2193 | // ANZEIGEN => NON-MULTI TABELLEN |
46 | echo '<table><tr><td valign=top width=560>'; | ||
47 | niro | 1600 | |
48 | niro | 2193 | if(!$_POST['do_import']) |
49 | { | ||
50 | niro | 1600 | 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 | niro | 2193 | } |
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 | niro | 1600 | |
80 | niro | 2193 | // ANZEIGEN => NAVI |
81 | echo '</td><td valign=top>'; | ||
82 | niro | 1600 | |
83 | niro | 2193 | // 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 | niro | 1600 | |
92 | niro | 2193 | echo '<img src="pics/logo2.jpg"><br><br>'; |
93 | niro | 1600 | |
94 | niro | 2193 | $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 | niro | 1600 | |
97 | niro | 2193 | 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 | niro | 1600 | |
101 | niro | 2193 | echo '<br><input type=button value="INDEX" style="width:150px; font-weight:bold" onclick="location.href=\'index.php\'"><br><br>'; |
102 | niro | 1600 | |
103 | niro | 2193 | echo '<br><br>'; |
104 | echo '<div style="border:solid black 1px; padding:5px; background-color:#d5e5ff"><b>'; | ||
105 | echo '<u>Serial:</u> #'.$id.'<br>'; | ||
106 | echo '<u>Stand:</u> '.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 | niro | 1600 | |
110 | niro | 2193 | echo '</b></div>'; |
111 | //echo '<br><br>'; | ||
112 | niro | 1600 | |
113 | niro | 2193 | 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 | niro | 1600 | |
120 | niro | 2193 | echo '</td></tr></table>'; |
121 | niro | 1600 | |
122 | niro | 2193 | if(!$_POST['do_import']) echo '</form>'; |
123 | |||
124 | niro | 1600 | ?> |