Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 479 - (hide annotations) (download)
Sat Jun 7 10:12:00 2008 UTC (15 years, 11 months ago) by niro
File size: 17959 byte(s)
-get autostart_session from defined sessions in the database. being little tricky here, defined an empty field before the array, so we can defined 'none' in the web interface

1 niro 425 <?
2     // INCLUDE UND TABELLEN-DEFINITIONEN
3     include('include/basesql.php');
4 niro 464 $tabs = array('cfg_graphic', 'cfg_network', 'cfg_interfaces', 'cfg_input', 'client_auth', 'cfg_autostart', 'client_serials', 'cfg_comments', 'cfg_printers', 'cfg_sessions', 'cfg_modules', 'cfg_other_menuitems', 'cfg_screensaver');
5     $multi= array( 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0);
6 niro 425 $data = array();
7    
8     if($kill==1)
9     {
10     foreach($tabs as $t) mysql_query('UPDATE '.$t.' SET serial=-serial WHERE serial='.$id);
11    
12     echo '<body onload="window.setTimeout(\'window.close()\', 1750)">';
13     echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>';
14    
15     if($id<0) echo 'ACTIVATED #'.abs($id);
16     else echo 'DEACTIVATED #'.$id;
17    
18     echo '</td></tr></table>';
19     return true;
20     }
21    
22    
23     // FELD-DEFINITIONEN (ARRAY=>DROPDOWN / HIDDEN / IGNORE / 1 / BOLD / PASSWORD / SHOW / SHOWTIME / MONITORID)
24     $drop = array();
25 niro 437 $drop['cfg_graphic_module'] = array('vesa', 'ati', 'cirrus', 'i810', 'i710', 'nv', 'mga', 'r128', 'radeon', 's3', 's3virge', 'sis', 'trident', 'tseng', 'via', 'vmware');
26     $drop['resolution'] = array('640x480', '800x600', '1024x768', '1280x1024','1360x768', '1366x768', '1600x1200');
27 niro 425 $drop['depth'] = array('24', '16', '8');
28     $drop['mouse'] = array('Auto', 'IMPS/2', 'PS/2');
29 niro 438 $drop['keyboard'] = array('kbd');
30 niro 435 $drop['cfg_network_module'] = array('auto','3c59x', '8139too', '8139cp', 'e100', 'ne2k-pci', 'pcnet32', 'sis900', 'via-rhine', 'zd1211');
31 niro 425 $drop['networking'] = array('dhcp', 'static');
32 niro 467 $drop['default_iface'] = sqlarr('SELECT iface FROM cfg_interfaces where serial='.$id, '', 'iface');
33 niro 440 $drop['iface'] = 'show';
34 niro 478 # only support parallel and seriell printing on tinyalx
35     //$drop['port'] = array('lpt1', 'com1', 'com2', 'lpd', 'socket', 'ipp');
36     $drop['port'] = array('lpt1', 'com1');
37 niro 425 $drop['location'] = sqlarr('SELECT location FROM client_locations', '', 'location');
38     $drop['id'] = 'hidden';
39     $drop['flg_modified'] = '1';
40     $drop['serial'] = 'ignore';
41     $drop['monitorid'] = 'monitorid';
42     $drop['hostname'] = 'bold';
43     $drop['session'] = 'bold';
44 niro 463 $drop['displaymode'] = array('fullscreen', 'seamless', '1280x1024', '1024x768', '800x600');
45 niro 479 $drop['cfg_autostart_session'] = array('');
46     $drop['cfg_autostart_session'] += sqlarr('SELECT filename FROM cfg_sessions where serial='.$id, 'array', 'filename');
47 niro 425 $drop['mtime'] = 'showtime';
48     $drop['mac'] = 'show';
49     $drop['client_serials_serial'] = 'show';
50     $drop['password'] = 'password';
51     $drop['shell'] = 'password';
52     $drop['vnc'] = 'password';
53     $drop['samba'] = 'password';
54     $drop['station'] = 'password';
55     $drop['txt'] = 'txt';
56     $drop['screensaver'] = array('','blank', 'random', 'ant', 'ant3d', 'apollonian', 'ball', 'bat', 'blot', 'bomb', 'bouboule',
57     'bounce', 'braid', 'bubble', 'bug', 'clock', 'coral', 'crystal', 'daisy', 'dclock', 'decay', 'deco',
58     'demon', 'dilemma', 'discrete', 'dragon', 'drift', 'euler2d', 'eyes', 'fadeplot', 'fiberlamp', 'flag',
59     'flame', 'flow', 'forest', 'galaxy', 'goop', 'grav', 'helix', 'hop', 'hyper', 'ico', 'ifs', 'image',
60     'juggle', 'julia', 'kaleid', 'kumppa', 'laser', 'life', 'life1d', 'life3d', 'lightning', 'lisa', 'lissie',
61     'loop', 'lyapunov', 'mandelbrot', 'marquee', 'matrix', 'maze', 'mountain', 'munch', 'nose', 'pacman',
62     'penrose', 'petal', 'petri', 'polyominoes', 'puzzle', 'pyro', 'qix', 'roll', 'rotor', 'scooter', 'shape',
63     'sierpinski', 'slip', 'solitare', 'space', 'sphere', 'spiral', 'spline', 'star', 'starfish', 'strange',
64     'swarm', 'swirl', 't3d', 'tetris', 'thornbird', 'tik_tak', 'toneclock', 'triangle', 'tube', 'turtle',
65     'vines', 'voters', 'wator', 'wire', 'world', 'worm', 'xcl', 'xjack');
66 niro 440
67 niro 425
68     // ACHTUNG!!! wlan_-Felder heißen eigentlich wireless_
69     $drop['wireless_mode'] = array('', 'managed', 'ad-hoc', 'master', 'repeater', 'secondary', 'monitor', 'auto');
70     $drop['wireless_auth_mode'] = array('', 'wep', 'wpa', 'off');
71     $drop['wireless_key_length'] = array('', '64', '128', '256');
72     $drop['wireless_channel'] = array('', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14');
73     $drop['wireless_frequency'] = array('', '2.412G', '2.417G', '2.422G', '2.427G', '2.432G', '2.437G', '2.442G',
74     '2.447G', '2.452G', '2.457G', '2.462G', '2.467G', '2.472G', '2.484G');
75     $drop['wireless_key'] = 'password';
76     $drop['wireless_key_ascii'] = 'password';
77    
78     // GGF. NEUEN DATENSATZ EINFÜGEN
79     if(isset($_POST['do_add']))
80     {
81     list($bla,$what) = explode(' ',$_POST['do_add']);
82     if($what=='COMMENT') sqladd('cfg_comments', array('serial'=>$id));
83     else if($what=='PRINTER') sqladd('cfg_printers', array('serial'=>$id));
84     else if($what=='MODULE') sqladd('cfg_modules', array('serial'=>$id));
85     else if($what=='SESSION') sqladd('cfg_sessions', array('domain'=>'DOM_AKA_NT', 'browseradrs'=>'128.20.50.38;128.20.50.39;128.20.50.46;128.20.50.24;128..20.100.20', 'serial'=>$id));
86     else if($what=='MENUITEM') sqladd('cfg_other_menuitems', array('serial'=>$id));
87     }
88    
89    
90     // GGF. SPEICHERN
91     if($_POST['do_upl'])
92     {
93     function postarr($prefix)
94     {
95     $prefix.='_';
96     $prelen = strlen($prefix);
97    
98     $arr = array();
99     foreach($_POST as $k=>$v)
100     if((substr($k,0,$prelen)==$prefix) && ($v!='KEEPPASS'))
101     $arr[substr($k,$prelen)] = stripslashes($v);
102    
103     return $arr;
104     }
105    
106     foreach($tabs as $k=>$t)
107     {
108 niro 470 if(!$multi[$k])
109     {
110 niro 471 mysql_query('UPDATE '.$t.' SET '.updatestr(postarr($t)).' WHERE serial='.$id);
111 niro 470 }
112 niro 425 else
113     {
114     $i=0;
115     while(isset($_POST[$t.'_'.$i.'_id']))
116     {
117     if($_POST[$t.'_'.$i.'_delete'])
118     mysql_query('DELETE FROM '.$t.' WHERE serial='.$id.' AND id='.$_POST[$t.'_'.$i.'_id']);
119     else
120 niro 471 mysql_query('UPDATE '.$t.' SET '.updatestr(postarr($t.'_'.$i)).' WHERE serial='.$id.' AND id='.$_POST[$t.'_'.$i.'_id']);
121 niro 425 $i++;
122     }
123     }
124     }
125     }
126    
127    
128     // EINLESEN DER DATEN AUS SQL-TABELLEN
129     foreach($tabs as $k=>$t)
130     {
131     if($multi[$k]) $data[$t] = sqlarr('SELECT * FROM '.$t.' WHERE serial='.$id);
132     else $data[$t] = sqlfirst('SELECT * FROM '.$t.' WHERE serial='.$id);
133     }
134    
135    
136    
137    
138     // ANZEIGEN - KLAPPFUNKTIONEN
139     $absnames = array();
140    
141     function openabs($heading, $helpfile='')
142     {
143     global $absnames;
144     $absnames[] = $heading;
145    
146     // <AufZuLink> <Bild/> <Heading/> </AufZuLink><BR/> <Absatz>
147    
148     if( $_SESSION['openclose'][$heading] )
149     {
150     echo '<a href="JavaScript:openclose(\''.$heading.'\',1);"><img border="0" src="pics/minus.gif" title="CLOSE" id="sch_bild_'.$heading.'"> <b>['.$heading.']</b></a>';
151     if($helpfile!='') echo ' <a href="JavaScript:showhelp(\''.$helpfile.'\')" title="HELP">[?]</a>';
152     echo '<br><div id="sch_absatz_'.$heading.'" style="top:0px; visibility:visible">';
153     }
154     else
155     {
156     echo '<a href="JavaScript:openclose(\''.$heading.'\',1);"><img border="0" src="pics/plus.gif" title="OPEN" id="sch_bild_'.$heading.'"> <b>['.$heading.']</b></a>';
157     if($helpfile!='') echo ' <a href="JavaScript:showhelp(\''.$helpfile.'\')" title="HELP">[?]</a>';
158     echo '<br><div id="sch_absatz_'.$heading.'" style="position:absolute; top:0px; visibility:hidden">';
159     }
160     }
161    
162     function closeabs()
163     {
164     // </Absatz> <BR/>
165    
166     echo '</div><br>';
167     }
168    
169    
170     // ANZEIGEN
171    
172     function parsearr($name, $arr, $del=false, $wireless=false)
173     {
174     global $drop;
175     global $id;
176    
177     $parts = explode('_',$name); $helpfile='help.php?page='.$parts[1];
178     openabs($name, $helpfile);
179     echo '<table class="keytab">';
180    
181     foreach($arr as $k=>$v)
182     {
183 niro 466 //if( (substr($k,0,9)=='wireless_') xor $wireless ) Continue;
184 niro 425
185     $d = $drop[$name.'_'.$k]; if($d==null) $d = $drop[$k];
186 niro 466 //$k = str_replace('wireless_', '', $k);
187 niro 425 $k2 = $k;
188    
189     if(is_array($d))
190     {
191     echo '<tr><td>'.$k2.'</td><td>= <select style="width:144px" name="'.$name.'_'.$k.'">';
192     foreach($d as $di) if($v==$di) echo '<option selected>'.$di; else echo '<option>'.$di;
193     echo '</select></td></tr>';
194     }
195     else if($d=='hidden') echo '<tr><td colspan=2><input type=hidden name="'.$name.'_'.$k.'" value="'.$v.'"></td></tr>';
196     else if($d=='1') echo '<tr><td colspan=2><input type=hidden name="'.$name.'_'.$k.'" value="1"></td></tr>';
197     else if($d=='monitorid') echo '<tr><td class="key">'.$k2.'</td><td>= <input type=button style="width:24px" onclick="window.open(\'monitor.php?id='.$id.'\', \'MonitorWin\', \'width=350,height=200\')" value="..."></td>';
198     else if($d=='bold') echo '<tr><td class="key">'.$k2.'</td><td>= <input style="width:144px;font-weight:bold" name="'.$name.'_'.$k.'" value="'.$v.'"></td></tr>';
199     else if($d=='filename') echo '<tr><td class="key">filename</td><td>= <input style="width:144px;font-weight:bold" name="'.$name.'_'.$k.'" value="'.$v.'"></td></tr>';
200     else if($d=='show') echo '<tr><td class="key">'.$k2.'</td><td>= <b>'.$v.'</b></td></tr>';
201     else if($d=='showtime') echo '<tr><td class="key">'.$k2.'</td><td>= <b>'.date('d.m.y - H:i:s', $v).'</b></td></tr>';
202     else if($d=='password' && $v=='') echo '<tr><td class="key">'.$k2.'</td><td>= <input type=password style="width:144px" name="'.$name.'_'.$k.'" value=""></td></tr>';
203     else if($d=='password') echo '<tr><td class="key">'.$k2.'</td><td>= <input type=password style="width:144px" name="'.$name.'_'.$k.'" value="KEEPPASS"></td></tr>';
204     else if($d=='txt') echo '<tr><td colspan=2><textarea style="width:240px; background-color:#d5e5ff" rows=4 name="'.$name.'_'.$k.'">'.$v.'</textarea></td></tr>';
205     else if($d!='ignore') echo '<tr><td class="key">'.$k2.'</td><td>= <input style="width:144px" name="'.$name.'_'.$k.'" value="'.$v.'"></td></tr>';
206     }
207    
208     if($del) echo '<tr><td class="key">delete</td><td>=<input type=checkbox name="'.$name.'_delete" value="1"></td></tr>';
209     echo '</table>';
210     closeabs();
211    
212 niro 466 //if($name=='cfg_network' && !$wireless) parsearr($name.'_wireless', $arr, $del, true);
213 niro 425 }
214     function parsearrs($name, $arr)
215     {
216     foreach($arr as $k=>$a)
217     parsearr($name.'_'.$k, $a, true);
218     }
219    
220     ?><head>
221     <title>ALX Config</title>
222     <style>
223     body,table { font-family:Tahoma; font-size:10pt }
224     a { color:#000000; text-decoration:none; }
225     .key { width:85px }
226     .keytab, input, textarea, select, option { font-size:8pt; font-family:Tahoma }
227     .but { font-size:10pt; font-family:Tahoma; height:23px }
228     </style>
229     <script language="JavaScript" src="openclose_ajax.js"></script>
230     <script language="JavaScript">
231    
232     function openclose(nummer, act)
233     {
234     var bild = document.images['sch_bild_'+nummer];
235     var absatz = document.all['sch_absatz_'+nummer].style;
236     var senden = false;
237    
238     if(bild.title == 'OPEN')
239     {
240     if(act<=1)
241     {
242     absatz.visibility = 'visible';
243     absatz.position = '';
244     bild.title = 'CLOSE';
245     bild.src = 'pics/minus.gif';
246     senden = true;
247     act = 0;
248     }
249     }
250     else
251     {
252     if(act>=1)
253     {
254     absatz.visibility = 'hidden';
255     absatz.position = 'absolute';
256     bild.title = 'OPEN';
257     bild.src = 'pics/plus.gif';
258     senden = true;
259     act = 2;
260     }
261     }
262    
263     if(senden) sendopenclose(nummer,act);
264     }
265    
266     function showhelp(name)
267     { window.open(name, 'HelpWin', 'width=620,height=500,scrollbars=yes'); }
268    
269     </script>
270     </head>
271    
272     <body><?
273    
274    
275     //echo '<body style="background-image:URL(logo.jpg);background-repeat:no-repeat; background-position:0px 0px; margin-top:25px">';
276     echo '<form action="show.php" method=post onreset="return confirm(\'UNDO CHANGES?\')">';
277     echo '<input type=hidden name="do_upl" value="1">';
278     echo '<input type=hidden name="id" value="'.$id.'">';
279    
280     // ANZEIGEN => NON-MULTI TABELLEN
281     echo '<table><tr><td valign=top width="300">';
282    
283     echo '<b style="font-size:6pt">';
284     echo '<a href="JavaScript:opencloseall(0);" title="OPEN ALL"><img src="pics/plus.gif" border="0"> OPEN...</a> ';
285     echo '<a href="JavaScript:opencloseall(2);" title="CLOSE ALL"><img src="pics/minus.gif" border="0"> CLOSE...</a> ALL';
286     echo '</b><br><br>';
287    
288     foreach($tabs as $k=>$t) if(!$multi[$k]) parsearr($t, $data[$t]);
289    
290     // ANZEIGEN => MULTI TABELLEN
291     echo '</td><td valign=top width="300">';
292    
293     foreach($tabs as $k=>$t) if($multi[$k]) parsearrs($t, $data[$t]);
294    
295     echo '<script language="JavaScript">';
296     echo 'function opencloseall(act) { ';
297    
298     foreach($absnames as $absname)
299     echo 'openclose("'.$absname.'", act); ';
300    
301     echo '}</script>';
302    
303     // ANZEIGEN => NAVI
304     echo '</td><td valign=top>';
305    
306     // STATUS BESTIMMEN (ON/OFF)
307     $conn = sqlfirst('SELECT * FROM state_connected WHERE serial='.$id);
308     $state = 'Off';
309     if(count($conn)>0)
310     {
311     passthru("/usr/sbin/fping -c 1 -i 50 -q ".$conn['ip']." &> /dev/null && exit 0 || exit 1",$retval);
312     if($retval==0) $state = 'On';
313     }
314    
315    
316     echo '<img src="pics/logo2.jpg"><br><br>';
317    
318     echo '<input class="but" type=submit value="SAVE" style="width:150px"><br><br>';
319    
320     echo '<input class="but" type=submit name="do_add" value="SAVE+ADD COMMENT" style="width:150px"><br>';
321     echo '<input class="but" type=submit name="do_add" value="SAVE+ADD PRINTER" style="width:150px"><br>';
322     echo '<input class="but" type=submit name="do_add" value="SAVE+ADD SESSION" style="width:150px"><br>';
323     echo '<input class="but" type=submit name="do_add" value="SAVE+ADD MODULE" style="width:150px"><br>';
324     echo '<input class="but" type=submit name="do_add" value="SAVE+ADD MENUITEM" style="width:150px"><br><br>';
325    
326    
327     if($id>0) $KILLCAP='DEACTIVATE'; else $KILLCAP='ACTIVATE';
328     echo '<input class="but" type=button value="'.$KILLCAP.'" style="width:150px" onclick="if(confirm(\''.$KILLCAP.' CLIENT #'.abs($id).' ?\')) { window.open(\'show.php?id='.$id.'&kill=1\', \'DeactWin\', \'width=200,height=100\'); location.href=\'index.php\'; }"><br>';
329     echo '<input class="but" type=button value="IMPORT FROM..." style="width:150px" onclick="location.href=\'import.php?id='.$id.'\'"><br>';
330     echo '<input class="but" type=reset value="UNDO CHANGES" style="width:150px"><br><br>';
331    
332     $davor = sqlfirst('SELECT mac FROM client_serials WHERE serial='.($id-1),'mac')!=null; if($davor) $disdavor=''; else $disdavor = 'disabled=1';
333     $danach = sqlfirst('SELECT mac FROM client_serials WHERE serial='.($id+1),'mac')!=null; if($danach) $disdanach=''; else $disdanach = 'disabled=1';
334    
335     echo '<input class="but" type=button '.$disdavor.' value="<" style="width:30px" onclick="location.href=\'show.php?id='.($id-1).'\'">';
336     echo '<input class="but" type=button value="REFRESH" style="width:90px" onclick="location.href=\'show.php?id='.$id.'\'">';
337     echo '<input class="but" type=button '.$disdanach.' value=">" style="width:30px" onclick="location.href=\'show.php?id='.($id+1).'\'">';
338     echo '<br><input class="but" type=button value="INDEX" style="width:150px; font-weight:bold" onclick="location.href=\'index.php\'"><br><br>';
339    
340     echo '<br><br>';
341     echo '<div style="border:solid black 1px; padding:5px; background-color:#d5e5ff"><b>';
342     if($id<0) echo '<b>DEACTIVATED!</b><br><br>';
343     echo '<u>Serial:</u>&nbsp;&nbsp;#'.$id.'<br>';
344     echo '<u>Stand:</u>&nbsp;&nbsp;'.date('H:i:s').'<br>';
345     echo '<u>Status:</u> <img src="pics/'.strtolower($state).'line.gif" align=top> '.$state.'line<br>';
346     if($state=='On')
347     {
348     echo '<u>IP:</u> '.$conn['ip'].'<br><br>';
349 niro 424 $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$id.'');
350     while ($row = mysql_fetch_row ($pubkey)) {
351     # schreiben der .ssh/known_hosts file mit dem public rsa key des client,
352     # um die "yes" abfrage zu vermeiden
353     $hostfile = fopen ($home."/.ssh/known_hosts","w");
354     fwrite($hostfile,$conn['ip']." ".$row[0],strlen($row[0])+strlen($conn['ip'])+1);
355     fclose($hostfile);
356 niro 355
357 niro 434 $osver = exec($sshcmd.' -l root '.$conn['ip'].' \'os_ver=$(<'.$mageversion.');cfg_ver=$(/sbin/magequery -n '.$alxconfig.'|cut -d" " -f5);pname=${cfg_ver%-*-*};cfg_ver=${cfg_ver/${pname}-};echo "${os_ver}:${cfg_ver}"\'');
358 niro 425 $osver = explode(':',$osver);
359     }
360     if($osver[0] == '') $osver[0]='unkown';
361     if($osver[1] == '') $osver[1]='unkown';
362     echo '<u>OS:</u> '.$osver[0].'<br>';
363     echo '<u>Utils:</u> '.$osver[1].'<br>';
364     }
365    
366     echo '</b></div>';
367     //echo '<br><br>';
368    
369     if($state=='On')
370     {
371     echo '<input class="but" type=button value="REBOOT" style="width:150px" onclick="if(confirm(\'REBOOT CLIENT #'.$id.' ?\')) window.open(\'reboot.php?client='.$id.'&ip='.$conn['ip'].'&op=reboot\', \'ShutdownWin\', \'width=200,height=100\')"><br>';
372     echo '<input class="but" type=button value="SHUTDOWN" style="width:150px" onclick="if(confirm(\'SHUTDOWN CLIENT #'.$id.' ?\')) window.open(\'reboot.php?client='.$id.'&ip='.$conn['ip'].'&op=halt\', \'ShutdownWin\', \'width=200,height=100\')"><br>';
373    
374     echo '<br>';
375     echo '<div style="border:solid black 1px; padding:5px; background-color:#d5e5ff" align="center"><b>';
376     echo 'Client Update:</b></div>';
377     echo '<input class="but" type=button value="UPDATE MAGE DB" style="width:150px" onclick="if(confirm(\'UPDATE DB ON CLIENT #'.$id.' ?\')) window.open(\'mageupgrade.php?client='.$id.'&ip='.$conn['ip'].'&op=update\', \'ShutdownWin\', \'width=800,height=600\')"><br>';
378     echo '<input class="but" type=button value="CALC DEPS" style="width:150px" onclick="if(confirm(\'CALC DEPS FOR CLIENT #'.$id.' ?\')) window.open(\'mageupgrade.php?client='.$id.'&ip='.$conn['ip'].'&op=calc\', \'ShutdownWin\', \'width=800,height=600\')"><br>';
379     echo '<input class="but" type=button value="UPGRADE CLIENT" style="width:150px" onclick="if(confirm(\'UPGRADE ALL PACKAGES ON CLIENT #'.$id.' ?\')) window.open(\'mageupgrade.php?client='.$id.'&ip='.$conn['ip'].'&op=upgrade\', \'ShutdownWin\', \'width=800,height=600\')"><br>';
380     }
381     else
382     echo '<input class="but" type=button value="WAKE ON LAN" style="width:150px" onclick="if(confirm(\'WAKE CLIENT #'.$id.' ?\')) window.open(\'wake_on_lan.php?mac='.$data['client_serials']['mac'].'\', \'WakeWin\', \'width=200,height=100\')"><br>';
383    
384     echo '<br><center><a href="share/ChangeLog.html" target="_blank">[ChangeLog]</a> <a href="share/FAQ.html" target="_blank">[FAQs]</a></center>';
385    
386     echo '</td></tr></table>';
387     echo '</form>';
388     ?>

Properties

Name Value
svn:executable *