Browse Source

Deleted POST, GET ...

Visman 8 years ago
parent
commit
9607fb3919
3 changed files with 23 additions and 18 deletions
  1. 8 5
      userlist.php
  2. 3 2
      viewforum.php
  3. 12 11
      viewtopic.php

+ 8 - 5
userlist.php

@@ -25,10 +25,13 @@ require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
 // Determine if we are allowed to view post counts
 $show_post_count = ($pun_config['o_show_post_count'] == '1' || $pun_user['is_admmod']) ? true : false;
 
-$username = isset($_GET['username']) && $pun_user['g_search_users'] == '1' ? pun_trim($_GET['username']) : '';
-$show_group = isset($_GET['show_group']) ? intval($_GET['show_group']) : -1;
-$sort_by = isset($_GET['sort_by']) && (in_array($_GET['sort_by'], array('username', 'registered')) || ($_GET['sort_by'] == 'num_posts' && $show_post_count)) ? $_GET['sort_by'] : 'username';
-$sort_dir = isset($_GET['sort_dir']) && $_GET['sort_dir'] == 'DESC' ? 'DESC' : 'ASC';
+$request = $container->get('Request');
+
+$username = $pun_user['g_search_users'] == '1' ? trim($request->getStr('username')) : '';
+$show_group = $request->getInt('show_group', -1);
+$sort_by = $request->getStr('sort_by', 'username');
+$sort_by = in_array($sort_by, array('username', 'registered')) || ($sort_by === 'num_posts' && $show_post_count) ? $sort_by : 'username';
+$sort_dir = $request->getStr('sort_dir') === 'DESC' ? 'DESC' : 'ASC';
 
 // Create any SQL for the WHERE clause
 $where_sql = array();
@@ -46,7 +49,7 @@ $num_users = $db->result($result);
 // Determine the user offset (based on $_GET['p'])
 $num_pages = ceil($num_users / 50);
 
-$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
+$p = max(min($request->getInt('p', 1), $num_pages), 1);
 $start_from = 50 * ($p - 1);
 
 $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['User list']);

+ 3 - 2
viewforum.php

@@ -13,8 +13,9 @@ require PUN_ROOT.'include/common.php';
 if ($pun_user['g_read_board'] == '0')
 	message($lang_common['No view'], false, '403 Forbidden');
 
+$request = $container->get('Request');
 
-$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
+$id = $request->getInt('id', 0);
 if ($id < 1)
 	message($lang_common['Bad request'], false, '404 Not Found');
 
@@ -76,7 +77,7 @@ if (!$pun_user['is_guest'])
 // Determine the topic offset (based on $_GET['p'])
 $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
 
-$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
+$p = max(min($request->getInt('p', 1), $num_pages), 1);
 $start_from = $pun_user['disp_topics'] * ($p - 1);
 
 // Generate paging links

+ 12 - 11
viewtopic.php

@@ -14,10 +14,11 @@ require PUN_ROOT.'include/common.php';
 if ($pun_user['g_read_board'] == '0')
 	message($lang_common['No view'], false, '403 Forbidden');
 
+$request = $container->get('Request');
 
-$action = isset($_GET['action']) ? $_GET['action'] : null;
-$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
-$pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
+$action = $request->getStr('action');
+$id = $request->getInt('id', 0);
+$pid = $request->getInt('pid', 0);
 if ($id < 1 && $pid < 1)
 	message($lang_common['Bad request'], false, '404 Not Found');
 
@@ -38,12 +39,12 @@ if ($pid)
 	$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND id<'.$pid) or error('Unable to count previous posts', __FILE__, __LINE__, $db->error());
 	$num_posts = $db->result($result) + 1;
 
-	$_GET['p'] = ceil($num_posts / $pun_user['disp_posts']);
+	$_GET['p'] = ceil($num_posts / $pun_user['disp_posts']); //????
 }
 else
 {
 	// If action=new, we redirect to the first new post (if any)
-	if ($action == 'new')
+	if ($action === 'new')
 	{
 		if (!$pun_user['is_guest'])
 		{
@@ -66,7 +67,7 @@ else
 	}
 
 	// If action=last, we redirect to the last post
-	if ($action == 'last')
+	if ($action === 'last')
 	{
 		$result = $db->query('SELECT MAX(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id) or error('Unable to fetch last post info', __FILE__, __LINE__, $db->error());
 		$last_post_id = $db->result($result);
@@ -86,14 +87,14 @@ if (!is_null(poll_post('poll_submit')))
 {
 	poll_vote($id, $pun_user['id']);
 
-	redirect('viewtopic.php?id='.$id.((isset($_GET['p']) && $_GET['p'] > 1) ? '&p='.intval($_GET['p']) : ''), $lang_poll['M0']);
+	redirect('viewtopic.php?id='.$id.($request->getInt('p', 0) > 1 ? '&p='.$request->getInt('p', 1) : ''), $lang_poll['M0']);
 }
 
 // search HL - Visman
 $url_shl = '';
-if (isset($_GET['search_hl']))
+if ($request->isGet('search_hl'))
 {
-	$search_hl = intval($_GET['search_hl']);
+	$search_hl = $request->getInt('search_hl', 0);
 	if ($search_hl < 1)
 		message($lang_common['Bad request'], false, '404 Not Found');
 
@@ -116,7 +117,7 @@ if (isset($_GET['search_hl']))
 	{
 		if ($id > 0)
 		{
-			$p = isset($_GET['p']) && $_GET['p'] > 1 ? '&p='.intval($_GET['p']) : '';
+			$p = $request->getInt('p', 0) > 1 ? '&p='.$request->getInt('p', 1) : '';
 
 			header('Location: viewtopic.php?id='.$id.$p.($pid > 0 ? '#p'.$pid : ''), true, 301);
 		}
@@ -225,7 +226,7 @@ if (!$pun_user['is_guest'])
 // Determine the post offset (based on $_GET['p'])
 $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
 
-$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
+$p = max(min($request->getInt('p', 1), $num_pages), 1);
 $start_from = $pun_user['disp_posts'] * ($p - 1);
 
 // Generate paging links