/** * For display of custom parsed text on user-facing pages * Expects $text to be the value directly from the database (stored value) */ function generate_text_for_display($text, $only_smileys = false, $censor = true, $acro_autolinks = false, $forum_id = '999999') { global $bbcode, $config, $user; if (empty($text)) { return ''; } if (defined('IS_ICYPHOENIX') && $censor) { $text = censor_text($text); } if (!class_exists('bbcode') || empty($bbcode)) { include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } if (empty($bbcode)) { $bbcode = new bbcode(); if (!$user->data['session_logged_in']) { $user->data['user_allowhtml'] = $config['allow_html'] ? true : false; $user->data['user_allowbbcode'] = $config['allow_bbcode'] ? true : false; $user->data['user_allowsmile'] = $config['allow_smilies'] ? true : false; } $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? true : false; $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? true : false; $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? true : false; } if ($only_smileys) { $text = $bbcode->parse_only_smilies($text); } else { $text = $bbcode->parse($text); if ($acro_autolinks) { $text = $bbcode->acronym_pass($text); $text = $bbcode->autolink_text($text, $forum_id); } } return $text; }
function get_html($tree = null) { $str = ''; foreach ($this->tree as $item) { if ('item' == $item['type']) { continue; } $str .= $item['str']; } $bb = new bbcode(); $bb->tags = $this->tags; $bb->mnemonics = $this->mnemonics; $bb->autolinks = $this->autolinks; $bb->parse($str); return '<code class="bb_code">' . $bb->highlight() . '</code>'; }
function book_info($mysql_db, $sqlite_db, $min) { $sqlite_db->query("begin transaction;"); $bb = new bbcode(); $bb->autolinks = false; $sqltest = "SELECT BookId FROM libbannotations WHERE BookId>{$min}"; $query = $mysql_db->query($sqltest); while ($row = $query->fetch_array()) { echo "Book: " . $row['BookId'] . "\n"; $sqltest1 = "SELECT Body FROM libbannotations WHERE BookId=" . $row['BookId']; $query1 = $mysql_db->query($sqltest1); $row1 = $query1->fetch_array(); $sql = "UPDATE books SET description=? where id=?"; $insert = $sqlite_db->prepare($sql); $bb->parse($row1['Body']); $body = $bb->get_html(); $body = str_replace("<", "<", $body); $body = str_replace(">", ">", $body); $insert->execute(array($body, $row['BookId'])); $insert->closeCursor(); } $sqlite_db->query("commit;"); }
function parseMessage($text, $enable_bbcode, $enable_html, $enable_smilies, $enable_autolinks_acronyms) { global $db, $cache, $config, $user, $bbcode, $lofi; if (!class_exists('bbcode')) { include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } if (empty($bbcode)) { $bbcode = new bbcode(); } if (!empty($text)) { $text = censor_text($text); // Parse message and/or sig for BBCode if reqd $bbcode->allow_html = $this->config['allow_html'] == true && $enable_html == true ? true : false; $bbcode->allow_bbcode = $this->config['allow_bbcode'] == true && $enable_bbcode == true ? true : false; $bbcode->allow_smilies = $this->config['allow_smilies'] == true && !$lofi == true && $enable_smilies == true ? true : false; $text = $bbcode->parse($text); if ($enable_autolinks_acronyms) { $text = $bbcode->acronym_pass($text); $text = $bbcode->autolink_text($text, '999999'); } } else { $text = ''; } // Strip out the <!--break--> delimiter. $delim = htmlspecialchars('<!--break-->'); $pos = strpos($text, $delim); if ($pos !== false && $pos < strlen($text)) { $text = substr_replace($text, html_entity_decode($delim), $pos, strlen($delim)); } return $text; }
} } else { // They didn't feel like giving us any information. Oh, too bad, we'll just display the list then... $template->set_filenames(array('body' => ADM_TPL . 'title_list_body.tpl')); $sql = "SELECT * FROM " . TITLE_INFOS_TABLE . "\n\t\t\t\t\t\tORDER BY id ASC"; $result = $db->sql_query($sql); $title_rows = $db->sql_fetchrowset($result); $title_count = sizeof($title_rows); $template->assign_vars(array('S_TITLE_ACTION' => append_sid('admin_quick_title.' . PHP_EXT), 'ADMIN_TITLE' => $lang['Title_infos'], 'ADMIN_TITLE_EXPLAIN' => $lang['Quick_title_explain'], 'HEAD_TITLE' => $lang['Title_head'], 'HEAD_HTML' => $lang['Title_html'], 'HEAD_AUTH' => $lang['Title_auth'], 'ADD_NEW' => $lang['Add_new'], 'HEAD_DATE' => $lang['Date_format'], 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'])); for ($i = 0; $i < $title_count; $i++) { $title_id = $title_rows[$i]['id']; $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2']; $perm = $title_rows[$i]['admin_auth'] == 1 ? $lang['Administrator'] . '<br />' : ''; $perm .= $title_rows[$i]['mod_auth'] == 1 ? $lang['Moderator'] . '<br />' : ''; $perm .= $title_rows[$i]['poster_auth'] == 1 ? $lang['Topic_poster'] : ''; $template->assign_block_vars('title', array('ROW_CLASS' => $row_class, 'TITLE' => $title_rows[$i]['title_info'], 'HTML' => $bbcode->parse($title_rows[$i]['title_html']), 'PERMISSIONS' => $perm, 'DATE_FORMAT' => $title_rows[$i]['date_format'], 'U_TITLE_EDIT' => append_sid('admin_quick_title.' . PHP_EXT . '?mode=edit&id=' . $title_id), 'U_TITLE_DELETE' => append_sid('admin_quick_title.' . PHP_EXT . '?mode=delete&id=' . $title_id))); } } } else { // Show the default page $template->set_filenames(array('body' => ADM_TPL . 'title_list_body.tpl')); $sql = "SELECT * FROM " . TITLE_INFOS_TABLE . "\n\t\t\t\t\tORDER BY id ASC LIMIT {$start}, 40"; $result = $db->sql_query($sql); $title_rows = $db->sql_fetchrowset($result); $title_count = sizeof($title_rows); $sql = "SELECT count(*) AS total\n\t\t\t\t\tFROM " . TITLE_INFOS_TABLE; $result = $db->sql_query($sql); if ($total = $db->sql_fetchrow($result)) { $total_records = $total['total']; $pagination = generate_pagination('admin_quick_title.' . PHP_EXT . '?mode=' . $mode, $total_records, 40, $start) . ' '; }
/** * Edit topic(s) titles */ function topic_quick_title_edit($topics_ids, $qt_row) { global $db, $cache, $config, $bbcode, $user, $lang; if (!class_exists('bbcode')) { include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } if (empty($bbcode)) { $bbcode = new bbcode(); } $bbcode->allow_html = true; $bbcode->allow_bbcode = true; $bbcode->allow_smilies = true; $title_prefix = !empty($qt_row['title_html']) ? $bbcode->parse($qt_row['title_html']) : $qt_row['title_info']; $title_prefix = str_replace('%mod%', $user->data['username'], $title_prefix); $qt_date = empty($qt_row['date_format']) ? create_date($config['default_dateformat'], time(), $config['board_timezone']) : create_date($qt_row['date_format'], time(), $config['board_timezone']); $title_prefix = str_replace('%date%', $qt_date, $title_prefix); $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\tSET title_compl_infos = '" . $db->sql_escape(trim($title_prefix)) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids) . "\n\t\t\t\tAND topic_moved_id = 0"; $result = $db->sql_query($sql); empty_cache_folders(POSTS_CACHE_FOLDER); }
function get_event_topics(&$events, &$number, $start_date, $end_date, $limit = false, $start = 0, $max_limit = -1, $fid = '') { global $tree, $template, $lang, $images, $user, $db, $cache, $config, $bbcode; if (!class_exists('bbcode')) { include IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT; } if (empty($bbcode)) { $bbcode = new bbcode(); } // get some parameter $topic_title_length = isset($config['calendar_title_length']) ? intval($config['calendar_title_length']) : 30; $topic_text_length = isset($config['calendar_text_length']) ? intval($config['calendar_text_length']) : 200; if ($max_limit < 0) { $max_limit = $config['topics_per_page']; } // get the forums authorized (compliency with categories hierarchy v2 mod) $cat_hierarchy = function_exists(get_auth_keys); $s_forums_ids = ''; if (!$cat_hierarchy) { // standard read $is_auth = array(); $is_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data); // forum or cat asked $is_ask = array(); if ($fid == 'Root' || $fid == POST_CAT_URL . 0) { $fid = ''; } if (!empty($fid)) { $type = substr($fid, 0, 1); $id = intval(substr($fid, 1)); if ($type == POST_CAT_URL) { $sql = "SELECT forum_id FROM " . FORUMS_TABLE . " WHERE parent_id = '" . $id . "'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $is_ask[$row['forum_id']] = true; } $db->sql_freeresult($result); } elseif ($type == POST_FORUM_URL) { $is_ask[$id] = true; } else { return; } } // get the list of authorized forums while (list($forum_id, $forum_auth) = each($is_auth)) { if ($forum_auth['auth_read'] && (empty($fid) || isset($is_ask[$forum_id]))) { $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $forum_id; } } } else { if (empty($fid) || $fid == POST_CAT_URL . 0) { $fid = 'Root'; } // get auth key $keys = array(); $keys = get_auth_keys($fid, true, -1, -1, 'auth_read'); for ($i = 0; $i < sizeof($keys['id']); $i++) { if ($tree['type'][$keys['idx'][$i]] == POST_FORUM_URL && $tree['auth'][$keys['id'][$i]]['auth_read']) { $s_forum_ids .= (empty($s_forum_ids) ? '' : ', ') . $tree['id'][$keys['idx'][$i]]; } } } // no forums authed, return if (empty($s_forum_ids)) { return; } // select topics $sql_forums_field = ''; $sql_forums_file = ''; $sql_forums_match = ''; if (!$cat_hierarchy) { $sql_forums_field = ', f.forum_name'; $sql_forums_file = ', ' . FORUMS_TABLE . ' AS f'; $sql_forums_match = ' AND f.forum_id = t.forum_id'; } $sql = "SELECT\n\t\t\t\t\tt.*,\n\t\t\t\t\tp.poster_id, p.post_username, p.post_text, p.enable_bbcode, p.enable_html, p.enable_smilies,\n\t\t\t\t\tu.username, u.user_active, u.user_color,\n\t\t\t\t\tlp.poster_id AS lp_poster_id,\n\t\t\t\t\tlu.username AS lp_username,\n\t\t\t\t\tlp.post_username AS lp_post_username,\n\t\t\t\t\tlp.post_time AS lp_post_time\n\t\t\t\t\t{$sql_forums_field}\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . POSTS_TABLE . " AS lp, " . USERS_TABLE . " lu {$sql_forums_file}\n\t\t\tWHERE\n\t\t\t\tt.forum_id IN ({$s_forum_ids})\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND u.user_id = p.poster_id\n\t\t\t\tAND lp.post_id = t.topic_last_post_id\n\t\t\t\tAND lu.user_id = lp.poster_id\n\t\t\t\tAND t.topic_calendar_time < {$end_date}\n\t\t\t\tAND (t.topic_calendar_time + t.topic_calendar_duration) >= {$start_date}\n\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\t{$sql_forums_match}\n\t\t\tORDER BY\n\t\t\t\tt.topic_calendar_time, t.topic_calendar_duration DESC, t.topic_last_post_id DESC"; $result = $db->sql_query($sql); // get the number of occurences $number = $db->sql_numrows($result); // if limit per page asked, limit the number of results if ($limit) { $db->sql_freeresult($result); $sql .= " LIMIT {$start}, {$max_limit}"; $result = $db->sql_query($sql); } $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? 1 : 0; $bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? 1 : 0; $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? 1 : 0; // read the items while ($row = $db->sql_fetchrow($result)) { // prepare the message $topic_author_id = $row['poster_id']; $topic_author = $row['poster_id'] == ANONYMOUS ? $row['post_username'] : $row['username']; $topic_time = $row['topic_time']; $topic_last_author_id = $row['lp_poster_id']; $topic_last_author = $row['lp_poster_id'] == ANONYMOUS ? $row['lp_post_username'] : $row['lp_username']; $topic_last_time = $row['lp_post_time']; $topic_views = $row['topic_views']; $topic_replies = $row['topic_replies']; $topic_icon = $row['topic_icon']; $topic_title = $row['topic_title']; $message = htmlspecialchars($row['post_text']); $topic_calendar_time = $row['topic_calendar_time']; $topic_calendar_duration = $row['topic_calendar_duration']; $topic_link = append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $row['topic_id']); $topic_title = censor_text($topic_title); $message = censor_text($message); $short_title = strlen($topic_title) > $topic_title_length + 3 ? substr($topic_title, 0, $topic_title_length) . '...' : $topic_title; // Convert and clean special chars! $topic_title = htmlspecialchars_clean($topic_title); $short_title = htmlspecialchars_clean($short_title); // SMILEYS IN TITLE - BEGIN if ($config['smilies_topic_title'] && !$lofi) { $topic_title = $bbcode->parse_only_smilies($topic_title); $short_title = $bbcode->parse_only_smilies($short_title); } // SMILEYS IN TITLE - END $dsp_topic_icon = ''; if (function_exists('get_icon_title')) { $dsp_topic_icon = get_icon_title($topic_icon, 0, POST_CALENDAR); } // parse the message $message = substr($message, 0, $topic_text_length); // remove HTML if not allowed if (!$config['allow_html'] && $row['enable_html']) { $message = preg_replace('#(<)([\\/]?.*?)(>)#is', "<\\2>", $message); } $message = $bbcode->parse($message); // get the date format $fmt = $lang['DATE_FORMAT_CALENDAR']; if (!empty($topic_calendar_duration)) { $fmt = $config['default_dateformat']; } // replace \n with <br /> //$message = preg_replace("/[\n\r]{1,2}/", '<br />', $message); // build the overview $sav_tpl = $template->_tpldata; $det_handler = '_overview_topic_' . $row['topic_id']; $template->set_filenames(array($det_handler => 'calendar_overview_topic.tpl')); $nav_desc = ''; if ($cat_hierarchy) { $nav_desc = make_cat_nav_tree(POST_FORUM_URL . $row['forum_id'], '', '', 'gensmall'); } else { $nav_desc = '<a href="' . append_sid(IP_ROOT_PATH . CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $row['forum_id']) . '" class="gensmall">' . $row['forum_name'] . '</a>'; } $template->assign_vars(array('L_CALENDAR_EVENT' => $lang['Calendar_event'], 'L_AUTHOR' => $lang['Author'], 'L_TOPIC_DATE' => $lang['Date'], 'L_FORUM' => $lang['Forum'], 'L_VIEWS' => $lang['Views'], 'L_REPLIES' => $lang['Replies'], 'TOPIC_TITLE' => $dsp_topic_icon . ' ' . $topic_title, 'CALENDAR_EVENT' => get_calendar_title_date($topic_calendar_time, $topic_calendar_duration), 'AUTHOR' => $topic_author, 'TOPIC_DATE' => create_date($user->data['user_dateformat'], $topic_time, $config['board_timezone']), 'NAV_DESC' => $nav_desc, 'CALENDAR_MESSAGE' => $message, 'VIEWS' => $topic_views, 'REPLIES' => $topic_replies)); $template->assign_var_from_handle('_calendar_overview', $det_handler); $message = $template->_tpldata['.'][0]['_calendar_overview']; $template->_tpldata = $sav_tpl; // remove \n remaining from the template $message = preg_replace("/[\n\r]{1,2}/", '', $message); // store only the new values $new_row = array(); $new_row['event_id'] = POST_TOPIC_URL . $row['topic_id']; $new_row['event_author_id'] = $topic_author_id; $new_row['event_author'] = $topic_author; $new_row['event_author_active'] = $row['user_active']; $new_row['event_author_color'] = $row['user_color']; $new_row['event_time'] = $topic_time; $new_row['event_last_author_id'] = $topic_last_author_id; $new_row['event_last_author'] = $topic_last_author; $new_row['event_last_time'] = $topic_last_time; $new_row['event_replies'] = $topic_replies; $new_row['event_views'] = $topic_views; $new_row['event_type'] = $row['topic_type']; $new_row['event_status'] = $row['topic_status']; $new_row['event_moved_id'] = $row['topic_moved_id']; $new_row['event_last_id'] = $row['topic_last_post_id']; $new_row['event_forum_id'] = $row['forum_id']; $new_row['event_forum_name'] = $row['forum_name']; $new_row['event_icon'] = $topic_icon; $new_row['event_title'] = $topic_title; $new_row['event_short_title'] = $short_title; $new_row['event_message'] = $message; $new_row['event_calendar_time'] = $topic_calendar_time; $new_row['event_calendar_duration'] = $topic_calendar_duration; $new_row['event_link'] = $topic_link; $new_row['event_birthday'] = false; $new_row['event_txt_class'] = 'genmed'; $new_row['event_type_icon'] = '<img src="' . $images['icon_tiny_topic'] . '" style="vertical-align: bottom;" alt="" hspace="2" />'; $events[] = $new_row; } $db->sql_freeresult($result); }
public function save_comment() { $gb_id = $this->request->getParameterFromGet('gb_id'); $comment = $this->request->getParameterFromPost('value'); // Add/Modify comment Doctrine_Query::create()->update('CsComments')->set('gb_comment', $comment)->whereIn('gb_id = ?', $gb_id); // Transform RAW text to BB-formatted Text Clansuite_Loader::loadLibrary('bbcode'); $bbcode = new bbcode(); $parsed_comment = $bbcode->parse($comment); #$this->suppress_wrapper = 1; }
private function replace_www($template, $document, $args = array()) { foreach ($document->query('//www:*') as $node) { $nested = null; switch ($node->name()) { case 'www:template': $nested = $this->render_template($template->get($node['@name'])); break; case 'www:xslt': $args = $node->attribute('args'); if ($node->attribute('cache') !== 'true') { $nested = $this->render_xslt($template, $node['@xsl'], $node['@xml'], $args ? args::decode($args) : array()); } else { $cache_args = $node->attribute('cache-args') ? $node->attribute('cache-args') : array(); $cache_lifetime = $node->attribute('cache-lifetime'); is_null($cache_lifetime) or is_numeric($cache_lifetime) or runtime_error('Cache lifetime should be numeric: ' . $cache_lifetime); $cache_args = args::decode($cache_args); $filename = cache_location . md5($node['@xsl'] . $node['@xml'] . ($args ? $args : '')) . '.xml'; if (!fs::exists($filename) || $cache_lifetime && $cache_lifetime > time() - fs::modification($filename)) { fs::write($filename, $this->render_xslt($template, $node['@xsl'], $node['@xml'], $args ? args::decode($args) : array())->render(false)); } $fragment = fs::checked_read($filename); if (!empty($cache_args)) { $fragment = vars::apply_assoc($fragment, $cache_args); } $nested = $document->fragment($fragment); } break; case 'www:xquery': require_once www_root . 'thirdparty/xquerylite/class_xquery_lite.php'; $xq = new XqueryLite(); $fragment = $xq->evaluate_xqueryl(fs::checked_read($node['@src'])); $nested = $document->fragment($fragment); break; case 'www:style': $src = $node['@src']; $nested = $document->element('link'); $nested['@rel'] = 'stylesheet'; $nested['@href'] = $src . '?' . fs::crc32($src); break; case 'www:script': $src = $node['@src']; $nested = $document->element('script', ''); $nested['@type'] = 'text/javascript'; $nested['@src'] = $src . '?' . fs::crc32($src); break; case 'www:img': $src = $node['@src']; $nested = $document->element('img'); $nested['@src'] = $src . '?' . crc32(fs::modification($src)); foreach ($node->attributes() as $name => $value) { if ($name != 'src') { $nested['@' . $name] = $value; } } break; case 'www:bbcode': $allow = $node->attribute('allow'); $deny = $node->attribute('deny'); $nested = bbcode::parse($node, $allow ? preg_split('/, */', $allow) : null, $deny ? preg_split('/, */', $deny) : null); break; default: runtime_error('Unknown extension element: ' . $node->name()); } self::replace_node($document, $node, $nested); } }
$(function(){ $('body').on('click', '.qxbb-spoiler > .qxbb-spoiler-btn', function(){ $(this).next().slideToggle('fast'); return false; }); }); </script> </head> <body> <?php // Создание нового объекта-обработчика BB-кодов $bb = new bbcode(); $text = ""; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $text = @$_POST['text']; // Обработка BB-кодов echo $bb->parse($text); } ?> <form method="POST" style="text-align: center;"> <textarea name="text" cols="80" rows="16"><?php echo $text; ?> </textarea> <p><button type="submit">Чпок!</button></p> </form> </body> </html>