--- backup-stock-image-20100320/www/interfaces_ppp_edit.php	2010-03-23 13:43:07.000000000 +0700
+++ interfaces_ppp_edit.php.new	2010-03-24 11:06:27.000000000 +0700
@@ -56,7 +56,8 @@
 
 if (isset($id) && $a_ppps[$id]) {
 	$pconfig['port'] = $a_ppps[$id]['port'];
-	$pconfig['ap'] = $a_ppps[$id]['ap'];
+	$pconfig['apn'] = $a_ppps[$id]['apn'];
+	$pconfig['apnum'] = $a_ppps[$id]['apnum'];
 	$pconfig['initstr'] = $a_ppps[$id]['initstr'];
 	$pconfig['username'] = $a_ppps[$id]['username'];
 	$pconfig['password'] = $a_ppps[$id]['password'];
@@ -65,9 +66,9 @@
 	if (isset($a_ppps[$id]['defaultgw']))
 		$pconfig['defaultgw'] = true;
 	$pconfig['phone'] = $a_ppps[$id]['phone'];
-	$pconfig['dialcmd'] = base64_decode($a_ppps[$id]['dialcmd']);
-	$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
-	$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
+	//$pconfig['dialcmd'] = base64_decode($a_ppps[$id]['dialcmd']);
+	//$pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts'];
+	//$pconfig['linespeed'] = $a_ppps[$id]['linespeed'];
 	$pconfig['descr'] = $a_ppps[$id]['descr'];
 }
 
@@ -94,11 +95,21 @@
 
 	if (!$input_errors) {
 		$ppp = array();
+		if (isset($id)) {
+			$ppp['pppid'] = $id;
+		} else
+			$ppp['pppid'] = count($a_ppps);
 		$ppp['port'] = $_POST['port'];
 		$ppp['initstr'] = $_POST['initstr'];
-		$ppp['ap'] = $_POST['ap'];
+		$ppp['apn'] = $_POST['apn'];
+		if ($_POST['apn'] <> ""){
+			if ($_POST['apnum'] <> ""){
+				$ppp['apnum'] = $_POST['apnum'];
+			} else
+				$ppp['apnum'] = "1";
+		}
 		$ppp['phone'] = $_POST['phone'];
-		$ppp['dialcmd'] = base64_encode($_POST['dialcmd']);
+		//$ppp['dialcmd'] = base64_encode($_POST['dialcmd']);
 		$ppp['username'] = $_POST['username'];
 		$ppp['password'] = $_POST['password'];
 		$ppp['localip'] = $_POST['localip'];
@@ -107,8 +118,8 @@
 			$ppp['defaultgw'] = true;
 		else
 			unset($ppp['defaultgw']);
-		$ppp['linespeed'] = $_POST['linespeed'];
-		$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
+		//$ppp['linespeed'] = $_POST['linespeed'];
+		//$ppp['connect-max-attempts'] = $_POST['connect-max-attempts'];
 		$ppp['descr'] = $_POST['descr'];
 
 
@@ -119,7 +130,7 @@
 
 		write_config();
 
-		interfaces_ppp_configure();
+		interface_ppp_configure(-1,true);
 
 		header("Location: interfaces_ppp.php");
 		exit;
@@ -139,25 +150,27 @@
 	</script>
 	<script type="text/javascript">
 	function prefill_att() {
-		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATQ0V1E1S0=0&C1&D2+FCLASS=0 OK \AT+CGDCONT=1,\\\\\\"IP\\\\\\",\\\\\\"ISP.CINGULAR\\\\\\" OK \\\\dATDT\\\\T \TIMEOUT 40 CONNECT"';
+		//$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATQ0V1E1S0=0&C1&D2+FCLASS=0 OK \AT+CGDCONT=1,\\\\\\"IP\\\\\\",\\\\\\"ISP.CINGULAR\\\\\\" OK \\\\dATDT\\\\T \TIMEOUT 40 CONNECT"';
+		$('apn').value = "ISP.CINGULAR";
+		$('apnum').value = "1";
 		$('phone').value = "*99#";
 		$('username').value = "att";
 		$('password').value = "att";
-		$('linespeed').value = "921600";
+		//$('linespeed').value = "921600";
 	}
 	function prefill_sprint() {
-		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
+		//$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
 		$('phone').value = "#777";
 		$('username').value = "sprint";
 		$('password').value = "sprint";
-		$('linespeed').value = "921600";
+		//$('linespeed').value = "921600";
 	}
 	function prefill_vzw() {
-		$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0s7=60 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
+		//$('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0s7=60 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"';
 		$('phone').value = "#777";
 		$('username').value = "123@vzw3g.com";
 		$('password').value = "vzw";
-		$('linespeed').value = "921600";
+		//$('linespeed').value = "921600";
 	}
 	</script>
 	<table width="100%" border="0" cellpadding="6" cellspacing="0">
@@ -199,25 +212,27 @@
 			<td width="22%" valign="top" class="vncell">Init String</td>
 			<td width="78%" class="vtable">
 				<textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea>
-				<br><span class="vexpl">Enter the modem initialization string here</span>
+				<br><span class="vexpl">Note: Enter the modem initialization string here. Typically left blank.</span>
 			</td>
 		</tr>
  		<tr>
- 		  <td width="22%" valign="top" class="vncell">AP Hostname</td>
+ 		  <td width="22%" valign="top" class="vncell">Access Point Name (APN)</td>
  		  <td width="78%" class="vtable">
- 		    <input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>">
+ 		    <input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>">
  		</td>
  		</tr>
  		<tr>
- 		  <td width="22%" valign="top" class="vncell">Dial command</td>
+ 		  <td width="22%" valign="top" class="vncell">APN number (optional)</td>
  		  <td width="78%" class="vtable">
-			<textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea>
- 		  </td>
+ 		    <input name="apnum" type="text" class="formfld unknown" id="apnum" size="5" value="<?=htmlspecialchars($pconfig['apnum']);?>">
+ 		    <br><span class="vexpl">Note: Defaults to 1 if you set APN above. Ignored if you set no APN above.</span>
+ 		</td>
  		</tr>
  		<tr>
  		  <td width="22%" valign="top" class="vncell">Phone Number</td>
  		  <td width="78%" class="vtable">
  		    <input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>">
+ 		    <br><span class="vexpl">Note: Typically (*99# or *99***# or *99***1#) for GSM networks and *777 for CDMA networks</span>
  		  </td>
  		</tr>
 		<tr>
@@ -240,22 +255,10 @@
  		  </td>
 		</tr>
 		<tr>
-			<td width="22%" valign="top" class="vncell">Remote IP</td>
+			<td width="22%" valign="top" class="vncell">Remote IP (Gateway)</td>
 			<td width="78%" class="vtable">
 				<input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
-				<span><p>Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed, equivalent to the gateway.</span>
-			</td>
-		</tr>
-		<tr>
-			<td width="22%" valign="top" class="vncell">Line Speed</td>
-			<td width="78%" class="vtable">
-				<input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>">
-			</td>
-		</tr>
-		<tr>
-			<td width="22%" valign="top" class="vncell">Maximum connection retry</td>
-			<td width="78%" class="vtable">
-				<input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>">
+				<span><p>Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed.</span>
 			</td>
 		</tr>
 		<tr>
