/** * 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; }
/** * Insert article * * @param array $data * @return bool */ public function insertArticle($data) { $data['AuthorID'] = Admin_View_Helper_Authentication::getLoggedUserID(); $data['CreateTime'] = Site_View_Helper_Date::formatDate(); return Admin_View_Helper_DB::save(new Admin_Resource_Article(), $data); }
/** * Insert access log * * @param int $companyID, * @return bool Insertion successful or not */ public function insertAccessLog($username, $activityType, $additionalInfo = "") { $data = array(Username => $username, ActivityType => $activityType, IpAddress => Admin_View_Helper_AccessLog::getClientIp(), LoginDateTime => Site_View_Helper_Date::formatDate(), AdditionalInfo => $additionalInfo); return Admin_View_Helper_DB::save(new Admin_Resource_AccessLog(), $data); }
/** * Insert contact log * * @param array $postData * @return array Status and message */ public function insertContactLog($postData) { if ($postData['Name'] == '') { return [status => 0, message => 'Please fill in your name']; } if ($postData['PhoneNr'] == null && $postData['Email'] == null) { return [status => 0, message => 'Please enter at least one way to contact you']; } if ($postData['ServiceRequired'] == 0 || $postData['ServiceRequired'] == null) { return [status => 0, message => 'Please select required service']; } if ($postData['Text'] == '') { return [status => 0, message => 'Please enter your comments']; } // Send email $emailSubject = '[' . $postData['ServiceRequiredText'] . '] Form submitted on www.beyourlight.co.uk'; $emailFrom = $postData['Email']; $emailText = 'Hello,<br/><br/>' . 'contact form has been submitted on www.beyourlight.co.uk<br/><br/>' . 'Here are the details:<br/>' . '<b>Name</b>: ' . $postData['Name'] . '<b>Email</b>: ' . $postData['Email'] . '<b>PhoneNr</b>: ' . $postData['PhoneNr'] . '<b>Service</b>: ' . $postData['ServiceRequiredText'] . '<b>Text</b>: ' . $postData['Text']; $emailTo = $this->getContactsByID()->Email; $emailSent = Site_View_Helper_Mailer::sendEmail($emailTo, $emailSubject, $emailText, $postData['Name'], EMAIL_USERNAME); // Insert log in DB $data = [ContactDateTime => Site_View_Helper_Date::formatDate(), Name => $postData['Name'], Email => $postData['Email'], PhoneNr => $postData['PhoneNr'], ServiceID => $postData['ServiceRequired'], Text => $postData['Text'], IpAddress => Admin_View_Helper_AccessLog::getClientIp(), EmailSent => $emailSent['Sent'], ErrorMessage => $emailSent['Message']]; Admin_View_Helper_DB::save(new Admin_Resource_ContactLog(), $data); return [status => 1, message => 'Your request has been submitted successfully']; }
/** * Insert testimonial * * @param array $data * @return bool */ public function insertTestimonial($data) { $data['CreateTime'] = Site_View_Helper_Date::formatDate(); return Admin_View_Helper_DB::save(new Admin_Resource_Testimonial(), $data); }
public function whatIDoAction() { $form = new Admin_Form_WhatIDoForm(); $whatIDo = $this->_contacts->getWhatIDoByID(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // update if ($form->Image->isUploaded()) { $form->Image->receive(); $path = "img/profile/WhatIDo.jpg"; Admin_View_Helper_ImageControls::resizeImage($path, $path, 200, 300); $formData['ImageUpdateTime'] = Site_View_Helper_Date::formatDate(); $whatIDo->ImageUpdateTime = Site_View_Helper_Date::formatDate(); } $this->_contacts->updateWhatIDo($formData); } else { $form->populate($formData); } } else { $data = $whatIDo->toArray(); $form->populate($data); } $this->view->whatIDo = $whatIDo; $this->view->form = $form; }