Ignore:
Timestamp:
10/10/13 11:39:53 (10 years ago)
Author:
angelo
Message:

Ticket #3491 - Compatibilizar Expresso com novas versoes do PHP

Location:
sandbox/2.5.1-evolucao
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.5.1-evolucao/expressoAdmin1_2/inc/class.ldap_functions.inc.php

    r8234 r8235  
    1010                \**************************************************************************/  
    1111                 
    12 define('PHPGW_INCLUDE_ROOT','../'); 
    13 define('PHPGW_API_INC','../phpgwapi/inc');       
     12if (!defined('PHPGW_INCLUDE_ROOT')) define('PHPGW_INCLUDE_ROOT','../'); 
     13if (!defined('PHPGW_API_INC')) define('PHPGW_API_INC','../phpgwapi/inc');        
    1414include_once(PHPGW_API_INC.'/class.common.inc.php'); 
    1515include_once('class.functions.inc.php'); 
     
    178178                        $info['accountStatus'] = 'active'; 
    179179                } 
    180                 if ($params['phpgwAccountVisible'] == 'on') 
     180                if (isset($params['phpgwAccountVisible']) && $params['phpgwAccountVisible'] == 'on') 
    181181                { 
    182182                        $info['phpgwAccountVisible'] = '-1'; 
     
    556556                                $info['accountStatus'] = 'active'; 
    557557                        } 
    558                         if ($params['phpgwAccountVisible'] == 'on') 
     558                        if ( isset($params['phpgwAccountVisible']) && ($params['phpgwAccountVisible'] == 'on') ) 
    559559                        { 
    560560                                $info['phpgwAccountVisible'] = '-1'; 
     
    27182718                        $return['status'] = 'true'; 
    27192719                        $return['accountStatus']                = $entrie[0]['accountstatus'][0]; 
    2720                         $return['phpgwAccountVisible']  = $entrie[0]['phpgwaccountvisible'][0]; 
     2720                        $return['phpgwAccountVisible']  = isset($entrie[0]['phpgwaccountvisible']) ? $entrie[0]['phpgwaccountvisible'][0] : ''; 
    27212721                        $return['cn']                                   = utf8_decode($entrie[0]['cn'][0]); 
    27222722                        $return['mail']                                 = $entrie[0]['mail'][0]; 
     
    27342734                                } 
    27352735                                natcasesort($a_cn); 
     2736                                $return['owners'] = ''; 
    27362737                                foreach($a_cn as $uidnumber => $cn) 
    27372738                                { 
  • sandbox/2.5.1-evolucao/header.inc.php.template

    r8142 r8235  
    1919        \**************************************************************************/ 
    2020        ob_start(); 
    21         define('PHPGW_SERVER_ROOT','{SERVER_ROOT}'); 
    22         define('PHPGW_INCLUDE_ROOT','{INCLUDE_ROOT}'); 
     21        if (!defined('PHPGW_SERVER_ROOT')) define('PHPGW_SERVER_ROOT','{SERVER_ROOT}'); 
     22        if (!defined('PHPGW_INCLUDE_ROOT')) define('PHPGW_INCLUDE_ROOT','{INCLUDE_ROOT}'); 
    2323        $GLOBALS['phpgw_info']['server']['header_admin_user'] = '{HEADER_ADMIN_USER}'; 
    2424        $GLOBALS['phpgw_info']['server']['header_admin_password'] = '{HEADER_ADMIN_PASSWORD}'; 
     
    114114        * Do not edit these lines                                                  * 
    115115        \**************************************************************************/ 
    116         define('PHPGW_API_INC',PHPGW_INCLUDE_ROOT.'/phpgwapi/inc'); 
     116        if (!defined('PHPGW_API_INC')) define('PHPGW_API_INC',PHPGW_INCLUDE_ROOT.'/phpgwapi/inc'); 
    117117        include(PHPGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'); 
    118118        $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] = $setup_info['phpgwapi']['version']; 
  • sandbox/2.5.1-evolucao/library/mime/mime.php

    r7673 r8235  
    4949 * @copyright 2003-2006 PEAR <pear-group@php.net> 
    5050 * @license   http://www.opensource.org/licenses/bsd-license.php BSD License 
    51  * @version   CVS: $Id: mime.php 305690 2010-11-23 12:41:00Z alec $ 
     51 * @version   CVS: $Id$ 
    5252 * @link      http://pear.php.net/package/Mail_mime 
    5353 * 
     
    6464 * This package depends on PEAR to raise errors. 
    6565 */ 
    66 require_once dirname(__FILE__).'/../PEAR/PEAR.php'; 
     66require_once 'PEAR.php'; 
    6767 
    6868/** 
     
    7373 * consist of. 
    7474 */ 
    75 //require_once 'Mail/mimePart.php'; 
     75require_once 'Mail/mimePart.php'; 
    7676 
    7777 
     
    246246        } else { 
    247247            $cont = $this->_file2str($data); 
    248             if (PEAR::isError($cont)) { 
     248            if ($this->_isError($cont)) { 
    249249                return $cont; 
    250250            } 
     
    255255            } 
    256256        } 
     257 
    257258        return true; 
    258259    } 
     
    287288        } else { 
    288289            $cont = $this->_file2str($data); 
    289             if (PEAR::isError($cont)) { 
     290            if ($this->_isError($cont)) { 
    290291                return $cont; 
    291292            } 
     
    337338                $bodyfile = $file; 
    338339            } else { 
    339                 if (PEAR::isError($filedata = $this->_file2str($file))) { 
     340                if ($this->_isError($filedata = $this->_file2str($file))) { 
    340341                    return $filedata; 
    341342                } 
     
    348349 
    349350        if (!$content_id) { 
    350             $content_id = md5(uniqid(time())); 
     351            $content_id = preg_replace('/[^0-9a-zA-Z]/', '', uniqid(time(), true)); 
    351352        } 
    352353 
     
    388389     * @param string $h_charset   The character set of the headers e.g. filename 
    389390     *                            If not specified, $charset will be used 
     391     * @param array  $add_headers Additional part headers. Array keys can be in form 
     392     *                            of <header_name>:<parameter_name> 
    390393     * 
    391394     * @return mixed              True on success or PEAR_Error object 
     
    404407        $f_encoding  = null, 
    405408        $description = '', 
    406         $h_charset   = null 
     409        $h_charset   = null, 
     410        $add_headers = array() 
    407411    ) { 
    408412        $bodyfile = null; 
     
    414418                $bodyfile = $file; 
    415419            } else { 
    416                 if (PEAR::isError($filedata = $this->_file2str($file))) { 
     420                if ($this->_isError($filedata = $this->_file2str($file))) { 
    417421                    return $filedata; 
    418422                } 
    419423            } 
    420424            // Force the name the user supplied, otherwise use $file 
    421             $filename = ($name ? $name : $this->_basename($file ));         
     425            $filename = ($name ? $name : $this->_basename($file)); 
    422426        } else { 
    423427            $filedata = $file; 
     
    427431        if (!strlen($filename)) { 
    428432            $msg = "The supplied filename for the attachment can't be empty"; 
    429             $err = PEAR::raiseError($msg); 
    430             return $err; 
    431         } 
    432          
     433            return $this->_raiseError($msg); 
     434        } 
     435 
    433436        $this->_parts[] = array( 
    434437            'body'        => $filedata, 
     
    442445            'disposition' => $disposition, 
    443446            'description' => $description, 
     447            'add_headers' => $add_headers, 
    444448            'name_encoding'     => $n_encoding, 
    445449            'filename_encoding' => $f_encoding, 
     
    458462     * @access private 
    459463     */ 
    460     function &_file2str($file_name) 
     464    function _file2str($file_name) 
    461465    { 
    462466        // Check state of file and raise an error properly 
    463467        if (!file_exists($file_name)) { 
    464             $err = PEAR::raiseError('File not found: ' . $file_name); 
    465             return $err; 
     468            return $this->_raiseError('File not found: ' . $file_name); 
    466469        } 
    467470        if (!is_file($file_name)) { 
    468             $err = PEAR::raiseError('Not a regular file: ' . $file_name); 
    469             return $err; 
     471            return $this->_raiseError('Not a regular file: ' . $file_name); 
    470472        } 
    471473        if (!is_readable($file_name)) { 
    472             $err = PEAR::raiseError('File is not readable: ' . $file_name); 
    473             return $err; 
     474            return $this->_raiseError('File is not readable: ' . $file_name); 
    474475        } 
    475476 
     
    497498     * @access private 
    498499     */ 
    499     function &_addTextPart(&$obj, $text) 
     500    function &_addTextPart(&$obj = null, $text = '') 
    500501    { 
    501502        $params['content_type'] = 'text/plain'; 
     
    506507        if (is_object($obj)) { 
    507508            $ret = $obj->addSubpart($text, $params); 
    508             return $ret; 
    509509        } else { 
    510510            $ret = new Mail_mimePart($text, $params); 
    511             return $ret; 
    512         } 
     511        } 
     512 
     513        return $ret; 
    513514    } 
    514515 
     
    523524     * @access private 
    524525     */ 
    525     function &_addHtmlPart(&$obj) 
     526    function &_addHtmlPart(&$obj = null) 
    526527    { 
    527528        $params['content_type'] = 'text/html'; 
     
    532533        if (is_object($obj)) { 
    533534            $ret = $obj->addSubpart($this->_htmlbody, $params); 
    534             return $ret; 
    535535        } else { 
    536536            $ret = new Mail_mimePart($this->_htmlbody, $params); 
    537             return $ret; 
    538         } 
     537        } 
     538 
     539        return $ret; 
    539540    } 
    540541 
     
    549550    function &_addMixedPart() 
    550551    { 
    551         $params                 = array(); 
    552552        $params['content_type'] = 'multipart/mixed'; 
    553553        $params['eol']          = $this->_build_params['eol']; 
     
    569569     * @access private 
    570570     */ 
    571     function &_addAlternativePart(&$obj) 
     571    function &_addAlternativePart(&$obj = null) 
    572572    { 
    573573        $params['content_type'] = 'multipart/alternative'; 
     
    575575 
    576576        if (is_object($obj)) { 
    577             return $obj->addSubpart('', $params); 
     577            $ret = $obj->addSubpart('', $params); 
    578578        } else { 
    579579            $ret = new Mail_mimePart('', $params); 
    580             return $ret; 
    581         } 
     580        } 
     581 
     582        return $ret; 
    582583    } 
    583584 
     
    593594     * @access private 
    594595     */ 
    595     function &_addRelatedPart(&$obj) 
     596    function &_addRelatedPart(&$obj = null) 
    596597    { 
    597598        $params['content_type'] = 'multipart/related'; 
     
    599600 
    600601        if (is_object($obj)) { 
    601             return $obj->addSubpart('', $params); 
     602            $ret = $obj->addSubpart('', $params); 
    602603        } else { 
    603604            $ret = new Mail_mimePart('', $params); 
    604             return $ret; 
    605         } 
     605        } 
     606 
     607        return $ret; 
    606608    } 
    607609 
     
    679681        if (!empty($value['description'])) { 
    680682            $params['description'] = $value['description']; 
     683        } 
     684        if (is_array($value['add_headers'])) { 
     685            $params['headers'] = $value['add_headers']; 
    681686        } 
    682687 
     
    694699     * @param string $separation The separation between these two parts. 
    695700     * @param array  $params     The Build parameters passed to the 
    696      *                           &get() function. See &get for more info. 
     701     *                           get() function. See get() for more info. 
    697702     * @param array  $headers    The extra headers that should be passed 
    698      *                           to the &headers() function. 
     703     *                           to the headers() method. 
    699704     *                           See that function for more info. 
    700705     * @param bool   $overwrite  Overwrite the existing headers with new. 
     
    712717        $body = $this->get($params); 
    713718 
    714         if (PEAR::isError($body)) { 
     719        if ($this->_isError($body)) { 
    715720            return $body; 
    716721        } 
    717722 
    718         $head = $this->txtHeaders($headers, $overwrite); 
    719         $mail = $head . $separation . $body; 
    720         return $mail; 
     723        return $this->txtHeaders($headers, $overwrite) . $separation . $body; 
    721724    } 
    722725 
     
    726729     *  
    727730     * @param array $params The Build parameters passed to the 
    728      *                      &get() function. See &get for more info. 
     731     *                      get() method. See get() for more info. 
    729732     * 
    730733     * @return mixed The e-mail body or PEAR error object 
     
    742745     * @param string $filename  Output file location 
    743746     * @param array  $params    The Build parameters passed to the 
    744      *                          &get() function. See &get for more info. 
     747     *                          get() method. See get() for more info. 
    745748     * @param array  $headers   The extra headers that should be passed 
    746      *                          to the &headers() function. 
     749     *                          to the headers() function. 
    747750     *                          See that function for more info. 
    748751     * @param bool   $overwrite Overwrite the existing headers with new. 
     
    756759        // Check state of file and raise an error properly 
    757760        if (file_exists($filename) && !is_writable($filename)) { 
    758             $err = PEAR::raiseError('File is not writable: ' . $filename); 
    759             return $err; 
     761            return $this->_raiseError('File is not writable: ' . $filename); 
    760762        } 
    761763 
     
    766768 
    767769        if (!($fh = fopen($filename, 'ab'))) { 
    768             $err = PEAR::raiseError('Unable to open file: ' . $filename); 
    769             return $err; 
     770            return $this->_raiseError('Unable to open file: ' . $filename); 
    770771        } 
    771772 
     
    773774        $head = $this->txtHeaders($headers, $overwrite, true); 
    774775        if (fwrite($fh, $head) === false) { 
    775             $err = PEAR::raiseError('Error writing to file: ' . $filename); 
    776             return $err; 
     776            return $this->_raiseError('Error writing to file: ' . $filename); 
    777777        } 
    778778 
     
    791791    /** 
    792792     * Writes (appends) the complete e-mail body into file. 
    793      *  
     793     * 
    794794     * @param string $filename Output file location 
    795795     * @param array  $params   The Build parameters passed to the 
    796      *                         &get() function. See &get for more info. 
     796     *                         get() method. See get() for more info. 
    797797     * 
    798798     * @return mixed True or PEAR error object 
     
    804804        // Check state of file and raise an error properly 
    805805        if (file_exists($filename) && !is_writable($filename)) { 
    806             $err = PEAR::raiseError('File is not writable: ' . $filename); 
    807             return $err; 
     806            return $this->_raiseError('File is not writable: ' . $filename); 
    808807        } 
    809808 
     
    814813 
    815814        if (!($fh = fopen($filename, 'ab'))) { 
    816             $err = PEAR::raiseError('Unable to open file: ' . $filename); 
    817             return $err; 
     815            return $this->_raiseError('Unable to open file: ' . $filename); 
    818816        } 
    819817 
     
    838836     * @access public 
    839837     */ 
    840     function &get($params = null, $filename = null, $skip_head = false) 
     838    function get($params = null, $filename = null, $skip_head = false) 
    841839    { 
    842840        if (isset($params)) { 
     
    872870                $rep[] = '\1\2=\3cid:' . $value['cid'] .'\3'; 
    873871                $rep[] = 'url(\1cid:' . $value['cid'] . '\1)'; 
    874                               
     872 
    875873                $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody); 
    876874                $this->_html_images[$key]['name'] 
    877875                    = $this->_basename($this->_html_images[$key]['name']); 
    878                              
    879876            } 
    880877        } 
     
    895892        case !$text && !$html && $attachments: 
    896893            $message =& $this->_addMixedPart(); 
    897             $parts_count = count($this->_parts); 
    898             for ($i = 0; $i < $parts_count; ++$i) { 
     894            for ($i = 0; $i < count($this->_parts); $i++) { 
    899895                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    900896            } 
     
    904900            $message =& $this->_addMixedPart(); 
    905901            $this->_addTextPart($message, $this->_txtbody); 
    906             $parts_count = count($this->_parts); 
    907             for ($i = 0; $i < $parts_count; ++$i) { 
     902            for ($i = 0; $i < count($this->_parts); $i++) { 
    908903                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    909904            } 
     
    932927                $ht =& $this->_addRelatedPart($message); 
    933928                $this->_addHtmlPart($ht); 
    934                 $html_images_count = count($this->_html_images); 
    935                 for ($i = 0; $i < $html_images_count; ++$i) { 
     929                for ($i = 0; $i < count($this->_html_images); $i++) { 
    936930                    $this->_addHtmlImagePart($ht, $this->_html_images[$i]); 
    937931                } 
     
    942936                $message =& $this->_addRelatedPart($null); 
    943937                $this->_addHtmlPart($message); 
    944                 $html_images_count = count($this->_html_images); 
    945                 for ($i = 0; $i < $html_images_count; ++$i) { 
     938                for ($i = 0; $i < count($this->_html_images); $i++) { 
    946939                    $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    947940                } 
     
    962955                $this->_addHtmlPart($message); 
    963956            } 
    964             $html_images_count = count($this->_html_images); 
    965             for ($i = 0; $i < $html_images_count; ++$i) { 
     957            for ($i = 0; $i < count($this->_html_images); $i++) { 
    966958                $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    967959            } 
     
    978970                $this->_addHtmlPart($message); 
    979971            } 
    980             $parts_count = count($this->_parts); 
    981             for ($i = 0; $i < $parts_count; ++$i) { 
     972            for ($i = 0; $i < count($this->_parts); $i++) { 
    982973                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    983974            } 
    984975            break; 
    985                 /* 
    986                  * Original: 
    987                  * case $html && $attachments && $html_images: 
     976 
     977        case $html && $attachments && $html_images: 
    988978            $message =& $this->_addMixedPart(); 
    989979            if (isset($this->_txtbody)) { 
     
    995985            } 
    996986            $this->_addHtmlPart($rel); 
    997                     $html_images_count = count($this->_html_images); 
    998             for ($i = 0; $i < $html_images_count; ++$i) { 
     987            for ($i = 0; $i < count($this->_html_images); $i++) { 
    999988                $this->_addHtmlImagePart($rel, $this->_html_images[$i]); 
    1000989            } 
    1001                     $parts_count = count($this->_parts); 
    1002             for ($i = 0; $i < $parts_count; ++$i) { 
     990            for ($i = 0; $i < count($this->_parts); $i++) { 
    1003991                $this->_addAttachmentPart($message, $this->_parts[$i]); 
    1004992            } 
    1005                  *      break; 
    1006                  * Alteração feita para que as imagens senjam inseridas junto com os anexos e não em uma alternate part. 
    1007                  * Para compatibilização com a fomra do expresso anexar imagens no copo do e-mail 
    1008                  *  
    1009                  */ 
    1010                 case $html && $attachments && $html_images: 
    1011             $message =& $this->_addMixedPart(); 
    1012             if (isset($this->_txtbody)) { 
    1013                 $alt =& $this->_addAlternativePart($message); 
    1014                 $this->_addTextPart($alt, $this->_txtbody); 
    1015             } else { 
    1016                                 $this->_addHtmlPart($message); 
    1017             } 
    1018  
    1019                         $html_images_count = count($this->_html_images); 
    1020             for ($i = 0; $i < $html_images_count; ++$i) { 
    1021                 $this->_addHtmlImagePart($message, $this->_html_images[$i]); 
    1022             } 
    1023             $parts_count = count($this->_parts); 
    1024             for ($i = 0; $i < $parts_count; ++$i) { 
    1025                 $this->_addAttachmentPart($message, $this->_parts[$i]); 
    1026             } 
    1027993            break; 
    1028                 /* 
    1029                  * Fim da alteração 
    1030                  */      
    1031994 
    1032995        } 
    1033996 
    1034997        if (!isset($message)) { 
    1035             $ret = null; 
    1036             return $ret; 
     998            return null; 
    1037999        } 
    10381000 
     
    10481010            // Append mimePart message headers and body into file 
    10491011            $headers = $message->encodeToFile($filename, $boundary, $skip_head); 
    1050             if (PEAR::isError($headers)) { 
     1012            if ($this->_isError($headers)) { 
    10511013                return $headers; 
    10521014            } 
    10531015            $this->_headers = array_merge($this->_headers, $headers); 
    1054             $ret = null; 
    1055             return $ret; 
     1016            return null; 
    10561017        } else { 
    10571018            $output = $message->encode($boundary, $skip_head); 
    1058             if (PEAR::isError($output)) { 
     1019            if ($this->_isError($output)) { 
    10591020                return $output; 
    10601021            } 
    10611022            $this->_headers = array_merge($this->_headers, $output['headers']); 
    1062             $body = $output['body']; 
    1063             return $body; 
     1023            return $output['body']; 
    10641024        } 
    10651025    } 
     
    10791039     * @access public 
    10801040     */ 
    1081     function &headers($xtra_headers = null, $overwrite = false, $skip_content = false) 
     1041    function headers($xtra_headers = null, $overwrite = false, $skip_content = false) 
    10821042    { 
    10831043        // Add mime version header 
     
    11771137 
    11781138        // add parameters 
    1179         $token_regexp = '#([^\x21,\x23-\x27,\x2A,\x2B,\x2D' 
    1180             . ',\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#'; 
     1139        $token_regexp = '#([^\x21\x23-\x27\x2A\x2B\x2D' 
     1140            . '\x2E\x30-\x39\x41-\x5A\x5E-\x7E])#'; 
    11811141        if (is_array($params)) { 
    11821142            foreach ($params as $name => $value) { 
     
    13541314    function encodeHeader($name, $value, $charset, $encoding) 
    13551315    { 
    1356         return Mail_mimePart::encodeHeader( 
     1316        $mime_part = new Mail_mimePart; 
     1317        return $mime_part->encodeHeader( 
    13571318            $name, $value, $charset, $encoding, $this->_build_params['eol'] 
    13581319        ); 
     
    15001461    } 
    15011462 
     1463    /** 
     1464     * PEAR::isError implementation 
     1465     * 
     1466     * @param mixed $data Object 
     1467     * 
     1468     * @return bool True if object is an instance of PEAR_Error 
     1469     * @access private 
     1470     */ 
     1471    function _isError($data) 
     1472    { 
     1473        // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473) 
     1474        if (is_object($data) && is_a($data, 'PEAR_Error')) { 
     1475            return true; 
     1476        } 
     1477 
     1478        return false; 
     1479    } 
     1480 
     1481    /** 
     1482     * PEAR::raiseError implementation 
     1483     * 
     1484     * @param $message A text error message 
     1485     * 
     1486     * @return PEAR_Error Instance of PEAR_Error 
     1487     * @access private 
     1488     */ 
     1489    function _raiseError($message) 
     1490    { 
     1491        // PEAR::raiseError() is not PHP 5.4 compatible 
     1492        return new PEAR_Error($message); 
     1493    } 
     1494 
    15021495} // End of class 
  • sandbox/2.5.1-evolucao/library/mime/mimeDecode.php

    r7673 r8235  
    6363 * This package depends on PEAR to raise errors. 
    6464 */ 
    65 //require_once 'PEAR.php'; 
     65require_once 'PEAR.php'; 
    6666 
    6767 
     
    8989 * @link       http://pear.php.net/package/Mail_mime 
    9090 */ 
    91 class Mail_mimeDecode  
     91class Mail_mimeDecode extends PEAR 
    9292{ 
    9393    /** 
     
    194194     * @return object Decoded results 
    195195     * @access public 
    196      */  
     196     */ 
    197197    function decode($params = null) 
    198198    { 
     
    326326 
    327327                    $parts = $this->_boundarySplit($body, $content_type['other']['boundary']); 
    328                     $parts_count = count($parts); 
    329                     for ($i = 0; $i < $parts_count; ++$i) { 
     328                    for ($i = 0; $i < count($parts); $i++) { 
    330329                        list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]); 
    331330                        $part = $this->_decode($part_header, $part_body, $default_ctype); 
     
    337336 
    338337                case 'message/rfc822': 
    339                     if ($this->_rfc822_bodies) { 
    340                             $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; 
    341                             $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body); 
    342                     } 
     338                                        if ($this->_rfc822_bodies) { 
     339                                                $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; 
     340                                                $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body); 
     341                                        } 
    343342                    $obj = new Mail_mimeDecode($body); 
    344343                    $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies, 
     
    348347                    break; 
    349348 
    350                 case 'message/delivery-status': 
    351                     if(!isset($content_transfer_encoding['value'])) 
    352                         $content_transfer_encoding['value'] = '7bit'; 
    353                     $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $content_transfer_encoding['value']) : $body) : null; 
    354                      break; 
    355                       
    356349                default: 
    357350                    if(!isset($content_transfer_encoding['value'])) 
     
    387380                $return[$prepend . $mime_number] = &$structure; 
    388381            } 
    389             $structure_parts_count = count($structure->parts); 
    390             for ($i = 0; $i < $structure_parts_count; ++$i) { 
     382            for ($i = 0; $i < count($structure->parts); $i++) { 
     383 
    391384             
    392385                if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') { 
     
    522515            $escaped = false; 
    523516            if ($c == '\\') { 
    524                 ++$i; 
     517                $i++; 
    525518                if ($i == $l-1) { // end of string. 
    526519                    break; 
     
    536529                    $val = ''; 
    537530                    $key = trim($key); 
    538                     ++$i; 
     531                    $i++; 
    539532                    continue; 
    540533                } 
     
    548541                } 
    549542                $key .= $c; 
    550                 ++$i; 
     543                $i++; 
    551544                continue; 
    552545            } 
     
    557550                // not in quote yet. 
    558551                if ((!strlen($val) || $lq !== false) && $c == ' ' ||  $c == "\t") { 
    559                     ++$i; 
     552                    $i++; 
    560553                    continue; // skip leading spaces after '=' or after '"' 
    561554                } 
     
    566559                    // but we will handle it as a merged part of the string.. 
    567560                    $val = !strlen(trim($val)) ? '' : trim($val); 
    568                     ++$i; 
     561                    $i++; 
    569562                    continue; 
    570563                } 
     
    594587                    $key = ''; 
    595588                    $lq = false; 
    596                     ++$i; 
     589                    $i++; 
    597590                    continue; 
    598591                } 
    599592 
    600593                $val .= $c; 
    601                 ++$i; 
     594                $i++; 
    602595                continue; 
    603596            } 
     
    609602                $lq = $q; 
    610603                $q = false; 
    611                 ++$i; 
     604                $i++; 
    612605                continue; 
    613606            } 
     
    615608            // normal char inside of quoted string.. 
    616609            $val.= $c; 
    617             ++$i; 
     610            $i++; 
    618611        } 
    619612         
     
    669662 
    670663        $len = count($tmp) -1; 
    671         for ($i = 1; $i < $len; ++$i) { 
     664        for ($i = 1; $i < $len; $i++) { 
    672665            if (strlen(trim($tmp[$i]))) { 
    673666                $parts[] = $tmp[$i]; 
     
    789782    function &uudecode($input) 
    790783    { 
    791  
    792784        // Find all uuencoded sections 
    793785        preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches); 
    794786 
    795         $matches_count = count($matches[3]); 
    796         for ($j = 0; $j < $matches_count; ++$j) { 
     787        for ($j = 0; $j < count($matches[3]); $j++) { 
    797788 
    798789            $str      = $matches[3][$j]; 
     
    801792 
    802793            $file = ''; 
    803             $str = preg_split('/\r?\n/', trim($str)); 
     794            $str = preg_split("/\r?\n/", trim($str)); 
    804795            $strlen = count($str); 
    805796 
    806             for ($i = 0; $i < $strlen; ++$i) { 
     797            for ($i = 0; $i < $strlen; $i++) { 
    807798                $pos = 1; 
    808799                $d = 0; 
     
    945936            // Multiple headers with this name 
    946937            if (is_array($headers[$hdr_name])) { 
    947                 $hdr_value_count = count($hdr_value); 
    948                 for ($i = 0; $i < $hdr_value_count; ++$i) { 
     938                for ($i = 0; $i < count($hdr_value); $i++) { 
    949939                    $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent); 
    950940                } 
     
    957947 
    958948        if (!empty($input->parts)) { 
    959             $parts_count = count($input->parts); 
    960             for ($i = 0; $i < $parts_count; ++$i) { 
     949            for ($i = 0; $i < count($input->parts); $i++) { 
    961950                $output .= $crlf . str_repeat($htab, $indent) . '<mimepart>' . $crlf . 
    962951                           Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . 
  • sandbox/2.5.1-evolucao/library/mime/mimePart.php

    r7673 r8235  
    4949 * @copyright 2003-2006 PEAR <pear-group@php.net> 
    5050 * @license   http://www.opensource.org/licenses/bsd-license.php BSD License 
    51  * @version   CVS: $Id: mimePart.php 314695 2011-08-10 07:18:07Z alec $ 
     51 * @version   CVS: $Id$ 
    5252 * @link      http://pear.php.net/package/Mail_mime 
    5353 */ 
     
    131131    */ 
    132132    var $_eol = "\r\n"; 
     133 
    133134 
    134135    /** 
     
    156157    *                         If not set, 'charset' will be used 
    157158    *     eol               - End of line sequence. Default: "\r\n" 
     159    *     headers           - Hash array with additional part headers. Array keys can be 
     160    *                         in form of <header_name>:<parameter_name> 
    158161    *     body_file         - Location of file with part's body (instead of $body) 
    159162    * 
     
    166169        } else if (defined('MAIL_MIMEPART_CRLF')) { // backward-copat. 
    167170            $this->_eol = MAIL_MIMEPART_CRLF; 
     171        } 
     172 
     173        // Additional part headers 
     174        if (!empty($params['headers']) && is_array($params['headers'])) { 
     175            $headers = $params['headers']; 
    168176        } 
    169177 
     
    216224            } 
    217225        } 
     226 
     227        // header values encoding parameters 
     228        $h_charset  = !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII'; 
     229        $h_language = !empty($params['language']) ? $params['language'] : null; 
     230        $h_encoding = !empty($params['name_encoding']) ? $params['name_encoding'] : null; 
     231 
     232 
    218233        if (!empty($params['filename'])) { 
    219234            $headers['Content-Type'] .= ';' . $this->_eol; 
    220235            $headers['Content-Type'] .= $this->_buildHeaderParam( 
    221                 'name', $params['filename'], 
    222                 !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', 
    223                 !empty($params['language']) ? $params['language'] : null, 
    224                 !empty($params['name_encoding']) ? $params['name_encoding'] : null 
     236                'name', $params['filename'], $h_charset, $h_language, $h_encoding 
    225237            ); 
    226238        } 
     
    232244                $headers['Content-Disposition'] .= ';' . $this->_eol; 
    233245                $headers['Content-Disposition'] .= $this->_buildHeaderParam( 
    234                     'filename', $params['filename'], 
    235                     !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', 
    236                     !empty($params['language']) ? $params['language'] : null, 
     246                    'filename', $params['filename'], $h_charset, $h_language, 
    237247                    !empty($params['filename_encoding']) ? $params['filename_encoding'] : null 
    238248                ); 
    239249            } 
     250 
     251            // add attachment size 
     252            $size = $this->_body_file ? filesize($this->_body_file) : strlen($body); 
     253            if ($size) { 
     254                $headers['Content-Disposition'] .= ';' . $this->_eol . ' size=' . $size; 
     255            } 
    240256        } 
    241257 
    242258        if (!empty($params['description'])) { 
    243259            $headers['Content-Description'] = $this->encodeHeader( 
    244                 'Content-Description', $params['description'], 
    245                 !empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII', 
    246                 !empty($params['name_encoding']) ? $params['name_encoding'] : 'quoted-printable', 
     260                'Content-Description', $params['description'], $h_charset, $h_encoding, 
    247261                $this->_eol 
    248262            ); 
     263        } 
     264 
     265        // Search and add existing headers' parameters 
     266        foreach ($headers as $key => $value) { 
     267            $items = explode(':', $key); 
     268            if (count($items) == 2) { 
     269                $header = $items[0]; 
     270                $param  = $items[1]; 
     271                if (isset($headers[$header])) { 
     272                    $headers[$header] .= ';' . $this->_eol; 
     273                } 
     274                $headers[$header] .= $this->_buildHeaderParam( 
     275                    $param, $value, $h_charset, $h_language, $h_encoding 
     276                ); 
     277                unset($headers[$key]); 
     278            } 
    249279        } 
    250280 
     
    283313            $encoded['body'] = '';  
    284314 
    285             $subparts_count = count($this->_subparts); 
    286             for ($i = 0; $i < $subparts_count; ++$i) { 
     315            for ($i = 0; $i < count($this->_subparts); $i++) { 
    287316                $encoded['body'] .= '--' . $boundary . $eol; 
    288317                $tmp = $this->_subparts[$i]->encode(); 
    289                 if (PEAR::isError($tmp)) { 
     318                if ($this->_isError($tmp)) { 
    290319                    return $tmp; 
    291320                } 
     
    310339            } 
    311340 
    312             if (PEAR::isError($body)) { 
     341            if ($this->_isError($body)) { 
    313342                return $body; 
    314343            } 
     
    340369    { 
    341370        if (file_exists($filename) && !is_writable($filename)) { 
    342             $err = PEAR::raiseError('File is not writeable: ' . $filename); 
     371            $err = $this->_raiseError('File is not writeable: ' . $filename); 
    343372            return $err; 
    344373        } 
    345374 
    346375        if (!($fh = fopen($filename, 'ab'))) { 
    347             $err = PEAR::raiseError('Unable to open file: ' . $filename); 
     376            $err = $this->_raiseError('Unable to open file: ' . $filename); 
    348377            return $err; 
    349378        } 
     
    362391        } 
    363392 
    364         return PEAR::isError($res) ? $res : $this->_headers; 
     393        return $this->_isError($res) ? $res : $this->_headers; 
    365394    } 
    366395 
     
    394423 
    395424        if (count($this->_subparts)) { 
    396             $subparts_count = count($this->_subparts); 
    397             for ($i = 0; $i < $subparts_count; ++$i) { 
     425            for ($i = 0; $i < count($this->_subparts); $i++) { 
    398426                fwrite($fh, $f_eol . '--' . $boundary . $eol); 
    399427                $res = $this->_subparts[$i]->_encodePartToFile($fh); 
    400                 if (PEAR::isError($res)) { 
     428                if ($this->_isError($res)) { 
    401429                    return $res; 
    402430                } 
     
    413441                $this->_body_file, $this->_encoding, $fh 
    414442            ); 
    415             if (PEAR::isError($res)) { 
     443            if ($this->_isError($res)) { 
    416444                return $res; 
    417445            } 
     
    429457     *                       as the $params argument for constructor. 
    430458     * 
    431      * @return Mail_mimePart A reference to the part you just added. It is 
     459     * @return Mail_mimePart A reference to the part you just added. In PHP4, it is 
    432460     *                       crucial if using multipart/* in your subparts that 
    433461     *                       you use =& in your script when calling this function, 
     
    437465    function &addSubpart($body, $params) 
    438466    { 
    439         $this->_subparts[] = new Mail_mimePart($body, $params); 
    440         return $this->_subparts[count($this->_subparts) - 1]; 
     467        $this->_subparts[] = $part = new Mail_mimePart($body, $params); 
     468        return $part; 
    441469    } 
    442470 
     
    484512    { 
    485513        if (!is_readable($filename)) { 
    486             $err = PEAR::raiseError('Unable to read file: ' . $filename); 
     514            $err = $this->_raiseError('Unable to read file: ' . $filename); 
    487515            return $err; 
    488516        } 
    489517 
    490518        if (!($fd = fopen($filename, 'rb'))) { 
    491             $err = PEAR::raiseError('Could not open file: ' . $filename); 
     519            $err = $this->_raiseError('Could not open file: ' . $filename); 
    492520            return $err; 
    493521        } 
     
    572600        } 
    573601        */ 
    574         $lines  = preg_split('/\r?\n/', $input); 
     602        $lines  = preg_split("/\r?\n/", $input); 
    575603        $escape = '='; 
    576604        $output = ''; 
     
    583611                $char = $line[$i]; 
    584612                $dec  = ord($char); 
    585                 ++$i; 
     613                $i++; 
    586614 
    587615                if (($dec == 32) && (!isset($line[$i]))) { 
     
    621649 
    622650    /** 
    623      * Encodes the paramater of a header. 
     651     * Encodes the parameter of a header. 
    624652     * 
    625653     * @param string $name      The name of the header-parameter 
     
    641669        // value needs encoding if contains non-ASCII chars or is longer than 78 chars 
    642670        if (!preg_match('#[^\x20-\x7E]#', $value)) { 
    643             $token_regexp = '#([^\x21,\x23-\x27,\x2A,\x2B,\x2D' 
    644                 . ',\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#'; 
     671            $token_regexp = '#([^\x21\x23-\x27\x2A\x2B\x2D' 
     672                . '\x2E\x30-\x39\x41-\x5A\x5E-\x7E])#'; 
    645673            if (!preg_match($token_regexp, $value)) { 
    646674                // token 
     
    664692        // RFC2231: 
    665693        $encValue = preg_replace_callback( 
    666             '/([^\x21,\x23,\x24,\x26,\x2B,\x2D,\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])/', 
     694            '/([^\x21\x23\x24\x26\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E])/', 
    667695            array($this, '_encodeReplaceCallback'), $value 
    668696        ); 
     
    690718                $value = ''; 
    691719            } 
    692             ++$headCount; 
     720            $headCount++; 
    693721        } 
    694722 
     
    788816            'resent-from', 'resent-to', 'resent-cc', 'resent-bcc', 
    789817            'resent-sender', 'resent-reply-to', 
     818            'mail-reply-to', 'mail-followup-to', 
    790819            'return-receipt-to', 'disposition-notification-to', 
    791820        ); 
     
    809838        if (!empty($separator)) { 
    810839            // Simple e-mail address regexp 
    811             $email_regexp = '(\S+|("[^\r\n"]+"))@\S+'; 
     840            $email_regexp = '([^\s<]+|("[^\r\n"]+"))@\S+'; 
    812841 
    813842            $parts = Mail_mimePart::_explodeQuotedString($separator, $value); 
     
    923952        $strlen = strlen($string); 
    924953 
    925         for ($q=$p=$i=0; $i < $strlen; ++$i) { 
     954        for ($q=$p=$i=0; $i < $strlen; $i++) { 
    926955            if ($string[$i] == "\"" 
    927956                && (empty($string[$i-1]) || $string[$i-1] != "\\") 
     
    9851014                $cutpoint = $maxLength; 
    9861015                // RFC 2047 specifies that any split header should 
    987                 // be seperated by a CRLF SPACE. 
     1016                // be separated by a CRLF SPACE. 
    9881017                if ($output) { 
    9891018                    $output .= $eol . ' '; 
     
    10271056 
    10281057                    // RFC 2047 specifies that any split header should 
    1029                     // be seperated by a CRLF SPACE 
     1058                    // be separated by a CRLF SPACE 
    10301059                    if ($output) { 
    10311060                        $output .= $eol . ' '; 
     
    11051134            $prev  = ''; 
    11061135 
    1107             for ($i=1; $i<=$length; ++$i) { 
     1136            for ($i=1; $i<=$length; $i++) { 
    11081137                // See #17311 
    11091138                $chunk = mb_substr($str, $start, $i-$start, $charset); 
     
    11361165            $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/'; 
    11371166 
    1138             for ($i=0; $i<=$length; ++$i) { 
     1167            for ($i=0; $i<=$length; $i++) { 
    11391168                $char = mb_substr($str, $i, 1, $charset); 
    11401169                // RFC recommends underline (instead of =20) in place of the space 
     
    11981227    } 
    11991228 
     1229    /** 
     1230     * PEAR::isError implementation 
     1231     * 
     1232     * @param mixed $data Object 
     1233     * 
     1234     * @return bool True if object is an instance of PEAR_Error 
     1235     * @access private 
     1236     */ 
     1237    function _isError($data) 
     1238    { 
     1239        // PEAR::isError() is not PHP 5.4 compatible (see Bug #19473) 
     1240        if (is_object($data) && is_a($data, 'PEAR_Error')) { 
     1241            return true; 
     1242        } 
     1243 
     1244        return false; 
     1245    } 
     1246 
     1247    /** 
     1248     * PEAR::raiseError implementation 
     1249     * 
     1250     * @param $message A text error message 
     1251     * 
     1252     * @return PEAR_Error Instance of PEAR_Error 
     1253     * @access private 
     1254     */ 
     1255    function _raiseError($message) 
     1256    { 
     1257        // PEAR::raiseError() is not PHP 5.4 compatible 
     1258        return new PEAR_Error($message); 
     1259    } 
     1260 
    12001261} // End of class 
  • sandbox/2.5.1-evolucao/phpgwapi/inc/class.db.inc.php

    r8234 r8235  
    209209                                        $GLOBALS[ 'phpgw' ]->ADOdb = NULL; 
    210210                                } 
    211                                 if (!is_object($GLOBALS['phpgw']->ADOdb) ||     // we have no connection so far 
     211                                if (!isset($GLOBALS[ 'phpgw' ]->ADOdb) /*!is_object($GLOBALS['phpgw']->ADOdb)*/ ||      // we have no connection so far 
    212212                                        (isset($GLOBALS['phpgw']->db) && is_object($GLOBALS['phpgw']->db) &&    // we connect to a different db, then the global one 
    213213                                                ($this->Type != $GLOBALS['phpgw']->db->Type || 
     
    217217                                                $this->Port != $GLOBALS['phpgw']->db->Port))) 
    218218                                { 
    219                                         if (!is_object($GLOBALS['phpgw']->ADOdb))       // use the global object to store the connection 
     219                                        if (isset($GLOBALS[ 'phpgw' ]->ADOdb)/*!is_object($GLOBALS['phpgw']->ADOdb)*/)  // use the global object to store the connection 
    220220                                        { 
    221221                                                $this->Link_ID = &$GLOBALS['phpgw']->ADOdb; 
Note: See TracChangeset for help on using the changeset viewer.