public function parse($str) { $newstr = $this->clean($str); $newstr = html_escape($newstr); parent::parse($newstr); $treeRoot =& $this->treeRoot; $i = 0; $chren = $treeRoot->getChildren(); $children =& $chren; foreach ($children as &$child) { if ($child instanceof \JBBCode\ElementNode && $child->getTagName() == 'section1') { $child->setAttribute('tuto-section-' . $i++); } } $code = new JBBCode\codedefinitions\FileCodeDefinition(); $code->setUseOption(true); $this->addCodeDefinition($code); }
<?php require_once "../Parser.php"; require_once "../visitors/SmileyVisitor.php"; error_reporting(E_ALL); $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); if (count($argv) < 2) { die("Usage: " . $argv[0] . " \"bbcode string\"\n"); } $inputText = $argv[1]; $parser->parse($inputText); $smileyVisitor = new \JBBCode\visitors\SmileyVisitor(); $parser->accept($smileyVisitor); echo $parser->getAsHTML() . "\n";
public function testAttributes() { $parser = new JBBCode\Parser(); $builder = new JBBCode\CodeDefinitionBuilder('img', '<img src="{param}" height="{height}" alt="{alt}" />'); $parser->addCodeDefinition($builder->setUseOption(true)->setParseContent(false)->build()); $expected = 'Multiple <img src="http://jbbcode.com/img.png" height="50" alt="alt text" /> options.'; $code = 'Multiple [img height="50" alt="alt text"]http://jbbcode.com/img.png[/img] options.'; $parser->parse($code); $result = $parser->getAsHTML(); $this->assertEquals($expected, $result); $code = 'Multiple [img height=50 alt="alt text"]http://jbbcode.com/img.png[/img] options.'; $parser->parse($code); $result = $parser->getAsHTML(); $this->assertEquals($expected, $result); }
/** * Tests an immediate end after a verbatim. */ public function testVerbatimThenEof() { $parser = new JBBCode\Parser(); $parser->addBBCode('verbatim', '{param}', false, false); $parser->parse('[verbatim]'); $this->assertEquals('', $parser->getAsHtml()); }
/** * Asserts that the given bbcode string produces the given html string * when parsed with the default bbcodes. */ public function assertProduces($bbcode, $html) { $parser = new \JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($bbcode); $this->assertEquals($html, $parser->getAsHtml()); }
/** * A utility method for these tests that will evaluate its arguments as bbcode with * a fresh parser loaded with only the default bbcodes. It returns the * bbcode output, which in most cases should be in the input itself. */ private function defaultBBCodeParse($bbcode) { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($bbcode); return $parser->getAsBBCode(); }
/** * Asserts that the given bbcode string produces the given html string * when parsed with the default bbcodes. */ public function assertProduces($bbcode, $html) { $parser = new \JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($bbcode); $htmlsafer = new JBBCode\visitors\HTMLSafeVisitor(); $parser->accept($htmlsafer); $this->assertEquals($html, $parser->getAsHtml()); }
/** * Test over nesting. */ public function testOverNesting() { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->addBBCode('quote', '<blockquote>{param}</blockquote>', false, true, 2); $bbcode = '[quote][quote][quote]wut[/quote] huh?[/quote] i don\'t know[/quote]'; $parser->parse($bbcode); $expectedBbcode = '[quote][quote] huh?[/quote] i don\'t know[/quote]'; $expectedHtml = '<blockquote><blockquote> huh?</blockquote> i don\'t know</blockquote>'; $this->assertEquals($expectedBbcode, $parser->getAsBBCode()); $this->assertEquals($expectedHtml, $parser->getAsHtml()); }
/** * parseBBcode * @return void */ public function parseBBcode() { $dom = new \DomDocument(); $dom->loadHTML($this->html); $finder = new \DomXPath($dom); $nodes = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' cacheLogText ')]"); $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); foreach ($this->bbcode_colors as $color) { $builder = new JBBCode\CodeDefinitionBuilder($color, '<span style="color: ' . $color . ';">{param}</span>'); $parser->addCodeDefinition($builder->build()); } foreach ($nodes as $node) { $raw_log = $node->ownerDocument->saveHTML($node); $raw_log = trim(str_replace(array('<td class="cacheLogText" colspan="2">', '</td>'), '', $raw_log)); $log = preg_replace('/<br>$/', '', $raw_log); $parser->parse($log); $node->nodeValue = $parser->getAsHtml(); } //$smileyVisitor = new JBBCode\visitors\SmileyVisitor(); //$parser->accept($smileyVisitor); $this->html = htmlspecialchars_decode($dom->saveHtml()); $bbcodes = array_keys($this->bbcode_smileys); $images = array_values($this->bbcode_smileys); foreach ($images as $k => &$image) { $image = '<img src="../images/icons/' . $image . '" alt="' . $bbcodes[$k] . '" />'; } foreach ($bbcodes as &$bbcode) { $bbcode = '[' . $bbcode . ']'; } $this->html = str_replace($bbcodes, $images, $this->html); }
public static function preprocessHtml($content, $plugins = false, $bbcode = false, $autolink = false) { if ($bbcode) { require_once CJLIB_PATH . '/lib/jbbcode/Parser.php'; require_once CJLIB_PATH . '/lib/jbbcode/custom/CjCustomCodeDefinitions.php'; $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->addCodeDefinitionSet(new JBBCode\CjCodeDefinitionSet()); $content = $parser->parse(nl2br(htmlspecialchars($content, ENT_COMPAT, 'UTF-8')))->getAsHtml(); } if ($autolink) { require_once 'lib_autolink.php'; $content = autolink_urls($content, 50, ' rel="nofollow"'); } if ($plugins) { $content = JHTML::_('content.prepare', $content); } return $content; }
/** * Convert BBCode to HTML. * * @param string $bbcode * @return string */ public static function bbcode($bbcode) { $parser = new \JBBCode\Parser(); $parser->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet()); $builder = new \JBBCode\CodeDefinitionBuilder('quote', '<blockquote>{param}</blockquote>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('code', '<pre><code>{param}</code></pre>'); $builder->setParseContent(false); $parser->addCodeDefinition($builder->build()); $parser->parse($bbcode); $html = $parser->getAsHtml(); return Filters\HTMLFilter::clean($html); }
if (!$conn) { die('MariaDB 連線失敗' . mysql_error()); } $author = $_POST['author']; $subject = $_POST['topic']; $content = $_POST['content']; $type = $_POST['type']; //All HTML will be escaped. This is to prevent XSS attack. $author = htmlspecialchars($author, ENT_NOQUOTES); $subject = htmlspecialchars($subject, ENT_NOQUOTES); $content = htmlspecialchars($content, ENT_NOQUOTES); //Prevent SQL Injection, escape characters before running SQL query $author = mysql_real_escape_string($author); $subject = mysql_real_escape_string($subject); $content = mysql_real_escape_string($content); //JBBCode phaser process, the print out is at line 112 require_once "jbbc/Parser.php"; $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse(htmlentities($content)); $content = $parser->getAsHtml(); $content = nl2br($content); $sql = "INSERT INTO topic " . "(author,subject,content,type,datetime) " . "VALUES('{$author}','{$subject}','{$content}','{$type}',NOW())"; mysql_select_db('project'); $retval = mysql_query($sql, $conn); if (!$retval) { die('發貼失敗...Sorry... ' . mysql_error()); } //Echo HTML echo "<html>\n\t\t\t \t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t\t\t\t\t\t<body>\n\t\t\t \t\t\t<table align=\"centre\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"border-collapse:collapse; \" width=\"80%\">\n\t\t\t \t\t\t\t<tbody>\n\t\t\t \t\t\t\t\t<tr bgcolor=\"#275187\">\n\t\t\t \t\t\t\t\t\t<td style=\"text-align: center;\"><span style=\"color:#FFFFFF;\">發貼成功</span></td>\n\t\t\t \t\t\t\t\t</tr>\n\t\t\t \t\t\t\t\t<tr>\n\t\t\t \t\t\t\t\t\t<td>\n\t\t\t \t\t\t\t\t\t\t<form action=\"index.php\">\n\t\t\t \t\t\t\t\t\t\t<p style=\"text-align: center;\"><input name=\"back\" type=\"submit\" value=\"按此返回主頁\" /> </p>\n\t\t\t \t\t\t\t\t\t\t</form>\n\t\t\t \t\t\t\t\t\t\t<p style=\"text-align: center;\"> </p>\n\t\t\t \t\t\t\t\t\t</td>\n\t\t\t \t\t\t\t\t</tr>\n\t\t\t \t\t\t\t</tbody>\n\t\t\t \t\t\t</table>\n\t\t\t \t\t</body></html>"; mysql_close($conn);
public function signer($product_id, $record_info, $settings, $mark_id) { $record_settings = $settings; $pointer_answer = ''; $this->load->model('agoo/signer/signer'); $this->load->model('catalog/fields'); if ($this->config->get('ascp_settings') != '') { $this->data['settings_general'] = $this->config->get('ascp_settings'); } else { $this->data['settings_general'] = array(); } if (!isset($record_info['name'])) { $record_info['name'] = ''; } if (isset($record_info['comment_id'])) { $comment_info = $this->model_agoo_signer_signer->getComment($record_info['comment_id'], $mark_id); } else { $comment_info = array(); } if (isset($this->request->post['notify']) && $this->request->post['notify'] && $this->validateDelete()) { $notify_status = true; } else { $notify_status = false; } $this->data['comment_id'] = $record_info['comment_id']; if ($settings['signer'] || $settings['signer_answer'] || $notify_status || $settings['comments_email'] != '') { $this->data['product_id'] = $product_id; $this->data['record_info'] = $record_info; if ($mark_id == 'product_id') { $route = 'product/product'; if ($settings['signer_answer']) { $pointer_answer = 'review_id'; $pointer_id = $comment_info['parent_id']; } } if ($mark_id == 'record_id') { $route = 'record/record'; if ($settings['signer_answer']) { $pointer_answer = 'comment_id'; $pointer_id = $comment_info['parent_id']; } } if ($this->registry->get('admin_work')) { if ($mark_id == 'record_id') { require_once DIR_CATALOG . 'controller/common/seoblog.php'; $seoUrl = new ControllerCommonSeoBlog($this->registry); } else { $seo_type = $this->config->get('config_seo_url_type'); if (!$seo_type) { $seo_type = 'seo_url'; } require_once DIR_CATALOG . 'controller/common/' . $seo_type . '.php'; $classSeo = 'ControllerCommon' . str_replace('_', '', $seo_type); $seoUrl = new $classSeo($this->registry); } $urlToCatalog = new Url(HTTP_CATALOG, $this->config->get('config_secure') ? HTTPS_CATALOG : HTTP_CATALOG); $urlToCatalog->addRewrite($seoUrl); $correct_URL = $urlToCatalog->link($route, '&' . $mark_id . '=' . $this->data['product_id']); $pos = strpos($correct_URL, 'http'); if ($pos === false) { $correct_URL = ($this->config->get('config_secure') ? HTTPS_CATALOG : HTTP_CATALOG) . $correct_URL; } $this->data['record_info']['link'] = $correct_URL; } else { if (SCP_VERSION > 1) { $this->load->controller('common/seoblog'); } else { $this->getChild('common/seoblog'); } $this->data['record_info']['link'] = $this->url->link($route, '&' . $mark_id . '=' . $this->data['product_id']); } if (!class_exists('Customer')) { require_once DIR_SYSTEM . 'library/customer.php'; } $obj = $this->registry->get('customer'); if (!is_object($obj)) { $this->registry->set('customer', new Customer($this->registry)); } unset($obj); $this->language->load('agoo/signer/signer'); if (isset($settings['langfile']) && $settings['langfile'] != '') { $this->language->load($settings['langfile']); } $this->data['login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName(); $this->data['customer_id'] = $this->customer->getId(); if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) { $this->data['logo'] = $this->getHttpImage() . $this->config->get('config_logo'); } else { $this->data['logo'] = false; } if (isset($this->request->post['text'])) { $this->request->post['text'] = strip_tags($this->request->post['text']); } else { $this->request->post['text'] = ''; } $text = $this->request->post['text']; $text = nl2br(strip_tags($text)); $width = '160px'; require_once DIR_SYSTEM . 'library/bbcode/Parser.php'; $parser = new JBBCode\Parser(); $parser->addBBCode("quote", '<div class="quote">{param}</div>', true, true); $parser->addBBCode("quote", '<div class="quote">{param}</div>', false, false); $parser->addBBCode("size", '<span style="font-size:{option}%;">{param}</span>', true, true); $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1); $parser->addBBCode("video", '<div style="overflow:hidden; "><iframe width="300" height="200" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe></div>', false, false, 1); $parser->addBBCode("img", '<a href="{param}" class="imagebox" rel="imagebox" style="overflow: hidden;"><img class="bbimage" alt="" width="' . $width . '" src="{param}"></a>'); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($text); $text = $parser->getAsHtml(); /* if (rdate($this,$this->language->get('text_date')) == rdate($this,$this->language->get('text_date'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours'))))) { $date_str = $this->language->get('text_today'); } else { $date_str = rdate($this,$this->language->get('text_date'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours')))); } $date_added = $date_str.(rdate($this, $this->language->get('text_hours'), strtotime(date($this->language->get('text_date').$this->language->get('text_hours'))))); */ if (isset($this->data['settings_general']['format_date'])) { } else { $this->data['settings_general']['format_date'] = $this->language->get('text_date'); } if (isset($this->data['settings_general']['format_hours'])) { } else { $this->data['settings_general']['format_hours'] = $this->language->get('text_hours'); } if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time']) { $date_str = $this->language->get('text_today'); } else { $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime(date($this->data['settings_general']['format_date'] . $this->data['settings_general']['format_hours']))); } $date_added = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime(date($this->data['settings_general']['format_date'] . $this->data['settings_general']['format_hours']))); $fields = array(); if (isset($this->request->post['af'])) { /* print_r("<PRE>"); print_r($this->request->post['af']); print_r("</PRE>"); */ $addfields = $this->model_catalog_fields->getFieldsDesc(); $f_name = ''; foreach ($this->request->post['af'] as $num => $value) { if (trim($value) != '') { if (trim($value) != '0') { if (isset($record_settings['addfields'])) { foreach ($addfields as $nm => $vl) { if ($vl['field_name'] == $num) { $f_name = $vl['field_description']; } } } else { $field_info = $this->model_catalog_fields->getFieldByName($num); $f_name = $field_info['field_description']; } $fields[$this->db->escape(strip_tags($num))]['field_name'] = $f_name; $fields[$this->db->escape(strip_tags($num))]['text'] = $this->db->escape(strip_tags($value)); } } } } $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name')); $answer_signers = array(); $record_signers = array(); $admin_signers = array(); if (isset($record_settings['status_now']) && $record_settings['status_now'] || $notify_status) { $record_signers = $this->model_agoo_signer_signer->getStatusId($this->data['product_id'], $mark_id); if ($settings['signer_answer']) { $answer_signers = $this->model_agoo_signer_signer->getStatusId($pointer_id, $pointer_answer); } $record_signers = array_merge($record_signers, $answer_signers); } else { $record_signers = array(); } $this->data['answer_signers'] = $answer_signers; $this->data['record_signers'] = $record_signers; if (isset($settings['comments_email']) && $settings['comments_email'] != '') { $comments_email = explode(";", $settings['comments_email']); foreach ($comments_email as $num => $email) { $email = trim($email); array_push($admin_signers, array('id' => $this->data['product_id'], 'pointer' => $mark_id, 'customer_id' => $email, 'admin' => true)); } } if (!empty($admin_signers)) { foreach ($admin_signers as $par => $singers) { $template = '/template/agootemplates/module/blog_signer_mail.tpl'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $template)) { $this->template = $this->config->get('config_template') . $template; } else { $this->template = 'default' . $template; } $this->data['theme'] = $this->config->get('config_template'); if (isset($singers['admin']) && $singers['admin']) { $customer['email'] = $singers['customer_id']; $customer['firstname'] = 'admin'; $customer['lastname'] = ''; } else { $customer['email'] = ''; $customer['firstname'] = ''; $customer['lastname'] = ''; } $this->data['data'] = array('text' => $text, 'settings' => $record_settings, 'fields' => $fields, 'comment' => $this->request->post, 'comment_db' => $comment_info, 'record' => $this->data['record_info'], 'date' => $date_added, 'shop' => $this->config->get('config_name'), 'signers' => serialize($singers), 'signer_customer' => $customer); $this->data['language'] = $this->language; if (SCP_VERSION < 2) { $html = $this->render(); } else { if (!is_array($this->data)) { $this->data = array(); } $html = $this->load->view($this->template, $this->data); } $message = $html; $data_mail['customer_email'] = $customer['email']; $data_mail['message'] = $message; $data_mail['subject'] = $subject; $this->send_mail($data_mail); unset($data_mail); } } if (!empty($record_signers)) { $customer_email_array = array(); foreach ($record_signers as $par => $singers) { $template = '/template/agootemplates/module/blog_signer_mail.tpl'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $template)) { $this->template = $this->config->get('config_template') . $template; } else { $this->template = 'default' . $template; } $this->data['theme'] = $this->config->get('config_template'); if ($singers['customer_id'] == "0") { $customer['email'] = $singers['email']; $customer['firstname'] = $this->language->get('text_ghost'); $customer['lastname'] = ''; } else { $customer = $this->model_agoo_signer_signer->getCustomer($singers['customer_id']); } $this->data['data'] = array('text' => $text, 'settings' => $record_settings, 'fields' => $fields, 'comment' => $this->request->post, 'comment_db' => $comment_info, 'record' => $this->data['record_info'], 'date' => $date_added, 'shop' => $this->config->get('config_name'), 'signers' => serialize($singers), 'signer_customer' => $customer); $this->data['language'] = $this->language; if (SCP_VERSION < 2) { $html = $this->render(); } else { if (!is_array($this->data)) { $this->data = array(); } $html = $this->load->view($this->template, $this->data); } $message = $html; $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name')); if (isset($comment_info['status']) && $comment_info['status'] && (isset($record_settings['comment_signer']) && $record_settings['comment_signer']) && $singers['customer_id'] != $this->data['customer_id'] && isset($customer['email']) || $notify_status) { if (!isset($customer_email_array[$customer['email']])) { $data_mail['customer_email'] = $customer['email']; $data_mail['message'] = $message; $data_mail['subject'] = $subject; $this->send_mail($data_mail); unset($data_mail); $customer_email_array[$customer['email']] = $customer['email']; } } } } } }
/** * @param string $code * @param string $expected * @dataProvider codeProvider */ public function testParse($code, $expected) { $this->assertEquals($expected, $this->_parser->parse($code)->getAsText()); }
function getPlainFromBB($bb) { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); return $parser->parse($bb)->getAsText(); }
$parser = new JBBCode\Parser(); $builder = new JBBCode\CodeDefinitionBuilder('i', '/{param}/'); $parser->addCodeDefinition($builder->build()); $builder = new JBBCode\CodeDefinitionBuilder('u', '_{param}_'); $parser->addCodeDefinition($builder->build()); $builder = new JBBCode\CodeDefinitionBuilder('b', '*{param}*'); $parser->addCodeDefinition($builder->build()); $parser->addCodeDefinition(new QuoteWithOption()); $parser->addCodeDefinition(new QuoteWithoutOption()); $builder = new JBBCode\CodeDefinitionBuilder('code', '{param}'); $parser->addCodeDefinition($builder->build()); $builder = (new JBBCode\CodeDefinitionBuilder('color', '{param}'))->setUseOption(true); $parser->addCodeDefinition($builder->build()); $builder = (new JBBCode\CodeDefinitionBuilder('size', '{param}'))->setUseOption(true); $parser->addCodeDefinition($builder->build()); $parser->parse($message); $message = $parser->getAsHtml(); // build the informational table $message .= "{$phrase['subject']}: {$post_SUBJECT}\n"; $message .= "{$phrase['thread']}: {$post_TOPICTITLE} {$thread_url}\n"; $message .= "{$phrase['forum']} : {$post_FORUMPARENTS_laquo}{$post_FORUMNAME} {$forum_url}\n"; $message .= "{$phrase['actions']}:\n"; $message .= " Reply address in the AEGEE Forum: " . $reply_url . "\n"; $message .= " Post URL: " . $post_url . "\n"; $message .= " Info URL: " . $info_url . "\n\n"; $message .= "--\nThis message is generated upon adding a new posting in the AEGEE Forum, https://www.aegee.org/forum . You can answer directly to the sender by clicking the reply button, if the sender has activated its @aegee.org address, and does not want to hide his/her identity, otherwise the sending address of this email does not exist. Sending emails from the AEGEE forum is experimental. Direct your feedback at forum@aegee.org ."; if ($post_HOST == $post_IP) { $post_HOST = $phrase[host_na]; } // build the post text table // search for inline attachments to show them in the post text
function markup(&$body, $track_cites = false) { global $board, $config, $markup_urls; $modifiers = extract_modifiers($body); $body = preg_replace('@<tinyboard (?!escape )([\\w\\s]+)>(.+?)</tinyboard>@us', '', $body); $body = preg_replace('@<(tinyboard) escape ([\\w\\s]+)>@i', '<$1 $2>', $body); if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') { return array(); } $body = str_replace("\r", '', $body); $body = utf8tohtml($body); if (mysql_version() < 50503) { $body = mb_encode_numericentity($body, array(0x10000, 0xffffff, 0, 0xffffff), 'UTF-8'); } $parser = new JBBCode\Parser(); foreach ($config['markup'] as $markup) { if (is_string($markup[1])) { $builder = new JBBCode\CodeDefinitionBuilder($markup[0], $markup[1]); if ($markup[2] == "option") { $builder->setUseOption(true); } else { if ($markup[2] == "false") { $builder->setParseContent(false); } } $parser->addCodeDefinition($builder->build()); } } foreach ($config['old_markup'] as $markup) { if (is_string($markup[1])) { $body = preg_replace($markup[0], $markup[1], $body); } elseif (is_callable($markup[1])) { $body = preg_replace_callback($markup[0], $markup[1], $body); } } $parser->addCodeDefinition($builder->build()); $parser->parse($body); $body = $parser->getAsHtml(); if ($config['markup_urls']) { $markup_urls = array(); $body = preg_replace_callback('/((?:https?:\\/\\/|ftp:\\/\\/|irc:\\/\\/)[^\\s<>()"]+?(?:\\([^\\s<>()"]*?\\)[^\\s<>()"]*?)*)((?:\\s|<|>|"|\\.||\\]|!|\\?|,|,|")*(?:[\\s<>()"]|$))/', 'markup_url', $body, -1, $num_links); if ($num_links > $config['max_links']) { error($config['error']['toomanylinks']); } } if ($config['markup_repair_tidy']) { $body = str_replace(' ', ' ', $body); } if ($config['auto_unicode']) { $body = unicodify($body); if ($config['markup_urls']) { foreach ($markup_urls as &$url) { $body = str_replace(unicodify($url), $url, $body); } } } $tracked_cites = array(); // Cites if (isset($board) && preg_match_all('/(^|\\s)?>>(\\d+?)([\\s,.)?]|$)/m', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { if (count($cites[0]) > $config['max_cites']) { error($config['error']['toomanycites']); } $skip_chars = 0; $body_tmp = $body; $search_cites = array(); foreach ($cites as $matches) { $search_cites[] = '`id` = ' . $matches[2][0]; } $search_cites = array_unique($search_cites); $query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' . implode(' OR ', $search_cites), $board['uri'])) or error(db_error()); $cited_posts = array(); while ($cited = $query->fetch(PDO::FETCH_ASSOC)) { $cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false; } foreach ($cites as $matches) { $cite = $matches[2][0]; // preg_match_all is not multibyte-safe foreach ($matches as &$match) { $match[1] = mb_strlen(substr($body_tmp, 0, $match[1])); } if (isset($cited_posts[$cite])) { $replacement = '<a onclick="highlightReply(\'' . $cite . '\');" href="' . $config['root'] . $board['dir'] . $config['dir']['res'] . ($cited_posts[$cite] ? $cited_posts[$cite] : $cite) . '.html#' . $cite . '">' . '>>' . $cite . '</a>'; $body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[3][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0])); $skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[3][0]) - mb_strlen($matches[0][0]); if ($track_cites && $config['track_cites']) { $tracked_cites[] = array($board['uri'], $cite); } } } } // Cross-board linking if (preg_match_all('/(^|\\s)>>>\\/(' . $config['board_regex'] . 'f?)\\/(\\d+)?([\\s,.)?]|$)/um', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { if (count($cites[0]) > $config['max_cites']) { error($config['error']['toomanycross']); } $skip_chars = 0; $body_tmp = $body; if (isset($cited_posts)) { // Carry found posts from local board >>X links foreach ($cited_posts as $cite => $thread) { $cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] . ($thread ? $thread : $cite) . '.html#' . $cite; } $cited_posts = array($board['uri'] => $cited_posts); } else { $cited_posts = array(); } $crossboard_indexes = array(); $search_cites_boards = array(); foreach ($cites as $matches) { $_board = $matches[2][0]; $cite = @$matches[3][0]; if (!isset($search_cites_boards[$_board])) { $search_cites_boards[$_board] = array(); } $search_cites_boards[$_board][] = $cite; } $tmp_board = $board['uri']; foreach ($search_cites_boards as $_board => $search_cites) { $clauses = array(); foreach ($search_cites as $cite) { if (!$cite || isset($cited_posts[$_board][$cite])) { continue; } $clauses[] = '`id` = ' . $cite; } $clauses = array_unique($clauses); if ($board['uri'] != $_board) { if (!openBoard($_board)) { continue; } // Unknown board } if (!empty($clauses)) { $cited_posts[$_board] = array(); $query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' . implode(' OR ', $clauses), $board['uri'])) or error(db_error()); while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { $cited_posts[$_board][$cite['id']] = $config['root'] . $board['dir'] . $config['dir']['res'] . ($cite['thread'] ? $cite['thread'] : $cite['id']) . '.html#' . $cite['id']; } } $crossboard_indexes[$_board] = $config['root'] . $board['dir'] . $config['file_index']; } // Restore old board if ($board['uri'] != $tmp_board) { openBoard($tmp_board); } foreach ($cites as $matches) { $_board = $matches[2][0]; $cite = @$matches[3][0]; // preg_match_all is not multibyte-safe foreach ($matches as &$match) { $match[1] = mb_strlen(substr($body_tmp, 0, $match[1])); } if ($cite) { if (isset($cited_posts[$_board][$cite])) { $link = $cited_posts[$_board][$cite]; $replacement = '<a ' . ($_board == $board['uri'] ? 'onclick="highlightReply(\'' . $cite . '\');" ' : '') . 'href="' . $link . '">' . '>>>/' . $_board . '/' . $cite . '</a>'; $body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0])); $skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]); if ($track_cites && $config['track_cites']) { $tracked_cites[] = array($_board, $cite); } } } elseif (isset($crossboard_indexes[$_board])) { $replacement = '<a href="' . $crossboard_indexes[$_board] . '">' . '>>>/' . $_board . '/' . '</a>'; $body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0])); $skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]); } } } $tracked_cites = array_unique($tracked_cites, SORT_REGULAR); $body = preg_replace("/^\\s*>.*\$/m", '<span class="quote">$0</span>', $body); if ($config['strip_superfluous_returns']) { $body = preg_replace('/\\s+$/', '', $body); } $body = preg_replace("/\n/", '<br/>', $body); if ($config['markup_repair_tidy']) { $tidy = new tidy(); $body = str_replace("\t", '	', $body); $body = $tidy->repairString($body, array('doctype' => 'omit', 'bare' => true, 'literal-attributes' => true, 'indent' => false, 'show-body-only' => true, 'wrap' => 0, 'output-bom' => false, 'output-html' => true, 'newline' => 'LF', 'quiet' => true), 'utf8'); $body = str_replace("\n", '', $body); } // replace tabs with 8 spaces $body = str_replace("\t", ' ', $body); return $tracked_cites; }
/** * Gets html from bbcode. * * @param string $bbcode * @return string */ public function getHtmlFromBBCode($bbcode) { require_once APPLICATION_PATH . '/libraries/jbbcode/Parser.php'; $parser = new \JBBCode\Parser(); $parser->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet()); $builder = new \JBBCode\CodeDefinitionBuilder('quote', '<div class="quote">{param}</div>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('list', '<ul>{param}</ul>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('*', '<li>{param}</li>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('email', '<a href="mailto:{param}">{param}</a>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('img', '<img src="{param}" alt="Image">'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('i', '<em>{param}</em>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('u', '<u>{param}</u>'); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('url', '<a href="{option}">{param}</a>'); $builder->setUseOption(true)->setOptionValidator(new \JBBCode\validators\UrlValidator()); $parser->addCodeDefinition($builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('code', '<pre class="code">{param}</pre>'); $builder->setParseContent(false); $parser->addCodeDefinition($builder->build()); $parser->parse($bbcode); return $parser->getAsHTML(); }
<?php require_once "/path/to/jbbcode/Parser.php"; $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $text = "The bbcode in here [b]is never closed!"; $parser->parse($text); print $parser->getAsBBCode();
function assemblePost($header, $post_content) { include_once "JBBCode/Parser.php"; $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $content = nl2br($post_content); $parser->parse($content); echo "<table class='pure-table pure-table-bordered' width=80%>"; echo "<thead>"; echo "<tr>"; echo $header; echo "</tr>"; echo "</thead>"; echo "<tbody>"; echo "<tr>"; echo "<td>" . $parser->getAsHtml() . "</td>"; echo "</tr>"; echo "</tbody>"; echo "</table>"; }
public function comment() { $ver = VERSION; if (!defined('SCP_VERSION')) { define('SCP_VERSION', $ver[0]); } $this->config->set("blog_work", true); if (SCP_VERSION > 1) { $this->load->controller('common/seoblog'); } else { $this->getChild('common/seoblog'); } if (isset($this->request->get['prefix'])) { $this->data['prefix'] = $this->request->get['prefix']; } else { if ($this->registry->get("prefix") != '') { $this->data['prefix'] = $this->registry->get("prefix"); } else { $this->data['prefix'] = ''; } } $this->load->model('setting/setting'); if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) { $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_https_admin_path'); } else { $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_http_admin_path'); } foreach ($settings_admin as $key => $value) { $this->data['admin_path'] = $value; } /* ?????????????????????????????????????? $this->load->model('setting/setting'); if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) { $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_https_admin_path'); } else { $settings_admin = $this->model_setting_setting->getSetting('ascp_admin', 'ascp_admin_http_admin_path'); } foreach ($settings_admin as $key => $value) { $this->data['admin_path'] = $value; } */ /* if (!class_exists('User')) { require_once(DIR_SYSTEM . 'library/user.php'); $this->registry->set('user', new User($this->registry)); } */ $this->load->library('user'); $this->user = new User($this->registry); if ($this->user->isLogged()) { $this->data['userLogged'] = true; } else { $this->data['userLogged'] = false; } if (isset($this->request->get['ascp_widgets_position'])) { $this->data['cmswidget'] = $this->request->get['cmswidget'] = (int) $this->request->get['ascp_widgets_position']; } if (isset($this->request->post['thislist']) || isset($this->request->get['thislist'])) { if (isset($this->request->get['thislist'])) { $str = base64_decode($this->request->get['thislist']); } else { $str = base64_decode($this->request->post['thislist']); } //$this->data['cmswidget'] = unserialize($str); } else { $numargs = func_num_args(); if ($numargs >= 1) { $this->data['cmswidget'] = func_get_arg(0); } else { $this->data['cmswidget'] = false; } } $this->data['http_image'] = getHttpImage($this); $this->data['config_language_id'] = $this->config->get('config_language_id'); $this->data['ascp_widgets'] = $this->config->get('ascp_widgets'); $this->data['thislist'] = $this->data['ascp_widgets'][$this->data['cmswidget']]; $this->language->load('product/product'); $this->language->load('record/blog'); $this->language->load('record/record'); if (isset($this->data['thislist']['langfile']) && $this->data['thislist']['langfile'] != '') { $this->language->load($this->data['thislist']['langfile']); } if (isset($this->request->get['product_id']) || isset($this->request->get['record_id']) || isset($this->data['thislist']['recordid'])) { $comments_settings = array(); $record_info = array(); $record_info['comment'] = array(); $this->data['mark'] = false; if (isset($this->request->get['product_id'])) { $this->data['mark'] = 'product_id'; $this->data['product_id'] = $this->request->get['product_id']; $mark_route = 'product/product'; } if (isset($this->request->get['record_id'])) { $this->data['mark'] = 'record_id'; $this->data['product_id'] = $this->request->get['record_id']; $mark_route = 'record/record'; } if (isset($this->data['thislist']['recordid']) && $this->data['thislist']['recordid'] != '') { $this->data['mark'] = 'record_id'; $this->data['product_id'] = $this->data['thislist']['recordid']; $mark_route = 'record/record'; $this->load->model('catalog/record'); $this->data['record'] = $this->data['mark_info'] = $this->model_catalog_record->getRecord($this->data['product_id']); } else { $this->data['record'] = ''; } $this->data['url'] = $this->url->link($mark_route, $this->data['mark'] . '=' . $this->data['product_id']); $this->data['mark_id'] = $this->data['product_id']; $this->data['entry_sorting'] = $this->language->get('entry_sorting'); $this->data['text_sorting_desc'] = $this->language->get('text_sorting_desc'); $this->data['text_sorting_asc'] = $this->language->get('text_sorting_asc'); $this->data['text_rollup'] = $this->language->get('text_rollup'); $this->data['text_rollup_down'] = $this->language->get('text_rollup_down'); $this->data['text_no_comments'] = $this->language->get('text_no_comments'); $this->data['text_reply_button'] = $this->language->get('text_reply_button'); $this->data['text_signer_answer'] = $this->language->get('text_signer_answer'); $this->data['text_signer_answer_email'] = $this->language->get('text_signer_answer_email'); /* todo $this->data['text_edit_button'] = $this->language->get('text_edit_button'); $this->data['text_delete_button'] = $this->language->get('text_delete_button'); */ if ($this->customer->isLogged()) { $this->data['text_login'] = $this->customer->getFirstName() . " " . $this->customer->getLastName(); $this->data['captcha_status'] = false; $this->data['customer_id'] = $this->customer->getId(); } else { $this->data['text_login'] = $this->language->get('text_anonymus'); $this->data['captcha_status'] = true; $this->data['customer_id'] = false; } $this->load->model('catalog/treecomments'); $this->load->model('catalog/product'); $this->load->model('catalog/record'); $this->load->model('catalog/blog'); if ($this->data['mark'] == 'product_id') { $mark_path = $this->model_catalog_treecomments->getPathByProduct($this->data['mark_id']); $mark_info = $this->model_catalog_product->getProduct($this->data['mark_id']); } if ($this->data['mark'] == 'record_id') { $mark_path = $this->model_catalog_blog->getPathByRecord($this->data['mark_id']); $record_info = $mark_info = $this->model_catalog_record->getRecord($this->data['mark_id']); } $category_path = $mark_path['path']; if (isset($category_path)) { $array_path = explode('_', $category_path); $category_id = end($array_path); } if (!isset($category_id)) { $category_id = 0; } $category_info = $this->model_catalog_treecomments->getCategory($category_id, $this->data['mark']); if ($this->config->get('ascp_settings') != '') { $this->data['settings_general'] = $this->config->get('ascp_settings'); } else { $this->data['settings_general'] = array(); } if (isset($category_info['design']) && $category_info['design'] != '') { $this->data['category_design'] = unserialize($category_info['design']); } else { $this->data['category_design'] = array(); } if (!isset($this->data['settings_general']['colorbox_theme'])) { $this->data['settings_general']['colorbox_theme'] = 0; } $get = $this->request->get; if (isset($this->data['settings_general']['get_pagination'])) { $get_pagination = $this->data['settings_general']['get_pagination']; } else { $get_pagination = 'tracking'; } if (isset($get['ascp_widgets_position'])) { $this->data['ascp_widgets_position'] = $get['ascp_widgets_position']; } else { $this->data['ascp_widgets_position'] = $this->registry->get('ascp_widgets_position'); } $cmswidget = $this->data['ascp_widgets_position']; $cmswidget_flag = false; if (isset($get[$get_pagination])) { $tracking = $get[$get_pagination]; } else { $tracking = ''; } if ($tracking != '') { $parts = explode('_', trim(utf8_strtolower($tracking))); foreach ($parts as $num => $val) { $aval = explode("-", $val); if (isset($aval[0]) && $aval[0] == 'cmswidget') { if (isset($aval[1]) && $aval[1] == $cmswidget) { $cmswidget_flag = true; } } } if ($cmswidget_flag) { foreach ($parts as $num => $val) { $aval = explode("-", $val); if (isset($aval[0])) { $getquery = $aval[0]; if (isset($aval[1])) { $getpar = $aval[1]; $get[$getquery] = $getpar; } } } } } if (isset($get['wpage']) && isset($get['cmswidget']) && $get['cmswidget'] == $cmswidget) { $page = $get['wpage']; } else { $page = 1; } if (isset($get['ajax']) && $get['ajax'] == '1' && isset($get['page'])) { $page = $get['wpage'] = $get['page']; } $this->data['wpage'] = $this->data['page'] = $page; if (isset($record_info['comment']) && !empty($record_info['comment'])) { $comments_settings_record = unserialize($record_info['comment']); } else { $comments_settings_record = array(); } $comments_settings = $comments_settings_record + $this->data['thislist']; $this->data['sorting'] = 'desc'; $comments_order = 'comment_id'; if (isset($comments_settings['order_ad']) && $comments_settings['order_ad'] != '') { $this->data['sorting'] = strtolower($comments_settings['order_ad']); } if (isset($comments_settings['order']) && $comments_settings['order'] != '') { $this->data['order'] = strtolower($comments_settings['order']); } if (isset($this->data['order']) && $this->data['order'] == 'sort') { $comments_order = 'comment_id'; } if (isset($this->data['order']) && $this->data['order'] == 'date') { $comments_order = 'date_available'; } if (isset($this->data['order']) && $this->data['order'] == 'rating') { $comments_order = 'rating'; } if (isset($this->data['order']) && $this->data['order'] == 'rate') { $comments_order = 'delta'; } if (isset($get['sorting'])) { if ($get['sorting'] == 'none') { $this->data['sorting'] = $this->data['sorting']; } else { $this->data['sorting'] = $get['sorting']; } } if (isset($this->data['thislist']['view_captcha']) && $this->data['thislist']['view_captcha'] == 0) { $this->data['captcha_status'] = false; } if (isset($this->data['thislist']['visual_editor']) && isset($this->data['thislist']['comment_must']) && $this->data['thislist']['comment_must'] && $this->data['thislist']['visual_editor'] || !isset($this->data['thislist']['visual_editor'])) { $this->data['visual_editor'] = true; $this->document->addScript('catalog/view/javascript/wysibb/jquery.wysibb.min.js'); $this->document->addStyle('catalog/view/javascript/wysibb/theme/default/wbbtheme.css'); $this->document->addScript('catalog/view/javascript/blog/blog.bbimage.js'); $this->document->addScript('catalog/view/javascript/blog/rating/jquery.rating.js'); $this->document->addStyle('catalog/view/javascript/blog/rating/jquery.rating.css'); } else { $this->data['visual_editor'] = false; } $thislist = $this->data['thislist']; $this->data['record_comment'] = $thislist; if (isset($thislist['order_ad']) && $thislist['order_ad'] != '') { $this->data['sorting'] = strtolower($thislist['order_ad']); } if (isset($get['sorting'])) { if ($get['sorting'] == 'none') { $this->data['sorting'] = $this->data['sorting']; } else { $this->data['sorting'] = $get['sorting']; } } $this->data['comments'] = array(); if (isset($thislist['status_language'])) { if ($thislist['status_language']) { $this->registry->set("status_language", true); } else { $this->registry->set("status_language", false); } } else { $this->registry->set("status_language", true); } $this->data['comment_total'] = $comment_total = $this->model_catalog_treecomments->getTotalCommentsByMarkId($this->data['mark_id'], $this->data['mark'], $this->data['thislist']); if (isset($thislist['number_comments'])) { $this->data['number_comments'] = $thislist['number_comments']; } else { $this->data['number_comments'] = ''; } if ($this->data['number_comments'] == '') { $this->data['number_comments'] = 10; } if (isset($_COOKIE["karma_" . $this->data['mark']])) { $karma_cookie = unserialize(base64_decode($_COOKIE["karma_" . $this->data['mark']])); } else { $karma_cookie = array(); } $mark = $this->data['mark']; if (!isset($this->data['settings_general']['complete_status'])) { $this->data['settings_general']['complete_status'] = false; } $data = array('status' => $this->data['settings_general']['complete_status'], $mark => $this->data['mark_id'], 'start' => ($page - 1) * $this->data['number_comments'], 'limit' => $this->data['number_comments']); /***********************************************************************************************************/ $results = $this->model_catalog_treecomments->getCommentsByMarkId($data, $mark, $this->data['thislist']); if (isset($this->data['thislist']['admin_name']) && $this->data['thislist']['admin_name'] != '') { $this->data['admin_name'] = array_flip(explode(";", trim($this->data['thislist']['admin_name']))); } else { $this->data['admin_name'] = array(); } if ($this->customer->isLogged()) { $customer_id = $this->customer->getId(); } else { $customer_id = false; } $this->data[$this->data['mark']] = $this->data['mark_id']; $results_rates = $this->model_catalog_treecomments->getRatesByMarkId($this->data['mark_id'], $customer_id, $this->data['mark']); if (!$customer_id == -1) { $customer_id = false; } if (count($results) > 0) { $resa = NULL; foreach ($results as $num => $res1) { $resa[$num] = $res1; if (isset($results_rates[$res1['review_id']])) { $resa[$num]['delta'] = $results_rates[$res1['review_id']]['rate_delta']; $resa[$num]['rate_count'] = $results_rates[$res1['review_id']]['rate_count']; $resa[$num]['rate_count_blog_plus'] = $results_rates[$res1['review_id']]['rate_delta_blog_plus']; $resa[$num]['rate_count_blog_minus'] = $results_rates[$res1['review_id']]['rate_delta_blog_minus']; $resa[$num]['customer_delta'] = $results_rates[$res1['review_id']]['customer_delta']; } else { $resa[$num]['customer_delta'] = 0; $resa[$num]['delta'] = 0; $resa[$num]['rate_count'] = 0; $resa[$num]['rate_count_blog_plus'] = 0; $resa[$num]['rate_count_blog_minus'] = 0; } $resa[$num]['hsort'] = ''; $mmm = NULL; $kkk = ''; $wh = strlen($res1['sorthex']) / 4; for ($i = 0; $i < $wh; $i++) { $mmm[$i] = str_pad(dechex(65535 - hexdec(substr($res1['sorthex'], $i * 4, 4))), 4, "F", STR_PAD_LEFT); $sortmy = substr($res1['sorthex'], $i * 4, 4); $kkk = $kkk . $sortmy; } $ssorthex = ''; if (is_array($mmm)) { foreach ($mmm as $num1 => $val) { $ssorthex = $ssorthex . $val; } } if ($this->data['sorting'] != 'asc') { $resa[$num]['sorthex'] = $ssorthex; } else { $resa[$num]['sorthex'] = $kkk; } $resa[$num]['hsort'] = $kkk; } $results = NULL; $results = $resa; uasort($results, 'sdesc'); $this->data['fields'] = array(); if (isset($thislist['addfields'])) { usort($thislist['addfields'], 'comp_field'); $this->data['fields'] = $thislist['addfields']; } $this->load->model('catalog/fields'); $fields_db = $this->model_catalog_fields->getFieldsDBlang(); foreach ($this->data['fields'] as $num => $field) { foreach ($fields_db as $num_db => $field_db) { if ($field['field_name'] == $field_db['field_name']) { foreach ($field_db as $num_1 => $field_1) { if (!isset($this->data['fields'][$num][$num_1]) || $field_db[$num_1] == '') { $this->data['fields'][$num][$num_1] = $field_1; } else { } } } } } $i = 0; foreach ($results as $num => $result) { $f = 0; $addfields = array(); foreach ($result as $field_key => $field) { foreach ($this->data['fields'] as $num_db => $field_db) { if (trim($field_key) == trim($field_db['field_name'])) { $field_db['value'] = $field_db['text'] = $result[$field_key]; $addfields[$f] = $field_db; break; } else { } } $f++; } usort($addfields, 'comp_field'); if (!isset($result['date_available'])) { $result['date_available'] = $result['date_added']; } if (isset($this->data['settings_general']['format_date'])) { } else { $this->data['settings_general']['format_date'] = $this->language->get('text_date'); } if (isset($this->data['settings_general']['format_hours'])) { } else { $this->data['settings_general']['format_hours'] = $this->language->get('text_hours'); } if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($result['date_added']))) { $date_str = $this->language->get('text_today'); } else { $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($result['date_added'])); } $date_added = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($result['date_added'])); $text = strip_tags($result['text']); $text = nl2br($text); if ($this->data['visual_editor']) { if (isset($this->data['thislist']['bbwidth']) && $this->data['thislist']['bbwidth'] != '') { $width = $this->data['thislist']['bbwidth']; } else { $width = '160px'; } require_once DIR_SYSTEM . 'library/bbcode/Parser.php'; $parser = new JBBCode\Parser(); $parser->addBBCode("quote", '<div class="quote">{param}</div>', true, true); $parser->addBBCode("quote", '<div class="quote">{param}</div>', false, false); $parser->addBBCode("size", '<span style="font-size:{option}%;">{param}</span>', true, true); $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1); $parser->addBBCode("video", '<div style="overflow:hidden; "><iframe width="300" height="200" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe></div>', false, false, 1); $parser->addBBCode("img", '<a href="{param}" class="imagebox" rel="imagebox" style="overflow: hidden;"><img class="bbimage" alt="" width="' . $width . '" src="{param}"></a>'); $parser->addBBCode("url", '<a href="{param}" target="_blank" rel="nofollow">{param}</a>', false, false); $parser->addBBCode("url", '<a href="{option}" target="_blank" rel="nofollow">{param}</a>', true, true); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($text); $text = $parser->getAsHtml(); } $this->data['voted'] = false; if (!$customer_id) { if (!empty($karma_cookie)) { if (isset($karma_cookie[$result['review_id']])) { $this->data['voted'] = true; } } } if ($customer_id) { $this->data['voted'] = $result['customer_delta']; } if (!isset($result['buyproduct'])) { $result['buyproduct'] = false; } if (isset($result['avatar'])) { $this->data['avatar'] = $result['avatar']; } else { $this->data['avatar'] = ''; } if (isset($this->data['thislist']['avatar_width']) && $this->data['thislist']['avatar_width'] != '') { $width = $this->data['thislist']['avatar_width']; } else { if (isset($this->data['settings_general']['avatar_width']) && $this->data['settings_general']['avatar_width'] != '') { $width = $this->data['settings_general']['avatar_width']; } else { $width = '100'; } } if (isset($this->data['thislist']['avatar_height']) && $this->data['thislist']['avatar_height'] != '') { $height = $this->data['thislist']['avatar_height']; } else { if (isset($this->data['settings_general']['avatar_height']) && $this->data['settings_general']['avatar_height'] != '') { $height = $this->data['settings_general']['avatar_height']; } else { $height = '100'; } } $this->data['avatar_width'] = $width; $this->data['avatar_height'] = $height; $this->load->model('tool/image'); if ($this->data['avatar'] == '') { if (file_exists(DIR_IMAGE . 'no_image.jpg')) { $no_image = 'no_image.jpg'; } if (file_exists(DIR_IMAGE . 'no_image.png')) { $no_image = 'no_image.png'; } if (isset($this->data['settings_general']['avatar_admin']) && $this->data['settings_general']['avatar_admin'] != '' && isset($this->data['admin_name'][trim($result['author'])])) { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_admin'], $this->data['avatar_width'], $this->data['avatar_height']); } else { if (isset($this->data['settings_general']['avatar_buyproduct']) && $this->data['settings_general']['avatar_buyproduct'] != '' && isset($result['buyproduct']) && $result['buyproduct'] != '') { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buyproduct'], $this->data['avatar_width'], $this->data['avatar_height']); } else { if (isset($this->data['settings_general']['avatar_buy']) && $this->data['settings_general']['avatar_buy'] != '' && isset($result['buy']) && $result['buy'] != '') { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buy'], $this->data['avatar_width'], $this->data['avatar_height']); } else { if (isset($this->data['settings_general']['avatar_reg']) && $this->data['settings_general']['avatar_reg'] != '' && isset($result['customer_id']) && $result['customer_id'] > 0) { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_reg'], $this->data['avatar_width'], $this->data['avatar_height']); } else { if (isset($this->data['settings_general']['avatar_default']) && $this->data['settings_general']['avatar_default'] != '') { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_default'], $this->data['avatar_width'], $this->data['avatar_height']); } else { $this->data['avatar'] = $this->model_tool_image->resizeme($no_image, $this->data['avatar_width'], $this->data['avatar_height']); } } } } } } else { $this->data['avatar'] = $this->model_tool_image->resizeme($this->data['avatar'], $this->data['avatar_width'], $this->data['avatar_height']); } if ($result['rating_mark'] != '0') { $result['rating'] = 0; } $this->data['comments'][] = array('comment_id' => $result['review_id'], 'avatar' => $this->data['avatar'], 'sorthex' => $result['sorthex'], 'buy' => $result['buy'], 'buyproduct' => $result['buyproduct'], 'customer_id' => $result['customer_id'], 'customer' => $customer_id, 'voted' => $this->data['voted'], 'customer_delta' => $result['customer_delta'], 'level' => strlen($result['sorthex']) / 4 - 1, 'parent_id' => $result['parent_id'], 'author' => $result['author'], 'text' => $text, 'rating' => (int) $result['rating'], 'rating_mark' => (int) $result['rating_mark'], 'hsort' => $result['hsort'], 'myarray' => $mmm, 'fields' => $addfields, 'delta' => $result['delta'], 'rate_count' => $result['rate_count'], 'rate_count_blog_plus' => $result['rate_count_blog_plus'], 'rate_count_blog_minus' => $result['rate_count_blog_minus'], 'comments' => sprintf($this->language->get('text_comments'), (int) $comment_total), 'date_added' => $date_added, 'date_available' => $result['date_available']); $i++; } } if (!function_exists('my_sort_div_mark')) { function my_sort_div_mark($data, $parent = 0, $sorting, $field, $lev = -1) { $arr = $data[$parent]; usort($arr, array(new cmp_my_comment($field, $sorting), "my_cmp")); $lev = $lev + 1; for ($i = 0; $i < count($arr); $i++) { $arr[$i]['level'] = $lev; $z[] = $arr[$i]; $z[count($z) - 1]['flag_start'] = 1; $z[count($z) - 1]['flag_end'] = 0; if (isset($data[$arr[$i]['comment_id']])) { $m = my_sort_div_mark($data, $arr[$i]['comment_id'], $sorting, $field, $lev); $z = array_merge($z, $m); } if (isset($z[count($z) - 1]['flag_end'])) { $z[count($z) - 1]['flag_end']++; } else { $z[count($z) - 1]['flag_end'] = 1; } } return $z; } } if (count($this->data['comments']) > 0) { for ($i = 0, $c = count($this->data['comments']); $i < $c; $i++) { $new_arr[$this->data['comments'][$i]['parent_id']][] = $this->data['comments'][$i]; } $mycomments = my_sort_div_mark($new_arr, 0, $this->data['sorting'], $comments_order); $i = 0; foreach ($mycomments as $num => $result) { if ($i >= ($page - 1) * $this->data['number_comments'] && $i < ($page - 1) * $this->data['number_comments'] + $this->data['number_comments']) { $this->data['mycomments'][$i] = $result; } $i++; } } else { $this->data['mycomments'] = array(); } if (!isset($this->data['mycomments'])) { $this->data['mycomments'] = array(); } $this->data['karma_voted'] = false; if (!$customer_id) { if (isset($_COOKIE["karma_" . $this->data['mark']])) { $karma_cookie = unserialize(base64_decode($_COOKIE["karma_" . $this->data['mark']])); } else { $karma_cookie = array(); } if (!empty($karma_cookie)) { foreach ($karma_cookie as $id => $mark_id) { if (isset($mark_id['id'])) { if ($mark_id['id'] == $this->data['mark_id']) { $this->data['karma_voted'] = true; } } else { setcookie("karma_" . $this->data['mark'], '', time() + 60 * 60 * 24 * 555, '/', $this->request->server['HTTP_HOST']); } } } } else { $check_rate_num = $this->model_catalog_treecomments->checkRateNum($this->data, $this->data['mark']); foreach ($check_rate_num as $id => $mark_id) { if ($id == $this->data['mark'] && $mark_id == $this->data['mark_id']) { $this->data['karma_voted'] = true; } } } $url_end = ""; foreach ($this->request->get as $get_key => $get_val) { if ($get_key != 'route' && $get_key != 'prefix' && $get_key != '_route_' && $get_key != 'wpage' && $get_key != 'cmswidget' && $get_key != $get_pagination) { $url_end .= "&" . (string) $get_key . "=" . (string) $get_val; } } $this->data['cmswidget'] = $cmswidget; $link_url = $this->url->link($mark_route, $this->data['mark'] . '=' . $this->data['mark_id'] . '&' . $get_pagination . '=cmswidget-' . $cmswidget . '_sorting-' . $this->data['sorting'] . '_wpage-{page}' . '#cmswidget-' . $cmswidget); $pagination = new Pagination(); $pagination->total = $comment_total; $pagination->page = $page; $pagination->limit = $this->data['number_comments']; $pagination->text = $this->language->get('text_pagination'); $pagination->url = $link_url; $this->data['pagination'] = $pagination->render(); $data_statistics = $this->ratingStatistics($this->data); $template = 'rozetka.tpl'; if (isset($thislist['blog_template_comment']) && $thislist['blog_template_comment'] != '') { $template = $thislist['blog_template_comment']; } if (isset($this->data['category_design']['blog_template_comment']) && $this->data['category_design']['blog_template_comment'] != '') { $template = $this->data['category_design']['blog_template_comment']; } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/agootemplates/module/treecomments/' . $template)) { $this_template = $this->config->get('config_template') . '/template/agootemplates/module/treecomments/' . $template; } else { if (file_exists(DIR_TEMPLATE . 'default/template/agootemplates/module/treecomments/' . $template)) { $this_template = 'default/template/agootemplates/module/treecomments/' . $template; } else { $this_template = 'default/template/agootemplates/module/treecomments/rozetka.tpl'; } } $this->data['text_signer_answer'] = $this->language->get('text_signer_answer'); $this->data['text_signer_answer_email'] = $this->language->get('text_signer_answer_email'); $this->data['text_signer'] = $this->language->get('text_signer'); $this->data['text_write_review'] = $this->language->get('text_write_review'); $this->data['text_write'] = $this->language->get('text_write'); $this->data['hide_block'] = $this->language->get('hide_block'); $this->data['error_register'] = $this->language->get('error_register'); $this->data['entry_name'] = $this->language->get('entry_name'); $this->data['text_customer_enter'] = $this->language->get('text_customer_enter'); $this->data['entry_comment'] = $this->language->get('entry_comment'); $this->data['text_note'] = $this->language->get('text_note'); $this->data['entry_rating_review'] = $this->language->get('entry_rating_review'); $this->data['entry_bad'] = $this->language->get('entry_bad'); $this->data['entry_good'] = $this->language->get('entry_good'); $this->data['entry_captcha_title'] = $this->language->get('entry_captcha_title'); $this->data['entry_captcha'] = $this->language->get('entry_captcha'); $this->data['text_voted_blog_plus'] = $this->language->get('text_voted_blog_plus'); $this->data['text_voted_blog_minus'] = $this->language->get('text_voted_blog_minus'); $this->data['text_vote_will_reg'] = $this->language->get('text_vote_will_reg'); $this->data['text_vote_blog_plus'] = $this->language->get('text_vote_blog_plus'); $this->data['text_vote_blog_minus'] = $this->language->get('text_vote_blog_minus'); $this->data['text_review_yes'] = $this->language->get('text_review_yes'); $this->data['text_review_no'] = $this->language->get('text_review_no'); $this->data['text_review_karma'] = $this->language->get('text_review_karma'); $this->data['tab_review'] = $this->language->get('tab_review'); $this->data['text_all'] = $this->language->get('text_all'); $this->data['text_admin'] = $this->language->get('text_admin'); $this->data['text_buyproduct'] = $this->language->get('text_buyproduct'); $this->data['text_buy'] = $this->language->get('text_buy'); $this->data['text_registered'] = $this->language->get('text_registered'); $this->data['text_buy_ghost'] = $this->language->get('text_buy_ghost'); $this->data['button_write'] = $this->language->get('button_write'); $this->data['text_wait'] = $this->language->get('text_wait'); $this->data['theme'] = $this->config->get('config_template'); $this->data['ascp_widgets'] = $this->config->get('ascp_widgets'); $this->data['settings_widget'] = $this->data['thislist']; $this->data['theme_stars'] = $this->getThemeStars('image/blogstars-1.png'); if (isset($this->session->data['token'])) { $this->data['token'] = $this->session->data['token']; } else { $this->data['token'] = ''; } $this->template = $this_template; $this->data['language'] = $this->language; if (SCP_VERSION < 2) { $html = $this->render(); } else { if (!is_array($this->data)) { $this->data = array(); } $html = $this->load->view($this->template, $this->data); } if (isset($get['ajax']) && $get['ajax'] == 1) { $this->response->setOutput($html); //return $html; } else { return $html; } } }
<div id="all-container"> <?php $notice_query = mysqli_query($mysql, "SELECT * FROM ms_pengumuman WHERE peng_status = 1 AND peng_text != ''"); if (mysqli_num_rows($notice_query) > 0) { ?> <div id="notice"> <?php while ($data = mysqli_fetch_array($notice_query)) { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->addBBCode("sup", '<sup>{param}</sup>'); $parser->addBBCode("sub", '<sub>{param}</sub>'); $parser->addBBCode("s", '<strike>{param}</strike>'); $parser->parse(htmlentities($data['peng_text'], ENT_QUOTES)); $pengumuman = str_replace("\n", "<br />", $parser->getAsHtml()); if ($pengumuman == "") { continue; } ?> <div id="notice-title">PENGUMUMAN</div> <div id="notice-content"><?php echo $pengumuman; ?> </div> <div id="notice-timestamp" class="hide"><?php echo strtotime($data['peng_lastedit']); ?> </div> <div class="clear"></div>
public function parse($str) { $str = str_replace("\t", " ", $str); $str = html_escape($str); parent::parse($str); $treeRoot =& $this->treeRoot; $i = 0; $children =& $treeRoot->getChildren(); foreach ($children as &$child) { if ($child instanceof \JBBCode\ElementNode && $child->getTagName() == 'section1') { $child->setAttribute('tuto-section-' . $i++); } } /* * * on convertit les smilies ** */ $smileyVisitor = new \JBBCode\visitors\SmileyVisitor(); $this->accept($smileyVisitor); }
?> <table width="100%" class="pure-table"> <tr> <th colspan="2">The 5 most recent messages between you and <?php echo $users->name($_GET['ID']); ?> </th> </tr><?php $db->query('SELECT `time_sent`, `message`, `sender` FROM `users_messages` WHERE (`sender` = ? AND `receiver` = ?) OR (`receiver` = ? AND `sender` = ?) ORDER BY `time_sent` DESC LIMIT 5'); $db->execute([$my['id'], $_GET['ID'], $_GET['ID'], $my['id']]); if (!$db->num_rows()) { echo '<tr><td colspan="2" class="center">You haven\'t spoken to ' . $users->name($_GET['ID']) . ' yet</td></tr>'; } else { $rows = $db->fetch_row(); foreach ($rows as $r) { $parser->parse($mtg->format($r['message'], true)); ?> <tr> <td width="25%" valign="top"> <strong><?php echo $_GET['ID'] == $r['sender'] ? $users->name($_GET['ID']) : 'You'; ?> wrote:</strong><br /> <span class="small"><?php echo date('F j, Y, g:i:s a', strtotime($r['time_sent'])); ?> </span> </td> <td valign="top"><?php echo str_replace('[username]', $users->name($my['id']), $parser->getAsHTML()); ?>
/** * Tests invalid css colors in a color bbcode. * * @depends testInvalidCssColor */ public function testInvalidColorBBCode() { $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse('[color=" onclick="alert(\'hey ya!\');]click me[/color]'); $this->assertEquals('[color=" onclick="alert(\'hey ya!\');]click me[/color]', $parser->getAsHtml()); }
private function getBlogsReviews($thislist, $type = 'reviews') { //$this->load->helper('utf8blog'); require_once DIR_SYSTEM . 'helper/utf8blog.php'; if (file_exists(DIR_IMAGE . 'no_image.jpg')) { $no_image = 'no_image.jpg'; } if (file_exists(DIR_IMAGE . 'no_image.png')) { $no_image = 'no_image.png'; } $this->data['settings'] = $thislist; $hash = md5(serialize($thislist)); $this->data['settings_hash'] = $hash; if ($this->customer->isLogged()) { $this->data['customer_group_id'] = $this->customer_group_id; } else { $this->data['customer_group_id'] = $this->config->get('config_customer_group_id'); } $rate = array(); $this->language->load('record/blog'); $this->load->model('catalog/comment'); $this->load->model('catalog/blog'); $this->load->model('catalog/fields'); $this->load->model('tool/image'); $this->data['text_manufacturer'] = $this->language->get('text_manufacturer'); $this->data['text_karma'] = $this->language->get('text_karma'); if (isset($thislist['title_list_latest'][$this->config->get('config_language_id')])) { $this->data['heading_title'] = $thislist['title_list_latest'][$this->config->get('config_language_id')]; } else { $this->data['heading_title'] = ""; } $this->data['text_comments'] = $this->language->get('text_comments'); $this->data['text_viewed'] = $this->language->get('text_viewed'); $row = $this->cache->get('product.blog.reviews.' . (int) $this->config->get('config_language_id') . '.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->data['customer_group_id'] . '.' . $hash); if (0 == 0 || empty($row)) { $this->data['fields'] = $this->model_catalog_fields->getFieldsDBlang(); $comments = $this->model_catalog_comment->getCommentsByBlogsIN($thislist, 3); if (isset($comments) && count($comments) > 0) { foreach ($comments as $comment) { if ($comment['type'] == 'blogs') { $blog_href = $this->model_catalog_blog->getPathByBlog($comment['blog_id']); $blog_link = $this->url->link('record/blog', 'blog_id=' . $blog_href['path']); $record_link = $this->url->link('record/record', 'record_id=' . $comment['record_id']); $rate = $this->model_catalog_comment->getRatesByCommentId($comment['comment_id']); $this->data['text_category'] = $this->language->get('text_blog'); $this->data['text_record'] = $this->language->get('text_record'); $comment['mark'] = 'record_id'; } if ($comment['type'] == 'categories') { $comment['mark'] = 'product_id'; if (isset($comment['review_id'])) { $comment['comment_id'] = $comment['review_id']; } else { $comment['comment_id'] = ''; } if (isset($comment['commentid'])) { $comment['comment_id'] = $comment['commentid']; } else { $comment['comment_id'] = ''; } if (isset($comment['product_id'])) { $comment['record_id'] = $comment['product_id']; } else { if (!isset($comment['record_id'])) { $comment['record_id'] = ''; } } } if ($comment['type'] == 'categories') { $blog_href = $this->model_catalog_blog->getPathByCategory($comment['blog_id']); $blog_link = $this->url->link('product/category', 'path=' . $blog_href['path']); $record_link = $this->url->link('product/product', 'product_id=' . $comment['record_id'] . "&path=" . $blog_href['path']); $rate = array(); $this->data['text_category'] = $this->language->get('text_category'); $this->data['text_record'] = $this->language->get('text_product'); } $comment_total = $comment['total']; $rate_count = 0; $rate_delta = 0; $rate_delta_blog_plus = 0; $rate_delta_blog_minus = 0; foreach ($rate as $r) { $rate_count = $r['rate_count']; $rate_delta = $r['rate_delta']; $rate_delta_blog_plus = $r['rate_delta_blog_plus']; $rate_delta_blog_minus = $r['rate_delta_blog_minus']; } $this->load->model('tool/image'); if ($comment) { if ($comment['image']) { if (isset($this->data['settings']['image']['width']) && isset($this->data['settings']['image']['height']) && $this->data['settings']['image']['width'] != "" && $this->data['settings']['image']['height'] != "") { $thumb = $this->model_tool_image->resizeme($comment['image'], $this->data['settings']['image']['width'], $this->data['settings']['image']['height'], $this->data['settings']['image_adaptive_status']); } else { $thumb = $this->model_tool_image->resizeme($comment['image'], 150, 150, $this->data['settings']['image_adaptive_status']); } } else { $thumb = ''; } } else { $thumb = ''; } if (!isset($comment['text'])) { $comment['text'] = ''; } $text = ''; if ($comment['text'] != '') { $flag_desc = 'none'; if ($thislist['desc_symbols'] != '') { $amount = $thislist['desc_symbols']; $flag_desc = 'symbols'; } if ($thislist['desc_words'] != '') { $amount = $thislist['desc_words']; $flag_desc = 'words'; } if ($thislist['desc_pred'] != '') { $amount = $thislist['desc_pred']; $flag_desc = 'pred'; } //if ($flag_desc != 'none') //$comment['text'] = preg_replace('/\[(.*?)\]/', '', $comment['text']); switch ($flag_desc) { case 'symbols': $limit = $amount; $source = strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')); $counter = 0; $matches = array(); utf8_preg_match_all('/(?:\\[.*\\].*\\[\\/.*\\])|(.)/Usiu', $source, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[1] as $num => $val) { if (is_array($val)) { $counter++; if ($counter == $limit) { $source = utf8_substr_replace($source, '', $val[1] + 1); break; } } } $text = $source; //$pattern = ('/((.*?)\S){0,' . $amount . '}/isu'); //preg_match_all($pattern, strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')), $out); //$text = $out[0][0]; break; case 'words': $limit = $amount; $source = strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')); $counter = 0; $matches = array(); utf8_preg_match_all('/(?:\\[.*\\].*\\[\\/.*\\])|(\\x20)/Usiu', $source, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[1] as $num => $val) { if (is_array($val)) { $counter++; if ($counter == $limit) { $source = utf8_substr_replace($source, '', $val[1] + 1); break; } } } $text = $source; /* $pattern = ('/((.*?)\x20){0,' . $amount . '}/isu'); preg_match_all($pattern, strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')), $out); $text = $out[0][0];*/ break; case 'pred': $limit = $amount; $source = strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')); $counter = 0; $matches = array(); utf8_preg_match_all('/(?:\\[.*\\].*\\[\\/.*\\])|(\\.)/Usiu', $source, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[1] as $num => $val) { if (is_array($val)) { $counter++; if ($counter == $limit) { $source = utf8_substr_replace($source, '', $val[1] + 1); break; } } } $text = $source; /* $pattern = ('/((.*?)\.){0,' . $amount . '}/isu'); preg_match_all($pattern, strip_tags(html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8')), $out); $text = $out[0][0]; */ break; case 'none': $text = html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8'); break; } } if ($text == '') { $text = html_entity_decode($comment['text'], ENT_QUOTES, 'UTF-8'); } if (isset($this->data['settings_general']['format_date'])) { } else { $this->data['settings_general']['format_date'] = $this->language->get('text_date'); } if (isset($this->data['settings_general']['format_hours'])) { } else { $this->data['settings_general']['format_hours'] = $this->language->get('text_hours'); } if (isset($this->data['settings_general']['format_time']) && $this->data['settings_general']['format_time'] && date($this->data['settings_general']['format_date']) == date($this->data['settings_general']['format_date'], strtotime($comment['date_added']))) { $date_str = $this->language->get('text_today'); } else { $date_str = rdate($this, $this->data['settings_general']['format_date'], strtotime($comment['date_added'])); } $date_available = $date_str . rdate($this, $this->data['settings_general']['format_hours'], strtotime($comment['date_added'])); require_once DIR_SYSTEM . 'library/bbcode/Parser.php'; $text = nl2br(strip_tags($text)); $width = '160px'; require_once DIR_SYSTEM . 'library/bbcode/Parser.php'; $parser = new JBBCode\Parser(); $parser->addBBCode("quote", '<div class="quote">{param}</div>', true, true); $parser->addBBCode("quote", '<div class="quote">{param}</div>', false, false); $parser->addBBCode("size", '<span style="font-size:{option}%;">{param}</span>', true, true); $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1); $parser->addBBCode("video", '<div style="overflow:hidden; "><iframe width="300" height="200" src="http://www.youtube.com/embed/{param}" frameborder="0" allowfullscreen></iframe></div>', false, false, 1); $parser->addBBCode("img", '<a href="{param}" class="imagebox" rel="imagebox" style="overflow: hidden;"><img class="bbimage" alt="" width="' . $width . '" src="{param}"></a>'); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $parser->parse($text); $text = $parser->getAsHtml(); $data = array('review_id' => $comment['comment_id'], 'mark' => $comment['mark']); $fields = $this->model_catalog_fields->getFields($data); $fields_new = array(); foreach ($fields as $num => $field) { foreach ($field as $pole => $val) { if ($pole != 'review_id' && $pole != 'mark') { if ($val != '') { $fields_new[$pole]['field_value'] = $val; $fields_new[$pole]['value'] = $val; foreach ($this->data['fields'] as $n => $value) { if ($value['field_name'] == $pole) { $fields_new[$pole]['field_description'] = ''; if ($value['field_description'][(int) $this->config->get('config_language_id')] != '') { $fields_new[$pole]['field_description'] = $value['field_description']; $fields_new[$pole]['field_name'] = $value['field_name']; $fields_new[$pole]['field'] = $value['field']; $fields_new[$pole]['field_image'] = $value['field_image']; $fields_new[$pole]['field_type'] = $value['field_type']; $fields_new[$pole]['field_order'] = $value['field_order']; $fields_new[$pole]['field_status'] = $value['field_status']; break; } } } } } } } if (isset($fields_new) && !empty($fields_new)) { usort($fields_new, 'comp_field'); } $comment['info'] = ''; if ($this->data['settings_widget']['buyer_status'] || $this->data['settings_widget']['avatar_status'] || $this->data['settings_widget']['karma_status'] || $this->data['settings_widget']['manufacturer_status']) { if ($comment['type'] == 'blogs') { $table = 'record'; } if ($comment['type'] == 'categories') { $table = 'product'; } if (isset($this->data['settings_widget']['admin_name']) && $this->data['settings_widget']['admin_name'] != '') { $this->data['admin_name'] = array_flip(explode(";", trim($this->data['settings_widget']['admin_name']))); } else { $this->data['admin_name'] = array(); } if (isset($this->data['settings_widget']['avatar_width']) && $this->data['settings_widget']['avatar_width'] != '') { $width = $this->data['settings_widget']['avatar_width']; } else { if (isset($this->data['settings_general']['avatar_width']) && $this->data['settings_general']['avatar_width'] != '') { $width = $this->data['settings_general']['avatar_width']; } else { $width = '100'; } } if (isset($this->data['settings_widget']['avatar_height']) && $this->data['settings_widget']['avatar_height'] != '') { $height = $this->data['settings_widget']['avatar_height']; } else { if (isset($this->data['settings_general']['avatar_height']) && $this->data['settings_general']['avatar_height'] != '') { $height = $this->data['settings_general']['avatar_height']; } else { $height = '100'; } } $this->data['avatar_width'] = $width; $this->data['avatar_height'] = $height; $comment['info'] = $this->getAvatarComment($comment, $table, $this->data); if ($comment['info']['avatar'] == '') { if (isset($this->data['settings_general']['avatar_admin']) && $this->data['settings_general']['avatar_admin'] != '' && isset($this->data['admin_name'][trim($comment['author'])])) { $comment['info']['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_admin'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } else { if (isset($this->data['settings_general']['avatar_buyproduct']) && $this->data['settings_general']['avatar_buyproduct'] != '' && isset($comment['info']['buyproduct']) && $comment['info']['buyproduct'] != '') { $comment['info']['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buyproduct'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } else { if (isset($this->data['settings_general']['avatar_buy']) && $this->data['settings_general']['avatar_buy'] != '' && isset($comment['info']['buy']) && $comment['info']['buy'] != '') { $comment['info']['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_buy'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } else { if (isset($this->data['settings_general']['avatar_reg']) && $this->data['settings_general']['avatar_reg'] != '' && isset($comment['info']['customer_id']) && $comment['info']['customer_id'] > 0) { $comment['info']['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_reg'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } else { if (isset($this->data['settings_general']['avatar_default']) && $this->data['settings_general']['avatar_default'] != '') { $comment['info']['avatar'] = $this->model_tool_image->resizeme($this->data['settings_general']['avatar_default'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } else { $comment['info']['avatar'] = $this->model_tool_image->resizeme($no_image, $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } } } } } } else { $comment['info']['avatar'] = $this->model_tool_image->resizeme($comment['info']['avatar'], $this->data['avatar_width'], $this->data['avatar_height'], $this->data['settings']['image_adaptive_status']); } if (isset($comment['info']['manufacturer_id']) && $comment['info']['manufacturer_id']) { $comment['info']['manufacturer_url'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $comment['info']['manufacturer_id']); } } if ($comment['rating_mark'] != '0') { $comment['rating'] = 0; } $this->data['comments'][] = array('comment_id' => $comment['comment_id'], 'fields' => $fields_new, 'parent_id' => $comment['parent_id'], 'blog_id' => $comment['blog_id'], 'blog_name' => $comment['blog_name'], 'blog_href' => $blog_link, 'blog_path' => $blog_href['path'], 'record_id' => $comment['record_id'], 'cmswidget' => $comment['cmswidget'], 'record_comments' => $comment['record_comments'], 'record_viewed' => $comment['record_viewed'], 'record_name' => $comment['record_name'], 'record_rating' => (int) $comment['rating_avg'], 'record_href' => $record_link, 'customer_id' => $comment['customer_id'], 'author' => $comment['author'], 'text' => $text, 'rating' => (int) $comment['rating'], 'rate_count' => $rate_count, 'rate_delta' => $rate_delta, 'rate_delta_blog_plus' => $rate_delta_blog_plus, 'rate_delta_blog_minus' => $rate_delta_blog_minus, 'date' => $date_available, 'image' => $comment['image'], 'thumb' => $thumb, 'text_category' => $this->data['text_category'], 'text_record' => $this->data['text_record'], 'info' => $comment['info']); } $this->data['comment_total'] = $comment_total; } $this->cache->set('product.blog.reviews.' . (int) $this->config->get('config_language_id') . '.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->data['customer_group_id'] . '.' . $hash, $this->data); } else { $this->data = $row; } return $this->data; }