Ejemplo n.º 1
0
function EnviaCorreoAlta($strMail, $originado, $destinatario, $num, $fecha, $departamento, $tipo)
{
    require_once '../general/phpmailer/PHPMailerAutoload.php';
    $to = $strMail;
    $from = '*****@*****.**';
    $mail = new PHPMailer();
    //Correo desde donde se envía (from)
    $mail->setFrom($from, '');
    //Correo de envío (to)
    $mail->addAddress($to, '');
    $mail->CharSet = "UTF-8";
    $mail->Subject = "Sistema de Qualidad";
    $html = '<!DOCTYPE html>
            <html>
                <head>
                    <title>Q-Conta</title>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width">
                </head>
                <body>
                    <div><IMG SRC="https://www.qualidad.es/qualidad/images/logo-' . $_SESSION['base'] . '.JPG" width="140" height="70" BORDER="0"></div>
                    <div><h1><font color="blue">Sistema de Gestión de Calidad</font></h1></div>
                    <hr/>    
                    <div><font color="red">MENSAJE AUTOMÁTICO ENVIADO POR EL SISTEMA</font></div>
                    <div>Originado por: <strong>' . $originado . '</strong></div>
                    <div>Destinatario: <strong>' . $destinatario . '</strong></div>
                    <div>En el Sistema de Gestión de la Calidad de ' . $_SESSION['strSesion'] . ' se han llevado a cabo acciones que requieren su intervención.</div>
                    <div>Si por error las acciones detalladas al pie no le afectasen, deberá reenviar este mensaje a la persona afectada o comunicárselo al Departamento de Calidad.</div><br/>
                    <div><font color="red">DESCRIPCIÓN DE LAS ACCIONES</font></div><br/>
                    <div><strong>No Conformidad</strong> número <font color="blue">' . $num . '</font> con fecha <font color="blue">' . $fecha . '</font> que afecta al Departamento de <font color="blue">' . $departamento . '.</font></div><br/>
                    <hr/>    
                    <div>El Departamento de Calidad agradece su participación en el sistema de gestión y su rápida actuación en las acciones mencionadas, orientadas al cumplimiento de los requisitos de la norma UNE-EN ISO 9001:2008.</div><br/>
                    <div>AVISO: esta dirección de correo está destinada al envío de información y no está habilitada para la recepción de mensajes.</div><br/>
                </body>
            </html>';
    //veo si el correo es HTML o texto plano
    if ($tipo === '1') {
        //HTML
        $mail->msgHTML($html);
    } else {
        //texto plano
        $mail->ContentType = 'text/plain';
        $mail->IsHTML(false);
        $html = convert_html_to_text($html);
        $mail->Body = $html;
    }
    if (!$mail->send()) {
        logger('traza', basename($_SERVER['PHP_SELF']) . '-', "Usuario: " . $_SESSION['strUsuario'] . ', Empresa: ' . $_SESSION['srtBD'] . ', SesionID: ' . session_id() . " Correo NO Enviado.");
        return false;
    } else {
        logger('traza', basename($_SERVER['PHP_SELF']) . '-', "Usuario: " . $_SESSION['strUsuario'] . ', Empresa: ' . $_SESSION['srtBD'] . ', SesionID: ' . session_id() . " Correo Enviado CORRECTAMENTE.");
        return true;
    }
}
Ejemplo n.º 2
0
 /**
  * Encodes the email into MIME format
  *
  * Returns the MIME Multipart string
  * If the mail is plain text without attachment, the plain text is returned without any change
  *
  * @return string
  */
 public function encode()
 {
     if ($this->email->attachments || strpos($this->email->content, '<body')) {
         /** @var $mail Mail_mime */
         $mail = Builder::create(Mail_mime::class);
         $body = $this->parseImages($mail, $this->email->content);
         $error_reporting = error_reporting();
         error_reporting(E_ALL & ~E_WARNING);
         $mail->setTXTBody(convert_html_to_text($this->email->content));
         error_reporting($error_reporting);
         $mail->setHTMLBody($body);
         $this->addAttachments($mail);
         $mime_params = ['text_encoding' => '8bit', 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8', 'head_charset' => 'UTF-8'];
         $body = $mail->get($mime_params);
         $this->email->headers = $mail->headers($this->email->getHeadersAsStrings());
         return $body;
     }
     return $this->email->content;
 }
Ejemplo n.º 3
0
 function escapeText($text)
 {
     $text = convert_html_to_text($text);
     if ($this->getConfig()->get('rocketchat-text-escape') == true) {
         $text = str_replace('<br />', '\\n', $text);
         $text = str_replace('<br/>', '\\n', $text);
         $text = str_replace('&', '&amp;', $text);
         $text = str_replace('<', '&lt;', $text);
         $text = str_replace('>', '&gt;', $text);
     }
     if ($this->getConfig()->get('rocketchat-text-doublenl') == true) {
         $text = preg_replace("/[\r\n]+/", "\n", $text);
         $text = preg_replace("/[\n\n]+/", "\n", $text);
     }
     $text = nl2br($text);
     $text = preg_replace('/[\\n]+/', '', $text);
     if (strlen($text) >= $this->getConfig()->get('rocketchat-text-length')) {
         $text = substr($text, 0, $this->getConfig()->get('rocketchat-text-length')) . '...';
     }
     return $text;
 }
Ejemplo n.º 4
0
function html2text($html)
{
    return convert_html_to_text($html);
}
Ejemplo n.º 5
0
require_once "../wechat/html2text.php";
echo '<h1>获取每日弥撒、日课</h1>';
echo file_get_contents(ROOT_WEB_URL . 'getstuff/checkstuff.php');
$dtstr = gmdate("Y-m-d", time() + 3600 * 8);
$dtnow = intval((time() + 3600 * 8) / (3600 * 24)) * 3600 * 24;
$url = ROOT_WEB_URL . "getstuff/getstuff.php?date=" . $dtstr;
$json = json_decode(file_get_contents($url), true);
if (isset($json['lod'])) {
    //6点发送晨祷信息
    add2weibolist('#晨祷# ' . mb_substr(convert_html_to_text($json['lod']), 0, 40, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_lod.html', $dtnow + 3600 * 6);
}
if (isset($json['mass'])) {
    //7点发送弥撒信息
    add2weibolist('#弥撒# ' . mb_substr(convert_html_to_text($json['mass']), 0, 40, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_mass.html', $dtnow + 3600 * 7);
}
if (isset($json['thought'])) {
    //8点发送反省(读经)信息
    add2weibolist('#读经及反省# ' . mb_substr(convert_html_to_text($json['thought']), 0, 60, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_thought.html', $dtnow + 3600 * 8);
}
if (isset($json['ves'])) {
    //18点发送晚祷信息
    add2weibolist('#晚祷# ' . mb_substr(convert_html_to_text($json['ves']), 0, 40, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_ves.html', $dtnow + 3600 * 18);
}
if (isset($json['comp'])) {
    //18点发送晚祷信息
    add2weibolist('#夜祷# ' . mb_substr(convert_html_to_text($json['comp']), 0, 40, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_comp.html', $dtnow + 3600 * 21);
}
if (isset($json['saint'])) {
    //12点发送圣人传记
    add2weibolist('#圣人传记# ' . mb_substr(convert_html_to_text($json['saint']), 0, 60, "UTF-8") . '…… ' . ROOT_WEB_URL . 'getstuff/stuff/' . $dtstr . '_saint.html', $dtnow + 3600 * 12);
}
Ejemplo n.º 6
0
                $mobi->setContentProvider($mobiContent);
                $filename = $uniqid . "_" . $story["title"] . " - " . $story["author"] . ".mobi";
                $mobi->save("./tmp/" . $filename);
                if (!empty($email)) {
                    mailAttachment($filename, "./tmp/", $email, $uniqid);
                }
            } else {
                if ($format == "txt") {
                    include_once "include/html2text.php";
                    $output = $story["title"] . "\r\n\r\nby " . $story["author"] . "\r\n\r\n\r\n";
                    for ($i = 0; $i < $numChapter; $i++) {
                        $title = isset($story["chapters"]["title"][$i]) ? $story["chapters"]["title"][$i] : "";
                        $content = isset($story["chapters"]["content"][$i]) ? $story["chapters"]["content"][$i] : "";
                        if (!empty($content) && !empty($title)) {
                            $title = formatTitle($title, $i);
                            $content = convert_html_to_text($content);
                            $output .= $title . "\r\n\r\n" . $content . "\r\n\r\n";
                        }
                    }
                    $filename = $uniqid . "_" . $story["title"] . " - " . $story["author"] . ".txt";
                    file_put_contents("./tmp/" . $filename, $output);
                    if (!empty($email)) {
                        mailAttachment($filename, "./tmp/", $email, $uniqid);
                    }
                }
            }
        }
    }
    exit(0);
} else {
    exit(0);
Ejemplo n.º 7
0
 private function getSubArticle($mode, $content, $isLarge, $offset)
 {
     $titlemap = array('mass' => '弥撒及读经', 'med' => '日祷经文', 'lod' => '晨祷经文', 'ves' => '晚祷经文', 'comp' => '夜祷经文', 'let' => '诵读', 'thought' => '反省', 'ordo' => '礼仪', 'saint' => '圣人传记');
     $title = "";
     $url = ROOT_WEB_URL . "getstuff/stuff/" . gmdate("Y-m-d", time() + 3600 * 8 + $offset * 24 * 3600) . "_" . $mode . ".html";
     if ($content == "") {
         $content = convert_html_to_text(file_get_contents($url));
     }
     $picurl = ROOT_WEB_URL . "wechat/pics/" . $mode . "1.jpg";
     if (isset($titlemap[$mode])) {
         $title = $titlemap[$mode];
     }
     $textTpl = '<item><Title><![CDATA[%s]]></Title><Url><![CDATA[%s]]></Url><Description><![CDATA[%s]]></Description><PicUrl><![CDATA[%s]]></PicUrl></item>';
     $resultStr = "";
     if ($isLarge > 0) {
         $picurl = ROOT_WEB_URL . "wechat/pics/" . $mode . "_l1.jpg";
         $index = strpos($content, "\n", 140);
         $desc = "";
         if ($index > 0) {
             $title = $title . "\n" . substr($content, 0, $index);
             $desc = substr($content, 0, $index);
         } else {
             $desc = mb_substr($content, 0, 20, "UTF-8");
         }
         $resultStr = sprintf($textTpl, $title, $url, $desc, $picurl);
     } else {
         $index = strpos($content, "\n", 20);
         if ($index > -1 and $index < 100) {
             $title = $title . "\n" . substr($content, 0, $index);
         } else {
             $title = $title . "\n" . mb_substr($content, 0, 30, "UTF-8");
         }
         $resultStr = sprintf($textTpl, $title, $url, mb_substr($content, 0, 30, "UTF-8"), $picurl);
     }
     return $resultStr;
 }
Ejemplo n.º 8
0
 function html2text($html, $width = 74, $tidy = true)
 {
     # Tidy html: decode, balance, sanitize tags
     if ($tidy) {
         $html = Format::html(Format::htmldecode($html), array('balance' => 1));
     }
     # See if advanced html2text is available (requires xml extension)
     if (function_exists('convert_html_to_text') && extension_loaded('dom')) {
         return convert_html_to_text($html, $width);
     }
     # Try simple html2text  - insert line breaks after new line tags.
     $html = preg_replace(array(':<br ?/?\\>:i', ':(</div>)\\s*:i', ':(</p>)\\s*:i'), array("\n", "\$1\n", "\$1\n\n"), $html);
     # Strip tags, decode html chars and wrap resulting text.
     return Format::wrap(Format::htmldecode(Format::striptags($html, false)), $width);
 }
Ejemplo n.º 9
0
 /** 
  * @deprecated use html2text.php convert_html_to_text function instead
  */
 public function get_text()
 {
     return convert_html_to_text($this->html);
 }
 static function DownConvertHTML($_content)
 {
     @set_error_handler("ignoreError");
     try {
         require_once LIVEZILLA_PATH . "_lib/trdp/html2text.php";
         $_content = convert_html_to_text($_content);
     } catch (Exception $e) {
         $_content = preg_replace("/<style\\b[^>]*>(.*?)<\\/style>/s", "", $_content);
         $_content = trim(html_entity_decode(strip_tags($_content), ENT_COMPAT, "UTF-8"));
         $_content = preg_replace('/[\\s\\s\\s\\s\\s\\s]+/', " ", $_content);
     }
     @set_error_handler("handleError");
     return $_content;
 }
Ejemplo n.º 11
0
 /**
  * Transforms HTML into formatted plain text.
  * 
  * @param string HTML
  * @return string plain text
  */
 static function HtmlToText($html)
 {
     return convert_html_to_text($html);
 }
Ejemplo n.º 12
0
 /**
  * Clean a string embedding html, producing AltText for html mails
  *
  * @return current message in plaintext format
  */
 protected function cleanedHtml()
 {
     $html = $this->message;
     $txt = convert_html_to_text($html);
     return $txt;
 }
Ejemplo n.º 13
0
function gotoend()
{
    global $mode;
    global $isjson;
    global $date;
    global $stuff_mass;
    global $stuff_med;
    global $stuff_comp;
    global $stuff_let;
    global $stuff_lod;
    global $stuff_thought;
    global $stuff_ordo;
    global $stuff_ves;
    global $stuff_saint;
    global $trimedUtf8;
    $ret["mass"] = $stuff_mass;
    $ret["med"] = $stuff_med;
    $ret["comp"] = $stuff_comp;
    $ret["let"] = $stuff_let;
    $ret["lod"] = $stuff_lod;
    $ret["thought"] = '<audio id="audio" src="' . 'http://media.cathassist.org/thought/mp3/' . $date->format('Y-m-d') . '.mp3" controls>反省(' . $date->format('Y-m-d') . ')</audio>' . $stuff_thought;
    $ret["ordo"] = $stuff_ordo;
    $ret["ves"] = $stuff_ves;
    $ret["saint"] = $stuff_saint;
    if ($isjson > 0) {
        $ret = json_encode($ret);
        if ($isjson == 2) {
            echo $_GET['callback'] . '(' . $ret . ')';
            die;
        }
    } else {
        $ret = '<mass>' . htmlspecialchars($stuff_mass, ENT_QUOTES) . '</mass><med>' . htmlspecialchars($stuff_med, ENT_QUOTES) . '</med><comp>' . htmlspecialchars($stuff_comp, ENT_QUOTES) . '</comp><let>' . htmlspecialchars($stuff_let, ENT_QUOTES) . '<let><lod>' . htmlspecialchars($stuff_lod, ENT_QUOTES) . '</lod><thought>' . htmlspecialchars($stuff_thought, ENT_QUOTES) . '</thought><ordo>' . htmlspecialchars($stuff_ordo, ENT_QUOTES) . '</ordo><ves>' . htmlspecialchars($stuff_ves, ENT_QUOTES) . '</ves><saint>' . htmlspecialchars($stuff_saint, ENT_QUOTES) . '</saint>';
    }
    $ret = str_replace($trimedUtf8, "", $ret);
    if ($mode != "") {
        $json = json_decode($ret, true);
        $content = convert_html_to_text($json[$mode]);
        $title = str_replace(PHP_EOL, ' ', mb_substr($content, 0, 20, "UTF-8"));
        echo '<head><meta name="viewport" content="user-scalable=no, width=device-width"/><meta http-equiv=Content-Type content="text/html;charset=utf-8"><title>' . $title . '</title>
		<link href="/css/stuff.css" type="text/css" rel="stylesheet"></head><html><body>';
        if ($mode == "lod") {
            $lod_all = $json[$mode];
            $index_h2 = strpos($lod_all, "</h2>", 0);
            if ($index_h2 > 4 and $index_h2 < 128) {
                $lod_first = "<p><strong>序经</strong><br><strong>领</strong>:上主,求祢开启我的口。<br><strong>答</strong>:我的口要赞美祢。</p><p><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>请大家前来,向上主欢呼,<br>向拯救我们的磐石歌舞。<br>一齐到祂面前感恩赞颂,<br>向祂歌唱圣诗,欢呼吟咏。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>因为上主是崇高的天主,<br>是超越诸神的伟大君王;<br>大地深渊都在祂的手中,<br>高山峻岭都是祂的化工,<br>海洋属于祂,因为是祂所创造,<br>陆地属于祂,因为是祂所形成。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>请大家前来叩首致敬,<br>向造我们的天主跪拜,<br>因为祂是我们的天主,<br>我们是祂牧养的子民,<br>是祂亲手领导的羊羣。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>你们今天要听从祂的声音,<br>不要像在默黎巴那样心硬,<br>不要像在旷野中玛撒那天,<br>你们的祖先看到我的工作,<br>在那里仍然试探我,考验我。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>我四十年之久厌恶那一世代,<br>我曾说:这个民族冥顽不灵,<br>他们不肯承认我的道路;<br>因此,我在盛怒之下起誓说:<br>他们绝不得进入我的安居之所。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p><p>愿光荣归于父、及子、及圣神。<br>起初如何,今日亦然,直到永远。阿们。<br><strong>对经</strong>:基督是牧者们的首领,请大家前来朝拜祂,阿肋路亚。</p>";
                $index_h2 = $index_h2 + 5;
                echo substr($lod_all, 0, $index_h2) . $lod_first . substr($lod_all, $index_h2);
            } else {
                echo $lod_all;
            }
        } else {
            if ($mode == "thought") {
                echo $json[$mode];
            } else {
                echo $json[$mode];
            }
        }
        $imgurl = ROOT_WEB_URL . "wechat/pics/" . $mode . "1.jpg";
        $link = ROOT_WEB_URL . 'getstuff/stuff/' . $_GET["date"] . '_' . $mode . '.html';
        echo '</body><script type="text/javascript" language="javascript" src="/include/googleanalysis.js"></script>' . getWechatShareScript($link, $title, $imgurl) . '</html>';
    } else {
        echo $ret;
    }
    die;
}
Ejemplo n.º 14
0
 function prep_message_body($body)
 {
     if (!$this->html) {
         $body = mb_convert_encoding(trim($body), "HTML-ENTITIES", "UTF-8");
         $body = mb_convert_encoding($body, "UTF-8", "HTML-ENTITIES");
         $body = $this->format_message_text($body);
         $this->headers['Content-Type'] = 'text/plain; charset=UTF-8; format=flowed';
         $this->headers['Content-Transfer-Encoding'] = 'quoted-printable';
     } else {
         $txt = convert_html_to_text($body);
         $this->text_body = sprintf("--%s\r\nContent-Type: text/plain; charset=UTF-8; format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($txt));
         $body = sprintf("--%s\r\nContent-Type: text/html; charset=UTF-8; format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($body));
         $this->headers['Content-Type'] = 'multipart/alternative; boundary=' . $this->boundary;
     }
     return $body;
 }
Ejemplo n.º 15
0
 function setCampaignFiles($content)
 {
     require_once $this->modx->getOption('cmx.core_path', null, $this->modx->getOption('core_path') . 'components/cmx/') . 'library/html2text.php';
     $rand = rand(111111111, 999999999);
     $filename_html = $rand . '.html';
     $filename_txt = $rand . '.txt';
     if (!file_exists($this->assets_cache_path . $filename_html)) {
         if (!$this->setAssetsCached($filename_html, $content)) {
             // problem saving html copy
             return false;
         }
     } else {
         return false;
     }
     if (!file_exists($this->assets_cache_path . $filename_txt)) {
         if (!$this->setAssetsCached($filename_txt, convert_html_to_text($content))) {
             // problem saving txt copy
             return false;
         }
     } else {
         return false;
     }
     return $rand;
 }
Ejemplo n.º 16
0
 function prep_message_body()
 {
     $body = $this->body;
     if (!$this->html) {
         $body = mb_convert_encoding(trim($body), "HTML-ENTITIES", "UTF-8");
         $body = mb_convert_encoding($body, "UTF-8", "HTML-ENTITIES");
         if (!empty($this->attachments)) {
             $this->headers['Content-Type'] = 'multipart/mixed; boundary=' . $this->boundary;
             $body = sprintf("--%s\r\nContent-Type: text/plain; charset=UTF-8; format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($body));
         } else {
             $this->headers['Content-Type'] = 'text/plain; charset=UTF-8; format=flowed';
             $this->headers['Content-Transfer-Encoding'] = 'quoted-printable';
             $body = $this->format_message_text($body);
         }
     } else {
         $txt = convert_html_to_text($body);
         if (!empty($this->attachments)) {
             $alt_boundary = Hm_Crypt::unique_id(32);
             $this->headers['Content-Type'] = 'multipart/mixed; boundary=' . $this->boundary;
             $this->text_body = sprintf("--%s\r\nContent-Type: multipart/alternative; boundary=" . "\"%s\"\r\n\r\n--%s\r\nContent-Type: text/plain; charset=UTF-8; " . "format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $alt_boundary, $alt_boundary, $this->format_message_text($txt));
             $body = sprintf("--%s\r\nContent-Type: text/html; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n\r\n%s\r\n\r\n--%s--", $alt_boundary, $this->format_message_text($body), $alt_boundary);
         } else {
             $this->headers['Content-Type'] = 'multipart/alternative; boundary=' . $this->boundary;
             $this->text_body = sprintf("--%s\r\nContent-Type: text/plain; charset=UTF-8; " . "format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($txt));
             $body = sprintf("--%s\r\nContent-Type: text/html; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($body));
         }
     }
     $this->body = $body;
 }
Ejemplo n.º 17
0
function downloadFromMailbox(&$_reload, $_type, $_server, $_port, $_password, $_account, $_secure, $_delete, $_test = false)
{
    global $CONFIG;
    $starttime = time();
    $executiontime = setTimeLimit(CALLER_TIMEOUT - 10);
    loadLibrary("ZEND", "Zend_Mail");
    $list = array();
    $config = array('host' => $_server, 'auth' => 'login', 'user' => $_account, 'password' => $_password, 'port' => $_port);
    if (!empty($_secure)) {
        $config['ssl'] = $_secure == 1 ? 'SSL' : 'TLS';
    }
    try {
        if ($_type == "IMAP") {
            loadLibrary("ZEND", "Zend_Mail_Storage_Imap");
            $mail = new Zend_Mail_Storage_Imap($config);
        } else {
            loadLibrary("ZEND", "Zend_Mail_Storage_Pop3");
            $mail = new Zend_Mail_Storage_Pop3($config);
        }
    } catch (Exception $e) {
        if ($_test) {
            throw $e;
        } else {
            handleError("111", $_server . " " . $_type . " mailbox connection error: " . $e->getMessage(), "functions.global.inc.php", 0);
        }
        return $list;
    }
    $message = null;
    $delete = array();
    $subject = "";
    try {
        $counter = 0;
        foreach ($mail as $mnum => $message) {
            if ($_test) {
                return count($mail);
            }
            try {
                $temail = new TicketEmail();
                if ($message->headerExists("subject")) {
                    $subject = $temail->Subject = mimeHeaderDecode($message->Subject);
                }
                if ($message->headerExists("message-id")) {
                    $temail->Id = str_replace(array("<", ">"), "", $message->MessageId);
                }
                if (empty($temail->Id)) {
                    $temail->Id = getId(32);
                }
                if ($_delete) {
                    $delete[$mnum] = $temail->Id;
                }
                if (strpos($message->From, "<") !== false) {
                    $fromparts = explode("<", str_replace(">", "", $message->From));
                    if (!empty($fromparts[0])) {
                        $temail->Name = str_replace(array("\""), "", mimeHeaderDecode(trim($fromparts[0])));
                    }
                    $temail->Email = trim($fromparts[1]);
                } else {
                    $temail->Email = trim($message->From);
                }
                if (strpos($message->To, "<") !== false) {
                    $toparts = explode("<", str_replace(">", "", $message->To));
                    $temail->ReceiverEmail = trim($toparts[1]);
                } else {
                    $temail->ReceiverEmail = trim($message->To);
                }
                if ($message->headerExists("reply-to")) {
                    if (strpos($message->ReplyTo, "<") !== false) {
                        $rtoparts = explode("<", str_replace(">", "", $message->ReplyTo));
                        $temail->ReplyTo = trim($rtoparts[1]);
                    } else {
                        $temail->ReplyTo = trim($message->ReplyTo);
                    }
                }
                $parts = array();
                if ($message->isMultipart()) {
                    foreach (new RecursiveIteratorIterator($message) as $part) {
                        $parts[] = $part;
                    }
                } else {
                    $parts[] = $message;
                }
                foreach ($parts as $part) {
                    try {
                        if ($part->headerExists("content-type")) {
                            $ctype = $part->contentType;
                        } else {
                            $ctype = 'text/html';
                        }
                        if ($part->headerExists("content-disposition")) {
                            $ctype .= "; " . $part->contentDisposition;
                        }
                        $charset = "";
                        $hparts = explode(";", str_replace(" ", "", $ctype));
                        foreach ($hparts as $hpart) {
                            if (strpos(strtolower($hpart), "charset=") === 0) {
                                $charset = trim(str_replace(array("charset=", "'", "\""), "", strtolower($hpart)));
                            }
                        }
                        $isatt = strpos(strtolower($ctype), "name=") !== false || strpos(strtolower($ctype), "filename=") !== false;
                        if (DEBUG_MODE) {
                            logit(" PROCESSING EMAIL / charset:" . $ctype . " - " . $charset . " - " . $subject . " - " . $isatt);
                        }
                        if (!$isatt && (($html = strpos(strtolower($ctype), 'text/html') !== false) || strpos(strtolower($ctype), 'text/plain') !== false)) {
                            $content = $part->getContent();
                            foreach ($part->getHeaders() as $name => $value) {
                                if (strpos(strtolower($name), 'content-transfer-encoding') !== false && strpos(strtolower($value), 'quoted-printable') !== false) {
                                    $content = quoted_printable_decode($content);
                                } else {
                                    if (strpos(strtolower($name), 'content-transfer-encoding') !== false && strpos(strtolower($value), 'base64') !== false) {
                                        $content = base64_decode($content);
                                    }
                                }
                            }
                            if ($html) {
                                if (!empty($CONFIG["gl_avhe"])) {
                                    $temail->BodyHTML = max($temail->BodyHTML, $content);
                                }
                                @set_error_handler("ignoreError");
                                try {
                                    require_once LIVEZILLA_PATH . "_lib/trdp/html2text.php";
                                    $content = convert_html_to_text($content);
                                } catch (Exception $e) {
                                    $content = preg_replace("/<style\\b[^>]*>(.*?)<\\/style>/s", "", $content);
                                    $content = trim(html_entity_decode(strip_tags($content), ENT_COMPAT, "UTF-8"));
                                    $content = preg_replace('/[\\s\\s\\s\\s\\s\\s]+/', " ", $content);
                                }
                                @set_error_handler("handleError");
                            }
                            if ((!$html || empty($temail->Body)) && !empty($content)) {
                                if (strpos(strtolower($charset), 'utf-8') === false && !empty($charset)) {
                                    if (DEBUG_MODE) {
                                        logit(" PROCESSING EMAIL / iconv | " . strtoupper($charset) . " | " . 'UTF-8' . " | " . $subject);
                                    }
                                    $temail->Body = @iconv(strtoupper($charset), 'UTF-8', $content);
                                } else {
                                    if ($html && empty($charset)) {
                                        $temail->Body = utf8_encode($content);
                                    } else {
                                        $temail->Body = $content;
                                    }
                                }
                            }
                        } else {
                            $filename = "";
                            $fileid = getId(32);
                            $unknown = getId(32);
                            $filesid = $CONFIG["gl_lzid"] . "_" . $fileid;
                            foreach ($hparts as $hpart) {
                                $hpart = mimeHeaderDecode($hpart);
                                if (strpos(strtolower(trim($hpart)), "name=") === 0 || strpos(strtolower(trim($hpart)), "filename=") === 0) {
                                    $filename = trim(str_replace(array("filename=", "name=", "'", "\""), "", strtolower($hpart)));
                                } else {
                                    if ($part->headerExists("content-id") && empty($filename)) {
                                        $filename = trim(str_replace(array("<", ">", "'", "\""), "", strtolower($part->contentId)));
                                    } else {
                                        if (strpos(strtolower($ctype), 'message/rfc822') !== false && $part->headerExists("subject") && empty($filename)) {
                                            $filename = trim($part->Subject) . ".eml";
                                        } else {
                                            if (strpos(strtolower($ctype), 'message/rfc822') !== false) {
                                                $unknown = "unknown.eml";
                                            }
                                        }
                                    }
                                }
                            }
                            $base64dec = !(strpos(strtolower($ctype), 'message/rfc822') !== false || strpos(strtolower($ctype), 'text/plain') !== false);
                            foreach ($part->getHeaders() as $name => $value) {
                                if (strpos(strtolower($name), 'content-transfer-encoding') !== false && strpos(strtolower($value), 'base64') !== false) {
                                    $base64dec = true;
                                }
                            }
                            $filename = empty($filename) ? $unknown : str_replace(array("\\", ":", "?", "*", "<", ">", "|", "/", "\""), "", $filename);
                            $content = !$base64dec ? $part->getContent() : base64_decode($part->getContent());
                            $temail->Attachments[$fileid] = array($filesid, $filename, $content);
                            if (DEBUG_MODE) {
                                logit("ADD ATT: " . $filesid . " - " . $filename . " - " . $ctype);
                            }
                        }
                    } catch (Exception $e) {
                        handleError("112", $_server . " imap Email Part Error: " . $e->getMessage() . ", email: " . $subject, "functions.global.inc.php", 0);
                    }
                }
                $temail->Created = strtotime($message->Date);
                if ((!is_numeric($temail->Created) || empty($temail->Created)) && $message->headerExists("delivery-date")) {
                    $temail->Created = strtotime($message->DeliveryDate);
                }
                if (!is_numeric($temail->Created) || empty($temail->Created)) {
                    $temail->Created = time();
                }
                $list[] = $temail;
                if (time() - $starttime >= $executiontime / 2 || $counter++ > DATA_ITEM_LOADS) {
                    $_reload = true;
                    break;
                }
            } catch (Exception $e) {
                if ($_test) {
                    throw $e;
                } else {
                    handleError("115", $_type . " Email Error: " . $e->getMessage() . ", email: " . $subject, "functions.global.inc.php", 0);
                }
            }
        }
        try {
            krsort($delete);
            foreach ($delete as $num => $id) {
                $mail->removeMessage($num);
            }
        } catch (Exception $e) {
            if ($_test) {
                throw $e;
            } else {
                handleError("114", $_type . " Email delete error: " . $e->getMessage() . ", email: " . $subject, "functions.global.inc.php", 0);
            }
        }
    } catch (Exception $e) {
        if ($_test) {
            throw $e;
        } else {
            handleError("113", $_type . " Email Error: " . $e->getMessage() . ", email: " . $subject, "functions.global.inc.php", 0);
        }
    }
    return $list;
}
 public function RiskAssessmentAnswers($answers, $questions)
 {
     $this->SectionTitlePage(2, 'Risk Assessment Questions / Answers');
     $this->AddPage();
     $this->SetY(35);
     $this->SetFont('Arial', '', 9);
     $w = array(20, 25, 38, 72, 25);
     $headers = array('Question #', 'Question', 'Description', 'HIPAA Related Info', 'Control Implemented');
     $header_align = array('C', 'C', 'C', 'C', 'C');
     $this->_tableRow(6, $w, $headers, 1, $header_align);
     $this->SetFont('Arial', '', 7);
     $align = array('C', 'L', 'L', 'L', 'C');
     foreach ($questions as $question) {
         $data = array($question['RiskAssessmentQuestions']['category_question_number'], $question['RiskAssessmentQuestions']['question'], convert_html_to_text($question['RiskAssessmentQuestions']['how_to_answer_question']), convert_html_to_text($question['RiskAssessmentQuestions']['additional_information']), $answers['RiskAssessment']['question_' . (string) $question['RiskAssessmentQuestions']['question_number']]);
         $data = array_map(function ($val) {
             return $this->_decode($val);
         }, $data);
         $this->_tableRow(4, $w, $data, 1, $align);
     }
 }
Ejemplo n.º 19
0
function hesk_show_kb_article($artid)
{
    global $hesk_settings, $hesklang, $article;
    // Print header
    $hesk_settings['tmp_title'] = $article['subject'];
    hesk_kb_header($hesk_settings['kb_link'], $article['catid']);
    // Update views by 1
    hesk_dbQuery('UPDATE `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1");
    echo '<h3>' . $article['subject'] . '</h3>
        <div class="footerWithBorder blankSpace"></div>



	<h4>' . $hesklang['as'] . '</h4>
    ' . $article['content'];
    if (!empty($article['attachments'])) {
        echo '<p><b>' . $hesklang['attachments'] . ':</b><br />';
        $att = explode(',', substr($article['attachments'], 0, -1));
        foreach ($att as $myatt) {
            list($att_id, $att_name) = explode('#', $myatt);
            echo '<i class="fa fa-papercip"></i> <a href="../download_attachment.php?kb_att=' . $att_id . '" rel="nofollow">' . $att_name . '</a><br />';
        }
        echo '</p>';
    }
    if ($article['catid'] == 1) {
        $link = 'knowledgebase_private.php';
    } else {
        $link = 'knowledgebase_private.php?category=' . $article['catid'];
    }
    ?>
    <br><br>
    <div class="row">
        <?php 
    $showRelated = false;
    $column = 'col-md-12';
    require HESK_PATH . 'inc/mail/email_parser.php';
    $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content']));
    // Get relevant articles from the database
    $res = hesk_dbQuery("SELECT `id`, `subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `type` IN ('0','1') AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT " . intval($hesk_settings['kb_related'] + 1));
    // Array with related articles
    $related_articles = array();
    while ($related = hesk_dbFetchAssoc($res)) {
        // Get base match score from the first (this) article
        if (!isset($base_score)) {
            $base_score = $related['score'];
        }
        // Ignore this article
        if ($related['id'] == $artid) {
            continue;
        }
        // Stop when articles reach less than 10% of base score
        if ($related['score'] / $base_score < 0.1) {
            break;
        }
        // This is a valid related article
        $related_articles[$related['id']] = $related['subject'];
    }
    // Print related articles if we have any valid matches
    if (count($related_articles)) {
        $column = 'col-md-6';
        $showRelated = true;
    }
    ?>
        <div class="<?php 
    echo $column;
    ?>
 col-sm-12">
            <h4><?php 
    echo $hesklang['ad'];
    ?>
</h4>
            <div class="footerWithBorder blankSpace"></div>
            <table border="0">
                <tr>
                    <td><?php 
    echo $hesklang['aid'];
    ?>
: </td>
                    <td><?php 
    echo $article['id'];
    ?>
</td>
                </tr>
                <tr>
                    <td><?php 
    echo $hesklang['category'];
    ?>
: </td>
                    <td><a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $article['cat_name'];
    ?>
</a></td>
                </tr>
                <tr>
                    <td><?php 
    echo $hesklang['dta'];
    ?>
: </td>
                    <td><?php 
    echo hesk_date($article['dt'], true);
    ?>
</td>
                </tr>
                <tr>
                    <td><?php 
    echo $hesklang['views'];
    ?>
: </td>
                    <td><?php 
    echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1;
    ?>
</td>
                </tr>
            </table>
        </div>
        <?php 
    if ($showRelated) {
        ?>
        <div class="col-md-6 col-sm-12">
            <h4><?php 
        echo $hesklang['relart'];
        ?>
</h4>
            <div class="footerWithBorder blankSpace"></div>
            <?php 
        // Related articles
        foreach ($related_articles as $id => $subject) {
            echo '<span class="glyphicon glyphicon-file" style="font-size: 16px;"></span> <a href="knowledgebase_private.php?article=' . $id . '">' . $subject . '</a><br />';
        }
        ?>
        </div>
        <?php 
    }
    ?>
    </div>

    <?php 
    if (!isset($_GET['back'])) {
        ?>
		<p><br /><a href="javascript:history.go(-1)"><span class="glyphicon glyphicon-circle-arrow-left"></span>&nbsp;<?php 
        echo $hesklang['back'];
        ?>
</a></p>
        <?php 
    } else {
        ?>
        <p>&nbsp;</p>
        <?php 
    }
}
Ejemplo n.º 20
0
    }
    return rtrim(preg_replace($search, $replace, $string), $break);
}
// Thanks http://www.php.net/manual/en/ref.mbstring.php#90611
function mb_str_pad($input, $pad_length, $pad_string = " ", $pad_style = STR_PAD_RIGHT)
{
    return str_pad($input, strlen($input) - mb_strwidth($input) + $pad_length, $pad_string, $pad_style);
}
// Enable use of html2text from command line
// The syntax is the following: php html2text.php file.html
do {
    if (PHP_SAPI != 'cli') {
        break;
    }
    if (empty($_SERVER['argc']) || $_SERVER['argc'] < 2) {
        break;
    }
    if (empty($_SERVER['PHP_SELF']) || FALSE === strpos($_SERVER['PHP_SELF'], 'html2text.php')) {
        break;
    }
    $file = $argv[1];
    $width = 74;
    if (isset($argv[2])) {
        $width = (int) $argv[2];
    } elseif (isset($ENV['COLUMNS'])) {
        $width = $ENV['COLUMNS'];
    }
    require_once dirname(__FILE__) . '/../bootstrap.php';
    Bootstrap::i18n_prep();
    echo convert_html_to_text(file_get_contents($file), $width);
} while (0);
Ejemplo n.º 21
0
/**
 * Converts HTML to plain-text.
 *
 * Uses the html2text() function by Jevon Wright.  Thanks Jevon! :)
 *
 * @uses html2text() by Jevon Wright. Licensed under the EPL v1.0 and LGPL v3.0.
 *       We use a fork of 0.1.1 to maintain PHP 5.2 compatibility.
 * @link https://github.com/r-a-y/html2text/tree/0.1.x
 * @link https://github.com/soundasleep/html2text/
 *
 * @param string $content The HTML content we want to convert to plain-text.
 * @return string Converted plain-text.
 */
function bp_rbe_html_to_plaintext($content)
{
    if (empty($content)) {
        return $content;
    }
    if (false === function_exists('convert_html_to_text')) {
        require BP_RBE_DIR . '/includes/functions.html2text.php';
    }
    // Suppress warnings when using DOMDocument.
    // This addresses issues when failing to parse certain HTML.
    if (function_exists('libxml_use_internal_errors')) {
        libxml_use_internal_errors(true);
    }
    return convert_html_to_text($content);
}
Ejemplo n.º 22
0
/**
 * Format reply text as text
 * @subpackage core/functions
 * @param string $body message body
 * @param string $type MIME type
 * @param string $reply_type type (forward, reply, reply_all)
 * @param string $lead_in body lead in text
 * @return string
 */
function format_reply_as_text($body, $type, $reply_type, $lead_in)
{
    if ($type == 'texthtml') {
        if ($reply_type == 'reply') {
            $msg = $lead_in . format_reply_text(convert_html_to_text($body));
        } elseif ($reply_type == 'forward') {
            $msg = $lead_in . convert_html_to_text($body);
        }
    } elseif ($type == 'textplain') {
        if ($reply_type == 'reply') {
            $msg = $lead_in . format_reply_text($body);
        } else {
            $msg = $lead_in . $body;
        }
    }
    return $msg;
}
             $rep = array('{TICKET_REFERENCE_ID}' => $refid, '{TICKET_OPERATOR_NAME}' => $opname, '{TICKET_CREATOR_NAME}' => $gmane, '{TICKET_PRIORITY}' => $priority, '{TICKET_STATUS}' => $stat, '{TICKET_DEPARTMENT}' => $dpname, '{TICKET_URL}' => dirname(dirname(curPageURL())) . '/user/view.php?id=' . $argv[2], '{TICKET_TITLE}' => $tit);
         }
         break;
 }
 if (isset($allow) && $allow == 'no') {
     exit;
 } else {
     if (isset($setting[0])) {
         $rep['{SITE_NAME}'] = $setting[0];
     }
     $rep['{SITE_ADDRESS}'] = domain_name();
     $file[1] = html_entity_decode($file[1]);
     foreach ($rep as $find => $sost) {
         $file[1] = str_replace($find, $sost, $file[1]);
     }
     $plain = convert_html_to_text(str_replace('&', '&amp;', str_replace('&nbsp;', ' ', $file[1])));
     //Send Mail
     $message = Swift_Message::newInstance();
     $message->setFrom($settingmail);
     $message->setReplyTo($settingmail);
     $message->setSubject($file[0]);
     $message->setContentType("text/plain; charset=UTF-8");
     $message->setBody($plain, 'text/plain');
     $message->addPart($file[1], 'text/html');
     $message->setTo($tomail);
     if ($smailservice == 0) {
         $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -t');
     } else {
         if ($smailservice == 1) {
             if ($smailssl == 0) {
                 $transport = Swift_SmtpTransport::newInstance($settingmail, $smailport);
Ejemplo n.º 24
0
$failed = 0;
foreach ($tests as $test) {
    echo "[test {$test}]\n";
    if (!file_exists(__DIR__ . "/{$test}.html")) {
        echo "FAILED: File '{$test}.html' did not exist\n\n";
        $failed++;
        continue;
    }
    if (!file_exists(__DIR__ . "/{$test}.txt")) {
        echo "FAILED: File '{$test}.txt' did not exist\n\n";
        $failed++;
        continue;
    }
    $input = file_get_contents(__DIR__ . "/{$test}.html");
    $expected = fix_newlines(file_get_contents(__DIR__ . "/{$test}.txt"));
    $output = convert_html_to_text($input);
    if ($output != $expected) {
        file_put_contents(__DIR__ . "/{$test}.output", $output);
        // mark whitespace
        /*
        $output = str_replace(" ", ".", $output);
        $expected = str_replace(" ", ".", $expected);
        $output = str_replace("\t", " -> ", $output);
        $expected = str_replace("\t", " -> ", $expected);
        $output = str_replace("\r", "\\r\r", $output);
        $expected = str_replace("\r", "\\r\r", $expected);
        $output = str_replace("\n", "\\n\n", $output);
        $expected = str_replace("\n", "\\n\n", $expected);
        */
        echo "FAILED: Expected:\n[{$expected}]\n\nGot:\n[{$output}]\n\n";
        $failed++;
Ejemplo n.º 25
0
     $buzzwords = array("%name%", "%email%", "%date%", "%courses%", "%license%");
     //, "%nextstep%");
     $replacewords = array("User Name", "*****@*****.**", $readabledate, "Courses", "License Name");
     $newbody = str_replace($buzzwords, $replacewords, $emails->body);
     $headertemplate .= $newbody;
     $headertemplate .= $footertemplate;
     $messageHtml = $headertemplate;
     $subject = $emails->subject;
 }
 echo $messageHtml;
 echo "<p></p>";
 function convert_html_to_text($html)
 {
     return html2text::convert($html);
 }
 $messageText = convert_html_to_text($messageHtml);
 //plain text message, if needed
 if ($testmail) {
     $toUserTest = new stdClass();
     $toUserTest = $USER;
     $toUserTest->maildisplay = true;
     $toUserTest->mailformat = 1;
     email_to_user($toUserTest, $fromUser, $subject, $messageText, $messageHtml, ", ", false);
 }
 $baseurl = "checkemail.php?id=";
 $baseurl .= $id;
 $form_output = html_writer::start_tag('form', array('method' => 'POST', 'action' => $baseurl, 'id' => 'checkemail_form'));
 $form_output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $id));
 $form_output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sender', 'value' => "sender"));
 $form_fields = html_writer::start_tag('fieldset');
 $form_fields .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'submit', 'id' => 'submit', 'class' => 'submit', 'value' => 'Receive Test E-Mail'));
Ejemplo n.º 26
0
function process_results($result, $tempdir)
{
    global $hesk_settings;
    $r = array();
    // from address and name
    $r["from"] = process_addrname_pairs($result["From"]);
    // to  address and name
    $r["to"] = process_addrname_pairs($result["To"]);
    // cc address and name
    if (array_key_exists("Cc", $result)) {
        $r["cc"] = process_addrname_pairs($result["Cc"]);
    } else {
        $r["cc"] = array();
    }
    // bcc address and name
    if (array_key_exists("Bcc", $result)) {
        $r["bcc"] = process_addrname_pairs($result["Bcc"]);
    } else {
        $r["bcc"] = array();
    }
    // reply-to address and name
    if (array_key_exists("Reply-to", $result)) {
        $r["reply-to"] = process_addrname_pairs($result["Reply-to"]);
    } else {
        $r["reply-to"] = array();
    }
    // subject and subject encoding
    $r["subject"] = $result["Subject"];
    $r["subject_encoding"] = isset($result["SubjectEncoding"]) ? strtoupper($result["SubjectEncoding"]) : "";
    // Message encoding
    $r["encoding"] = isset($result["Encoding"]) ? strtoupper($result["Encoding"]) : "";
    // If message is saved in a file get it from the file
    if (!isset($result["Data"]) && isset($result["DataFile"])) {
        $result["Data"] = file_get_contents($result["DataFile"]);
    }
    // Convert to UTF-8 before processing further
    if ($r["encoding"] != 'UTF-8') {
        $result["Data"] = iconv($r["encoding"], 'UTF-8', $result["Data"]);
        $r["encoding"] = 'UTF-8';
    }
    // the message shall be converted to text if it is in html
    if ($result["Type"] === "html") {
        $r["message"] = convert_html_to_text($result["Data"]);
    } else {
        $r["message"] = $result["Data"];
    }
    // Message attachments
    $r["attachments"] = array();
    if ($hesk_settings['attachments']) {
        // File attachments
        if (array_key_exists("Attachments", $result)) {
            $r["attachments"] = array_merge($r["attachments"], process_attachments($result["Attachments"]));
        }
        // Save embedded files (for example embedded images)
        if ($hesk_settings['save_embedded'] && array_key_exists("Related", $result)) {
            $r["attachments"] = array_merge($r["attachments"], process_attachments($result["Related"]));
        }
    }
    // Name of the temporary folder
    $r["tempdir"] = $tempdir;
    return $r;
}
Ejemplo n.º 27
0
function hesk_show_kb_article($artid)
{
    global $hesk_settings, $hesklang, $article;
    // Print header
    $hesk_settings['tmp_title'] = $article['subject'];
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link']);
    // Update views by 1 - exclude known bots and reloads because of ratings
    if (!isset($_GET['rated']) && !hesk_detect_bots()) {
        hesk_dbQuery("UPDATE `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1");
    }
    echo '<h1>' . $article['subject'] . '</h1>

    <fieldset>
	<legend>' . $hesklang['as'] . '</legend>
    ' . $article['content'];
    if (!empty($article['attachments'])) {
        echo '<p><b>' . $hesklang['attachments'] . ':</b><br />';
        $att = explode(',', substr($article['attachments'], 0, -1));
        foreach ($att as $myatt) {
            list($att_id, $att_name) = explode('#', $myatt);
            echo '<img src="img/clip.png" width="16" height="16" alt="' . $att_name . '" style="align:text-bottom" /> <a href="download_attachment.php?kb_att=' . $att_id . '" rel="nofollow">' . $att_name . '</a><br />';
        }
        echo '</p>';
    }
    // Article rating
    if ($hesk_settings['kb_rating'] && strpos(hesk_COOKIE('hesk_kb_rate'), 'a' . $artid . '%') === false) {
        echo '
	    <div id="rating" class="rate" align="right">&nbsp;<br />' . $hesklang['rart'] . '
			<a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=5&amp;id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['yes']) . '</a> /
	        <a href="Javascript:void(0)" onclick="Javascript:window.location=\'knowledgebase.php?rating=1&amp;id=' . $article['id'] . '\'" rel="nofollow">' . strtolower($hesklang['no']) . '</a>
	    </div>
        ';
    }
    echo '</fieldset>';
    // Related articles
    if ($hesk_settings['kb_related']) {
        require HESK_PATH . 'inc/mail/email_parser.php';
        $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content']));
        // Get relevant articles from the database
        $res = hesk_dbQuery("SELECT t1.`id`, t1.`subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . 'kb_articles` AS t1 LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_categories` AS t2 ON t1.`catid` = t2.`id` WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT " . intval($hesk_settings['kb_related'] + 1));
        // Array with related articles
        $related_articles = array();
        while ($related = hesk_dbFetchAssoc($res)) {
            // Get base match score from the first article
            if (!isset($base_score)) {
                $base_score = $related['score'];
            }
            // Ignore this article
            if ($related['id'] == $artid) {
                continue;
            }
            // Stop when articles reach less than 10% of base score
            if ($related['score'] / $base_score < 0.1) {
                break;
            }
            // This is a valid related article
            $related_articles[$related['id']] = $related['subject'];
        }
        // Print related articles if we have any valid matches
        if (count($related_articles)) {
            echo '<fieldset><legend>' . $hesklang['relart'] . '</legend>';
            foreach ($related_articles as $id => $subject) {
                echo '<img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle;padding:2px;" /> <a href="knowledgebase.php?article=' . $id . '">' . $subject . '</a><br />';
            }
            echo '</fieldset>';
        }
    }
    if ($article['catid'] == 1) {
        $link = 'knowledgebase.php';
    } else {
        $link = 'knowledgebase.php?category=' . $article['catid'];
    }
    ?>

    <fieldset>
    <legend><?php 
    echo $hesklang['ad'];
    ?>
</legend>
	<table border="0">
    <tr>
    <td><?php 
    echo $hesklang['aid'];
    ?>
: </td>
    <td><?php 
    echo $article['id'];
    ?>
</td>
    </tr>
    <tr>
    <td><?php 
    echo $hesklang['category'];
    ?>
: </td>
    <td><a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $article['cat_name'];
    ?>
</a></td>
    </tr>

    <?php 
    if ($hesk_settings['kb_date']) {
        ?>
    <tr>
    <td><?php 
        echo $hesklang['dta'];
        ?>
: </td>
    <td><?php 
        echo hesk_date($article['dt'], true);
        ?>
</td>
    </tr>
    <?php 
    }
    if ($hesk_settings['kb_views']) {
        ?>
    <tr>
    <td><?php 
        echo $hesklang['views'];
        ?>
: </td>
    <td><?php 
        echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1;
        ?>
</td>
    </tr>
    <?php 
    }
    if ($hesk_settings['kb_rating']) {
        $alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
        echo '
        <tr>
        <td>' . $hesklang['rating'] . ' (' . $hesklang['votes'] . '):</td>
        <td><img src="img/star_' . hesk_round_to_half($article['rating']) * 10 . '.png" width="85" height="16" alt="' . $alt . '" title="' . $alt . '" border="0" style="vertical-align:text-bottom" /> (' . $article['votes'] . ')</td>
        </tr>
        ';
    }
    ?>
    </table>
    </fieldset>

    <?php 
    if (!isset($_GET['suggest'])) {
        ?>
		<p>&nbsp;<br />&laquo; <a href="javascript:history.go(<?php 
        echo isset($_GET['rated']) ? '-2' : '-1';
        ?>
)"><?php 
        echo $hesklang['back'];
        ?>
</a></p>
        <?php 
    } else {
        ?>
        <p>&nbsp;</p>
        <?php 
    }
}
function hesk_show_kb_article($artid)
{
    global $hesk_settings, $hesklang, $article;
    // Print header
    $hesk_settings['tmp_title'] = $article['subject'];
    require_once HESK_PATH . 'inc/header.inc.php';
    hesk_kb_header($hesk_settings['kb_link'], $article['catid']);
    // Update views by 1
    hesk_dbQuery('UPDATE `' . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1");
    echo '<h1>' . $article['subject'] . '</h1>

    <fieldset>
	<legend>' . $hesklang['as'] . '</legend>
    ' . $article['content'];
    if (!empty($article['attachments'])) {
        echo '<p><b>' . $hesklang['attachments'] . ':</b><br />';
        $att = explode(',', substr($article['attachments'], 0, -1));
        foreach ($att as $myatt) {
            list($att_id, $att_name) = explode('#', $myatt);
            echo '<img src="../img/clip.png" width="16" height="16" alt="' . $att_name . '" style="align:text-bottom" /> <a href="../download_attachment.php?kb_att=' . $att_id . '" rel="nofollow">' . $att_name . '</a><br />';
        }
        echo '</p>';
    }
    echo '</fieldset>';
    // Related articles
    if ($hesk_settings['kb_related']) {
        require HESK_PATH . 'inc/mail/email_parser.php';
        $query = hesk_dbEscape($article['subject'] . ' ' . convert_html_to_text($article['content']));
        // Get relevant articles from the database
        $res = hesk_dbQuery("SELECT `id`, `subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "kb_articles` WHERE `type` IN ('0','1') AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT " . intval($hesk_settings['kb_related'] + 1));
        // Array with related articles
        $related_articles = array();
        while ($related = hesk_dbFetchAssoc($res)) {
            // Get base match score from the first article
            if (!isset($base_score)) {
                $base_score = $related['score'];
            }
            // Ignore this article
            if ($related['id'] == $artid) {
                continue;
            }
            // Stop when articles reach less than 10% of base score
            if ($related['score'] / $base_score < 0.1) {
                break;
            }
            // This is a valid related article
            $related_articles[$related['id']] = $related['subject'];
        }
        // Print related articles if we have any valid matches
        if (count($related_articles)) {
            echo '<fieldset><legend>' . $hesklang['relart'] . '</legend>';
            foreach ($related_articles as $id => $subject) {
                echo '<img src="' . HESK_PATH . 'img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle;padding:2px;" /> <a href="knowledgebase_private.php?article=' . $id . '">' . $subject . '</a><br />';
            }
            echo '</fieldset>';
        }
    }
    if ($article['catid'] == 1) {
        $link = 'knowledgebase_private.php';
    } else {
        $link = 'knowledgebase_private.php?category=' . $article['catid'];
    }
    ?>

    <fieldset>
    <legend><?php 
    echo $hesklang['ad'];
    ?>
</legend>
	<table border="0">
    <tr>
    <td><?php 
    echo $hesklang['aid'];
    ?>
: </td>
    <td><?php 
    echo $article['id'];
    ?>
</td>
    </tr>
    <tr>
    <td><?php 
    echo $hesklang['category'];
    ?>
: </td>
    <td><a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $article['cat_name'];
    ?>
</a></td>
    </tr>
    <tr>
    <td><?php 
    echo $hesklang['dta'];
    ?>
: </td>
    <td><?php 
    echo hesk_date($article['dt'], true);
    ?>
</td>
    </tr>
    <tr>
    <td><?php 
    echo $hesklang['views'];
    ?>
: </td>
    <td><?php 
    echo isset($_GET['rated']) ? $article['views'] : $article['views'] + 1;
    ?>
</td>
    </tr>
    </table>
    </fieldset>

    <?php 
    if (!isset($_GET['back'])) {
        ?>
		<p>&nbsp;<br />&laquo; <a href="javascript:history.go(-1)"><?php 
        echo $hesklang['back'];
        ?>
</a></p>
        <?php 
    } else {
        ?>
        <p>&nbsp;</p>
        <?php 
    }
}
Ejemplo n.º 29
0
                    $image = $images->item(1)->getAttribute('src');
                } else {
                    $image = $images->item(0)->getAttribute('src');
                }
            }
        }
        //convert datetime to normal datetime
        $time = new DateTime($pubDate);
        $end_date = $time->format('Y-m-d h:i:s');
        $now = date('Y-m-d H:i:s');
        // $time = strtotime($pubDate);
        // $end_date = datetime('Y-m-d : h:i:s', $time);
        if (!$postModel->postWithLinkExists($link)) {
            //Insert data to DB
            $post['feedsource_id'] = intval($feedSource['id']);
            $post['title'] = $title;
            $post['link'] = $link;
            $post['publishedAt'] = $end_date;
            $post['updated'] = $now;
            $post['image'] = $image;
            $post['totalViews'] = 0;
            $post['favorites'] = 0;
            $post['latitude'] = 0;
            $post['longitude'] = 0;
            $post['summary'] = $description;
            $post['body'] = convert_html_to_text($content);
            $postModel->addPost($post);
        }
    }
    echo "{$e} is done.<br>";
}