MyBB Community Forums
[F] Archive - bug with non-numeric $page [C-Chris] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] Archive - bug with non-numeric $page [C-Chris] (/thread-46030.html)



[F] Archive - bug with non-numeric $page [C-Chris] - koziolek - 03-02-2009

MyBB 1.4.4, confirmed here too:
http://community.mybboard.net/archive/index.php/thread-34200-lastpost.html

In archive mode links to threads with 0 replies and a string as param (e.g. "lastpost") produce error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10, 10' at line 1
Query:
SELECT pid FROM posts WHERE tid='34200' AND visible='1' ORDER BY dateline LIMIT -10, 10
because of variable $page with value "lastpost".
		if($page)
		{
			$start = ($page-1) * $perpage;
		}
		else
		{
			$start = 0;
			$page = 1;
		}
A possible solution is to replace first line with:
if(is_int($page))
or maybe add $page = intval($page) ; just before using $page?


RE: Archive - bug with non-numeric $page - dvb - 03-02-2009

(03-02-2009, 12:27 PM)koziolek Wrote: ...
or maybe add $page = intval($page) ; just before using $page?

This is the more correct way,

File 'archive\global.php', lines 78-87 Wrote:
if($endpart != "index.php")
{
	$endpart = str_replace(".html", "", $endpart);
	$todo = explode("-", $endpart, 3);
	if($todo[0])
	{
		$action = $todo[0];
	}
	$page = $todo[2];
	$id = intval($todo[1]);
The line:
	$page = $todo[2];
Should be:
	$page = intval($todo[2]);



[F] Archive - bug with non-numeric $page - Ryan Gordon - 03-02-2009

Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group


RE: [F] Archive - bug with non-numeric $page - Ryan Gordon - 03-02-2009

dvb's fix is correct