Changeset 239
- Timestamp:
- Aug 2, 2009, 10:28:58 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forms.php
r229 r239 43 43 break; 44 44 case 'String': 45 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';45 $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 46 46 break; 47 47 case 'Text': 48 $Edit = '<textarea style="width: 100%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>';49 break; 50 case 'Password': 51 $Edit = '<input style="width: 100%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';48 $Edit = '<textarea style="width: 98%; height: 200px;" name="'.$Context.$Index.'">'.$this->Values[$Index].'</textarea>'; 49 break; 50 case 'Password': 51 $Edit = '<input style="width: 98%;" type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 52 52 break; 53 53 case 'Integer': 54 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';54 $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 55 55 break; 56 56 case 'Float': 57 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';57 $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 58 58 break; 59 59 case 'Time': 60 60 if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y'); 61 $Edit = '<input style="width: 100%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />';61 $Edit = '<input style="width: 98%;" type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'" />'; 62 62 break; 63 63 case 'Array': … … 252 252 { 253 253 if($Index == 0) $Class = ' class="Header"'; else $Class = ''; 254 $Result .= '<td'.$Class.' >'.$Item.'</td>';254 $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>'; 255 255 } 256 256 $Result .= '</tr>'; -
trunk/map/index.php
r216 r239 18 18 19 19 var map; 20 var tinyIcon; 20 21 21 22 function initialize() … … 37 38 tinyIcon.shadowSize = new GSize(10, 10); 38 39 tinyIcon.iconAnchor = new GPoint(5, 5); 39 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 40 41 // Set up our GMarkerOptions object literal 42 markerOptions = { icon:tinyIcon };'; 40 tinyIcon.infoWindowAnchor = new GPoint(5, 1);'; 43 41 44 42 $Output .= ' … … 102 100 while($Device = $DbResult->fetch_assoc()) 103 101 { 104 $Output .= 'new GMarker(new GLatLng('.$Device['PositionLatitude'].', '.$Device['PositionLongitude'].'), markerOptions), ';102 $Output .= 'new GMarker(new GLatLng('.$Device['PositionLatitude'].', '.$Device['PositionLongitude'].'), {title: "'.$Device['Name'].'", icon:tinyIcon }), '; 105 103 } 106 104 $Output .= ']; -
trunk/system/generators/dhcp_routerboard.php
r213 r239 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include_once('../../global.php'); 4 include('../../global.php'); 5 include('../routerboard.php'); 6 $Path = array('ip', 'dhcp-server', 'lease'); 7 8 $Routerboard = new Routerboard(); 9 $Routerboard->UserName = $Config['MainRouter']['UserName']; 10 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 5 11 6 12 $DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0'); … … 8 14 { 9 15 echo($Subnet['DHCP']); 16 $Routerboard->HostName = $Subnet['DHCP']; 10 17 $I = explode('.', $Subnet['AddressRange']); 11 18 $I = $I[2]; 12 $Commands = array(); 13 $Commands[] = '/ip dhcp-server lease { remove [find server=dhcp'.$I.']}'; 19 $Items = array(); 14 20 $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM `NetworkInterface` LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (`LocalIP` LIKE "192.168.'.$I.'.%") AND (`MAC` != "00:00:00:00:00:00") ORDER BY `LocalIP`'); 15 21 while($Interface = $DbResult2->fetch_assoc()) 16 22 { 17 $Commands[] = '/ip dhcp-server lease add mac-address='.$Interface['MAC'].' address='.$Interface['LocalIP'].' server=dhcp'.$I.' comment='.$Interface['DeviceName'].'-'.$Interface['Name']; 23 $Name = $Interface['DeviceName']; 24 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 25 $Items[] = array('mac-address' => $Interface['MAC'], 'address' => $Interface['LocalIP'], 'server' => 'dhcp'.$I, 'comment' => $Name); 18 26 } 19 $Commands = implode(';', $Commands); 20 $Command = '/usr/bin/ssh -o ConnectTimeout=5 -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Subnet['DHCP'].' "'.$Commands.'"'; 21 //echo($Command."\n"); 22 $Output = ''; 23 exec($Command, $Output); 24 print_r($Output); 27 28 print_r($Routerboard->ListUpdate($Path, array('mac-address', 'address', 'server', 'comment'), $Items, array('server' => 'dhcp'.$I))); 25 29 echo("\n"); 26 30 } -
trunk/system/generators/netwatch.php
r235 r239 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include_once('../../global.php'); 4 include('../../global.php'); 5 include('../routerboard.php'); 6 $Path = array('tool', 'netwatch'); 7 8 $Routerboard = new Routerboard(); 9 $Routerboard->UserName = $Config['MainRouter']['UserName']; 10 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 5 11 6 12 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Member` = 0'); … … 8 14 { 9 15 echo($Router['DHCP']."\n"); 10 $ Commands = array();11 $ Commands[] = '/tool netwatch remove [find]';16 $Routerboard->HostName = $Router['DHCP']; 17 $Items = array(); 12 18 $DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `DHCP`="'.$Router['DHCP'].'"'); 13 19 while($Subnet = $DbResult->fetch_assoc()) … … 22 28 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 23 29 echo($Name.', '); 24 $ Commands[] = '/tool netwatch add host='.$Interface['LocalIP'].' interval=1m comment='.$Name;30 $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:01:00', 'comment' => $Name); 25 31 } 26 32 } 27 $Commands = implode(';', $Commands); 28 $Command = '/usr/bin/ssh -o ConnectTimeout='.$Config['MainRouter']['ConnectTimeout'].' -l '.$Config['MainRouter']['UserName'].' -i id_dsa '.$Router['DHCP'].' "'.$Commands.'"'; 29 //echo($Command."\n"); 30 $Output = ''; 31 exec($Command, $Output); 32 print_r($Output); 33 $Routerboard->ListUpdate($Path, array('host', 'interval', 'comment'), $Items); 33 34 echo("\n"); 34 35 } -
trunk/system/queues_import.php
r161 r239 1 1 <?php 2 include_once(' global.php');2 include_once('../global.php'); 3 3 4 4 $Config['Web']['ShowErrors'] = 1; 5 5 6 include _once('routerboard.php');6 include('routerboard.php'); 7 7 8 8 $Routerboard = new Routerboard($Config['MainRouter']['HostName'], $Config['MainRouter']['UserName'], $Config['MainRouter']['Password']); 9 $QueueTree = $Routerboard->GetList('/queue tree', array('bytes', 'rate', 'parent', 'packet-mark', 'name')); 10 print($QueueTree); 9 $Routerboard->PrivateKey = 'generators/id_dsa'; 10 print_r($Routerboard->ListUpdate(array('tool', 'netwatch'), array('host', 'comment'), array())); 11 //print_r($Routerboard->Execute('ip address {:foreach i in=[find] do={:put "address=".[get $i address]." network=".[get $i network])}}')); 12 //print_r($Routerboard->GetItem('system ntp client print')); 11 13 12 14 ?> -
trunk/system/routerboard.php
r161 r239 1 1 <?php 2 2 3 include_once('ssh.php'); 4 5 class Routerboard extends SSH 3 class Routerboard 6 4 { 7 var $Methods = array( 8 'kex' => 'diffie-hellman-group1-sha1', 9 'client_to_server' => array('crypt' => '3des-cbc', 'comp' => 'none'), 10 'server_to_client' => array('crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc', 'comp' => 'none') 11 ); 5 var $SSHPath = '/usr/bin/ssh'; 6 var $Timeout = 3; 7 var $HostName; 8 var $UserName; 9 var $Password; 10 var $PrivateKey = 'id_dsa'; 11 12 function __construct($HostName = 'localhost', $UserName = 'admin', $Password = '') 13 { 14 $this->HostName = $HostName; 15 $this->UserName = $UserName; 16 $this->Password = $Password; 17 } 12 18 13 19 function Execute($Commands) 14 { 20 { 15 21 if(is_array($Commands)) $Commands = implode(';', $Commands); 16 return(parent::Execute($Commands)); 22 $Commands = trim($Commands); 23 if($Commands != '') 24 { 25 $Output = array(); 26 $Commands = addslashes($Commands); 27 $Commands = str_replace('$', '\$', $Commands); 28 $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"'; 29 //echo($Command); 30 exec($Command, $Output); 31 } else $Output = ''; 32 //print_r($Output); 33 return($Output); 17 34 } 18 35 19 function GetItem($Command)36 function ItemGet($Path) 20 37 { 21 $Result = $this->Execute( $Command);38 $Result = $this->Execute(implode(' ', $Path).' print'); 22 39 array_pop($Result); 23 40 $List = array(); … … 25 42 { 26 43 $ResultLineParts = explode(' ', trim($ResultLine)); 27 if($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 28 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 44 if(count($ResultLineParts) > 1) 45 { 46 if($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes 47 $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1]; 48 } else $List[substr($ResultLineParts[0], 0, -1)] = ''; 29 49 } 30 50 return($List); 31 51 } 32 52 33 function GetList($Command, $Properties)53 function ListGet($Path, $Properties, $Conditions = array()) 34 54 { 35 55 $PropertyList = '"'; 36 foreach($Properties as $ Property)56 foreach($Properties as $Index => $Property) 37 57 { 38 $PropertyList .= $ Property.'=".[get $i '.$Property.']." ';58 $PropertyList .= $Index.'=".[get $i '.$Property.']." '; 39 59 } 40 60 $PropertyList = substr($PropertyList, 0, -3); 41 $Result = $this->Execute($Command.' {:foreach i in=[find] do={:put ('.$PropertyList.')}}'); 61 62 $ConditionList = ''; 63 foreach($Conditions as $Index => $Item) 64 { 65 $ConditionList .= $Index.'="'.$Item.'" '; 66 } 67 $ConditionList = substr($ConditionList, 0, -1); 68 69 $Result = $this->Execute(implode(' ', $Path).' {:foreach i in=[find '.$ConditionList.'] do={:put ('.$PropertyList.')}}'); 42 70 $List = array(); 43 71 foreach($Result as $ResultLine) … … 48 76 { 49 77 $Value = explode('=', $ResultLinePart); 50 $ListItem[$ Value[0]] = $Value[1];78 $ListItem[$Properties[$Value[0]]] = $Value[1]; 51 79 } 52 80 $List[] = $ListItem; … … 55 83 } 56 84 57 function GetSystemResource()85 function ListEraseAll($Path) 58 86 { 59 return($this->GetItem('/system resource print'));87 $this->Execute(implode(' ', $Path).' { remove [find] }'); 60 88 } 61 62 function GetFirewallFilterList()89 90 function ListUpdate($Path, $Properties, $Values, $Condition = array()) 63 91 { 64 return($this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes'))); 65 } 66 67 function GetDHCPServerLeasesList() 68 { 69 return($this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'))); 92 $List = $this->ListGet($Path, $Properties, $Condition); 93 //print_r($List); 94 //print_r($Values); 95 $Commands = array(); 96 97 // Erase all items not existed in $Values 98 foreach($List as $Index => $ListItem) 99 { 100 if(!in_array($ListItem, $Values)) 101 { 102 $Prop = ''; 103 foreach($ListItem as $Index => $Property) 104 { 105 $Prop .= $Index.'="'.$Property.'" '; 106 } 107 $Prop = substr($Prop, 0, -1); 108 $Commands[] = implode(' ', $Path).' remove [find '.$Prop.']'; 109 } 110 } 111 112 // Add new items 113 foreach($Values as $ListItem) 114 { 115 if(!in_array($ListItem, $List)) 116 { 117 $Prop = ''; 118 foreach($ListItem as $Index => $Property) 119 { 120 $Prop .= $Index.'='.$Property.' '; 121 } 122 $Prop = substr($Prop, 0, -1); 123 $Commands[] = implode(' ', $Path).' add '.$Prop; 124 } 125 } 126 //print_r($Commands); 127 return($this->Execute($Commands)); 70 128 } 71 129 }
Note:
See TracChangeset
for help on using the changeset viewer.