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";
/** * 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(); }
/** * 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); $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()); }
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); }
/** * 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); }
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; }
protected function getNewParser() { $parser = new JBBCode\Parser(); if ($this->parser == null) { $this->parser = $parser; } $parser->addCodeDefinition(new \Extension\bbcode\JBBCode\myCodes\Titles()); $parser->addCodeDefinition(new \Extension\bbcode\JBBCode\myCodes\Lis()); $parser->addCodeDefinition(new \Extension\bbcode\JBBCode\myCodes\ListItem()); return $parser; }
<?php require_once __DIR__ . '/bb/Parser.php'; $parser = new JBBCode\Parser(); $parser->loadDefaultCodes(); //Images $parser->addBBCode("avatar", '<img src="//' . $domain . '/avatar/{param}"/>'); $parser->addBBCode("card", '<img src="//' . $domain . '/card/{param}"/>'); $parser->addBBCode("stats", '<img src="//' . $domain . '/infopic/{param}"/>'); //Links $parser->addBBCode("player", '<a href="//' . $domain . '/player/{param}">{param}<sup>(character)</sup></a>'); //Various $parser->addBBCode("br", '<br />');
/** * @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(); }
</td> <td><?php echo $lang['mod/delete']; ?> </td> </tr> </thead> <tbody> <?php require_once "libs/jbbcode/Parser.php"; $parser = new \JBBCode\Parser(); $bbcode = $conn->query("SELECT * FROM bbcodes;"); while ($row = $bbcode->fetch_assoc()) { $parser->addBBCode($row['name'], $row['code']); } $qID = $conn->real_escape_string($_GET['id']); $qBoard = $conn->real_escape_string($_GET['board']); $getPass = $conn->query("SELECT password FROM posts WHERE board='" . $qBoard . "' AND id='" . $qID . "' "); $rPass = $getPass->fetch_row(); $posts = $conn->query("SELECT * FROM posts WHERE password='******'"); while ($row = $posts->fetch_assoc()) { echo "<tr><td class='text-center text-nowrap'>"; if ($row['resto'] == 0) { echo "<a href='./" . $row['board'] . "/res/" . $row['id'] . ".html'>/" . $row['board'] . "/" . $row['id'] . ".html</a>"; } else { echo "<a href='./" . $row['board'] . "/res/" . $row['resto'] . ".html#p" . $row['id'] . "'>/" . $row['board'] . "/" . $row['resto'] . ".html#p" . $row['id'] . "</a>";
function serializeThread($board, $thread_id) { if ($this->mitsuba->common->isBoard($board)) { $thread = $this->conn->query("SELECT * FROM posts WHERE board='" . $board . "' AND id=" . $thread_id . " AND deleted=0"); if ($thread->num_rows == 1) { $row = $thread->fetch_assoc(); require_once "libs/jbbcode/Parser.php"; $parser = new \JBBCode\Parser(); $boarddata = $this->mitsuba->common->getBoardData($board); if ($boarddata['bbcode'] == 1) { $bbcode = $this->conn->query("SELECT * FROM bbcodes;"); while ($row = $bbcode->fetch_assoc()) { $parser->addBBCode($row['name'], $row['code']); } } $api_posts = array(); $api_posts[] = $this->serializePost($row, $boarddata, $parser); $posts = $this->conn->query("SELECT * FROM posts WHERE board='" . $board . "' AND resto=" . $thread_id); while ($row2 = $posts->fetch_assoc()) { $api_posts[] = $this->serializePost($row2, $boarddata, $parser); } $api_handle = fopen("./" . $board . "/res/" . $thread_id . ".json", "w"); $api['posts'] = $api_posts; fwrite($api_handle, json_encode($api)); fclose($api_handle); } } }
<?php require_once "/path/to/jbbcode/Parser.php"; $parser = new JBBCode\Parser(); $parser->addBBCode("quote", '<div class="quote">{param}</div>'); $parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1);
if ($userGroupData['staff']) { $staffQuery = $mysql->query("SELECT * FROM `staffpermissions` WHERE `id` = '" . $userGroupData['staff'] . "'"); $staffData = $staffQuery->fetch_assoc(); foreach ($staffData as $arrayIndex => $arrayValue) { if ($arrayValue > $permissions[$arrayIndex]) { $permissions[$arrayIndex] = $arrayValue ? $arrayValue : 0; } } } } } $userAvatarStyle = "style='max-width: " . $permissions['maxavatarwidth'] . "px; max-height: " . $permissions['maxavatarheight'] . "px;'"; date_default_timezone_set($timezoneList[strpos($user['timezone'], ".0") ? round($user['timezone']) : $user['timezone']]); $mysql->query("UPDATE `accounts` SET `ip` = '" . $_SERVER['REMOTE_ADDR'] . "', `lastactivity` = '" . time() . "' WHERE `id` = '" . $_SESSION['accountid'] . "'"); } $bbParser = new JBBCode\Parser(); $bbParser->loadDefaultCodes(); $bbParser->addBBCode("quote", "<div class='quote'>{param}</div> <br>"); $bbParser->addBBCode("left", "<div align='left'>{param}</div>"); $bbParser->addBBCode("center", "<div align='center'>{param}</div>"); $bbParser->addBBCode("right", "<div align='right'>{param}</div>"); $bbParser->addBBCode("email", "<a href='mailto:{param}'>{param}</a>"); $bbParser->addBBCode("font", "<span style='font-family: {option};'>{param}</span>", true); $bbParser->addBBCode("size", "<span style='font-size: {option}px;'>{param}</span>", true); $bbParser->addBBCode("list", "<ul>{param}</ul>"); $bbParser->addBBCode("nlist", "<ol>{param}</ol>"); $bbParser->addBBCode("li", "<li>{param}</li>"); $bbParser->addBBCode("mention", "<span data-user='******' class='mentionUser bold'>{param}</span>"); ?> <script>
<?php define('URL', 'http://forum.mods.de/bb/'); require_once './bbcode/Parser.php'; require_once 'ModsCodeDefinitions.php'; $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); $builder = new QuoteCodeDefinition(); $builder->setUseOption(true); $parser->addCodeDefinition($builder); $builder = new QuoteCodeDefinition(); $parser->addCodeDefinition($builder); $builder = new YouTubeCodeDefinition(); $parser->addCodeDefinition($builder); function holeBoardAlsXML($page) { $boardUrl = URL . 'xml/board.php?BID=14'; if (isset($page)) { if ($page < 1) { $page = 1; } } else { $page = 1; } $boardUrl .= '&page=' . $page; return simplexml_load_file($boardUrl); } function holeThreadAlsXML($threadId, $page) { $threadUrl = URL . 'xml/thread.php?TID=' . $threadId . '&page=' . $page; return simplexml_load_file($threadUrl);
?> </td> <td class="reporterIP"><?php echo $lang['mod/reporter_ip']; ?> </td> <td><?php echo $lang['mod/actions']; ?> </td> </tr> </thead> <tbody> <?php require_once "libs/jbbcode/Parser.php"; $parser = new \JBBCode\Parser(); $bbcode = $conn->query("SELECT * FROM bbcodes;"); while ($row = $bbcode->fetch_assoc()) { $parser->addBBCode($row['name'], $row['code']); } $result = $conn->query("SELECT * FROM reports ORDER BY created DESC"); while ($row = $result->fetch_assoc()) { $post = $conn->query("SELECT * FROM posts WHERE id=" . $row['reported_post'] . " AND board='" . $row['board'] . "'"); if ($post->num_rows == 0) { $conn->query("DELETE FROM reports WHERE id=" . $row['id']); continue; } $pdata = $post->fetch_assoc(); $resto = $pdata['id']; if ($pdata['resto'] != 0) { $resto = $pdata['resto'];
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); }
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; } } }
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; }
<?php require_once "../Parser.php"; require_once "../visitors/TagCountingVisitor.php"; error_reporting(E_ALL); $parser = new JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); if (count($argv) < 3) { die("Usage: " . $argv[0] . " \"bbcode string\" <tag name to check>\n"); } $inputText = $argv[1]; $tagName = $argv[2]; $parser->parse($inputText); $tagCountingVisitor = new \JBBCode\visitors\TagCountingVisitor(); $parser->accept($tagCountingVisitor); echo $tagCountingVisitor->getFrequency($tagName) . "\n";
<?php } ?> </div> </div> <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>
<?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();
$config['core.job.queue.manager'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Job\\MysqlQueueManager', 'arguments' => array('@core.job.queue.launcher')); $config['core.job.queue.launcher'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Job\\ModuleLauncher'); $config['core.image.manipulator'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Image\\Manipulator'); $config['ikantam.theme.factory'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Ikantam\\Theme\\Factory'); $config['core.image.manipulator'] = array('type' => 'service', 'class' => 'Core\\Service\\Image\\Manipulator'); //Mailer service $config['core.mailer'] = array('type' => 'service', 'class' => 'Core\\Service\\Mail\\MailerSwiftInflect', 'arguments' => array('@swift.mailer', '%email.config%', '@template', '@swift.message')); $config['swift.mailer'] = array('type' => 'service', 'class' => 'Swift_Mailer', 'arguments' => array('@swift.transport')); $config['swift.transport'] = function ($container) { return Core\Service\Mail\SwiftTransportFactory::create($container['parameters.container']->get('email.config', array())); }; $config['core.theme.storage.db'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Storage\\DbStorage', 'arguments' => array('@core.service.theme.values.handler')); $config['core.service.theme.installer'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Installer', 'arguments' => array('@core.theme.storage.db', '%theme.install.html.component.handler.class.name%')); $config['core.service.theme.user.data'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\DbUserData', 'arguments' => array('@core.service.theme.values.handler')); $config['jbbcode.parser'] = function () { $parser = new \JBBCode\Parser(); $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet()); return $parser; }; $config['core.service.theme.bbcode.parser'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\BbcodeParser', 'arguments' => array('@jbbcode.parser', '%theme.custom.bbcodes%')); $config['core.service.theme.html'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Html', 'arguments' => array('@core.theme.storage.db', '@core.service.theme.user.data', '@core.service.theme.bbcode.parser', '%theme.edit.html.component.handler.class.name%', '%theme.view.html.component.handler.class.name%')); $config['core.service.theme.values.handler'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\ValuesHandlerDb'); $config['core.service.theme.user.data.storage.db'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Storage\\DbUserDataStorage', 'arguments' => array('@core.service.theme.values.handler')); $config['core.service.theme.helper'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Helper', 'arguments' => array('@core.service.theme.user.data.storage.db', '@core.theme.storage.db', '%theme.install.html.component.handler.class.name%')); $config['core.service.theme.session.helper'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\SessionHelper', 'arguments' => array('@codeigniter', '@core.service.theme.values.handler')); $config['core.servce.theme.image.uploader'] = array('type' => PimpleContainer::TYPE_SERVICE, 'class' => 'Core\\Service\\Theme\\Image\\Uploader', 'arguments' => array('@core.file.upload')); $config['current_user.model'] = function ($container) { return $container['codeigniter']->ion_auth->getActiveUser(); }; $config['ci_image_lib'] = function ($container) { $container['codeigniter']->load->library('image_lib');
protected function processCommentBBCode($comment) { if ($this->_bbcode_processor === null) { $parser = new \JBBCode\Parser(); $definitions = array(); $builder = new \Foolz\FoolFuuka\Model\BBCode\Code(); array_push($definitions, $builder); $builder = new \JBBCode\CodeDefinitionBuilder('spoiler', '<span class="spoiler">{param}</span>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('sub', '<sub>{param}</sub>'); $builder->setNestLimit(1); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('sup', '<sup>{param}</sup>'); $builder->setNestLimit(1); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('eqn', '<script type="math/tex; mode=display">{param}</script>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('math', '<script type="math/tex">{param}</script>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('b', '<strong>{param}</strong>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('i', '<em>{param}</em>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('o', '<span class="overline">{param}</span>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('s', '<span class="strikethrough">{param}</span>'); array_push($definitions, $builder->build()); $builder = new \JBBCode\CodeDefinitionBuilder('u', '<span class="underline">{param}</span>'); array_push($definitions, $builder->build()); $definitions = Hook::forge('Foolz\\FoolFuuka\\Model\\Comment::processCommentBBCode#var.definitions')->setObject($this)->setParam('definitions', $definitions)->execute()->get($definitions); foreach ($definitions as $definition) { $parser->addCodeDefinition($definition); } $this->_bbcode_processor = $parser; } // work around for dealing with quotes in BBCode tags $comment = str_replace('"', '"', $comment); $comment = $this->_bbcode_processor->parse($comment)->getAsBBCode(); $comment = str_replace('"', '"', $comment); return $this->_bbcode_processor->parse($comment)->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()); }