Project

General

Profile

« Previous | Next » 

Revision bd259571

Added by Ermal LUÇI over 14 years ago

Correctly verify the input on bandwith at voip step for traffic shaper wizards. Reported-by: http://forum.pfsense.org/index.php/topic,32833.0.html

View differences:

usr/local/www/wizards/traffic_shaper_wizard.inc
456 456
			$stepid--;
457 457
			return;
458 458
		}
459
		$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
460
		$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
461
		$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
462
		$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
463
		if ((0.8 * $ifbw) < $input_bw) {
464
			$friendly_interface = $i+1;
465
			$savemsg=gettext("You cannot set the VoIP upload bandwidth on WAN #{$friendly_interface} higher than 80% of the connection.");
466
			$stepid--;
467
			return;
459
		if ($_POST["conn{$i}uploadspeed"] == "%") {
460
			if (intval($_POST["conn{$i}upload"]) > 80) {
461
				$friendly_interface = $i+1;
462
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on WAN #{$friendly_interface} higher than 80% of the connection.");
463
				$stepid--;
464
				return;
465
			}
466
		} else {
467
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
468
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
469
			$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
470
			$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
471
			if ((0.8 * $ifbw) < $input_bw) {
472
				$friendly_interface = $i+1;
473
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on WAN #{$friendly_interface} higher than 80% of the connection.");
474
				$stepid--;
475
				return;
476
			}
468 477
		}	
469 478
	}
470 479

  
usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
469 469
			$stepid--;
470 470
			return;
471 471
		}
472
		$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
473
		$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
474
		$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
475
		$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
476
		if ((0.8 * $ifbw) < $input_bw) {
477
			$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
478
			$stepid--;
479
			return;
472
		if ($_POST["conn{$i}uploadspeed"] == "%") {
473
			if (intval($_POST["conn{$i}upload"]) > 80) {
474
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
475
				$stepid--;
476
				return;
477
			}
478
		} else {
479
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
480
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
481
			$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
482
			$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
483
			if ((0.8 * $ifbw) < $input_bw) {
484
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
485
				$stepid--;
486
				return;
487
			}
480 488
		}	
481 489

  
482 490
		if (!is_numeric($_POST["local{$i}download"])) {
......
484 492
			$stepid--;
485 493
			return;
486 494
		}
487
		$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
488
		$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);	
489
		$factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]);
490
		$input_bw = $factor * floatval($_POST["local{$i}download"]);
491
		if ((0.8 * $ifbw) < $input_bw) {
492
			$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
493
			$stepid--;
494
			return;
495
		if ($_POST["local{$i}downloadspeed"] == "%") {
496
			if (intval($_POST["local{$i}download"]) > 80) {
497
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
498
				$stepid--;
499
				return;
500
			}
501
		} else {
502
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
503
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);	
504
			$factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]);
505
			$input_bw = $factor * floatval($_POST["local{$i}download"]);
506
			if ((0.8 * $ifbw) < $input_bw) {
507
				$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
508
				$stepid--;
509
				return;
510
			}
495 511
		}	
496 512
	}
497 513

  
usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
495 495
	$steps = intval($config['ezshaper']['step1']['numberofconnections']);
496 496
	for ($i = 0; $i < $steps; $i++) {
497 497
		if (!is_numeric($_POST["conn{$i}upload"])) {
498
				$savemsg = gettext("Upload bandwidth of connection {$i} is not valid.");
498
			$savemsg = gettext("Upload bandwidth of connection {$i} is not valid.");
499
			$stepid--;
500
			return;
501
		}
502
		if ($_POST["conn{$i}uploadspeed"] == "%") {
503
			if (intval($_POST["conn{$i}upload"]) > 80) {
504
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
499 505
				$stepid--;
500 506
				return;
501 507
			}
508
		} else {
502 509
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
503 510
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
504 511
			$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
......
507 514
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
508 515
				$stepid--;
509 516
				return;
517
			}
510 518
		}	
511 519
	}
512 520

  
......
517 525
			$stepid--;
518 526
			return;
519 527
		}
520
		$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
521
		$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);	
522
		$factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]);
523
		$input_bw = $factor * floatval($_POST["local{$i}download"]);
524
		if ((0.8 * $ifbw) < $input_bw) {
525
		$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
526
		$stepid--;
527
			return;
528
		if ($_POST["local{$i}downloadspeed"] == "%") {
529
			if (intval($_POST["local{$i}download"]) > 80) {
530
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
531
				$stepid--;
532
				return;
533
			}
534
		} else {
535
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
536
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);	
537
			$factor = wizard_get_bandwidthtype_scale($_POST["local{$i}downloadspeed"]);
538
			$input_bw = $factor * floatval($_POST["local{$i}download"]);
539
			if ((0.8 * $ifbw) < $input_bw) {
540
				$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
541
				$stepid--;
542
				return;
543
			}
528 544
		}
529 545
	}
530 546

  
usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc
296 296
		}
297 297
	}
298 298

  
299
	if (!is_numeric($_POST["connupload"]) || !is_numeric($_POST['conndownload'])) {
300
		$savemsg = gettext("Upload or download bandwidth is not valid.");
301
		$stepid--;
302
		return;
303
	}
299 304
	$steps = intval($config['ezshaper']['step1']['numberofconnections']);
300 305
	for ($i = 0; $i < $steps; $i++) {
301
		if (!is_numeric($_POST["connupload"])) {
302
			$savemsg = gettext("Upload bandwidth of connection {$i} is not valid.");
303
			$stepid--;
304
			return;
305
		}
306
		$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
307
		$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
308
		$factor = wizard_get_bandwidthtype_scale($_POST["conn{$i}uploadspeed"]);
309
		$input_bw = $factor * floatval($_POST["conn{$i}upload"]);
310
		if ((0.8 * $ifbw) < $input_bw) {
311
			$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
312
			$stepid--;
313
			return;
306
		if ($_POST["connuploadspeed"] == "%") {
307
			if (intval($_POST['connupload']) > 80) {
308
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
309
				$stepid--;
310
				return;
311
			}
312
		} else {
313
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}uploadspeed"]);
314
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}upload"]);	
315
			$factor = wizard_get_bandwidthtype_scale($_POST["connuploadspeed"]);
316
			$input_bw = $factor * floatval($_POST["connupload"]);
317
			if ((0.8 * $ifbw) < $input_bw) {
318
				$savemsg=gettext("You cannot set the VoIP upload bandwidth on connection {$i} higher than 80% of the connection.");
319
				$stepid--;
320
				return;
321
			}
322
		}	
323
		if ($_POST["conndownloadspeed"] == "%") {
324
			if (intval($_POST['conndownload']) > 80) {
325
				$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
326
				$stepid--;
327
				return;
328
			}
329
		} else {
330
			$factor = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
331
			$ifbw = $factor * floatval($config['ezshaper']['step2']["conn{$i}download"]);	
332
			$factor = wizard_get_bandwidthtype_scale($_POST["conndownloadspeed"]);
333
			$input_bw = $factor * floatval($_POST["conndownload"]);
334
			if ((0.8 * $ifbw) < $input_bw) {
335
				$savemsg=gettext("You cannot set the VoIP download bandwidth on connection {$i} higher than 80% of the connection.");
336
				$stepid--;
337
				return;
338
			}
314 339
		}	
315 340
	}
316 341
}
usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml
124 124
				<message>IP Address field is non-blank and doesn't look like an IP address.</message>
125 125
			</field>
126 126
			<field>
127
				<name>Download Speed</name>
127
				<displayname>Upload Speed</displayname>
128
				<name>connupload</name>
128 129
				<type>input</type>
129 130
				<bindstofield>ezshaper-&gt;step3-&gt;connupload</bindstofield>
130 131
				<combinefieldsbegin>true</combinefieldsbegin>
......
134 135
				<dontdisplayname>true</dontdisplayname>
135 136
				<dontcombinecells>true</dontcombinecells>
136 137
				<donotdisable>true</donotdisable>
137
               			<name>Download Speed Unit</name>
138
               			<name>connuploadspeed</name>
138 139
				<description>The limit you want to apply.</description>
139 140
                                <type>select</type>
140 141
				<options>
......
158 159
                    		<bindstofield>ezshaper->step3->connuploadspeed</bindstofield>
159 160
              </field>
160 161
			<field>
161
				<name>Upload Speed</name>
162
				<displayname>Download Speed</displayname>
163
				<name>conndownload</name>
162 164
				<type>input</type>
163 165
				<bindstofield>ezshaper-&gt;step3-&gt;conndownload</bindstofield>
164 166
				<combinefieldsbegin>true</combinefieldsbegin>
......
168 170
				<dontdisplayname>true</dontdisplayname>
169 171
				<dontcombinecells>true</dontcombinecells>
170 172
				<donotdisable>true</donotdisable>
171
               <name>Upload Speed Unit</name>
173
			       <name>conndownloadspeed</name>
172 174
				<description>The limit you want to apply.</description>
173 175
                                <type>select</type>
174 176
				<options>
175 177
				<option>
176
                    <name>%</name>
177
                    <value>%</value>
178
                </option>
178
			    <name>%</name>
179
			    <value>%</value>
180
				</option>
179 181
				<option>
180 182
					<name>Kilobit/s</name>
181 183
					<value>Kb</value>
......
189 191
					<value>Gb</value>
190 192
				</option>
191 193
				</options>
192
                    <bindstofield>ezshaper->step3->conndownloadspeed</bindstofield>
194
			    <bindstofield>ezshaper->step3->conndownloadspeed</bindstofield>
193 195
              </field>
194 196
			<field>
195 197
				<name>Next</name>

Also available in: Unified diff