Code Duplication    Length = 10-10 lines in 3 locations

web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php 3 locations

@@ 814-823 (lines=10) @@
811
		$query = $this->db_model->getSelect("*", "sip_profiles", $where);
812
		$query = $query->result_array();
813
		$gateway_result = array();
814
		foreach ($query as $key => $query_value) {
815
			foreach ($query_value as $gateway_key => $gatewau_val) {
816
				if ($gateway_key != "profile_data") {
817
					$gateway_data[$gateway_key] = $gatewau_val;
818
				} else {
819
					$tmp = (array) json_decode($gatewau_val);
820
					$gateway_result = array_merge($gateway_data, $tmp);
821
				}
822
			}
823
		}
824
		$data['grid_fields'] = $this->freeswitch_form->build_fssipprofile_params_list_for_admin();
825
		$data['edited_id'] = $edit_id;
826
		$data['sip_name']=$query[0]['name'];
@@ 873-882 (lines=10) @@
870
		$query = $this->db_model->getSelect("*", "sip_profiles", $where);
871
		$query = $query->result_array();
872
		$gateway_result = array();
873
		foreach ($query as $key => $query_value) {
874
			foreach ($query_value as $gateway_key => $gatewau_val) {
875
				if ($gateway_key != "profile_data") {
876
					$gateway_data[$gateway_key] = $gatewau_val;
877
				} else {
878
					$tmp = (array) json_decode($gatewau_val);
879
					$gateway_result = array_merge($gateway_data, $tmp);
880
				}
881
			}
882
		}
883
		$tmp[$sipprofile_data['params_name']]=$sipprofile_data['params_value'];
884
	$final_data= json_encode($tmp);
885
	$insert_arr["profile_data"] = json_encode($tmp);
@@ 895-904 (lines=10) @@
892
		$query = $this->db_model->getSelect("*", "sip_profiles", $where);
893
		$query = $query->result_array();
894
		$gateway_result = array();
895
		foreach ($query as $key => $query_value) {
896
			foreach ($query_value as $gateway_key => $gatewau_val) {
897
				if ($gateway_key != "profile_data") {
898
					$gateway_data[$gateway_key] = $gatewau_val;
899
				} else {
900
					$tmp = (array) json_decode($gatewau_val);
901
					$gateway_result = array_merge($gateway_data, $tmp);
902
				}
903
			}
904
		}
905
	if(isset($tmp[$name])){
906
	  unset($tmp[$name]);
907
	}