Changeset 608 for trunk/expressoAdmin1_2


Ignore:
Timestamp:
01/14/09 16:26:13 (15 years ago)
Author:
niltonneto
Message:
  • Correção de traduções;
  • Retirado código que pode gerar overflow no servidor (loop infinito

com while(true);

Location:
trunk/expressoAdmin1_2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php

    r594 r608  
    386386                        $classe = new ReflectionClass($this->current_config['expressoAdmin_loginGenScript']); 
    387387                                         
    388                         if(!$classe->implementsInterface('login')) { 
    389                                 return array("status" => False, "msg" => "A classe geradora de logins não implementa a interface login (Se você for um usuário, contacte o suporte)"); 
    390                         } 
    391  
    392                         $gerador = $classe->newInstance(); 
    393  
    394                         $login = $gerador->generate_login($params["first_name"],$params["second_name"],$this->ldap); 
     388                        if(!$classe->implementsInterface('login')) 
     389                        { 
     390                                return array( 
     391                                        "status" => False, 
     392                                        "msg" => lang("Login interface not implemented (contact suport)") 
     393                                ); 
     394                        } 
     395 
     396                        $login = $classe->newInstance()->generate_login($params["first_name"],$params["second_name"],$this->ldap); 
    395397                         
    396398                        /* 
    397                                 Se o algoritmo gerar um login que já existe, colocamos um número no final do  
    398                                 login gerado, resultando em um login não existente 
    399                         */ 
    400                         while(true) { 
    401                                 $filter = "(uid=$login)";                
    402                                 $search = ldap_search($this->ldap, $context, $filter, $justthese); 
    403                                 $entries = ldap_count_entries($this->ldap,$search); 
    404                                 if($entries==0) 
     399                                If login exists, it concatenates a number to the end. 
     400                                resulting in a new login 
     401                         */ 
     402                        $i = 1; 
     403                        while($i < 1000) // Limit of 1000 equal names 
     404                        { 
     405                                $search = ldap_search($this->ldap, $context, "(uid=".$login.")", $justthese); 
     406                                if (ldap_count_entries($this->ldap,$search) == 0) 
    405407                                        break; 
    406                                 else { 
    407                                         $login.=$i; 
     408                                else 
     409                                { 
     410                                        if ($i > 1) // If login have a number, remove the number and put the new one 
     411                                                $login=substr($login,0,strlen($login)-strlen($i)).$i; 
     412                                        else 
     413                                                $login.=$i; 
    408414                                        $i++; 
    409415                                } 
Note: See TracChangeset for help on using the changeset viewer.