public function loginAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $storage = new Zend_Auth_Storage_Session(); $storage->clear(); } $users = new Application_Model_User(); $form = new Application_Form_Login(); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'user'); $authAdapter->setIdentityColumn('name')->setCredentialColumn('password'); $authAdapter->setIdentity($data['name'])->setCredential($data['password']); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $storage = new Zend_Auth_Storage_Session(); $storage->write($authAdapter->getResultRowObject(array('id', 'name', 'image'))); if ($auth->getIdentity()->name == 'admin') { $this->redirect("Order/adminhome"); } elseif ($auth->getIdentity()->name != 'admin') { $this->redirect("Order/adduserorder"); } } else { $this->view->errorMessage = "Invalid username or password. Please try again."; } } } }
/** * Login * * @param array $data * @return array */ public function login($data) { foreach ($data as $param) { if ($param == null || $param == '') { $return['status'] = 0; $return['message'] = 'Please, fill all the fields.'; return $return; } } $storage = new Zend_Auth_Storage_Session('www.beyourlight.co.uk'); $auth = Zend_Auth::getInstance(); $authAdapter = $this->getAuthAdapter(); $authAdapter->setIdentity($data['Username'])->setCredential($data['Password']); $result = $auth->authenticate($authAdapter)->isValid(); $storage->write($authAdapter->getResultRowObject(array('UserID', 'FirstName', 'LastName', 'Username', 'Role'))); $message = '. User agent: ' . $_SERVER['HTTP_USER_AGENT']; if ($result) { // update last login $currentTime = Site_View_Helper_Date::formatDate(); $data = array(); $data['LastLoginDate'] = $currentTime; $this->updateUser($data); // register in access log and forward to home $this->_accessLog->insertAccessLog($storage->read()->Username, Enum_ActivityType::Login, $message); $return['status'] = 1; } else { // register in access log $this->_accessLog->insertAccessLog($data['Username'], Enum_ActivityType::FailedLogin, $message); $return['status'] = 0; $return['message'] = "Invalid username or password. Please try again."; } return $return; }
public function indexAction() { $storage = new Zend_Auth_Storage_Session('admin_type'); $data = $storage->read(); if ($data && $data != null) { $this->_redirect('admin/'); } $this->view->messages = $this->_flashMessenger->getMessages(); //$this->_helper->layout()->disableLayout(); $this->_helper->layout()->setLayout('adminlogin'); $users = new Admin_Model_DbTable_AdminUsers(); if ($this->getRequest()->isPost()) { $formdata = $this->getRequest()->getPost(); $enc_pwd = md5($formdata['user_password']); //print_r($formdata);exit; $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), TBL_ADMIN); $authAdapter->setIdentityColumn('user_name')->setCredentialColumn('user_password'); $authAdapter->setIdentity($formdata['user_name'])->setCredential($enc_pwd); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $storage = new Zend_Auth_Storage_Session('admin_type'); $storage->write($authAdapter->getResultRowObject()); $this->_redirect('admin/'); } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } }
public function write($contents) { if (!$this->_session) { $this->_session = new Zend_Session_Namespace($this->_namespace); } parent::write($contents); }
public function indexAction() { if (!empty($this->sessUserInfo)) { $this->_redirect('user/'); } //$this->_helper->layout()->setLayout('publisherlogin'); $this->view->messages = $this->_flashMessenger->getMessages(); $formData = array(); $formErrors = array(); if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); //print_r($formData);exit; if (!isset($formData['user_name']) || trim($formData['user_name']) == "") { $formErrors['user_name'] = "Please enter your username"; } if (!isset($formData['user_password']) || trim($formData['user_password']) == "") { $formErrors['user_password'] = "******"; } if (count($formErrors) == 0) { //echo md5($formData['user_password']); $user_pwd = md5($formData['user_password']); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($this->modelCompanies->getAdapter(), TBL_COMPANIES); $authAdapter->setIdentityColumn('user_email')->setCredentialColumn('user_password'); $authAdapter->setIdentity($formData['user_name'])->setCredential($user_pwd); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $userInfo = $authAdapter->getResultRowObject(); if ($userInfo->account_type == '2' || $userInfo->account_type == '3') { //AND parent_id=0 if ($this->modelCompanies->isExist('status=1 and id=' . $userInfo->id)) { $storage = new Zend_Auth_Storage_Session('account_type'); $storage->write($userInfo); $this->_redirect('user/'); } else { if ($this->modelCompanies->isExist('status=1 AND parent_id>0 and id=' . $userInfo->id)) { $this->view->errorMessage = '<div class="div-error">You can only login through mobile app.</div>'; } else { $this->view->errorMessage = '<div class="div-error">Sorry, user is not active</div>'; } } } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Please enter username and password</div>'; } } $sessionMsg = new Zend_Session_Namespace('step1Msg'); $sessionMsg->formData = $formData; $sessionMsg->formErrors = $formErrors; $sessionMsg->errorMessage = $this->view->errorMessage; //$this->_redirect('/'); }
public function indexAction() { if (!empty($this->sessPublisherInfo)) { $this->_redirect('publisher/'); } //$this->_helper->layout()->setLayout('publisherlogin'); $this->view->messages = $this->_flashMessenger->getMessages(); $formData = array(); $formErrors = array(); if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); //print_r($formData);exit; if (!isset($formData['user_name']) || trim($formData['user_name']) == "") { $formErrors['user_name'] = "Please enter your username"; } if (!isset($formData['user_password']) || trim($formData['user_password']) == "") { $formErrors['user_password'] = "******"; } if (count($formErrors) == 0) { $usermailID = trim($formData['user_name']); $getLoginRecord = $this->modelPublishers->getInfoByLoginEmail($usermailID); if (count($getLoginRecord) > 0) { for ($countUser = 0; $countUser < count($getLoginRecord); $countUser++) { if ($getLoginRecord[$countUser]['user_type'] != 'author') { $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($this->modelPublishers->getAdapter(), TBL_PUBLISHERS); $authAdapter->setIdentityColumn('emailid')->setCredentialColumn('password'); $authAdapter->setIdentity($formData['user_name'])->setCredential(md5($formData['user_password'])); $authAdapter->getDbSelect()->where('user_type="' . $getLoginRecord[$countUser]['user_type'] . '"'); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $userInfo = $authAdapter->getResultRowObject(); if ($this->modelPublishers->isExist('profile_status=1 AND id=' . $userInfo->id)) { $storage = new Zend_Auth_Storage_Session('publisher_type'); $storage->write($userInfo); $this->_redirect('publisher/'); } else { $this->view->errorMessage = '<div class="div-error">Sorry, user is not active</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } } } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Please enter username and password</div>'; } } $sessionMsg = new Zend_Session_Namespace('step1Msg'); $sessionMsg->formData = $formData; $sessionMsg->formErrors = $formErrors; $sessionMsg->errorMessage = $this->view->errorMessage; //$this->_redirect('/'); }
public function loginUser($data) { $id = $this->getIdByUsername($data['username']); $user = $this->find((int) $id)->current(); $salt = $user['password_salt_usr']; $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($this->getAdapter(), 'users_usr'); $authAdapter->setIdentityColumn('login_name_usr')->setCredentialColumn('password_usr'); $authAdapter->setIdentity($data['username'])->setCredential(md5($salt . $data['password'] . $salt)); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $storage = new Zend_Auth_Storage_Session(); $storage->write($authAdapter->getResultRowObject()); return true; } return false; }
public function indexAction() { //$this->_helper->layout()->disableLayout(); //$this->_helper->layout()->setLayout('companylogin'); $this->view->messages = $this->_flashMessenger->getMessages(); $formData = array(); $formErrors = array(); if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); //print_r($formData);exit; if (!isset($formData['user_name']) || trim($formData['user_name']) == "") { $formErrors['user_name'] = "Please enter your username"; } if (!isset($formData['user_password']) || trim($formData['user_password']) == "") { $formErrors['user_password'] = "******"; } if (count($formErrors) == 0) { $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($this->modelCompanies->getAdapter(), TBL_COMPANIES); $authAdapter->setIdentityColumn('user_email')->setCredentialColumn('user_password'); $authAdapter->setIdentity($formData['user_name'])->setCredential($formData['user_password']); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $userInfo = $authAdapter->getResultRowObject(); if ($this->modelCompanies->isExist('status=1 AND id=' . $userInfo->id)) { $storage = new Zend_Auth_Storage_Session('company_type'); $storage->write($userInfo); $this->_redirect('company/'); } else { $this->view->errorMessage = '<div class="div-error">Sorry, user is not active</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Invalid username or password</div>'; } } else { $this->view->errorMessage = '<div class="div-error">Please enter username and password</div>'; } } $sessionMsg = new Zend_Session_Namespace('companyStep1Msg'); $sessionMsg->formData = $formData; $sessionMsg->formErrors = $formErrors; $sessionMsg->errorMessage = $this->view->errorMessage; //$this->_redirect('/'); /uncomment this if you want to login from front }
public function loginAction() { $goto = $this->getRequest()->getParam('goto'); if (@$this->_me) { if ($goto) { $this->_redirect("/{$goto}"); } else { $this->redirect("/track"); } } $this->view->goto = $goto; if ($this->getRequest()->isPost()) { //Get form data from post array $data = $this->_request->getPost(); if ($data['email'] == '' || $data['password'] == '') { $this->view->error = "Please provide your email address and password."; return false; } //Log user in to session $users = new Users(); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'users'); $authAdapter->setIdentityColumn('email')->setCredentialColumn('password'); $authAdapter->setIdentity($data['email'])->setCredential(sha1($data['password'])); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { Zend_Session::rememberMe(31536000); $credentials = base64_encode(serialize(array('email' => $data['email'], 'password' => sha1($data['password'])))); //Set login cookie setcookie('autl', $credentials, time() + 31536000, '', '.' . $_SERVER['HTTP_HOST']); $storage = new Zend_Auth_Storage_Session(); $storage->write($authAdapter->getResultRowObject()); $this->_redirect($data['goto']); } else { $this->view->error = "Invalid email or password. Please try again."; } } }
public function loginAction() { $users = new Application_Model_DbTable_Users(); $form = new Application_Form_LoginForm(); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'users'); $authAdapter->setIdentityColumn('username')->setCredentialColumn('password'); $authAdapter->setIdentity($data['username'])->setCredential($data['password']); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $storage = new Zend_Auth_Storage_Session(); $storage->write($authAdapter->getResultRowObject()); $this->_redirect('auth/home'); } else { $this->view->errorMessage = "Invalid username or password. Please try again."; } } } }
/** * @param values * function to check whether emailaddress and password valid or not * if it is valid user enters to his/her account */ protected function _process($values) { $adapter = $this->_getAuthAdapter(); $userMapper = new User_Model_ClientDataMapper(); $passPhrase = $userMapper->getUserPassPhrase($values['emailAddress']); if ($passPhrase) { $passwordHash = sha1($values['password'] . $passPhrase->usrpassphrase); $email = strtolower($values['emailAddress']); $adapter->setIdentity(trim($email))->setCredential($passwordHash); $auth = Zend_Auth::getInstance(); try { $select = $adapter->getDbSelect(); $select->where('usruser_status_id = 1'); $result = $auth->authenticate($adapter); } catch (Zend_Exception $ex) { $this->view->errorMsg = $ex->getMessage() . "<br>"; Rdine_Logger_FileLogger::info($ex->getMessage()); throw new Exception($ex->getMessage()); } if ($result->isValid()) { $data = $adapter->getResultRowObject(); $loginProfile = $userMapper->getLoginProfile($data); $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $namespace = new Zend_Session_Namespace(); $loginProfile['lang'] = $namespace->lang; $storage->write($loginProfile); $userType = $loginProfile['Usertype']; if (($userType == "ADU" || $userType == "RSO" || $userType == "RSU" || $userType == "SRU" || $userType == "CUS") && $loginProfile['companyid'] != 1) { /*$companyMapper = new Administrator_Model_CompanyDataMapper(); $status = $companyMapper->getComapnyStatusById($loginProfile['companyid']); if($status == true){*/ $loginRes = array('Status' => true, 'Usertype' => $userType, 'loginprofile' => $loginProfile); /*}else{ $auth->clearIdentity(); return $loginRes = array('Status'=>false,'CompanyInActive'=>true); }*/ return $loginRes; } else { $loginRes = array('Status' => true, 'Usertype' => $userType, 'loginprofile' => $loginProfile); } //$LoginAttemptMapper = new User_Model_LoginAttemptsDataMapper(); //$LoginAttemptMapper->UpdateLoginAttempts($data['Email']); return $loginRes; } else { $userMapper = new User_Model_ClientDataMapper(); $userstatus = $userMapper->getUserStatusByEmail($values['emailAddress']); if ($userstatus['userstatusid'] == 3) { return $loginRes = array('Status' => false, 'UserNotApproved' => true); } else { if ($userstatus['userstatusid'] == 2) { return $loginRes = array('Status' => false, 'UserInActive' => true); } else { return $loginRes = array('Status' => false, 'isFormValid' => true); } } } } else { return $loginRes = array('Status' => false, 'isFormValid' => true); } }
public function AddSubscribedRestaurant(array $data) { try { $form = $this->getAddSubscribedRestaurantForm(); $stateid = null; $regionid = null; $cityid = null; $cityBd = array(); $regionBd = array(); $ngbhBd = array(); $restService = new Application_Service_Firm(); if ($data['cantfind'] == 1) { $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } if ($data['resCity']) { $cityid = $data['resCity']; $ngbhBd = $restService->GetNeighborhodByCityId_($cityid); $ngbhBd[] = array('key' => 'find', 'value' => "Can't Find Your Neighbourhood"); } } else { if ($data['cantfind'] == 2) { $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } } else { if ($data['cantfind'] == 3) { $form->cantfindregion->setRequired(true); $form->resRegion->setRequired(false); $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } $cityBd[] = array('key' => 'noCity', 'value' => "Can't Find Your City"); } else { if ($data['cantfind'] == 4) { $form->cantfindstate->setRequired(true); $form->resState->setRequired(false); $form->cantfindregion->setRequired(true); $form->resRegion->setRequired(false); $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } else { if ($data['cantfind'] == 0 || $data['cantfind'] == '') { if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } } } } } } if ($form->isValid($data)) { $imageadapter = $form->resImage->getTransferAdapter(); $logoadapter = $form->resLogo->getTransferAdapter(); $restname = trim($data['restName']); $paths = $restService->UploadImages($imageadapter, $logoadapter, $restname); // $imagepath = null; // $logopath = null; // if($paths){ // $imagepath = $paths['imagepath']; // $logopath = $paths['logopath']; // } $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $formData = $form->getValues(); $restaurant = new FirmManagement_Model_Firm(); $cuisineTypes = $formData['restype']; //$resCusisneType = array(); //foreach($cuisineTypes as $types){ $cusisneTypeObj = new FirmManagement_Model_FirmCuisine(); $cusisneTypeObj->setRestaurantTypeId($cuisineTypes); //$resCusisneType[] = $cusisneTypeObj; //} /*$reservSys = 'FALSE'; if($formData['restSubResSys'] == 1) { $reservSys = 'TRUE'; }*/ $restaddress = $formData['resAddress']; $paymentModes = $formData['resPayment']; $resPaymentMode = array(); foreach ($paymentModes as $types) { $paymentModeObj = new FirmManagement_Model_FirmPaymentOptions(); $paymentModeObj->setRestaurantPaymentTypeId($types); $resPaymentMode[] = $paymentModeObj; } $tagid = array(); $tagidString = ""; $tagidString = $formData['tagId']; if ($tagidString) { $tagid = explode(',', $tagidString); } /* Listed Restaurant $resByIdObj = new FirmManagement_Model_FirmById(); $resByIdObj->setRestaurantId($formData['restId']); $restaurantMapper = new FirmManagement_Model_FirmDataMapper(); $resDetails = $restaurantMapper->getRestaurantById($resByIdObj); $listedMapper = new FirmManagement_Model_ListedRestaurantsDataMapper(); $listedRes = $listedMapper->addRestaurant($resDetails); */ // $paymentModel = new Application_Model_RestaurantPaymentMode(); // $paymentMapper = new Application_Model_RestaurantPaymentModeDataMapper(); // $paymentModel->setId($formData['resPayment']); // $paymentObj = $paymentMapper->getPaymentModeById($paymentModel); if ($formData['restId']) { $restaurant->setRestListedResId($formData['restId']); } $latlong = ''; if ((int) $formData['cantfind'] < 2) { /* Reterving City By Id */ $cityModel = new Application_Model_City(); $cityMapper = new Application_Model_CityDataMapper(); $cityModel->setId($formData['resCity']); $cityObj = $cityMapper->getCityById($cityModel); $restaddress .= ", " . $cityObj->getDescription(); $latlong = Rdine_Geocode_GeocodingAdapter::getGeocodedLatitudeAndLongitude($restaddress); } if (!$formData['restLatitude'] == NULL && !$formData['restLongitude'] == NULL) { $googlemapstatus = 'TRUE'; } else { $googlemapstatus = 'FALSE'; } if ($googlemapstatus == 'TRUE') { $latitude = $formData['restLatitude']; $longitude = $formData['restLongitude']; } else { $latitude = NULL; $longitude = NULL; } $resgoogleimage = Rdine_Geocode_GeocodingAdapter::getGoogleRestaurantImage($latitude, $longitude); $categoryModel = new Application_Model_RestaurantCategory(); $categoryMapper = new Application_Model_RestaurantCategoryDataMapper(); $categoryModel->setCode('SUB'); $categoryObj = $categoryMapper->getIdByCode($categoryModel); if ($data['Usertype'] == "ADM" || $data['Usertype'] == "ADU") { $restaurant->setRestaurantownerid($formData['restowner'])->setcompanyid($data['companyid']); } else { $restaurant->setRestaurantownerid($formData['restowner'])->setcompanyid(1); } $restaurant->setRestaurantname($formData['restName'])->setRescapacity($formData['rescapacity'])->setRestemail($formData['emailAddress'])->setMaxpax($formData['maxpax'])->setRestaddress($formData['resAddress'])->setReststateid($formData['resState'])->setRestRegion($formData['resRegion'])->setRestCity($formData['resCity'])->setCantFindState($formData['cantfindstate'])->setCantFindRegion($formData['cantfindregion'])->setCantFindCity($formData['cantfindcity'])->setCantFindNeighbour($formData['cantfindneigh'])->setCantFind($formData['cantfind'])->setRestPaymentMode($resPaymentMode)->setResttypeid($cusisneTypeObj)->setResttimezone($formData['restimezone'])->setRestPrice($formData['resprice'])->setRestneighboorhood($formData['resNeighbour'])->setRestzipcode($formData['postalCode'])->setres_country_code($formData['countryCode'])->setRestphone($formData['resPhone'])->setRestfax($formData['resFax'])->setRestwebsite($formData['resWebsite'])->setRestmanagername($formData['resManager'])->setRestdesc($formData['resDescription'])->setRestDiningStyle($formData['restDiningStyle'])->setRestParking($formData['restParking'])->setRestParkDetails($formData['restParkDetails'])->setRestPrivParty($formData['restPrivParty'])->setRestPrivPartyContact($formData['restPrivPartyContact'])->setRestAdditDet($formData['restAdditDetails'])->setRestEntertainment($formData['restEntertainment'])->setRestsubforreservation('TRUE')->setReststatus(1)->setRestverifiedstatus(3)->setRestCreatedOn(date('Y-m-d H:i:s'))->setRestLatitude($latitude)->setRestLongtitude($longitude)->setRestGoogleMapStatus($googlemapstatus)->setRestGoogleImage($resgoogleimage)->setRestTimings($formData['restTimings'])->setRestCategory($categoryObj->getId())->setResCreatedDate(date('Y-m-d H:i:s'))->setRestCreatedBy($data['User_Id'])->setreslandmark($formData['restLandMark'])->setres_delevery($formData['restDelevery'])->setreslunch_buffet($formData['restLunchBuffet'])->setresdinner_buffet($formData['restDinnerBuffet'])->setres_wifi($formData['restWifi'])->setres_alcohol($formData['restAlcohol'])->setres_smoking($formData['restSmoke'])->setres_ac($formData['restAC'])->setres_catering($formData['restCatering'])->setres_kids_section($formData['restKidsSection'])->setres_party_allowed($formData['restPrivParty'])->setres_meal_category($formData['restMealType'])->setres_new_tag($formData['restnewtag'])->settag_id($tagid); if ($formData['restAvgMealPriceMax'] == '') { $restaurant->setresavg_mealprice_max(0); } else { $restaurant->setresavg_mealprice_max($formData['restAvgMealPriceMax']); } if ($formData['restAvgMealPriceMin'] == '') { $restaurant->setresavg_mealprice_min(0); } else { $restaurant->setresavg_mealprice_min($formData['restAvgMealPriceMin']); } $mapper = new FirmManagement_Model_FirmDataMapper(); $status = $mapper->addRestaurant($restaurant); $restid = $status['resid']; $ownerid = $restaurant->getRestaurantaownerid(); $mapper = new User_Model_ManagerDataMapper(); $status = $mapper->addPresid($restid, $ownerid); $storage = new Zend_Auth_Storage_Session(); $userdata = $storage->read(); $userdata['RestId'] = $restid; if ($userdata['Usertype'] == 'RSO') { $restNameByOwnObj = new FirmManagement_Model_FirmNamesByOwnerId(); $restNameByOwnObj->setRestOwnerId($userdata['User_Id']); $restMapper = new FirmManagement_Model_FirmDataMapper(); $restList = $restMapper->getRestaurantNamesByOwnerId($restNameByOwnObj); $userdata['restList'] = $restList; } else { $restNameByOwnObj = new FirmManagement_Model_FirmNamesByOwnerId(); $restNameByOwnObj->setRestId($restid); $restMapper = new FirmManagement_Model_FirmDataMapper(); $restList = $restMapper->getRestaurantNamesByOwnerId($restNameByOwnObj); $userdata['restList'] = $restList; } $storage->write($userdata); $folderRename = rename("images/restaurant_images/{$restname}/", "images/restaurant_images/{$restid}/"); $imagepath = null; $logopath = null; if ($paths) { $imagepath = $paths['imagepath']; $logopath = $paths['logopath']; $imagelogoRename = '/' . $restname . '/'; $restid = $restid; $imageRename = str_replace($imagelogoRename, '/' . $restid . '/', $imagepath); $logoRename = str_replace($imagelogoRename, '/' . $restid . '/', $logopath); $mapper1 = new FirmManagement_Model_FirmDataMapper(); $result = $mapper1->Updateimglogo($restid, $imageRename, $logoRename); } return $result; } else { $formData = $form->getValues(); $form->populate($data); if ($regionBd) { $form->resRegion->addMultiOptions($regionBd); } if ($cityBd) { $form->resCity->addMultiOptions($cityBd); } if ($ngbhBd) { $form->resNeighbour->addMultiOptions($ngbhBd); } return false; } } catch (Exception $ex) { Rdine_Logger_FileLogger::info($ex->getMessage()); throw new Exception($ex->getMessage()); } }
public function _writeSession() { $user = serialize($this->_sessionData); if (extension_loaded('mhash')) { $hmac = bin2hex(mhash(MHASH_SHA1, $user, $this->_pSalt)); $user = $hmac . $user; } parent::write($user); }
function loginajaxAction() { $this->_helper->layout->disableLayout(); $this->modelCompanies = new Company_Model_DbTable_Companies(); $redirect_url = $_SERVER['HTTP_REFERER']; $formData = $this->getRequest()->getPost(); /*echo "<pre>"; print_r($formData); exit;*/ if (!isset($formData['user_name']) || trim($formData['user_name']) == "") { echo "Please enter your username/password"; } if (!isset($formData['user_password']) || trim($formData['user_password']) == "") { echo "Please enter your username/password"; } if (count($formErrors) == 0) { $comp_pwd = md5($formData['user_password']); $auth = Zend_Auth::getInstance(); $authAdapter = new Zend_Auth_Adapter_DbTable($this->modelCompanies->getAdapter(), TBL_COMPANIES); $authAdapter->setIdentityColumn('user_email')->setCredentialColumn('user_password'); $authAdapter->setIdentity($formData['user_name'])->setCredential($comp_pwd); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $userInfo = $authAdapter->getResultRowObject(); if ($userInfo->account_type == '1') { $storage = new Zend_Auth_Storage_Session('company_type'); $storage->write($userInfo); //header("Location:$redirect_url"); echo "s"; } elseif ($userInfo->account_type == '2') { $storage = new Zend_Auth_Storage_Session('account_type'); $storage->write($userInfo); echo "s"; } elseif ($userInfo->account_type == '3') { $storage = new Zend_Auth_Storage_Session('account_type'); $storage->write($userInfo); echo "s"; } } else { echo "Invalid username or password"; } } exit; }
public function createsubscribedfirmAction() { try { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $this->_helper->layout()->setLayout('adminlayout'); $request = $this->getRequest(); /* Populating Restaurant owners */ $resownerMapper = new User_Model_ManagerDataMapper(); $resOwners = $resownerMapper->fetchAll(); $this->view->resowners = $resOwners; $userservice = new Application_Service_Client(); $form = $userservice->getRestaurantOwnerForm(); $this->view->form = $form; // $CountryCodeMapper = new Application_Model_CountryCodeDataMapper(); // $CountryCode = $CountryCodeMapper->fetchAll(); // $CodeList = array(); // $CodeList[] = array('key'=>'','value'=>'Select Country Flag'); // foreach($CountryCode as $listcode){ // $CodeList[] = array('key'=>$listcode->getCountry_dial_code(),'value'=>$listcode->getCountry_flag()); // } // $this->view->codelist = $CodeList; if (isset($request->userid)) { $data['restownerId'] = $request->userid; $rsoMapper = new User_Model_ManagerDataMapper(); $table = $rsoMapper->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from($table, array('rsofk_salution', 'rsofirst_name', 'rsolast_name', 'rsophone', 'rsostateid', 'rsocityid', 'rsoregionid', 'rso_companyid', 'presid', 'defaultview'))->join(array('rd.restaurant_details'), 'resfk_user = rsofk_user', array('resid'))->where('rsofk_user = ?', $request->userid)->where('resstatus = ?', 1); $row = $table->fetchRow($select); if ($row->resid != null) { if ($row->presid != null) { $data['RestId'] = $row->presid; } else { $data['RestId'] = $row->resid; } $restNameByOwnObj = new FirmManagement_Model_FirmNamesByOwnerId(); $restNameByOwnObj->setRestOwnerId($request->userid); $restMapper = new FirmManagement_Model_FirmDataMapper(); $restList = $restMapper->getRestaurantNamesByOwnerId($restNameByOwnObj); $data['restList'] = $restList; } else { $data['RestId'] = ""; $data['restList'] = ""; } $storage->write($data); if ($data['companyid'] != 6) { return $this->_helper->redirector('addfirm', 'Firm', 'FirmManagement'); } else { return $this->_helper->redirector('addroundmenufirm', 'Firm', 'FirmManagement'); } } else { if ($this->getRequest()->isPost()) { $result = $userservice->RegisterRestaurantOwner($this->getRequest()->getPost()); if ($result['status']) { $data['restownerId'] = $result['userid']; $storage->write($data); if ($data['companyid'] != 6) { return $this->_helper->redirector('addfirm', 'Firm', 'FirmManagement'); } else { return $this->_helper->redirector('addroundmenufirm', 'Firm', 'FirmManagement'); } } else { if ($result['form']) { $this->view->form = $result['form']; $this->view->errors = $form; } } } } } else { $this->_redirect($this->view->url(array('module' => 'User', 'controller' => 'Login', 'action' => 'signin'), 'login', true)); } } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
public function signingmailAction() { try { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $request = $this->getRequest(); if ($request->isPost()) { $userResponse = $this->_userService->manageProfile($request); $storage = new Zend_Auth_Storage_Session(); $storage->write($userResponse); echo true; } } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
/** * Persists the entity in the database and writes the key to the session * * @param SessionEntity $session * @throws InvalidArgumentException If invalid SessionEntity is passed */ public function write($session) { $entityClass = $this->getEntityClass(); if (!$session instanceof $entityClass) { throw new InvalidArgumentException(sprintf('Expecting type `%s`, but got `%s`', $entityClass, is_object($session) ? get_class($session) : gettype($session))); } $em = $this->getEntityManager(); $em->persist($session); $em->flush(); $this->session = $session; parent::write($session->getKey()); }
public function signinfromwidgetAction() { try { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity() && isset($data['User_Id'])) { if (isset($request->code)) { echo "<script type=\"text/javascript\">"; echo "window.opener.location.href = '" . $loginProfile['widgetlink'] . "';window.close(); </script>"; } else { echo 'auth'; } } else { if (isset($request->error_reason) && isset($request->error)) { $auth->clearIdentity(); echo "<script type=\"text/javascript\">"; echo "window.close(); </script>"; } else { $storage = new Zend_Auth_Storage_Session('fblogin'); $data = $storage->read(); $auth = Zend_Auth::getInstance(); /* facebook*/ include 'facebook/src/facebook.php'; $app_id = "1701350336753170"; $app_secret = "a9feac008bab4610efcb5082158f4858"; $my_url = "http://www.rdine.com/User/Client/signinfromwidget"; $loginProfile = $data; if (isset($request->widgetlink)) { $loginProfile['widgetlink'] = $request->widgetlink; } $facebook = new Facebook(array('appId' => '1701350336753170', 'secret' => 'a9feac008bab4610efcb5082158f4858')); $code = $request->code; if (empty($code)) { $loginProfile['state'] = md5(uniqid(rand(), TRUE)); // CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?display=popup&domain=www.rdine.com&locale=en_US&client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email&state=" . $loginProfile['state']; // echo '<a href="'.$dialog_url.'" onclick="window.open (this.href, "child", "height=400,width=300"); return false">Click to log out</a>'; $storage->write($loginProfile); echo $dialog_url; } if ($loginProfile['state'] && $loginProfile['state'] === $request->state) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code . "&scope=email"; try { $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $loginProfile['access_token'] = $params['access_token']; $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token']; $user = json_decode(file_get_contents($graph_url)); $emailObj = new User_Model_Signin(); $emailObj->setEmailAddress(strtolower(trim($user->email))); $result = $this->_userService->manageLoginProfileWidget($user, $loginProfile); if ($result['Status']) { $auth->clearIdentity(); $auth = Zend_Auth::getInstance(); $storage = new Zend_Auth_Storage_Session(); $storage->write($result['loginprofile']); echo "<script type=\"text/javascript\">"; echo "window.opener.location.href = '" . $loginProfile['widgetlink'] . "';window.close(); </script>"; } else { $auth->clearIdentity(); echo "<script type=\"text/javascript\">"; echo "window.close(); </script>"; } } catch (Exception $e) { unset($loginProfile['access_token']); $storage->write($loginProfile); } } } } } catch (Exception $ex) { throw new Exception($ex->getMessage()); } }
public function write($contents) { parent::write($contents->id); }