Fix code style

This commit is contained in:
Art4 2025-01-13 13:31:54 +00:00
parent d4697a17a3
commit 0e59dba914
102 changed files with 3038 additions and 2764 deletions

View file

@ -131,10 +131,10 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
$post = DI::contentItem()->initializePost($post);
$post['edit'] = null;
$post['post-type'] = $request['post_type'] ?? '';
$post['wall'] = $request['wall'] ?? true;
$post['post-type'] = $request['post_type'] ?? '';
$post['wall'] = $request['wall'] ?? true;
$post['pubmail'] = $request['pubmail_enable'] ?? false;
$post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
$post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
$post['edited'] = $post['changed'] = $post['commented'] = $post['created'];
$post['app'] = '';
$post['inform'] = '';
@ -167,15 +167,15 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
DI::logger()->info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]);
}
$post['parent'] = $toplevel_item['id'];
$post['gravity'] = Item::GRAVITY_COMMENT;
$post['thr-parent'] = $parent_item['uri'];
$post['wall'] = $toplevel_item['wall'];
$post['parent'] = $toplevel_item['id'];
$post['gravity'] = Item::GRAVITY_COMMENT;
$post['thr-parent'] = $parent_item['uri'];
$post['wall'] = $toplevel_item['wall'];
} else {
$parent_item = [];
$post['parent'] = 0;
$post['gravity'] = Item::GRAVITY_PARENT;
$post['thr-parent'] = $post['uri'];
$parent_item = [];
$post['parent'] = 0;
$post['gravity'] = Item::GRAVITY_PARENT;
$post['thr-parent'] = $post['uri'];
}
$post = DI::contentItem()->getACL($post, $parent_item, $request);

View file

@ -114,8 +114,8 @@ function photos_post()
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$can_post = false;
$visitor = 0;
$can_post = false;
$visitor = 0;
$page_owner_uid = intval($user['uid']);
$community_page = in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_COMM_MAN]);
@ -124,8 +124,8 @@ function photos_post()
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
$can_post = true;
$visitor = $contact_id;
$can_post = true;
$visitor = $contact_id;
}
if (!$can_post) {
@ -141,7 +141,7 @@ function photos_post()
System::exit();
}
$aclFormatter = DI::aclFormatter();
$aclFormatter = DI::aclFormatter();
$str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
$str_circle_allow = isset($_REQUEST['circle_allow']) ? $aclFormatter->toString($_REQUEST['circle_allow']) : $owner_record['allow_gid'] ?? '';
$str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $owner_record['deny_cid'] ?? '';
@ -151,7 +151,7 @@ function photos_post()
if ($visibility === 'public') {
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
$str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_deny = '';
} else if ($visibility === 'custom') {
} elseif ($visibility === 'custom') {
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
// case that would make it public. So we always append the author's contact id to the allowed contacts.
// See https://github.com/friendica/friendica/issues/9672
@ -317,7 +317,7 @@ function photos_post()
if (DBA::isResult($photos)) {
$photo = $photos[0];
$ext = Images::getExtensionByMimeType($photo['type']);
$ext = Images::getExtensionByMimeType($photo['type']);
Photo::update(
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny],
['resource-id' => $resource_id, 'uid' => $page_owner_uid]
@ -332,9 +332,9 @@ function photos_post()
if (DBA::isResult($photos) && !$item_id) {
// Create item container
$title = '';
$uri = Item::newURI();
$uri = Item::newURI();
$arr = [];
$arr = [];
$arr['guid'] = System::createUUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
@ -356,7 +356,7 @@ function photos_post()
$arr['visible'] = 0;
$arr['origin'] = 1;
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
$arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
$item_id = Item::insert($arr);
}
@ -370,7 +370,7 @@ function photos_post()
}
if (strlen($rawtags)) {
$inform = '';
$inform = '';
// if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
$x = substr($rawtags, 0, 1);
@ -379,13 +379,13 @@ function photos_post()
}
$taginfo = [];
$tags = BBCode::getTags($rawtags);
$tags = BBCode::getTags($rawtags);
if (count($tags)) {
foreach ($tags as $tag) {
if (strpos($tag, '@') === 0) {
$profile = '';
$name = substr($tag, 1);
$name = substr($tag, 1);
$contact = Contact::getByURL($name);
if (empty($contact)) {
$newname = $name;
@ -453,7 +453,7 @@ function photos_post()
}
$newinform .= $inform;
$fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
$fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
$condition = ['id' => $item_id];
Item::update($fields, $condition);
@ -552,7 +552,7 @@ function photos_content()
$datum = null;
if (DI::args()->getArgc() > 3) {
$datatype = DI::args()->getArgv()[2];
$datum = DI::args()->getArgv()[3];
$datum = DI::args()->getArgv()[3];
} elseif ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
$datatype = 'upload';
} else {
@ -582,12 +582,12 @@ function photos_content()
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
if (DBA::isResult($contact)) {
$can_post = true;
$can_post = true;
$remote_contact = true;
$visitor = $contact_id;
$visitor = $contact_id;
}
}
@ -643,14 +643,14 @@ function photos_content()
$uploader = '';
$ret = [
'post_url' => 'profile/' . $user['nickname'] . '/photos',
'addon_text' => $uploader,
'post_url' => 'profile/' . $user['nickname'] . '/photos',
'addon_text' => $uploader,
'default_upload' => true
];
Hook::callAll('photo_upload_form', $ret);
$default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
$default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
$default_upload_submit = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_submit.tpl'), [
'$submit' => DI::l10n()->t('Submit'),
]);
@ -675,22 +675,22 @@ function photos_content()
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId()));
$o .= Renderer::replaceMacros($tpl, [
'$pagename' => DI::l10n()->t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
'$nickname' => $user['nickname'],
'$newalbum' => DI::l10n()->t('New album name: '),
'$existalbumtext' => DI::l10n()->t('or select existing album:'),
'$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
'$albumselect' => $albumselect,
'$selname' => $selname,
'$permissions' => DI::l10n()->t('Permissions'),
'$aclselect' => $aclselect_e,
'$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
'$alt_uploader' => $ret['addon_text'],
'$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
'$pagename' => DI::l10n()->t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
'$nickname' => $user['nickname'],
'$newalbum' => DI::l10n()->t('New album name: '),
'$existalbumtext' => DI::l10n()->t('or select existing album:'),
'$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
'$albumselect' => $albumselect,
'$selname' => $selname,
'$permissions' => DI::l10n()->t('Permissions'),
'$aclselect' => $aclselect_e,
'$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
'$alt_uploader' => $ret['addon_text'],
'$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
'$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
'$uploadurl' => $ret['post_url'],
'$uploadurl' => $ret['post_url'],
// ACL permissions box
'$return_path' => DI::args()->getQueryString(),
@ -712,7 +712,7 @@ function photos_content()
}
$total = 0;
$r = DBA::toArray(DBA::p(
$r = DBA::toArray(DBA::p(
"SELECT `resource-id`, MAX(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
$owner_uid,
@ -748,7 +748,7 @@ function photos_content()
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$l10n' => [
'$l10n' => [
'message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
'confirm' => DI::l10n()->t('Delete Album'),
'cancel' => DI::l10n()->t('Cancel'),
@ -768,11 +768,11 @@ function photos_content()
$album_e = $album;
$o .= Renderer::replaceMacros($edit_tpl, [
'$nametext' => DI::l10n()->t('New album name: '),
'$nickname' => $user['nickname'],
'$album' => $album_e,
'$hexalbum' => bin2hex($album),
'$submit' => DI::l10n()->t('Submit'),
'$nametext' => DI::l10n()->t('New album name: '),
'$nickname' => $user['nickname'],
'$album' => $album_e,
'$hexalbum' => bin2hex($album),
'$submit' => DI::l10n()->t('Submit'),
'$dropsubmit' => DI::l10n()->t('Delete Album')
]);
}
@ -782,7 +782,7 @@ function photos_content()
}
if ($order_field === 'created') {
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
} else {
$order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=created', 'newest'];
}
@ -798,7 +798,7 @@ function photos_content()
$ext = Images::getExtensionByMimeType($rr['type']);
$imgalt_e = $rr['filename'];
$desc_e = $rr['desc'];
$desc_e = $rr['desc'];
$photos[] = [
'id' => $rr['id'],
@ -817,13 +817,13 @@ function photos_content()
$tpl = Renderer::getMarkupTemplate('photo_album.tpl');
$o .= Renderer::replaceMacros($tpl, [
'$photos' => $photos,
'$album' => $album,
'$photos' => $photos,
'$album' => $album,
'$can_post' => $can_post,
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
'$order' => $order,
'$edit' => $edit,
'$drop' => $drop,
'$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
'$order' => $order,
'$edit' => $edit,
'$drop' => $drop,
'$paginate' => $pager->renderFull($total),
]);
@ -848,7 +848,7 @@ function photos_content()
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$l10n' => [
'$l10n' => [
'message' => DI::l10n()->t('Do you really want to delete this photo?'),
'confirm' => DI::l10n()->t('Delete Photo'),
'cancel' => DI::l10n()->t('Cancel'),
@ -950,8 +950,8 @@ function photos_content()
if ($cmd === 'edit') {
$tools['view'] = ['photos/' . $user['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')];
} else {
$tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
$tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
$tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
$tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
$tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
}
@ -973,9 +973,9 @@ function photos_content()
'filename' => $hires['filename'],
];
$map = null;
$map = null;
$link_item = [];
$total = 0;
$total = 0;
// Do we have an item for this photo?
@ -989,12 +989,12 @@ function photos_content()
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
$total = Post::count($condition);
$total = Post::count($condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
$items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
@ -1021,51 +1021,51 @@ function photos_content()
$tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr];
if ($cmd === 'edit') {
$tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand());
$tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
$tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
}
}
$edit = Null;
$edit = null;
if ($cmd === 'edit' && $can_post) {
$edit_tpl = Renderer::getMarkupTemplate('photo_edit.tpl');
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
$aclselect_e = ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
$edit = Renderer::replaceMacros($edit_tpl, [
'$id' => $ph[0]['id'],
'$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
'$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
'$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
'$id' => $ph[0]['id'],
'$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
'$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
'$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
'$rotate_none' => ['rotate', DI::l10n()->t('Do not rotate'), 0, '', true],
'$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
'$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
'$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
'$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
'$nickname' => $user['nickname'],
'$nickname' => $user['nickname'],
'$resource_id' => $ph[0]['resource-id'],
'$permissions' => DI::l10n()->t('Permissions'),
'$aclselect' => $aclselect_e,
'$aclselect' => $aclselect_e,
'$item_id' => $link_item['id'] ?? 0,
'$submit' => DI::l10n()->t('Submit'),
'$delete' => DI::l10n()->t('Delete Photo'),
'$submit' => DI::l10n()->t('Submit'),
'$delete' => DI::l10n()->t('Delete Photo'),
// ACL permissions box
'$return_path' => DI::args()->getQueryString(),
]);
}
$like = '';
$dislike = '';
$like = '';
$dislike = '';
$likebuttons = '';
$comments = '';
$paginate = '';
$comments = '';
$paginate = '';
if (!empty($link_item['id']) && !empty($link_item['uri'])) {
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$return_path = DI::args()->getCommand();
if (!DBA::isResult($items)) {
@ -1076,25 +1076,25 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$loading' => DI::l10n()->t('Loading...'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
'$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$loading' => DI::l10n()->t('Loading...'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
]);
}
}
@ -1132,29 +1132,29 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
'$jsreload' => $return_path,
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
]);
}
foreach ($items as $item) {
$comment = '';
$comment = '';
$template = $tpl;
$activity = DI::activity();
@ -1181,7 +1181,7 @@ function photos_content()
}
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
$drop = [
$drop = [
'dropping' => $dropping,
'pagedrop' => false,
'select' => DI::l10n()->t('Select'),
@ -1189,7 +1189,7 @@ function photos_content()
];
$title_e = $item['title'];
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
$comments .= Renderer::replaceMacros($template, [
'$id' => $item['id'],
@ -1212,24 +1212,24 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
'$id' => $item['id'],
'$parent' => $item['parent'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
'$jsreload' => $return_path,
'$id' => $item['id'],
'$parent' => $item['parent'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],
'$mytitle' => DI::l10n()->t('This is you'),
'$myphoto' => $contact['thumb'],
'$comment' => DI::l10n()->t('Comment'),
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
]);
}
}
@ -1243,17 +1243,17 @@ function photos_content()
}
if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
$like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
$likebuttons = Renderer::replaceMacros($like_tpl, [
'$id' => $link_item['id'],
'$like' => DI::l10n()->t('Like'),
'$like_title' => DI::l10n()->t('I like this (toggle)'),
'$dislike' => DI::l10n()->t('Dislike'),
'$wait' => DI::l10n()->t('Please wait'),
'$id' => $link_item['id'],
'$like' => DI::l10n()->t('Like'),
'$like_title' => DI::l10n()->t('I like this (toggle)'),
'$dislike' => DI::l10n()->t('Dislike'),
'$wait' => DI::l10n()->t('Please wait'),
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
'$responses' => $responses,
'$return_path' => DI::args()->getQueryString(),
'$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
'$responses' => $responses,
'$return_path' => DI::args()->getQueryString(),
]);
}
@ -1262,22 +1262,22 @@ function photos_content()
$photo_tpl = Renderer::getMarkupTemplate('photo_view.tpl');
$o .= Renderer::replaceMacros($photo_tpl, [
'$id' => $ph[0]['id'],
'$album' => [$album_link, $ph[0]['album']],
'$tools' => $tools,
'$photo' => $photo,
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
'$desc' => $ph[0]['desc'],
'$tags' => $tags,
'$edit' => $edit,
'$map' => $map,
'$map_text' => DI::l10n()->t('Map'),
'$id' => $ph[0]['id'],
'$album' => [$album_link, $ph[0]['album']],
'$tools' => $tools,
'$photo' => $photo,
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
'$desc' => $ph[0]['desc'],
'$tags' => $tags,
'$edit' => $edit,
'$map' => $map,
'$map_text' => DI::l10n()->t('Map'),
'$likebuttons' => $likebuttons,
'$like' => $like,
'$dislike' => $dislike,
'$comments' => $comments,
'$paginate' => $paginate,
'$like' => $like,
'$dislike' => $dislike,
'$comments' => $comments,
'$paginate' => $paginate,
]);
DI::page()['htmlhead'] .= "\n" . '<meta name="twitter:card" content="summary_large_image" />' . "\n";

View file

@ -81,7 +81,7 @@ class Page implements ArrayAccess
public function __construct(string $basepath)
{
$this->timestamp = microtime(true);
$this->basePath = $basepath;
$this->basePath = $basepath;
}
public function setLogging(string $method, string $module, string $command)
@ -445,7 +445,7 @@ class Page implements ArrayAccess
$this->initContent($response, $mode);
// Load current theme info after module has been initialized as theme could have been set in module
$currentTheme = $appHelper->getCurrentTheme();
$currentTheme = $appHelper->getCurrentTheme();
$theme_info_file = 'view/theme/' . $currentTheme . '/theme.php';
if (file_exists($theme_info_file)) {
require_once $theme_info_file;
@ -479,7 +479,7 @@ class Page implements ArrayAccess
// Add the navigation (menu) template
if ($moduleName != 'install' && $moduleName != 'maintenance') {
$this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('nav_head.tpl'), []);
$this->page['nav'] = $nav->getHtml();
$this->page['nav'] = $nav->getHtml();
}
// Build the page - now that we have all the components
@ -512,7 +512,7 @@ class Page implements ArrayAccess
}
}
$page = $this->page;
$page = $this->page;
// add and escape some common but crucial content for direct "echo" in HTML (security)
$page['title'] = htmlspecialchars($page['title'] ?? '');

View file

@ -215,7 +215,7 @@ class Avatar
}
$avatarpath = parse_url(self::baseUrl(), PHP_URL_PATH);
$pos = strpos($parts['path'], $avatarpath);
$pos = strpos($parts['path'], $avatarpath);
if ($pos !== 0) {
return '';
}

View file

@ -116,8 +116,8 @@ class Item
public function determineCategoriesTerms(array $item, int $uid = 0): array
{
$categories = [];
$folders = [];
$first = true;
$folders = [];
$first = true;
$uid = $item['uid'] ?: $uid;
@ -132,11 +132,11 @@ class Item
$url = '#';
}
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
'name' => $savedFolderName,
'url' => $url,
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
'first' => $first,
'last' => false
];
$first = false;
}
@ -148,11 +148,11 @@ class Item
if ($this->userSession->getLocalUserId() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
'name' => $savedFolderName,
'url' => "#",
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
'first' => $first,
'last' => false
];
$first = false;
}
@ -197,55 +197,55 @@ class Item
// Sometimes the tag detection doesn't seem to work right
// This is some workaround
$nameparts = explode(' ', $name);
$name = $nameparts[0];
$name = $nameparts[0];
// Try to detect the contact in various ways
if (strpos($name, 'http://') || strpos($name, '@')) {
$contact = Contact::getByURLForUser($name, $profile_uid);
} else {
$contact = false;
$fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
$fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
if (strrpos($name, '+')) {
// Is it in format @nick+number?
$tagcid = intval(substr($name, strrpos($name, '+') + 1));
$tagcid = intval(substr($name, strrpos($name, '+') + 1));
$contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
}
// select someone by nick in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['nick' => $name, 'network' => $network, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by attag in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['attag' => $name, 'network' => $network, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
//select someone by name in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['name' => $name, 'network' => $network, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by nick in any network
if (!DBA::isResult($contact)) {
$condition = ['nick' => $name, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by attag in any network
if (!DBA::isResult($contact)) {
$condition = ['attag' => $name, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by name in any network
if (!DBA::isResult($contact)) {
$condition = ['name' => $name, 'uid' => $profile_uid];
$contact = DBA::selectFirst('contact', $fields, $condition);
$contact = DBA::selectFirst('contact', $fields, $condition);
}
}
@ -262,8 +262,8 @@ class Item
$replaced = true;
// create profile link
$profile = str_replace(',', '%2c', $profile);
$newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
$body = str_replace($tag_type . $name, $newtag, $body);
$newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
$body = str_replace($tag_type . $name, $newtag, $body);
}
}
@ -303,7 +303,7 @@ class Item
'url' => $item['author-link'],
'alias' => $item['author-alias'],
];
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
$author_arr = [
'uid' => 0,
@ -312,7 +312,7 @@ class Item
'url' => $obj['author-link'],
'alias' => $obj['author-alias'],
];
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
switch ($obj['verb']) {
case Activity::POST:
@ -340,7 +340,7 @@ class Item
$parsedobj = XML::parseString($xmlhead . $item['object']);
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$item['body'] = $this->l10n->t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
}
}
@ -358,7 +358,7 @@ class Item
public function photoMenu(array $item, string $formSecurityToken): string
{
$this->profiler->startRecording('rendering');
$sub_link = $contact_url = $pm_url = $status_link = '';
$sub_link = $contact_url = $pm_url = $status_link = '';
$photos_link = $posts_link = $block_link = $ignore_link = $collapse_link = $ignoreserver_link = '';
if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
@ -379,16 +379,16 @@ class Item
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
}
$cid = 0;
$pcid = $item['author-id'];
$network = '';
$rel = 0;
$cid = 0;
$pcid = $item['author-id'];
$network = '';
$rel = 0;
$condition = ['uid' => $this->userSession->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
$cid = $contact['id'];
$network = $contact['network'];
$rel = $contact['rel'];
$rel = $contact['rel'];
}
if (!empty($pcid)) {
@ -415,16 +415,16 @@ class Item
if ($this->userSession->getLocalUserId()) {
$menu = [
$this->l10n->t('Follow Thread') => $sub_link,
$this->l10n->t('View Status') => $status_link,
$this->l10n->t('View Profile') => $profile_link,
$this->l10n->t('View Photos') => $photos_link,
$this->l10n->t('Network Posts') => $posts_link,
$this->l10n->t('View Contact') => $contact_url,
$this->l10n->t('Send PM') => $pm_url,
$this->l10n->t('Block') => $block_link,
$this->l10n->t('Ignore') => $ignore_link,
$this->l10n->t('Collapse') => $collapse_link,
$this->l10n->t('Follow Thread') => $sub_link,
$this->l10n->t('View Status') => $status_link,
$this->l10n->t('View Profile') => $profile_link,
$this->l10n->t('View Photos') => $photos_link,
$this->l10n->t('Network Posts') => $posts_link,
$this->l10n->t('View Contact') => $contact_url,
$this->l10n->t('Send PM') => $pm_url,
$this->l10n->t('Block') => $block_link,
$this->l10n->t('Ignore') => $ignore_link,
$this->l10n->t('Collapse') => $collapse_link,
$this->l10n->t("Ignore %s server", $authorBaseUri->getHost()) => $ignoreserver_link,
];
@ -517,13 +517,13 @@ class Item
if (!empty($contact['prv']) || ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION])) {
$private_group = $contact['prv'];
$only_to_group = ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
$private_id = $contact['id'];
$private_id = $contact['id'];
$group_contact = $contact;
DI::logger()->info('Private group or exclusive mention', ['url' => $tag[2], 'mention' => $tag[1]]);
} elseif ($item['allow_cid'] == '<' . $contact['id'] . '>') {
$private_group = false;
$only_to_group = true;
$private_id = $contact['id'];
$private_id = $contact['id'];
$group_contact = $contact;
DI::logger()->info('Public group', ['url' => $tag[2], 'mention' => $tag[1]]);
} else {
@ -561,7 +561,7 @@ class Item
} elseif ($setPermissions) {
if (empty($receivers)) {
// For security reasons direct posts without any receiver will be posts to yourself
$self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
$self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
$receivers[] = $self['id'];
}
@ -605,9 +605,9 @@ class Item
$owner_updated = '';
$owner_thumb = $item['contact-avatar'];
} else {
$owner_avatar = $item['owner-id'];
$owner_updated = $item['owner-updated'];
$owner_thumb = $item['owner-avatar'];
$owner_avatar = $item['owner-id'];
$owner_updated = $item['owner-updated'];
$owner_thumb = $item['owner-avatar'];
}
if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
@ -634,7 +634,7 @@ class Item
return $body;
}
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
$shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id'], 'uid' => [$item['uid'], 0], 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
if (!DBA::isResult($shared_item)) {
DI::logger()->notice('Post does not exist.', ['uri-id' => $item['quote-uri-id'], 'uid' => $item['uid']]);
@ -649,7 +649,7 @@ class Item
*/
private function createSharedPostByGuid(string $guid, bool $add_media): string
{
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
$shared_item = Post::selectFirst($fields, ['guid' => $guid, 'uid' => 0, 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
if (!DBA::isResult($shared_item)) {
@ -800,14 +800,14 @@ class Item
public function storeAttachmentFromRequest(array $request): string
{
$attachment_type = $request['attachment_type'] ?? '';
$attachment_type = $request['attachment_type'] ?? '';
$attachment_title = $request['attachment_title'] ?? '';
$attachment_text = $request['attachment_text'] ?? '';
$attachment_text = $request['attachment_text'] ?? '';
$attachment_url = hex2bin($request['attachment_url'] ?? '');
$attachment_url = hex2bin($request['attachment_url'] ?? '');
$attachment_img_src = hex2bin($request['attachment_img_src'] ?? '');
$attachment_img_width = $request['attachment_img_width'] ?? 0;
$attachment_img_width = $request['attachment_img_width'] ?? 0;
$attachment_img_height = $request['attachment_img_height'] ?? 0;
// Fetch the basic attachment data
@ -815,10 +815,10 @@ class Item
unset($attachment['keywords']);
// Overwrite the basic data with possible changes from the frontend
$attachment['type'] = $attachment_type;
$attachment['type'] = $attachment_type;
$attachment['title'] = $attachment_title;
$attachment['text'] = $attachment_text;
$attachment['url'] = $attachment_url;
$attachment['text'] = $attachment_text;
$attachment['url'] = $attachment_url;
if (!empty($attachment_img_src)) {
$attachment['images'] = [
@ -842,7 +842,7 @@ class Item
$filedas = FileTag::fileToArray($post['file']);
}
$list_array = explode(',', trim($category));
$list_array = explode(',', trim($category));
$post['file'] = FileTag::arrayToFile($list_array, 'category');
if (!empty($filedas) && is_array($filedas)) {
@ -858,8 +858,8 @@ class Item
if ($toplevel_item) {
$post['allow_cid'] = $toplevel_item['allow_cid'] ?? '';
$post['allow_gid'] = $toplevel_item['allow_gid'] ?? '';
$post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
$post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
$post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
$post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
$post['private'] = $toplevel_item['private'];
return $post;
}
@ -878,7 +878,7 @@ class Item
if ($visibility === 'public') {
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
$post['allow_cid'] = $post['allow_gid'] = $post['deny_cid'] = $post['deny_gid'] = '';
} else if ($visibility === 'custom') {
} elseif ($visibility === 'custom') {
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
// case that would make it public. So we always append the author's contact id to the allowed contacts.
// See https://github.com/friendica/friendica/issues/9672
@ -907,7 +907,7 @@ class Item
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || !empty($data['type']))
&& ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)
) {
$post['post-type'] = ItemModel::PT_PAGE;
$post['post-type'] = ItemModel::PT_PAGE;
$post['object-type'] = Activity\ObjectType::BOOKMARK;
}
@ -925,10 +925,10 @@ class Item
$post['direction'] = Conversation::PUSH;
$post['received'] = DateTimeFormat::utcNow();
$post['origin'] = true;
$post['wall'] = $post['wall'] ?? true;
$post['guid'] = $post['guid'] ?? System::createUUID();
$post['verb'] = $post['verb'] ?? Activity::POST;
$post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
$post['wall'] = $post['wall'] ?? true;
$post['guid'] = $post['guid'] ?? System::createUUID();
$post['verb'] = $post['verb'] ?? Activity::POST;
$post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
$post['thr-parent'] = $post['thr-parent'] ?? $post['uri'];
if (empty($post['gravity'])) {
@ -989,7 +989,7 @@ class Item
// Convert links with empty descriptions to links without an explicit description
$post['body'] = trim(preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $post['body']));
$post['body'] = $this->bbCodeVideo->transform($post['body']);
$post = $this->setObjectType($post);
$post = $this->setObjectType($post);
// Personal notes must never be altered to a group post.
if ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE) {
@ -1083,7 +1083,7 @@ class Item
}
if (($expire_interval > 0) && !empty($created)) {
$expire_date = time() - ($expire_interval * 86400);
$expire_date = time() - ($expire_interval * 86400);
$created_date = strtotime($created);
if ($created_date < $expire_date) {
DI::logger()->notice('Item created before expiration interval.', ['created' => date('c', $created_date), 'expired' => date('c', $expire_date)]);

View file

@ -59,7 +59,7 @@ class PageInfo
$body = substr_replace($body, "\n[bookmark=" . $data['url'] . ']' . $linkTitle . "[/bookmark]\n", $existingAttachmentPos, 0);
} else {
$footer = self::getFooterFromData($data, $no_photos);
$body = self::stripTrailingUrlFromBody($body, $data['url']);
$body = self::stripTrailingUrlFromBody($body, $data['url']);
$body .= "\n" . $footer;
}
@ -215,8 +215,11 @@ class PageInfo
$taglist = [];
foreach ($data['keywords'] as $keyword) {
$hashtag = str_replace([' ', '+', '/', '.', '#', "'"],
['', '', '', '', '', ''], $keyword);
$hashtag = str_replace(
[' ', '+', '/', '.', '#', "'"],
['', '', '', '', '', ''],
$keyword
);
$taglist[] = $hashtag;
}
@ -270,7 +273,7 @@ class PageInfo
protected static function stripTrailingUrlFromBody(string $body, string $url): string
{
$quotedUrl = preg_quote($url, '#');
$body = preg_replace_callback("#(?:
$body = preg_replace_callback("#(?:
\[url]$quotedUrl\[/url]|
\[url=$quotedUrl]$quotedUrl\[/url]|
\[url=$quotedUrl]([^[]*?)\[/url]|

View file

@ -130,10 +130,11 @@ class BBCode
break;
case 'title':
$value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
$value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
$data['title'] = self::escapeContent($value);
// no break
default:
$data[$field] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
break;
@ -289,7 +290,7 @@ class BBCode
// Remove all unneeded white space
do {
$oldtext = $text;
$text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
$text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
} while ($oldtext != $text);
return trim($text);
@ -330,12 +331,12 @@ class BBCode
DI::logger()->info('the total body length exceeds the limit', ['maxlen' => $maxlen, 'body_len' => strlen($body)]);
$orig_body = $body;
$new_body = '';
$textlen = 0;
$new_body = '';
$textlen = 0;
$img_start = strpos($orig_body, '[img');
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
while (($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
@ -349,7 +350,7 @@ class BBCode
if ($textlen < $maxlen) {
DI::logger()->debug('the limit happens before an embedded image');
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
$textlen = $maxlen;
$textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_start);
@ -363,7 +364,7 @@ class BBCode
if ($textlen < $maxlen) {
DI::logger()->debug('the limit happens before the end of a non-embedded image');
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
$textlen = $maxlen;
$textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_end);
@ -377,9 +378,9 @@ class BBCode
$orig_body = '';
}
$img_start = strpos($orig_body, '[img');
$img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
}
if (($textlen + strlen($orig_body)) > $maxlen) {
@ -433,7 +434,7 @@ class BBCode
if (((strpos($data['text'], '[img=') !== false) || (strpos($data['text'], '[img]') !== false) || DI::config()->get('system', 'always_show_preview')) && !empty($data['image'])) {
$data['preview'] = $data['image'];
$data['image'] = '';
$data['image'] = '';
}
$return = '';
@ -506,11 +507,11 @@ class BBCode
}
$title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false);
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
$text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
if ($plaintext || (($title != '') && strstr($text, $title))) {
$data['title'] =