PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/init/auth.php

https://bitbucket.org/baruffaldi/website-insaneminds
PHP | 51 lines | 28 code | 7 blank | 16 comment | 12 complexity | 06666638eb58dd63c9e1593e4b613c57 MD5 | raw file
  1. <?php
  2. /**
  3. **
  4. **
  5. ** @Uses
  6. ** @Author Filippo Baruffaldi
  7. ** @Email filippo.baruffaldi@oneitalia.it
  8. * @version 0.1
  9. * @package StreamingAPI
  10. * @last-revisioner Filippo Baruffaldi
  11. */
  12. require_once ZENDLIBPATH . 'Auth.php';
  13. require_once ZENDLIBPATH . 'Exception.php';
  14. require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Result.php';
  15. require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Adapter' . DIRECTORY_SEPARATOR . 'DbTable.php';
  16. require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Storage' . DIRECTORY_SEPARATOR . 'Session.php';
  17. //*** Save a reference to the Singleton instance of Zend_Auth
  18. $auth = Zend_Auth::getInstance();
  19. //*** Use 'DSPAdminInterface v*' instead of 'Zend_Auth'
  20. $auth->setStorage( new Zend_Auth_Storage_Session( 'DSPAdminInterfaceDev ' . $AdminVersion ) );
  21. if ( ! empty( $_POST['login_username'] ) )
  22. {
  23. //*** Set up the auth adapter, $authAdapter
  24. $authAdapter = new Zend_Auth_Adapter_DbTable( $db,
  25. $dbParams['tableprefix'] . $dbParams['table_ad_users'],
  26. 'username',
  27. 'password',
  28. 'level > 0' );
  29. //*** Set up the auth adapter credentials
  30. $authAdapter->setIdentity( $_POST['login_username'] )
  31. ->setCredential( $_POST['login_password'] )
  32. ->setCredentialTreatment( 'MD5(?)' );
  33. //*** Authenticate, saving the result, and persisting the identity upon success
  34. $authResult = $auth->authenticate( $authAdapter );
  35. }
  36. //*** Define the authentication result constant
  37. define( '__USER__', $auth->getStorage( )->read( ) );
  38. define( '__LOGIN__', ( ! $auth->getStorage( )->isEmpty( ) ) );
  39. define( '__AUTHSKIP__', ( substr( $Request->action, -3 ) == 'css'
  40. || substr( $Request->action, -2 ) == 'js'
  41. || substr( $Request->category, -6 ) == 'login/'
  42. || ( $Request->category == '/' && !empty( $Request->action ) )
  43. || $Request->type != 'php'
  44. || __LOGIN__ ) ? TRUE : FALSE );