예제 #1
0
function html2plaintext($text, $texthtml0, $wrap)
{
    global $opt, $smiley;
    if ($texthtml0) {
        $text = str_replace(['<p>', "\n", "\r"], '', $text);
        $text = str_replace(['<br />', '</p>'], "\n", $text);
        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
    } else {
        // convert smilies ...
        $countSmileyImage = count($smiley['image']);
        for ($n = 0; $n < $countSmileyImage; $n++) {
            $text = mb_ereg_replace("<img [^>]*?src=[^>]+?" . str_replace('.', '\\.', $smiley['file'][$n]) . "[^>]+?>", "[s![" . $smiley['text'][$n] . "]!s]", $text);
            // the [s[ ]s] is needed to protect the spaces around the smileys
        }
        $h2t = new html2text($text);
        $h2t->set_base_url($opt['page']['default_absolute_url']);
        $h2t->width = $wrap;
        $text = $h2t->get_text();
        $text = str_replace(['[s![', ']!s]'], '', $text);
        // remove e.g. trailing \n created from </p> by html2text
        while (substr($text, -2) == "\n\n") {
            $text = substr($text, 0, strlen($text) - 1);
        }
    }
    return $text;
}
예제 #2
0
function html2plaintext($text, $texthtml0)
{
    global $opt, $absolute_server_URI;
    if ($texthtml0) {
        $text = str_replace(array('<p>', "\n", "\r"), '', $text);
        $text = str_replace(array('<br />', '</p>'), "\n", $text);
        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
    } else {
        $h2t = new html2text($text);
        $h2t->set_base_url(isset($opt['page']['absolute_url']) ? $opt['page']['absolute_url'] : $absolute_server_URI);
        $text = $h2t->get_text();
        // remove e.g. trailing \n created from </p> by html2text
        while (substr($text, -2) == "\n\n") {
            $text = substr($text, 0, strlen($text) - 1);
        }
    }
    return $text;
}
예제 #3
0
 } else {
     // we are the cache-owner
     $tplname = 'removelog_cacheowner';
     if ($commit == 1) {
         //send email to logowner
         $email_content = read_file($stylepath . '/email/removed_log.email');
         $message = isset($_POST['logowner_message']) ? $_POST['logowner_message'] : '';
         if ($message != '') {
             //message to logowner
             $message = $removed_message_title . "\n" . $message . "\n" . $removed_message_end;
         }
         $logtext = $log_record['log_text'];
         if ($log_record['text_html'] != 0) {
             $logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
             $h2t = new html2text($logtext);
             $h2t->set_base_url($absolute_server_URI);
             $logtext = $h2t->get_text();
         }
         $logtext = $removed_text_title . "\n" . trim($logtext) . "\n" . $removed_text_end;
         //get cache owner name
         $cache_owner_rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $log_record['cache_owner_id']);
         $cache_owner_record = sql_fetch_array($cache_owner_rs);
         mysql_free_result($cache_owner_rs);
         //get email address of logowner
         $log_user_rs = sql("SELECT `email`, `username` FROM `user` WHERE `user_id`='&1'", $log_record['log_user_id']);
         $log_user_record = sql_fetch_array($log_user_rs);
         mysql_free_result($log_user_rs);
         // insert log data
         $email_content = mb_ereg_replace('%log_owner%', $log_user_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_owner%', $cache_owner_record['username'], $email_content);
         $email_content = mb_ereg_replace('%cache_name%', $log_record['cache_name'], $email_content);
예제 #4
0
파일: web.php 프로젝트: Br3nda/mahara
/**
 * Given HTML, converts and formats it as text
 *
 * @param string $html The html to be formatted
 * @return string The formatted text
 */
function html2text($html)
{
    require_once 'html2text/class.html2text.php';
    $h2t = new html2text($html);
    $h2t->set_base_url(get_config('wwwroot'));
    return $h2t->get_text();
}
예제 #5
0
파일: Email.php 프로젝트: MirellJ/wlox-auth
    public static function send($from, $recipients, $subject, $from_name = false, $text_version = false, $html_version = false, $variables = false)
    {
        global $CFG;
        $reply_to = $from;
        $var_string = '';
        if (is_array($variables)) {
            foreach ($variables as $name => $value) {
                $var_string .= '
					' . ucfirst(str_ireplace('_', ' ', $name)) . ': ' . $value . '<br/>';
            }
        }
        $html_version = str_ireplace('[variables]', $var_string, $html_version);
        $text_version = str_ireplace('[variables]', $var_string, $text_version);
        $html_version = str_ireplace('&amp;', '&', $html_version);
        $text_version = str_ireplace('&amp;', '&', $text_version);
        if (is_array($variables)) {
            foreach ($variables as $key => $val) {
                $html_version = str_ireplace('[' . $key . ']', $val, $html_version);
                $text_version = str_ireplace('[' . $key . ']', $val, $text_version);
                $subject = str_ireplace('[' . $key . ']', $val, $subject);
            }
        }
        if (!$text_version) {
            include_once 'html2text.php';
            $h2t = new html2text($html_version);
            $h2t->set_base_url($CFG->frontend_baseurl);
            $text_version = $h2t->get_text();
        }
        if (!$html_version) {
            $html_version = nl2br($text_version);
        }
        include_once 'phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        $mail->isSMTP();
        $mail->CharSet = 'UTF-8';
        $mail->SMTPDebug = 0;
        $mail->Debugoutput = 'html';
        $mail->Host = $CFG->email_smtp_host;
        $mail->Port = $CFG->email_smtp_port;
        $mail->SMTPSecure = $CFG->email_smtp_security;
        $mail->SMTPAuth = true;
        $mail->Username = $CFG->email_smtp_username;
        $mail->Password = $CFG->email_smtp_password;
        $mail->setFrom($CFG->email_smtp_send_from, $from_name);
        $mail->addReplyTo($from);
        if (is_array($recipients)) {
            foreach ($recipients as $name => $email) {
                if (!self::verifyAddress($email)) {
                    unset($recipients[$name]);
                    continue;
                }
                $mail->addAddress($email, $name);
            }
        } else {
            if (self::verifyAddress($recipients)) {
                $mail->addAddress($recipients);
            }
        }
        $mail->Subject = $subject;
        $mail->msgHTML($html_version);
        $mail->AltBody = $text_version;
        if ($mail->send()) {
            return true;
        } else {
            trigger_error('Email could not be sent: ' . print_r($mail->ErrorInfo, true), E_USER_WARNING);
            return false;
        }
    }
예제 #6
0
파일: runwatch.php 프로젝트: 4Vs/oc-server3
function process_log_watch($user_id, $log_id)
{
    global $dblink, $logwatch_text, $absolute_server_URI;
    //	echo "process_log_watch($user_id, $log_id)\n";
    $rsLog = sql("SELECT cache_logs.cache_id cache_id, cache_logs.type, cache_logs.text text, cache_logs.text_html text_html, cache_logs.date logdate, user.username username, caches.name cachename, caches.wp_oc wp_oc FROM `cache_logs`, `user`, `caches` WHERE (cache_logs.user_id = user.user_id) AND (cache_logs.cache_id = caches.cache_id) AND (cache_logs.id = '&1')", $log_id);
    $rLog = sql_fetch_array($rsLog);
    mysql_free_result($rsLog);
    $watchtext = $logwatch_text;
    $logtext = $rLog['text'];
    if ($rLog['text_html'] != 0) {
        $logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
        $h2t = new html2text($logtext);
        $h2t->set_base_url($absolute_server_URI);
        $logtext = $h2t->get_text();
        /*
        		$logtext = html_entity_decode($logtext, ENT_COMPAT, 'UTF-8');
        		$logtext = mb_ereg_replace("\r", '', $logtext);
        		$logtext = mb_ereg_replace("\n", '', $logtext);
        		$logtext = mb_ereg_replace('</p>', "</p>\n", $logtext);
        		$logtext = mb_ereg_replace('<br/>', "<br/>\n", $logtext);
        		$logtext = mb_ereg_replace('<br />', "<br />\n", $logtext);
        		$logtext = strip_tags($logtext);
        */
    }
    if (strpos($rLog['logdate'], '00:00:00') > 0) {
        $dateformat = 'd.m.Y';
    } else {
        $dateformat = 'd.m.Y, H:i';
    }
    $watchtext = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['logdate'])), $watchtext);
    $watchtext = mb_ereg_replace('{wp_oc}', $rLog['wp_oc'], $watchtext);
    $watchtext = mb_ereg_replace('{text}', $logtext, $watchtext);
    $watchtext = mb_ereg_replace('{user}', $rLog['username'], $watchtext);
    $watchtext = mb_ereg_replace('{cachename}', $rLog['cachename'], $watchtext);
    $watchtext = mb_ereg_replace('{action}', get_log_action($rLog['type']), $watchtext);
    sql("INSERT IGNORE INTO watches_waiting (`user_id`, `object_id`, `object_type`, `date_created`, `watchtext`, `watchtype`) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'&1', '&2', 1, NOW(), '&3', 2)", $user_id, $log_id, $watchtext);
}