From b83f32898338578f6512f7f2f95ca51aa1018be9 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Mon, 13 Jan 2020 20:10:13 +0000
Subject: [PATCH] Remove "f" parameter / network page parameter cleanup

---
 include/conversation.php  |  4 +--
 mod/dfrn_poll.php         |  4 +--
 mod/display.php           |  2 +-
 mod/network.php           | 70 +++++++++------------------------------
 mod/oexchange.php         |  2 +-
 mod/photos.php            | 10 +++---
 src/Content/Item.php      |  4 +--
 src/Content/Nav.php       |  1 -
 view/js/autocomplete.js   |  4 +--
 view/js/main.js           |  4 +--
 view/theme/frio/theme.php |  4 +--
 11 files changed, 34 insertions(+), 75 deletions(-)

diff --git a/include/conversation.php b/include/conversation.php
index 409d679076..bbabcc4372 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -86,7 +86,7 @@ function item_redir_and_replace_images($body, $images, $cid) {
 
 		$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
 		$replace = '[url=' . DI::baseUrl() . '/redir/' . $cid
-				   . '?f=1&url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
+				   . '?url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
 
 		$newbody .= substr($origbody, 0, $pos['start']['open']);
 		$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
@@ -935,7 +935,7 @@ function item_photo_menu($item) {
 	}
 
 	if ($cid && !$item['self']) {
-		$poke_link = 'poke/?f=&c=' . $cid;
+		$poke_link = 'poke?c=' . $cid;
 		$contact_url = 'contact/' . $cid;
 		$posts_link = 'contact/' . $cid . '/posts';
 
diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
index 002ddf924b..3e193e2a3a 100644
--- a/mod/dfrn_poll.php
+++ b/mod/dfrn_poll.php
@@ -541,7 +541,7 @@ function dfrn_poll_content(App $a)
 
 			switch ($destination_url) {
 				case 'profile':
-					DI::baseUrl()->redirect('profile/' . $profile . '?f=&tab=profile');
+					DI::baseUrl()->redirect('profile/' . $profile . '?tab=profile');
 					break;
 				case 'photos':
 					DI::baseUrl()->redirect('photos/' . $profile);
@@ -551,7 +551,7 @@ function dfrn_poll_content(App $a)
 					DI::baseUrl()->redirect('profile/' . $profile);
 					break;
 				default:
-					$appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
+					$appendix = (strstr($destination_url, '?') ? '&redir=1' : '?redir=1');
 					DI::baseUrl()->redirect($destination_url . $appendix);
 					break;
 			}
diff --git a/mod/display.php b/mod/display.php
index d5db5d7e9b..07445ba51f 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -315,7 +315,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
 	}
 
 	if (!$update) {
-		$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
+		$o .= "<script> var netargs = '?item_id=" . $item_id . "'; </script>";
 	}
 
 	$o .= conversation($a, [$item], new Pager(DI::args()->getQueryString()), 'display', $update_uid, false, 'commented', $item_uid);
diff --git a/mod/network.php b/mod/network.php
index acf6c62716..a2c20ba40a 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -86,19 +86,11 @@ function network_init(App $a)
 			// last selected tab is _not_ '/network?order=activity'.
 			// and this isn't a date query
 
-			$tab_baseurls = [
-				'',     //all
-				'',     //postord
-				'',     //conv
-				'/new', //new
-				'',     //starred
-				'',     //bookmarked
-			];
 			$tab_args = [
 				'order=activity', //all
 				'order=post',     //postord
 				'conv=1',         //conv
-				'',               //new
+				'new=1',          //new
 				'star=1',         //starred
 				'bmark=1',        //bookmarked
 			];
@@ -106,8 +98,6 @@ function network_init(App $a)
 			$k = array_search('active', $last_sel_tabs);
 
 			if ($k != 3) {
-				$net_baseurl .= $tab_baseurls[$k];
-
 				// parse out tab queries
 				$dest_qa = [];
 				$dest_qs = $tab_args[$k];
@@ -152,7 +142,7 @@ function network_init(App $a)
  *        '/network?order=activity' => $activity_active = 'active'
  *        '/network?order=post'     => $postord_active = 'active'
  *        '/network?conv=1',        => $conv_active = 'active'
- *        '/network/new',           => $new_active = 'active'
+ *        '/network?new=1',         => $new_active = 'active'
  *        '/network?star=1',        => $starred_active = 'active'
  *        '/network?bmark=1',       => $bookmarked_active = 'active'
  *
@@ -169,7 +159,7 @@ function network_query_get_sel_tab(App $a)
 	$conv_active = '';
 	$postord_active = '';
 
-	if (($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new')) {
+	if (!empty($_GET['new'])) {
 		$new_active = 'active';
 	}
 
@@ -312,21 +302,7 @@ function network_content(App $a, $update = 0, $parent = 0)
 	$arr = ['query' => DI::args()->getQueryString()];
 	Hook::callAll('network_content_init', $arr);
 
-	$flat_mode = false;
-
-	if ($a->argc > 1) {
-		for ($x = 1; $x < $a->argc; $x ++) {
-			if ($a->argv[$x] === 'new') {
-				$flat_mode = true;
-			}
-		}
-	}
-
-	if (!empty($_GET['file'])) {
-		$flat_mode = true;
-	}
-
-	if ($flat_mode) {
+	if (!empty($_GET['new']) || !empty($_GET['file'])) {
 		$o = networkFlatView($a, $update);
 	} else {
 		$o = networkThreadedView($a, $update, $parent);
@@ -916,11 +892,16 @@ function network_tabs(App $a)
 
 	$cmd = DI::args()->getCommand();
 
+	$def_param = [];
+	if (!empty($_GET['cid'])) {
+		$def_param['cid'] = $_GET['cid'];
+	}
+
 	// tabs
 	$tabs = [
 		[
 			'label'	=> L10n::t('Latest Activity'),
-			'url'	=> str_replace('/new', '', $cmd) . '?order=activity' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
+			'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['order' => 'activity'])),
 			'sel'	=> $all_active,
 			'title'	=> L10n::t('Sort by latest activity'),
 			'id'	=> 'activity-order-tab',
@@ -928,7 +909,7 @@ function network_tabs(App $a)
 		],
 		[
 			'label'	=> L10n::t('Latest Posts'),
-			'url'	=> str_replace('/new', '', $cmd) . '?order=post' . (!empty($_GET['cid']) ? '&cid=' . $_GET['cid'] : ''),
+			'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['order' => 'post'])),
 			'sel'	=> $post_active,
 			'title'	=> L10n::t('Sort by post received date'),
 			'id'	=> 'post-order-tab',
@@ -936,14 +917,9 @@ function network_tabs(App $a)
 		],
 	];
 
-	$parameters = ['conv' => true];
-	if (!empty($_GET['cid'])) {
-		$parameters['cid'] = $_GET['cid'];
-	}
-
 	$tabs[] = [
 		'label'	=> L10n::t('Personal'),
-		'url'	=> str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
+		'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['conv' => true])),
 		'sel'	=> $conv_active,
 		'title'	=> L10n::t('Posts that mention or involve you'),
 		'id'	=> 'personal-tab',
@@ -951,15 +927,9 @@ function network_tabs(App $a)
 	];
 
 	if (Feature::isEnabled(local_user(), 'new_tab')) {
-		if (!empty($_GET['cid'])) {
-			$query = '?' . http_build_query(['cid' => $_GET['cid']]);
-		} else {
-			$query = '';
-		}
-
 		$tabs[] = [
 			'label'	=> L10n::t('New'),
-			'url'	=> 'network/new' . $query,
+			'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['new' => true])),
 			'sel'	=> $new_active,
 			'title'	=> L10n::t('Activity Stream - by date'),
 			'id'	=> 'activitiy-by-date-tab',
@@ -968,14 +938,9 @@ function network_tabs(App $a)
 	}
 
 	if (Feature::isEnabled(local_user(), 'link_tab')) {
-		$parameters = ['bmark' => true];
-		if (!empty($_GET['cid'])) {
-			$parameters['cid'] = $_GET['cid'];
-		}
-
 		$tabs[] = [
 			'label'	=> L10n::t('Shared Links'),
-			'url'	=> str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
+			'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['bmark' => true])),
 			'sel'	=> $bookmarked_active,
 			'title'	=> L10n::t('Interesting Links'),
 			'id'	=> 'shared-links-tab',
@@ -983,14 +948,9 @@ function network_tabs(App $a)
 		];
 	}
 
-	$parameters = ['tar' => true];
-	if (!empty($_GET['cid'])) {
-		$parameters['cid'] = $_GET['cid'];
-	}
-
 	$tabs[] = [
 		'label'	=> L10n::t('Starred'),
-		'url'	=> str_replace('/new', '', $cmd) . '?' . http_build_query($parameters),
+		'url'	=> $cmd . '?' . http_build_query(array_merge($def_param, ['star' => true])),
 		'sel'	=> $starred_active,
 		'title'	=> L10n::t('Favourite Posts'),
 		'id'	=> 'starred-posts-tab',
diff --git a/mod/oexchange.php b/mod/oexchange.php
index 751cb97884..10d48338a4 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -42,7 +42,7 @@ function oexchange_content(App $a) {
 	$tags = ((!empty($_REQUEST['tags']))
 		? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : '');
 
-	$s = Network::fetchUrl(DI::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
+	$s = Network::fetchUrl(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
 
 	if (!strlen($s)) {
 		return;
diff --git a/mod/photos.php b/mod/photos.php
index 2ca6c6a37b..37c974048b 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1071,7 +1071,7 @@ function photos_content(App $a)
 		if ($order_field === 'posted') {
 			$order =  [L10n::t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album), 'oldest'];
 		} else {
-			$order = [L10n::t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted', 'newest'];
+			$order = [L10n::t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?order=posted', 'newest'];
 		}
 
 		$photos = [];
@@ -1091,7 +1091,7 @@ function photos_content(App $a)
 					'id' => $rr['id'],
 					'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
 					'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
-						. ($order_field === 'posted' ? '?f=&order=posted' : ''),
+						. ($order_field === 'posted' ? '?order=posted' : ''),
 					'title' => L10n::t('View Photo'),
 					'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
 					'alt' => $imgalt_e,
@@ -1191,10 +1191,10 @@ function photos_content(App $a)
 				}
 
 				if (!is_null($prv)) {
-					$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
+					$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
 				}
 				if (!is_null($nxt)) {
-					$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?f=&order=posted' : '');
+					$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
 				}
 
 				$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
@@ -1252,7 +1252,7 @@ function photos_content(App $a)
 		$photo = [
 			'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
 			'title'=> L10n::t('View Full Size'),
-			'src'  => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . DateTimeFormat::utcNow('ymdhis'),
+			'src'  => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?_u=' . DateTimeFormat::utcNow('ymdhis'),
 			'height' => $hires['height'],
 			'width' => $hires['width'],
 			'album' => $hires['album'],
diff --git a/src/Content/Item.php b/src/Content/Item.php
index ea1baef180..6769a1293c 100644
--- a/src/Content/Item.php
+++ b/src/Content/Item.php
@@ -51,7 +51,7 @@ final class Item
 			$categories[] = [
 				'name' => $savedFolderName,
 				'url' => $url,
-				'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&cat=' . rawurlencode($savedFolderName) : ""),
+				'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : ""),
 				'first' => $first,
 				'last' => false
 			];
@@ -67,7 +67,7 @@ final class Item
 				$folders[] = [
 					'name' => $savedFolderName,
 					'url' => "#",
-					'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . rawurlencode($savedFolderName) : ""),
+					'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : ""),
 					'first' => $first,
 					'last' => false
 				];
diff --git a/src/Content/Nav.php b/src/Content/Nav.php
index 3685a8b327..7850e57c14 100644
--- a/src/Content/Nav.php
+++ b/src/Content/Nav.php
@@ -239,7 +239,6 @@ class Nav
 		// The following nav links are only show to logged in users
 		if (local_user()) {
 			$nav['network'] = ['network', L10n::t('Network'), '', L10n::t('Conversations from your friends')];
-			$nav['net_reset'] = ['network/?f=', L10n::t('Network Reset'), '', L10n::t('Load Network page with no filters')];
 
 			$nav['home'] = ['profile/' . $a->user['nickname'], L10n::t('Home'), '', L10n::t('Your posts and conversations')];
 
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index bb3577fb9b..1274e4ae45 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -222,7 +222,7 @@ function string2bb(element) {
 			match: /(^|\s)(\#)([^ \n]{2,})$/,
 			index: 3,
 			search: function(term, callback) {
-				$.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term)
+				$.getJSON(baseurl + '/hashtag/' + '?t=' + term)
 				.done(function(data) {
 					callback($.map(data, function(entry) {
 						// .toLowerCase() enables case-insensitive search
@@ -275,7 +275,7 @@ function string2bb(element) {
 		tags = {
 			match: /(^|\s)(\#)([^ \n]{2,})$/,
 			index: 3,
-			search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); },
+			search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); },
 			replace: function(item) { return "$1$2" + item.text; },
 			template: tag_format
 		};
diff --git a/view/js/main.js b/view/js/main.js
index a5aa6d434e..fed9cc59f0 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -498,7 +498,7 @@ function insertBBCodeInTextarea(BBCode, textarea) {
 
 function NavUpdate() {
 	if (!stopped) {
-		var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&f=&uid=' + localUser : '');
+		var pingCmd = 'ping?format=json' + ((localUser != 0) ? '&uid=' + localUser : '');
 		$.get(pingCmd, function(data) {
 			if (data.result) {
 				// send nav-update event
@@ -980,7 +980,7 @@ Array.prototype.remove = function(item) {
 
 function previewTheme(elm) {
 	theme = $(elm).val();
-	$.getJSON('pretheme?f=&theme=' + theme,function(data) {
+	$.getJSON('pretheme?theme=' + theme,function(data) {
 			$('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
 	});
 
diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
index 2cd30ad1f1..513bb4e61d 100644
--- a/view/theme/frio/theme.php
+++ b/view/theme/frio/theme.php
@@ -127,7 +127,7 @@ function frio_item_photo_links(App $a, &$body_info)
 function frio_item_photo_menu(App $a, &$arr)
 {
 	foreach ($arr['menu'] as $k => $v) {
-		if (strpos($v, 'poke/?f=&c=') === 0 || strpos($v, 'message/new/') === 0) {
+		if (strpos($v, 'poke?c=') === 0 || strpos($v, 'message/new/') === 0) {
 			$v = 'javascript:addToModal(\'' . $v . '\'); return false;';
 			$arr['menu'][$k] = $v;
 		}
@@ -181,7 +181,7 @@ function frio_contact_photo_menu(App $a, &$args)
 	// Add to pm and poke links a new key with the value 'modal'.
 	// Later we can make conditions in the corresponing templates (e.g.
 	// contact_template.tpl)
-	if (strpos($pokelink, 'poke/?f=&c=' . $cid) !== false) {
+	if (strpos($pokelink, 'poke?c=' . $cid) !== false) {
 		$args['menu']['poke'][3] = 'modal';
 	}