Commit eb0c9bb3 by Tobin

dc

parent c56582bf
...@@ -206,10 +206,5 @@ class Booking extends CI_Controller { ...@@ -206,10 +206,5 @@ class Booking extends CI_Controller {
} }
return $reportData; return $reportData;
} }
function aaa($name=''){
$url = genQRcode($name);
echo base_url().$url;
}
} }
?> ?>
\ No newline at end of file
...@@ -170,33 +170,13 @@ class Event extends CI_Controller { ...@@ -170,33 +170,13 @@ class Event extends CI_Controller {
$insertTag[] = array('event_id'=>$event_id,'tag_id'=>$tag); $insertTag[] = array('event_id'=>$event_id,'tag_id'=>$tag);
} }
$status = $this->Event_model->createTags($insertTag); $status = $this->Event_model->createTags($insertTag);
if(isset($_FILES) && isset($_FILES['event_image']) &&
isset($_FILES['event_image']['name']) && count($_FILES['event_image']['name'])>1){
$resp = $this->eventImageUpload($event_id,$_FILES);
$evtMediaData = array(); $evtMediaData = (isset($resp['evtMediaData']))?$resp['evtMediaData']:array();
if(!empty($files = $_FILES)){ $errorMediaFiles = (isset($resp['errorMediaFiles']))?$resp['errorMediaFiles']:array();
$media_type = 0;
$images = array();
$this->load->library('upload');
$config = set_upload_service("assets/uploads/services");
for ($typ = 0; $typ < count($files['event_image']['name']); $typ++) {
$_FILES['file']['name'] = $files['event_image']['name'][$typ];
$_FILES['file']['type'] = $files['event_image']['type'][$typ];
$_FILES['file']['size'] = $files['event_image']['size'][$typ];
$_FILES['file']['error'] = $files['event_image']['error'][$typ];
$_FILES['file']['tmp_name'] = $files['event_image']['tmp_name'][$typ];
$config['file_name'] = time()."_".$_FILES['file']['name'];
$this->upload->initialize($config);
if($this->upload->do_upload('file')){
$imgData = $this->upload->data();
$evtMediaData[] = array(
'event_id'=>$event_id,
'media_type'=>$media_type,
'media_url'=>"assets/uploads/services/".$imgData['file_name']);
$media_type = '1';
}
}
$status = $this->Event_model->createEventMedia($evtMediaData); $status = $this->Event_model->createEventMedia($evtMediaData);
} }
...@@ -371,36 +351,15 @@ class Event extends CI_Controller { ...@@ -371,36 +351,15 @@ class Event extends CI_Controller {
$_POST['existingImages']:''; $_POST['existingImages']:'';
$evtMediaData = array(); $evtMediaData = array();
if(isset($_FILES) && isset($_FILES['event_image']) && isset($_FILES['event_image']['name']) && $errorMediaFiles = array();
count($_FILES['event_image']['name']) > 1){ $media_type = (!empty($existingImages))?1:0;
$files = $_FILES; if(isset($_FILES) && isset($_FILES['event_image']) &&
isset($_FILES['event_image']['name']) && count($_FILES['event_image']['name'])>1){
$media_type = (!empty($existingImages))?1:0; $resp = $this->eventImageUpload($event_id,$_FILES,$media_type);
$images = array(); $evtMediaData = (isset($resp['evtMediaData']))?$resp['evtMediaData']:array();
$this->load->library('upload'); $errorMediaFiles = (isset($resp['errorMediaFiles']))?$resp['errorMediaFiles']:array();
$config = set_upload_service("assets/uploads/services");
for ($typ = 0; $typ < count($files['event_image']['name']); $typ++) {
$_FILES['file']['name'] = $files['event_image']['name'][$typ];
$_FILES['file']['type'] = $files['event_image']['type'][$typ];
$_FILES['file']['size'] = $files['event_image']['size'][$typ];
$_FILES['file']['error'] = $files['event_image']['error'][$typ];
$_FILES['file']['tmp_name'] = $files['event_image']['tmp_name'][$typ];
$config['file_name'] = time()."_".$_FILES['file']['name'];
$this->upload->initialize($config);
if($this->upload->do_upload('file')){
$imgData = $this->upload->data();
$evtMediaData[] = array(
'event_id'=>$event_id,
'media_type'=>$media_type,
'media_url'=>"assets/uploads/services/".$imgData['file_name']);
$media_type = '1';
}
}
} }
$status = $this->Event_model->updateEventMedia($event_id,$evtMediaData,$existingImages); $status = $this->Event_model->updateEventMedia($event_id,$evtMediaData,$existingImages);
$flashMsg['class'] = 'success'; $flashMsg['class'] = 'success';
...@@ -413,6 +372,58 @@ class Event extends CI_Controller { ...@@ -413,6 +372,58 @@ class Event extends CI_Controller {
redirect(base_url('Event/listEvents')); redirect(base_url('Event/listEvents'));
} }
function eventImageUpload($eId = '', $files = array(), $mTyp='0'){
if(empty($eId) || empty($files)){
return false;
}
$evtMediaData = array();
$errorMediaFiles = array();
$this->load->library('upload');
$bPath = "assets/uploads/services/";
$config = set_upload_service("assets/uploads/services");
for($typ = 0; $typ < count($files['event_image']['name']); $typ++) {
$_FILES['file']['name'] = $files['event_image']['name'][$typ];
$_FILES['file']['type'] = $files['event_image']['type'][$typ];
$_FILES['file']['size'] = $files['event_image']['size'][$typ];
$_FILES['file']['error'] = $files['event_image']['error'][$typ];
$_FILES['file']['tmp_name'] = $files['event_image']['tmp_name'][$typ];
$extn = substr($_FILES['file']['name'],strrpos($_FILES['file']['name'],'.')+1);
$file = date('YmdHis').gettimeofday()['usec']."_EVT_IMG.".$extn;
$config['file_name'] = $file;
$this->upload->initialize($config);
if($this->upload->do_upload('file')){
$iDat = $this->upload->data();
$path = $bPath.$iDat['file_name'];
if($extn != 'gif'){
$size = array('width'=>'720','height'=>'480');
$tFile = date('YmdHis').gettimeofday()['usec'].'_EVT_IMG_720x480.'.$extn;
$resp = $this->imageResize($tFile,$size,$path);
if($resp['status'] == '1'){
$file = $tFile;
unlink($path);
$path = $bPath.$tFile;
}
}
$imgSafety = $this->googleVisionApi(base_url($file));
if($imgSafety == 1){
$evtMediaData[] = array('event_id'=>$eId,'media_type'=>$mTyp,'media_url'=>$path);
$mTyp = '1';
}
else if ($imgSafety == 2) {
$errorMediaFiles[] = $_FILES['file']['name'];
}
} else {
$errorMediaFiles[] = $_FILES['file']['name'];
}
}
return array('evtMediaData'=>$evtMediaData,'errorMediaFiles'=>$errorMediaFiles);
}
function changeStatus(){ function changeStatus(){
if(!isset($_POST) || !isset($_POST['event_id']) || empty($_POST['event_id']) || if(!isset($_POST) || !isset($_POST['event_id']) || empty($_POST['event_id']) ||
!isset($_POST['status']) || $_POST['status'] == ''){ !isset($_POST['status']) || $_POST['status'] == ''){
...@@ -441,5 +452,68 @@ class Event extends CI_Controller { ...@@ -441,5 +452,68 @@ class Event extends CI_Controller {
echo $viewPage;exit; echo $viewPage;exit;
} }
function imageResize($newImage,$size,$path){
$this->load->library('image_lib');
$config['width'] = $size['width'];
$config['height'] = $size['height'];
$config['new_image'] = $newImage;
$config['source_image'] = $path;
$config['create_thumb'] = FALSE;
$config['image_library'] = 'gd2';
$config['maintain_ratio'] = TRUE;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
$res = array('status'=>'1');
if(!$this->image_lib->resize()){
$res['status'] = '0';
$res['error'] = $this->image_lib->display_errors();
}
return $res;
}
function googleVisionApi($img='', $typ='SAFE_SEARCH_DETECTION'){
if(empty($img)){
return 0;
}
$settings = getSettings();
$api = $settings['google_api_key'];
$url = "https://vision.googleapis.com/v1/images:annotate?key=".$api;
$req = "{'requests':[{'image':{'source':{'imageUri':'$img'}},'features':[{'type':'$typ'}]}]}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$req);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$resp = curl_exec($ch);
curl_close ($ch);
$safe = 1;
if(!empty($resp) && !empty($resp = json_decode($resp,true)) && isset($resp['responses']) &&
isset($resp['responses'][0]) && isset($resp['responses'][0]['safeSearchAnnotation'])){
$resp = $resp['responses'][0]['safeSearchAnnotation'];
if($resp['adult']=='Very Likely'||$resp['adult']=='Likely'||$resp['adult']=='Possible'){
$safe = 2;
}
if($resp['spoof']=='Very Likely'||$resp['spoof']=='Likely'){
$safe = 2;
}
if($resp['medical']=='Very Likely'||$resp['medical']=='Likely'){
$safe = 2;
}
if($resp['violence']=='Very Likely'||$resp['violence']=='Likely'){
$safe = 2;
}
if($resp['racy']=='Very Likely'||$resp['racy']=='Likely'||$resp['racy']=='Possible'){
$safe = 2;
}
}
return $safe;
}
} }
?> ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment