mirror of
https://github.com/friendica/friendica
synced 2025-04-22 04:30:10 +00:00
Merge pull request #8156 from MrPetovan/task/7817-custom-fields-part-2
New custom profile fields feature part 2: Feature switcheroo
This commit is contained in:
commit
09de4a5b47
86 changed files with 2352 additions and 3855 deletions
|
@ -35,9 +35,9 @@ class BaseSettingsModule extends BaseModule
|
|||
];
|
||||
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Profiles'),
|
||||
'url' => 'profiles',
|
||||
'selected' => (($a->argc == 1) && ($a->argv[0] === 'profiles') ? 'active' : ''),
|
||||
'label' => DI::l10n()->t('Profile'),
|
||||
'url' => 'settings/profile',
|
||||
'selected' => (($a->argc > 1) && ($a->argv[1] === 'profile') ? 'active' : ''),
|
||||
'accesskey' => 'p',
|
||||
];
|
||||
|
||||
|
|
|
@ -100,14 +100,6 @@ class Contact extends BaseModule
|
|||
|
||||
Hook::callAll('contact_edit_post', $_POST);
|
||||
|
||||
$profile_id = intval($_POST['profile-assign'] ?? 0);
|
||||
if ($profile_id) {
|
||||
if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
|
||||
notice(DI::l10n()->t('Could not locate selected profile.') . EOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$hidden = !empty($_POST['hidden']);
|
||||
|
||||
$notify = !empty($_POST['notify']);
|
||||
|
@ -124,7 +116,6 @@ class Contact extends BaseModule
|
|||
$info = Strings::escapeHtml(trim($_POST['info'] ?? ''));
|
||||
|
||||
$r = DBA::update('contact', [
|
||||
'profile-id' => $profile_id,
|
||||
'priority' => $priority,
|
||||
'info' => $info,
|
||||
'hidden' => $hidden,
|
||||
|
@ -555,20 +546,13 @@ class Contact extends BaseModule
|
|||
$poll_interval = ContactSelector::pollInterval($contact['priority'], !$poll_enabled);
|
||||
}
|
||||
|
||||
$profile_select = null;
|
||||
if ($contact['network'] == Protocol::DFRN) {
|
||||
$profile_select = ContactSelector::profileAssign($contact['profile-id'], $contact['network'] !== Protocol::DFRN);
|
||||
}
|
||||
|
||||
// Load contactact related actions like hide, suggest, delete and others
|
||||
$contact_actions = self::getContactActions($contact);
|
||||
|
||||
if ($contact['uid'] != 0) {
|
||||
$lbl_vis1 = DI::l10n()->t('Profile Visibility');
|
||||
$lbl_info1 = DI::l10n()->t('Contact Information / Notes');
|
||||
$contact_settings_label = DI::l10n()->t('Contact Settings');
|
||||
} else {
|
||||
$lbl_vis1 = null;
|
||||
$lbl_info1 = null;
|
||||
$contact_settings_label = null;
|
||||
}
|
||||
|
@ -578,8 +562,6 @@ class Contact extends BaseModule
|
|||
'$header' => DI::l10n()->t('Contact'),
|
||||
'$tab_str' => $tab_str,
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$lbl_vis1' => $lbl_vis1,
|
||||
'$lbl_vis2' => DI::l10n()->t('Please choose the profile you would like to display to %s when viewing your profile securely.', $contact['name']),
|
||||
'$lbl_info1' => $lbl_info1,
|
||||
'$lbl_info2' => DI::l10n()->t('Their personal note'),
|
||||
'$reason' => trim(Strings::escapeTags($contact['reason'])),
|
||||
|
@ -600,7 +582,6 @@ class Contact extends BaseModule
|
|||
'$updpub' => DI::l10n()->t('Update public posts'),
|
||||
'$last_update' => $last_update,
|
||||
'$udnow' => DI::l10n()->t('Update now'),
|
||||
'$profile_select' => $profile_select,
|
||||
'$contact_id' => $contact['id'],
|
||||
'$block_text' => ($contact['blocked'] ? DI::l10n()->t('Unblock') : DI::l10n()->t('Block')),
|
||||
'$ignore_text' => ($contact['readonly'] ? DI::l10n()->t('Unignore') : DI::l10n()->t('Ignore')),
|
||||
|
|
|
@ -1,361 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
||||
class Profile extends BaseModule
|
||||
{
|
||||
public static $which = '';
|
||||
public static $profile = 0;
|
||||
|
||||
public static function init(array $parameters = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ($a->argc < 2) {
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
self::$which = filter_var($a->argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK);
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if (local_user() && $a->argc > 2 && $a->argv[2] === 'view') {
|
||||
self::$which = $a->user['nickname'];
|
||||
self::$profile = filter_var($a->argv[1], FILTER_SANITIZE_NUMBER_INT);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
if (ActivityPub::isRequest()) {
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
|
||||
if (DBA::isResult($user)) {
|
||||
// The function returns an empty array when the account is removed, expired or blocked
|
||||
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
||||
if (!empty($data)) {
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
||||
if (DBA::exists('userd', ['username' => self::$which])) {
|
||||
// Known deleted user
|
||||
$data = ActivityPub\Transmitter::getDeletedUser(self::$which);
|
||||
|
||||
System::jsonError(410, $data);
|
||||
} else {
|
||||
// Any other case (unknown, blocked, unverified, expired, no profile, no self contact)
|
||||
System::jsonError(404, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [], $update = 0)
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
if (!$update) {
|
||||
ProfileModel::load($a, self::$which, self::$profile);
|
||||
|
||||
$page = DI::page();
|
||||
|
||||
$page['htmlhead'] .= "\n";
|
||||
|
||||
$blocked = !local_user() && !Session::getRemoteContactID($a->profile['uid']) && DI::config()->get('system', 'block_public');
|
||||
$userblock = !local_user() && !Session::getRemoteContactID($a->profile['uid']) && $a->profile['hidewall'];
|
||||
|
||||
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
$page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($a->profile['openidserver'])) {
|
||||
$page['htmlhead'] .= '<link rel="openid.server" href="' . $a->profile['openidserver'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($a->profile['openid'])) {
|
||||
$delegate = strstr($a->profile['openid'], '://') ? $a->profile['openid'] : 'https://' . $a->profile['openid'];
|
||||
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
|
||||
}
|
||||
|
||||
// site block
|
||||
if (!$blocked && !$userblock) {
|
||||
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $a->profile['pub_keywords'] ?? '');
|
||||
if (strlen($keywords)) {
|
||||
$page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
|
||||
|
||||
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
|
||||
$page['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . self::$which . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
|
||||
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . self::$which . '/" title="' . DI::l10n()->t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
|
||||
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . self::$which . '/comments" title="' . DI::l10n()->t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
|
||||
$page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . self::$which . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
|
||||
$uri = urlencode('acct:' . $a->profile['nickname'] . '@' . DI::baseUrl()->getHostname() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''));
|
||||
$page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . DI::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\n";
|
||||
header('Link: <' . DI::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
||||
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
||||
foreach ($dfrn_pages as $dfrn) {
|
||||
$page['htmlhead'] .= '<link rel="dfrn-' . $dfrn . '" href="' . DI::baseUrl() . '/dfrn_' . $dfrn . '/' . self::$which . '" />' . "\n";
|
||||
}
|
||||
$page['htmlhead'] .= '<link rel="dfrn-poco" href="' . DI::baseUrl() . '/poco/' . self::$which . '" />' . "\n";
|
||||
}
|
||||
|
||||
$category = $datequery = $datequery2 = '';
|
||||
|
||||
if ($a->argc > 2) {
|
||||
for ($x = 2; $x < $a->argc; $x ++) {
|
||||
if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
|
||||
if ($datequery) {
|
||||
$datequery2 = Strings::escapeHtml($a->argv[$x]);
|
||||
} else {
|
||||
$datequery = Strings::escapeHtml($a->argv[$x]);
|
||||
}
|
||||
} else {
|
||||
$category = $a->argv[$x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($category)) {
|
||||
$category = $_GET['category'] ?? '';
|
||||
}
|
||||
|
||||
$hashtags = $_GET['tag'] ?? '';
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['uid'])) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($update) {
|
||||
// Ensure we've got a profile owner if updating.
|
||||
$a->profile['uid'] = $update;
|
||||
} elseif ($a->profile['uid'] == local_user()) {
|
||||
Nav::setSelected('home');
|
||||
}
|
||||
|
||||
$remote_contact = Session::getRemoteContactID($a->profile['uid']);
|
||||
$is_owner = local_user() == $a->profile['uid'];
|
||||
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact;
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
|
||||
notice(DI::l10n()->t('Access to this profile has been restricted.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$update) {
|
||||
$tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
|
||||
|
||||
$o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
|
||||
|
||||
if ($tab === 'profile') {
|
||||
$o .= ProfileModel::getAdvanced($a);
|
||||
Hook::callAll('profile_advanced', $o);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$o .= Widget::commonFriendsVisitor($a->profile['uid']);
|
||||
|
||||
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
$commvisitor = $commpage && $remote_contact;
|
||||
|
||||
DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl()->get(true) . '/profile/' . $a->profile['nickname'], $a->profile['uid'] ?? 0, true);
|
||||
DI::page()['aside'] .= Widget::categories(DI::baseUrl()->get(true) . '/profile/' . $a->profile['nickname'], XML::escape($category));
|
||||
DI::page()['aside'] .= Widget::tagCloud();
|
||||
|
||||
if (Security::canWriteToUserWall($a->profile['uid'])) {
|
||||
$x = [
|
||||
'is_owner' => $is_owner,
|
||||
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
|
||||
'default_location' => $is_owner ? $a->user['default-location'] : '',
|
||||
'nickname' => $a->profile['nickname'],
|
||||
'lockstate' => is_array($a->user)
|
||||
&& (strlen($a->user['allow_cid'])
|
||||
|| strlen($a->user['allow_gid'])
|
||||
|| strlen($a->user['deny_cid'])
|
||||
|| strlen($a->user['deny_gid'])
|
||||
) ? 'lock' : 'unlock',
|
||||
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->user, true) : '',
|
||||
'bang' => '',
|
||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||
'profile_uid' => $a->profile['uid'],
|
||||
];
|
||||
|
||||
$o .= status_editor($a, $x);
|
||||
}
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']);
|
||||
$sql_extra2 = '';
|
||||
|
||||
$last_updated_array = Session::get('last_updated', []);
|
||||
|
||||
if ($update) {
|
||||
$last_updated = $last_updated_array[$last_updated_key] ?? 0;
|
||||
|
||||
// If the page user is the owner of the page we should query for unseen
|
||||
// items. Otherwise use a timestamp of the last succesful update request.
|
||||
if ($is_owner || !$last_updated) {
|
||||
$sql_extra4 = " AND `item`.`unseen`";
|
||||
} else {
|
||||
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
|
||||
$sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
|
||||
}
|
||||
|
||||
$items_stmt = DBA::p(
|
||||
"SELECT DISTINCT(`parent-uri`) AS `uri`, `item`.`created`
|
||||
FROM `item`
|
||||
INNER JOIN `contact`
|
||||
ON `contact`.`id` = `item`.`contact-id`
|
||||
AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending`
|
||||
WHERE `item`.`uid` = ?
|
||||
AND `item`.`visible`
|
||||
AND (NOT `item`.`deleted` OR `item`.`gravity` = ?)
|
||||
AND NOT `item`.`moderated`
|
||||
AND `item`.`wall`
|
||||
$sql_extra4
|
||||
$sql_extra
|
||||
ORDER BY `item`.`received` DESC",
|
||||
$a->profile['uid'],
|
||||
GRAVITY_ACTIVITY
|
||||
);
|
||||
|
||||
if (!DBA::isResult($items_stmt)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
} else {
|
||||
$sql_post_table = "";
|
||||
|
||||
if (!empty($category)) {
|
||||
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['uid']));
|
||||
}
|
||||
|
||||
if (!empty($hashtags)) {
|
||||
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['uid']));
|
||||
}
|
||||
|
||||
if (!empty($datequery)) {
|
||||
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`received` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
|
||||
}
|
||||
if (!empty($datequery2)) {
|
||||
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`received` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
|
||||
}
|
||||
|
||||
// Does the profile page belong to a forum?
|
||||
// If not then we can improve the performance with an additional condition
|
||||
$condition = ['uid' => $a->profile['uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
|
||||
if (!DBA::exists('user', $condition)) {
|
||||
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
|
||||
} else {
|
||||
$sql_extra3 = "";
|
||||
}
|
||||
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', 10);
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', 20);
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
// a maximum item number which is lower then the user choice
|
||||
if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {
|
||||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString(), $itemspage_network);
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
$items_stmt = DBA::p(
|
||||
"SELECT `item`.`uri`
|
||||
FROM `thread`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
$sql_post_table
|
||||
STRAIGHT_JOIN `contact`
|
||||
ON `contact`.`id` = `thread`.`contact-id`
|
||||
AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending`
|
||||
WHERE `thread`.`uid` = ?
|
||||
AND `thread`.`visible`
|
||||
AND NOT `thread`.`deleted`
|
||||
AND NOT `thread`.`moderated`
|
||||
AND `thread`.`wall`
|
||||
$sql_extra3
|
||||
$sql_extra
|
||||
$sql_extra2
|
||||
ORDER BY `thread`.`received` DESC
|
||||
$pager_sql",
|
||||
$a->profile['uid']
|
||||
);
|
||||
}
|
||||
|
||||
// Set a time stamp for this page. We will make use of it when we
|
||||
// search for new items (update routine)
|
||||
$last_updated_array[$last_updated_key] = time();
|
||||
Session::set('last_updated', $last_updated_array);
|
||||
|
||||
if ($is_owner && !$update && !DI::config()->get('theme', 'hide_eventlist')) {
|
||||
$o .= ProfileModel::getBirthdays();
|
||||
$o .= ProfileModel::getEventsReminderHTML();
|
||||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
}
|
||||
}
|
||||
|
||||
$items = DBA::toArray($items_stmt);
|
||||
|
||||
if ($pager->getStart() == 0 && !empty($a->profile['uid'])) {
|
||||
$pinned_items = Item::selectPinned($a->profile['uid'], ['uri', 'pinned'], ['true' . $sql_extra]);
|
||||
$pinned = Item::inArray($pinned_items);
|
||||
$items = array_merge($items, $pinned);
|
||||
}
|
||||
|
||||
$o .= conversation($a, $items, $pager, 'profile', $update, false, 'pinned_received', $a->profile['uid']);
|
||||
|
||||
if (!$update) {
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
298
src/Module/Profile/Index.php
Normal file
298
src/Module/Profile/Index.php
Normal file
|
@ -0,0 +1,298 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\ForumManager;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\Term;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
class Index extends BaseModule
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
if (ActivityPub::isRequest()) {
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $parameters['nickname']]);
|
||||
if (DBA::isResult($user)) {
|
||||
// The function returns an empty array when the account is removed, expired or blocked
|
||||
$data = ActivityPub\Transmitter::getProfile($user['uid']);
|
||||
if (!empty($data)) {
|
||||
System::jsonExit($data, 'application/activity+json');
|
||||
}
|
||||
}
|
||||
|
||||
if (DBA::exists('userd', ['username' => $parameters['nickname']])) {
|
||||
// Known deleted user
|
||||
$data = ActivityPub\Transmitter::getDeletedUser($parameters['nickname']);
|
||||
|
||||
System::jsonError(410, $data);
|
||||
} else {
|
||||
// Any other case (unknown, blocked, nverified, expired, no profile, no self contact)
|
||||
System::jsonError(404, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
Profile::load($a, $parameters['nickname']);
|
||||
|
||||
if (!$a->profile) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
|
||||
}
|
||||
|
||||
$remote_contact_id = Session::getRemoteContactID($a->profile_uid);
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$is_owner = local_user() == $a->profile_uid;
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
}
|
||||
|
||||
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
DI::page()['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
|
||||
}
|
||||
|
||||
DI::page()['htmlhead'] .= self::buildHtmlHead($a->profile, $parameters['nickname'], $remote_contact_id);
|
||||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$is_owner = local_user() == $a->profile['uid'];
|
||||
$o = Profile::getTabs($a, 'profile', $is_owner, $a->profile['nickname']);
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact_id) {
|
||||
notice(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
return '';
|
||||
}
|
||||
|
||||
$view_as_contacts = [];
|
||||
$view_as_contact_id = 0;
|
||||
if ($is_owner) {
|
||||
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
|
||||
|
||||
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
|
||||
'uid' => local_user(),
|
||||
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
|
||||
'network' => Protocol::DFRN,
|
||||
'blocked' => false,
|
||||
]);
|
||||
|
||||
// User manually provided a contact ID they aren't privy to, silently defaulting to their own view
|
||||
if (!in_array($view_as_contact_id, array_column($view_as_contacts, 'id'))) {
|
||||
$view_as_contact_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$basic_fields = [];
|
||||
|
||||
$basic_fields += self::buildField('fullname', DI::l10n()->t('Full Name:'), $a->profile['name']);
|
||||
|
||||
if (Feature::isEnabled($a->profile_uid, 'profile_membersince')) {
|
||||
$basic_fields += self::buildField(
|
||||
'membersince',
|
||||
DI::l10n()->t('Member since:'),
|
||||
DateTimeFormat::local($a->profile['register_date'])
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($a->profile['dob']) && $a->profile['dob'] > DBA::NULL_DATE) {
|
||||
$year_bd_format = DI::l10n()->t('j F, Y');
|
||||
$short_bd_format = DI::l10n()->t('j F');
|
||||
|
||||
$dob = DI::l10n()->getDay(
|
||||
intval($a->profile['dob']) ?
|
||||
DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
|
||||
: DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
|
||||
);
|
||||
|
||||
$basic_fields += self::buildField('dob', DI::l10n()->t('Birthday:'), $dob);
|
||||
|
||||
if ($age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'])) {
|
||||
$basic_fields += self::buildField('age', DI::l10n()->t('Age: '), DI::l10n()->tt('%d year old', '%d years old', $age));
|
||||
}
|
||||
}
|
||||
|
||||
if ($a->profile['pdesc']) {
|
||||
$basic_fields += self::buildField('pdesc', DI::l10n()->t('Description:'), HTML::toLink($a->profile['pdesc']));
|
||||
}
|
||||
|
||||
if ($a->profile['xmpp']) {
|
||||
$basic_fields += self::buildField('xmpp', DI::l10n()->t('XMPP:'), $a->profile['xmpp']);
|
||||
}
|
||||
|
||||
if ($a->profile['homepage']) {
|
||||
$basic_fields += self::buildField('homepage', DI::l10n()->t('Homepage:'), HTML::toLink($a->profile['homepage']));
|
||||
}
|
||||
|
||||
$o .= Profile::getTabs($a, 'profile', $is_owner, $a->profile['nickname']);
|
||||
if (
|
||||
$a->profile['address']
|
||||
|| $a->profile['locality']
|
||||
|| $a->profile['postal-code']
|
||||
|| $a->profile['region']
|
||||
|| $a->profile['country-name']
|
||||
) {
|
||||
$basic_fields += self::buildField('location', DI::l10n()->t('Location:'), Profile::formatLocation($a->profile));
|
||||
}
|
||||
|
||||
if ($a->profile['pub_keywords']) {
|
||||
$tags = [];
|
||||
foreach (explode(',', $a->profile['pub_keywords']) as $tag_label) {
|
||||
$tags[] = [
|
||||
'url' => '/search?tag=' . $tag_label,
|
||||
'label' => Term::TAG_CHARACTER[Term::HASHTAG] . $tag_label,
|
||||
];
|
||||
}
|
||||
|
||||
$basic_fields += self::buildField('pub_keywords', DI::l10n()->t('Tags:'), $tags);
|
||||
}
|
||||
|
||||
$custom_fields = [];
|
||||
|
||||
// Defaults to the current logged in user self contact id to show self-only fields
|
||||
$contact_id = $view_as_contact_id ?: $remote_contact_id ?: 0;
|
||||
|
||||
if ($is_owner && $contact_id === 0) {
|
||||
$profile_fields = DI::profileField()->selectByUserId($a->profile_uid);
|
||||
} else {
|
||||
$profile_fields = DI::profileField()->selectByContactId($contact_id, $a->profile_uid);
|
||||
}
|
||||
|
||||
foreach ($profile_fields as $profile_field) {
|
||||
$custom_fields += self::buildField(
|
||||
'custom_' . $profile_field->order,
|
||||
$profile_field->label,
|
||||
BBCode::convert($profile_field->value),
|
||||
'aprofile custom'
|
||||
);
|
||||
};
|
||||
|
||||
//show subcribed forum if it is enabled in the usersettings
|
||||
if (Feature::isEnabled($a->profile_uid, 'forumlist_profile')) {
|
||||
$custom_fields += self::buildField(
|
||||
'forumlist',
|
||||
DI::l10n()->t('Forums:'),
|
||||
ForumManager::profileAdvanced($a->profile_uid)
|
||||
);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/index.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$title' => DI::l10n()->t('Profile'),
|
||||
'$view_as_contacts' => $view_as_contacts,
|
||||
'$view_as_contact_id' => $view_as_contact_id,
|
||||
'$view_as' => DI::l10n()->t('View profile as:'),
|
||||
'$basic' => DI::l10n()->t('Basic'),
|
||||
'$advanced' => DI::l10n()->t('Advanced'),
|
||||
'$is_owner' => $a->profile_uid == local_user(),
|
||||
'$query_string' => DI::args()->getQueryString(),
|
||||
'$basic_fields' => $basic_fields,
|
||||
'$custom_fields' => $custom_fields,
|
||||
'$profile' => $a->profile,
|
||||
'$edit_link' => [
|
||||
'url' => DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'),
|
||||
'title' => '',
|
||||
'label' => DI::l10n()->t('Edit profile')
|
||||
],
|
||||
]);
|
||||
|
||||
Hook::callAll('profile_advanced', $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a profile field structure to be used in the profile template
|
||||
*
|
||||
* @param string $name Arbitrary name of the field
|
||||
* @param string $label Display label of the field
|
||||
* @param mixed $value Display value of the field
|
||||
* @param string $class Optional CSS class to apply to the field
|
||||
* @return array
|
||||
*/
|
||||
private static function buildField(string $name, string $label, $value, string $class = 'aprofile')
|
||||
{
|
||||
return [$name => [
|
||||
'id' => 'aprofile-' . $name,
|
||||
'class' => $class,
|
||||
'label' => $label,
|
||||
'value' => $value,
|
||||
]];
|
||||
}
|
||||
|
||||
private static function buildHtmlHead(array $profile, string $nickname, int $remote_contact_id)
|
||||
{
|
||||
$baseUrl = DI::baseUrl();
|
||||
|
||||
$htmlhead = "\n";
|
||||
|
||||
if (!empty($profile['page-flags']) && $profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
|
||||
$htmlhead .= '<meta name="friendica.community" content="true" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($profile['openidserver'])) {
|
||||
$htmlhead .= '<link rel="openid.server" href="' . $profile['openidserver'] . '" />' . "\n";
|
||||
}
|
||||
|
||||
if (!empty($profile['openid'])) {
|
||||
$delegate = strstr($profile['openid'], '://') ? $profile['openid'] : 'https://' . $profile['openid'];
|
||||
$htmlhead .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\n";
|
||||
}
|
||||
|
||||
// site block
|
||||
$blocked = !local_user() && !$remote_contact_id && DI::config()->get('system', 'block_public');
|
||||
$userblock = !local_user() && !$remote_contact_id && $profile['hidewall'];
|
||||
if (!$blocked && !$userblock) {
|
||||
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
|
||||
if (strlen($keywords)) {
|
||||
$htmlhead .= '<meta name="keywords" content="' . $keywords . '" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$htmlhead .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\n";
|
||||
|
||||
if (!$profile['net-publish'] || $profile['hidewall']) {
|
||||
$htmlhead .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $profile['username']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/" title="' . DI::l10n()->t('%s\'s posts', $profile['username']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/comments" title="' . DI::l10n()->t('%s\'s comments', $profile['username']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/feed/' . $nickname . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $profile['username']) . '"/>' . "\n";
|
||||
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHostname() . ($baseUrl->getUrlPath() ? '/' . $baseUrl->getUrlPath() : ''));
|
||||
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
|
||||
header('Link: <' . $baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
||||
$dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
|
||||
foreach ($dfrn_pages as $dfrn) {
|
||||
$htmlhead .= '<link rel="dfrn-' . $dfrn . '" href="' . $baseUrl . '/dfrn_' . $dfrn . '/' . $nickname . '" />' . "\n";
|
||||
}
|
||||
$htmlhead .= '<link rel="dfrn-poco" href="' . $baseUrl . '/poco/' . $nickname . '" />' . "\n";
|
||||
|
||||
return $htmlhead;
|
||||
}
|
||||
}
|
215
src/Module/Profile/Status.php
Normal file
215
src/Module/Profile/Status.php
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
class Status extends BaseModule
|
||||
{
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
$args = DI::args();
|
||||
|
||||
$a = DI::app();
|
||||
|
||||
ProfileModel::load($a, $parameters['nickname']);
|
||||
|
||||
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
|
||||
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/dfrn_poll/' . $parameters['nickname'] . '" title="DFRN: ' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/" title="' . DI::l10n()->t('%s\'s posts', $a->profile['username']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/comments" title="' . DI::l10n()->t('%s\'s comments', $a->profile['username']) . '"/>' . "\n";
|
||||
DI::page()['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . DI::baseUrl() . '/feed/' . $parameters['nickname'] . '/activity" title="' . DI::l10n()->t('%s\'s timeline', $a->profile['username']) . '"/>' . "\n";
|
||||
|
||||
$category = $datequery = $datequery2 = '';
|
||||
|
||||
$dtFormat = DI::dtFormat();
|
||||
|
||||
if ($args->getArgc() > 2) {
|
||||
for ($x = 2; $x < $args->getArgc(); $x++) {
|
||||
if ($dtFormat->isYearMonth($args->get($x))) {
|
||||
if ($datequery) {
|
||||
$datequery2 = Strings::escapeHtml($args->get($x));
|
||||
} else {
|
||||
$datequery = Strings::escapeHtml($args->get($x));
|
||||
}
|
||||
} else {
|
||||
$category = $args->get($x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($category)) {
|
||||
$category = $_GET['category'] ?? '';
|
||||
}
|
||||
|
||||
$hashtags = $_GET['tag'] ?? '';
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['uid'])) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($a->profile['uid'] == local_user()) {
|
||||
Nav::setSelected('home');
|
||||
}
|
||||
|
||||
$remote_contact = Session::getRemoteContactID($a->profile['uid']);
|
||||
$is_owner = local_user() == $a->profile['uid'];
|
||||
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact;
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
|
||||
notice(DI::l10n()->t('Access to this profile has been restricted.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
||||
$o .= ProfileModel::getTabs($a, 'status', $is_owner, $a->profile['nickname']);
|
||||
|
||||
$o .= Widget::commonFriendsVisitor($a->profile['uid']);
|
||||
|
||||
$commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
$commvisitor = $commpage && $remote_contact;
|
||||
|
||||
DI::page()['aside'] .= Widget::postedByYear(DI::baseUrl() . '/profile/' . $a->profile['nickname'] . '/status', $a->profile['profile_uid'] ?? 0, true);
|
||||
DI::page()['aside'] .= Widget::categories(DI::baseUrl() . '/profile/' . $a->profile['nickname'] . '/status', XML::escape($category));
|
||||
DI::page()['aside'] .= Widget::tagCloud();
|
||||
|
||||
if (Security::canWriteToUserWall($a->profile['uid'])) {
|
||||
$x = [
|
||||
'is_owner' => $is_owner,
|
||||
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
|
||||
'default_location' => $is_owner ? $a->user['default-location'] : '',
|
||||
'nickname' => $a->profile['nickname'],
|
||||
'lockstate' => is_array($a->user)
|
||||
&& (strlen($a->user['allow_cid'])
|
||||
|| strlen($a->user['allow_gid'])
|
||||
|| strlen($a->user['deny_cid'])
|
||||
|| strlen($a->user['deny_gid'])
|
||||
) ? 'lock' : 'unlock',
|
||||
'acl' => $is_owner ? ACL::getFullSelectorHTML(DI::page(), $a->user, true) : '',
|
||||
'bang' => '',
|
||||
'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
|
||||
'profile_uid' => $a->profile['uid'],
|
||||
];
|
||||
|
||||
$o .= status_editor($a, $x);
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']);
|
||||
$sql_extra2 = '';
|
||||
|
||||
$last_updated_array = Session::get('last_updated', []);
|
||||
|
||||
$sql_post_table = "";
|
||||
|
||||
if (!empty($category)) {
|
||||
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['uid']));
|
||||
}
|
||||
|
||||
if (!empty($hashtags)) {
|
||||
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['uid']));
|
||||
}
|
||||
|
||||
if (!empty($datequery)) {
|
||||
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`received` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
|
||||
}
|
||||
if (!empty($datequery2)) {
|
||||
$sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`received` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
|
||||
}
|
||||
|
||||
// Does the profile page belong to a forum?
|
||||
// If not then we can improve the performance with an additional condition
|
||||
$condition = ['uid' => $a->profile['uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
|
||||
if (!DBA::exists('user', $condition)) {
|
||||
$sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
|
||||
} else {
|
||||
$sql_extra3 = "";
|
||||
}
|
||||
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', 10);
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', 20);
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
// a maximum item number which is lower then the user choice
|
||||
if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {
|
||||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$pager = new Pager($args->getQueryString(), $itemspage_network);
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
$items_stmt = DBA::p(
|
||||
"SELECT `item`.`uri`
|
||||
FROM `thread`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
$sql_post_table
|
||||
STRAIGHT_JOIN `contact`
|
||||
ON `contact`.`id` = `thread`.`contact-id`
|
||||
AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending`
|
||||
WHERE `thread`.`uid` = ?
|
||||
AND `thread`.`visible`
|
||||
AND NOT `thread`.`deleted`
|
||||
AND NOT `thread`.`moderated`
|
||||
AND `thread`.`wall`
|
||||
$sql_extra3
|
||||
$sql_extra
|
||||
$sql_extra2
|
||||
ORDER BY `thread`.`received` DESC
|
||||
$pager_sql",
|
||||
$a->profile['uid']
|
||||
);
|
||||
|
||||
// Set a time stamp for this page. We will make use of it when we
|
||||
// search for new items (update routine)
|
||||
$last_updated_array[$last_updated_key] = time();
|
||||
Session::set('last_updated', $last_updated_array);
|
||||
|
||||
if ($is_owner && !DI::config()->get('theme', 'hide_eventlist')) {
|
||||
$o .= ProfileModel::getBirthdays();
|
||||
$o .= ProfileModel::getEventsReminderHTML();
|
||||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
}
|
||||
}
|
||||
|
||||
$items = DBA::toArray($items_stmt);
|
||||
|
||||
$o .= conversation($a, $items, $pager, 'profile', false, false, 'received', $a->profile['uid']);
|
||||
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
306
src/Module/Settings/Profile/Index.php
Normal file
306
src/Module/Settings/Profile/Index.php
Normal file
|
@ -0,0 +1,306 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Settings\Profile;
|
||||
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\ProfileField;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseSettingsModule;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
class Index extends BaseSettingsModule
|
||||
{
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = Profile::getByUID(local_user());
|
||||
if (!DBA::isResult($profile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('/settings/profile', 'settings_profile');
|
||||
|
||||
Hook::callAll('profile_post', $_POST);
|
||||
|
||||
$dob = Strings::escapeHtml(trim($_POST['dob'] ?? '0000-00-00'));
|
||||
|
||||
$y = substr($dob, 0, 4);
|
||||
if ((!ctype_digit($y)) || ($y < 1900)) {
|
||||
$ignore_year = true;
|
||||
} else {
|
||||
$ignore_year = false;
|
||||
}
|
||||
|
||||
if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) {
|
||||
if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
|
||||
$ignore_year = true;
|
||||
$dob = substr($dob, 5);
|
||||
}
|
||||
|
||||
if ($ignore_year) {
|
||||
$dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
|
||||
} else {
|
||||
$dob = DateTimeFormat::utc($dob, 'Y-m-d');
|
||||
}
|
||||
}
|
||||
|
||||
$name = Strings::escapeTags(trim($_POST['name'] ?? ''));
|
||||
if (!strlen($name)) {
|
||||
notice(DI::l10n()->t('Profile Name is required.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$namechanged = $profile['name'] != $name;
|
||||
|
||||
$pdesc = Strings::escapeTags(trim($_POST['pdesc']));
|
||||
$address = Strings::escapeTags(trim($_POST['address']));
|
||||
$locality = Strings::escapeTags(trim($_POST['locality']));
|
||||
$region = Strings::escapeTags(trim($_POST['region']));
|
||||
$postal_code = Strings::escapeTags(trim($_POST['postal_code']));
|
||||
$country_name = Strings::escapeTags(trim($_POST['country_name']));
|
||||
$pub_keywords = self::cleanKeywords(Strings::escapeTags(trim($_POST['pub_keywords'])));
|
||||
$prv_keywords = self::cleanKeywords(Strings::escapeTags(trim($_POST['prv_keywords'])));
|
||||
$xmpp = Strings::escapeTags(trim($_POST['xmpp']));
|
||||
$homepage = Strings::escapeTags(trim($_POST['homepage']));
|
||||
if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
|
||||
// neither http nor https in URL, add them
|
||||
$homepage = 'http://' . $homepage;
|
||||
}
|
||||
|
||||
$hide_friends = intval(!empty($_POST['hide-friends']));
|
||||
|
||||
$profileFields = DI::profileField()->selectByUserId(local_user());
|
||||
|
||||
$profileFields = DI::profileField()->updateCollectionFromForm(
|
||||
local_user(),
|
||||
$profileFields,
|
||||
$_REQUEST['profile_field'],
|
||||
$_REQUEST['profile_field_order']
|
||||
);
|
||||
|
||||
DI::profileField()->saveCollection($profileFields);
|
||||
|
||||
$result = DBA::update(
|
||||
'profile',
|
||||
[
|
||||
'name' => $name,
|
||||
'pdesc' => $pdesc,
|
||||
'dob' => $dob,
|
||||
'address' => $address,
|
||||
'locality' => $locality,
|
||||
'region' => $region,
|
||||
'postal-code' => $postal_code,
|
||||
'country-name' => $country_name,
|
||||
'xmpp' => $xmpp,
|
||||
'homepage' => $homepage,
|
||||
'pub_keywords' => $pub_keywords,
|
||||
'prv_keywords' => $prv_keywords,
|
||||
'hide-friends' => $hide_friends,
|
||||
],
|
||||
['uid' => local_user()]
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
info(DI::l10n()->t('Profile updated.'));
|
||||
} else {
|
||||
notice(DI::l10n()->t('Profile couldn\'t be updated.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($namechanged) {
|
||||
DBA::update('user', ['username' => $name], ['uid' => local_user()]);
|
||||
}
|
||||
|
||||
Contact::updateSelfFromUserID(local_user());
|
||||
|
||||
// Update global directory in background
|
||||
if (Session::get('my_url') && strlen(DI::config()->get('system', 'directory'))) {
|
||||
Worker::add(PRIORITY_LOW, 'Directory', Session::get('my_url'));
|
||||
}
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
|
||||
|
||||
// Update the global contact for the user
|
||||
GContact::updateForUser(local_user());
|
||||
}
|
||||
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
if (!local_user()) {
|
||||
notice(DI::l10n()->t('You must be logged in to use this module'));
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
parent::content();
|
||||
|
||||
$o = '';
|
||||
|
||||
$profile = Profile::getByUID(local_user());
|
||||
if (!DBA::isResult($profile)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$a = DI::app();
|
||||
|
||||
DI::page()->registerFooterScript('view/asset/es-jquery-sortable/source/js/jquery-sortable-min.js');
|
||||
DI::page()->registerFooterScript(Theme::getPathForFile('js/module/settings/profile/index.js'));
|
||||
|
||||
$custom_fields = [];
|
||||
|
||||
$profileFields = DI::profileField()->selectByUserId(local_user());
|
||||
foreach ($profileFields as $profileField) {
|
||||
/** @var ProfileField $profileField */
|
||||
$defaultPermissions = ACL::getDefaultUserPermissions($profileField->permissionset->toArray());
|
||||
|
||||
$custom_fields[] = [
|
||||
'id' => $profileField->id,
|
||||
'legend' => $profileField->label,
|
||||
'fields' => [
|
||||
'label' => ['profile_field[' . $profileField->id . '][label]', DI::l10n()->t('Label:'), $profileField->label],
|
||||
'value' => ['profile_field[' . $profileField->id . '][value]', DI::l10n()->t('Value:'), $profileField->value],
|
||||
'acl' => ACL::getFullSelectorHTML(
|
||||
DI::page(),
|
||||
$a->user,
|
||||
false,
|
||||
$defaultPermissions,
|
||||
['network' => Protocol::DFRN],
|
||||
'profile_field[' . $profileField->id . ']'
|
||||
),
|
||||
],
|
||||
'permissions' => DI::l10n()->t('Field Permissions'),
|
||||
'permdesc' => DI::l10n()->t("(click to open/close)"),
|
||||
];
|
||||
};
|
||||
|
||||
$custom_fields[] = [
|
||||
'id' => 'new',
|
||||
'legend' => DI::l10n()->t('Add a new profile field'),
|
||||
'fields' => [
|
||||
'label' => ['profile_field[new][label]', DI::l10n()->t('Label:')],
|
||||
'value' => ['profile_field[new][value]', DI::l10n()->t('Value:')],
|
||||
'acl' => ACL::getFullSelectorHTML(
|
||||
DI::page(),
|
||||
$a->user,
|
||||
false,
|
||||
['allow_cid' => []],
|
||||
['network' => Protocol::DFRN],
|
||||
'profile_field[new]'
|
||||
),
|
||||
],
|
||||
'permissions' => DI::l10n()->t('Field Permissions'),
|
||||
'permdesc' => DI::l10n()->t("(click to open/close)"),
|
||||
];
|
||||
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/profile/index_head.tpl'), [
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
]);
|
||||
|
||||
$opt_tpl = Renderer::getMarkupTemplate('settings/profile/hide-friends.tpl');
|
||||
$hide_friends = Renderer::replaceMacros($opt_tpl, [
|
||||
'$yesno' => [
|
||||
'hide-friends', //Name
|
||||
DI::l10n()->t('Hide contacts and friends:'), //Label
|
||||
!!$profile['hide-friends'], //Value
|
||||
'', //Help string
|
||||
[DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
|
||||
],
|
||||
'$desc' => DI::l10n()->t('Hide your contact/friend list from viewers of this profile?'),
|
||||
'$yes_str' => DI::l10n()->t('Yes'),
|
||||
'$no_str' => DI::l10n()->t('No'),
|
||||
'$yes_selected' => (($profile['hide-friends']) ? ' checked="checked"' : ''),
|
||||
'$no_selected' => (($profile['hide-friends'] == 0) ? ' checked="checked"' : '')
|
||||
]);
|
||||
|
||||
$personal_account = !in_array($a->user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('settings/profile/index.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$personal_account' => $personal_account,
|
||||
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_profile'),
|
||||
'$form_security_token_photo' => self::getFormSecurityToken('settings_profile_photo'),
|
||||
|
||||
'$profile_action' => DI::l10n()->t('Profile Actions'),
|
||||
'$banner' => DI::l10n()->t('Edit Profile Details'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$profpic' => DI::l10n()->t('Change Profile Photo'),
|
||||
'$profpiclink' => '/photos/' . $a->user['nickname'],
|
||||
'$viewprof' => DI::l10n()->t('View this profile'),
|
||||
|
||||
'$lbl_personal_section' => DI::l10n()->t('Personal'),
|
||||
'$lbl_picture_section' => DI::l10n()->t('Profile picture'),
|
||||
'$lbl_location_section' => DI::l10n()->t('Location'),
|
||||
'$lbl_miscellaneous_section' => DI::l10n()->t('Miscellaneous'),
|
||||
'$lbl_custom_fields_section' => DI::l10n()->t('Custom Profile Fields'),
|
||||
|
||||
'$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'),
|
||||
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$nickname' => $a->user['nickname'],
|
||||
'$name' => ['name', DI::l10n()->t('Display name:'), $profile['name']],
|
||||
'$pdesc' => ['pdesc', DI::l10n()->t('Title/Description:'), $profile['pdesc']],
|
||||
'$dob' => Temporal::getDateofBirthField($profile['dob'], $a->user['timezone']),
|
||||
'$hide_friends' => $hide_friends,
|
||||
'$address' => ['address', DI::l10n()->t('Street Address:'), $profile['address']],
|
||||
'$locality' => ['locality', DI::l10n()->t('Locality/City:'), $profile['locality']],
|
||||
'$region' => ['region', DI::l10n()->t('Region/State:'), $profile['region']],
|
||||
'$postal_code' => ['postal_code', DI::l10n()->t('Postal/Zip Code:'), $profile['postal-code']],
|
||||
'$country_name' => ['country_name', DI::l10n()->t('Country:'), $profile['country-name']],
|
||||
'$age' => ((intval($profile['dob'])) ? '(' . DI::l10n()->t('Age: ') . DI::l10n()->tt('%d year old', '%d years old', Temporal::getAgeByTimezone($profile['dob'], $a->user['timezone'])) . ')' : ''),
|
||||
'$xmpp' => ['xmpp', DI::l10n()->t('XMPP (Jabber) address:'), $profile['xmpp'], DI::l10n()->t('The XMPP address will be propagated to your contacts so that they can follow you.')],
|
||||
'$homepage' => ['homepage', DI::l10n()->t('Homepage URL:'), $profile['homepage']],
|
||||
'$pub_keywords' => ['pub_keywords', DI::l10n()->t('Public Keywords:'), $profile['pub_keywords'], DI::l10n()->t('(Used for suggesting potential friends, can be seen by others)')],
|
||||
'$prv_keywords' => ['prv_keywords', DI::l10n()->t('Private Keywords:'), $profile['prv_keywords'], DI::l10n()->t('(Used for searching profiles, never shown to others)')],
|
||||
'$custom_fields_description' => DI::l10n()->t("<p>Custom fields appear on <a href=\"%s\">your profile page</a>.</p>
|
||||
<p>You can use BBCodes in the field values.</p>
|
||||
<p>Reorder by dragging the field title.</p>
|
||||
<p>Empty the label field to remove a custom field.</p>
|
||||
<p>Non-public fields can only be seen by the selected Friendica contacts or the Friendica contacts in the selected groups.</p>",
|
||||
'profile/' . $a->user['nickname']
|
||||
),
|
||||
'$custom_fields' => $custom_fields,
|
||||
]);
|
||||
|
||||
$arr = ['profile' => $profile, 'entry' => $o];
|
||||
Hook::callAll('profile_edit', $arr);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
private static function cleanKeywords($keywords)
|
||||
{
|
||||
$keywords = str_replace(',', ' ', $keywords);
|
||||
$keywords = explode(' ', $keywords);
|
||||
|
||||
$cleaned = [];
|
||||
foreach ($keywords as $keyword) {
|
||||
$keyword = trim(strtolower($keyword));
|
||||
$keyword = trim($keyword, '#');
|
||||
if ($keyword != '') {
|
||||
$cleaned[] = $keyword;
|
||||
}
|
||||
}
|
||||
|
||||
$keywords = implode(', ', $cleaned);
|
||||
|
||||
return $keywords;
|
||||
}
|
||||
}
|
|
@ -167,7 +167,11 @@ class UserExport extends BaseSettingsModule
|
|||
|
||||
|
||||
$profile = self::exportMultiRow(
|
||||
sprintf("SELECT * FROM `profile` WHERE `uid` = %d ", intval(local_user()))
|
||||
sprintf("SELECT *, 'default' AS `profile_name`, 1 AS `is-default` FROM `profile` WHERE `uid` = %d ", intval(local_user()))
|
||||
);
|
||||
|
||||
$profile_fields = self::exportMultiRow(
|
||||
sprintf("SELECT * FROM `profile_field` WHERE `uid` = %d ", intval(local_user()))
|
||||
);
|
||||
|
||||
$photo = self::exportMultiRow(
|
||||
|
@ -196,6 +200,7 @@ class UserExport extends BaseSettingsModule
|
|||
'user' => $user,
|
||||
'contact' => $contact,
|
||||
'profile' => $profile,
|
||||
'profile_fields' => $profile_fields,
|
||||
'photo' => $photo,
|
||||
'pconfig' => $pconfig,
|
||||
'group' => $group,
|
||||
|
|
125
src/Module/Update/Profile.php
Normal file
125
src/Module/Update/Profile.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Update;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
use Friendica\Network\HTTPException\ForbiddenException;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
class Profile extends BaseModule
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['uid'])) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
$profile_uid = intval($_GET['p'] ?? 0);
|
||||
|
||||
// Ensure we've got a profile owner if updating.
|
||||
$a->profile['uid'] = $profile_uid;
|
||||
|
||||
$remote_contact = Session::getRemoteContactID($a->profile['uid']);
|
||||
$is_owner = local_user() == $a->profile['uid'];
|
||||
$last_updated_key = "profile:" . $a->profile['uid'] . ":" . local_user() . ":" . $remote_contact;
|
||||
|
||||
if (!empty($a->profile['hidewall']) && !$is_owner && !$remote_contact) {
|
||||
throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
}
|
||||
|
||||
// Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
|
||||
$sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']);
|
||||
|
||||
$last_updated_array = Session::get('last_updated', []);
|
||||
|
||||
$last_updated = $last_updated_array[$last_updated_key] ?? 0;
|
||||
|
||||
// If the page user is the owner of the page we should query for unseen
|
||||
// items. Otherwise use a timestamp of the last succesful update request.
|
||||
if ($is_owner || !$last_updated) {
|
||||
$sql_extra4 = " AND `item`.`unseen`";
|
||||
} else {
|
||||
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
|
||||
$sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
|
||||
}
|
||||
|
||||
$items_stmt = DBA::p(
|
||||
"SELECT DISTINCT(`parent-uri`) AS `uri`, `item`.`created`
|
||||
FROM `item`
|
||||
INNER JOIN `contact`
|
||||
ON `contact`.`id` = `item`.`contact-id`
|
||||
AND NOT `contact`.`blocked`
|
||||
AND NOT `contact`.`pending`
|
||||
WHERE `item`.`uid` = ?
|
||||
AND `item`.`visible`
|
||||
AND (NOT `item`.`deleted` OR `item`.`gravity` = ?)
|
||||
AND NOT `item`.`moderated`
|
||||
AND `item`.`wall`
|
||||
$sql_extra4
|
||||
$sql_extra
|
||||
ORDER BY `item`.`received` DESC",
|
||||
$a->profile['uid'],
|
||||
GRAVITY_ACTIVITY
|
||||
);
|
||||
|
||||
if (!DBA::isResult($items_stmt)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
|
||||
// Set a time stamp for this page. We will make use of it when we
|
||||
// search for new items (update routine)
|
||||
$last_updated_array[$last_updated_key] = time();
|
||||
Session::set('last_updated', $last_updated_array);
|
||||
|
||||
if ($is_owner && !$profile_uid && !DI::config()->get('theme', 'hide_eventlist')) {
|
||||
$o .= ProfileModel::getBirthdays();
|
||||
$o .= ProfileModel::getEventsReminderHTML();
|
||||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
||||
}
|
||||
}
|
||||
|
||||
$items = DBA::toArray($items_stmt);
|
||||
|
||||
$o .= conversation($a, $items, $pager, 'profile', $profile_uid, false, 'received', $a->profile['uid']);
|
||||
|
||||
header("Content-type: text/html");
|
||||
echo "<!DOCTYPE html><html><body>\r\n";
|
||||
// We can remove this hack once Internet Explorer recognises HTML5 natively
|
||||
echo "<section>";
|
||||
echo $o;
|
||||
if (DI::pConfig()->get(local_user(), "system", "bandwidth_saver")) {
|
||||
$replace = "<br />".DI::l10n()->t("[Embedded content - reload page to view]")."<br />";
|
||||
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
}
|
||||
|
||||
// reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
|
||||
echo str_replace("\t", " ", $o);
|
||||
echo "</section>";
|
||||
echo "</body></html>\r\n";
|
||||
exit();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue