From 676d7b78ccfd75bbe2cf0841101fe1b0307b3539 Mon Sep 17 00:00:00 2001 From: e107steved Date: Sat, 28 May 2011 12:05:40 +0000 Subject: [PATCH] Bugtracker #5226 - catch invalid page numbers in multi-page content documents --- e107_plugins/content/content.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/e107_plugins/content/content.php b/e107_plugins/content/content.php index a1b5839dc..dd87c822c 100644 --- a/e107_plugins/content/content.php +++ b/e107_plugins/content/content.php @@ -1060,7 +1060,8 @@ function show_content_score(){ } // ##### CONTENT ITEM ------------------------------------------ -function show_content_item(){ +function show_content_item() +{ global $pref, $content_pref, $custom, $plugindir, $plugintable, $array, $content_shortcodes, $datequery, $order, $nextprevquery, $from, $number, $row, $qs, $gen, $sql, $aa, $tp, $rs, $cobj, $e107, $e107cache, $eArrayStorage, $ns, $rater, $ep, $row, $authordetails, $mainparent; global $CONTENT_CONTENT_TABLE_TEXT, $CONTENT_CONTENT_TABLE_PAGENAMES, $CONTENT_CONTENT_TABLE_SUMMARY, $CONTENT_CONTENT_TABLE_CUSTOM_TAGS, $CONTENT_CONTENT_TABLE_PARENT, $CONTENT_CONTENT_TABLE_INFO_PRE, $CONTENT_CONTENT_TABLE_INFO_POST, $CM_AUTHOR, $CONTENT_CONTENT_TABLE_INFO_PRE_HEADDATA, $CONTENT_CONTENT_TABLE_INFO_POST_HEADDATA; global $CONTENT_CONTENT_TABLE_PREV_PAGE, $CONTENT_CONTENT_TABLE_NEXT_PAGE; @@ -1104,7 +1105,15 @@ function show_content_item(){ } } - if(!isset($qs[2])){ $cacheid = 1; }else{ $cacheid = $qs[2]; } + if(!isset($qs[2]) || ($qs[2] = intval($qs[2])) <= 0) + { + $cacheid = 1; + $qs[2] = 1; // Force first page + } + else + { + $cacheid = $qs[2]; + } $cachestr = "$plugintable.content.$qs[1].$cacheid"; $cachecheck = CachePre($cachestr); if($cachecheck) @@ -1144,7 +1153,14 @@ function show_content_item(){ $CONTENT_CONTENT_TABLE_TEXT = $pages[(!$qs[2] ? 0 : $qs[2]-1)]; $options = ""; for ($i=0; $i < count($pages); $i++) { - if(!isset($qs[2])){ $idp = 1; }else{ $idp = $qs[2]; } + if (!isset($qs[2])) + { + $idp = 1; + } + else + { + $idp = $qs[2]; + } if($idp == $i+1){ $pre = CONTENT_LAN_92; }else{ $pre = ""; } if($matches[0][$i] == "[newpage]"){ $pagename[$i] = CONTENT_LAN_78;