function loginAction() { $this->_helper->layout->disableLayout(); Zend_Date_Cities::getCityList(); $form = new App_Form_Login(); $this->view->form = $form; $this->view->message = ''; if ($this->_request->isPost()) { Zend_Loader::loadClass('Zend_Filter_StripTags'); $filter = new Zend_Filter_StripTags(); $username = $filter->filter($this->_request->getPost('username')); $password = $filter->filter($this->_request->getPost('password')); if (empty($username)) { $this->view->message = 'Please provide a username.'; } else { // setup Zend_Auth adapter for a database table Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable'); $db = Zend_Db_Table::getDefaultAdapter(); $authAdapter = new Zend_Auth_Adapter_DbTable($db); $authAdapter->setTableName('ourbank_user'); $authAdapter->setIdentityColumn('username'); $authAdapter->setCredentialColumn('password'); $authAdapter->setIdentity($username); $authAdapter->setCredential($password); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $data = $authAdapter->getResultRowObject(null, 'password'); $auth->getStorage()->write($data); $userinfo = new App_Model_Users(); $getresult = $userinfo->userinfo($username); foreach ($getresult as $getdata) { $user_id = $getdata["id"]; $username = $getdata["name"]; } $sessionName = new Zend_Session_Namespace('ourbank'); $sessionName->__set('primaryuserid', $user_id); $sessionName->primaryuserid; $sessionName->__set('username', $username); $sessionName->username; $globalsession = new App_Model_Users(); $this->view->globalvalue = $globalsession->getSession(); $sessionName->__set('language', $this->view->globalvalue[1]); $this->_redirect('/index/index'); } else { $this->view->message = 'Login failed.'; } } } $this->view->title = "Log in"; $this->render(); }
/** * Test for SunFunc */ public function testSunFunc() { $locale = new Zend_Locale('de_AT'); $date = new Zend_Date(1010101010, $locale); $date->setTimezone(date_default_timezone_get()); $result = Zend_Date_Cities::City('vienna'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C)); unset($result); $result = Zend_Date_Cities::City('vienna', 'civil'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C)); unset($result); $result = Zend_Date_Cities::City('vienna', 'nautic'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C)); unset($result); $result = Zend_Date_Cities::City('vienna', 'astronomic'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C)); unset($result); $result = Zend_Date_Cities::City('BERLIN'); $this->assertTrue(is_array($result)); $result = $date->getSunrise($result); $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C)); unset($result); $result = Zend_Date_Cities::City('London'); $this->assertTrue(is_array($result)); $result = $date->getSunInfo($result); $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C)); $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C)); unset($result); $result = array('longitude' => 0); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('latitude' => 0); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('longitude' => 180.1, 'latitude' => 0); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('longitude' => -180.1, 'latitude' => 0); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('longitude' => 0, 'latitude' => 90.09999999999999); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('longitude' => 0, 'latitude' => -90.09999999999999); try { $result = $date->getSunrise($result); $this->fail(); } catch (Zend_Date_Exception $e) { // success } unset($result); $result = array('latitude' => 0, 'longitude' => 0); $result = $date->getSunInfo($result); $this->assertTrue(is_array($result)); unset($result); $result = array('latitude' => 0, 'longitude' => 0); $result = $date->getSunrise($result); $this->assertTrue($result instanceof Zend_Date); }
/** * Test for SunFunc */ public function testSunFunc() { $locale = new Zend_Locale('de_AT'); $date = new Zend_Date(1010101010, $locale); $date->setTimezone(date_default_timezone_get()); $result = Zend_Date_Cities::City('vienna'); $this->assertTrue(is_array($result)); $result = $date->getSunSet($result); $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:10:10+01:00'); unset($result); $result = Zend_Date_Cities::City('vienna', 'civil'); $this->assertTrue(is_array($result)); $result = $date->getSunSet($result); $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:09:31+01:00'); unset($result); $result = Zend_Date_Cities::City('vienna', 'nautic'); $this->assertTrue(is_array($result)); $result = $date->getSunSet($result); $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:08:45+01:00'); unset($result); $result = Zend_Date_Cities::City('vienna', 'astronomic'); $this->assertTrue(is_array($result)); $result = $date->getSunSet($result); $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T16:08:00+01:00'); unset($result); $result = Zend_Date_Cities::City('BERLIN'); $this->assertTrue(is_array($result)); $result = $date->getSunRise($result); $this->assertSame($result->get(Zend_Date::W3C), '2002-01-04T08:21:17+01:00'); unset($result); $result = Zend_Date_Cities::City('London'); $this->assertTrue(is_array($result)); $result = $date->getSunInfo($result); $this->assertSame($result['sunrise']['effective']->get(Zend_Date::W3C), '2002-01-04T09:10:07+01:00'); $this->assertSame($result['sunrise']['civil']->get(Zend_Date::W3C), '2002-01-04T09:10:51+01:00'); $this->assertSame($result['sunrise']['nautic']->get(Zend_Date::W3C), '2002-01-04T09:11:42+01:00'); $this->assertSame($result['sunrise']['astronomic']->get(Zend_Date::W3C), '2002-01-04T09:12:31+01:00'); $this->assertSame($result['sunset']['effective']->get(Zend_Date::W3C), '2002-01-04T17:01:04+01:00'); $this->assertSame($result['sunset']['civil']->get(Zend_Date::W3C), '2002-01-04T17:00:20+01:00'); $this->assertSame($result['sunset']['nautic']->get(Zend_Date::W3C), '2002-01-04T16:59:30+01:00'); $this->assertSame($result['sunset']['astronomic']->get(Zend_Date::W3C), '2002-01-04T16:58:40+01:00'); }