Project

General

Profile

« Previous | Next » 

Revision 509ca889

Added by Evgeny Yurchenko about 14 years ago

Adding gui to choose media options for interfaces.

View differences:

usr/local/www/interfaces.php
711 711
		} else {
712 712
			$wancfg['mss'] = $_POST['mss'];
713 713
		}
714
		if (empty($_POST['mediaopt'])) {
715
			unset($wancfg['media']);
716
			unset($wancfg['mediaopt']);
717
		} else {
718
			$mediaopts = explode(' ', $_POST['mediaopt']);	
719
			if ($mediaopts[0] != ''){ $wancfg['media'] = $mediaopts[0]; }
720
			if ($mediaopts[1] != ''){ $wancfg['mediaopt'] = $mediaopts[1]; }
721
			else { unset($wancfg['mediaopt']); }
722
		}
714 723
		if (isset($wancfg['wireless'])) {
715 724
			handle_wireless_post();
716 725
		}
......
897 906
	}
898 907
}
899 908

  
909
// Find all possible media options for the interface
910
$mediaopts_list = array();
911
$intrealname = $config['interfaces'][$if]['if'];
912
exec("/sbin/ifconfig -m $intrealname | grep \"media \"", $mediaopts);
913
foreach ($mediaopts as $mediaopt){
914
	preg_match("/media (.*)/", $mediaopt, $matches);
915
 	if (preg_match("/(.*) mediaopt (.*)/", $matches[1], $matches1)){
916
		// there is media + mediaopt like "media 1000baseT mediaopt full-duplex"
917
 		array_push($mediaopts_list, $matches1[1] . " " . $matches1[2]);
918
	}else{
919
		// there is only media like "media 1000baseT"
920
		array_push($mediaopts_list, $matches[1]);
921
	}
922
}
923

  
900 924
$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
901 925
$statusurl = "status_interfaces.php";
902 926

  
......
1153 1177
								"header size) will be in effect."); ?>
1154 1178
							</td>
1155 1179
						</tr>
1180
						<?php 
1181
						if (count($mediaopts_list) > 0){
1182
						$mediaopt_from_config = $config['interfaces'][$if]['media'] . ' ' . $config['interfaces'][$if]['mediaopt'];
1183
						echo "<tr>";
1184
							echo '<td valign="top" class="vncell">' . gettext("Speed and duplex") . '</td>';
1185
							echo '<td class="vtable">';
1186
								echo '<select name="mediaopt" class="formselect" id="mediaopt">';
1187
								foreach($mediaopts_list as $mediaopt){
1188
									if ($mediaopt != rtrim($mediaopt_from_config)){
1189
										print "<option value=\"$mediaopt\">" . gettext("$mediaopt") . "</option>";
1190
									} else {
1191
										print "<option value=\"$mediaopt\" selected>" . gettext("$mediaopt") . "</option>";
1192
									}
1193
								}
1194
								echo '</select><br>';
1195
								echo gettext("Here you can explicitely set up speed and duplex mode for the interface.");
1196
							echo '</td>';
1197
						echo '</tr>';
1198
						}
1199
						?>
1156 1200
						<tr>
1157 1201
							<td colspan="2" valign="top" height="16"></td>
1158 1202
						</tr>

Also available in: Unified diff