示例#1
0
 protected function column_col3()
 {
     $message = $this->message;
     // Sender becomes Receiver
     $message->receiverUsername = $message->senderUsername;
     $message->senderUsername = $_SESSION['Username'];
     $disabledTinyMce = $this->sender->getPreference("PreferenceDisableTinyMCE", $default = "No") == 'Yes';
     if ($disabledTinyMce) {
         $html2text = new Html2Text\Html2Text($message->Message, false, array('do_links' => 'inline', 'width' => 75));
         $message->Message = $html2text->get_text();
         $message->Message = "\n\n>" . str_replace("\n", "\n>", $message->Message);
     } else {
         $purifier = new MOD_htmlpure();
         $purifier = $purifier->getMessagesHtmlPurifier();
         $message->Message = $purifier->purify($message->Message);
         $message->Message = "<p></p><blockquote>" . $message->Message . "</blockquote><p></p>";
     }
     $contact_username = $message->senderUsername;
     $direction_in = true;
     if ($contact_username == $_SESSION['Username']) {
         $contact_username = $message->receiverUsername;
         $direction_in = false;
     }
     parent::column_col3();
 }
    public function testIgnoreSpans()
    {
        $expected_output = <<<EOT
Outside
EOT;
        $html2text = new \Html2Text\Html2Text($this->input);
        $output = $html2text->get_text();
        $this->assertEquals($expected_output, $output);
    }
    public function testDoLinksNextline()
    {
        $expected_output = <<<EOT
Link text
[http://example.com]
EOT;
        $html2text = new \Html2Text\Html2Text($this->input, false, array('do_links' => 'inline'));
        $output = $html2text->get_text();
        $this->assertEquals($expected_output, $output);
    }
    public function testStrToUpper()
    {
        $expected_output = <<<EOT
WILL BE UTF-8 (ÄÖÜÈÉИЛČΛ) UPPERCASED

Will remain lowercased
EOT;
        $html2text = new \Html2Text\Html2Text($this->input);
        $output = $html2text->get_text();
        $this->assertEquals($expected_output, $output);
    }
    public function testDefinitionList()
    {
        $expected_output = <<<EOT
 \t* Definition Term: Definition Description 


EOT;
        $html2text = new \Html2Text\Html2Text($this->input);
        $output = $html2text->get_text();
        $this->assertEquals($expected_output, $output);
    }
示例#6
0
 protected function column_col3()
 {
     $message = $this->message;
     // Sender becomes Receiver
     $disabledTinyMce = $this->sender->getPreference("PreferenceDisableTinyMCE", $default = "No") == 'Yes';
     if ($disabledTinyMce) {
         $html2text = new Html2Text\Html2Text($message->Message, false, array('dolinks' => 'inline', 'width' => 75));
         $message->Message = $html2text->get_text();
     } else {
         $purifier = new MOD_htmlpure();
         $purifier = $purifier->getMessagesHtmlPurifier();
         $message->Message = $purifier->purify($message->Message);
     }
     parent::column_col3();
 }
 /**
  * @param unknown $text
  * @return Ambigous <string, mixed>
  */
 private function get_text($text)
 {
     // Strip links first
     $text = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $text);
     $html2Text = new \Html2Text\Html2Text($text);
     $text = $html2Text->get_text();
     // Strip multiply spaces and remove line breaks
     $text = preg_replace('/\\s+/m', ' ', $text);
     $text = \Rss\Util\Helpers\Helpers::fix_smartquotes($text);
     return $text;
 }
示例#8
0
 private function _postProcess()
 {
     //Проверяем отправлена ли форма
     if (Tools::isSubmit('submitTutorial')) {
         //Получаем значение поля формы tutorial_url
         $tutorial_url = Tools::getValue('tutorial_url');
         //Проверяем валидность ссылки
         if (Validate::isUrl($tutorial_url)) {
             //Сохраняем настройку
             Configuration::updateValue('TUTORIAL_URL', $tutorial_url);
             //Выводим сообщение об успешном сохранении
             $this->_html .= $this->displayConfirmation($this->l('Настройки обновлены.'));
         } else {
             //Выводим сообщение об ошибке
             $this->_html .= $this->displayError($this->l('Неверная ссылка.'));
         }
     }
     //Проверяем отправлена ли форма с номером каталога
     if (Tools::isSubmit('exportPrintCatalog')) {
         //Получаем значение поля формы num_catalog
         $num_catalog = Tools::getValue('num_catalog');
         //Проверяем валидность номера
         if (Validate::isInt($num_catalog)) {
             //Выполняем запрос
             //SELECT p.id_product, f9.author, pl.name, pl.description, CONCAT_WS(' ',f14.izdat, f10.god, f11.pereplet, f12.stranits, IFNULL(CONCAT('€ ',ROUND(p.price,2)), NULL)) as info, p.reference, /*lcp.id_category, lcp.level_depth,*/ cl.name, /*fp.id_feature, fl.name, fvl.value */
             //SELECT p.id_product, f9.author, pl.name as prod_name, pl.description, CONCAT_WS(' ',f14.izdat, f10.god, f11.pereplet, f12.stranits, IFNULL(CONCAT('€ ',ROUND(p.price,2)), NULL)) as info, p.reference, cl.name as cat_name
             $sql = "\n\t\t\t\t\tSELECT p.id_product, f9.author, pl.name as prod_name, pl.description, f14.izdat, f10.god, f11.pereplet, f12.stranits, p.price, p.reference, cl.name as cat_name\n\t\t\t\t\t\n\t\t\t\t\tFROM " . _DB_PREFIX_ . "product as p\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tON fp.id_product = p.id_product\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_lang AS fl \n\t\t\t\t\tON fl.id_feature = fp.id_feature\n\t\t\t\t\tINNER JOIN \n\t\t\t\t\t" . _DB_PREFIX_ . "feature_value_lang AS fvl \n\t\t\t\t\tON fp.id_feature_value = fvl.id_feature_value\n\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT fp.id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, ','), NULL) as izdat FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 14) as f14\n\t\t\t\t\tON p.id_product = f14.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, '.'), NULL) as god FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 10) as f10\n\t\t\t\t\tON p.id_product = f10.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, '.'), NULL)  as pereplet FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 11) as f11\n\t\t\t\t\tON p.id_product = f11.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, ' с.'), NULL) as stranits FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 12) as f12\n\t\t\t\t\tON p.id_product = f12.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, fvl.value as author FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 9) as f9\n\t\t\t\t\tON p.id_product = f9.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "product_lang as pl\n\t\t\t\t\tON p.id_product = pl.id_product \n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "category_product as cp\n\t\t\t\t\tON p.id_product = cp.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT *\n\t\t\t\t\tFROM (\n\t\t\t\t\tSELECT c.level_depth, c.id_category, cp.id_product\n\t\t\t\t\t    FROM " . _DB_PREFIX_ . "category as c\n\t\t\t\t\t    LEFT JOIN " . _DB_PREFIX_ . "category_product as cp \n\t\t\t\t\t    ON cp.id_category=c.id_category\n\t\t\t\t\tORDER BY level_depth desc\n\t\t\t\t\t) as lcp\n\t\t\t\t\tGROUP BY id_product\n\t\t\t\t\t)as lcp\n\t\t\t\t\tON cp.id_product = lcp.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "category_lang as cl\n\t\t\t\t\tON lcp.id_category = cl.id_category\n\n\t\t\t\t\tWHERE pl.id_lang = 1 AND pl.id_shop = 1 AND fvl.id_lang =1 AND fp.id_feature = 8 AND fvl.value='" . $num_catalog . "'\n\t\t\t\t\tGROUP BY p.id_product\n\t\t\t\t";
             var_dump($sql);
             if ($results = Db::getInstance()->ExecuteS($sql)) {
                 //Формируем CSV файл и выводим в браузер
                 $delimiter = ";";
                 $tmp_file = dirname(__FILE__) . "/Print_catalog_export.csv";
                 $tmp_url = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . "/modules/" . $this->name . "/Print_catalog_export.csv";
                 $f = fopen($tmp_file, 'w');
                 if ($f === false) {
                     $this->_html .= $this->displayError($this->l('Не удалось записать файл.'));
                     break;
                 } else {
                     $this->tmp_url = '<a href="' . $tmp_url . '">Скачать</a>';
                     $num_products = 0;
                     require_once __DIR__ . '/html2text/lib/Html2Text/Html2Text.php';
                     foreach ($results as $line) {
                         //$line['description'] = convert_html_to_text($line['description']);
                         $this->_html .= $line['description'] . "<br/>";
                         $html2text = new \Html2Text\Html2Text($line['description'], false, array('do_links' => 'none', 'width' => 0));
                         $line['description'] = $html2text->get_text();
                         $id_product = $line['id_product'];
                         $price_withtaxes = Product::getPriceStatic($id_product);
                         $line['price'] = "€ " . $price_withtaxes;
                         fputcsv($f, $line, $delimiter);
                         $num_products++;
                     }
                     fclose($f);
                 }
                 //Выводим сообщение об успешном сохранении
                 $this->_html .= $this->displayConfirmation($this->l('Печатный каталог ' . $num_catalog . ' выгружен. ' . $num_products . ' товаров.'));
             } else {
                 //Выводим сообщение об ошибке
                 $this->_html .= $this->displayError($this->l('Не найдены товары для каталога № ' . $num_catalog . '.'));
             }
         } else {
             //Выводим сообщение об ошибке
             $this->_html .= $this->displayError($this->l('Неверный номер каталога.'));
         }
     }
 }
示例#9
0
define('DOMAIN', str_replace('www.', '', $serverName));
// URI-Redirector Prefix (leave empty for direct links)
define('URI_REDIRECT_PREFIX', "http://www.redirect.am/?");
// --- end of CONFIG
// setup slim & twig
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig(), 'templates.path' => 'app/templates', 'slim.url_scheme' => 'https'));
$app->error(function (\Exception $e) use($app) {
    error_log($e->getMessage());
    $app->callErrorHandler($e);
});
$app->view()->parserOptions = array('cache' => __DIR__ . '/cache');
$app->view()->parserExtensions = array(new \Slim\Views\TwigExtension(), new DisposableEmail\AutoLinkTwigExtension());
// add html2Text filter
$app->view()->getInstance()->addFilter(new Twig_SimpleFilter('html2Text', function ($string) {
    $convert = new \Html2Text\Html2Text($string);
    return $convert->get_text();
}));
// redirect to random address
$app->get('/', function () use($app) {
    $wordLength = rand(3, 8);
    $container = new PronounceableWord_DependencyInjectionContainer();
    $generator = $container->getGenerator();
    $word = $generator->generateWordOfGivenLength($wordLength);
    $nr = rand(51, 91);
    $name = $word . $nr;
    $app->redirect($app->urlFor('read', array('name' => $name)));
})->name('home');
// switch to other account using form
$app->post('/switch', function () use($app) {
    $name = cleanName($app->request->params('name'));
    if (strlen($name) == 0) {
示例#10
0
 /**
  * Get the text from an html string
  *
  * @param string $text        	
  * @return string
  *
  */
 private function get_text($text)
 {
     // Strip links first because Html2Text puts them in the output
     $text = preg_replace("/<\\/?a(\\s+.*?>|>)/", "", $text);
     $html2Text = new \Html2Text\Html2Text($text);
     $text = $html2Text->get_text();
     $text = html_entity_decode($text, ENT_QUOTES);
     // Strip multiply spaces and remove line breaks
     $text = preg_replace('/\\s+/m', ' ', $text);
     $text = \Rss\Util\Helpers\Helpers::fix_smartquotes($text);
     $text = trim($text);
     return $text;
 }
示例#11
0
    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\Html2Text($html_version);
            $h2t->set_base_url($CFG->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;
        }
    }