/** * Execute a manual cron process */ public function executeAction() { $resources = Shineisp_Commons_Layout::getData("system", null); $class_called = $this->getRequest()->getParam('class'); $method_called = $this->getRequest()->getParam('method'); $email = $this->getRequest()->getParam('email'); $password = $this->getRequest()->getParam('password'); if (empty($email) || empty($password)) { Shineisp_Commons_Utilities::log("Manual Start needs the administrator authentication", 'cron.log'); } $result = AdminUser::fastlogin($email, $password, false); if (Zend_Auth_Result::SUCCESS == $result->getCode()) { $identity = $result->getIdentity(); // Get the cron default configuration $xmlobject = $resources->xpath("cron/execute"); if (count($xmlobject)) { foreach ($xmlobject as $cron) { foreach ($cron as $code) { $class = (string) $code['class']; $method = (string) $code['method']; $params = json_decode((string) $code['params']); $log = (string) $code; if ($class == $class_called && $method == $method_called) { $this->execScript($class, $method, $params); Shineisp_Commons_Utilities::log("Manual Start: {$log} by " . $identity['lastname'], 'cron.log'); } } } } } }
public function authenticate() { $email = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; if ($email == "" && $password == "") { list($email, $password) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); } //Check if username or password aren't empty if ($email == "" || $password == "") { throw new Shineisp_Api_Exceptions(403001); exit; } // login the user by ACL $result = AdminUser::fastlogin($email, $password, 0); switch ($result->getCode()) { case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: throw new Shineisp_Api_Exceptions(401001); break; case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: /** do stuff for invalid credential **/ throw new Shineisp_Api_Exceptions(401002); break; case Zend_Auth_Result::SUCCESS: return true; case Zend_Auth_Result::FAILURE: default: /** do stuff for other failure **/ throw new Shineisp_Api_Exceptions(401001); break; } die; }
/** * Login action */ public function dologinAction() { $user = new AdminUser(); $request = $this->getRequest(); $translation = Shineisp_Registry::getInstance()->Zend_Translate; // Get our form and validate it $form = new Admin_Form_LoginForm(array('action' => '/admin/login/dologin', 'method' => 'post')); // Invalid entries if ($form->isValid($request->getPost())) { if ($this->getRequest()->isPost()) { $result = AdminUser::fastlogin($this->getRequest()->getParam("email"), $this->getRequest()->getParam("password"), $this->getRequest()->getParam("rememberme")); switch ($result->getCode()) { case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: /** do stuff for nonexistent identity **/ Shineisp_Commons_Utilities::log("Login: User not found.", "login.log"); $this->view->message = $translation->translate('User not found.'); break; case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: /** do stuff for invalid credential **/ Shineisp_Commons_Utilities::log("Login: The email address or password is incorrect. please try again.", "login.log"); $this->view->message = $translation->translate('The email address or password is incorrect. please try again.'); break; case Zend_Auth_Result::SUCCESS: /** do stuff for successful authentication **/ Shineisp_Commons_Utilities::log("Login: The User has been authenticated successfully.", "login.log"); AdminUser::updateLog($this->getRequest()->getParam("email")); $this->_helper->redirector('index', 'index', 'admin'); break; case Zend_Auth_Result::FAILURE: /** do stuff for other failure **/ Shineisp_Commons_Utilities::log("Login: There was a problem during the login process.", "login.log"); $this->view->message = $translation->translate('There was a problem during the login process.'); break; } } else { Shineisp_Commons_Utilities::log("Login: Invalid Post Request.", "login.log"); $this->view->message = $translation->translate('Invalid Post Request.'); } } //Show the login form $this->view->loginform = $form; return $this->render('index'); // re-render the login form }