Completed
Pull Request — master (#532)
06:37
created
functions/scripts/find_untranslated_files.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@
 block discarded – undo
72 72
 function get_string_between($string, $start, $end){
73 73
     $string = " ".$string;
74 74
     $ini = strpos($string,$start);
75
-    if ($ini == 0) return "";
75
+    if ($ini == 0) {
76
+        return "";
77
+    }
76 78
     $ini += strlen($start);
77 79
     $len = strpos($string,$end,$ini) - $ini;
78 80
     return substr($string,$ini,$len);
Please login to merge, or discard this patch.
api/controllers/Responses.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -270,7 +270,9 @@  discard block
 block discarded – undo
270 270
 		    if(strpos($key, " ")>0)	{ $key = str_replace(" ", "_", $key); }
271 271
 
272 272
 		    // if key is numeric append item
273
-		    if(is_numeric($key)) $key = "item".$key;
273
+		    if(is_numeric($key)) {
274
+		        $key = "item".$key;
275
+		    }
274 276
 
275 277
 			// if array add child
276 278
 	        if (is_array($value)) {
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 	 * @license CC-BY-3.0 <http://spdx.org/licenses/CC-BY-3.0>
301 303
 	 */
302 304
 	public function xml_to_array ( $xmlObject, $out = array () ) {
303
-	    foreach ( (array) $xmlObject as $index => $node )
304
-	        $out[$index] = ( is_object ( $node ) ) ? $this->xml_to_array ( $node ) : $node;
305
+	    foreach ( (array) $xmlObject as $index => $node ) {
306
+	    	        $out[$index] = ( is_object ( $node ) ) ? $this->xml_to_array ( $node ) : $node;
307
+	    }
305 308
 
306 309
 	    return $out;
307 310
 	}
@@ -315,14 +318,18 @@  discard block
 block discarded – undo
315 318
 	 */
316 319
 	private function object_to_array ($obj) {
317 320
 		// object to array
318
-	    if(is_object($obj)) $obj = (array) $obj;
321
+	    if(is_object($obj)) {
322
+	        $obj = (array) $obj;
323
+	    }
319 324
 	    if(is_array($obj)) {
320 325
 	        $new = array();
321 326
 	        foreach($obj as $key => $val) {
322 327
 	            $new[$key] = $this->object_to_array($val);
323 328
 	        }
324 329
 	    }
325
-	    else $new = $obj;
330
+	    else {
331
+	        $new = $obj;
332
+	    }
326 333
 	    return $new;
327 334
 	}
328 335
 
Please login to merge, or discard this patch.
api/controllers/Addresses.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 		$this->remap_keys ();
217 217
 
218 218
 		// first free
219
-		if($this->_params->id=="first_free")   {
219
+		if($this->_params->id=="first_free") {
220 220
     		$this->_params->ip_addr = $this->Addresses->get_first_available_address ($this->_params->subnetId, $this->Subnets);
221 221
     		// null
222 222
     		if ($this->_params->ip_addr==false)          { $this->Response->throw_exception(404, 'No free addresses found'); }
223
-            else                                         { $this->_params->ip_addr = $this->Addresses->transform_address ($this->_params->ip_addr, "dotted"); }
223
+    		else                                         { $this->_params->ip_addr = $this->Addresses->transform_address ($this->_params->ip_addr, "dotted"); }
224 224
 		}
225 225
 
226 226
 		// validate ip address - format, proper subnet, subnet/broadcast check
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		}
241 241
 		else {
242 242
     		//set result
243
-    		if($this->_params->id=="first_free")   {
243
+    		if($this->_params->id=="first_free") {
244 244
         	    return array("code"=>201, "data"=>"Address created", "location"=>"/api/".$this->_params->app_id."/addresses/".$this->Addresses->lastId."/", "ip"=>$this->Addresses->transform_address ($this->_params->ip_addr, "dotted"));
245 245
     		}
246 246
     		else {
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		# execute update
316 316
 		if(!$this->Addresses->modify_address ($values))
317 317
 													{ $this->Response->throw_exception(500, "Failed to delete address"); }
318
-		else {
318
+													else {
319 319
 			//set result
320 320
 			return array("code"=>200, "data"=>"Address deleted");
321 321
 		}
Please login to merge, or discard this patch.
api/controllers/Sections.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		# execute update
190 190
 		if(!$this->Sections->modify_section ("add", $values))
191 191
 														{ $this->Response->throw_exception(500, "Section create failed"); }
192
-		else {
192
+														else {
193 193
 			//set result
194 194
 			return array("code"=>201, "data"=>"Section created", "location"=>"/api/".$this->_params->app_id."/sections/".$this->Sections->lastInsertId."/");
195 195
 		}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		# execute update
219 219
 		if(!$this->Sections->modify_section ("edit", $values))
220 220
 														{ $this->Response->throw_exception(500, "Section update failed"); }
221
-		else {
221
+														else {
222 222
 			//set result
223 223
 			return array("code"=>200, "data"=>NULL);
224 224
 		}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		# execute update
248 248
 		if(!$this->Sections->modify_section ("delete", $values))
249 249
 														{ $this->Response->throw_exception(500, "Section delete failed"); }
250
-		else {
250
+														else {
251 251
 			//set result
252 252
 			return array("code"=>200, "data"=>NULL);
253 253
 		}
Please login to merge, or discard this patch.
api/controllers/Common.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -244,10 +244,12 @@
 block discarded – undo
244 244
 						$result->links[$m] = new stdClass ();
245 245
 						$result->links[$m]->rel  	= $link;
246 246
 						// self ?
247
-						if ($link=="self")
248
-						$result->links[$m]->href 	= "/api/".$this->_params->app_id."/$controller/".$result->id."/";
249
-						else
250
-						$result->links[$m]->href 	= "/api/".$this->_params->app_id."/$controller/".$result->id."/$link/";
247
+						if ($link=="self") {
248
+												$result->links[$m]->href 	= "/api/".$this->_params->app_id."/$controller/".$result->id."/";
249
+						}
250
+						else {
251
+												$result->links[$m]->href 	= "/api/".$this->_params->app_id."/$controller/".$result->id."/$link/";
252
+						}
251 253
 						$result->links[$m]->methods = $method;
252 254
 						// next
253 255
 						$m++;
Please login to merge, or discard this patch.
api/controllers/Vrfs.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		# execute update
164 164
 		if(!$this->Admin->object_modify ("vrf", "add", "vrfId", $values))
165 165
 													{ $this->Response->throw_exception(500, "VRF creation failed"); }
166
-		else {
166
+													else {
167 167
 			//set result
168 168
 			return array("code"=>201, "data"=>"VRF created", "location"=>"/api/".$this->_params->app_id."/vrfs/".$this->Admin->lastId."/");
169 169
 		}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		# execute update
196 196
 		if(!$this->Admin->object_modify ("vrf", "edit", "vrfId", $values))
197 197
 													{ $this->Response->throw_exception(500, "Vrf edit failed"); }
198
-		else {
198
+													else {
199 199
 			//set result
200 200
 			return array("code"=>200, "data"=>"VRF updated");
201 201
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		# execute delete
223 223
 		if(!$this->Admin->object_modify ("vrf", "delete", "vrfId", $values))
224 224
 													{ $this->Response->throw_exception(500, "Vrf delete failed"); }
225
-		else {
225
+													else {
226 226
 			// delete all references
227 227
 			$this->Admin->remove_object_references ("subnets", "vrfId", $this->_params->id);
228 228
 
Please login to merge, or discard this patch.
api/controllers/Subnets.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			# execute update
249 249
 			if(!$this->Subnets->modify_subnet ("edit", $values))
250 250
 														{ $this->Response->throw_exception(500, 'Subnet update failed'); }
251
-			else {
251
+														else {
252 252
 				return array("code"=>200, "data"=>"Subnet updated");
253 253
 			}
254 254
 		}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 			# execute update
289 289
 			if(!$this->Subnets->modify_subnet ("delete", $values))
290 290
 														{ $this->Response->throw_exception(500, "Failed to delete subnet"); }
291
-			else {
291
+														else {
292 292
 				//set result
293 293
 				return array("code"=>200, "data"=>"Subnet deleted");
294 294
 			}
@@ -413,7 +413,8 @@  discard block
 block discarded – undo
413 413
 		# fetch all addresses and calculate usage
414 414
 		if($slaves) {
415 415
 			$addresses = $this->Addresses->fetch_subnet_addresses_recursive ($this->_params->id, false);
416
-		} else {
416
+		}
417
+		else {
417 418
 			$addresses = $this->Addresses->fetch_subnet_addresses ($this->_params->id);
418 419
 		}
419 420
 		// calculate
@@ -726,7 +727,7 @@  discard block
 block discarded – undo
726 727
 		$this->settings = $this->Tools->fetch_object ("settings", "id", 1);
727 728
 
728 729
 		# get master subnet details for folder overrides
729
-		if($this->_params->masterSubnetId!=0)	{
730
+		if($this->_params->masterSubnetId!=0) {
730 731
 			$master_section = $this->Subnets->fetch_subnet(null, $this->_params->masterSubnetId);
731 732
 			if($master_section->isFolder==1)	{ $parent_is_folder = true; }
732 733
 			else								{ $parent_is_folder = false; }
Please login to merge, or discard this patch.
api/controllers/Tools.php 1 patch
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		# execute update
269 269
 		if(!$this->Admin->object_modify ($this->_params->id, "add", "", $values))
270 270
 													{ $this->Response->throw_exception(500, $this->_params->id." object creation failed"); }
271
-		else {
271
+													else {
272 272
 			//set result
273 273
 			return array("code"=>201, "data"=>$this->_params->id." object created", "location"=>"/api/".$this->_params->app_id."/tools/".$this->_params->id."/".$this->Admin->lastId."/");
274 274
 		}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		# execute update
326 326
 		if(!$this->Admin->object_modify ($table_name, "edit",  $this->sort_key, $values))
327 327
 													{ $this->Response->throw_exception(500, $table_name." object edit failed"); }
328
-		else {
328
+													else {
329 329
 			//set result
330 330
 			return array("code"=>200, "data"=>$table_name." object updated");
331 331
 		}
@@ -355,14 +355,15 @@  discard block
 block discarded – undo
355 355
 		# execute delete
356 356
 		if(!$this->Admin->object_modify ($this->_params->id, "delete",  $this->sort_key, $values))
357 357
 													{ $this->Response->throw_exception(500, $this->_params->id." object delete failed"); }
358
-		else {
358
+													else {
359 359
 			// set update field
360 360
 			if ($this->_params->id == "devices")	{ $update_field = "switch"; }
361 361
 			elseif ($this->_params->id == "ipTags")	{ $update_field = "state"; }
362 362
 
363 363
 			// delete all references
364
-			if (isset($update_field))
365
-			$this->Admin->remove_object_references ("ipaddresses", $update_field, $this->_params->id2);
364
+			if (isset($update_field)) {
365
+						$this->Admin->remove_object_references ("ipaddresses", $update_field, $this->_params->id2);
366
+			}
366 367
 
367 368
 			// set result
368 369
 			return array("code"=>200, "data"=>$this->_params->id." object deleted");
@@ -388,8 +389,10 @@  discard block
 block discarded – undo
388 389
 	 */
389 390
 	private function validate_subcontroller () {
390 391
 		// not options
391
-		if($this->_params->controller !== "options")
392
-		if (!in_array($this->_params->id, @$this->subcontrollers))			{ $this->Response->throw_exception(400, "Invalid subcontroller"); }
392
+		if($this->_params->controller !== "options") {
393
+				if (!in_array($this->_params->id, @$this->subcontrollers))			{ $this->Response->throw_exception(400, "Invalid subcontroller");
394
+		}
395
+		}
393 396
 	}
394 397
 
395 398
 	/**
Please login to merge, or discard this patch.
api/index.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,21 +89,23 @@  discard block
 block discarded – undo
89 89
 
90 90
 
91 91
 	// append POST parameters if POST or PATCH
92
-	if($_SERVER['REQUEST_METHOD']=="POST" || $_SERVER['REQUEST_METHOD']=="PATCH"){
92
+	if($_SERVER['REQUEST_METHOD']=="POST" || $_SERVER['REQUEST_METHOD']=="PATCH") {
93 93
 		// if application tupe is JSON (application/json)
94
-        if($_SERVER['CONTENT_TYPE']=="application/json"){
94
+        if($_SERVER['CONTENT_TYPE']=="application/json") {
95 95
                 $rawPostData = file_get_contents('php://input');
96 96
                 $json = json_decode($rawPostData,true);
97
-                if(is_array($json))
98
-                $params = array_merge((array) $params, $json);
97
+                if(is_array($json)) {
98
+                                $params = array_merge((array) $params, $json);
99
+                }
99 100
                 $params = (object) $params;
100 101
         }
101 102
 		// if application tupe is XML (application/json)
102
-        elseif($_SERVER['CONTENT_TYPE']=="application/xml"){
103
+        elseif($_SERVER['CONTENT_TYPE']=="application/xml") {
103 104
                 $rawPostData = file_get_contents('php://input');
104 105
                 $xml = $Response->xml_to_array($rawPostData);
105
-                if(is_array($xml))
106
-                $params = array_merge((array) $params, $xml);
106
+                if(is_array($xml)) {
107
+                                $params = array_merge((array) $params, $xml);
108
+                }
107 109
                 $params = (object) $params;
108 110
         }
109 111
 		//if application type is default (application/x-www-form-urlencoded)
@@ -157,7 +159,8 @@  discard block
 block discarded – undo
157 159
 	//check if the controller exists. if not, throw an exception
158 160
 	if( file_exists( dirname(__FILE__) . "/controllers/$controller_file.php") ) {
159 161
 		require( dirname(__FILE__) . "/controllers/$controller_file.php");
160
-	} else {
162
+	}
163
+	else {
161 164
 		$Response->throw_exception(400, 'invalid controller');
162 165
 	}
163 166
 
Please login to merge, or discard this patch.