external_path = $this->config->item('external_data_path'); $this->load->helper(array('form', 'url')); $this->load->model('PD_Model'); $this->load->library('asynclibrary'); $this->load->library('AWS_REKONITION'); $this->load->helper('MYUTIL'); } /** * @desc : Function to perform multiple task in background * @param :void * @return : void */ public function ind_get(){ //echo base_url(); print_r(getallheaders()); $url = base_url()."test/sendmail"; $urls = base_url()."test/insert"; $param = array('email' => "jagroop@gmail.com" ); $param1 = array('name' => "Jagroop Singh", 'email' => "jagroop@gmail.com" ); // $async1 = $this->asynclibrary->do_in_background($url, $param); // $async2 = $this->asynclibrary->do_in_background($urls, $param1); // print_r($async1); // print_r($async2); } /** * @desc : Function to send mail * @param :void * @return : void */ public function sendmail_post(){ // $this->load->library('email'); $user_email = $_POST['email']; // $message = "Testing"; // $this->email->from('wolfy@gmail.com', 'Wolfy Singh'); // $this->email->to($user_email); // $this->email->subject("test"); // $this->email->message($message); // $this->email->send(); $id = $this->db->insert('t_city_master',array('city_name'=> $user_email)); // echo $user_email; // print_r($id); } /** * @desc : Function to call insert() method * of test_model to insert data in database * @param :void * @return : void */ public function insert_post(){ $user_email = $_POST['name']; $this->db->insert('t_city_master',array('city_name'=>$user_email)); // $email = $this->input->post('email'); // $name = $this->input->post('name'); // $this->test_model->insert($email, $name); //echo "insert"; } public function compareFaces_post() { $pdid = $this->post('pdid'); $src = $this->post('src'); $dest = $this->post('dest'); $src_url_type = $this->post('src_url_type'); $dest_url_type = $this->post('dest_url_type'); $res_data = array('nxt_action' => null); // echo $src;die(); if($src_url_type == 'base64')//make local img { //src base64 should be w/o the mime header part - data:image/png;base64, $src_local_file = APPPATH.'docs/'.MYUTIL::getRandomString(10).'-'.date('Y-m-d-H-i-s').'.png'; $ifp = fopen( $src_local_file, 'wb' ); //$data = explode( ',', $src ); fwrite( $ifp, base64_decode( $src ) ); fclose( $ifp ); $src = $src_local_file; } if($dest_url_type == 'base64')//make local img { $dest_local_file = APPPATH.'docs/'.MYUTIL::getRandomString(10).'-'.date('Y-m-d-H-i-s').'.png'; $ifp = fopen( $dest_local_file, 'wb' ); //$data = explode( ',', $src ); fwrite( $ifp, base64_decode( $dest ) ); fclose( $ifp ); $dest = $dest_local_file; } //check no of faces in src img $no_of_faces_in_src_img = $this->aws_rekonition->detectFaces($src); if(is_object($no_of_faces_in_src_img) && isset($no_of_faces_in_src_img['FaceDetails']) && count($no_of_faces_in_src_img['FaceDetails']) > 1) { foreach($no_of_faces_in_src_img as $k => $v) { $res_data[$k] = $v; // echo '***********************'; } $res_data['nxt_action'] = 'pick_src_img'; //if no faces more than two then return all face details to //front end and let user pick the src img $this->response($res_data,REST_Controller::HTTP_OK); } $compare_analysis_data = $this->aws_rekonition->comparePhotos($src,$dest); if(is_object($compare_analysis_data)) { foreach($compare_analysis_data as $k => $v) { $res_data[$k] = $v; // echo '***********************'; } } //update face api result in main table $where_condition_array = array('pd_id' => $pdid); $this->PD_Model->updateRecords(['faceapi_result' => json_encode($res_data)],PDTRIGGER,$where_condition_array); //delete local files if created if($dest_url_type == 'base64') { unlink($dest); } if($src_url_type == 'base64') { unlink($src); } $this->response($res_data,REST_Controller::HTTP_OK); } function handleGoolgeVideoFile($file,$pd_details) { $file_content = $this->googleapi->downloadDriveFile($file['id']); if($file_content) { //store locally $is_downloaded = file_put_contents($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4',$file_content); $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; // $bucketname = LENDER_BUCKET_NAME_PREFIX.'1'; $key = 'pd'.$pd_details[0]['pd_id'].'/video/'.$file['id'].'.mp4'; $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4')); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $record_data = array('fk_pd_id' => $pd_details[0]['pd_id'],'composition_id' => $file['id'].'.mp4','is_call_ended' => 1,'twilo_status'=>'completed','s3_copied' => 1,'vsp' => 'google'); $this->PD_Model->saveRecords($record_data,VIDEO_ROOM_INFO); //echo 'done'; unlink($this->external_path.'/pd_reports/'.$pd_details[0]['pd_id'].'/'.$file['id'].'.mp4'); $file_content = $this->googleapi->deleteDriveFile($file['id']); } } } function updateGoogleVideoStatus_get() { $this->load->library('Googleapi'); $pdid = $this->get('pdid'); $pd_details = $this->PD_Model->getPDMasterDetails($pdid); if(($pd_details[0]['fk_pd_type'] == 2 || $pd_details[0]['fk_pd_type'] == 3) && $pd_details[0]['gmeet_code'] != "") { $driveFilesList = $this->googleapi->getDriveFilesList($pd_details[0]['gmeet_code']); if(count($driveFilesList)) { log_message('ERROR','###Videos Found'.count($driveFilesList).' - PDID - '. $pdid); foreach ($driveFilesList as $key => $file) { $this->handleGoolgeVideoFile($file,$pd_details); } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; // $data['msg'] = 'Officers Records Not Found!'; $this->response($data,REST_Controller::HTTP_OK); } else { log_message('ERROR','###Videos not found/not available in drive yet Found'.count($driveFilesList).' - PDID - '. $pdid); $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_NO_CONTENT; // $data['msg'] = 'Officers Records Not Found!'; $this->response($data,REST_Controller::HTTP_OK); } } } }