Magellan Linux

Diff of /alx-src/branches/alx-web-060/import.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2192 by niro, Mon May 9 16:31:38 2011 UTC revision 2193 by niro, Tue Jun 7 13:07:35 2011 UTC
# Line 1  Line 1 
1  <?  <?
  // INCLUDE UND TABELLEN-DEFINITIONEN  
  include('include/basesql.php');  
  $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');  
  $multi= array(    0, 0, 0, 0, 0, 1, 1, 1, 1,       1, 0);  
  $data = array();  
2    
3   // GGF IMPORTIEREN  // INCLUDE UND TABELLEN-DEFINITIONEN
4   if($_POST['do_import'])  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   function add_data($data, $t)   $data['serial']=$_POST['id'];
15   {   unset($data['id']);
16   $data['serial']=$_POST['id'];   sqladd($t, $data);
17   unset($data['id']);   }
  sqladd($t, $data);  
  }  
18    
19   foreach($tabs as $k=>$t)   foreach($tabs as $k=>$t)
20     {
21     if($_POST['import_'.$t])
22   {   {
23   if($_POST['import_'.$t])   if($multi[$k])
24   {   {
25   if($multi[$k])   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   if(!$_POST['keep_'.$t]) mysql_query('DELETE FROM '.$t.' WHERE serial='.$_POST['id']);   }
28   sqlforeach('SELECT * FROM '.$t.' WHERE serial='.$_POST['id2'], 'add_data', $t);   else
29   }   {
30   else   $data = sqlfirst('SELECT * FROM '.$t.' WHERE serial='.$_POST['id2']);
31   {   $data['serial']=$_POST['id'];
32   $data = sqlfirst('SELECT * FROM '.$t.' WHERE serial='.$_POST['id2']);   mysql_query('UPDATE '.$t.' SET '.updatestr($data).' WHERE serial='.$_POST['id']);
  $data['serial']=$_POST['id'];  
  mysql_query('UPDATE '.$t.' SET '.updatestr($data).' WHERE serial='.$_POST['id']);  
  }  
33   }   }
34   }   }
35   }   }
36   else  }
37   {  else
38   // ANZEIGEN  {
39   echo '<form action="import.php" method=post>';   // ANZEIGEN
40   echo '<input type=hidden name="do_import" value="1">';   echo '<form action="import.php" method=post>';
41   echo '<input type=hidden name="id" value="'.$id.'">';   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  // ANZEIGEN => NON-MULTI TABELLEN
46   echo '<table><tr><td valign=top width=560>';  echo '<table><tr><td valign=top width=560>';
47    
48   if(!$_POST['do_import'])  if(!$_POST['do_import'])
49   {  {
50   echo '<b>TARGET:</b><br>';   echo '<b>TARGET:</b><br>';
51   echo '#'.$id.': '.sqlfirst('SELECT hostname FROM cfg_network WHERE serial='.$id,'hostname');   echo '#'.$id.': '.sqlfirst('SELECT hostname FROM cfg_network WHERE serial='.$id,'hostname');
52   echo '<br><br>';   echo '<br><br>';
# Line 73  Line 74 
74   echo '</table><br><br>';   echo '</table><br><br>';
75    
76   echo '<input type=submit value="IMPORT">';   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>';  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  // ANZEIGEN => NAVI
81   echo '</td><td valign=top>';  echo '</td><td valign=top>';
82    
83   // STATUS BESTIMMEN (ON/OFF)  // STATUS BESTIMMEN (ON/OFF)
84   $conn = sqlfirst('SELECT * FROM state_connected WHERE serial='.$id);  $conn = sqlfirst('SELECT * FROM state_connected WHERE serial='.$id);
85   $state = 'Off';  $state = 'Off';
86   if(count($conn)>0)  if(count($conn)>0)
87   {  {
88   passthru("/usr/sbin/fping -c 1 -i 50 -q ".$conn['ip']." &> /dev/null && exit 0 || exit 1",$retval);   passthru("/usr/sbin/fping -c 1 -i 50 -q ".$conn['ip']." &> /dev/null && exit 0 || exit 1",$retval);
89   if($retval==0) $state = 'On';   if($retval==0) $state = 'On';
90   }  }
91    
92   echo '<img src="pics/logo2.jpg"><br><br>';  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';  $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';  $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).'\'">';  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.'\'">';  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).'\'">';  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 '<br><input type=button value="INDEX" style="width:150px; font-weight:bold" onclick="location.href=\'index.php\'"><br><br>';  echo '</td></tr></table>';
   
  echo '<br><br>';  
  echo '<div style="border:solid black 1px; padding:5px; background-color:#d5e5ff"><b>';  
  echo '<u>Serial:</u>&nbsp;&nbsp;#'.$id.'<br>';  
  echo '<u>Stand:</u>&nbsp;&nbsp;'.date('H:i:s').'<br>';  
  echo '<u>Status:</u> <img src="pics/'.strtolower($state).'line.gif" align=top> '.$state.'line<br>';  
  if($state=='On') echo '<u>IP:</u> '.$conn['ip'];  
   
  echo '</b></div>';  
  //echo '<br><br>';  
   
  if($state=='On')  
  {  
  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>';  
  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>';  
  }  
  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>';  
121    
122   echo '</td></tr></table>';  if(!$_POST['do_import']) echo '</form>';
123    
  if(!$_POST['do_import']) echo '</form>';  
124  ?>  ?>

Legend:
Removed from v.2192  
changed lines
  Added in v.2193