Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class LoginController extends Zend_Controller_Action
- {
- public function indexAction()
- {
- $this->view->message = '';
- if ($this->_request->isPost()) {
- // collect the data from the user
- Zend_Loader::loadClass('Zend_Filter_StripTags');
- $f = new Zend_Filter_StripTags();
- $username = $f->filter($this->_request->getPost('username'));
- $password = $f->filter($this->_request->getPost('password'));
- if (empty($username)) {
- $this->view->message = 'Please provide a username.';
- } else {
- // setup Zend_Auth adapter for a database table
- error_log('start_auth');
- Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
- $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
- $authAdapter->setTableName('billing_customer');
- $authAdapter->setIdentityColumn('username');
- $authAdapter->setCredentialColumn('password');
- // Set the input credential values to authenticate against
- $authAdapter->setIdentity($username);
- $authAdapter->setCredential($password);
- // do the authentication
- $auth = Zend_Auth::getInstance();
- $result = $auth->authenticate($authAdapter);
- if ($result->isValid()) {
- // success: store database row to auth's storage
- // system. (Not the password though!)
- $data = $authAdapter->getResultRowObject(null,
- 'password');
- $auth->getStorage()->write($data);
- if ($_POST['remember']=="yes") {
- require_once('Zend/Session/Namespace.php');
- $session = new Zend_Session_Namespace('Zend_Auth');
- // Set the time of user logged in
- //$session->setExpirationSeconds();
- Zend_Session::rememberMe();
- }
- $userIdentity = Zend_Auth::getInstance()->getIdentity();
- $model = new Model_Login();
- ... fails here with
- PHP Fatal error: Class 'Model_Login' not found in application/controllers/LoginController.php on line 52
- =================================
- <?php // file Login.php
- class Model_Login
- {
- public function setDbTable($dbTable)
- {
- if (is_string($dbTable)) {
- $dbTable = new $dbTable();
- }
- ...
- =================================
- <?php // file Bootstrap.php
- //error_log("bootstrap start");
- class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
- {
- /**
- * Bootstrap autoloader for application resources
- *
- * @return Zend_Application_Module_Autoloader
- */
- protected function _initAutoload()
- {
- $autoloader = Zend_Loader_Autoloader::getInstance();
- //$autoloader->registerNamespace('NWS');
- error_log("APPLICATION_PATH" . APPLICATION_PATH);
- //$autoloader = new Zend_Application_Module_Autoloader(array(
- // 'namespace' => 'NWS',
- // 'basePath' => APPLICATION_PATH,
- //));
- return $autoloader;
- }
- /**
- * Bootstrap the view doctype
- *
- * @return void
- */
- protected function _initDoctype()
- {
- $this->bootstrap('view');
- $view = $this->getResource('view');
- $view->doctype('XHTML1_STRICT');
- return $view;
- }
- protected function _initSetupDatabase()
- {
- $resource = $this->getPluginResource('db');
- $db = $resource->getDbAdapter();
- Zend_Db_Table::setDefaultAdapter($db);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment