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() { $auth = new FrontEndAuth(); if (!$auth->hasIdentity()) { return $this->redirect()->toRoute('login', array('action' => 'index')); } $form = new VerificationForm(); $common = new Common(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $session = new Container('frontend'); if ($session->user_type_id == 3) { $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $subscriptionDetails = $common->getSubscriptiondetails($api_url, '', true); if (!isset($subscriptionDetails['features']) || !is_array($subscriptionDetails['features']) || !in_array(4, $subscriptionDetails['features'])) { $this->flashMessenger()->addErrorMessage("Either you have not subscribed any subscription or your subscription don't have permission to access this section..!!"); return $this->redirect()->toRoute('practitioner', array('action' => 'dashboard')); } } /* $getvalue = $this->checkuserexistence(); $msg=''; $class =''; if(count($getvalue)>0){ foreach($getvalue as $data){ // Email id condition if($data['verification_type_id']==1){ // already verified or verification code recieve (verification pending) $flag = ($data['verification_status']==1)?2:1; $msg = ($flag ==2)?"Your email id already verified":"Verified code already send on your registered email id. Please check it to get verified code"; $class = ($flag ==2)?"success-msg":"error-msg"; } else{ // For new user $flag = 3; } // Contact number condition if($data['verification_type_id']==2){ // already verified $noflag = ($data['verification_status']==1)?2:1; $msg = ($noflag ==2)?"Your number already verified":"Verified code already send on your registered number. Please check it to get verified code"; $class = ($flag ==2)?"success-msg":"error-msg"; } else{ // For new user $noflag = 3; } } }else{ // For new user $flag = 3; } */ // getting banners $banners = $common->getBanner($api_url, 17); $view = new ViewModel(array('form' => $form, 'flag' => $flag, 'noflag' => $noflag, 'msg' => $msg, 'class' => $class, 'banners' => $banners)); return $view; }
public function indexAction($redirectUrl = array('controller' => 'login')) { //var_dump($redirectUrl); die; $auth = new FrontEndAuth(); $auth->logout($redirectUrl); $auth->wordpress_logout(); return $this->redirect()->toRoute(null, $redirectUrl); /* return $this->redirect()->toRoute(null,array('controller'=>'Login', 'action' => 'dashboard','params' =>$params)); * */ }
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 onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $serviceManager = $e->getApplication()->getServiceManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); $this->bootstrapSession($e); // Added by sazid to use common data in every page $application = $e->getParam('application'); $viewModel = $application->getMvcEvent()->getViewModel(); $api_url = $serviceManager->get('Config')['api_url']['value']; $session_apiurl = new Container('api_url'); $session_apiurl->apiurl = $api_url; $apiCall = new Api(); $getCommonData = $apiCall->getCommonData($api_url); foreach ($getCommonData as $key => $val) { if (!empty($val)) { $viewModel->{$key} = $val; } } // Hybrid view for ajax calls (disable layout for xmlHttpRequests) $eventManager->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractController', MvcEvent::EVENT_DISPATCH, function (MvcEvent $event) { /** * @var Request $request */ $request = $event->getRequest(); $viewModel = $event->getResult(); $vModel = $event->getViewModel(); $vModel->setVariable('api_url', $event->getApplication()->getServiceManager()->get('Config')['api_url']['value']); $userAuth = new FrontEndAuth(); if ($userAuth->hasIdentity()) { $practitioner = new Practitioners(); $userSession = new Container('frontend'); $userType = $userSession->user_type_id == '3' ? 'practitioner' : 'consumer'; $vModel->setVariable('notifications', $practitioner->getNotifications($event->getApplication()->getServiceManager()->get('Config')['api_url']['value'], $userType)); } if ($request->isXmlHttpRequest()) { $viewModel->setTerminal(true); } return $viewModel; }, -95); $eventManager->attach('route', array($this, 'doHttpsRedirect')); }
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 authenticateAction() { $form = $this->getForm(); $redirect = 'admin/login'; $request = $this->getRequest(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { //check authentication... $this->getAuthService()->getAdapter()->setIdentity($request->getPost('username'))->setCredential($request->getPost('password')); $result = $this->getAuthService()->authenticate(); foreach ($result->getMessages() as $message) { //save message temporary into flashmessenger $this->flashmessenger()->addMessage($message); } if ($result->isValid()) { $redirect = 'admin'; /* //check if it has rememberMe : if ($request->getPost('rememberme') == 1 ) { $this->getSessionStorage() ->setRememberMe(1); //set storage again $this->getAuthService()->setStorage($this->getSessionStorage()); } */ // SET Cookies $time = $request->getPost('rememberme') == 1 ? time() + 365 * 60 * 60 * 24 : time() - 4; $cookie = new SetCookie('username', $request->getPost('username'), $time); // now + 1 year $cookie1 = new SetCookie('password', $request->getPost('password'), $time); // now + 1 year $cookie2 = new SetCookie('rememberme', $request->getPost('rememberme'), $time); // now + 1 year $response = $this->getResponse()->getHeaders(); $response->addHeader($cookie); $response->addHeader($cookie1); $response->addHeader($cookie2); // End set cookies $this->getAuthService()->setStorage($this->getSessionStorage()); $this->getAuthService()->getStorage()->write($request->getPost('username')); $wp_auth = new FrontEndAuth(); $wp_auth->wordpress_login($request->getPost('username')); // logging in wordpress account /* Setting logged in user details in session */ $user_details = new Container('user_details'); $user_details->details = array('user_id' => $result->user_id, 'user_type_id' => $result->user_type_id, 'user_name' => $result->getIdentity()); $user_permission = new Container('user_permission'); $user_permission->rights = $this->getServiceLocator()->get('Admin\\Model\\UserRightsTable')->getUserRightsArr($result->user_id); /* set last login time for user - starts here */ $username = $request->getPost('username'); $result = $this->getUsersTable()->getUser($username, 'user_name'); $result->last_login = date('Y-m-d H:i:s', time()); $this->getUsersTable()->saveUser($result, 'update_last_login'); /* set last login time for user - ends here */ } } } /* $session = new Container('user_permission'); print_r($session['rights']); exit; */ return $this->redirect()->toRoute($redirect); }
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 invoiceAction() { $id = (int) $this->params()->fromRoute('id', 0); if (!$id) { return $this->redirect()->toRoute('home'); } $auth = new FrontEndAuth(); $bookingModel = new Bookings(); $consumers = new Consumers(); $common = new Common(); $practitioners = new Practitioners(); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($auth->hasIdentity(3)) { // service provider invoice $data = $bookingModel->getBookings($api_url, '', '', '', '', '', '', $id, 'subscription'); $userDetails = $practitioners->getSPDetails($api_url, $session->userid); } else { return $this->redirect()->toRoute('home'); } $userDetails['address'] = json_decode($userDetails['address'][0], true); $userDetails['contact'] = json_decode($userDetails['contact'][0], true); //print_r($userDetails['address']); exit; if (isset($data['results']) && count($data['results']) == 1) { if ($this->getRequest()->getQuery('print') == 1) { $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails)); $view->setTemplate('application/membership/printinvoice.phtml'); $printData = $this->getServiceLocator()->get('viewrenderer')->render($view); // Store in PDF format $dompdf = new \DOMPDF(); $dompdf->load_html($printData); $dompdf->render(); $dompdf->stream('invoice.pdf', array('Attachment' => 0)); exit; } else { $banners = $common->getBanner($api_url, 16); return new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails, 'id' => $id, 'banners' => $banners)); } } else { return $this->redirect()->toRoute('home'); } return new viewModel($this->invoicedetails()); }
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 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 ratingsAction() { $id = $this->params()->fromRoute('id'); $getparams = $this->getRequest()->getQuery(); if (!empty($id) && $id != null && $id != "") { $auth = new FrontEndAuth(); if (!$auth->hasIdentity(4)) { return $this->redirect()->toUrl('/login'); } $ratingType = array(); $ratingData = array(); $session = new Container('frontend'); $model = new Practitioners(); $bookingModel = new Bookings(); $common = new Common(); $api = new Api(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $reviewFlag = false; $user_id = $session->userid; if (isset($getparams['review']) && $getparams['review'] == 1 && isset($getparams['s_id'])) { // check service $serivce_id = $getparams['s_id']; $sp_id = $id; $result = $bookingModel->getBookings($api_url, $sp_id, $user_id, '4', "", "", $serivce_id); $reviewFlag = $model->setreviewFlg($result); //get service provider details $sp_res = $api->curl($api_url . "/api/spusers/" . $sp_id . "/", array(), "GET"); if ($sp_res->getStatusCode() == 200) { $spData = json_decode($sp_res->getBody(), true); } } if ($reviewFlag == true) { //get previous ratings $ratings_data_res = $api->curl($api_url . "/api/rating/", array("users_id" => $id, "service_id" => $serivce_id, "created_by" => $user_id), "GET"); if ($ratings_data_res->getStatusCode() == 200) { $ratingData = json_decode($ratings_data_res->getBody(), true); } //Check if rating data exits otherwise send $ratingType for fresh reviews. if (empty($ratingData)) { if (empty($ratingData)) { $rating_res = $api->curl($api_url . "/api/ratingtype/", array("status_id" => 1), "GET"); if ($rating_res->getStatusCode() == 200) { $ratingType = json_decode($rating_res->getBody(), true); } } } } else { return $this->redirect()->toUrl('/consumer/dashboard'); } } else { return $this->redirect()->toUrl('/consumer/dashboard'); } // getting banner for this page $banners = $common->getBanner($api_url, 5); return new viewModel(array("ratingType" => $ratingType, "ratingData" => $ratingData, "spData" => $spData, "service_id" => $serivce_id, 'banners' => $banners)); }
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 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 detailsAction() { $request = $this->getRequest(); if ($request->isPost()) { $auth = new FrontEndAuth(); $bookingModel = new Bookings(); $id = $request->getPost('booking'); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($auth->hasIdentity(4)) { $bookingDetails = $bookingModel->getBookings($api_url, '', $session->userid, '', '', '', '', $id); } else { if ($auth->hasIdentity(3)) { $bookingDetails = $bookingModel->getBookings($api_url, $session->userid, '', '', '', '', '', $id); } else { echo json_encode(array('status' => 0, 'msg' => 'Not authorized to see the bookings details. Please login first..!!')); exit; } } if ($bookingDetails != false) { echo json_encode(array('status' => 1, 'data' => $bookingDetails['results'])); } else { echo json_encode(array('status' => 0, 'msg' => 'No booking found for this reference..!!')); } } exit; }