Code Duplication    Length = 39-39 lines in 2 locations

web_interface/astpp/application/modules/opensips/controllers/opensips.php 1 location

@@ 80-118 (lines=39) @@
77
78
		$this->load->view('view_opensips_add_edit', $data);
79
	}
80
	function opensips_save() {
81
		$add_array = $this->input->post();
82
		$data['form'] = $this->form->build_form($this->opensips_form->get_opensips_form_fields($add_array['id']), $add_array);
83
		if ($add_array['id'] != '') {
84
			$data['page_title'] = 'Edit Opensips';
85
			if ($this->form_validation->run() == FALSE) {
86
				$data['validation_errors'] = validation_errors();
87
				echo $data['validation_errors'];
88
				exit;
89
			} else {
90
				$auth_flag = $this->validate_device_data($add_array);
91
				if($auth_flag == "TRUE"){
92
						$this->opensips_model->edit_opensipsdevices($add_array, $add_array['id']);
93
						echo json_encode(array("SUCCESS"=> " OpenSips updated successfully!"));
94
						exit;
95
				}else{
96
					   echo json_encode($auth_flag);
97
					   exit;
98
				}
99
			}
100
		} else {
101
			$data['page_title'] = 'Add Opensips';
102
			if ($this->form_validation->run() == FALSE) {
103
				$data['validation_errors'] = validation_errors();
104
				echo $data['validation_errors'];
105
				exit;
106
			} else {
107
				$auth_flag = $this->validate_device_data($add_array);
108
				if($auth_flag == "TRUE"){
109
						$this->opensips_model->add_opensipsdevices($add_array);
110
						echo json_encode(array("SUCCESS"=> "OpenSips added successfully!"));
111
						exit;
112
				}else{
113
					   echo json_encode($auth_flag);
114
						exit;
115
				}
116
			}
117
		}
118
	}
119
	function validate_device_data($data){
120
121
		if(isset($data["username"]) && $data["username"] != ""){

web_interface/astpp/application/modules/user/controllers/user.php 1 location

@@ 1713-1751 (lines=39) @@
1710
    
1711
	}
1712
    
1713
	function user_opensips_save(){
1714
	$add_array = $this->input->post();
1715
		$data['form'] = $this->form->build_form($this->user_form->build_user_opensips_form(), $add_array);
1716
		if ($add_array['id'] != '') {
1717
			$data['page_title'] = 'Edit Opensips';
1718
			if ($this->form_validation->run() == FALSE) {
1719
				$data['validation_errors'] = validation_errors();
1720
				echo $data['validation_errors'];
1721
				exit;
1722
			} else {
1723
				$auth_flag = $this->validate_device_data($add_array);
1724
				if($auth_flag == "TRUE"){
1725
						$this->user_model->user_opensips_edit($add_array, $add_array['id']);
1726
						echo json_encode(array("SUCCESS"=> " OpenSips updated successfully!"));
1727
						exit;
1728
				}else{
1729
					   echo json_encode($auth_flag);
1730
					   exit;
1731
				}
1732
			}
1733
		} else {
1734
			$data['page_title'] = 'Add Opensips';
1735
			if ($this->form_validation->run() == FALSE) {
1736
				$data['validation_errors'] = validation_errors();
1737
				echo $data['validation_errors'];
1738
				exit;
1739
			} else {
1740
				$auth_flag = $this->validate_device_data($add_array);
1741
				if($auth_flag == "TRUE"){
1742
						$this->user_model->user_opensips_add($add_array);
1743
						echo json_encode(array("SUCCESS"=> "OpenSips added successfully!"));
1744
						exit;
1745
				}else{
1746
					   echo json_encode($auth_flag);
1747
						exit;
1748
				}
1749
			}
1750
		}
1751
	}
1752
	function validate_device_data($data){
1753
		if(isset($data["username"]) && $data["username"] != ""){
1754
				$db_config = Common_model::$global_config['system_config'];