Recent Topics

1 Sep 26, 2008 23:16    

Using 2.4.2 Palm Release

I've set debugging to be on to see messages and queries

Using Blueyed ldap plugin as reference as well as other posts on the same subject. I'm trying to write a plugin to use an external db for authentication.

Why can't I see the error or success messages? In Debug mode, I can see the queries (#8 and #9) that it checks the evo_users database but not the external DB.

using simple code to test as I'm not familar with b2evolution methods.
Looking at the
_main.inc.php, _usercache.class (get_by_login, get_by_loginAndPwd) as sample code.


function LoginAttempt( $params )
	{

			global $DB, $Session, $Messages;
			$validator = new EmailAddressValidator; //http://code.google.com/p/php-email-address-validation/
//email address validator			
			$UserCache = & get_Cache( 'UserCache' );
		
									
	//check if login is an email, if so use ex_auth
					
	//if($validator->check_email_address($local_User)) //using google email validator code
		//not sure if email validation is working so trying string postion
		$login = strtolower( $_POST['login'] );//basic test  
		$mystring = '@';
		$pos = strpos(mystring,$login);
		if($pos !== false)
		{  
		echo 'passed through email check 1';
		$this->msg('passed through email check','success');
		
		$DB->select('other_database'); //switch to our other db

		$query = "SELECT email FROM other_database_user WHERE email = '".$DB->escape($login)."'";
		
	    if ($DB->get_row( "
					SELECT * FROM other_database_user
					WHERE email = '".$DB->escape($login)."'", 0, 0, 'Get User login' )){ 
										  		
		    //if( $DB->get_var($query) ){  			
			
			$this->debug_log( 'User exists in the external database' );	
			$this->msg('User exists in the external database','success');
			}
			
			else 			
			{
		   $this->debug_log( 'User does not exist in the database Redirect to New Registration' );	
		   $this->msg('You do not exists','error');
			
			}

              //TODO: if exists create new user in DB see Daniel's example

			}
             //if not in external use b2evolution
	
		if( ( $local_User = & $UserCache->get_by_login( $params['login'] ) )
				&& $local_User->pass == $params['pass_md5'] )
		{ // User exist (with this password), do nothing
			$this->debug_log( 'User already exists locally with this password.' );
			return true;
		}
	}

[/code]

2 Sep 27, 2008 01:16

putting in as php code and not as code in BBcode. Thanks for any hints or help!



function LoginAttempt( $params )
   {

         global $DB, $Session, $Messages;
         $validator = new EmailAddressValidator; //http://code.google.com/p/php-email-address-validation/
//email address validator         
         $UserCache = & get_Cache( 'UserCache' );
      
                           
   //check if login is an email, if so use ex_auth
               
   //if($validator->check_email_address($local_User)) //using google email validator code
      //not sure if email validation is working so trying string postion
      $login = strtolower( $_POST['login'] );//basic test 
      $mystring = '@';
      $pos = strpos(mystring,$login);
      if($pos !== false)
      { 
      echo 'passed through email check 1';
      $this->msg('passed through email check','success');
      
      $DB->select('other_database'); //switch to our other db

      $query = "SELECT email FROM other_database_user WHERE email = '".$DB->escape($login)."'";
      
       if ($DB->get_row( "
               SELECT * FROM other_database_user
               WHERE email = '".$DB->escape($login)."'", 0, 0, 'Get User login' )){
                                      
          //if( $DB->get_var($query) ){           
         
         $this->debug_log( 'User exists in the external database' );   
         $this->msg('User exists in the external database','success');
         }
         
         else          
         {
         $this->debug_log( 'User does not exist in the database Redirect to New Registration' );   
         $this->msg('You do not exists','error');
         
         }

              //TODO: if exists create new user in DB see Daniel's example

         }
             //if not in external use b2evolution
   
      if( ( $local_User = & $UserCache->get_by_login( $params['login'] ) )
            && $local_User->pass == $params['pass_md5'] )
      { // User exist (with this password), do nothing
         $this->debug_log( 'User already exists locally with this password.' );
         return true;
      }
   }


[/php]

3 Oct 09, 2008 19:14

fixed my own mistake... strpos use is wrong.. have to swap the two variables around.. and you can see the error messages


Form is loading...