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); }
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; }
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; }
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; }
/** * 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; }
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; }
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; }
/** * 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; }
$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');
/** * @param object $feed * @param array $item * @param[out] array $author * @return multitype:multitype: string NULL number Ambigous <NULL, string, number> Ambigous <mixed, string> Ambigous <multitype:multitype:string Ambigous <NULL, string> , multitype:multitype:string unknown > multitype:NULL unknown */ function get_atom_elements($feed, $item, &$author) { //$best_photo = array(); $res = array(); $found_author = $item->get_author(); if ($found_author) { $author['author_name'] = unxmlify($found_author->get_name()); $author['author_link'] = unxmlify($found_author->get_link()); $author['author_is_feed'] = false; } else { $author['author_name'] = unxmlify($feed->get_title()); $author['author_link'] = unxmlify($feed->get_permalink()); $author['author_is_feed'] = true; } if (substr($author['author_link'], -1, 1) == '/') { $author['author_link'] = substr($author['author_link'], 0, -1); } $res['mid'] = base64url_encode(unxmlify($item->get_id())); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); $res['plink'] = unxmlify($item->get_link(0)); $res['item_flags'] = ITEM_RSS; // removing the content of the title if its identically to the body // This helps with auto generated titles e.g. from tumblr if (title_is_body($res["title"], $res["body"])) { $res['title'] = ""; } if ($res['plink']) { $base_url = implode('/', array_slice(explode('/', $res['plink']), 0, 3)); } else { $base_url = ''; } // look for a photo. We should check media size and find the best one, // but for now let's just find any author photo $rawauthor = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if (!x($author, 'author_photo') || !$author['author_photo']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $author['author_photo'] = unxmlify($link['attribs']['']['href']); } } } } $rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor'); if ($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if ($base && count($base)) { foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$res['author_link']) { $author['author_link'] = unxmlify($link['attribs']['']['href']); } if (!x($author, 'author_photo') || !$author['author_photo']) { if ($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') { $author['author_photo'] = unxmlify($link['attribs']['']['href']); } } } } } // check for a yahoo media element (github etc.) if (!$author['author_photo']) { $rawmedia = $item->get_item_tags(NAMESPACE_YMEDIA, 'thumbnail'); if ($rawmedia && $rawmedia[0]['attribs']['']['url']) { $author['author_photo'] = strip_tags(unxmlify($rawmedia[0]['attribs']['']['url'])); } } // No photo/profile-link on the item - look at the feed level if (!x($author, 'author_link') || !x($author, 'author_photo')) { $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$author['author_link']) { $author['author_link'] = unxmlify($link['attribs']['']['href']); $author['author_is_feed'] = true; } if (!$author['author_photo']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $author['author_photo'] = unxmlify($link['attribs']['']['href']); } } } } $rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject'); if ($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['obj_type'][0]['data'], ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if ($base && count($base)) { foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$res['author_link']) { $author['author_link'] = unxmlify($link['attribs']['']['href']); } if (!x($author, 'author_photo')) { if ($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') { $author['author_photo'] = unxmlify($link['attribs']['']['href']); } } } } } } $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) { $res['edited'] = unxmlify($rawedited[0]['data']); } if (x($res, 'edited') && !x($res, 'created')) { $res['created'] = $res['edited']; } if (!$res['created']) { $res['created'] = $item->get_date('c'); } if (!$res['edited']) { $res['edited'] = $item->get_date('c'); } // Disallow time travelling posts $d1 = strtotime($res['created']); $d2 = strtotime($res['edited']); $d3 = strtotime('now'); if ($d1 > $d3) { $res['created'] = datetime_convert(); } if ($d2 > $d3) { $res['edited'] = datetime_convert(); } $res['created'] = datetime_convert('UTC', 'UTC', $res['created']); $res['edited'] = datetime_convert('UTC', 'UTC', $res['edited']); $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if (!$rawowner) { $rawowner = $item->get_item_tags(NAMESPACE_ZOT, 'owner'); } if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) { $author['owner_name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); } elseif ($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']) { $author['owner_name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']); } if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']) { $author['owner_link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']); } elseif ($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']) { $author['owner_link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']); } if ($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if (!x($author, 'owner_photo') || !$author['owner_photo']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $author['owner_photo'] = unxmlify($link['attribs']['']['href']); } } } } $rawgeo = $item->get_item_tags(NAMESPACE_GEORSS, 'point'); if ($rawgeo) { $res['coord'] = unxmlify($rawgeo[0]['data']); } $rawverb = $item->get_item_tags(NAMESPACE_ACTIVITY, 'verb'); // select between supported verbs if ($rawverb) { $res['verb'] = unxmlify($rawverb[0]['data']); } // translate OStatus unfollow to activity streams if it happened to get selected if (x($res, 'verb') && $res['verb'] === 'http://ostatus.org/schema/1.0/unfollow') { $res['verb'] = ACTIVITY_UNFOLLOW; } $cats = $item->get_categories(); if ($cats) { if (is_null($terms)) { $terms = array(); } foreach ($cats as $cat) { $term = $cat->get_term(); if (!$term) { $term = $cat->get_label(); } $scheme = $cat->get_scheme(); $termurl = ''; if ($scheme && $term && stristr($scheme, 'X-DFRN:')) { $termtype = substr($scheme, 7, 1) === '#' ? TERM_HASHTAG : TERM_MENTION; $termurl = unxmlify(substr($scheme, 9)); } else { $termtype = TERM_CATEGORY; } $termterm = notags(trim(unxmlify($term))); if ($termterm) { $terms[] = array('otype' => TERM_OBJ_POST, 'type' => $termtype, 'url' => $termurl, 'term' => $termterm); } } } if (!is_null($terms)) { $res['term'] = $terms; } $attach = $item->get_enclosures(); if ($attach) { $res['attach'] = array(); foreach ($attach as $att) { $len = intval($att->get_length()); $link = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_link())))); $title = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_title())))); $type = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_type())))); if (strpos($type, ';')) { $type = substr($type, 0, strpos($type, ';')); } if (!$link || strpos($link, 'http') !== 0) { continue; } if (!$title) { $title = ' '; } if (!$type) { $type = 'application/octet-stream'; } $res['attach'][] = array('href' => $link, 'length' => $len, 'type' => $type, 'title' => $title); } } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); if ($rawobj) { $obj = array(); $child = $rawobj[0]['child']; if ($child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']) { $res['obj_type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; $obj['type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) { $obj['id'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $obj['link'] = encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']); } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) { $obj['title'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if (!$body) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; } // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events $obj['orig'] = xmlify($body); if (strpos($body, '<') !== false || strpos($body, '>') !== false) { $body = purify_html($body); $body = html2bbcode($body); } $obj['content'] = $body; } $res['object'] = $obj; } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target'); if ($rawobj) { $obj = array(); $child = $rawobj[0]['child']; if ($child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']) { $res['tgt_type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; $obj['type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) { $obj['id'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $obj['link'] = encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']); } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) { $obj['title'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if (!$body) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; } // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events $obj['orig'] = xmlify($body); if (strpos($body, '<') !== false || strpos($body, '>') !== false) { $body = purify_html($body); $body = html2bbcode($body); } $obj['content'] = $body; } $res['target'] = $obj; } $res['public_policy'] = 'specific'; $res['comment_policy'] = 'none'; $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); logger('get_atom_elements: author: ' . print_r($author, true), LOGGER_DATA); logger('get_atom_elements: ' . print_r($res, true), LOGGER_DATA); return $res; }
} 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');
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; }
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(); $ext = $phototypes[$r[0]['type']]; $_REQUEST['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $r[0]['nickname'] . '/image/' . $r[0]['resource-id'] . ']'; $_REQUEST['body'] .= '[img]' . $a->get_baseurl() . "/photo/" . $r[0]['resource-id'] . "-" . $r[0]['scale'] . "." . $ext . "[/img][/url]"; } } // set this so that the item_post() function is quiet and doesn't redirect or emit json $_REQUEST['api_source'] = true; if (!x($_REQUEST, "source")) { $_REQUEST["source"] = api_source(); } // call out normal post function item_post($a); // this should output the last post (the one we just posted). return api_status_show($a, $type); }
function pkpost($cacheinfo, $cp = 1) { global $_G, $_SGLOBAL, $theurl, $mname, $checkresults; $itemid = !empty($_POST['itemid']) ? intval($_POST['itemid']) : 0; $hash = ''; $op = 'add'; $mustverify = false; $resultitems = $resultmessage = $updateitem = array(); $modelsinfoarr = $cacheinfo['models']; $columnsinfoarr = $cacheinfo['columns']; $feedcolum = array(); foreach ($columnsinfoarr as $result) { if ($mname == "groupbuy" && preg_match('/^user_|^ext_/', $result['fieldname'])) { continue; } if ($result['isfixed'] == 1) { $resultitems[] = $result; } else { $resultmessage[] = $result; } if ($result['formtype'] == 'linkage') { if (!empty($_POST[$result['fieldname']])) { $_POST[$result['fieldname']] = $cacheinfo['linkage']['info'][$result['fieldname']][$_POST[$result['fieldname']]]; } } elseif ($result['formtype'] == 'timestamp') { if (empty($_POST[$result['fieldname']])) { $_POST[$result['fieldname']] = $_G['timestamp']; } else { $_POST[$result['fieldname']] = sstrtotime($_POST[$result['fieldname']]); } } } //輸入檢查 $_POST['subject'] = trim(strip_tags($_POST['subject'])); $itemid = $_POST['itemid']; $checkresults = array(); if (bstrlen($_POST['subject']) < 1 || bstrlen($_POST['subject']) > 80) { array_push($checkresults, array('subject' => lang('space_suject_length_error'))); } //數據檢查 checkvalues(array_merge($resultitems, $resultmessage), 1, 1); //商品價格處理 Start if ($modelsinfoarr['modelname'] == 'good') { if ($_POST['minprice'] > 0 && $_POST['maxprice'] > 0 && $_POST['maxprice'] < $_POST['minprice']) { array_push($checkresults, array('maxprice' => lang('maxprice_must_big_then_minprice'))); } } //商品價格處理 End //修改時檢驗標題圖片是否修改 $defaultmessage = array(); if (!empty($itemid)) { if (empty($_POST['subjectimage_value']) || !empty($_FILES['subjectimage']['name'])) { //當file刪除時,或修改時執行刪除操作 $query = DB::query('SELECT * FROM ' . tname($modelsinfoarr['modelname'] . 'items') . ' WHERE itemid = \'' . $itemid . '\''); $defaultmessage = DB::fetch($query); $hash = getmodelhash($modelsinfoarr['mid'], $itemid); deletetable('attachments', array('hash' => $hash, 'subject' => 'subjectimage')); //刪除附件表 updatetable($modelsinfoarr['modelname'] . 'items', array('subjectimage' => ''), array('itemid' => $itemid)); $ext = fileext($defaultmessage['subjectimage']); if (in_array($ext, array('jpg', 'jpeg', 'png'))) { @unlink(A_DIR . '/' . substr($defaultmessage['subjectimage'], 0, strrpos($defaultmessage['subjectimage'], '.')) . '.thumb.jpg'); } @unlink(A_DIR . '/' . $defaultmessage['subjectimage']); } } //構建數據 $setsqlarr = $setitemsqlarr = array(); $setsqlarr = getsetsqlarr($resultitems); $itemgrade = DB::result_first("SELECT grade FROM " . tname($mname . "items") . " WHERE itemid = '{$itemid}'"); if ($itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) { $setsqlarr['subjectimage'] = $_POST['subjectimage_value']; } if (empty($_POST['catid']) || $_POST['catid'] < 0) { array_push($checkresults, array('catid' => lang('cat_not_selected'))); } $setsqlarr['catid'] = $_POST['catid']; if ($modelsinfoarr['modelname'] != 'shop') { //限制必填信息所屬店舖 if (pkperm('isadmin')) { if (empty($_POST['shopid'])) { array_push($checkresults, array('shopid' => lang('please_select_shopid'))); } $setsqlarr['shopid'] = intval($_POST['shopid']); } else { $setsqlarr['shopid'] = $_G['myshopid']; } } else { $setsqlarr['letter'] = !empty($_POST['letter']) ? trim($_POST['letter']) : getletter(trim($_POST['subject'])); $setsqlarr['keywords'] = trim(strip_tags($_POST['keywords'])); $setsqlarr['description'] = trim(strip_tags($_POST['description'])); if (!empty($_POST['syncfid'])) { require_once B_ROOT . './api/bbs_syncpost.php'; if (checkbbsfid($_POST['syncfid'])) { $setsqlarr['syncfid'] = intval($_POST['syncfid']); } else { array_push($checkresults, array('syncfid' => lang('syncfid_noexists'))); } } } $setsqlarr['subject'] = $_POST['subject']; $setsqlarr['allowreply'] = 1; if (!empty($checkresults)) { cpmsg('addobject_error', '', '', '', true, true, $checkresults); } if (pkperm('isadmin')) { $setsqlarr['grade'] = isset($_POST['grade']) ? $_POST['grade'] : 3; } elseif ($_G['myshopstatus'] == 'verified') { if (in_array($modelsinfoarr['modelname'], array('good', 'notice', 'consume', 'album', 'groupbuy')) && $itemgrade > 1 && $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']]) { $setsqlarr['grade'] = !empty($itemid) ? 5 : 0; if (!empty($itemid)) { if (in_array($_POST['grade'], array(2, 3))) { $setsqlarr['grade'] = $_POST['grade']; } } $mustverify = true; } else { if (in_array($_POST['grade'], array(2, 3))) { $setsqlarr['grade'] = $_POST['grade']; } else { $setsqlarr['grade'] = $_SGLOBAL['panelinfo']['group']['verify' . $modelsinfoarr['modelname']] ? 0 : 3; } } } elseif ($_G['myshopstatus'] == 'unverified') { $setsqlarr['grade'] = 0; } $setsqlarr['dateline'] = $_G['timestamp']; $setsqlarr['uid'] = $_G['uid']; $setsqlarr['username'] = $_G['username']; $setsqlarr['lastpost'] = $setsqlarr['dateline']; // 標題圖片處理 Start if (!empty($modelsinfoarr['thumbsize'])) { $modelsinfoarr['thumbsize'] = explode(',', trim($modelsinfoarr['thumbsize'])); $modelsinfoarr['subjectimagewidth'] = $modelsinfoarr['thumbsize'][0]; $modelsinfoarr['subjectimageheight'] = $modelsinfoarr['thumbsize'][1]; } if ($_POST['imagetype'] == 0 && $modelsinfoarr['modelname'] == 'consume' && $_G['setting']['allowcreateimg']) { if ($_GET['action'] == 'add') { $hotline = $_SGLOBAL['panelinfo']['tel']; $address = $_SGLOBAL['panelinfo']['address']; } else { $shopinfo = DB::fetch(DB::query("SELECT tel, address FROM " . tname('shopitems') . " WHERE itemid='{$setsqlarr['shopid']}'")); $hotline = $shopinfo['tel']; $address = $shopinfo['address']; } $dealer_name = DB::result_first("SELECT subject FROM " . tname('shopitems') . " WHERE itemid='{$setsqlarr['shopid']}'"); $createimgarr = array('id' => intval($_POST['imgtplid']), 'mid' => intval($modelsinfoarr['mid']), 'itemid' => intval($itemid), 'coupon_title' => $setsqlarr['subject'], 'dealer_id' => $setsqlarr['uid'], 'dealer_name' => $dealer_name, 'begin_date' => date('Y-m-d', $setsqlarr['validity_start']), 'end_date' => date('Y-m-d', $setsqlarr['validity_end']), 'brief' => trim($_POST['message']), 'exception' => trim($_POST['exception']), 'address' => $address, 'hotline' => $hotline, 'subjectimagewidth' => $modelsinfoarr['subjectimagewidth'], 'subjectimageheight' => $modelsinfoarr['subjectimageheight']); require_once B_ROOT . './source/adminfunc/tool.func.php'; if ($consumeimgpath = image_text($createimgarr)) { $setsqlarr['subjectimage'] = $consumeimgpath; $setsqlarr['imagetype'] = 0; $setsqlarr['imgtplid'] = intval($_POST['imgtplid']); } } else { $uploadfilearr = $ids = array(); $subjectimageid = ''; $uploadfilearr = uploadfile(array(array('fieldname' => 'subjectimage', 'fieldcomment' => '圖片標題', 'formtype' => 'img')), $modelsinfoarr['mid'], 0, 1, $modelsinfoarr['subjectimagewidth'], $modelsinfoarr['subjectimageheight']); if (!empty($uploadfilearr)) { $feedsubjectimg = $uploadfilearr; foreach ($uploadfilearr as $tmpkey => $tmpvalue) { if (empty($tmpvalue['error'])) { $setsqlarr[$tmpkey] = $tmpvalue['filepath']; } if (!empty($tmpvalue['aid'])) { $ids[] = $tmpvalue['aid']; } } } if ($modelsinfoarr['modelname'] == 'consume') { $setsqlarr['imagetype'] = 1; } } /* --------- 標題圖片處理 End --------------*/ //詞語過濾 if (!empty($modelsinfoarr['allowfilter'])) { $setsqlarr = scensor($setsqlarr, 1); } //發佈時間 $setsqlarr['dateline'] = $_G['timestamp']; // 商品添加簡介 if ($mname == "good") { $setsqlarr['intro'] = trim(strip_tags($_POST['intro'])); } if (empty($itemid)) { //插入數據 $itemid = inserttable($modelsinfoarr['modelname'] . 'items', $setsqlarr, 1); if (in_array($modelsinfoarr['modelname'], array('good', 'notice', 'consume', 'album', 'groupbuy'))) { itemnumreset($modelsinfoarr['modelname'], $setsqlarr['shopid']); } } else { $_SGLOBAL['itemupdate'] = 1; //更新 $op = 'update'; unset($setsqlarr['uid']); unset($setsqlarr['username']); unset($setsqlarr['lastpost']); if ($itemgrade == 1 && !pkperm('isadmin')) { $setsqlarr['grade'] = 0; } elseif ($itemgrade == 1 && pkperm('isadmin')) { $setsqlarr['grade'] = 1; } elseif ($itemgrade == 0 && !pkperm('isadmin')) { $setsqlarr['grade'] = 0; } elseif ($itemgrade == 0 && pkperm('isadmin')) { $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; }
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); }
function randpost_fetch(&$a, &$b) { $fort_server = get_config('fortunate', 'server'); if (!$fort_server) { return; } $r = q("select * from pconfig where cat = 'randpost' and k = 'enable'"); if ($r) { foreach ($r as $rr) { if (!$rr['v']) { continue; } // logger('randpost'); // cronhooks run every 10-15 minutes typically // try to keep from posting frequently. $test = mt_rand(0, 100); if ($test == 25) { $c = q("select * from channel where channel_id = %d limit 1", intval($rr['uid'])); if (!$c) { continue; } $mention = ''; require_once 'include/html2bbcode.php'; $s = z_fetch_url('http://' . $fort_server . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand()); if (!$s['success']) { continue; } $x = array(); $x['uid'] = $c[0]['channel_id']; $x['aid'] = $c[0]['channel_account_id']; $x['mid'] = $x['parent_mid'] = item_message_id(); $x['author_xchan'] = $x['owner_xchan'] = $c[0]['channel_hash']; $x['item_thread_top'] = 1; $x['item_origin'] = 1; $x['item_verified'] = 1; $x['item_wall'] = 1; // if it might be a quote make it a quote if (strpos($s['body'], '--')) { $x['body'] = $mention . '[quote]' . html2bbcode($s['body']) . '[/quote]'; } else { $x['body'] = $mention . html2bbcode($s['body']); } $x['sig'] = base64url_encode(rsa_sign($x['body'], $c[0]['channel_prvkey'])); $post = item_store($x); $post_id = $post['item_id']; $x['id'] = $post_id; call_hooks('post_local_end', $x); Zotlabs\Daemon\Master::Summon(array('Notifier', 'wall-new', $post_id)); } } } }
/** * remote post * * https://yoursite/rpost?f=&title=&body=&remote_return= * * This can be called via either GET or POST, use POST for long body content as suhosin often limits GET parameter length * * f= placeholder, often required * title= Title of post * body= Body of post * url= URL which will be parsed and the results appended to the body * source= Source application * remote_return= absolute URL to return after posting is finished * type= choices are 'html' or 'bbcode', default is 'bbcode' * */ function rpost_content(&$a) { $o = ''; if (!local_channel()) { if (remote_channel()) { // redirect to your own site. // We can only do this with a GET request so you'll need to keep the text short or risk getting truncated // by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin // blocks them. $url = get_rpost_path($a->get_observer()); // make sure we're not looping to our own hub if ($url && !stristr($url, $a->get_hostname())) { foreach ($_REQUEST as $key => $arg) { $url .= '&' . $key . '=' . $arg; } goaway($url); } } // The login procedure is going to bugger our $_REQUEST variables // so save them in the session. if (array_key_exists('body', $_REQUEST)) { $_SESSION['rpost'] = $_REQUEST; } return login(); } // If we have saved rpost session variables, but nothing in the current $_REQUEST, recover the saved variables if (!array_key_exists('body', $_REQUEST) && array_key_exists('rpost', $_SESSION)) { $_REQUEST = $_SESSION['rpost']; unset($_SESSION['rpost']); } if (array_key_exists('channel', $_REQUEST)) { $r = q("select channel_id from channel where channel_account_id = %d and channel_address = '%s' limit 1", intval(get_account_id()), dbesc($_REQUEST['channel'])); if ($r) { require_once 'include/security.php'; $change = change_channel($r[0]['channel_id']); } } if ($_REQUEST['remote_return']) { $_SESSION['remote_return'] = $_REQUEST['remote_return']; } if (argc() > 1 && argv(1) === 'return') { if ($_SESSION['remote_return']) { goaway($_SESSION['remote_return']); } goaway(z_root() . '/network'); } $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) // $plaintext = false; if (array_key_exists('type', $_REQUEST) && $_REQUEST['type'] === 'html') { require_once 'include/html2bbcode.php'; $_REQUEST['body'] = html2bbcode($_REQUEST['body']); } $channel = $a->get_channel(); $channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']); if ($_REQUEST['url']) { $x = z_fetch_url(z_root() . '/parse_url?f=&url=' . urlencode($_REQUEST['url'])); if ($x['success']) { $_REQUEST['body'] = $_REQUEST['body'] . $x['body']; } } $x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($channel_acl), 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), 'title' => $_REQUEST['title'], 'body' => $_REQUEST['body'], 'attachment' => $_REQUEST['attachment'], 'source' => x($_REQUEST, 'source') ? strip_tags($_REQUEST['source']) : '', 'return_path' => 'rpost/return'); $editor = status_editor($a, $x); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit post'), '$editor' => $editor)); return $o; }
while ($value = $_SGLOBAL['db']->fetch_array($query)) { $joins[$value['uid']] = $value['uid']; } realname_get(); //用户组 $groups = getfriendgroup(); $groupselect = array($_GET['group'] => ' selected'); $multi = multi($count, $perpage, $page, "cp.php?ac=mtag&op=manage&tagid=$mtag[tagid]&subop=invite&group=$_GET[group]&key=$_GET[key]"); } else { //显示 include_once(S_ROOT.'./source/function_bbcode.php'); $mtag['announcement'] = html2bbcode($mtag['announcement']); $joinperms = array($mtag['joinperm'] => ' selected'); $viewperms = array($mtag['viewperm'] => ' selected'); $threadperms = array($mtag['threadperm'] => ' selected'); $postperms = array($mtag['postperm'] => ' selected'); $closeapply = array($mtag['closeapply'] => ' checked'); } $actives = array($_GET['subop'] => ' class="active"'); } elseif($_GET['op'] == 'join') { $tagid = empty($_GET['tagid'])?0:intval($_GET['tagid']); if(submitcheck('joinsubmit')) { $mtag = mtag_join('tagid', $tagid);
function api_statuses_update(&$a, $type) { if (local_user() === false) { 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')) { 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); $_POST['body'] = html2bbcode($txt); } } else { $_POST['body'] = urldecode(requestdata('status')); } $parent = requestdata('in_reply_to_status_id'); if (ctype_digit($parent)) { $_POST['parent'] = $parent; } else { $_POST['parent_uri'] = $parent; } if (requestdata('lat') && requestdata('long')) { $_POST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long')); } $_POST['profile_uid'] = local_user(); if (requestdata('parent')) { $_POST['type'] = 'net-comment'; } else { $_POST['type'] = 'wall'; } // set this so that the item_post() function is quiet and doesn't redirect or emit json $_POST['api_source'] = true; // 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); }
if (isset($valueparse['host'])) { $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 . '" />'; } showsetting('forums_edit_basic_banner', 'bannernew', $forum['banner'], 'filetext', '', 0, $forumbannerhtml); } showsetting('forums_edit_basic_display', array('statusnew', array(array(1, cplang('forums_edit_basic_display_yes')), array(0, cplang('forums_edit_basic_display_no')), array(2, cplang('forums_edit_basic_display_select')))), $forum['status'], 'mradio'); if (!$multiset) { showsetting('forums_edit_basic_up', '', '', $fupselect); } showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text'); showsetting('forums_edit_basic_description', 'descriptionnew', html2bbcode($forum['description']), 'textarea'); showsetting('forums_edit_basic_rules', 'rulesnew', html2bbcode($forum['rules']), 'textarea'); showsetting('forums_edit_basic_keyword', 'keywordsnew', $forum['keywords'], 'text'); showsetting('forums_edit_basic_keys', 'keysnew', $forumkeys[$fid], 'text'); showtablefooter(); showtagfooter('div'); showtagheader('div', 'extend', $anchor == 'extend'); showtableheader('forums_edit_extend', 'nobottom'); showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text'); showsetting('forums_edit_extend_subforumsindex', array('subforumsindexnew', array(array(-1, cplang('default')), array(1, cplang('yes')), array(0, cplang('no'))), 1), $forum['subforumsindex'], 'mradio'); showsetting('forums_edit_extend_simple', 'simplenew', $forum['simple'], 'radio'); showsetting('forums_edit_extend_allowside', 'allowsidenew', $forum['allowside'], 'radio'); showsetting('forums_edit_extend_recommend_top', 'allowglobalsticknew', $forum['allowglobalstick'], 'radio'); showsetting('forums_edit_extend_defaultorderfield', array('defaultorderfieldnew', array(array(0, cplang('forums_edit_extend_order_lastpost')), array(1, cplang('forums_edit_extend_order_starttime')), array(2, cplang('forums_edit_extend_order_replies')), array(3, cplang('forums_edit_extend_order_views')))), $forum['defaultorderfield'], 'mradio'); showsetting('forums_edit_extend_defaultorder', array('defaultordernew', array(array(0, cplang('forums_edit_extend_order_desc')), array(1, cplang('forums_edit_extend_order_asc')))), $forum['defaultorder'], 'mradio'); showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text'); showsetting('forums_edit_extend_edit_rules', 'alloweditrulesnew', $forum['alloweditrules'], 'radio');
if (isset($valueparse['host'])) { $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'); if (!$multiset) { showsetting('forums_edit_basic_up', '', '', $fupselect); } showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text'); showsetting('forums_edit_basic_description', 'descriptionnew', str_replace('&', '&', html2bbcode($forum['description'])), 'textarea'); showsetting('forums_edit_basic_rules', 'rulesnew', str_replace('&', '&', 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');
function _public_add_info($type = 'bbs') { $info = $this->_article_info(); if (!$info) { return; } if ($type == 'bbs') { require_once libfile('function/editor'); $info['content'] = dstripslashes($info['content']); $info['content'] = img_htmlbbcode($info['content'], $info['page_url']); $info['content'] = media_htmlbbcode($info['content'], $info['page_url']); $info['content'] = audio_htmlbbcode($info['content'], $info['page_url']); $info['content'] = htmlspecialchars_decode(html2bbcode($info['content'])); $info['content'] = dstripslashes(format_html($info['content'])); $script .= '<div id="show_title" style="display:none">' . $info['title'] . '</div><div id="show_content" style="display:none">' . $info['content'] . '</div><script language="javascript" type="text/javascript" >'; $script .= ' var subject = $("show_title").innerHTML; var message = $("show_content").innerHTML; $("subject").value= subject; message = message.replace(/<p>([\\s\\S]*?)<\\/p>/ig, "$1<br />"); message = message.replace(/<center>([\\s\\S]*?)<\\/center>/ig, "[align=center]$1[/align]"); $(\'e_textarea\').value = message; $("subject").focus();'; $script .= '</script>'; } else { if ($type == 'portal') { $script .= '<div id="show_title" style="display:none">' . $info['title'] . '</div><div id="show_content" style="display:none">' . $info['content'] . '</div><script language="javascript" type="text/javascript" >'; $script .= ' var subject = $("show_title").innerHTML; var message = $("show_content").innerHTML; $("title").value= subject; $("from").value= \'' . $this->_public_data($info['from']) . '\'; document.getElementsByName(\'fromurl\')[0].value = \'' . $this->_public_data($info['url']) . '\'; document.getElementsByName(\'author\')[0].value = \'' . $this->_public_data($info['author']) . '\'; $(\'uchome-ttHtmlEditor\').value = message; var p = window.frames[\'uchome-ifrHtmlEditor\']; var obj = p.window.frames[\'HtmlEditor\']; obj.document.body.innerHTML = message; edit_save(); $("title").focus()'; $script .= '</script>'; } else { if ($type == 'blog') { $script .= '<div id="show_title" style="display:none">' . $info['title'] . '</div><div id="show_content" style="display:none">' . $info['content'] . '</div><script language="javascript" type="text/javascript" >'; $script .= ' var subject = $("show_title").innerHTML; var message = $("show_content").innerHTML; $("subject").value= subject; document.getElementsByName(\'tag\')[0].value = \'' . $this->_public_data($info['article_tag']) . '\'; $(\'uchome-ttHtmlEditor\').value = message; var p = window.frames[\'uchome-ifrHtmlEditor\']; var obj = p.window.frames[\'HtmlEditor\']; obj.document.body.innerHTML = message; edit_save(); $("subject").focus()'; $script .= '</script>'; } } } return $script; }
function poco_discover_server($data, $default_generation = 0) { if (!isset($data->entry) or !count($data->entry)) { return false; } $success = false; foreach ($data->entry as $entry) { $profile_url = ''; $profile_photo = ''; $connect_url = ''; $name = ''; $network = ''; $updated = '0000-00-00 00:00:00'; $location = ''; $about = ''; $keywords = ''; $gender = ''; $generation = $default_generation; $name = $entry->displayName; if (isset($entry->urls)) { foreach ($entry->urls as $url) { if ($url->type == 'profile') { $profile_url = $url->value; continue; } if ($url->type == 'webfinger') { $connect_url = str_replace('acct:', '', $url->value); continue; } } } if (isset($entry->photos)) { foreach ($entry->photos as $photo) { if ($photo->type == 'profile') { $profile_photo = $photo->value; continue; } } } if (isset($entry->updated)) { $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); } if (isset($entry->network)) { $network = $entry->network; } if (isset($entry->currentLocation)) { $location = $entry->currentLocation; } if (isset($entry->aboutMe)) { $about = html2bbcode($entry->aboutMe); } if (isset($entry->gender)) { $gender = $entry->gender; } if (isset($entry->generation) and $entry->generation > 0) { $generation = ++$entry->generation; } if (isset($entry->tags)) { foreach ($entry->tags as $tag) { $keywords = implode(", ", $tag); } } if ($generation > 0) { $success = true; logger("Store profile " . $profile_url, LOGGER_DEBUG); poco_check($profile_url, $name, $network, $profile_photo, $about, $location, $gender, $keywords, $connect_url, $updated, $generation, 0, 0, 0); logger("Done for profile " . $profile_url, LOGGER_DEBUG); } } return $success; }
if ($optionuser) { foreach ($optionuser as $uid => $polluser) { $oparr = array(); if ($polluser['oid']) { foreach ($polluser['oid'] as $key => $id) { $oparr[$key] = $changeoid[$key]; } } $userdate = array('tid' => $tid, 'uid' => intval($uid), 'username' => daddslashes($polluser['username']), 'options' => implode("\t", $oparr), 'dateline' => $polluser['dateline']); $db_target->insert('forum_pollvoter', $userdate); } } $lastpost = array(); $query = $db_source->query("SELECT * FROM " . $db_source->table('comment') . " WHERE id='{$value['pid']}' AND idtype='pid' ORDER BY dateline"); while ($comment = $db_source->fetch_array($query)) { $comment['message'] = html2bbcode($comment['message']); $comment = daddslashes($comment); $postarr = array('fid' => $fid, 'tid' => $tid, 'first' => '0', 'author' => $comment['author'], 'authorid' => $comment['authorid'], 'useip' => $comment['ip'], 'dateline' => $comment['dateline'], 'message' => $comment['message']); $lastpost = array('lastpost' => $comment['dateline'], 'lastposter' => $comment['author']); $db_target->insert('forum_post', $postarr); $db_target->insert('common_member_count', array('uid' => $comment['authorid']), 0, false, true); $db_target->query("UPDATE " . $db_target->table('common_member_count') . " SET posts=posts+1 WHERE uid='{$comment['authorid']}'", 'UNBUFFERED'); } if ($lastpost) { $db_target->update('forum_thread', $lastpost, array('tid' => $tid)); } $db_target->insert('common_member_count', array('uid' => $comment['authorid']), 0, false, true); $db_target->query("UPDATE " . $db_target->table('common_member_count') . " SET threads=threads+1, posts=posts+{$postnum} WHERE uid='{$value['uid']}'", 'UNBUFFERED'); $db_target->query("UPDATE " . $db_target->table('forum_forum') . " SET lastpost='{$lastpost['lastpost']}', threads=threads+1, posts=posts+{$value['replynum']}, todayposts=todayposts+{$value['replynum']} WHERE fid='{$fid}'", 'UNBUFFERED'); } if ($nextid) {
$secqaacheck = false; $member['msn'] = explode("\t", $member['msn']); if (!submitcheck('editsubmit', 0, $seccodecheck)) { if ($typeid == 1) { if ($seccodecheck) { $seccode = random(6, 1) + $seccode[0] * 1000000; } } elseif ($typeid == 2) { require_once DISCUZ_ROOT . './include/editor.func.php'; require_once DISCUZ_ROOT . '/uc_client/client.php'; $gendercheck = array($member['gender'] => 'selected="selected"'); $uc_avatarflash = uc_avatar($discuz_uid, '', 0); $member['bio'] = preg_replace("/<imme>(.+)<\\/imme>/is", '[imme]', $member['bio']); $member['sightml'] = preg_replace("/<imme>(.+)<\\/imme>/is", '[imme]', $member['sightml']); $member['bio'] = html2bbcode($member['bio']); $member['signature'] = html2bbcode($member['sightml']); } elseif ($typeid == 5) { $invisiblechecked = $member['invisible'] ? 'checked="checked"' : ''; $emailchecked = $member['showemail'] ? 'checked="checked"' : ''; $newschecked = $member['newsletter'] ? 'checked="checked"' : ''; $tppchecked = array($member['tpp'] => 'checked="checked"'); $pppchecked = array($member['ppp'] => 'checked="checked"'); $toselect = array(strval((double) $member['timeoffset']) => 'selected="selected"'); $pscheck = array(intval($member['pmsound']) => 'checked="checked"'); $emcheck = array($member['editormode'] => 'checked="checked"'); $tfcheck = array($member['timeformat'] => 'checked="checked"'); $dfcheck = array($member['dateformat'] => 'checked="checked"'); $styleselect = ''; $query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'"); while ($style = $db->fetch_array($query)) { $styleselect .= "<option value=\"{$style['styleid']}\" " . ($style['styleid'] == $member['styleid'] ? 'selected="selected"' : NULL) . ">{$style['name']}</option>\n";
if ($expiration <= $_SGLOBAL['timestamp']) { showmessage('time_expired_error', $_POST['refer']); } } updatetable('poll', array('expiration' => $expiration), array('pid' => $pid)); showmessage('do_success', 'space.php?uid=' . $space['uid'] . '&do=poll&pid=' . $pid, 0); } } elseif ($op == 'summary') { //Write poll summary if (submitcheck('summarysubmit')) { $summary = getstr($_POST['summary'], 0, 1, 1, 1, 2); updatetable('pollfield', array('summary' => $summary), array('pid' => $pid)); showmessage('do_success', 'space.php?uid=' . $space['uid'] . '&do=poll&pid=' . $pid, 0); } //bbcode transform $poll['summary'] = html2bbcode(str_replace('<br/>', "\n", $poll['summary'])); //ÏÔʾÓà } elseif ($op == 'vote') { //Vote count if (submitcheck('votesubmit')) { if (empty($poll)) { showmessage("voting_does_not_exist"); } //Gender verification if ($poll['sex'] && $poll['sex'] != $space['sex']) { showmessage('no_privilege'); } //Verify that voted $count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('polluser') . " WHERE uid='{$_SGLOBAL['supe_uid']}' AND pid='{$pid}'"), 0); if ($count) { showmessage("already_voted");
function getmtag($start) { global $db_source, $db_target, $fieldid, $gid, $fid, $sid, $tagid; if (empty($fieldid)) { getprofield($fieldid); } $mtag = $db_source->fetch_first("SELECT * FROM " . $db_source->table('mtag') . " WHERE fieldid='{$fieldid}' AND tagid>'{$start}' ORDER BY tagid LIMIT 1"); if (empty($mtag)) { $tagid = $sid = 0; return false; } $tagid = $mtag['tagid']; $founder = $groupuser = array(); $query = $db_source->query("SELECT * FROM " . $db_source->table('tagspace') . " WHERE tagid='{$mtag['tagid']}'"); while ($space = $db_source->fetch_array($query)) { $space['level'] = 4; if ($space['grade'] == 9) { $space['level'] = 1; if (empty($founder)) { $founder = array('founderuid' => $space['uid'], 'foundername' => daddslashes($space['username'])); } } elseif ($space['grade'] == 8) { $space['level'] = 2; } elseif ($space['grade'] == 1) { $space['level'] = 3; } elseif ($space['grade'] == -2) { $space['level'] = 0; } $groupuser[$space['uid']] = $space; } if (empty($founder)) { $member = $db_target->fetch_first("SELECT uid,username FROM " . $db_target->table('common_member') . " WHERE adminid='1' ORDER BY uid LIMIT 1"); $founder = array('founderuid' => $member['uid'], 'foundername' => daddslashes($member['username'])); $groupuser[$member['uid']] = array('uid' => $member['uid'], 'username' => $member['username'], 'level' => 1); } $levelid = $db_target->result_first("SELECT levelid FROM " . $db_target->table('forum_grouplevel') . " WHERE creditshigher<='0' AND '0'<creditslower LIMIT 1"); $forumarr = array('fup' => $fid, 'type' => 'sub', 'name' => daddslashes($mtag['tagname']), 'status' => 3, 'allowsmilies' => 1, 'allowbbcode' => 1, 'allowimgcode' => 1, 'level' => $levelid); $sid = $db_target->insert('forum_forum', $forumarr, true); $forumfieldarr = array('fid' => $sid, 'description' => daddslashes(html2bbcode($mtag['announcement'])), 'jointype' => $mtag['joinperm'] ? $mtag['joinperm'] == 1 ? 2 : 1 : 0, 'gviewperm' => $mtag['viewperm'] ? 0 : 1, 'dateline' => TIMESTAMP, 'founderuid' => $founder['founderuid'], 'foundername' => $founder['foundername'], 'membernum' => $mtag['membernum']); $db_target->insert('forum_forumfield', $forumfieldarr); $db_target->query("UPDATE " . $db_target->table('forum_forumfield') . " SET groupnum=groupnum+1 WHERE fid='{$fid}'"); foreach ($groupuser as $uid => $user) { $userarr = array('fid' => $sid, 'uid' => $uid, 'username' => daddslashes($user['username']), 'level' => $user['level'], 'threads' => 0, 'replies' => 0, 'joindateline' => TIMESTAMP, 'lastupdate' => TIMESTAMP, 'privacy' => ''); $db_target->insert('forum_groupuser', $userarr, 0, true); } $query = $db_source->query("SELECT * FROM " . $db_source->table('mtaginvite') . " WHERE tagid='{$mtag['tagid']}'"); while ($invite = $db_source->fetch_array($query)) { $invitearr = array('fid' => $sid, 'uid' => $invite['fromuid'], 'inviteuid' => $invite['uid'], 'dateline' => $invite['dateline']); $db_target->insert('forum_groupinvite', $invitearr, 0, true); } return true; }
function get_atom_elements($feed, $item, $contact = array()) { require_once 'library/HTMLPurifier.auto.php'; require_once 'include/html2bbcode.php'; $best_photo = array(); $res = array(); $author = $item->get_author(); if ($author) { $res['author-name'] = unxmlify($author->get_name()); $res['author-link'] = unxmlify($author->get_link()); } else { $res['author-name'] = unxmlify($feed->get_title()); $res['author-link'] = unxmlify($feed->get_permalink()); } $res['uri'] = unxmlify($item->get_id()); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); $res['plink'] = unxmlify($item->get_link(0)); if (isset($contact["network"]) and $contact["network"] == NETWORK_FEED and strstr($res['plink'], ".app.net/")) { logger("get_atom_elements: detected app.net posting: " . print_r($res, true), LOGGER_DEBUG); $res['title'] = ""; $res['body'] = nl2br($res['body']); } // removing the content of the title if its identically to the body // This helps with auto generated titles e.g. from tumblr if (title_is_body($res["title"], $res["body"])) { $res['title'] = ""; } if ($res['plink']) { $base_url = implode('/', array_slice(explode('/', $res['plink']), 0, 3)); } else { $base_url = ''; } // look for a photo. We should check media size and find the best one, // but for now let's just find any author photo // Additionally we look for an alternate author link. On OStatus this one is the one we want. $authorlinks = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["author"][0]["child"]["http://www.w3.org/2005/Atom"]["link"]; if (is_array($authorlinks)) { foreach ($authorlinks as $link) { $linkdata = array_shift($link["attribs"]); if ($linkdata["rel"] == "alternate") { $res["author-link"] = $linkdata["href"]; } } } $rawauthor = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate') { $res['author-link'] = unxmlify($link['attribs']['']['href']); } if (!x($res, 'author-avatar') || !$res['author-avatar']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $res['author-avatar'] = unxmlify($link['attribs']['']['href']); } } } } $rawactor = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor'); if ($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'], ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if ($base && count($base)) { foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$res['author-link']) { $res['author-link'] = unxmlify($link['attribs']['']['href']); } if (!x($res, 'author-avatar') || !$res['author-avatar']) { if ($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') { $res['author-avatar'] = unxmlify($link['attribs']['']['href']); } } } } } // No photo/profile-link on the item - look at the feed level if (!x($res, 'author-link') || !x($res, 'author-avatar')) { $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$res['author-link']) { $res['author-link'] = unxmlify($link['attribs']['']['href']); } if (!$res['author-avatar']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $res['author-avatar'] = unxmlify($link['attribs']['']['href']); } } } } $rawactor = $feed->get_feed_tags(NAMESPACE_ACTIVITY, 'subject'); if ($rawactor && activity_match($rawactor[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'], ACTIVITY_OBJ_PERSON)) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if ($base && count($base)) { foreach ($base as $link) { if ($link['attribs']['']['rel'] === 'alternate' && !$res['author-link']) { $res['author-link'] = unxmlify($link['attribs']['']['href']); } if (!x($res, 'author-avatar')) { if ($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') { $res['author-avatar'] = unxmlify($link['attribs']['']['href']); } } } } } } $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 ($res['app'] === 'web') { $res['app'] = 'OStatus'; } } // base64 encoded json structure representing Diaspora signature $dsig = $item->get_item_tags(NAMESPACE_DFRN, 'diaspora_signature'); if ($dsig) { $res['dsprsig'] = unxmlify($dsig[0]['data']); } $dguid = $item->get_item_tags(NAMESPACE_DFRN, 'diaspora_guid'); if ($dguid) { $res['guid'] = unxmlify($dguid[0]['data']); } $bm = $item->get_item_tags(NAMESPACE_DFRN, 'bookmark'); if ($bm) { $res['bookmark'] = unxmlify($bm[0]['data']) === 'true' ? 1 : 0; } /** * 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'])); } $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']); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); // we shouldn't need a whitelist, because the bbcode converter // will strip out any unsupported tags. $purifier = new HTMLPurifier($config); $res['body'] = $purifier->purify($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']); } // this tag is obsolete but we keep it for really old sites $allow = $item->get_item_tags(NAMESPACE_DFRN, 'comment-allow'); if ($allow && $allow[0]['data'] == 1) { $res['last-child'] = 1; } else { $res['last-child'] = 0; } $private = $item->get_item_tags(NAMESPACE_DFRN, 'private'); if ($private && intval($private[0]['data']) > 0) { $res['private'] = intval($private[0]['data']); } else { $res['private'] = 0; } $extid = $item->get_item_tags(NAMESPACE_DFRN, 'extid'); if ($extid && $extid[0]['data']) { $res['extid'] = $extid[0]['data']; } $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) { $res['edited'] = unxmlify($rawedited[0]['data']); } if (x($res, 'edited') && !x($res, 'created')) { $res['created'] = $res['edited']; } if (!$res['created']) { $res['created'] = $item->get_date('c'); } if (!$res['edited']) { $res['edited'] = $item->get_date('c'); } // Disallow time travelling posts $d1 = strtotime($res['created']); $d2 = strtotime($res['edited']); $d3 = strtotime('now'); if ($d1 > $d3) { $res['created'] = datetime_convert(); } if ($d2 > $d3) { $res['edited'] = datetime_convert(); } $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']) { $base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach ($base as $link) { if (!x($res, 'owner-avatar') || !$res['owner-avatar']) { if ($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') { $res['owner-avatar'] = unxmlify($link['attribs']['']['href']); } } } } $rawgeo = $item->get_item_tags(NAMESPACE_GEORSS, 'point'); if ($rawgeo) { $res['coord'] = unxmlify($rawgeo[0]['data']); } if ($contact["network"] == NETWORK_FEED) { $res['verb'] = ACTIVITY_POST; $res['object-type'] = ACTIVITY_OBJ_NOTE; } $rawverb = $item->get_item_tags(NAMESPACE_ACTIVITY, 'verb'); // select between supported verbs if ($rawverb) { $res['verb'] = unxmlify($rawverb[0]['data']); } // translate OStatus unfollow to activity streams if it happened to get selected if (x($res, 'verb') && $res['verb'] === 'http://ostatus.org/schema/1.0/unfollow') { $res['verb'] = ACTIVITY_UNFOLLOW; } $cats = $item->get_categories(); if ($cats) { $tag_arr = array(); foreach ($cats as $cat) { $term = $cat->get_term(); if (!$term) { $term = $cat->get_label(); } $scheme = $cat->get_scheme(); if ($scheme && $term && stristr($scheme, 'X-DFRN:')) { $tag_arr[] = substr($scheme, 7, 1) . '[url=' . unxmlify(substr($scheme, 9)) . ']' . unxmlify($term) . '[/url]'; } elseif ($term) { $tag_arr[] = notags(trim($term)); } } $res['tag'] = implode(',', $tag_arr); } $attach = $item->get_enclosures(); if ($attach) { $att_arr = array(); foreach ($attach as $att) { $len = intval($att->get_length()); $link = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_link())))); $title = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_title())))); $type = str_replace(array(',', '"'), array('%2D', '%22'), notags(trim(unxmlify($att->get_type())))); if (strpos($type, ';')) { $type = substr($type, 0, strpos($type, ';')); } if (!$link || strpos($link, 'http') !== 0) { continue; } if (!$title) { $title = ' '; } if (!$type) { $type = 'application/octet-stream'; } $att_arr[] = '[attach]href="' . $link . '" length="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]'; } $res['attach'] = implode(',', $att_arr); } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); if ($rawobj) { $res['object'] = '<object>' . "\n"; $child = $rawobj[0]['child']; if ($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) { $res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data']; $res['object'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) { $res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $res['object'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) { $res['object'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if (!$body) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; } // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events $res['object'] .= '<orig>' . xmlify($body) . '</orig>' . "\n"; if (strpos($body, '<') !== false || strpos($body, '>') !== false) { $body = html2bb_video($body); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $purifier = new HTMLPurifier($config); $body = $purifier->purify($body); $body = html2bbcode($body); } $res['object'] .= '<content>' . $body . '</content>' . "\n"; } $res['object'] .= '</object>' . "\n"; } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target'); if ($rawobj) { $res['target'] = '<target>' . "\n"; $child = $rawobj[0]['child']; if ($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) { $res['target'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) { $res['target'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $res['target'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) { $res['target'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n"; } if (x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if (!$body) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; } // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events $res['target'] .= '<orig>' . xmlify($body) . '</orig>' . "\n"; if (strpos($body, '<') !== false || strpos($body, '>') !== false) { $body = html2bb_video($body); $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); $purifier = new HTMLPurifier($config); $body = $purifier->purify($body); $body = html2bbcode($body); } $res['target'] .= '<content>' . $body . '</content>' . "\n"; } $res['target'] .= '</target>' . "\n"; } // This is some experimental stuff. By now retweets are shown with "RT:" // But: There is data so that the message could be shown similar to native retweets // There is some better way to parse this array - but it didn't worked for me. $child = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["entry"][0]["child"]["http://activitystrea.ms/spec/1.0/"][object][0]["child"]; if (is_array($child)) { logger('get_atom_elements: Looking for status.net repeated message'); $message = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["content"][0]["data"]; $orig_id = ostatus_convert_href($child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["id"][0]["data"]); $author = $child[SIMPLEPIE_NAMESPACE_ATOM_10]["author"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]; $uri = $author["uri"][0]["data"]; $name = $author["name"][0]["data"]; $avatar = @array_shift($author["link"][2]["attribs"]); $avatar = $avatar["href"]; if ($name != "" and $uri != "" and $avatar != "" and $message != "") { logger('get_atom_elements: fixing sender of repeated message. ' . $orig_id, LOGGER_DEBUG); if (!intval(get_config('system', 'wall-to-wall_share'))) { $prefix = share_header($name, $uri, $avatar, "", "", $orig_link); $res["body"] = $prefix . html2bbcode($message) . "[/share]"; } else { $res["owner-name"] = $res["author-name"]; $res["owner-link"] = $res["author-link"]; $res["owner-avatar"] = $res["author-avatar"]; $res["author-name"] = $name; $res["author-link"] = $uri; $res["author-avatar"] = $avatar; $res["body"] = html2bbcode($message); } } } if (isset($contact["network"]) and $contact["network"] == NETWORK_FEED and $contact['fetch_further_information']) { $preview = ""; // Handle enclosures and treat them as preview picture if (isset($attach)) { foreach ($attach as $attachment) { if ($attachment->type == "image/jpeg") { $preview = $attachment->link; } } } $res["body"] = $res["title"] . add_page_info($res['plink'], false, $preview, $contact['fetch_further_information'] == 2, $contact['ffi_keyword_blacklist']); $res["tag"] = add_page_keywords($res['plink'], false, $preview, $contact['fetch_further_information'] == 2, $contact['ffi_keyword_blacklist']); $res["title"] = ""; $res["object-type"] = ACTIVITY_OBJ_BOOKMARK; unset($res["attach"]); } elseif (isset($contact["network"]) and $contact["network"] == NETWORK_OSTATUS) { $res["body"] = add_page_info_to_body($res["body"]); } elseif (isset($contact["network"]) and $contact["network"] == NETWORK_FEED and strstr($res['plink'], ".app.net/")) { $res["body"] = add_page_info_to_body($res["body"]); } $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); return $res; }
emailcheck_send($space['uid'], $toemail); dsetcookie('resendemail', TIMESTAMP); showmessage('send_activate_mail_succeed', "home.php?mod=spacecp&ac=profile&op=password"); } elseif ($_G['gp_resend']) { showmessage('send_activate_mail_error', "home.php?mod=spacecp&ac=profile&op=password"); } if (!empty($space['newemail'])) { $acitvemessage = lang('spacecp', 'email_acitve_message', array('newemail' => $space['newemail'], 'imgdir' => $_G['style']['imgdir'])); } $actives = array('password' => ' class="a"'); $navtitle = lang('core', 'title_password_security'); } else { space_merge($space, 'field_home'); space_merge($space, 'field_forum'); require_once libfile('function/editor'); $space['sightml'] = html2bbcode($space['sightml']); $vid = $_G['gp_vid'] ? intval($_G['gp_vid']) : 0; $privacy = $space['privacy']['profile'] ? $space['privacy']['profile'] : array(); $_G['setting']['privacy'] = $_G['setting']['privacy'] ? $_G['setting']['privacy'] : array(); $_G['setting']['privacy'] = is_array($_G['setting']['privacy']) ? $_G['setting']['privacy'] : unserialize($_G['setting']['privacy']); $_G['setting']['privacy']['profile'] = !empty($_G['setting']['privacy']['profile']) ? $_G['setting']['privacy']['profile'] : array(); $privacy = array_merge($_G['setting']['privacy']['profile'], $privacy); $actives = array('profile' => ' class="a"'); $opactives = array($operation => ' class="a"'); $allowitems = array(); if (in_array($operation, array('base', 'contact', 'edu', 'work', 'info'))) { $allowitems = $profilegroup[$operation]['field']; } elseif ($operation == 'verify') { if ($vid == 0) { foreach ($_G['setting']['verify'] as $key => $setting) { if ($setting['available']) {
$_GET['jointypenew'] = intval($_GET['jointypenew']); if ($_GET['jointypenew'] == '-1' && $_G['uid'] != $_G['forum']['founderuid']) { showmessage('group_close_only_founder'); } $_GET['gviewpermnew'] = intval($_GET['gviewpermnew']); $setarr['description'] = $_GET['descriptionnew']; $setarr['jointype'] = $_GET['jointypenew']; $setarr['gviewperm'] = $_GET['gviewpermnew']; C::t('forum_forumfield')->update($_G['fid'], $setarr); showmessage('group_setup_succeed', $url); } else { $firstgid = $_G['cache']['grouptype']['second'][$_G['forum']['fup']]['fup']; $groupselect = get_groupselect($firstgid, $_G['forum']['fup']); $gviewpermselect = $jointypeselect = array('', '', ''); require_once libfile('function/editor'); $_G['forum']['descriptionnew'] = html2bbcode($_G['forum']['description']); $jointypeselect[$_G['forum']['jointype']] = 'checked="checked"'; $gviewpermselect[$_G['forum']['gviewperm']] = 'checked="checked"'; if ($_G['setting']['allowgroupdomain'] && !empty($_G['setting']['domain']['root']['group']) && $domainlength) { loadcache('creditrule'); getuserprofile('extcredits1'); $rule = $_G['cache']['creditrule']['modifydomain']; $credits = $consume = $common = ''; for ($i = 1; $i <= 8; $i++) { if ($_G['setting']['extcredits'][$i] && $rule['extcredits' . $i]) { $consume .= $common . $_G['setting']['extcredits'][$i]['title'] . $rule['extcredits' . $i] . $_G['setting']['extcredits'][$i]['unit']; $credits .= $common . $_G['setting']['extcredits'][$i]['title'] . $_G['member']['extcredits' . $i] . $_G['setting']['extcredits'][$i]['unit']; $common = ','; } } }