Projet

Général

Profil

« Précédent | Suivant » 

Révision 495c7f0c

Ajouté par Renato Botelho il y a plus de 9 ans

Replace all GET use by POST

Voir les différences:

usr/local/www/vpn_ipsec.php
97 97
		}
98 98
	} else {
99 99
		/* yuck - IE won't send value attributes for image buttons, while Mozilla does - so we use .x/.y to find move button clicks instead... */
100
		unset($movebtn);
100
		unset($delbtn, $delbtnp2, $movebtn, $movebtnp2, $togglebtn, $togglebtnp2);
101 101
		foreach ($_POST as $pn => $pd) {
102
			if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
102
			if (preg_match("/del_(\d+)_x/", $pn, $matches)) {
103
				$delbtn = $matches[1];
104
			} else if (preg_match("/delp2_(\d+)_x/", $pn, $matches)) {
105
				$delbtnp2 = $matches[1];
106
			} else if (preg_match("/move_(\d+)_x/", $pn, $matches)) {
103 107
				$movebtn = $matches[1];
104
				break;
108
			} else if (preg_match("/movep2_(\d+)_x/", $pn, $matches)) {
109
				$movebtnp2 = $matches[1];
110
			} else if (preg_match("/toggle_(\d+)_x/", $pn, $matches)) {
111
				$togglebtn = $matches[1];
112
			} else if (preg_match("/togglep2_(\d+)_x/", $pn, $matches)) {
113
				$togglebtnp2 = $matches[1];
105 114
			}
106 115
		}
116

  
117
		$save = 1;
118

  
107 119
		/* move selected p1 entries before this */
108 120
		if (isset($movebtn) && is_array($_POST['p1entry']) && count($_POST['p1entry'])) {
109 121
			$a_phase1_new = array();
......
134 146
			if (count($a_phase1_new) > 0)
135 147
				$a_phase1 = $a_phase1_new;
136 148

  
137
			if (write_config())
138
				mark_subsystem_dirty('ipsec');
139
			header("Location: vpn_ipsec.php");
140
			exit;
141
		}
142

  
143
		unset($movebtn);
144
		foreach ($_POST as $pn => $pd) {
145
			if (preg_match("/movep2_(\d+)_x/", $pn, $matches)) {
146
				$movebtn = $matches[1];
147
				break;
148
			}
149
		}
150
		/* move selected p2 entries before this */
151
		if (isset($movebtn) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
149
		} else if (isset($movebtnp2) && is_array($_POST['p2entry']) && count($_POST['p2entry'])) {
150
			/* move selected p2 entries before this */
152 151
			$a_phase2_new = array();
153 152

  
154
			/* copy all p2 entries < $movebtn and not selected */
155
			for ($i = 0; $i < $movebtn; $i++) {
153
			/* copy all p2 entries < $movebtnp2 and not selected */
154
			for ($i = 0; $i < $movebtnp2; $i++) {
156 155
				if (!in_array($i, $_POST['p2entry']))
157 156
					$a_phase2_new[] = $a_phase2[$i];
158 157
			}
159 158

  
160 159
			/* copy all selected p2 entries */
161 160
			for ($i = 0; $i < count($a_phase2); $i++) {
162
				if ($i == $movebtn)
161
				if ($i == $movebtnp2)
163 162
					continue;
164 163
				if (in_array($i, $_POST['p2entry']))
165 164
					$a_phase2_new[] = $a_phase2[$i];
166 165
			}
167 166

  
168
			/* copy $movebtn p2 entry */
169
			if ($movebtn < count($a_phase2))
170
				$a_phase2_new[] = $a_phase2[$movebtn];
167
			/* copy $movebtnp2 p2 entry */
168
			if ($movebtnp2 < count($a_phase2))
169
				$a_phase2_new[] = $a_phase2[$movebtnp2];
171 170

  
172
			/* copy all p2 entries > $movebtn and not selected */
173
			for ($i = $movebtn+1; $i < count($a_phase2); $i++) {
171
			/* copy all p2 entries > $movebtnp2 and not selected */
172
			for ($i = $movebtnp2+1; $i < count($a_phase2); $i++) {
174 173
				if (!in_array($i, $_POST['p2entry']))
175 174
					$a_phase2_new[] = $a_phase2[$i];
176 175
			}
177 176
			if (count($a_phase2_new) > 0)
178 177
				$a_phase2 = $a_phase2_new;
179 178

  
180
			if (write_config())
181
				mark_subsystem_dirty('ipsec');
182
			header("Location: vpn_ipsec.php");
183
			exit;
184
		}
185
	}
186
}
179
		} else if (isset($togglebtn)) {
180
			if (isset($a_phase1[$togglebtn]['disabled']))
181
				unset($a_phase1[$togglebtn]['disabled']);
182
			else
183
				$a_phase1[$togglebtn]['disabled'] = true;
187 184

  
188
if (isset($_GET['p1index']) && is_numericint($_GET['p1index']) && isset($a_phase1[$_GET['p1index']])) {
189
	if ($_GET['act'] == "delph1") {
190
		/* remove static route if interface is not WAN */
191
		if ($a_phase1[$_GET['p1index']]['interface'] <> "wan")
192
			mwexec("/sbin/route delete -host {$a_phase1[$_GET['p1index']]['remote-gateway']}");
193

  
194
		/* remove all phase2 entries that match the ikeid */
195
		$ikeid = $a_phase1[$_GET['p1index']]['ikeid'];
196
		foreach ($a_phase2 as $p2index => $ph2tmp)
197
			if ($ph2tmp['ikeid'] == $ikeid) {
198
				unset($a_phase2[$p2index]);
199
			}
185
		} else if (isset($togglebtnp2)) {
186
			if (isset($a_phase2[$togglebtnp2]['disabled']))
187
				unset($a_phase2[$togglebtnp2]['disabled']);
188
			else
189
				$a_phase2[$togglebtnp2]['disabled'] = true;
200 190

  
201
		/* remove the phase1 entry */
202
		unset($a_phase1[$_GET['p1index']]);
203
		write_config();
204
		mark_subsystem_dirty('ipsec');
205
	} else if ($_GET['act'] == "delph2") {
206
		/* remove the phase2 entry */
207
		unset($a_phase2[$_GET['p2index']]);
208
		write_config();
209
		mark_subsystem_dirty('ipsec');
210
	} else if ($_GET['act'] == "toggle") {
211
		if (isset($a_phase1[$_GET['p1index']]['disabled']))
212
			unset($a_phase1[$_GET['p1index']]['disabled']);
213
		else
214
			$a_phase1[$_GET['p1index']]['disabled'] = true;
191
		} else if (isset($delbtn)) {
192
			/* remove static route if interface is not WAN */
193
			if ($a_phase1[$delbtn]['interface'] <> "wan")
194
				mwexec("/sbin/route delete -host {$a_phase1[$delbtn]['remote-gateway']}");
215 195

  
216
		write_config();
217
		mark_subsystem_dirty('ipsec');
218
	}
196
			/* remove all phase2 entries that match the ikeid */
197
			$ikeid = $a_phase1[$delbtn]['ikeid'];
198
			foreach ($a_phase2 as $p2index => $ph2tmp)
199
				if ($ph2tmp['ikeid'] == $ikeid) {
200
					unset($a_phase2[$p2index]);
201
				}
219 202

  
220
	header("Location: vpn_ipsec.php");
221
	exit;
222
} else if (isset($_GET['p2index']) && is_numericint($_GET['p2index']) && isset($a_phase2[$_GET['p2index']])) {
223
	if ($_GET['act'] == "togglep2") {
224
		if (isset($a_phase2[$_GET['p2index']]['disabled']))
225
			unset($a_phase2[$_GET['p2index']]['disabled']);
226
		else
227
			$a_phase2[$_GET['p2index']]['disabled'] = true;
203
			unset($a_phase1[$delbtn]);
228 204

  
229
		write_config();
230
		mark_subsystem_dirty('ipsec');
231
	}
205
		} else if (isset($delbtnp2)) {
206
			unset($a_phase2[$delbtnp2]);
232 207

  
233
	header("Location: vpn_ipsec.php");
234
	exit;
208
		} else
209
			$save = 0;
210

  
211
		if ($save === 1) {
212
			if (write_config())
213
				mark_subsystem_dirty('ipsec');
214
			header("Location: vpn_ipsec.php");
215
			exit;
216
		}
217
	}
235 218
}
236 219

  
237 220
$pgtitle = array(gettext("VPN"),gettext("IPsec"));
......
317 300
							<input type="checkbox" id="frc<?=$i;?>" name="p1entry[]" value="<?=$i;?>" onclick="fr_bgcolor('<?=$i;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
318 301
						</td>
319 302
						<td class="listt" align="center" valign="middle">
320
							<a href="?p1index=<?=$i;?>&amp;act=toggle"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" /></a>
303
							<input name="toggle_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn?>.gif"
304
								title="<?=gettext("click to toggle enabled/disabled status");?>"
305
								type="image" style="height:11;width:11;border:0" />
321 306
						</td>
322 307
						<td class="listlr" onclick="fr_toggle(<?=$i;?>)" id="frd<?=$i;?>">
323 308
							<?=$spans;?>
......
408 393
								</tr>
409 394
								<tr>
410 395
									<td>
411
										<a href="vpn_ipsec.php?act=delph1&amp;p1index=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this phase1 and all associated phase2 entries?"); ?>')">
412
											<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete phase1 entry"); ?>" width="17" height="17" border="0" alt="delete" />
413
										</a>
396
										<input name="del_<?=$i;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
397
											title="<?=gettext("delete phase1 entry");?>"
398
											type="image" style="height:17;width:17;border:0"
399
											onclick="return confirm('<?=gettext("Do you really want to delete this phase1 and all associated phase2 entries?"); ?>')" />
414 400
									</td>
415 401
									<td>
416 402
<?php
......
479 465
									<input type="checkbox" id="<?=$fr_c;?>" name="p2entry[]" value="<?=$ph2index;?>" onclick="fr_bgcolor('<?=$j;?>', '<?=$fr_prefix;?>')" style="margin: 0; padding: 0; width: 15px; height: 15px;" />
480 466
									</td>
481 467
									<td class="listt" align="center" valign="middle">
482
										<a href="?p2index=<?=$ph2index;?>&amp;act=togglep2"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn;?>.gif" width="11" height="11" border="0" title="<?=gettext("click to toggle enabled/disabled status");?>" alt="icon" /></a>
468
										<input name="togglep2_<?=$ph2index;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_<?=$iconfn?>.gif"
469
											title="<?=gettext("click to toggle enabled/disabled status");?>"
470
											type="image" style="height:11;width:11;border:0" />
483 471
									</td>
484 472
									<td class="listlr nowrap" id="<?=$fr_d;?>" onclick="fr_toggle('<?=$j;?>', '<?=$fr_prefix;?>')">
485 473
										<?=$spans;?>
......
547 535
										<a href="vpn_ipsec_phase2.php?p2index=<?=$ph2ent['uniqid'];?>">
548 536
											<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit phase2 entry"); ?>" width="17" height="17" border="0" alt="edit" />
549 537
										</a>
550
										<a href="vpn_ipsec.php?act=delph2&amp;p1index=<?=$i;?>&amp;p2index=<?=$ph2index;?>" onclick="return confirm('<?=gettext("Do you really want to delete this phase2 entry?"); ?>')">
551
											<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete phase2 entry"); ?>" width="17" height="17" border="0" alt="delete" />
552
										</a>
538
										<input name="delp2_<?=$ph2index;?>" src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif"
539
											title="<?=gettext("delete phase2 entry");?>"
540
											type="image" style="height:17;width:17;border:0"
541
											onclick="return confirm('<?=gettext("Do you really want to delete this phase2 entry?"); ?>')" />
553 542
										<a href="vpn_ipsec_phase2.php?dup=<?=$ph2ent['uniqid'];?>">
554 543
											<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add a new Phase 2 based on this one"); ?>" width="17" height="17" border="0" alt="add" />
555 544
										</a>

Formats disponibles : Unified diff