/includes/init/auth.php
PHP | 51 lines | 28 code | 7 blank | 16 comment | 12 complexity | 06666638eb58dd63c9e1593e4b613c57 MD5 | raw file
- <?php
- /**
- **
- **
- ** @Uses
- ** @Author Filippo Baruffaldi
- ** @Email filippo.baruffaldi@oneitalia.it
- * @version 0.1
- * @package StreamingAPI
- * @last-revisioner Filippo Baruffaldi
- */
- require_once ZENDLIBPATH . 'Auth.php';
- require_once ZENDLIBPATH . 'Exception.php';
- require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Result.php';
- require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Adapter' . DIRECTORY_SEPARATOR . 'DbTable.php';
- require_once ZENDLIBPATH . 'Auth' . DIRECTORY_SEPARATOR . 'Storage' . DIRECTORY_SEPARATOR . 'Session.php';
-
- //*** Save a reference to the Singleton instance of Zend_Auth
- $auth = Zend_Auth::getInstance();
- //*** Use 'DSPAdminInterface v*' instead of 'Zend_Auth'
- $auth->setStorage( new Zend_Auth_Storage_Session( 'DSPAdminInterfaceDev ' . $AdminVersion ) );
- if ( ! empty( $_POST['login_username'] ) )
- {
- //*** Set up the auth adapter, $authAdapter
- $authAdapter = new Zend_Auth_Adapter_DbTable( $db,
- $dbParams['tableprefix'] . $dbParams['table_ad_users'],
- 'username',
- 'password',
- 'level > 0' );
- //*** Set up the auth adapter credentials
- $authAdapter->setIdentity( $_POST['login_username'] )
- ->setCredential( $_POST['login_password'] )
- ->setCredentialTreatment( 'MD5(?)' );
- //*** Authenticate, saving the result, and persisting the identity upon success
- $authResult = $auth->authenticate( $authAdapter );
-
- }
- //*** Define the authentication result constant
- define( '__USER__', $auth->getStorage( )->read( ) );
- define( '__LOGIN__', ( ! $auth->getStorage( )->isEmpty( ) ) );
- define( '__AUTHSKIP__', ( substr( $Request->action, -3 ) == 'css'
- || substr( $Request->action, -2 ) == 'js'
- || substr( $Request->category, -6 ) == 'login/'
- || ( $Request->category == '/' && !empty( $Request->action ) )
- || $Request->type != 'php'
- || __LOGIN__ ) ? TRUE : FALSE );