public function indexAction() { $api = new Api(); $common = new Common(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/partners/?status_id=1"; $res = $api->curl($url, array(), "GET"); if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); if ($this->getRequest()->isXmlHttpRequest()) { $partners_list = ''; foreach ($content as $data) { $partners_list .= "<li>"; $partners_list .= "<img src='" . $data['logo'] . "' alt='' >"; $partners_list .= "</li>"; } echo $partners_list; die; } // getting banners $banners = $common->getBanner($api_url, 13); $banner_content = $common->getPage($api_url, 14); return new ViewModel(array('partners' => $content, 'banners' => $banners, 'banner_content' => $banner_content)); } }
public function indexAction() { $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; if ($this->getRequest()->isXmlHttpRequest()) { //echo $this->getRequest()->getPost('page'); exit; $next = $this->getRequest()->getPost('page') != '' ? $this->getRequest()->getPost('page') : '1'; $api = new Api(); $url = $api_url . "/api/testimonials/"; $res = $api->curl($url, array('page' => $next, 'status_id' => '1'), "GET"); if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); if (count($content['results'])) { $count = 0; foreach ($content['results'] as $value) { $currentDate = strtotime(date("Y-m-d H:i:s")); $lastDate = strtotime($value['created_on']); $dateTime = $lastDate + 86400 > $currentDate ? 'About ' . floor(($currentDate - $lastDate) / 3600) . ':' . floor(($currentDate - $lastDate) / (24 * 60)) . ' Hours Ago' : $value['created_on']; $ts_list[$count]['id'] = $value['id']; $ts_list[$count]['created_on'] = $dateTime; $ts_list[$count]['text'] = $value['text']; if (count($value['created_by_user']) > 0) { $details = json_decode($value['created_by_user'], true); foreach ($details as $user_detail) { $ts_list[$count]['user_name'] = $details['first_name'] . ' ' . $details['last_name']; $ts_list[$count]['user_id'] = $details['user_id']; $ts_list[$count]['img_url'] = $details['avtar_url'] != 'None' ? $details['avtar_url'] : 0; } } $count++; } if ($content['next'] != '') { $str = str_replace("page", "@!##", $content['next']); $str_arr = explode('@!##=', $str); $next = explode('&', $str_arr[1]); $ts_list['next'] = $next[0]; } else { $ts_list['next'] = ''; } //$ts_list['error'] = false; $ts_list['count'] = $count; echo json_encode($ts_list); exit; } else { $ts_list = ''; echo json_encode($ts_list); // no data found exit; } } else { $ts_list = array('next' => '', 'count' => ''); } echo json_encode($ts_list); exit; } else { // getting banners $common = new Common(); $banners = $common->getBanner($api_url, 8); return new ViewModel(array('banners' => $banners)); } }
public function indexAction() { $slug = $this->params()->fromRoute('slug'); $redirectUrl = array('controller' => 'index', 'action' => 'index'); $page = ""; if (!empty($slug) && $slug != null) { $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/pages/"; $data = array('slug' => $slug); $res = $api->curl($url, $data, "GET"); if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); if (!(isset($content[0]['content']) && !empty($content[0]['content']))) { return $this->redirect()->toRoute(null, $redirectUrl); } $page = stripcslashes($content[0]['content']); //var_dump($content); die; $this->getServiceLocator()->get('ViewHelperManager')->get('HeadTitle')->set($content[0]['title']); $this->getServiceLocator()->get('ViewHelperManager')->get('headMeta')->setName('keywords', $content[0]['meta_tags']); $this->getServiceLocator()->get('ViewHelperManager')->get('headMeta')->setName('description', $content[0]['title']); } return new ViewModel(array('page' => $page)); } else { return $this->redirect()->toUrl('/'); } }
public function indexAction() { $linkedIn = new LinkedIn($this->getServiceLocator()->get('config')['linkedin_keys']['aapId'], $this->getServiceLocator()->get('config')['linkedin_keys']['app_secret']); if ($linkedIn->isAuthenticated()) { //we know that the user is authenticated now. Start query the API $user = $linkedIn->api('v1/people/~:(id,firstName,lastName,emailAddress)'); //Check user exist or not $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/useractivity/"; $data = array('op' => 'check_exist_user', 'user_name' => $user['emailAddress'], 'email' => $user['emailAddress']); $res = $api->curl($url, $data, "POST"); //Set value in session $lk_login = new Container('linkedin'); $lk_login->first_name = $user['firstName']; $lk_login->last_name = $user['lastName']; $lk_login->user_name = $user['emailAddress']; $lk_login->email = $user['emailAddress']; $lk_login->social_id = $user['id']; // END :- Set value in session //$facebook1->destroySession(); die; // For new user if ($res->getStatusCode() != 200) { $redirectUrl = 'register/index#register-a'; return $this->redirect()->toUrl($redirectUrl); } else { $auth = new FrontEndAuth(); $session = new Container('frontend'); $content = json_decode($res->getBody(), true); $session->status_id = $content['status_id']; $session->userid = $content['id']; if ($content['status_id'] != 3) { $session->first_name = $content['first_name']; $session->last_name = $content['last_name']; $session->email = $content['email']; $session->user_name = $content['user_name']; $session->user_type_id = $content['user_type_id']; $session->user_data = $content; $session->last_login = $content['last_login_prev']; $auth->wordpress_login($fbuname); //$redirectUrl = ($session->user_type_id == 4)?array('controller' => 'practitioner', 'action' => 'list'):array('controller' => 'practitioner', 'action' => 'dashboard'); $redirectUrl = $session->user_type_id == 4 ? 'list' : 'dashboard'; $url = "practitioner/" . $redirectUrl; return $this->redirect()->toUrl($url); } else { return $this->redirect()->toRoute('login', array('action' => 'index')); } } } elseif ($linkedIn->hasError()) { echo "User canceled the login."; exit; } //if not authenticated $url = $linkedIn->getLoginUrl(); return $this->redirect()->toUrl($url); die; }
public function indexAction() { $api = new Api(); $common = new Common(); $model = new Practitioners(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $subscription_id = $this->getSubscriptionid($api_url); $url = $api_url . "/api/subscription/"; $url_sf = $api_url . "/api/sitefeatures/"; $data = array(''); $res = $api->curl($url, $data, "GET"); $res_sf = $api->curl($url_sf, $data, "GET"); if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); if (count($content) > 0) { foreach ($content as $key => $value) { $membership[$key] = $value; } } } else { $membership = array(); } if ($res_sf->getStatusCode() == 200) { $content = json_decode($res_sf->getBody(), true); if (count($content) > 0) { $i = 0; foreach ($content as $data) { $site_features_list[$i]['id'] = $data['id']; $site_features_list[$i]['feature_name'] = $data['feature_name']; $site_features_list[$i]['description'] = $data['description']; $i++; } } } else { $site_features_list = array(); } $banners = $common->getBanner($api_url, 15); return new ViewModel(array('membership' => $membership, 'site_features_list' => $site_features_list, 'subscription_id' => $subscription_id, 'banners' => $banners, 'currency' => $model->getcurrency($api_url, $this->getRequest()->getServer('REMOTE_ADDR')))); }
public function indexAction() { $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $api = new Api(); $auth = new FrontEndAuth(); $error = ""; $redirectUrl = array('controller' => 'index'); if ($auth->hasIdentity()) { return $this->redirect()->toRoute(null, $redirectUrl); } $form = new ForgetPasswordForm(); $request = $this->getRequest(); if ($request->isPost()) { $model = new ForgetPassword(); $form->setInputFilter($model->getInputFilter()); $data = $request->getPost()->toArray(); $form->setData($data); if ($form->isValid()) { unset($data['submit']); $random_password = $model->generateRandomPassword(); $data['password'] = $random_password; $session = new Container('frontend'); $url = $api_url . "/api/useractivity/"; $data['email'] = $request->getPost('email'); $res = $api->curl($url, $data, "GET"); //echo '<pre>'; var_dump($res); die; if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); //echo '<pre>'; var_dump($content[0]); die; $model = new Common(); $model->sendMail($api_url, $content[0]['email'], '', 22, '', array('/{{user_name}}/i', '/{{username}}/i'), array($content[0]['first_name'] . ' ' . $content[0]['last_name'], '<strong>' . $content[0]['user_name'] . '</strong>')); $error = false; $msg = "A mail has been send to " . $content[0]['email'] . " ,Please check "; } else { $error = true; $msg = "User with given email does not exist"; } } } $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg)); $view->setTemplate('application/forgetPassword/index.phtml'); return $view; }
public function indexAction() { //session_start(); $google_login = new Container('google'); $google_client_id = $this->getServiceLocator()->get('config')['gplus_keys']['google_client_id']; $google_client_secret = $this->getServiceLocator()->get('config')['gplus_keys']['google_client_secret']; $google_redirect_url = $this->getServiceLocator()->get('config')['gplus_keys']['google_redirect_url']; $google_developer_key = $this->getServiceLocator()->get('config')['gplus_keys']['google_developer_key']; $gClient = new \Google_Client(); $gClient->setClientId($google_client_id); $gClient->setClientSecret($google_client_secret); $gClient->setRedirectUri($google_redirect_url); $gClient->setDeveloperKey($google_developer_key); $google_oauthV2 = new \Google_Oauth2Service($gClient); $id = (int) $this->params()->fromRoute('code', 0); //var_dump($id); if ($_GET['code']) { $gClient->authenticate($_GET['code']); //$_SESSION['token'] = $gClient->getAccessToken(); $google_login->token = $gClient->getAccessToken(); //header('Location: ' . filter_var($google_redirect_url, FILTER_SANITIZE_URL)); //return; } /*print"<pre>"; print_r($google_oauthV2);*/ //print_r($_SESSION); //die; if (isset($google_login->token)) { $gClient->setAccessToken($google_login->token); } if ($gClient->getAccessToken()) { //For logged in user, get details from google using access token $user = $google_oauthV2->userinfo->get(); $user_id = $user['id']; $first_name = filter_var($user['given_name'], FILTER_SANITIZE_SPECIAL_CHARS); $last_name = filter_var($user['family_name'], FILTER_SANITIZE_SPECIAL_CHARS); $user_name = filter_var($user['name'], FILTER_SANITIZE_SPECIAL_CHARS); $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL); $profile_url = filter_var($user['link'], FILTER_VALIDATE_URL); $google_login->token = $gClient->getAccessToken(); //Check user exist or not $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/useractivity/"; $data = array('op' => 'check_exist_user', 'user_name' => $email, 'email' => $email); $res = $api->curl($url, $data, "POST"); //Set value in session $google_login->first_name = $first_name; $google_login->last_name = $last_name; $google_login->user_name = $email; $google_login->email = $email; $google_login->social_id = $user_id; // END :- Set value in session // For new user if ($res->getStatusCode() != 200) { $redirectUrl = 'register/index#register-a'; return $this->redirect()->toUrl($redirectUrl); } else { $auth = new FrontEndAuth(); $session = new Container('frontend'); $content = json_decode($res->getBody(), true); $session->status_id = $content['status_id']; $session->userid = $content['id']; if ($content['status_id'] != 3) { $session->first_name = $content['first_name']; $session->last_name = $content['last_name']; $session->email = $content['email']; $session->user_name = $content['user_name']; $session->user_type_id = $content['user_type_id']; $session->last_login = $content['last_login_prev']; $session->user_data = $content; $auth->wordpress_login($fbuname); $redirectUrl = $session->user_type_id == 4 ? array('controller' => 'practitioner', 'action' => 'list') : array('controller' => 'practitioner', 'action' => 'dashboard'); //$redirectUrl = array('controller' => 'practitioner', 'action' => 'dashboard'); return $this->redirect()->toRoute(null, $redirectUrl); } else { $redirectUrl = array('controller' => 'login', 'action' => 'index'); return $this->redirect()->toRoute(null, $redirectUrl); } } } else { //For Guest user, get google login url $authUrl = $gClient->createAuthUrl(); return $this->redirect()->toUrl($authUrl); } die; }
public function indexAction() { $keys = $this->getServiceLocator()->get('config')['fb_keys']; $facebook = new \Facebook($keys); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); //Check user exist or not $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/useractivity/"; $data = array('op' => 'check_exist_user', 'user_name' => $user_profile['email'], 'email' => $user_profile['email']); $res = $api->curl($url, $data, "POST"); //Set value in session $fb_login = new Container('facebook'); $fb_login->first_name = $user_profile['first_name']; $fb_login->last_name = $user_profile['last_name']; $fb_login->user_name = $user_profile['email']; $fb_login->email = $user_profile['email']; $fb_login->social_id = $user_profile['id']; $fb_login->token = $facebook->getAccessToken(); // END :- Set value in session //$facebook1->destroySession(); die; // For new user if ($res->getStatusCode() != 200) { $redirectUrl = 'register/index#register-a'; return $this->redirect()->toUrl($redirectUrl); } else { $auth = new FrontEndAuth(); $session = new Container('frontend'); $content = json_decode($res->getBody(), true); $session->status_id = $content['status_id']; $session->userid = $content['id']; if ($content['status_id'] != 3) { $session->first_name = $content['first_name']; $session->last_name = $content['last_name']; $session->email = $content['email']; $session->user_name = $content['user_name']; $session->user_type_id = $content['user_type_id']; $session->user_data = $content; $session->last_login = $content['last_login_prev']; $auth->wordpress_login($fbuname); $redirectUrl = $session->user_type_id == 4 ? array('controller' => 'practitioner', 'action' => 'list') : array('controller' => 'practitioner', 'action' => 'dashboard'); //$redirectUrl = array('controller' => 'practitioner', 'action' => 'dashboard'); return $this->redirect()->toRoute(null, $redirectUrl); } else { $redirectUrl = array('controller' => 'login', 'action' => 'index'); return $this->redirect()->toRoute(null, $redirectUrl); } } } catch (FacebookApiException $e) { error_log($e); $user = null; } } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'email,read_stream')); return $this->redirect()->toUrl($loginUrl); } die; }
public function indexAction() { $api = new Api(); $auth = new FrontEndAuth(); $loginError = ""; $error = ''; $redirectUrl = array('controller' => 'index'); if ($auth->hasIdentity()) { return $this->redirect()->toRoute(null, $redirectUrl); } $resettoken = $this->params()->fromRoute('resettoken'); if ($resettoken === null) { return $this->redirect()->toRoute(null, $redirectUrl); } // var_dump($resettoken); die; $resettoken = base64_encode($resettoken); $form = new ResetPasswordForm(); $request = $this->getRequest(); if ($request->isPost()) { $model = new ResetPassword(); $form->setInputFilter($model->getInputFilter()); $data = $request->getPost()->toArray(); // var_dump($data['resettoken']); // var_dump(base64_decode($data['resettoken'])); die; $form->setData($data); if ($form->isValid()) { $data['email'] = $data['resettoken']; unset($data['submit'], $data['resettoken']); //$session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/useractivity/"; $data['op'] = 'resetpassword'; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 200) { // $content = json_decode($res->getBody(), true); // // //print_r($content); // //print_r($content[0]['fields']); // //die; // $content = json_decode($res->getBody(), true); // $session->userid = $content['id']; // $session->first_name = $content['first_name']; // $session->last_name = $content['last_name']; // $session->email = $content['email']; // $session->user_name = $content['user_name']; // $session->user_type_id = $content['user_type_id']; // $session->user_data = $content; // // return $this->redirect()->toRoute(null, $redirectUrl); } else { // $errors = json_decode($res->getBody(), true); // foreach ($errors as $key=>$value) { // if(isset($value[0])){ // $form->setMessages(array( // $key => array( // $value[0] // ) // )); // } // } } //var_dump($res); die; } } else { // die('else'); $form->get('resettoken')->setValue($resettoken); } $view = new ViewModel(array('form' => $form, 'error' => $error, 'res' => $res)); $view->setTemplate('application/resetPassword/index.phtml'); return $view; }
public function sendmsgAction() { $request = $this->getRequest(); $session = new Container('frontend'); // User detail session $verify_session = new Container('verify'); // verify type session $sendcode = rand(); $common = new Common(); $number = $request->getPost('number'); $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; if ($smstemplate = $common->smsTemplate($api_url, 5)) { // Create a msg $patterns = array('/{{code}}/i'); $replacements = array($sendcode); $newMessage = preg_replace($patterns, $replacements, $smstemplate['message']); $config = $this->getServiceLocator()->get('Config'); $client = new \Services_Twilio($config['Twilio']['sid'], $config['Twilio']['token']); $msg = $client->account->messages->sendMessage($config['Twilio']['fromNumber'], $number, $newMessage, null, array("MessageStatus", "ErrorCode")); if ($msg->status == 'queued') { // Enter verify code in database // maintain sms history $url = $api_url . "/api/smshistory/"; $data = array('subject' => $smstemplate['subject'], 'message' => $newMessage, 'to_user_id' => $session->userid, 'from_user_id' => $session->userid, 'status' => 1); $res = $api->curl($url, $data, "POST"); // End maintain sms history $data = array('user_id' => $session->userid, 'verification_type_id' => $verify_session->type, 'verification_code' => $sendcode, 'created_date' => date('Y-m-d H:i:s')); $getvalue = $this->checkuserexistence(); if (count($getvalue) > 0) { // verification code time out if ($getvalue['timeverification'] == false) { $url = $api_url . "/api/userverification/" . $getvalue['id'] . "/"; $type = "PUT"; } } else { // new user $url = $api_url . "/api/userverification/"; $type = "POST"; } $res = $api->curl($url, $data, $type); //$msg = ($res->getStatusCode()==201)? ('Your verified code was sent to your number'):('Error in create verified code'); //$error = ($res->getStatusCode()==201)? false: true; $msg = 'Your verified code was sent to your number'; $error = false; // End :- Enter verify code in database } else { $error = true; $msg = 'Invalid contact number for send verify code'; } } else { $error = true; $msg = 'Message template not found..!!'; } echo json_encode(array('msg' => $msg, 'error' => $error)); die; }
public function indexAction() { $fb_login = new Container('facebook'); $google_login = new Container('google'); $linkedin_login = new Container('linkedin'); $social_media_id = ''; if (isset($fb_login->social_id)) { $common_object = $fb_login; $social_media_id = $fb_login->social_id; } if (isset($google_login->social_id)) { $common_object = $google_login; $social_media_id = $google_login->social_id; } if (isset($linkedin_login->social_id)) { $common_object = $linkedin_login; $social_media_id = $linkedin_login->social_id; } $api = new Api(); $auth = new FrontEndAuth(); $session = new Container('frontend'); $loginError = ""; $redirectUrl = array('controller' => 'index'); if ($auth->hasIdentity()) { //$redirectUrl = array('controller'=>'index'); //$redirectUrl = array('controller'=>'login', 'action' => 'dashboard'); return $this->redirect()->toRoute(null, $redirectUrl); } //var_dump($session->user_name); die; $common = new Common(); $form = new LoginForm(); $register_form = new RegisterForm(); $request = $this->getRequest(); if ($request->isPost()) { //die('hello'); $register = new Register(); $register_form->setInputFilter($register->getInputFilter()); $data = $request->getPost()->toArray(); $register_form->setData($data); //$validation_result = json_decode($this->passwordValidation($data['confirm_password']), true); if ($register_form->isValid()) { $loginError = $validation_result['msg']; //if(!$validation_result['error']){ $loginError = ''; unset($data['confirm_password'], $data['register_submit']); //die('hello'); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/users/"; $data['op'] = 'register'; $data['social_media_id'] = $social_media_id; $data['status_id'] = $data['user_type_id'] == 4 ? 9 : 5; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 201) { $content = json_decode($res->getBody(), true); $common->addChatAccount($this->getServiceLocator()->get('Config')['chatpath']['url'], $content, $data, $request); // Creating account for live chat $newsletter = $content['user_type_id'] == 3 ? 1 : 4; $common->addFeature($api_url, array('user_id' => $content['id'], 'email' => 1, 'sms' => 1, 'chat' => 0, 'newsletter' => $newsletter)); // Adding user feature setting $common->sendMail($api_url, $content['email'], '', 21, '', array('/{{user_name}}/i'), array($content['first_name'] . ' ' . $content['last_name'])); $session->userid = $content['id']; $session->first_name = $content['first_name']; $session->last_name = $content['last_name']; $session->email = $content['email']; $session->user_name = $content['user_name']; $session->user_type_id = $content['user_type_id']; $session->user_data = $content; // adding default subscription if ($session->user_type_id == 3) { $common->addSubscription($api_url, array('user_id' => $session->userid)); } $auth->wordpress_create_user($session->user_name, $session->email, $data['confirm_password']); $auth->wordpress_login($session->user_name); $bookingData = new Container('bookingData'); //var_dump($res); die; //return ($session->user_type_id == 4) ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard')); if (isset($bookingData->bookingData)) { return $this->redirect()->toRoute('booking', array('action' => 'schedule', 'id' => $bookingData->sp)); } else { if ($this->getRequest()->getQuery('lasturl') != '') { return $this->redirect()->toUrl($this->getRequest()->getQuery('lasturl')); } else { return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard')); } } //return $this->redirect()->toRoute(null, $redirectUrl); } else { $errors = json_decode($res->getBody(), true); foreach ($errors as $key => $value) { if (isset($value[0])) { $register_form->setMessages(array($key => array($value[0]))); } } $this->errors = $register_form->getMessages(); // added by Ritesh to get error messages } //var_dump($errors); die; //}// validation condition } else { $this->errors = $register_form->getMessages(); } } $view = new ViewModel(array('form' => $form, 'register_form' => $register_form, 'loginError' => $loginError, 'fb_login' => $common_object, 'errors' => $this->errors)); $view->setTemplate('application/login/index.phtml'); return $view; }
public function getcontactlistAction() { $request = $this->getRequest(); if ($request->isPost()) { $api = new Api(); $page = $request->getPost('page'); $user_id = $request->getPost('user_id'); $recordsPerPage = $request->getPost('items'); if ($page != '' && $user_id != '' && $recordsPerPage != '') { $data = array('page' => $page, 'no_of_records' => $recordsPerPage, 'from_user_id' => $user_id); //print_r($data); exit; $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $contact_res = $api->curl($api_url . "/api/messages/", $data, "GET"); //echo '<pre>'; print_r($contact_res); exit; if ($contact_res->getStatusCode() == 200) { $content = json_decode($contact_res->getBody(), true); //echo '<pre>'; print_r($content['results']); exit; echo json_encode($content['results']); die; } } } exit; }
public function unsubscribeAction() { $status = array(); $error = array(); $token = $this->params()->fromRoute('id'); if ($token != "" && strlen($token) == 44) { $model = new Common(); $id = $model->getDecode($token); if ($id != "" && is_numeric($id)) { $api = new Api(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $newsletter_res = $api->curl($api_url . "/api/newslettersubscription/" . $id . "/", array("status_id" => 0), "PUT"); if ($newsletter_res->getStatusCode() == 200) { $status = array('status' => 1, 'msg' => 'Your Email is sucessfully unsubscribe for newsletter..!!'); } else { $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again."); } } else { $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again."); } } else { return $this->redirect()->toUrl('/contact'); } return new ViewModel(array('status' => $status)); }
public function indexAction() { $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $api = new Api(); $auth = new FrontEndAuth(); $error = ""; $redirectUrl = array('controller' => 'index'); if ($auth->hasIdentity()) { return $this->redirect()->toRoute(null, $redirectUrl); } $form = new ForgetPasswordForm(); $request = $this->getRequest(); if ($request->isPost()) { $model = new ForgetPassword(); $form->setInputFilter($model->getInputFilter()); $data = $request->getPost()->toArray(); $form->setData($data); if ($form->isValid()) { unset($data['submit']); $random_password = $model->generateRandomPassword(); $data['password'] = $random_password; $session = new Container('frontend'); $url = $api_url . "/api/useractivity/"; $data['op'] = 'forgotpassword'; $res = $api->curl($url, $data, "POST"); //var_dump($res); die; if ($res->getStatusCode() == 200) { $model = new Common(); if ($template = $model->emailTemplate($api_url, 3)) { $content = json_decode($res->getBody(), true); // '{{user_first_name}}', '{{username}}', '{{password}}' //$content['first_name'], $content['user_name'], $random_password), $template['content']); $patterns = array('/{{user_first_name}}/i', '/{{username}}/i', '/{{password}}/i'); $replacements = array($content['first_name'], '<strong>' . $content['user_name'] . '</strong>', '<strong>' . $random_password . '</strong>', '<strong>' . $getservices . '</strong>'); $mail = new Message(); $transport = new \Zend\Mail\Transport\Sendmail(); $html = new MimePart(preg_replace($patterns, $replacements, $template['content'])); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $url = $api_url . "/api/useractivity/"; $data = array('email' => $content['email'], 'password' => $random_password); $data['op'] = 'resetpassword'; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 200) { $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($content['email'], '')->setSubject($template['subject']); $transport->send($mail); $error = false; $msg = "A mail has been send to " . $content['email'] . " ,Please check "; } else { $error = true; $msg = "Unable to set password..!! "; } // echo json_encode(array('status' => 1, 'msg' => 'Business card sent to the email address..!!')); } else { $error = true; $msg = "Unable to find mail template..!!"; //echo json_encode(array('status' => 0, 'msg' => 'Unable to find mail template..!!')); } /* $content = json_decode($res->getBody(), true); $forget_pass_url = $api_url."/api/emailtemplate/3/"; $forget_pass_res = $api->curl($forget_pass_url, array(), "GET"); //print_r($forget_pass_res); die; if($forget_pass_res->getStatusCode() == 200) { $template = json_decode($forget_pass_res->getBody(), true); $template_data = str_replace(array('{{user_first_name}}', '{{username}}', '{{password}}' ), array($content['first_name'], $content['user_name'], $random_password), $template['content']); $wp_user_detail = $auth->wordpress_user_detail($content['user_name']); $auth->wordpress_set_password($random_password, $wp_user_detail->ID); $reset_data['op'] = 'resetpassword'; $reset_data['email'] = $content['email']; $reset_data['password'] = $random_password; $reset_res = $api->curl($url, $reset_data, "POST"); $mail = new \Zend\Mail\Message(); $html = new \Zend\Mime\Part($template_data); $html->type = "text/html"; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); //$content['email'] $mail->setBody($body) ->setFrom($template['fromEmail'], 'Ovessence') ->addTo('*****@*****.**', $content['first_name'].' '.$content['last_name']) ->setSubject($template['subject']); $transport = new \Zend\Mail\Transport\Sendmail($template['fromEmail']); $transport->send($mail); $error = "A mail has been send to ". $content['email'] ." ,Please check "; }*/ } else { if ($res->getStatusCode() == "404") { $error = true; $msg = "User with given email does not exist"; } else { $error = true; $msg = $res->getReasonPhrase(); } } } } $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg)); $view->setTemplate('application/forgetPassword/index.phtml'); return $view; }
public function indexAction() { $api = new Api(); $auth = new FrontEndAuth(); $session = new Container('frontend'); $loginError = ""; $seturl = $this->getRequest()->getQuery('last_url'); //$redirectUrl = 'http://blog.ovessence.in/'; if ($auth->hasIdentity()) { if ($session->status_id != 3) { //$redirectUrl = array('controller' => 'practitioner', 'action' => 'list'):array('controller' => 'practitioner', 'action' => 'dashboard'); return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard')); } else { $loginError = "Sorry your are suspended to access this site ..!! "; $auth->logout($redirectUrl); } } $form = new LoginForm(); $register_form = new RegisterForm(); //$forWishlist = new Container('last_url'); $request = $this->getRequest(); if ($request->isPost()) { $login = new Login(); $form->setInputFilter($login->getInputFilter()); $data = $request->getPost()->toArray(); $form->setData($data); if ($form->isValid()) { //unset($data['rememberme'], $data['submit']); $bookingData = new Container('bookingData'); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $url = $api_url . "/api/useractivity/"; //$data = array("username" => "sazid1s", "password" => "123456", "op" => "login"); $data['op'] = 'login'; $res = $api->curl($url, $data, "POST"); //var_dump($res); die; if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); if ($content['status_id'] != 3) { //Get verifiy status $url = $api_url . "/api/userverification/?user_id=" . $content['id']; $res = $api->curl($url, array(), "GET"); $result = json_decode($res->getBody(), true); $emailStatus = 0; $smsStatus = 0; if (count($result) > 0) { // retrieving verification code foreach ($result as $userid) { // email validation where 1:- email if ($userid['verification_type_id'] == 1) { $emailStatus = $userid['verification_status']; } // sms validation where 2:- for sms if ($userid['verification_type_id'] == 2) { $smsStatus = $userid['verification_status']; } } } //End:- Get verifiy status $session->userid = $content['id']; $session->first_name = $content['first_name']; $session->last_name = $content['last_name']; $session->email = $content['email']; $session->user_name = $content['user_name']; $session->user_type_id = $content['user_type_id']; $session->user_data = $content; $session->status_id = $content['status_id']; $session->last_login = $content['last_login_prev']; $session->email_verification_status = $emailStatus; $session->sms_verification_status = $smsStatus; // SET Cookies $time = $data['rememberme'] == 'yes' ? time() + 365 * 60 * 60 * 24 : time() - 4; $cookie = new SetCookie('username', $content['user_name'], $time); // now + 1 year $cookie1 = new SetCookie('password', $data['Pass'], $time); // now + 1 year $cookie2 = new SetCookie('rememberme', $data['rememberme'], $time); // now + 1 year $response = $this->getResponse()->getHeaders(); $response->addHeader($cookie); $response->addHeader($cookie1); $response->addHeader($cookie2); // End set cookies if ($data['rememberme'] == 'yes') { setcookie("user_name", $content['user_name'], time() + 60 * 60 * 1); setcookie("password", $data['Pass'], time() + 60 * 60 * 1); /* expire in 1 hour */ } $auth->wordpress_login($session->user_name); $redirectUrl = $session->user_type_id == 4 ? array('controller' => 'consumer', 'action' => 'dashboard') : array('controller' => 'practitioner', 'action' => 'dashboard'); if (isset($bookingData->bookingData)) { return $this->redirect()->toRoute('booking', array('action' => 'schedule', 'id' => $bookingData->sp)); } else { if ($this->getRequest()->getQuery('lasturl') != '') { return $this->redirect()->toUrl($this->getRequest()->getQuery('lasturl')); } else { return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard')); } } } //Status check $loginError = "Sorry your are suspended to access this site ..!! "; //return $this->redirect()->toUrl($redirectUrl); } else { $loginError = "Username or Password is incorrect"; } } } else { $username = $this->getRequest()->getHeaders()->get('Cookie')->username ? $this->getRequest()->getHeaders()->get('Cookie')->username : ''; $password = $this->getRequest()->getHeaders()->get('Cookie')->password ? $this->getRequest()->getHeaders()->get('Cookie')->password : ''; $rememberme = $this->getRequest()->getHeaders()->get('Cookie')->password ? $this->getRequest()->getHeaders()->get('Cookie')->rememberme : ''; $form->get('Pass')->setValue($password); $form->get('user_name')->setValue($username); $form->get('rememberme')->setValue($rememberme); } return new ViewModel(array('form' => $form, 'register_form' => $register_form, 'loginError' => $loginError, 'setUrl' => $seturl)); }
public function adminNewsletterAction() { //set_time_limit(0); $api = new Api(); $common = $this->getServiceLocator()->get('Application\\Model\\Common'); $users = $this->getServiceLocator()->get('Admin\\Model\\UsersTable'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $data = array('status_id' => '1', 'created_by' => '1'); $result = $common->adminNewsletters($api_url, $data); $consumer = new Consumers(); // Start :- Get admin email id $res = $consumer->getConsumerdetails($api_url, 1); if (count($res) > 0) { $adminEmailId = $res['email']; } if (count($result) > 0) { foreach ($result as $details) { if ($details['created_by'] == "1") { // newsletter only created by admin //if ((strtotime($details['send_date']) < strtotime('+1 days')) || $details['send_date'] == null) { if (strtotime($details['send_date']) === strtotime('today') || $details['send_date'] == null) { /* new code to get list of recievers for newsletter with usertype condition : starts here pi28jan */ if ($details['user_type_id'] == "1") { // send to all users available + subscribers $res = $users->fetchAll(false, array()); $newsletter_subs = $common->newsletterSubscription($api_url, array('status_id' => '1', 'send_status' => '0')); } else { if ($details['user_type_id'] == "3") { // send to all service providers $res = $users->fetchAll(false, array('user_type' => '3')); } else { if ($details['user_type_id'] == "4") { // send to all consumers $res = $users->fetchAll(false, array('user_type' => '4')); } else { if ($details['user_type_id'] == "8") { // send to all newsletter subscribers $res = $users->fetchAll(false, array('user_type' => '8')); $newsletter_subs = $common->newsletterSubscription($api_url, array('status_id' => '1', 'send_status' => '0')); } else { $res = ''; } } } } $recievers_list = array(); if (isset($res)) { foreach ($res as $list) { $userFeatures = $common->getFeatures($api_url, $list->id); if ($userFeatures['newsletter'] == 1 || $userFeatures['newsletter'] == 4) { $recievers_list[] = $list->email; } } } if (isset($newsletter_subs) && count($newsletter_subs)) { foreach ($newsletter_subs as $ns) { array_push($recievers_list, $ns['email']); $api->curl($api_url . '/api/newslettersubscription/' . $ns['id'] . '/', array('send_status' => '1'), "PUT"); } unset($newsletter_subs); } /* code : ends here */ if (count($recievers_list) > 0) { //Send mail foreach ($recievers_list as $email) { echo $email; $common->sendMail($api_url, $email, $adminEmailId, '', array('subject' => $details['subject'], 'message' => $details['message'])); //sleep(180); } } } } } } exit; }
public function transactionsAction() { $api = new Api(); $trans = new Transactions(); $model = new Practitioners(); $common = new Common(); $bookingModel = new Bookings(); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $request = $this->getRequest(); if ($request->isPost()) { $page = $request->getPost('page'); $recordsPerPage = $request->getPost('items'); switch ($request->getPost('action')) { case 'subscriptions': $subscriptions = $bookingModel->getBookings($api_url, '', $session->userid, '', $page, $recordsPerPage, '', '', 'subscription'); echo json_encode($subscriptions['results']); break; case 'bookings': $bookings = $bookingModel->getBookings($api_url, $session->userid, '', '', $page, $recordsPerPage); echo json_encode($bookings['results']); break; } exit; } $auth = new FrontEndAuth(); if (!$auth->hasIdentity(3)) { return $this->redirect()->toRoute('login', array('action' => 'index')); } $res = $api->curl($api_url . "/api/spusers/" . $session->userid . "/", array(''), "GET"); if ($res->getStatusCode() != 200) { return $this->redirect()->toRoute('practitioner', array('action' => 'list')); } $data = $this->getSpdata($res); // getting banner for this page $banners = $common->getBanner($api_url, 4); return new ViewModel(array('user_id' => $session->userid, 'content' => $data['content'], 'notifications' => $model->getNotifications($api_url), 'booking_total' => $bookingModel->getBookings($api_url, $session->userid)['count'], 'subs_total' => $bookingModel->getBookings($api_url, '', $session->userid, '', '', '', '', '', 'subscription')['count'], 'banners' => $banners)); }
public function wishlistAction() { $request = $this->getRequest(); $session = new Container('frontend'); $api = new Api(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $data = array('user_id' => $request->getPost('sp_id'), 'created_by' => $session->userid, 'created_date' => date('Y-m-d h:i:s'), 'service_id' => $request->getPost('service_id'), 'service_duration_id' => $request->getPost('duration'), 'current_price' => $request->getPost('priceDel'), 'status_id' => 1); $url = $api_url . "/api/wishlist/"; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 201 || $res->getStatusCode() == 200) { echo "Congratulation ! you have a new practitioner on your wishlist"; } else { echo "Not Added Into Wishlist"; } exit; }