Project

General

Profile

« Previous | Next » 

Revision 56f9c164

Added by Ermal Luçi over 17 years ago

Fix some bugs and typos.

View differences:

etc/inc/shaper.inc
89 89
                $factor = 1000 * 1000 * 1000;
90 90
        break;
91 91
        case "Mb":
92
                $factor = 1000 * 1000 * 1000;
92
                $factor = 1000 * 1000;
93 93
        break;
94 94
        case "Kb":
95 95
                $factor = 1000;
......
99 99
                $factor = 1;
100 100
        break;
101 101
        }
102
        return $factor;
102
        return intval($factor);
103 103
}
104 104

  
105 105
function get_hfsc_bandwidth($object, $bw) {
......
108 108
                $bw_1 = $match[0];
109 109
        else
110 110
                return 0;
111
        $pattern= "/(Kb|Mb|Gb|%)/";
111
        $pattern= "/(b|Kb|Mb|Gb|%)/";
112 112
        if (preg_match($pattern, $bw, $match)) {
113 113
                switch ($match[0]) {
114 114
                case '%':
......
118 118
                        $bw_1 = $bw_1 * get_bandwidthtype_scale($match[0]);
119 119
                        break;
120 120
                }
121
		return $bw_1;
121
		return intval($bw_1);
122 122
        } else
123 123
                return 0;
124 124
}
......
131 131
        if ($altq) {
132 132
                $bw_3 = $altq->GetBandwidth();
133 133
                $bw_3 = $bw_3 *  get_bandwidthtype_scale($altq->GetBwscale());
134
		return $bw_3;
134
		return intval($bw_3);
135 135
        } else return 0;
136 136
}
137 137

  
......
149 149
        }
150 150

  
151 151
        for ($i = 0; $i < count($reqdfields); $i++) {
152
                if ($_POST[$reqdfields[$i]] == "") {
152
                if ($postdata[$reqdfields[$i]] == "") {
153 153
                        $input_errors[] = "The field '" . $reqdfieldsn[$i] . "' is required.";
154 154
                }
155 155
        }
......
272 272
		if (isset($config['interface'][$this->GetQname()]['bandwidth'])) {
273 273
                        switch($data['banwidthtype']) {
274 274
                                case "%":
275
                                        $myBw = $this->GetAvailableBandwidth() * $data['bandwidth'] / 100;
275
                                        $myBw = $this->GetAvailableBandwidth() * intval($data['bandwidth']) / 100;
276 276
                                        break;
277 277
                                default:
278
                                        $myBw = $data['bandwidth'] * get_bandwidthtype_scale($data['banwidthtype'])
278
                                        $myBw = intval($data['bandwidth']) * get_bandwidthtype_scale($data['banwidthtype'])
279 279
;
280 280
                                        break;
281 281
                        }
......
1285 1285
                $parent =& $this->GetParent();
1286 1286
                switch ($data['bandwidthtype']) {
1287 1287
                       case "%":
1288
                             $myBw = $parent->GetAvailableBandwidth() * $data['bandwidth'] / 100;
1288
                             $myBw = $parent->GetAvailableBandwidth() * intval($data['bandwidth']) / 100;
1289 1289
                       default:
1290
                             $mybw = $data['bandwiddth'] * get_bandwidthtype_scale($data['bandwidthtype']);
1290
                             $mybw = intval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']);
1291 1291
                             break;
1292 1292
                }
1293 1293
                if ($parent->GetAvailableBandwidth() < $myBw)
......
1296 1296
                        $input_errors[] = "Priority must be an integer between 1 and 7.";
1297 1297
		}
1298 1298

  
1299
		/* 
1300
		 * XXX: WARNING Some of this are not valid checks! 
1301
		 * We should check available bandwidth too for these values 
1302
		 */
1303 1299
		if ($data['upperlimit1'] <> "" &&  $data['upperlimit2'] == "")
1304 1300
			$input_errors[] = ("upperlimit service curve defined but missing (d) value");
1305 1301
		if ($data['upperlimit2'] <> "" &&  $data['upperlimit1'] == "")
......
1314 1310
		if (isset($data['upperlimit']) && $data['upperlimit3'] <> "" && $data['upperlimit1'] <> "") {
1315 1311
		$bw_1 = get_hfsc_bandwidth($this, $data['upperlimit1']);
1316 1312
		$bw_2 = get_hfsc_bandwidth($this, $data['upperlimit3']);
1317
		if ($bw_1 < $bw_2) 
1313
		if (intval($bw_1) < intval($bw_2)) 
1318 1314
			$input_errors[] = ("upperlimit m1 cannot be smaller than m2");
1319 1315

  
1320 1316
		
1321
		if (get_interface_bandwidth($this) < (80/100 * ($bw_1+$bw_2)))
1317
		if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2))))
1322 1318
			$input_errors[] = ("upperlimit specification excedd 80% of allowable allocation.");
1323 1319
		}
1324 1320
		if ($data['linkshare1'] <> "" &&  $data['linkshare2'] == "")
......
1339 1335
		if (isset($data['linkshare']) && $data['linkshare3'] <> "" && $data['linkshare1'] <> "") {
1340 1336
		$bw_1 = get_hfsc_bandwidth($this, $data['linkshare1']);
1341 1337
                $bw_2 = get_hfsc_bandwidth($this, $data['linkshare3']);
1342
                if ($bw_1 < $bw_2)
1338
                if (intval($bw_1) < intval($bw_2))
1343 1339
                        $input_errors[] = ("linkshare m1 cannot be smaller than m2");
1344 1340

  
1345 1341

  
1346
                if (get_interface_bandwidth($this) < (80/100 * ($bw_1+$bw_2)))
1342
                if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2))))
1347 1343
                        $input_errors[] = ("linkshare specification excedd 80% of allowable allocation.");
1348 1344
		}
1349 1345
		if ($data['realtime1'] <> "" && !is_valid_shaperbw($data['realtime1']))
......
1356 1352
		if (isset($data['realtime']) && $data['realtime3'] <> "" && $data['realtime1'] <> "") {
1357 1353
		$bw_1 = get_hfsc_bandwidth($this, $data['realtime1']);
1358 1354
                $bw_2 = get_hfsc_bandwidth($this, $data['realtime3']);
1359
                if ($bw_1 < $bw_2)
1355
                if (intval($bw_1) < intval($bw_2))
1360 1356
                        $input_errors[] = ("realtime m1 cannot be smaller than m2");
1361 1357

  
1362 1358

  
1363
                if (get_interface_bandwidth($this) < (80/100 * ($bw_1+$bw_2)))
1359
                if (get_interface_bandwidth($this) < (0.8 * (intval($bw_1) + intval($bw_2))))
1364 1360
                        $input_errors[] = ("realtime specification excedd 80% of allowable allocation.");
1365 1361
		}
1366 1362

  
......
1815 1811
           $parent =& $this->GetParent();
1816 1812
           switch ($data['bandwidthtype']) {
1817 1813
                       case "%":
1818
                             $myBw = $parent->GetAvailableBandwidth() * $data['bandwidth'] / 100;
1814
                             $myBw = $parent->GetAvailableBandwidth() * intval($data['bandwidth']) / 100;
1819 1815
                       default:
1820
                             $mybw = $data['bandwiddth'] * get_bandwidthtype_scale($data['bandwidthtype']);
1816
                             $mybw = intval($data['bandwiddth']) * get_bandwidthtype_scale($data['bandwidthtype']);
1821 1817
                             break;
1822 1818
           }
1823
                if ($parent->GetAvailableBandwidth() < $myBw)
1819
                if ($parent->GetAvailableBandwidth() < intval($myBw))
1824 1820
                        $input_errors[] = "The sum of child bandwidths exceeds that of the parent.";
1825 1821
	}
1826 1822
		function ReadConfig(&$q) {

Also available in: Unified diff