]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
escape_tags calls
[friendica.git] / mod / profile.php
index e20836a0598cd55d2fb07f3b59fdff477a0abecc..d07631dced8c592512e8898364476eecd221530b 100644 (file)
@@ -5,11 +5,13 @@
 
 use Friendica\App;
 use Friendica\Content\Nav;
+use Friendica\Content\Pager;
 use Friendica\Content\Widget;
 use Friendica\Core\ACL;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
@@ -18,9 +20,12 @@ use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\Profile;
 use Friendica\Module\Login;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\DFRN;
 use Friendica\Util\DateTimeFormat;
-use Friendica\Protocol\ActivityPub;
+use Friendica\Util\Security;
+use Friendica\Util\Strings;
+use Friendica\Util\XML;
 
 function profile_init(App $a)
 {
@@ -33,9 +38,9 @@ function profile_init(App $a)
        } else {
                $r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1");
                if (DBA::isResult($r)) {
-                       goaway(System::baseUrl() . '/profile/' . $r[0]['nickname']);
+                       $a->internalRedirect('profile/' . $r[0]['nickname']);
                } else {
-                       logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
+                       Logger::log('profile error: mod_profile ' . $a->query_string, Logger::DEBUG);
                        notice(L10n::t('Requested profile is not available.') . EOL);
                        $a->error = 404;
                        return;
@@ -53,7 +58,7 @@ function profile_init(App $a)
        if (ActivityPub::isRequest()) {
                $user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]);
                if (DBA::isResult($user)) {
-                       $data = ActivityPub::profile($user['uid']);
+                       $data = ActivityPub\Transmitter::getProfile($user['uid']);
                        echo json_encode($data);
                        header('Content-Type: application/activity+json');
                        exit();
@@ -91,7 +96,7 @@ function profile_init(App $a)
        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/" title="' . L10n::t('%s\'s posts', $a->profile['username']) . '"/>' . "\r\n";
        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/comments" title="' . L10n::t('%s\'s comments', $a->profile['username']) . '"/>' . "\r\n";
        $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/feed/' . $which . '/activity" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
-       $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''));
+       $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->getHostName() . ($a->getURLPath() ? '/' . $a->getURLPath() : ''));
        $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
        header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
 
@@ -110,9 +115,9 @@ function profile_content(App $a, $update = 0)
                for ($x = 2; $x < $a->argc; $x ++) {
                        if (is_a_date_arg($a->argv[$x])) {
                                if ($datequery) {
-                                       $datequery2 = escape_tags($a->argv[$x]);
+                                       $datequery2 = Strings::escapeTags($a->argv[$x]);
                                } else {
-                                       $datequery = escape_tags($a->argv[$x]);
+                                       $datequery = Strings::escapeTags($a->argv[$x]);
                                }
                        } else {
                                $category = $a->argv[$x];
@@ -130,7 +135,6 @@ function profile_content(App $a, $update = 0)
                return Login::form();
        }
 
-       require_once 'include/security.php';
        require_once 'include/conversation.php';
        require_once 'include/items.php';
 
@@ -190,7 +194,7 @@ function profile_content(App $a, $update = 0)
        if (!$update) {
                $tab = false;
                if (!empty($_GET['tab'])) {
-                       $tab = notags(trim($_GET['tab']));
+                       $tab = Strings::removeTags(trim($_GET['tab']));
                }
 
                $o .= Profile::getTabs($a, $is_owner, $a->profile['nickname']);
@@ -207,10 +211,10 @@ function profile_content(App $a, $update = 0)
                $commvisitor = $commpage && $remote_contact;
 
                $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
-               $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? xmlify($category) : ''));
+               $a->page['aside'] .= Widget::categories(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], (!empty($category) ? XML::escape($category) : ''));
                $a->page['aside'] .= Widget::tagCloud();
 
-               if (can_write_wall($a->profile['profile_uid'])) {
+               if (Security::canWriteToUserWall($a->profile['profile_uid'])) {
                        $x = [
                                'is_owner' => $is_owner,
                                'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
@@ -234,7 +238,7 @@ function profile_content(App $a, $update = 0)
 
 
        // 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_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
+       $sql_extra = Item::getPermissionsSQLByUserId($a->profile['profile_uid'], $remote_contact, $groups);
        $sql_extra2 = '';
 
        if ($update) {
@@ -307,9 +311,9 @@ function profile_content(App $a, $update = 0)
                        $itemspage_network = $a->force_max_items;
                }
 
-               $a->set_pager_itemspage($itemspage_network);
+               $pager = new Pager($a->query_string, $itemspage_network);
 
-               $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
+               $pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
 
                $items = q("SELECT `item`.`uri`
                        FROM `thread`
@@ -344,10 +348,10 @@ function profile_content(App $a, $update = 0)
                }
        }
 
-       $o .= conversation($a, $items, 'profile', $update, false, 'created', local_user());
+       $o .= conversation($a, $items, $pager, 'profile', $update, false, 'created', local_user());
 
        if (!$update) {
-               $o .= alt_pager($a, count($items));
+               $o .= $pager->renderMinimal(count($items));
        }
 
        return $o;