public function post_create() { $posts = Input::all(); $title = $posts['thread_name']; $contentRaw = $posts['inputarea']; if ($title != '' && strlen($contentRaw) > 10) { $alias = Str::slug($title, '-'); $exist = Thread::where('alias', '=', $alias)->first(); if ($exist != null) { return Redirect::to($exist->id); } $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s")); $thread = Thread::create($threadData); if ($thread != null) { $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id); $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0); $pst = Post::create($postData); if ($pst != null) { return Redirect::to($thread->id); } } } else { return Redirect::to(URL::full()); } }
public function transform($text) { return BBCode2Html($text); }
/** * Подробная информация и статистика опроса, комментарии пользователей * * @param string $tpl_dir путь к папке с шаблонами модуля * @param string $lang_file путь к языковому файлу модуля * @param int $pid идентификатор опроса */ function pollResultShow($tpl_dir, $lang_file, $pid) { global $AVE_DB, $AVE_Template; $AVE_Template->config_load($lang_file, 'showresult'); if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'new') { $errors = $this->pollCommentNew($pid); if (sizeof($errors) == 0) { header('Location:' . $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid)); exit; } $AVE_Template->assign('errors', $errors); } $poll = $AVE_DB->Query("\r\n\t\t\tSELECT\r\n\t\t\t\tpoll.*,\r\n\t\t\t\tSUM(itm.poll_item_hits) AS votes\r\n\t\t\tFROM\r\n\t\t\t\t" . PREFIX . "_modul_poll AS poll\r\n\t\t\tLEFT JOIN\r\n\t\t\t\t" . PREFIX . "_modul_poll_items AS itm\r\n\t\t\t\t\tON poll_id = poll.id\r\n\t\t\tWHERE\r\n\t\t\t\tpoll.id = '" . $pid . "' AND\r\n\t\t\t\tpoll.poll_title != '' AND\r\n\t\t\t\tpoll.poll_status = '1' AND\r\n\t\t\t\tpoll.poll_start < '" . time() . "'\r\n\t\t\tGROUP BY poll.id\r\n\t\t")->FetchRow(); if ($poll === false) { return; } $items = array(); $sql = $AVE_DB->Query("\r\n\t\t\tSELECT\r\n\t\t\t\t*,\r\n\t\t\t\t" . ($poll->votes > 0 ? 'ROUND(poll_item_hits*100/' . $poll->votes . ')' : 0) . " AS sum\r\n\t\t\tFROM " . PREFIX . "_modul_poll_items\r\n\t\t\tWHERE poll_id = '" . $pid . "'\r\n\t\t\tORDER BY poll_item_position ASC\r\n\t\t"); while ($row_items = $sql->FetchRow()) { array_push($items, $row_items); } if ($poll->poll_can_comment == 1) { include_once BASE_DIR . '/lib/markitup/sets/bbcode/markitup.bbcode-parser.php'; $comments = array(); $sql = $AVE_DB->Query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tcmnt.*,\r\n\t\t\t\t\tIFNULL(firstname, '') AS firstname,\r\n\t\t\t\t\tIFNULL(lastname, '" . $AVE_Template->get_config_vars('POLL_GUEST') . "') AS lastname\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . PREFIX . "_modul_poll_comments AS cmnt\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t" . PREFIX . "_users AS usr\r\n\t\t\t\t\t\tON usr.Id = cmnt.poll_comment_author_id\r\n\t\t\t\tWHERE poll_id = '" . $pid . "'\r\n\t\t\t\tORDER BY poll_comment_time DESC\r\n\t\t\t"); while ($row_comments = $sql->FetchRow()) { $row_comments->poll_comment_text = BBCode2Html($row_comments->poll_comment_text); array_push($comments, $row_comments); } $poll->count_comments = $sql->NumRows(); } $poll_users_id = empty($poll->poll_users_id) ? array() : explode(',', $poll->poll_users_id); $poll_users_ip = empty($poll->poll_users_ip) ? array() : explode(',', $poll->poll_users_ip); $current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']; $is_vote = 1; if (@in_array($current_user_ip, $poll_users_ip) || @in_array($_SESSION['user_id'], $poll_users_id) || isset($_COOKIE['poll_' . $pid]) && $_COOKIE['poll_' . $pid] == '1') { $is_vote = 0; } $rights = 0; $groups = array(); if ($poll->poll_groups_id != '') { $sql = $AVE_DB->Query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tuser_group,\r\n\t\t\t\t\tuser_group_name\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . PREFIX . "_user_groups\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tuser_group IN(" . $poll->poll_groups_id . ")\r\n\t\t\t"); while ($row_g = $sql->FetchRow()) { if (UGROUP == $row_g->user_group) { $rights = 1; } array_push($groups, $row_g->user_group_name); } } $poll->can_vote = $is_vote == 1 && $rights == 1 ? 1 : 0; $poll->groups = implode(', ', $groups); $poll->can_comment = $poll->poll_status == 1 && $poll->poll_can_comment == 1 && $rights == 1 ? 1 : 0; $poll->anti_spam = $this->_antispam == 1 && function_exists('imagettftext') && function_exists('imagejpeg') ? 1 : 0; $poll->comment_max_chars = $this->_commentwords; $poll->items = $items; $poll->comments = $comments; $poll->formaction = 'index.php?module=poll&action=vote&pid=' . $pid; $poll->link_result = $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid); // $poll->link_archive = $this->_pollLinkRewrite('index.php?module=poll&action=archive'); // $poll->link_comment = $this->_pollLinkRewrite('index.php?module=poll&action=form&pop=1&pid=' . $pid); $AVE_Template->assign('poll', $poll); define('MODULE_SITE', $AVE_Template->get_config_vars('POLL_PAGE_TITLE_PREFIX') . $poll->poll_title); define('MODULE_CONTENT', $AVE_Template->fetch($tpl_dir . 'result.tpl')); }
/** * Processes BBCode content if the <code>bbcode</code> value is set, else returns <code>content</code> * * @param string $content html or bbcode content * @param boolean $bbcode flag indicating the content type is bbocde or not * @param boolean $process_content_plugins flag to enable processing of Joomla(r) content plugins */ public static function process_html($content, $bbcode = false, $process_content_plugins = false, $autolink = true) { if ($bbcode) { if (!function_exists('BBCode2Html')) { require_once CJLIB_PATH . DS . 'lib' . DS . 'markitup' . DS . 'bbcodeparser.php'; } $content = BBCode2Html($content); } if ($autolink) { require_once 'lib_autolink.php'; $content = autolink_urls($content, 50, ' rel="nofollow"'); } if ($process_content_plugins) { $content = JHTML::_('content.prepare', $content); } return $content; }
'<span style="color:\1">\2</span>', '<blockquote>\1</blockquote>', '<ol start="\1">\2</ol>', '<ul>\1</ul>', '<li>\1</li>' ); $text = preg_replace($in, $out, $text); // paragraphs $text = str_replace("\r", "", $text); $text = "<p>".preg_replace("/(\n){2,}/", "</p><p>", $text)."</p>"; $text = nl2br($text); // clean some tags to remain strict // not very elegant, but it works. No time to do better ;) if (!function_exists('removeBr')) { function removeBr($s) { return str_replace("<br />", "", $s[0]); } } $text = preg_replace_callback('/<pre>(.*?)<\/pre>/ms', "removeBr", $text); $text = preg_replace('/<p><pre>(.*?)<\/pre><\/p>/ms', "<pre>\\1</pre>", $text); $text = preg_replace_callback('/<ul>(.*?)<\/ul>/ms', "removeBr", $text); $text = preg_replace('/<p><ul>(.*?)<\/ul><\/p>/ms', "<ul>\\1</ul>", $text); return $text; } echo BBCode2Html( $_POST['data'] );
/** * Еще одна обрабтка bbCode * * @param string $text * @return string */ function _guestbookBbcodeParse($text) { global $AVE_Template; require_once BASE_DIR . '/modules/guestbook/markitup/sets/bbcode/markitup.bbcode-parser.php'; return BBCode2Html($text); }
function BBCode_Print($target, $mother) { return BBCode2Html($target); }
<?php if (!empty($_POST['data']) && (require 'markitup.bbcode-parser.php')) { $data = get_magic_quotes_gpc() ? stripslashes($_POST['data']) : $_POST['data']; $data = iconv('utf-8', 'cp1251', $data); $data = BBCode2Html($data); echo $data; }
public function post_postpreview() { return BBCode2Html(Input::get('data')); }