*/
use Friendica\App;
-use Friendica\Content\ContactSelector;
-use Friendica\Content\Feature;
-use Friendica\Content\Smilies;
use Friendica\Content\Text\BBCode;
-use Friendica\Core\Addon;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
-use Friendica\Core\System;
-use Friendica\Database\DBA;
use Friendica\Model\Contact;
-use Friendica\Model\Event;
-use Friendica\Model\Item;
-use Friendica\Render\FriendicaSmarty;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Map;
-use Friendica\Util\Proxy as ProxyUtils;
-
-use Friendica\Core\Logger;
-use Friendica\Core\Renderer;
use Friendica\Model\FileTag;
-use Friendica\Util\XML;
-use Friendica\Content\Text\HTML;
-
-require_once "include/conversation.php";
+use Friendica\Model\Group;
+use Friendica\Util\Strings;
/**
* Turn user/group ACLs stored as angle bracketed text into arrays
function expand_acl($s) {
// turn string array of angle-bracketed elements into numeric array
// e.g. "<1><2><3>" => array(1,2,3);
- $ret = [];
+ preg_match_all('/<(' . Group::FOLLOWERS . '|'. Group::MUTUALS . '|[0-9]+)>/', $s, $matches, PREG_PATTERN_ORDER);
- if (strlen($s)) {
- $t = str_replace('<', '', $s);
- $a = explode('>', $t);
- foreach ($a as $aa) {
- if (intval($aa)) {
- $ret[] = intval($aa);
- }
- }
- }
- return $ret;
+ return $matches[1];
}
*/
function sanitise_acl(&$item) {
if (intval($item)) {
- $item = '<' . intval(notags(trim($item))) . '>';
+ $item = '<' . intval(Strings::escapeTags(trim($item))) . '>';
+ } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) {
+ $item = '<' . $item . '>';
} else {
unset($item);
}
*/
function redir_private_images($a, &$item)
{
- $matches = false;
+ $matches = [];
$cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
}
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == Protocol::DFRN)) {
- $img_url = 'redir?f=1&quiet=1&url=' . urlencode($mtch[1]) . '&conurl=' . urlencode($item['author-link']);
+ $img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
}
}
* @brief Given a text string, convert from bbcode to html and add smilie icons.
*
* @param string $text String with bbcode.
- * @return string Formattet HTML.
+ * @return string Formatted HTML
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
-function prepare_text($text) {
- if (stristr($text, '[nosmile]')) {
- $s = BBCode::convert($text);
- } else {
- $s = Smilies::replace(BBCode::convert($text));
- }
-
+function prepare_text($text)
+{
+ $s = BBCode::convert($text);
return trim($s);
}
{
$categories = [];
$folders = [];
-
- $matches = false;
$first = true;
- $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- $categories[] = [
- 'name' => XML::escape(FileTag::decode($mtch[1])),
- 'url' => "#",
- 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::escape(FileTag::decode($mtch[1])):""),
- 'first' => $first,
- 'last' => false
- ];
- $first = false;
- }
+
+ foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
+ $categories[] = [
+ 'name' => $savedFolderName,
+ 'url' => "#",
+ 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
+ 'first' => $first,
+ 'last' => false
+ ];
+ $first = false;
}
if (count($categories)) {
}
if (local_user() == $item['uid']) {
- $matches = false;
- $first = true;
- $cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
- if ($cnt) {
- foreach ($matches as $mtch) {
- $folders[] = [
- 'name' => XML::escape(FileTag::decode($mtch[1])),
- 'url' => "#",
- 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::escape(FileTag::decode($mtch[1])) : ""),
- 'first' => $first,
- 'last' => false
- ];
- $first = false;
- }
+ foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
+ $folders[] = [
+ 'name' => $savedFolderName,
+ 'url' => "#",
+ 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
+ 'first' => $first,
+ 'last' => false
+ ];
+ $first = false;
}
}
/**
* return number of bytes in size (K, M, G)
* @param string $size_str
- * @return number
+ * @return int
*/
function return_bytes($size_str) {
switch (substr ($size_str, -1)) {