示例#1
0
 public function run()
 {
     try {
         Yii::app()->session->open();
         $controller = $this->getController();
         if (isset($_POST['listingid'])) {
             $this->listingid = $_POST['listingid'];
         }
         if (isset($_POST['userid'])) {
             $responseid = $_POST['sid'];
             $userid = $_POST['userid'];
             $mobileno = $_POST['mobileno'];
             $userRedis = new UserRedis();
             $listingInfo = $userRedis->getListingDetails($this->listingid, 'sellerinfo');
             $listing_array = json_decode($listingInfo, TRUE);
             $userInfo = $userRedis->getUserinfo($userid);
             $user_array = json_decode($userInfo, TRUE);
             //$user_array['mobile'] = $mobileno;
             $exotel_url = "https://" . Yii::app()->params['exotel_sid'] . ":" . Yii::app()->params['exotel_token'] . "@twilix.exotel.in/v1/Accounts/" . Yii::app()->params['exotel_sid'] . "/Calls/" . $responseid;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $exotel_url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_FAILONERROR, 0);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
             $curl_call_result = curl_exec($ch);
             $curl_call_error_code = curl_error($ch);
             $curl_call_http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             curl_close($ch);
             if ($curl_call_error_code) {
                 $html = $controller->renderPartial('_call_disconnected_form', array(), TRUE);
                 $response_array = array('status' => 'Failure', 'http_code' => $curl_call_http_code, 'error_code' => $curl_call_error_code, 'html' => $html);
                 return json_encode($response_array);
             } else {
                 if ($curl_call_http_code == '200') {
                     $call_details = simplexml_load_string($curl_call_result);
                     $call_details = json_encode($call_details);
                     $call_details = json_decode($call_details, TRUE);
                     $call_status = $call_details['Call']['Status'];
                     $call_sid = $call_details['Call']['Sid'];
                     $call_from = $call_details['Call']['From'];
                     $call_to = $call_details['Call']['To'];
                     if (isset(Yii::app()->request->cookies['cookie_id'])) {
                         $cookieid = Yii::app()->request->cookies['cookie_id'];
                         $userRedis->setUserContacted($cookieid, $this->listingid);
                     }
                     $html = $controller->renderPartial('_call_disconnected_form', array('listing_array' => $listing_array, 'user' => $user_array, 'mobileno' => $mobileno), TRUE);
                     $response_array = array('status' => 'Sucess', 'call_Status' => $call_status, 'call_Sid' => $call_sid, 'html' => $html, 'url' => $controller->createUrl('contactseller/sendemail'), 'listingid' => $this->listingid, 'userid' => $userid, 'mobileno' => $mobileno);
                     echo json_encode($response_array);
                 }
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }
示例#2
0
 public function run()
 {
     try {
         Yii::app()->session->open();
         $userRedis = new UserRedis();
         $controller = $this->getController();
         if (isset($_POST['listingid'])) {
             $this->listingid = $_POST['listingid'];
         }
         if (isset(Yii::app()->session['userid'])) {
             $this->_userid = Yii::app()->session['userid'];
         } else {
             $this->_userid = $_POST['userid'];
         }
         if (isset($_POST['mobileno']) && $_POST['mobileno'] != '') {
             $this->buyer = $_POST['mobileno'];
         }
         $userInfo = $userRedis->getUserinfo($this->_userid);
         $listingInfo = $userRedis->getListingDetails($this->listingid, 'sellerinfo');
         $user_array = json_decode($userInfo, TRUE);
         $listing_array = json_decode($listingInfo, TRUE);
         $this->_tobuyeremail = $user_array['email_id'];
         /*$seller     = $listing_array['phoneNo'];
         		$this->_toselleremail  = $listing_array['email'];*/
         $seller = '08122219504';
         $this->_toselleremail = '*****@*****.**';
         $call_output = Yii::app()->call->call_seller($seller, $this->buyer);
         $call_result = json_decode($call_output, TRUE);
         $user_array['mobile'] = $this->buyer;
         if ($call_result['status'] == 'Success') {
             if ($call_result['call_status'] == 'in-progress') {
                 /*
                  * Need to do log here for sending emails.
                  */
                 $send_email_buyer = Yii::app()->email->email_send($this->_emailtype, $this->_tobuyeremail, $this->listingid, $user_array['user_name']);
                 $this->_emailtype = 'contact_seller';
                 $send_email_seller = Yii::app()->email->email_send($this->_emailtype, $this->_toselleremail, $this->_userid, $user_array['user_name']);
                 $html = $controller->renderPartial('_call_in_progress_form', array('listing' => $listing_array, 'user' => $user_array), TRUE);
                 $json_array = array('status' => 'sucess', 'html' => $html, 'responsesid' => $call_result['call_ressid'], 'userid' => $this->_userid, 'listingid' => $this->listingid, 'mobileno' => $this->buyer, 'url' => $controller->createUrl('contactseller/callstatus'));
                 echo json_encode($json_array);
             }
         } else {
             if ($call_result['status'] == 'Failure') {
                 $html = $controller->renderPartial('_call_failed_form', array('listing_array' => $listing_array, 'user' => $user_array), TRUE);
                 $json_array = array('status' => 'failure', 'html' => $html, 'userid' => $this->_userid, 'http_code' => $call_result['http_code'], 'mobileno' => $this->buyer, 'error_code' => $call_result['error_code']);
                 echo json_encode($json_array);
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }
 public function run()
 {
     $controller = $this->getController();
     try {
         if (isset($_GET['activation_code'])) {
             $this->_activationcode = trim($_GET['activation_code']);
             $userArray = UserRegistration::model()->find(array('select' => '*', 'condition' => 'user_activation_code=:user_activation_code', 'params' => array(':user_activation_code' => $this->_activationcode)));
             $this->_userid = $userArray['uid'];
             if ($userArray['user_email_status'] == '0') {
                 $userRedis = new UserRedis();
                 $userInfo = $userRedis->getUserinfo($this->_userid);
                 $userRArray = json_decode($userInfo, TRUE);
                 $userRArray['email_status'] = '1';
                 $userRedis->setUserinfo($this->_userid, json_encode($userRArray));
                 $emailverified = UserRegistration::model()->updateByPk($this->_userid, array('user_email_status' => '1'));
                 if ($emailverified != '1') {
                     $response_array = array('status' => 'failure', 'message' => 'Email Status Not Update Successfully.');
                     echo json_encode($response_array);
                     exit;
                 }
             }
             if ($userArray['user_pass'] == '') {
                 echo $controller->renderPartial('/layouts/auth/_user_email_verify_form', array('set_password' => 'yes', 'userid' => $this->_userid), TRUE);
             } else {
                 if (isset($_GET['forgot_password'])) {
                     echo $controller->renderPartial('/layouts/auth/_user_email_verify_form', array('set_password' => 'yes', 'userid' => $this->_userid), TRUE);
                 } else {
                     echo $controller->renderPartial('/layouts/auth/_user_email_verify_form', array('userid' => $this->_userid), TRUE);
                 }
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }
示例#4
0
 public function run()
 {
     $controller = $this->getController();
     $model = new LoginForm();
     $userredis = new UserRedis();
     try {
         if (isset($_POST['UserLogin'])) {
             $model->attributes = $_POST['UserLogin'];
             if ($model->validate()) {
                 $user = UserRegistration::model()->find('LOWER(user_email)=?', array(strtolower($model->user_email)));
                 $userInfo = $userredis->getUserinfo(trim($user->uid));
                 $user_array = json_decode($userInfo, TRUE);
                 Yii::app()->session->open();
                 Yii::app()->session['userid'] = $user->uid;
                 Yii::app()->session['username'] = $user->user_name;
                 Yii::app()->session['mobile'] = $user->user_mobile;
                 Yii::app()->session['email'] = $user->user_email;
                 if (isset($_POST['UserLogin']['form_name'])) {
                     $state = 'mob_notchanged';
                     $this->seller_type = '';
                     $this->listingid = '';
                     $mobileno = '';
                     $mob_sta = '';
                     if ($_POST['UserLogin']['form_name'] == 'register_user') {
                         $html = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                         $html_ano = "";
                     } else {
                         if ($_POST['UserLogin']['form_name'] == 'contact_user') {
                             $html = $controller->renderPartial('/contactseller/_user_mobile_confirm_form', array('listingid' => $_POST['listingid']), TRUE);
                             $html_ano = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                         } else {
                             if ($_POST['UserLogin']['form_name'] == 'mobile_change') {
                                 /*Yii::import('application.controllers.contact_seller.UpdateusermobileAction');
                                 	 $mobileno_changed = 'mobile_changed';
                                 	 $obj =new UpdateusermobileAction($_POST['userid'],$_POST['mobileno']);
                                 	 $result = $obj->run();*/
                                 $userRedis = new UserRedis();
                                 $userInfo = $userRedis->getUserinfo($_POST['userid']);
                                 $user_array = json_decode($userInfo, TRUE);
                                 $useridArray = UserRegistration::model()->findAll(array('select' => 'uid', 'condition' => 'user_mobile=:user_mobile', 'params' => array(':user_mobile' => $_POST['mobileno'])));
                                 $user_array['mobile_status'] = '1';
                                 $user_array['mobile'] = $_POST['mobileno'];
                                 $userRedis->setUserinfo($_POST['userid'], json_encode($user_array));
                                 UserRegistration::model()->updateByPk($_POST['userid'], array('user_mobile' => $_POST['mobileno']));
                                 UserRegistration::model()->updateByPk($_POST['userid'], array('user_mobile_status' => '1'));
                                 if (!empty($useridArray)) {
                                     foreach ($useridArray as $key => $value) {
                                         if ($value['uid'] != '' && $_POST['userid'] != $value['uid']) {
                                             $userRinfo = $userRedis->getUserinfo($value['uid']);
                                             $userRarray = json_decode($userRinfo, TRUE);
                                             $userRarray['mobile_status'] = '0';
                                             $userRedis->setUserinfo($value['uid'], json_encode($userRarray));
                                             UserRegistration::model()->updateByPk($value['uid'], array('user_mobile_status' => '0'));
                                         }
                                     }
                                 }
                                 $html = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                                 $json_array = array('status' => 'sucess', 'html' => $html);
                                 echo json_encode($json_array);
                                 exit;
                             }
                         }
                     }
                 }
                 if (isset($_POST['result_user_mobile'])) {
                     $state = 'mob_changed';
                     $mob_sta = 'notverified';
                     if (isset($_POST['listingid'])) {
                         $this->listingid = $_POST['listingid'];
                         $this->currentDateTime = date('H:i');
                         $this->newDateTime = date('h:i A', strtotime($this->currentDateTime));
                         if ($this->currentDateTime >= Yii::app()->params['starttime'] && $this->currentDateTime <= Yii::app()->params['endtime']) {
                             $this->seller_type = 'view';
                         } else {
                             if ($userredis->getListingDetails($this->listingid, 'status')) {
                                 $this->seller_type = 'view';
                             } else {
                                 $this->seller_type = 'call';
                             }
                         }
                     }
                     if ($_POST['result_user_mobile'] != $user->user_mobile) {
                         $mobileno = $_POST['result_user_mobile'];
                         $user_array['mobile'] = $mobileno;
                         $sms_result = Yii::app()->sms->send_message($mobileno, $this->sms_type, $user->uid);
                         $html = $controller->renderPartial('/contactseller/_otp_form', array('seller_type' => $this->seller_type, 'user_array' => $user_array), TRUE);
                         $html_ano = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                     }
                 }
                 $json_array = array('status' => 'sucess', 'state' => $state, 'message' => 'User Details Verified Sucessfully', 'html' => $html, 'html_ano' => $html_ano, 'listingid' => $this->listingid, 'userid' => $user->uid, 'mobile_number' => $mobileno, 'mob_sta' => $mob_sta, 'url' => $controller->createUrl('contactseller/mobilenumberverification'));
                 echo json_encode($json_array);
             } else {
                 $_error = $model->getErrors();
                 $_error['status'] = 'error';
                 echo json_encode($_error);
             }
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }
 public function run()
 {
     try {
         $controller = $this->getController();
         $userRedis = new UserRedis();
         if (isset($_POST['listingid'])) {
             $this->listingid = $_POST['listingid'];
             $this->currentDateTime = date('H:i');
             $this->newDateTime = date('h:i A', strtotime($this->currentDateTime));
             if ($this->currentDateTime >= Yii::app()->params['starttime'] || $this->currentDateTime <= Yii::app()->params['endtime']) {
                 $this->seller_type = 'view';
             } else {
                 if ($userRedis->getListingDetails($this->listingid, 'status')) {
                     $this->seller_type = 'view';
                 } else {
                     $this->seller_type = 'call';
                 }
             }
             $listingInfo = $userRedis->getListingDetails($this->listingid, 'sellerinfo');
             $listing_array = json_decode($listingInfo, TRUE);
         }
         if (isset($_POST['userid'])) {
             $userInfo = $userRedis->getUserinfo(trim($_POST['userid']));
             $user_array = json_decode($userInfo, TRUE);
             $userid = $user_array['uid'];
             if (isset($_POST['mobileno'])) {
                 if ($_POST['mobileno'] != $user_array['mobile']) {
                     $mobileno = $_POST['mobileno'];
                 } else {
                     $mobileno = $user_array['mobile'];
                 }
             }
             if ($mobileno != '') {
                 $user_deatail = array('userid' => $user_array['uid'], 'user_email' => $user_array['email_id'], 'user_mobile' => $mobileno, 'user_username' => $user_array['user_name']);
                 if (isset($_POST['otp_number'])) {
                     $_otpValue = $userRedis->getOtpinfo($userid, $mobileno);
                     if (isset($_otpValue) && $_otpValue != '') {
                         if ($_POST['otp_number'] == $_otpValue) {
                             if (isset($_POST['user_registration'])) {
                                 $html = $controller->renderPartial('/layouts/auth/_mobile_verified_form', array(), TRUE);
                             }
                             if ($this->seller_type == 'call') {
                                 $html = $controller->renderPartial('_connect_seller_form', $user_deatail, TRUE);
                             } else {
                                 if ($this->seller_type == 'view') {
                                     if (isset(Yii::app()->request->cookies['cookie_id'])) {
                                         $cookieid = Yii::app()->request->cookies['cookie_id'];
                                         $userRedis->setUserContacted($cookieid, $this->listingid);
                                     }
                                     $html = $controller->renderPartial('_view_contact_details_form', array('listing_array' => $listing_array, 'user' => $user_array, 'mobileno' => $mobileno), TRUE);
                                 }
                             }
                             if ($_POST['mobileno'] == $user_array['mobile']) {
                                 Yii::app()->session->open();
                                 Yii::app()->session['userid'] = $user_array['uid'];
                                 Yii::app()->session['username'] = $user_array['user_name'];
                                 Yii::app()->session['mobile'] = $user_array['mobile'];
                                 Yii::app()->session['email'] = $user_array['email_id'];
                                 $useridArray = UserRegistration::model()->findAll(array('select' => 'uid', 'condition' => 'user_mobile=:user_mobile', 'params' => array(':user_mobile' => $mobileno)));
                                 $user_array['mobile_status'] = '1';
                                 $userRedis->setUserinfo($userid, json_encode($user_array));
                                 $updatemobilestatus = UserRegistration::model()->updateByPk($userid, array('user_mobile_status' => '1'));
                                 if (!empty($useridArray)) {
                                     foreach ($useridArray as $key => $value) {
                                         if ($value['uid'] != '' && $userid != $value['uid']) {
                                             $userRinfo = $userRedis->getUserinfo($value['uid']);
                                             $userRarray = json_decode($userRinfo, TRUE);
                                             $userRarray['mobile_status'] = '0';
                                             $userRedis->setUserinfo($value['uid'], json_encode($userRarray));
                                             UserRegistration::model()->updateByPk($value['uid'], array('user_mobile_status' => '0'));
                                         }
                                     }
                                 }
                                 $html_ano = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                                 $state = "loggedin";
                             } else {
                                 $html_ano = "";
                                 $state = "notloggedin";
                             }
                             $json_array = array('status' => 'sucess', 'state' => $state, 'html' => $html, 'html_ano' => $html_ano, 'url' => $controller->createUrl('contactseller/call'), 'userid' => $userid, 'listingid' => $this->listingid, 'seller_type' => $this->seller_type, 'mobile_number' => $mobileno, 'message' => Yii::t('app', 'site_otpverified'));
                             echo json_encode($json_array);
                         } else {
                             $json_array = array('status' => 'failure', 'message' => Yii::t('app', 'site_wrongotp'));
                             echo json_encode($json_array);
                         }
                     } else {
                         $json_array = array('status' => 'failure', 'message' => Yii::t('app', 'site_validotp'));
                         echo json_encode($json_array);
                     }
                 } else {
                     $_misscallvalue = $userRedis->getMissedcallverification($mobileno);
                     if ($_misscallvalue != '' && $_misscallvalue == '1') {
                         if (isset($_POST['user_registration'])) {
                             $html = $controller->renderPartial('/layouts/auth/_mobile_verified_form', array(), TRUE);
                         }
                         if ($this->seller_type == 'call') {
                             $html = $controller->renderPartial('_connect_seller_form', $user_deatail, TRUE);
                         } else {
                             if ($this->seller_type == 'view') {
                                 if (isset(Yii::app()->request->cookies['cookie_id'])) {
                                     $cookieid = Yii::app()->request->cookies['cookie_id'];
                                     $userRedis->setUserContacted($cookieid, $this->listingid);
                                 }
                                 $html = $controller->renderPartial('_view_contact_details_form', array('listing_array' => $listing_array, 'user' => $user_array, 'mobileno' => $mobileno), TRUE);
                             }
                         }
                         if ($_POST['mobileno'] == $user_array['mobile']) {
                             Yii::app()->session->open();
                             Yii::app()->session['userid'] = $user_array['uid'];
                             Yii::app()->session['username'] = $user_array['user_name'];
                             Yii::app()->session['mobile'] = $user_array['mobile'];
                             Yii::app()->session['email'] = $user_array['email_id'];
                             $user_array['mobile_status'] = '1';
                             $userRedis->setUserinfo($userid, json_encode($user_array));
                             $updatemobilestatus = UserRegistration::model()->updateByPk($userid, array('user_mobile_status' => '1'));
                             if (!empty($useridArray)) {
                                 foreach ($useridArray as $key => $value) {
                                     if ($value['uid'] != '' && $userid != $value['uid']) {
                                         $userRinfo = $userRedis->getUserinfo($value['uid']);
                                         $userRarray = json_decode($userRinfo, TRUE);
                                         $userRarray['mobile_status'] = '0';
                                         $userRedis->setUserinfo($value['uid'], json_encode($userRarray));
                                         UserRegistration::model()->updateByPk($value['uid'], array('user_mobile_status' => '0'));
                                     }
                                 }
                             }
                             $html_ano = $controller->renderPartial('/layouts/auth/_user_logout_form', array(), TRUE);
                             $state = "loggedin";
                         } else {
                             $html_ano = "";
                             $state = "notloggedin";
                         }
                         $json_array = array('status' => 'sucess', 'state' => $state, 'html' => $html, 'html_ano' => $html_ano, 'message' => Yii::t('app', 'site_missedcallverification'), 'userid' => $userid, 'listingid' => $this->listingid, 'seller_type' => $this->seller_type, 'mobile_number' => $mobileno, 'url' => $controller->createUrl('contactseller/call'));
                         echo json_encode($json_array);
                     } else {
                         if ($_misscallvalue == '') {
                             $json_array = array('status' => 'failure', 'message' => Yii::t('app', 'site_missedcallnotverified'));
                             echo json_encode($json_array);
                         }
                     }
                 }
             }
         }
     } catch (Exception $e) {
         Yii::app()->session->destroy();
         echo 'Caught exception: ', $e->getMessage(), "\n";
         exit;
     }
 }