Example #1
0
 function iso_charset($recipient)
 {
     $this->set(array(
     'recipients' => $recipient,
     'subject' => Ak::recode('testing isø charsets','ISO-8859-1', 'UTF-8'),
     'from' => "*****@*****.**",
     'sent_on' => Ak::getDate(strtotime('2004-12-12')),
     'cc' => "*****@*****.**",
     'bcc' => "*****@*****.**",
     'body' => "Nothing to see here.",
     'charset' => "ISO-8859-1"
     ));
 }
Example #2
0
 /**
  * PEAR's header decoding function is buggy and is not enough tested, so we 
  * override it using the Akelos charset transcoding engine to get the result
  * as UTF-8
  */
 function _decodeHeader($encoded_header)
 {
     $encoded_header = str_replace(array('_', "\r", "\n =?"), array(' ', "\n", "\n=?"), preg_replace('/\\?\\=([^=^\\n^\\r]+)?\\=\\?/', "?=\$1\n=?", $encoded_header));
     $decoded = $encoded_header;
     if (preg_match_all('/(\\=\\?([^\\?]+)\\?([BQ]{1})\\?([^\\?]+)\\?\\=?)+/i', $encoded_header, $match)) {
         foreach ($match[0] as $k => $encoded) {
             $charset = strtoupper($match[2][$k]);
             $decode_function = strtolower($match[3][$k]) == 'q' ? 'quoted_printable_decode' : 'base64_decode';
             $decoded_part = trim(Ak::recode($decode_function($match[4][$k]), AK_ACTION_MAILER_DEFAULT_CHARSET, $charset, true));
             $decoded = str_replace(trim($match[0][$k]), $decoded_part, $decoded);
         }
     }
     return trim(preg_replace("/(%0A|%0D|\n+|\r+)/i", '', $decoded));
 }
Example #3
0
 protected function _decodeHeader($encoded_header)
 {
     // PEAR's header decoding function is buggy and is not enough tested, so we
     // override it using the Akelos charset transcoding engine to get the result
     // as UTF-8
     $encoded_header = str_replace(array('_', "\r", "\n =?"), array(' ', "\n", "\n=?"), preg_replace('/\\?\\=([^=^\\n^\\r]+)?\\=\\?/', "?=\$1\n=?", $encoded_header));
     $decoded = $encoded_header;
     if (preg_match_all('/(\\=\\?([^\\?]+)\\?([BQ]{1})\\?([^\\?]+)\\?\\=?)+/i', $encoded_header, $match)) {
         foreach ($match[0] as $k => $encoded) {
             $charset = strtoupper($match[2][$k]);
             $decode_function = strtolower($match[3][$k]) == 'q' ? 'quoted_printable_decode' : 'base64_decode';
             $decoded_part = trim(Ak::recode($decode_function($match[4][$k]), AK_ACTION_MAILER_DEFAULT_CHARSET, $charset, true));
             $decoded = str_replace(trim($match[0][$k]), $decoded_part, $decoded);
         }
     }
     return trim(preg_replace("/(%0A|%0D|\n+|\r+)/i", '', $decoded));
 }
Example #4
0
        case '<':
            $command = $last_command;
            echo "running command: " . $command;
        default:
            $last_command = $command;
            $_script_name = array_shift(explode(' ', trim($command) . ' '));
            $_script_file_name = AK_OS == 'WINDOWS' ? $_script_name : AK_SCRIPT_DIR . DS . $_script_name;
            if (file_exists($_script_file_name)) {
                $command = trim(substr(trim($command), strlen($_script_name)));
                echo "\n";
                passthru((AK_OS == 'WINDOWS' ? 'php -q ' : '') . $_script_file_name . ' ' . escapeshellcmd($command));
                echo "\n>>> ";
            } else {
                ob_start();
                $parser = new AkPhpParser($command);
                echo $parser->parse() === 0 ? '' : "...";
                if (!$parser->hasErrors()) {
                    eval($parser->code);
                } else {
                    echo "\nPHP Error: \n" . join("\n", $parser->getErrors()) . "\n";
                }
                $result = ob_get_contents();
                ob_end_clean();
                $result = strstr($result, ": eval()") ? strip_tags(array_shift(explode(': eval()', $result))) : $result;
                Ak::file_add_contents(AK_LOG_DIR . DS . 'command_line.log', $promt_line . $command . "\n" . $result . "\n");
                echo empty($result) ? $promt_line : "\n" . (AK_RECODE_UTF8_ON_CONSOLE_TO ? Ak::recode($result, AK_RECODE_UTF8_ON_CONSOLE_TO) : $result) . "\n\n{$promt_line}";
            }
            break;
    }
}
fclose(AK_PROMT);
Example #5
0
                echo "\n>>> ";

        }else{

            ob_start();
            $parser = new AkPhpParser($command);
            echo $parser->parse() === 0 ? '' : "...";
            if(!$parser->hasErrors()){
                eval($parser->code);
            }else{
                echo "\nPHP Error: \n".join("\n", $parser->getErrors())."\n";
            }

            $result = ob_get_contents();
            ob_end_clean();

            $result = strstr($result,": eval()") ?
            strip_tags(array_shift(explode(': eval()',$result))) :
            $result;

            Ak::file_add_contents(AK_LOG_DIR.DS.'command_line.log',$promt_line.$command."\n".$result."\n");
            echo empty($result) ? $promt_line : "\n".
            (AK_RECODE_UTF8_ON_CONSOLE_TO ? Ak::recode($result, AK_RECODE_UTF8_ON_CONSOLE_TO) : $result).
            "\n\n$promt_line";
        }
        break;
    }
}
fclose(AK_PROMT);

?>
Example #6
0
 /**
  * RFC 2231 Implementation
  */
 function _decodeHeaderAttribute($header_attribute, $charset = '')
 {
     if(preg_match("/^([A-Z0-9\-]+)(\'[A-Z\-]{2,5}\')?/i",$header_attribute,$match)){
         $charset = $match[1];
         $header_attribute = urldecode(str_replace(array('_','='),array('%20','%'), substr($header_attribute,strlen($match[0]))));
     }
     return Ak::recode($header_attribute, 'UTF-8', $charset);
 }
Example #7
0
    function test_iso_charset()
    {
        $Expected =& $this->new_mail();
        $Expected->setTo($this->recipient);
        $Expected->setCharset("ISO-8859-1");
        $Expected->setSubject(Ak::recode('testing isø charsets','ISO-8859-1', 'UTF-8'));
        $Expected->setBody("Nothing to see here.");
        $Expected->setFrom("*****@*****.**");
        $Expected->setDate("2004-12-12");
        $Expected->setCc("*****@*****.**");
        $Expected->setBcc("*****@*****.**");

        $TestMailer =& new TestMailer();

        $this->assertTrue($Created = $TestMailer->create('iso_charset', $this->recipient));

        $this->assertEqual($Expected->getEncoded(), $Created->getEncoded());

        $this->assertTrue($TestMailer->deliver('iso_charset', $this->recipient));
        $this->assertTrue(!empty($TestMailer->deliveries[0]));
        $this->assertEqual($Expected->getEncoded(), $TestMailer->deliveries[0]);

        $this->assertEqual($Created->getSubject(), '=?ISO-8859-1?Q?testing_is=F8_charsets?=');

    }