Ignore:
Timestamp:
01/05/09 17:20:41 (15 years ago)
Author:
niltonneto
Message:

resolve #381

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.ScriptS.inc.php

    r330 r564  
    1313        var $rules;                                             // Regras do sieve; 
    1414        var $errstr;                                    // Erros retornados; 
    15         var $size;                                              // var tamanho; 
    16         var $so;                                                // para verificar se a regra foi criada por outro tipo serviço de filtros; 
     15        var $size;                                              // Tamanho; 
     16        var $so;                                                // Verifica se a regra foi criada por outro tipo serviço de filtros; 
    1717        var $continuebit; 
    1818        var $sizebit; 
     
    2222        var $newrules = array(); 
    2323        var $newout; 
     24        var $teste; 
     25        var $EmailVoip; 
     26        var $EmailExpresso; 
    2427         
    2528        function ScriptS(){ 
     
    4245        $this->keepbit          = 8; 
    4346        $this->regexbit         = 128; 
     47         
     48        $this->EmailVoip = trim($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect']); 
     49        $this->EmailExpresso = trim($_SESSION['phpgw_info']['expressomail']['user']['email']); 
    4450         
    4551        } 
     
    189195                        return "Ok"; 
    190196                }else{ 
    191                         return "Problemas na criação do arquivo!"; 
     197                        return "Problemas na criação do arquivo!\n" . $this->teste; 
    192198                } 
    193199        } 
    194200 
    195         function convert_specialchar($input){ 
    196                   $special_char = false; 
    197                   for ( $i = 0; $i < strlen($input); $i++ ) 
    198                       if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 
    199                       { 
    200                           $special_char = true; 
    201                           $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 
    202                       } 
    203                        
    204            if ( $special_char ) 
    205                    { 
    206                    /*  When using arrays with pattern and replacement, the keys are processed in the order they appear in the array. See preg_replace in php.net/preg_replace */ 
     201    function convert_specialchar($input) 
     202    { 
     203      $special_char = false; 
     204          for ( $i = 0; $i < strlen($input); $i++ ) 
     205          { 
     206              if ( preg_match('/[ÁáÉéÍíÓóÚúÀàÈèÌìÒòÙùüÇçÃãÕõÂâÊêÔô®©§ªºÐ¹²³°¢¿Æ£µøæß«»Ø÷±¬]/', $input[$i]) ) 
     207              { 
     208                  $special_char = true; 
     209                  $input = preg_replace('/'.$input[$i].'/', '=' . bin2hex($input[$i]), $input); 
     210              } 
     211          }    
     212       
     213      if ( $special_char ) 
     214          { 
     215                   /* * 
     216                    * When using arrays with pattern and replacement,  
     217                    * the keys are processed in the order they appear in the array.  
     218                    * See preg_replace in php.net/preg_replace  
     219                    * */ 
    207220                   $patterns[0] = '/=c3/i'; 
    208221                   $patterns[1] = '/ /'; 
     
    210223                   $replacements[0] = '_'; 
    211224                   $input = preg_replace($patterns, $replacements, $input); 
    212                    } 
    213                 //   if (($input{0}) && (!eregi('^[a-zA-Z0-9=\-@&\.#\$!?%:\+_<>\(\)\"\ ]+$',$input))) 
    214                 //              return false;    
    215                 //      else 
    216                         return($input); 
    217         } 
     225           } 
     226        
     227       return($input); 
     228    } 
    218229 
    219230        // Grava a nova regra; 
     
    227238                $regexused = 0; 
    228239                $rejectused = 0; 
     240                $notify = 0; 
    229241                $newscriptbody = ""; 
    230242        $continue = 1; 
     243        $tmpSubject = ""; 
    231244         
    232245                // Recebe os valores das regras; 
     
    237250          $rule['from']              = $this->convert_specialchar($tmp1[3]); 
    238251          $rule['to']            = $this->convert_specialchar($tmp1[4]); 
    239                   $rule['subject'] = $this->convert_specialchar($tmp1[5]); 
     252                  $tmpSubject                    = $tmp1[5]; 
     253                  $rule['subject']               = $this->convert_specialchar($tmp1[5]); 
    240254          $rule['action']            = $tmp1[6]; 
    241255                  $rule['action_arg']    = utf8_encode(preg_replace("/\\r\\n/","\r\n",$tmp1[7])); 
     
    337351                if (!$rule['unconditional']) $newruletext .= ") {\n\t"; 
    338352         
    339                 if (preg_match("/folder/i",$rule['action'])) { 
     353                if (preg_match("/folder/i",$rule['action'])) 
     354                { 
    340355                    $newruletext .= "fileinto \"" . $rule['action_arg'] . "\";"; 
    341356                } 
    342                 if (preg_match("/reject/i",$rule['action'])) { 
     357                 
     358                if (preg_match("/reject/i",$rule['action'])) 
     359                { 
    343360                    $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; 
    344361                    $rejectused = 1; 
    345362                } 
    346                 if (preg_match("/address/i",$rule['action'])) { 
     363                 
     364                if (preg_match("/address/i",$rule['action'])) 
     365                { 
    347366                    $newruletext .= "redirect \"" . $rule['action_arg'] . "\";"; 
    348367                } 
     368                 
     369                if (preg_match("/notify/i",$rule['action'])) 
     370                { 
     371                                $newruletext .= "notify :method \"mailto\" :options [\"".$this->EmailVoip ."\"]:" . 
     372                                                                "message \"<expressovoip><from>". $this->EmailExpresso."</from>". 
     373                                                                "<br/><Subject>".utf8_encode($tmpSubject)."</Subject></expressovoip>\";"; 
     374                                $notify = 1;                                                     
     375                } 
     376                 
    349377                if (preg_match("/discard/i",$rule['action'])) { 
    350378                    $newruletext .= "discard;"; 
     
    362390              } 
    363391                }// Fim do Foreach; 
    364                  
     392                $this->teste = $newscriptbody;           
    365393                // Para a regras fora do escritorio; 
    366394        unset($tmp); 
     
    389417            if ($activerules) { 
    390418                $newscripthead .= "require [\"fileinto\""; 
     419                 
     420                if($notify){ 
     421                        $newscripthead .= ",\"notify\"";                         
     422                } 
    391423                if($regexused){ 
    392424                        $newscripthead .= ",\"regex\""; 
     
    405437            } 
    406438                 
    407                 //preg_replace("/[\\n\\r]/","", $p);             
    408                  
    409    
    410439            // Cria o rodapé do arquivo; 
    411440            $newscriptfoot  = ""; 
Note: See TracChangeset for help on using the changeset viewer.