Guest User

Untitled

a guest
Jul 9th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. <?php
  2.  
  3. class LoginController extends Zend_Controller_Action
  4. {
  5.  
  6. public function indexAction()
  7. {
  8. $this->view->message = '';
  9. if ($this->_request->isPost()) {
  10. // collect the data from the user
  11. Zend_Loader::loadClass('Zend_Filter_StripTags');
  12. $f = new Zend_Filter_StripTags();
  13. $username = $f->filter($this->_request->getPost('username'));
  14. $password = $f->filter($this->_request->getPost('password'));
  15. if (empty($username)) {
  16. $this->view->message = 'Please provide a username.';
  17. } else {
  18. // setup Zend_Auth adapter for a database table
  19. error_log('start_auth');
  20. Zend_Loader::loadClass('Zend_Auth_Adapter_DbTable');
  21.  
  22. $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
  23. $authAdapter->setTableName('billing_customer');
  24. $authAdapter->setIdentityColumn('username');
  25. $authAdapter->setCredentialColumn('password');
  26.  
  27. // Set the input credential values to authenticate against
  28. $authAdapter->setIdentity($username);
  29. $authAdapter->setCredential($password);
  30. // do the authentication
  31. $auth = Zend_Auth::getInstance();
  32. $result = $auth->authenticate($authAdapter);
  33. if ($result->isValid()) {
  34. // success: store database row to auth's storage
  35. // system. (Not the password though!)
  36. $data = $authAdapter->getResultRowObject(null,
  37. 'password');
  38. $auth->getStorage()->write($data);
  39.  
  40. if ($_POST['remember']=="yes") {
  41. require_once('Zend/Session/Namespace.php');
  42. $session = new Zend_Session_Namespace('Zend_Auth');
  43. // Set the time of user logged in
  44. //$session->setExpirationSeconds();
  45. Zend_Session::rememberMe();
  46. }
  47. $userIdentity = Zend_Auth::getInstance()->getIdentity();
  48. $model = new Model_Login();
  49. ... fails here with
  50.  
  51. PHP Fatal error: Class 'Model_Login' not found in application/controllers/LoginController.php on line 52
  52. =================================
  53. <?php // file Login.php
  54.  
  55. class Model_Login
  56. {
  57. public function setDbTable($dbTable)
  58. {
  59. if (is_string($dbTable)) {
  60. $dbTable = new $dbTable();
  61. }
  62. ...
  63.  
  64. =================================
  65.  
  66. <?php // file Bootstrap.php
  67. //error_log("bootstrap start");
  68.  
  69. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  70. {
  71.  
  72. /**
  73. * Bootstrap autoloader for application resources
  74. *
  75. * @return Zend_Application_Module_Autoloader
  76. */
  77. protected function _initAutoload()
  78. {
  79.  
  80. $autoloader = Zend_Loader_Autoloader::getInstance();
  81. //$autoloader->registerNamespace('NWS');
  82.  
  83. error_log("APPLICATION_PATH" . APPLICATION_PATH);
  84. //$autoloader = new Zend_Application_Module_Autoloader(array(
  85. // 'namespace' => 'NWS',
  86. // 'basePath' => APPLICATION_PATH,
  87. //));
  88. return $autoloader;
  89. }
  90.  
  91. /**
  92. * Bootstrap the view doctype
  93. *
  94. * @return void
  95. */
  96. protected function _initDoctype()
  97. {
  98. $this->bootstrap('view');
  99. $view = $this->getResource('view');
  100. $view->doctype('XHTML1_STRICT');
  101. return $view;
  102. }
  103.  
  104. protected function _initSetupDatabase()
  105. {
  106. $resource = $this->getPluginResource('db');
  107. $db = $resource->getDbAdapter();
  108. Zend_Db_Table::setDefaultAdapter($db);
  109. }
  110.  
  111. }
  112.  
  113. ?>
Add Comment
Please, Sign In to add comment