本文整理汇总了PHP中html2bbcode函数的典型用法代码示例。如果您正苦于以下问题:PHP html2bbcode函数的具体用法?PHP html2bbcode怎么用?PHP html2bbcode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html2bbcode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: oexchange_content
function oexchange_content(&$a)
{
if (!local_user()) {
$o = login(false);
return $o;
}
if ($a->argc > 1 && $a->argv[1] === 'done') {
info(t('Post successful.') . EOL);
return;
}
$url = x($_GET, 'url') && strlen($_GET['url']) ? urlencode(notags(trim($_GET['url']))) : '';
$title = x($_GET, 'title') && strlen($_GET['title']) ? '&title=' . urlencode(notags(trim($_GET['title']))) : '';
$description = x($_GET, 'description') && strlen($_GET['description']) ? '&description=' . urlencode(notags(trim($_GET['description']))) : '';
$tags = x($_GET, 'tags') && strlen($_GET['tags']) ? '&tags=' . urlencode(notags(trim($_GET['tags']))) : '';
$s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
if (!strlen($s)) {
return;
}
require_once 'include/html2bbcode.php';
$post = array();
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done';
$post['body'] = html2bbcode($s);
$post['type'] = 'wall';
$_POST = $post;
require_once 'mod/item.php';
item_post($a);
}
示例2: diaspora2bb
function diaspora2bb($s)
{
// for testing purposes: Collect raw markdown articles
// $file = tempnam("/tmp/friendica/", "markdown");
// file_put_contents($file, $s);
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
// Too many new lines. So deactivated the following line
// $s = str_replace("\r","\n",$s);
// Simply remove cr.
$s = str_replace("\r", "", $s);
// <br/> is invalid. Replace it with the valid expression
$s = str_replace("<br/>", "<br />", $s);
$s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
// Escaping the hash tags - doesn't always seem to work
// $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
// This seems to work
$s = preg_replace('/\\#([^\\s\\#])/', '#$1', $s);
$s = Markdown($s);
$s = str_replace('#', '#', $s);
$s = str_replace("\n", '<br />', $s);
$s = html2bbcode($s);
// $s = str_replace('*','*',$s);
// Convert everything that looks like a link to a link
$s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', $s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', $s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
// Don't show link to full picture (until it is fixed)
$s = scale_external_images($s, false);
return $s;
}
示例3: diaspora2bb
function diaspora2bb($s)
{
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
// Remove CR to avoid problems with following code
$s = str_replace("\r", "", $s);
$s = str_replace("\n", " \n", $s);
// The parser cannot handle paragraphs correctly
$s = str_replace(array("</p>", "<p>", '<p dir="ltr">'), array("<br>", "<br>", "<br>"), $s);
// Escaping the hash tags
$s = preg_replace('/\\#([^\\s\\#])/', '#$1', $s);
$s = Markdown($s);
$s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
$s = str_replace('#', '#', $s);
$s = html2bbcode($s);
// protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
$s = str_replace('♲', html_entity_decode('♲', ENT_QUOTES, 'UTF-8'), $s);
// Convert everything that looks like a link to a link
$s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', 'url', $s);
$s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', 'url', $s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
// Don't show link to full picture (until it is fixed)
$s = scale_external_images($s, false);
return $s;
}
示例4: parse_event
function parse_event($h)
{
require_once 'include/Scrape.php';
require_once 'library/HTMLPurifier.auto.php';
require_once 'include/html2bbcode';
$h = '<html><body>' . $h . '</body></html>';
$ret = array();
try {
$dom = HTML5_Parser::parse($h);
} catch (DOMException $e) {
logger('parse_event: parse error: ' . $e);
}
if (!$dom) {
return $ret;
}
$items = $dom->getElementsByTagName('*');
foreach ($items as $item) {
if (attribute_contains($item->getAttribute('class'), 'vevent')) {
$level2 = $item->getElementsByTagName('*');
foreach ($level2 as $x) {
if (attribute_contains($x->getAttribute('class'), 'dtstart') && $x->getAttribute('title')) {
$ret['start'] = $x->getAttribute('title');
if (!strpos($ret['start'], 'Z')) {
$ret['adjust'] = true;
}
}
if (attribute_contains($x->getAttribute('class'), 'dtend') && $x->getAttribute('title')) {
$ret['finish'] = $x->getAttribute('title');
}
if (attribute_contains($x->getAttribute('class'), 'description')) {
$ret['desc'] = $x->textContent;
}
if (attribute_contains($x->getAttribute('class'), 'location')) {
$ret['location'] = $x->textContent;
}
}
}
}
// sanitise
if (x($ret, 'desc') && (strpos($ret['desc'], '<') !== false || strpos($ret['desc'], '>') !== false)) {
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$ret['desc'] = html2bbcode($purifier->purify($ret['desc']));
}
if (x($ret, 'location') && (strpos($ret['location'], '<') !== false || strpos($ret['location'], '>') !== false)) {
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$ret['location'] = html2bbcode($purifier->purify($ret['location']));
}
if (x($ret, 'start')) {
$ret['start'] = datetime_convert('UTC', 'UTC', $ret['start']);
}
if (x($ret, 'finish')) {
$ret['finish'] = datetime_convert('UTC', 'UTC', $ret['finish']);
}
return $ret;
}
示例5: convert
/**
* Import the sample content
*
* @return $this
*/
public function convert()
{
$tables = array(array('name' => 'attachments', 'options' => array('name' => 'ccb_attachments'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('tbl.id', 'tbl.post_id AS post', 'tbl.real_name AS name', 'post.post_user AS joomla_user_id', 'tbl.ccb_name AS file'))->join('left', 'ccb_posts AS post', 'tbl.post_id = post.id')), array('name' => 'forums', 'options' => array('name' => 'ccb_category'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('(id + (SELECT MAX(id) FROM #__ccb_forums)) AS id', 'cat_name AS title', "'/' AS path"))), array('name' => 'forums', 'options' => array('name' => 'ccb_forums'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('id', 'forum_name AS title', 'forum_desc AS description', 'topic_count AS topics', 'post_count AS posts', 'last_post_id', 'published AS enabled', 'locked', "CONCAT('/', (cat_id + (SELECT MAX(id) FROM #__ccb_forums)), '/') AS path"))), array('name' => 'posts', 'options' => array('name' => 'ccb_posts'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('*', 'topic_id AS ninjaboard_topic_id', 'post_subject AS subject', 'post_text AS text', 'post_user AS created_by', 'FROM_UNIXTIME(post_time) AS created_on', 'ip AS user_ip', 'modified_by', 'FROM_UNIXTIME(modified_time) AS mofidied_on', 'modified_reason AS edit_reason'))), array('name' => 'topics', 'options' => array('name' => 'ccb_topics'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('*', 'reply_count AS replies', 'topic_type AS topic_type_id', 'start_post_id AS first_post_id'))), array('name' => 'people', 'options' => array('name' => 'ccb_users'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('user_id AS id', 'signature', 'post_count AS posts', 'avatar'))));
//This returns false if the import is big enough to be done in steps.
//So we need to stop the importing in this step, in order for it to initiate
if ($this->importData($tables, 'ccboard') === false) {
return $this;
}
//Convert html 2 bbcode where needed
if (isset($this->data['posts'])) {
foreach ($this->data['posts'] as $id => $post) {
if (!isset($this->data['posts'][$id]['text'])) {
continue;
}
$this->data['posts'][$id]['text'] = html2bbcode($post['text']);
}
}
//Move over file attachments
if (isset($this->data['attachments'])) {
foreach ($this->data['attachments'] as $id => $attachment) {
$from = JPATH_ROOT . '/components/com_ccboard/assets/uploads/' . $attachment['file'];
$file = JPATH_ROOT . '/media/com_ninjaboard/attachments/' . $attachment['file'];
//Don't do anything if avatar don't exist
if (!JFile::exists($from)) {
continue;
}
JFile::copy($from, $file);
}
}
//Move over avatars
if (isset($this->data['people'])) {
foreach ($this->data['people'] as $id => $person) {
if (!$person['avatar']) {
continue;
}
$from = JPATH_ROOT . '/components/com_ccboard/assets/avatar/' . $person['avatar'];
$file = basename($from);
$avatar = '/media/com_ninjaboard/images/avatars/' . $person['id'] . '/' . $file;
//Don't do anything if avatar don't exist
if (!JFile::exists($from)) {
continue;
}
JFile::copy($from, JPATH_ROOT . $avatar);
$this->data['people'][$id]['avatar'] = $avatar;
}
}
//Clear cache folder so that avatars and attachments cache are cleared
//@TODO this should only run once
$cache = JPATH_ROOT . '/cache/com_ninjaboard/';
if (JFolder::exists($cache)) {
JFolder::delete($cache);
}
parent::convert();
return $this;
}
示例6: babel_content
function babel_content(&$a)
{
$o .= '<h1>Babel Diagnostic</h1>';
$o .= '<form action="babel" method="post">';
$o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
$o .= '<form action="babel" method="post">';
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '<textarea name="d2bbtext" >' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if (x($_REQUEST, 'text')) {
$text = trim($_REQUEST['text']);
$o .= "<h2>" . t("Source input: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($text) . EOL . EOL;
$html = bbcode($text);
$o .= "<h2>" . t("bb2html (raw HTML): ") . "</h2>" . EOL . EOL;
$o .= htmlspecialchars($html) . EOL . EOL;
//$html = bbcode($text);
$o .= "<h2>" . t("bb2html: ") . "</h2>" . EOL . EOL;
$o .= $html . EOL . EOL;
$bbcode = html2bbcode($html);
$o .= "<h2>" . t("bb2html2bb: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
$diaspora = bb2diaspora($text);
$o .= "<h2>" . t("bb2md: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($diaspora) . EOL . EOL;
$html = Markdown($diaspora);
$o .= "<h2>" . t("bb2md2html: ") . "</h2>" . EOL . EOL;
$o .= $html . EOL . EOL;
$bbcode = diaspora2bb($diaspora);
$o .= "<h2>" . t("bb2dia2bb: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
$bbcode = html2bbcode($html);
$o .= "<h2>" . t("bb2md2html2bb: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($bbcode) . EOL . EOL;
}
if (x($_REQUEST, 'd2bbtext')) {
$d2bbtext = trim($_REQUEST['d2bbtext']);
$o .= "<h2>" . t("Source input (Diaspora format): ") . "</h2>" . EOL . EOL;
$o .= visible_lf($d2bbtext) . EOL . EOL;
$bb = diaspora2bb($d2bbtext);
$o .= "<h2>" . t("diaspora2bb: ") . "</h2>" . EOL . EOL;
$o .= visible_lf($bb) . EOL . EOL;
}
return $o;
}
示例7: diaspora2bb
function diaspora2bb($s)
{
$s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
$s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
$s = Markdown($s);
$s = html2bbcode($s);
// $s = str_replace('*','*',$s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', $s);
$s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', $s);
$s = preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', $s);
$s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)(vimeo|youtu|www\\.youtube|soundcloud)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url]$2$3$4[/url]', $s);
// remove duplicate adjacent code tags
$s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
$s = scale_diaspora_images($s);
return $s;
}
示例8: convert
/**
* Import the sample content
*
* @return $this
*/
public function convert()
{
$tables = array(array('name' => 'topics', 'options' => array('name' => 'yahoo_messages', 'identity_column' => 'ninjaboard_topic_id'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('tbl.post_id AS ninjaboard_topic_id', 'tbl.post_id AS first_post_id', '(SELECT last_post.post_id FROM #__yahoo_messages AS last_post WHERE last_post.topic_id = tbl.topic_id ORDER BY post_id DESC LIMIT 1) AS last_post_id', '(SELECT COUNT(*) FROM #__yahoo_messages AS count_replies WHERE count_replies.topic_id = tbl.topic_id) AS replies', '(SELECT forum.ninjaboard_forum_id FROM #__ninjaboard_forums AS forum LIMIT 1) AS forum_id'))->where('tbl.post_subject = tbl.topic_id')), array('name' => 'posts', 'options' => array('name' => 'yahoo_messages', 'identity_column' => 'ninjaboard_post_id'), 'query' => KFactory::tmp('lib.koowa.database.query')->select(array('post_id AS ninjaboard_post_id', 'post_subject AS subject', 'post_text AS text', 'post_time AS created_on', 'post_username AS guest_name', '(SELECT topic.post_id FROM #__yahoo_messages AS topic WHERE topic.post_subject = tbl.topic_id LIMIT 1) AS ninjaboard_topic_id'))));
//This returns false if the import is big enough to be done in steps.
//So we need to stop the importing in this step, in order for it to initiate
if ($this->importData($tables, 'yahoo') === false) {
return $this;
}
//Convert the html to bbcode before it's inserted to ninjaboard tables
if (isset($this->data['posts'])) {
foreach ($this->data['posts'] as $id => $post) {
$this->data['posts'][$id]['text'] = html2bbcode($post['text']);
}
}
//Clear cache folder so that avatars and attachments cache are cleared
//@TODO this should only run once
$cache = JPATH_ROOT . '/cache/com_ninjaboard/';
if (JFolder::exists($cache)) {
JFolder::delete($cache);
}
parent::convert();
return $this;
}
示例9: random
$forumbanner = $forum['banner'];
} else {
$forumbanner = $_G['setting']['attachurl'] . 'common/' . $forum['banner'] . '?' . random(6);
}
$forumbannerhtml = '<label><input type="checkbox" class="checkbox" name="deletebanner" value="yes" /> ' . $lang['delete'] . '</label><br /><img src="' . $forumbanner . '" /><br />';
}
showsetting('forums_edit_basic_banner', 'bannernew', $forum['banner'], 'filetext', '', 0, $forumbannerhtml);
}
showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');
showsetting('forums_edit_basic_shownav', 'shownavnew', array_key_exists($fid, $navs) ? 1 : 0, 'radio');
if (!$multiset) {
showsetting('forums_edit_basic_up', '', '', $fupselect);
}
showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text');
showsetting('forums_edit_basic_description', 'descriptionnew', htmlspecialchars_decode(html2bbcode($forum['description'])), 'textarea');
showsetting('forums_edit_basic_rules', 'rulesnew', htmlspecialchars_decode(html2bbcode($forum['rules'])), 'textarea');
showsetting('forums_edit_basic_keys', 'keysnew', $forumkeys[$fid], 'text');
if (!empty($_G['setting']['domain']['root']['forum'])) {
$iname = $multiset ? "multinew[{$_G[showsetting_multi]}][domainnew]" : 'domainnew';
showsetting('forums_edit_extend_domain', '', '', 'http://<input type="text" name="' . $iname . '" class="txt" value="' . $forum['domain'] . '" style="width:100px; margin-right:0px;" >.' . $_G['setting']['domain']['root']['forum']);
} elseif (!$multiset) {
showsetting('forums_edit_extend_domain', 'domainnew', '', 'text', 'disabled');
}
showtablefooter();
if (!$multiset) {
showtips('setting_seo_forum_tips', 'seo_tips', true, 'setseotips');
}
showtableheader();
showsetting('forums_edit_basic_seotitle', 'seotitlenew', dhtmlspecialchars($forum['seotitle']), 'text');
showsetting('forums_edit_basic_keyword', 'keywordsnew', dhtmlspecialchars($forum['keywords']), 'text');
showsetting('forums_edit_basic_seodescription', 'seodescriptionnew', dhtmlspecialchars($forum['seodescription']), 'textarea');
示例10: get_atom_elements
//.........这里部分代码省略.........
}
}
$apps = $item->get_item_tags(NAMESPACE_STATUSNET, 'notice_info');
if ($apps && $apps[0]['attribs']['']['source']) {
$res['app'] = strip_tags(unxmlify($apps[0]['attribs']['']['source']));
}
/*
* If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it.
*/
$have_real_body = false;
$rawenv = $item->get_item_tags(NAMESPACE_DFRN, 'env');
if ($rawenv) {
$have_real_body = true;
$res['body'] = $rawenv[0]['data'];
$res['body'] = str_replace(array(' ', "\t", "\r", "\n"), array('', '', '', ''), $res['body']);
// make sure nobody is trying to sneak some html tags by us
$res['body'] = notags(base64url_decode($res['body']));
// We could probably turn these old Friendica bbcode bookmarks into bookmark tags but we'd have to
// create a term table item for them. For now just make sure they stay as links.
$res['body'] = preg_replace('/\\[bookmark(.*?)\\](.*?)\\[\\/bookmark\\]/', '[url$1]$2[/url]', $res['body']);
}
$res['body'] = limit_body_size($res['body']);
// It isn't certain at this point whether our content is plaintext or html and we'd be foolish to trust
// the content type. Our own network only emits text normally, though it might have been converted to
// html if we used a pubsubhubbub transport. But if we see even one html tag in our text, we will
// have to assume it is all html and needs to be purified.
// It doesn't matter all that much security wise - because before this content is used anywhere, we are
// going to escape any tags we find regardless, but this lets us import a limited subset of html from
// the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining
// html.
if (strpos($res['body'], '<') !== false && strpos($res['body'], '>') !== false) {
$res['body'] = reltoabs($res['body'], $base_url);
$res['body'] = html2bb_video($res['body']);
$res['body'] = oembed_html2bbcode($res['body']);
$res['body'] = purify_html($res['body']);
$res['body'] = @html2bbcode($res['body']);
} elseif (!$have_real_body) {
// it's not one of our messages and it has no tags
// so it's probably just text. We'll escape it just to be safe.
$res['body'] = escape_tags($res['body']);
}
if ($res['plink'] && $res['title']) {
$res['body'] = '#^[url=' . $res['plink'] . ']' . $res['title'] . '[/url]' . "\n\n" . $res['body'];
$terms = array();
$terms[] = array('otype' => TERM_OBJ_POST, 'type' => TERM_BOOKMARK, 'url' => $res['plink'], 'term' => $res['title']);
} elseif ($res['plink']) {
$res['body'] = '#^[url]' . $res['plink'] . '[/url]' . "\n\n" . $res['body'];
$terms = array();
$terms[] = array('otype' => TERM_OBJ_POST, 'type' => TERM_BOOKMARK, 'url' => $res['plink'], 'term' => $res['plink']);
}
$private = $item->get_item_tags(NAMESPACE_DFRN, 'private');
if ($private && intval($private[0]['data']) > 0) {
$res['item_private'] = intval($private[0]['data']) ? 1 : 0;
} else {
$res['item_private'] = 0;
}
$rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location');
if ($rawlocation) {
$res['location'] = unxmlify($rawlocation[0]['data']);
}
$rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published');
if ($rawcreated) {
$res['created'] = unxmlify($rawcreated[0]['data']);
}
$rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated');
if ($rawedited) {
示例11: formhash
} else {
$threads = C::t('forum_thread')->count_by_fid($fid);
$formhash = formhash();
cpmsg('grouptype_delete_alarm', "action=group&operation=deletetype&fid={$fid}&confirmed=1&formhash={$formhash}", 'loadingform', array(), '<div id="percent">0%</div>', FALSE);
echo "\r\n\t\t\t<div id=\"statusid\" style=\"display:none\"></div>\r\n\t\t\t<script type=\"text/JavaScript\">\r\n\t\t\t\tvar xml_http_building_link = '" . cplang('xml_http_building_link') . "';\r\n\t\t\t\tvar xml_http_sending = '" . cplang('xml_http_sending') . "';\r\n\t\t\t\tvar xml_http_loading = '" . cplang('xml_http_loading') . "';\r\n\t\t\t\tvar xml_http_load_failed = '" . cplang('xml_http_load_failed') . "';\r\n\t\t\t\tvar xml_http_data_in_processed = '" . cplang('xml_http_data_in_processed') . "';\r\n\t\t\t\tvar adminfilename = '" . ADMINSCRIPT . "';\r\n\t\t\t\tfunction forumsdelete(url, total, pp, currow) {\r\n\r\n\t\t\t\t\tvar x = new Ajax('HTML', 'statusid');\r\n\t\t\t\t\tx.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {\r\n\t\t\t\t\t\tif(s != 'GO') {\r\n\t\t\t\t\t\t\tlocation.href = adminfilename + '?action=group&operation=deletetype&finished=1';\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tcurrow += pp;\r\n\t\t\t\t\t\tvar percent = ((currow / total) * 100).toFixed(0);\r\n\t\t\t\t\t\tpercent = percent > 100 ? 100 : percent;\r\n\t\t\t\t\t\tdocument.getElementById('percent').innerHTML = percent+'%';\r\n\t\t\t\t\t\tdocument.getElementById('percent').style.backgroundPosition = '-'+percent+'%';\r\n\r\n\t\t\t\t\t\tif(currow < total) {\r\n\t\t\t\t\t\t\tforumsdelete(url, total, pp, currow);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tforumsdelete(adminfilename + '?action=group&operation=deletetype&fid={$fid}&confirmed=1&formhash={$formhash}', {$threads}, 2000, 0);\r\n\t\t\t</script>\r\n\t\t\t";
}
}
} elseif ($operation == 'editgroup') {
require_once libfile('function/group');
$fid = intval($_GET['fid']);
if (empty($fid)) {
cpmsg('group_nonexist', 'action=group&operation=manage', 'error');
}
$group = C::t('forum_forum')->fetch_info_by_fid($fid);
require_once libfile('function/editor');
$group['description'] = html2bbcode($group['description']);
if (!$group || $group['status'] != 3 || $group['type'] != 'sub') {
cpmsg('group_nonexist', '', 'error');
}
require_once libfile('function/group');
require_once libfile('function/discuzcode');
$groupicon = get_groupimg($group['icon'], 'icon');
$groupbanner = get_groupimg($group['banner']);
$jointypeselect = array(array('-1', cplang('closed')), array('0', cplang('public')), array('1', cplang('invite')), array('2', cplang('moderate')));
if (!submitcheck('editsubmit')) {
$groupselect = get_groupselect(0, $group['fup'], 0);
shownav('group', 'nav_group_manage');
showsubmenu('nav_group_manage');
showformheader("group&operation=editgroup&fid={$fid}", 'enctype');
showtableheader();
showsetting('groups_editgroup_name', 'namenew', $group['name'], 'text');
示例12: get_atom_elements
function get_atom_elements($item)
{
require_once 'library/HTMLPurifier.auto.php';
require_once 'include/html2bbcode.php';
$res = array();
$raw_author = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author');
if ($raw_author) {
if ($raw_author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] == 'photo') {
$res['author-avatar'] = unxmlify($raw_author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href']);
}
}
$author = $item->get_author();
$res['author-name'] = unxmlify($author->get_name());
$res['author-link'] = unxmlify($author->get_link());
if (!$res['author-avatar']) {
$res['author-avatar'] = unxmlify($author->get_avatar());
}
$res['uri'] = unxmlify($item->get_id());
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$maxlen = get_max_import_size();
if ($maxlen && strlen($res['body']) > $maxlen) {
$res['body'] = substr($res['body'], 0, $maxlen);
}
// It isn't certain at this point whether our content is plaintext or html and we'd be foolish to trust
// the content type. Our own network only emits text normally, though it might have been converted to
// html if we used a pubsubhubbub transport. But if we see even one html open tag in our text, we will
// have to assume it is all html and needs to be purified.
// It doesn't matter all that much security wise - because before this content is used anywhere, we are
// going to escape any tags we find regardless, but this lets us import a limited subset of html from
// the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining
// html.
if (strpos($res['body'], '<')) {
$res['body'] = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\\-_=]+).+?</object>#s', '[youtube]$1[/youtube]', $res['body']);
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.DefinitionCache', null);
// we shouldn't need a whitelist, because the bbcode converter
// will strip out any unsupported tags.
// $config->set('HTML.Allowed', 'p,b,a[href],i');
$purifier = new HTMLPurifier($config);
$res['body'] = $purifier->purify($res['body']);
}
$res['body'] = html2bbcode($res['body']);
$allow = $item->get_item_tags(NAMESPACE_DFRN, 'comment-allow');
if ($allow && $allow[0]['data'] == 1) {
$res['last-child'] = 1;
} else {
$res['last-child'] = 0;
}
$rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published');
if ($rawcreated) {
$res['created'] = unxmlify($rawcreated[0]['data']);
}
$rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location');
if ($rawlocation) {
$res['location'] = unxmlify($rawlocation[0]['data']);
}
$rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated');
if ($rawedited) {
$res['edited'] = unxmlify($rawcreated[0]['data']);
}
$rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner');
if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) {
$res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']);
} elseif ($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']) {
$res['owner-name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']);
}
if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']) {
$res['owner-link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']);
} elseif ($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']) {
$res['owner-link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']);
}
if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] == 'photo') {
$res['owner-avatar'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href']);
} elseif ($rawowner[0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']) {
$res['owner-avatar'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']);
}
$rawverb = $item->get_item_tags(NAMESPACE_ACTIVITY, 'verb');
// select between supported verbs
if ($rawverb) {
$res['verb'] = unxmlify($rawverb[0]['data']);
}
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object');
if ($rawobj) {
$res['object-type'] = $rawobj[0]['object-type'][0]['data'];
$res['object'] = $rawobj[0];
}
return $res;
}
示例13: api_statuses_update
function api_statuses_update(&$a, $type)
{
if (api_user() === false) {
logger('api_statuses_update: no user');
return false;
}
$user_info = api_get_user($a);
// convert $_POST array items to the form we use for web posts.
// logger('api_post: ' . print_r($_POST,true));
if (requestdata('htmlstatus')) {
$txt = requestdata('htmlstatus');
if (strpos($txt, '<') !== false || strpos($txt, '>') !== false) {
require_once 'library/HTMLPurifier.auto.php';
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$txt = $purifier->purify($txt);
$_REQUEST['body'] = html2bbcode($txt);
}
} else {
$_REQUEST['body'] = requestdata('status');
}
$_REQUEST['title'] = requestdata('title');
$parent = requestdata('in_reply_to_status_id');
// Twidere sends "-1" if it is no reply ...
if ($parent == -1) {
$parent = "";
}
if (ctype_digit($parent)) {
$_REQUEST['parent'] = $parent;
} else {
$_REQUEST['parent_uri'] = $parent;
}
if (requestdata('lat') && requestdata('long')) {
$_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long'));
}
$_REQUEST['profile_uid'] = api_user();
if ($parent) {
$_REQUEST['type'] = 'net-comment';
} else {
// Check for throttling (maximum posts per day, week and month)
$throttle_day = get_config('system', 'throttle_limit_day');
if ($throttle_day > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24 * 60 * 60);
$r = q("SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall`\n\t\t\t\t\tAND `created` > '%s' AND `id` = `parent`", intval(api_user()), dbesc($datefrom));
if ($r) {
$posts_day = $r[0]["posts_day"];
} else {
$posts_day = 0;
}
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user ' . api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)));
}
}
$throttle_week = get_config('system', 'throttle_limit_week');
if ($throttle_week > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24 * 60 * 60 * 7);
$r = q("SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall`\n\t\t\t\t\tAND `created` > '%s' AND `id` = `parent`", intval(api_user()), dbesc($datefrom));
if ($r) {
$posts_week = $r[0]["posts_week"];
} else {
$posts_week = 0;
}
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user ' . api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)));
}
}
$throttle_month = get_config('system', 'throttle_limit_month');
if ($throttle_month > 0) {
$datefrom = date("Y-m-d H:i:s", time() - 24 * 60 * 60 * 30);
$r = q("SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall`\n\t\t\t\t\tAND `created` > '%s' AND `id` = `parent`", intval(api_user()), dbesc($datefrom));
if ($r) {
$posts_month = $r[0]["posts_month"];
} else {
$posts_month = 0;
}
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user ' . api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)));
}
}
$_REQUEST['type'] = 'wall';
}
if (x($_FILES, 'media')) {
// upload the image if we have one
$_REQUEST['hush'] = 'yeah';
//tell wall_upload function to return img info instead of echo
$media = wall_upload_post($a);
if (strlen($media) > 0) {
$_REQUEST['body'] .= "\n\n" . $media;
}
}
// To-Do: Multiple IDs
if (requestdata('media_ids')) {
$r = q("SELECT `resource-id`, `scale`, `nickname`, `type` FROM `photo` INNER JOIN `user` ON `user`.`uid` = `photo`.`uid` WHERE `resource-id` IN (SELECT `resource-id` FROM `photo` WHERE `id` = %d) AND `scale` > 0 AND `photo`.`uid` = %d ORDER BY `photo`.`width` DESC LIMIT 1", intval(requestdata('media_ids')), api_user());
if ($r) {
$phototypes = Photo::supportedTypes();
//.........这里部分代码省略.........
示例14: pkpost
//.........这里部分代码省略.........
$setsqlarr['grade'] = 0;
}
if (pkperm('isadmin')) {
//站長可以post任何數據
updatetable($modelsinfoarr['modelname'] . 'items', $setsqlarr, array('itemid' => $itemid));
//權限限制
} else {
// 店長不允許更改店舖組
unset($setsqlarr['groupid']);
if ($modelsinfoarr['modelname'] == 'shop') {
unset($setsqlarr['validity_start']);
unset($setsqlarr['validity_end']);
if ($itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) {
$updatesqlarr = $setsqlarr;
} else {
//店長提交店舖權限檢查
updatetable($modelsinfoarr['modelname'] . 'items', $setsqlarr, array('itemid' => $_G['myshopid']));
}
} else {
if ($itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) {
$updatesqlarr = $setsqlarr;
} else {
//店長只能更改管理的店舖的信息
updatetable($modelsinfoarr['modelname'] . 'items', $setsqlarr, array('itemid' => $itemid, 'shopid' => $_G['myshopid']));
}
}
}
$query = DB::query('SELECT * FROM ' . tname($modelsinfoarr['modelname'] . 'message') . ' WHERE itemid = \'' . $itemid . '\'');
$defaultmessage = DB::fetch($query);
}
$hash = getmodelhash($modelsinfoarr['mid'], $itemid);
if (!empty($ids)) {
$ids = simplode($ids);
DB::query('UPDATE ' . tname('attachments') . ' SET hash=\'' . $hash . '\' WHERE aid IN (' . $ids . ')');
}
$do = 'pass';
if ($op == 'update' && !$_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) {
if (!empty($resultmessage)) {
foreach ($resultmessage as $value) {
if (preg_match("/^(img|flash|file)\$/i", $value['formtype']) && !empty($defaultmessage[$value['fieldname']])) {
if (empty($_POST[$value['fieldname'] . '_value']) || !empty($_FILES[$value['fieldname']]['name'])) {
//當file刪除時,或修改時執行刪除操作
deletetable('attachments', array('hash' => $hash, 'subject' => $value['fieldname']));
//刪除附件表
updatetable($modelsinfoarr['modelname'] . 'message', array($value['fieldname'] => ''), array('itemid' => $itemid));
@unlink(A_DIR . '/' . substr($defaultmessage[$value['fieldname']], 0, strrpos($defaultmessage[$value['fieldname']], '.')) . '.thumb.jpg');
@unlink(A_DIR . '/' . $defaultmessage[$value['fieldname']] . '.thumb.jpg');
@unlink(A_DIR . '/' . $defaultmessage[$value['fieldname']]);
}
}
}
}
}
//內容
$setsqlarr = $uploadfilearr = $ids = array();
$setsqlarr = getsetsqlarr($resultmessage);
$uploadfilearr = $feedcolum = uploadfile($resultmessage, $modelsinfoarr['modelname'], $itemid, 0);
$setsqlarr['message'] = trim($_POST['message']);
$setsqlarr['message'] = saddslashes(html2bbcode(stripslashes($setsqlarr['message'])));
if ($modelsinfoarr['modelname'] == 'consume') {
$setsqlarr['exception'] = trim($_POST['exception']);
}
if ($_POST['imagetype'] == 0 && $modelsinfoarr['modelname'] == 'consume' && $_G['setting']['allowcreateimg']) {
$setsqlarr['address'] = trim($_POST['address']);
$setsqlarr['hotline'] = trim($_POST['hotline']);
}
$setsqlarr['postip'] = $_G['clientip'];
if ($modelsinfoarr['modelname'] == 'shop' && $itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) {
$setsqlarr['banner'] = $_POST['banner_value'];
$setsqlarr['windowsimg'] = $_POST['windowsimg_value'];
}
if (!empty($uploadfilearr)) {
foreach ($uploadfilearr as $tmpkey => $tmpvalue) {
if (empty($tmpvalue['error'])) {
$setsqlarr[$tmpkey] = $tmpvalue['filepath'];
}
if (!empty($tmpvalue['aid'])) {
$ids[] = $tmpvalue['aid'];
}
}
}
//添加內容
if (!empty($modelsinfoarr['allowfilter'])) {
$setsqlarr = scensor($setsqlarr, 1);
}
if ($op == 'add') {
$setsqlarr['itemid'] = $itemid;
//添加內容
inserttable($modelsinfoarr['modelname'] . 'message', $setsqlarr);
} else {
if ($itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']] && !pkperm('isadmin')) {
$_SGLOBAL['updatesqlarr'] = array_merge($updatesqlarr, $setsqlarr);
} else {
//更新內容
updatetable($modelsinfoarr['modelname'] . 'message', $setsqlarr, array('nid' => $_POST['nid'], 'itemid' => $itemid));
}
}
updatetable('attachments', array('isavailable' => '1', 'type' => 'model'), array('hash' => $hash));
return $itemid;
}
示例15: api_statuses_update
function api_statuses_update(&$a, $type)
{
if (api_user() === false) {
logger('api_statuses_update: no user');
return false;
}
logger('api_statuses_update: REQUEST ' . print_r($_REQUEST, true));
logger('api_statuses_update: FILES ' . print_r($_FILES, true));
// set this so that the item_post() function is quiet and doesn't redirect or emit json
$_REQUEST['api_source'] = true;
$user_info = api_get_user($a);
// convert $_POST array items to the form we use for web posts.
// logger('api_post: ' . print_r($_POST,true));
if (requestdata('htmlstatus')) {
require_once 'library/HTMLPurifier.auto.php';
require_once 'include/html2bbcode.php';
$txt = requestdata('htmlstatus');
if (strpos($txt, '<') !== false || strpos($txt, '>') !== false) {
$txt = html2bb_video($txt);
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$purifier = new HTMLPurifier($config);
$txt = $purifier->purify($txt);
}
$_REQUEST['body'] = html2bbcode($txt);
} else {
$_REQUEST['body'] = requestdata('status');
}
$parent = requestdata('in_reply_to_status_id');
if (ctype_digit($parent)) {
$_REQUEST['parent'] = $parent;
} else {
$_REQUEST['parent_mid'] = $parent;
}
if ($_REQUEST['namespace'] && $parent) {
$x = q("select iid from item_id where service = '%s' and sid = '%s' limit 1", dbesc($_REQUEST['namespace']), dbesc($parent));
if ($x) {
$_REQUEST['parent'] = $x[0]['iid'];
}
}
if (requestdata('lat') && requestdata('long')) {
$_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long'));
}
$_REQUEST['profile_uid'] = api_user();
if ($parent) {
$_REQUEST['type'] = 'net-comment';
} else {
$_REQUEST['type'] = 'wall';
if (x($_FILES, 'media')) {
$_FILES['userfile'] = $_FILES['media'];
// upload the image if we have one
$_REQUEST['silent'] = '1';
//tell wall_upload function to return img info instead of echo
require_once 'mod/wall_attach.php';
$media = wall_attach_post($a);
if (strlen($media) > 0) {
$_REQUEST['body'] .= "\n\n" . $media;
}
}
}
// call out normal post function
require_once 'mod/item.php';
item_post($a);
// this should output the last post (the one we just posted).
return api_status_show($a, $type);
}