Ignore:
Timestamp:
12/14/12 14:30:35 (11 years ago)
Author:
douglasz
Message:

Ticket #3236 - Melhorias de performance no codigo do Expresso.

File:
1 edited

Legend:

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

    r6917 r7655  
    690690                                $entries = ldap_get_entries($ldap_connection, $search); 
    691691                                 
    692                                 for ($i=0; $i<$entries['count']; $i++) 
     692                                for ($i=0; $i<$entries['count']; ++$i) 
    693693                                { 
    694694                                        $users .= $entries[$i]['cn'][0] . ' - ' . $entries[$i]['mail'][0] . "\n"; 
     
    844844                                                { 
    845845                                                        $result['question'] = $this->functions->lang('Field CPF used by') . ":\n"; 
    846                                                                 for ($i=0; $i<$entries['count']; $i++) 
     846                                                                for ($i=0; $i<$entries['count']; ++$i) 
    847847                                                                        { 
    848848                                                                                if (strcasecmp($uid, $entries[$i]['uid'][0]) != 0) 
     
    910910                                        else 
    911911                                                $login.=$i; 
    912                                         $i++; 
     912                                        ++$i; 
    913913                                } 
    914914                        } 
     
    12601260                         
    12611261                $options = '';                   
    1262                 for ($i=0; $i<$entries['count']; $i++) 
     1262                for ($i=0; $i<$entries['count']; ++$i) 
    12631263                        { 
    12641264                        $options .= "<option value=" . $entries[$i]['uid'][0] . ">" . $entries[$i]['uid'][0] . " (" . $entries[$i]['mail'][0] . ")" . "</option>"; 
     
    12831283                 
    12841284                $options = ''; 
    1285                 for ($i=0; $i<$entries['count']; $i++) 
     1285                for ($i=0; $i<$entries['count']; ++$i) 
    12861286                { 
    12871287                            $options .= "<option value=" . $entries[$i]['mail'][0] . ">" . $entries[$i]['mail'][0] . "</option>"; 
     
    13081308         
    13091309                $options = '';                   
    1310                 for ($i=0; $i<$entries['count']; $i++) 
     1310                for ($i=0; $i<$entries['count']; ++$i) 
    13111311                { 
    13121312                            $options .= "<option value=" . $entries[$i]['mail'][0] . ">" . $entries[$i]['mail'][0] . "</option>"; 
     
    15411541                $entries = ldap_get_entries($this->ldap, $search); 
    15421542                $result['status'] = true; 
    1543                 for ($i=0; $i<$entries['count']; $i++) 
     1543                for ($i=0; $i<$entries['count']; ++$i) 
    15441544                { 
    15451545                        $attrs['mailforwardingaddress'] = $old_mail; 
     
    15711571                                $entry[0]['dn'] = strtolower($entry[0]['dn']); 
    15721572                                $sector_dn_array = explode(",", $entry[0]['dn']); 
    1573                                 for($i=1; $i<count($sector_dn_array); $i++) 
     1573                                for($i=1; $i<count($sector_dn_array); ++$i) 
    15741574                                        $sector_dn .= $sector_dn_array[$i] . ','; 
    15751575                                //Retira ultimo pipe. 
     
    15991599                 
    16001600                                // Samba 
    1601                                 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 
     1601                                for ($i=0; $i<$entry[0]['objectclass']['count']; ++$i) 
    16021602                                { 
    16031603                                        if ($entry[0]['objectclass'][$i] == 'sambaSamAccount') 
     
    16401640                        ldap_sort($this->ldap, $search, "cn"); 
    16411641                        $entries = ldap_get_entries($this->ldap, $search); 
    1642                         for ($i=0; $i<$entries['count']; $i++) 
     1642                        for ($i=0; $i<$entries['count']; ++$i) 
    16431643                        { 
    16441644                                $result['groups_ldap'][ $entries[$i]['gidnumber'][0] ] = utf8_decode($entries[$i]['cn'][0]); 
     
    16981698                                $entry[0]['dn'] = strtolower($entry[0]['dn']); 
    16991699                                $sector_dn_array = explode(",", $entry[0]['dn']); 
    1700                                 for($i=1; $i<count($sector_dn_array); $i++) 
     1700                                for($i=1; $i<count($sector_dn_array); ++$i) 
    17011701                                        $sector_dn .= $sector_dn_array[$i] . ','; 
    17021702                                //Retira ultimo pipe. 
     
    17271727                 
    17281728                                // Samba 
    1729                                 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 
     1729                                for ($i=0; $i<$entry[0]['objectclass']['count']; ++$i) 
    17301730                                { 
    17311731                                        if ($entry[0]['objectclass'][$i] == 'sambaSamAccount') 
     
    17681768                        ldap_sort($this->ldap, $search, "cn"); 
    17691769                        $entries = ldap_get_entries($this->ldap, $search); 
    1770                         for ($i=0; $i<$entries['count']; $i++) 
     1770                        for ($i=0; $i<$entries['count']; ++$i) 
    17711771                        { 
    17721772                                $result['groups_ldap'][ $entries[$i]['gidnumber'][0] ] = utf8_decode($entries[$i]['cn'][0]); 
     
    17961796                $entries = ldap_get_entries($ldapMasterConnect, $search); 
    17971797                 
    1798                 for ($i=0; $i<$entries['count']; $i++) 
     1798                for ($i=0; $i<$entries['count']; ++$i) 
    17991799                { 
    18001800                                $result[ $entries[$i]['uid'][0] ]['uid']                = $entries[$i]['uid'][0]; 
     
    18311831                                $entry[0]['dn'] = strtolower($entry[0]['dn']); 
    18321832                                $sector_dn_array = explode(",", $entry[0]['dn']); 
    1833                                 for($i=1; $i<count($sector_dn_array); $i++) 
     1833                                for($i=1; $i<count($sector_dn_array); ++$i) 
    18341834                                        $sector_dn .= $sector_dn_array[$i] . ','; 
    18351835                                //Retira ultimo pipe. 
     
    18441844                 
    18451845                                //MemberUid 
    1846                                 for ($i=0; $i<$entry[0]['memberuid']['count']; $i++) 
     1846                                for ($i=0; $i<$entry[0]['memberuid']['count']; ++$i) 
    18471847                                { 
    18481848                                        $justthese = array("cn","uid","uidnumber"); 
     
    18501850                                        // Montagem dinamica do filtro 
    18511851                                        $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=s))(|"; 
    1852                                         for ($k=0; (($k<10) && ($i<$entry[0]['memberuid']['count'])); $k++) 
     1852                                        for ($k=0; (($k<10) && ($i<$entry[0]['memberuid']['count'])); ++$k) 
    18531853                                        { 
    18541854                                                $filter .= "(uid=".$entry[0]['memberuid'][$i].")"; 
    1855                                                 $i++; 
     1855                        ++$i; 
    18561856                                        } 
    18571857                                        $i--; 
     
    18611861                                        $user_entry = ldap_get_entries($this->ldap, $search); 
    18621862 
    1863                                         for ($j=0; $j<$user_entry['count']; $j++) 
     1863                                        for ($j=0; $j<$user_entry['count']; ++$j) 
    18641864                                        { 
    18651865                                                $result['memberuid_info'][$user_entry[$j]['uid'][0]]['cn'] = $user_entry[$j]['cn'][0]; 
     
    18911891                 
    18921892                                // Samba 
    1893                                 for ($i=0; $i<$entry[0]['objectclass']['count']; $i++) 
     1893                                for ($i=0; $i<$entry[0]['objectclass']['count']; ++$i) 
    18941894                                { 
    18951895                                        if ($entry[0]['objectclass'][$i] == 'sambaGroupMapping') 
     
    19291929                                $entry[0]['dn'] = strtolower($entry[0]['dn']); 
    19301930                                $sector_dn_array = explode(",", $entry[0]['dn']); 
    1931                                 for($i=1; $i<count($sector_dn_array); $i++) 
     1931                                for($i=1; $i<count($sector_dn_array); ++$i) 
    19321932                                        $sector_dn .= $sector_dn_array[$i] . ','; 
    19331933                                //Retira ultimo pipe. 
     
    19441944                         
    19451945                                //Members 
    1946                                 for ($i=0; $i<$entry[0]['mailforwardingaddress']['count']; $i++) 
     1946                                for ($i=0; $i<$entry[0]['mailforwardingaddress']['count']; ++$i) 
    19471947                                { 
    19481948                                        $justthese = array("cn", "uidnumber", "uid", "phpgwaccounttype", "mail"); 
     
    19501950                                        // Montagem dinamica do filtro, para nao ter muitas conexoes com o ldap 
    19511951                                        $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(|"; 
    1952                                         for ($k=0; (($k<10) && ($i<$entry[0]['mailforwardingaddress']['count'])); $k++) 
     1952                                        for ($k=0; (($k<10) && ($i<$entry[0]['mailforwardingaddress']['count'])); ++$k) 
    19531953                                        { 
    19541954                                                $filter .= "(mail=".$entry[0]['mailforwardingaddress'][$i].")"; 
    1955                                                 $i++; 
     1955                        ++$i; 
    19561956                                        } 
    19571957                                        $i--; 
     
    19611961                                        $user_entry = ldap_get_entries($ldap_conn_following_ref, $search); 
    19621962                                                                         
    1963                                         for ($j=0; $j<$user_entry['count']; $j++) 
     1963                                        for ($j=0; $j<$user_entry['count']; ++$j) 
    19641964                                        { 
    19651965                                                $result['mailForwardingAddress_info'][$user_entry[$j]['mail'][0]]['uid'] = $user_entry[$j]['uid'][0]; 
     
    20012001                                $entry[0]['dn'] = strtolower($entry[0]['dn']); 
    20022002                                $sector_dn_array = explode(",", $entry[0]['dn']); 
    2003                                 for($i=1; $i<count($sector_dn_array); $i++) 
     2003                                for($i=1; $i<count($sector_dn_array); ++$i) 
    20042004                                        $sector_dn .= $sector_dn_array[$i] . ','; 
    20052005                                //Retira ultimo pipe. 
     
    20182018                 
    20192019                                //Senders 
    2020                                 for ($i=0; $i<$entry[0]['mailsenderaddress']['count']; $i++) 
     2020                                for ($i=0; $i<$entry[0]['mailsenderaddress']['count']; ++$i) 
    20212021                                { 
    20222022                                        $justthese = array("cn", "uidnumber", "uid", "mail"); 
     
    20812081                                } 
    20822082 
    2083                                 $i++; 
     2083                ++$i; 
    20842084                        } 
    20852085                } 
     
    22542254            $entries = ldap_get_entries($this->ldap, $search); 
    22552255                 
    2256                 for ($i=0; $i<$entries['count']; $i++) 
     2256                for ($i=0; $i<$entries['count']; ++$i) 
    22572257                { 
    22582258                        if ( !@ldap_mod_del($this->ldap, $entries[$i]['dn'], $attrs) ) 
     
    23252325                $entry = ldap_get_entries($this->ldap, $search); 
    23262326                $attrs['mailForwardingAddress'] = $mail; 
    2327                 for ($i=0; $i<=$entry['count']; $i++) 
     2327                for ($i=0; $i<=$entry['count']; ++$i) 
    23282328            { 
    23292329                        $dn = $entry[$i]['dn']; 
     
    24102410 
    24112411                $parent = array(); 
    2412                 for ($j=1; $j<(count($explode_dn)-1); $j++) 
     2412                for ($j=1; $j<(count($explode_dn)-1); ++$j) 
    24132413                        $parent[] = $explode_dn[$j]; 
    24142414                $parent = implode(",", $parent); 
     
    24302430        $array_mod_del['memberUid'] = $uid; 
    24312431 
    2432             for ($i=0; $i<=$entry['count']; $i++) 
     2432            for ($i=0; $i<=$entry['count']; ++$i) 
    24332433            { 
    24342434                $dn = $entry[$i]['dn']; 
     
    24532453 
    24542454                $parent = array(); 
    2455                 for ($j=1; $j<(count($explode_dn)-1); $j++) 
     2455                for ($j=1; $j<(count($explode_dn)-1); ++$j) 
    24562456                        $parent[] = $explode_dn[$j]; 
    24572457                $parent = implode(",", $parent); 
     
    25162516            $entry = ldap_get_entries($this->ldap, $search); 
    25172517             
    2518             for ($i=0; $i<$entry['count']; $i++) 
     2518            for ($i=0; $i<$entry['count']; ++$i) 
    25192519            { 
    25202520                        $return['sambaDomains'][$i] = $entry[$i]['sambadomainname'][0]; 
     
    26222622                $entries = ldap_get_entries($this->ldap, $institutional_accounts); 
    26232623                 
    2624                         for ($i=0; $i<$entries['count']; $i++) 
     2624                        for ($i=0; $i<$entries['count']; ++$i) 
    26252625                        { 
    26262626                                $tr = "<tr class='normal' onMouseOver=this.className='selected' onMouseOut=this.className='normal'><td onClick=edit_institutional_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]) . "</td><td onClick=edit_institutional_account('".$entries[$i]['uid'][0]."')>" . $entries[$i]['mail'][0] . "</td><td align='center' onClick=delete_institutional_accounts('".$entries[$i]['uid'][0]."')><img HEIGHT='16' WIDTH='16' src=./expressoAdmin1_2/templates/default/images/delete.png></td></tr>"; 
     
    26812681                        { 
    26822682                                $a_cn = array(); 
    2683                                 for ($i=0; $i<$entrie[0]['mailforwardingaddress']['count']; $i++) 
     2683                                for ($i=0; $i<$entrie[0]['mailforwardingaddress']['count']; ++$i) 
    26842684                                { 
    26852685                                        $tmp = $this->mailforwardingaddress2uidnumber($entrie[0]['mailforwardingaddress'][$i]); 
     
    27162716                $entries = ldap_get_entries($this->ldap, $institutional_accounts); 
    27172717                 
    2718                         for ($i=0; $i<$entries['count']; $i++) 
     2718                        for ($i=0; $i<$entries['count']; ++$i) 
    27192719                        { 
    27202720                                $tr = "<tr class='normal' onMouseOver=this.className='selected' onMouseOut=this.className='normal'><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]) . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]). " (" . $entries[$i]['uid'][0] . ")" . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . $entries[$i]['mail'][0] . "<td align='center' onClick=delete_shared_accounts('".$entries[$i]['uid'][0]."','".$entries[$i]['mail'][0]."')><img HEIGHT='16' WIDTH='16' src=./expressoAdmin1_2/templates/default/images/delete.png></td></tr>"; 
     
    28582858                $entries = ldap_get_entries($this->ldap, $search); 
    28592859                $result['status'] = true; 
    2860                 for ($i=0; $i<$entries['count']; $i++) 
     2860                for ($i=0; $i<$entries['count']; ++$i) 
    28612861                { 
    28622862                        $attrs['mailforwardingaddress'] = $oldMail; 
Note: See TracChangeset for help on using the changeset viewer.