diff --git a/includes/basetype.class.php b/includes/basetype.class.php index 614bd46e..1218e27a 100644 --- a/includes/basetype.class.php +++ b/includes/basetype.class.php @@ -818,13 +818,32 @@ abstract class Filter if (strpos($term, $c.'=') === 0) { $$c = explode(':', explode('=', $term)[1]); - $this->formData['setCriteria'][$c] = $$c; // todo (high): move to checks unset($tmp[$i]); } } } - for ($i = 0; $i < max(count($cr), count($crv), count($crs)); $i++) + // handle erronous input + if (count($cr) != count($crv) || count($cr) != count($crs)) + { + // use min provided criterion as basis + $min = min(count($cr), count($crv), count($crs)); + if (count($cr) > $min) + array_splice($cr, $min); + + if (count($crv) > $min) + array_splice($crv, $min); + + if (count($crs) > $min) + array_splice($crs, $min); + + $this->error = true; + } + + foreach (self::$criteria as $c) + $this->formData['setCriteria'][$c] = $$c; + + for ($i = 0; $i < count($cr); $i++) { if (!isset($cr[$i]) || !isset($crs[$i]) || !isset($crv[$i]) || !intVal($cr[$i]) || $crs[$i] === '' || $crv[$i] === '') diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index 7f4e31e9..8cb96010 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -229,7 +229,8 @@ class GenericPage case 0: // no params works always return true; case 1: // null is valid || value in a 1-dim-array || key for a n-dim-array - return $this->category[0] === null || in_array($this->category[0], $this->validCats) || !empty($this->validCats[$this->category[0]]); + $filtered = array_filter($this->validCats, function ($x) { return is_int($x); }); + return $this->category[0] === null || in_array($this->category[0], $filtered) || !empty($this->validCats[$this->category[0]]); case 2: // first param has to be a key. otherwise invalid if (!isset($this->validCats[$this->category[0]])) return false; diff --git a/pages/item.php b/pages/item.php index 9ad251af..690f02f5 100644 --- a/pages/item.php +++ b/pages/item.php @@ -54,16 +54,16 @@ class ItemPage extends genericPage // allow lookup by name for xml if (!is_numeric($param)) - $conditions = [['name_loc'.User::$localeId, utf8_encode(urldecode($param))]]; - - if (!is_numeric($param)) - $this->typeId = $this->subject->id; + $conditions = [['name_loc'.User::$localeId, urldecode($param)]]; } $this->subject = new ItemList($conditions); if ($this->subject->error) $this->notFound(); + if (!is_numeric($param)) + $this->typeId = $this->subject->id; + $this->name = $this->subject->getField('name', true); if ($this->mode == CACHE_TYPE_PAGE) diff --git a/pages/npc.php b/pages/npc.php index f563a0b3..07208743 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -881,7 +881,10 @@ class NpcPage extends GenericPage if ($row['spillover']) { - $spillover[$factions->getField('cat')] = [intVal(array_sum($row['qty']) / 2), $row['maxRank']]; + $spillover[$factions->getField('cat')] = array( + [ $set['qty'][0] / 2, $set['qty'][1] / 2 ], + $row['maxRank'] + ); $set['spillover'] = $factions->getField('cat'); } diff --git a/pages/quest.php b/pages/quest.php index d8d41b49..9094e4a9 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -258,8 +258,14 @@ class QuestPage extends GenericPage $_ = $chain[0][0]; while ($_) { - if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask FROM ?_quests WHERE nextQuestIdChain = ?d', $_['typeId'])) + if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, IF(id = nextQuestIdChain, 1, 0) AS error, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask FROM ?_quests WHERE nextQuestIdChain = ?d', $_['typeId'])) { + if ($_['error']) + { + trigger_error('Quest '.$_['typeId'].' is in a chain with itself'); + break; + } + $n = Util::localizedString($_, 'name'); array_unshift($chain, array( array( @@ -275,8 +281,11 @@ class QuestPage extends GenericPage $_ = end($chain)[0]; while ($_) { - if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask, nextQuestIdChain AS _next FROM ?_quests WHERE id = ?d', $_['_next'])) + if ($_ = DB::Aowow()->selectRow('SELECT id AS typeId, IF(id = nextQuestIdChain, 1, 0) AS error, name_loc0, name_loc2, name_loc3, name_loc6, name_loc8, reqRaceMask, nextQuestIdChain AS _next FROM ?_quests WHERE id = ?d', $_['_next'])) { + if ($_['error']) // error already triggered + break; + $n = Util::localizedString($_, 'name'); array_push($chain, array( array( @@ -471,6 +480,7 @@ class QuestPage extends GenericPage 'id' => $i, 'name' => $pair[1] ?: Util::localizedString($olGOData->getEntry($i), 'name'), 'qty' => $pair[0] > 1 ? $pair[0] : 0, + 'extraText' => '' ); } } diff --git a/template/pages/npc.tpl.php b/template/pages/npc.tpl.php index e73c5b16..fb35478c 100644 --- a/template/pages/npc.tpl.php +++ b/template/pages/npc.tpl.php @@ -92,9 +92,9 @@ if ($this->reputation): foreach ($set[1] as $itr): if ($itr['qty'][1] && User::isInGroup(U_GROUP_EMPLOYEE)) - $qty = $itr['qty'][0] . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($itr['qty'][1] > 0 ? '+' : '').$itr['qty'][1]); + $qty = intVal($itr['qty'][0]) . sprintf(Util::$dfnString, Lang::faction('customRewRate'), ($itr['qty'][1] > 0 ? '+' : '').intVal($itr['qty'][1])); else - $qty = array_sum($itr['qty']); + $qty = intVal(array_sum($itr['qty'])); echo '
  • '.$qty.' '.Lang::npc('repWith') . ' '.$itr['name'].''.($itr['cap'] && $itr['qty'][0] > 0 ? ' ('.sprintf(Lang::npc('stopsAt'), $itr['cap']).')' : null).'
  • ';