diff --git a/application/controllers/api.php b/application/controllers/api.php index ce6f2be..11524e4 100644 --- a/application/controllers/api.php +++ b/application/controllers/api.php @@ -1991,8 +1991,7 @@ public function saverecordsweb() { // this code is used for sending record to other domain if ($post_url) { - if ($form_id == '4575' && - strpos($_SERVER ['SERVER_NAME'], 'dataplug.itu') !== false) { + if ($form_id == '4575' && strpos($_SERVER ['SERVER_NAME'], 'dataplug.itu') !== false) { $tempary = array( 'imei_no' => $imei_no, 'image_url' => $add_images ['image'], @@ -2070,8 +2069,7 @@ public function getUcName($location) { $lat = trim($loc [0]); $long = trim($loc [1]); - $url = "http://ucfinder.herokuapp.com/" - $url .= "ajax/region_finder.json?lat=$lat&long=$long"; + $url = "http://ucfinder.herokuapp.com/ajax/region_finder.json?lat=$lat&long=$long"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -2098,8 +2096,7 @@ public function getTownName($location = null) { $loc = explode(',', $location); $lat = trim($loc [0]); $long = trim($loc [1]); - $url = "http://ucfinder.herokuapp.com/" - $url .= "ajax/town_finder.json?lat=$lat&long=$long"; + $url = "http://ucfinder.herokuapp.com/ajax/town_finder.json?lat=$lat&long=$long"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -2126,8 +2123,7 @@ public function getDistrictName($location = null) { $loc = explode(',', $location); $lat = trim($loc [0]); $long = trim($loc [1]); - $url = "http://ucfinder.herokuapp.com/"; - $url .= "ajax/distict_finder.json?lat=$lat&long=$long"; + $url = "http://ucfinder.herokuapp.com/ajax/distict_finder.json?lat=$lat&long=$long"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -2169,8 +2165,7 @@ public function getOptions() { public function getoptionapi() { $api = $this->input->get('api'); $secret = $this->input->get('secret'); - $query = $this->db->query("SELECT * FROM api WHERE id = - '$api' AND secret_key='$secret'"); + $query = $this->db->query("SELECT * FROM api WHERE id = '$api' AND secret_key='$secret'"); $api_data = $query->row_array(); if ($api_data) { $csv_file_name = $api_data ['file_name']; @@ -2199,17 +2194,14 @@ public function getoptionapi() { if (!isset($existArray [$parent_optional_name])) { $existArray [$parent_optional_name] = array(); } - if (!in_array(strtolower(trim($data [$child_index])), - $existArray [$parent_optional_name])) { - array_push($existArray [$parent_optional_name], - strtolower(trim($data [$child_index]))); + if (!in_array(strtolower(trim($data [$child_index])), $existArray [$parent_optional_name])) { + array_push($existArray [$parent_optional_name], strtolower(trim($data [$child_index]))); $option_parent_value = ''; if ($parent_name != '') { $option_parent_value = trim($data [$parent_index]); } $option_display_value = $option_value = trim($data [$child_index]); - if(isset($heading_row[$child_index+1]) && - $heading_row[$child_index+1]=='display_value_'.$heading_row[$child_index]){ + if(isset($heading_row[$child_index+1]) && $heading_row[$child_index+1]=='display_value_'.$heading_row[$child_index]){ $option_display_value = trim($data[$child_index+1]); } $record = array( @@ -2248,8 +2240,7 @@ function cmpBySort($a, $b) { // URL : http://www.dataplug.itu.edu.pk/api/syncDataRemotely?app_id=1293&security_token=1ae473a61dbe13cb9ec199e9c2361956&last_date_stamp= public function syncDataRemotely() { - if (isset($_REQUEST ['app_id']) && isset($_REQUEST ['last_date_stamp']) - && isset($_REQUEST ['security_token'])) { + if (isset($_REQUEST ['app_id']) && isset($_REQUEST ['last_date_stamp']) && isset($_REQUEST ['security_token'])) { $app_id = $_REQUEST ['app_id']; $last_date_stamp = $_REQUEST ['last_date_stamp']; $security_token = $_REQUEST ['security_token']; // 1ae473a61dbe13cb9ec199e9c2361956 @@ -2300,8 +2291,7 @@ public function syncDataRemotely() { */ public function importDataFormBased() { - if (isset($_REQUEST ['local_form_id']) - && isset($_REQUEST ['remote_form_id'])) { + if (isset($_REQUEST ['local_form_id']) && isset($_REQUEST ['remote_form_id'])) { $local_form_id = $_REQUEST ['local_form_id']; $table_name = 'zform_' . $local_form_id; $remote_form_id = $_REQUEST ['remote_form_id']; @@ -2312,8 +2302,7 @@ public function importDataFormBased() { $last_id = 0; } - $url = "http://godk.itu.edu.pk/api/exportDataFormBased?"; - $url .= "form_id=$remote_form_id&last_id=$last_id"; + $url = "http://godk.itu.edu.pk/api/exportDataFormBased?form_id=$remote_form_id&last_id=$last_id"; $ch = curl_init() or die("Cannot init"); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -2322,8 +2311,8 @@ public function importDataFormBased() { $table_headers_array = array( 'created_datetime' ); - - $schema_list = $this->form_results_model->getTableHeadingsFromSchema($table_name); + $temp_tb=$table_name; + $schema_list = $this->form_results_model->getTableHeadingsFromSchema($temp_tb); foreach ($schema_list as $key => $value) { $header_value = $value ['COLUMN_NAME']; if ($header_value != 'created_datetime') { @@ -2382,10 +2371,12 @@ public function importDataFormBased() { //for hospital watch app public function hospitalwatchapi() { - //if (isset($_REQUEST['app_id']) && isset($_REQUEST['last_date_stamp']) && isset($_REQUEST['security_token'])) { + //if (isset($_REQUEST['app_id']) && isset($_REQUEST['last_date_stamp']) + // && isset($_REQUEST['security_token'])) { if (isset($_REQUEST['app_id'])) { $app_id = $_REQUEST['app_id']; - $last_date_stamp = isset($_REQUEST['last_date_stamp']) ? $_REQUEST['last_date_stamp'] : ''; + $temp_date=$_REQUEST['last_date_stamp']; + $last_date_stamp = isset($temp_date) ? $temp_date : ''; $start_date_stamp = isset($_REQUEST['start_date_stamp']) ? $_REQUEST['start_date_stamp'] : ''; $selected_app = $this->app_model->get_app($app_id); @@ -2399,9 +2390,12 @@ public function hospitalwatchapi() { $results_count = 0; $all_forms = $this->form_model->get_form_by_app($app_id); foreach ($all_forms as $forms) { - $forms_list[] = array('form_id' => $forms['form_id'], 'form_name' => $forms['form_name']); + $forms_list[] = array('form_id' => $forms['form_id'], + 'form_name' => $forms['form_name']); /** in case of post of form filters * */ - $results = $this->form_results_model->syncDataFromRemoteServer($forms['form_id'], $last_date_stamp, $start_date_stamp); + $temp_id=$forms['form_id'] + $results = $this->form_results_model->syncDataFromRemoteServer($temp_id, + $last_date_stamp, $start_date_stamp); $results_count += count($results); $final_result = array_merge($final_result, $results); } @@ -2440,7 +2434,8 @@ public function sendToRemoteServer() { if (isset($_REQUEST ['app_id']) && isset($_REQUEST ['security_token'])) { $app_id = $_REQUEST ['app_id']; $from_date_stamp = ""; - if(isset($_REQUEST ['from_date_stamp']) && !empty($_REQUEST ['from_date_stamp'])){ + $temp_stamp=$_REQUEST ['from_date_stamp']; + if(isset($temp_stamp) && !empty($temp_stamp)){ $pos = strpos($_REQUEST ['from_date_stamp'], ':'); $from_date_stamp = $_REQUEST ['from_date_stamp']; if ($pos === false) { @@ -2456,10 +2451,13 @@ public function sendToRemoteServer() { } } - // $from_date_stamp = isset($_REQUEST ['from_date_stamp']) ? $_REQUEST ['from_date_stamp'] : ''; - // $to_date_stamp = isset($_REQUEST ['to_date_stamp']) ? $_REQUEST ['to_date_stamp'] : ''; + // $from_date_stamp = isset($_REQUEST ['from_date_stamp']) ? + // $_REQUEST ['from_date_stamp'] : ''; + // $to_date_stamp = isset($_REQUEST ['to_date_stamp']) ? + // $_REQUEST ['to_date_stamp'] : ''; $imei_no = isset($_REQUEST ['imei_no']) ? $_REQUEST ['imei_no'] : null; - $security_token = $_REQUEST ['security_token']; // 954223eaaec107c5d7965978c9665e64 + $security_token = $_REQUEST ['security_token']; + //954223eaaec107c5d7965978c9665e64 $selected_app = $this->app_model->get_app($app_id); $app_name = $selected_app ['name']; @@ -2468,7 +2466,9 @@ public function sendToRemoteServer() { $final_result = array(); $results_count = 0; if( isset($_REQUEST ['form_id']) && !empty($_REQUEST ['form_id']) ){ - $results = $this->form_results_model->syncDataFromRemoteServer($_REQUEST ['form_id'], $from_date_stamp, $to_date_stamp,$imei_no); + $temp_req=$_REQUEST ['form_id']; + $results = $this->form_results_model->syncDataFromRemoteServer($temp_req, + $from_date_stamp, $to_date_stamp,$imei_no); $results_count += count($results); foreach ($results as $rec) { $rec ['images'] = array(); @@ -2521,7 +2521,9 @@ public function sendToRemoteServer() { 'form_id' => $forms ['form_id'], 'form_name' => $forms ['form_name'] ); - $results = $this->form_results_model->syncDataFromRemoteServer($forms ['form_id'], $from_date_stamp, $to_date_stamp,$imei_no); + $temp_form=$forms ['form_id']; + $results = $this->form_results_model->syncDataFromRemoteServer($temp_form, + $from_date_stamp, $to_date_stamp,$imei_no); $results_count += count($results); foreach ($results as $rec) { $rec['images'] = array(); @@ -2586,19 +2588,24 @@ public function sendToRemoteServer() { } public function update_application_general_settings() { - $query = $this->db->query("select * from app_settings LEFT JOIN app ON (app.id=app_settings.app_id)"); + $query = $this->db->query("select * from app_settings + LEFT JOIN app ON (app.id=app_settings.app_id)"); $result = $query->result_array(); foreach ($result as $key => $val) { $general_settings = array(); echo $app_id = $val ["app_id"]; echo " "; - echo $is_secured = (isset($val ['is_secure']) && $val ['is_secure'] == 'yes') ? 1 : 0; + $temp_secure=$val ['is_secure']; + echo $is_secured = (isset($temp_secure) && $temp_secure == 'yes') ? 1 : 0; echo " - "; - echo $is_authorized = (isset($val ['is_authorized']) && $val ['is_authorized'] == '1') ? 1 : 0; + $temp_auth=$val ['is_authorized'] + echo $is_authorized = (isset($temp_auth) && $temp_auth == '1') ? 1 : 0; echo " -> "; - $screen_view = (isset($val ['default_view_builder'])) ? $val ['default_view_builder'] : 4; - $app_language = (isset($val ['app_language'])) ? $val ['app_language'] : "english"; + $temp=$val ['default_view_builder']; + $screen_view = (isset($temp)) ? $temp : 4; + $temp2=$val ['app_language']; + $app_language = (isset($temp2)) ? $temp2 : "english"; $general_settings ['setting_type'] = "general_settings"; $general_settings ['secured_apk'] = $is_secured; @@ -2637,7 +2644,8 @@ public function update_application_list_view_settings() { 'setting_type' => 'RESULT_VIEW_SETTINGS', 'filters' => $json_string ); - $app_exist = $this->db->query("select * from app_settings where app_id=$app_id AND setting_type='RESULT_VIEW_SETTINGS'"); + $app_exist = $this->db->query("select * from app_settings where + app_id=$app_id AND setting_type='RESULT_VIEW_SETTINGS'"); $app_exist1 = $app_exist->result_array(); if (!empty($app_exist1)) { $this->db->set("filters", $json_string); @@ -2676,7 +2684,8 @@ public function update_application_map_view_settings() { 'setting_type' => 'MAP_VIEW_SETTINGS', 'filters' => $json_string ); - $app_exist = $this->db->query("select * from app_settings where app_id=$app_id AND setting_type='MAP_VIEW_SETTINGS'"); + $app_exist = $this->db->query("select * from app_settings where + app_id=$app_id AND setting_type='MAP_VIEW_SETTINGS'"); $app_exist1 = $app_exist->result_array(); if (!empty($app_exist1)) { $this->db->set("filters", $json_string); @@ -2710,7 +2719,8 @@ public function update_application_graph_view_settings() { 'setting_type' => 'GRAPH_VIEW_SETTINGS', 'filters' => $json_string ); - $app_exist = $this->db->query("select * from app_settings where app_id=$app_id AND setting_type='GRAPH_VIEW_SETTINGS'"); + $app_exist = $this->db->query("select * from app_settings where + app_id=$app_id AND setting_type='GRAPH_VIEW_SETTINGS'"); $app_exist1 = $app_exist->result_array(); if (!empty($app_exist1)) { $this->db->set("filters", $json_string); @@ -2769,7 +2779,8 @@ function remove_security_key($slug){ $rec_id = $fv['id']; foreach($fv as $key =>$v){ if(strpos($v, $form_info['security_key']) !== FALSE){ - $vdcode = urldecode(base64_decode(str_replace($form_info['security_key'], '', $v))); + $vdcode = urldecode(base64_decode(str_replace($form_info['security_key'], + '', $v))); $up_array[$key] = $vdcode; } else{ @@ -2787,7 +2798,8 @@ function remove_security_key($slug){ } /** - * This function is used for saving the record which sent from android application + * This function is used for saving the record which + * sent from android application * * @return json * @author Zahid Nadeem @@ -2828,7 +2840,8 @@ public function savetracking() { 'data_type' => 'single' ); - $tracking_inserted_id = $this->form_results_model->save_mobile_tracking($tracking_temp); + $tracking_inserted_id = $this->form_results_model->save_mobile_tracking( + $tracking_temp); @@ -2859,17 +2872,20 @@ public function savetracking() { if(!$ret_ins){ $err_msg = $this->db->_error_message(); - $this->form_results_model->update_mobile_tracking($tracking_inserted_id,array('error'=>$err_msg)); + $this->form_results_model->update_mobile_tracking($tracking_inserted_id, + array('error'=>$err_msg)); echo $jsone_array = array ( 'error' => $err_msg ); } - //$this->form_results_model->remove_mobile_tracking($tracking_inserted_id,array('error'=>$err_msg)); + //$this->form_results_model->remove_mobile_tracking($tracking_inserted_id, + // array('error'=>$err_msg)); exit(); } /** - * This function is used for saving the record which sent from android application + * This function is used for saving the record which + * sent from android application * * @return json * @author Zahid Nadeem @@ -2889,7 +2905,8 @@ public function savetrackingbulk() { 'data_type' => 'bulk' ); - $tracking_inserted_id = $this->form_results_model->save_mobile_tracking($tracking_temp); + $tracking_inserted_id = $this->form_results_model->save_mobile_tracking( + $tracking_temp); header("Content-Length: 1"); header("HTTP/1.1 200 OK"); @@ -2934,7 +2951,8 @@ public function savetrackingbulk() { if(!$ret_ins){ $err_msg = $this->db->_error_message(); - $this->form_results_model->update_mobile_tracking($tracking_inserted_id,array('error'=>$err_msg)); + $this->form_results_model->update_mobile_tracking($tracking_inserted_id, + array('error'=>$err_msg)); echo $jsone_array = array ( 'error' => $err_msg @@ -2944,7 +2962,8 @@ public function savetrackingbulk() { } - //$this->form_results_model->remove_mobile_tracking($tracking_inserted_id,array('error'=>$err_msg)); + //$this->form_results_model->remove_mobile_tracking($tracking_inserted_id, + // array('error'=>$err_msg)); exit(); } /** @@ -2975,7 +2994,8 @@ public function editAppUser() { if($type == 'update') { $old_imei_no = $this->input->post('old_imei_no'); - $query = $this->db->query("SELECT * FROM app_users WHERE is_deleted=0 AND app_id = '$app_id' AND imei_no='$old_imei_no'"); + $query = $this->db->query("SELECT * FROM app_users WHERE + is_deleted=0 AND app_id = '$app_id' AND imei_no='$old_imei_no'"); $current_rec = $query->row_array(); $app_user_id = $current_rec['id']; diff --git a/application/controllers/apimaker.php b/application/controllers/apimaker.php index c9ed413..bc8f56f 100644 --- a/application/controllers/apimaker.php +++ b/application/controllers/apimaker.php @@ -13,13 +13,15 @@ public function __construct() { $this->load->model('api_model'); $this->load->model('department_model'); // if (!$this->acl->hasSuperAdmin()) { - // if($this->acl->hasPermission('complaint','Access only complaint module')){ + // if($this->acl->hasPermission('complaint', + // 'Access only complaint module')){ // redirect(base_url() . 'complaintSystem'); // } // } $sess_ar = $this->session->userdata('logged_in'); if ($sess_ar['login_verification_code']!= '') { - $this->session->set_flashdata('validate', array('message' => 'Limited time access , Your account not verified yet, please check your email and verify otherwise account will delete after 30 days.', 'type' => 'warning')); + $this->session->set_flashdata('validate', + array('message' => 'Limited time access , Your account not verified yet, please check your email and verify otherwise account will delete after 30 days.', 'type' => 'warning')); } } @@ -40,7 +42,7 @@ public function __construct() { * @see http://codeigniter.com/user_guide/general/urls.html */ public function index() { -// this method was calling again and again by list so applied logic here +//this method was calling again and again by list so applied logic here if ($this->session->userdata('logged_in')) { $this->session->unset_userdata('view'); $session_data = $this->session->userdata('logged_in'); @@ -72,7 +74,7 @@ public function index() { } public function createurl($slug) { -// this method was calling again and again by list so applied logic here +//this method was calling again and again by list so applied logic here if ($this->session->userdata('logged_in')) { $this->session->unset_userdata('view'); $api_id = $slug; @@ -109,7 +111,7 @@ public function createurl($slug) { } } public function apiappurl($slug) { -// this method was calling again and again by list so applied logic here + //this method was calling again and again by list so applied logic here //exit; if ($this->session->userdata('logged_in')) { //$this->session->unset_userdata('view'); @@ -148,15 +150,18 @@ public function add() { $session_data = $this->session->userdata('logged_in'); if (!$this->acl->hasPermission('app', 'add')) { - $this->session->set_flashdata('validate', array('message' => "You don't have enough permissions to do this task.", 'type' => 'warning')); + $this->session->set_flashdata('validate', + array('message' => "You don't have enough permissions to do this task.", 'type' => 'warning')); redirect(base_url() . ''); } session_to_page($session_data, $data); $department_id = $session_data['login_department_id']; if ($this->input->post()) { - $this->form_validation->set_rules('api_title', 'Api', 'trim|required|xss_clean|callback_app_already_exist[' . $department_id . ']'); + $this->form_validation->set_rules('api_title', 'Api', + 'trim|required|xss_clean|callback_app_already_exist[' . $department_id . ']'); if ($this->form_validation->run() == FALSE) { - $this->session->set_flashdata('validate', array('message' => 'Please enter the Required Fields', 'type' => 'error')); + $this->session->set_flashdata('validate', + array('message' => 'Please enter the Required Fields', 'type' => 'error')); redirect(base_url()); } else { $rand_key = random_string('alnum', 10); @@ -177,7 +182,8 @@ public function add() { @mkdir($abs_path, 0777); umask($old); if ($_FILES['userfile_addapi']['name'] != '') { - $file_name = preg_replace("/[^A-Za-z0-9\.]/", "_",$_FILES['userfile_addapi']['name']); + $file_name = preg_replace("/[^A-Za-z0-9\.]/", + "_",$_FILES['userfile_addapi']['name']); $iconName = $api_id.'_'.$file_name; $config['upload_path'] = $abs_path; $config['file_name'] = $iconName; @@ -190,7 +196,8 @@ public function add() { if (!$this->upload->do_upload('userfile_addapi')) { $this->data['error'] = $this->upload->display_errors(); - $this->session->set_flashdata('validate', array('message' => $this->upload->display_errors() . ', Default icon has been embeded with your app.', 'type' => 'warning')); + $this->session->set_flashdata('validate', + array('message' => $this->upload->display_errors() . ', Default icon has been embeded with your app.', 'type' => 'warning')); } else { //success } @@ -201,7 +208,8 @@ public function add() { ); $this->db->where('id', $api_id); $this->db->update('api', $change_file); - $this->session->set_flashdata('validate', array('message' => 'API added successfully.', 'type' => 'success')); + $this->session->set_flashdata('validate', + array('message' => 'API added successfully.', 'type' => 'success')); redirect(base_url() . 'apimaker/index'); } @@ -262,7 +270,8 @@ public function edit($slug) { $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile_addapi')) { $this->data['error'] = $this->upload->display_errors(); - $this->session->set_flashdata('validate', array('message' => $this->upload->display_errors() . ', Default icon has been embeded with your app.', 'type' => 'warning')); + $this->session->set_flashdata('validate', + array('message' => $this->upload->display_errors() . ', Default icon has been embeded with your app.', 'type' => 'warning')); } else { unlink('./assets/data/'.$api_rec['file_name']); //success @@ -274,7 +283,8 @@ public function edit($slug) { $this->db->update('api', $change_file); } - $this->session->set_flashdata('validate', array('message' => 'API Updated successfully.', 'type' => 'success')); + $this->session->set_flashdata('validate', + array('message' => 'API Updated successfully.', 'type' => 'success')); redirect(base_url() . 'apimaker/index'); } if($department_id==0){ @@ -308,7 +318,8 @@ public function delete($slug) { $this->db->where('id', $api_id); $this->db->delete('api'); unlink('./assets/data/'.$api_rec['file_name']); - $this->session->set_flashdata('validate', array('message' => 'API deleted successfully.', 'type' => 'success')); + $this->session->set_flashdata('validate', + array('message' => 'API deleted successfully.', 'type' => 'success')); } else { //If no session, redirect to login page redirect(base_url());