Skip to content

Commit

Permalink
Ticket #3149 - Search Extended: Encode/decode conditions with base64.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Dec 29, 2021
1 parent 99e64a0 commit 6553b04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions inc/classes/BxDolSearchExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ static public function actionGetMention()
self::actionGetHashtags();
}

static public function encodeConditions($aConditions)
{
return urlencode(base64_encode(serialize($aConditions)));
}

static public function decodeConditions($sConditions)
{
return unserialize(base64_decode(urldecode($sConditions)));
}

public function isEnabled()
{
return isset($this->_aObject['active']) && (int)$this->_aObject['active'] != 0;
Expand Down
2 changes: 1 addition & 1 deletion template/scripts/BxBaseSearchExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getResults($aParams = array())
return '';

if(!empty($aParams['cond']) && is_array($aParams['cond']))
$aParams['cond'] = urlencode(serialize($aParams['cond']));
$aParams['cond'] = self::encodeConditions($aParams['cond']);

$aPaginate = array('start' => $iStart, 'per_page' => $iPerPage);
if(!$bJsMode) {
Expand Down
2 changes: 1 addition & 1 deletion template/scripts/BxBaseSearchExtendedServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function prepareParams(&$aParams)
$aParams['template'] = bx_process_input(bx_get('template'), BX_DATA_TEXT);

if(empty($aParams['cond']) && bx_get('cond') !== false)
$aParams['cond'] = unserialize(urldecode(bx_process_input(bx_get('cond'), BX_DATA_TEXT)));
$aParams['cond'] = BxDolSearchExtended::decodeConditions(bx_process_input(bx_get('cond'), BX_DATA_TEXT));

if(!isset($aParams['start']) && bx_get('start') !== false)
$aParams['start'] = (int)bx_get('start');
Expand Down

0 comments on commit 6553b04

Please sign in to comment.