]> git.mxchange.org Git - friendica.git/blobdiff - mod/profile.php
Merge pull request #6170 from annando/safe-save
[friendica.git] / mod / profile.php
index cfbe07dadb07473cd37457a11d9662750779806c..0aa42cf4462df9e29eb6f1d398978eb78016035a 100644 (file)
@@ -24,6 +24,7 @@ use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\DFRN;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Security;
+use Friendica\Util\Strings;
 use Friendica\Util\XML;
 
 function profile_init(App $a)
@@ -58,8 +59,8 @@ function profile_init(App $a)
                $user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]);
                if (DBA::isResult($user)) {
                        $data = ActivityPub\Transmitter::getProfile($user['uid']);
-                       echo json_encode($data);
                        header('Content-Type: application/activity+json');
+                       echo json_encode($data);
                        exit();
                }
        }
@@ -91,7 +92,7 @@ function profile_init(App $a)
        }
 
        $a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($a->profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
-       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which . '" title="' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
+       $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . System::baseUrl() . '/dfrn_poll/' . $which . '" title="DFRN: ' . L10n::t('%s\'s timeline', $a->profile['username']) . '"/>' . "\r\n";
        $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";
@@ -114,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::escapeHtml($a->argv[$x]);
                                } else {
-                                       $datequery = escape_tags($a->argv[$x]);
+                                       $datequery = Strings::escapeHtml($a->argv[$x]);
                                }
                        } else {
                                $category = $a->argv[$x];
@@ -193,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::escapeTags(trim($_GET['tab']));
                }
 
                $o .= Profile::getTabs($a, $is_owner, $a->profile['nickname']);
@@ -267,24 +268,26 @@ function profile_content(App $a, $update = 0)
                if (!DBA::isResult($items)) {
                        return '';
                }
+
+               $pager = new Pager($a->query_string);
        } 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(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
+                               DBA::escape(Strings::protectSprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['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(protect_sprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));
+                               DBA::escape(Strings::protectSprintf($hashtags)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval($a->profile['profile_uid']));
                }
 
                if (!empty($datequery)) {
-                       $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
+                       $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` <= '%s' ", DBA::escape(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
                }
                if (!empty($datequery2)) {
-                       $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
+                       $sql_extra2 .= Strings::protectSprintf(sprintf(" AND `thread`.`created` >= '%s' ", DBA::escape(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
                }
 
                // Does the profile page belong to a forum?