From cc96fca4c5fa560b10dc7d6faf85cb7160aa475e Mon Sep 17 00:00:00 2001 From: rub Date: Wed, 27 Dec 2006 20:26:36 +0000 Subject: Fix Feature Issue ID 0000608: crash when asking random images with no images are allowed git-svn-id: http://piwigo.org/svn/trunk@1681 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/section_init.inc.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include/section_init.inc.php') diff --git a/include/section_init.inc.php b/include/section_init.inc.php index d5bbce645..68fe8d452 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -247,13 +247,24 @@ else if ('list' == $tokens[$next_token]) $next_token++; $page['list'] = array(); - if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token])) + + // No pictures + if (empty($tokens[$next_token])) { - die('wrong format on list GET parameter'); + // Add dummy element list + array_push($page['list'], -1); } - foreach (explode(',', $tokens[$next_token]) as $image_id) + // With pictures list + else { - array_push($page['list'], $image_id); + if (!preg_match('/^\d+(,\d+)*$/', $tokens[$next_token])) + { + die('wrong format on list GET parameter'); + } + foreach (explode(',', $tokens[$next_token]) as $image_id) + { + array_push($page['list'], $image_id); + } } $next_token++; } -- cgit v1.2.3