Exemple #1
0
echo $run_welcome;
// Читаем последовательно сообщения и обрабатываем
if ($mbox = imap_open(IMAILBOX, ILOGIN, IPASSWORD)) {
    $nomsg = imap_num_msg($mbox);
    // Кол-во сообщений
    echo "Всего сообщений: {$nomsg}\n";
    for ($j = 1; $j <= $nomsg; $j++) {
        // Просматриваем все письма в ящике
        $user = '';
        // Сбрасываем пользователя
        ob_start();
        // Буферизуем вывод для каждого пользователя
        echo "======================";
        // Выводим данные о сообщении
        $h = mp_header($mbox, $j);
        print_ra($h);
        if ($h['Deleted']) {
            // Если сообщение удалено
            echo "Сообщение удалено!\n";
        } elseif (!isset($h['subject'])) {
            echo "Тема не задана!\n";
        } else {
            $module = 'app_' . $h['subject'] . '.php';
            // Имя модуля
            if (file_exists($module)) {
                // Если модуль существует
                list($message, $charset) = retrieve_message($mbox, $j);
                // Извлекаем сообщение
                echo "Кодировка: {$charset}\n";
                $message = mp_explode($message);
                // Преобразуем
Exemple #2
0
function print_rt($array, $htmlchars = 0, $style = '')
{
    if (is_array($array)) {
        if (!is_array(current($array))) {
            $array = array(0 => $array);
        }
        echo $style ? "\n<table {$style}>\n" : "\n<table border=1>\n<tr>\n";
        $a_keys = array_keys(current($array));
        echo " <th {$style}>#\n";
        while (list($field, $fieldname) = each($a_keys)) {
            echo " <th {$style}>{$fieldname}\n";
        }
        while (list($field, $one) = each($array)) {
            if (is_array($one)) {
                echo "<tr>\n <td {$style}><i>{$field}</i>\n";
                while (list($field, $fieldname) = each($one)) {
                    if (is_array($fieldname) or is_object($fieldname)) {
                        echo ' <td $style>';
                        print_ra($fieldname, $htmlchars, $style);
                    } else {
                        switch ($htmlchars) {
                            case 1:
                                $fieldname = htmlspecialchars($fieldname);
                                break;
                            case 2:
                                $fieldname = strip_tags($fieldname);
                                break;
                            default:
                        }
                        // switch
                        if (strlen($fieldname) > 20) {
                            $fieldname = substr($fieldname, 0, 20) . '<span title="' . $fieldname . '">...</span>';
                        }
                        echo " <td {$style}>{$fieldname}\n";
                    }
                }
                // if
            } else {
                // if
                echo "<tr>\n <td {$style}>" . ($one ? $one : '<i>empty</i>') . "\n";
            }
        }
        // while
        echo "</table>\n";
        return 1;
    } else {
        // if
        return 0;
    }
}
Exemple #3
0
             $r[$k] = $head;
         }
         // for
         print_rt($r);
     }
     // if
     break;
     //////////////////////////////////////////////////
 //////////////////////////////////////////////////
 case 'echo':
     // параметр - номер сообщения
     //////////////////////////////////////////////////
     $header = imap_header($mbi, $params);
     print_ra($header);
     $structure = imap_fetchstructure($mbi, $params);
     print_ra($structure);
     if ($structure->type == 1) {
         // Если MULTI-PART письмо
         $body = imap_fetchbody($mbi, $params, '1');
     } else {
         $body = imap_body($mbi, $params);
     }
     if (isset($structure->parameters[0]->attribute)) {
         $cp = strtolower($structure->parameters[0]->value);
         echo $structure->parameters[0]->attribute . ": {$cp}\n";
         $cp_table = array('koi8-r' => 'k', 'windows-1251' => 'w', 'iso8859-5' => 'i', 'x-cp866' => 'a', 'x-mac-cyrillic' => 'm');
         if (isset($cp_table[$cp])) {
             $body = convert_cyr_string($body, $cp_table[$cp], 'w');
         }
     }
     // if