<commit_before><?php

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

function smarty_function_query($params, &$smarty) {
  parse_str(TikiLib::htmldecode($_SERVER['QUERY_STRING'], ENT_COMPAT, HTML_SPECIALCHARS), $query);
  foreach($params as $param_name=>$param_value) {
    $list = explode(",",$param_value);
    if (isset($query[$param_name])) {
      if ($param_value === NULL or $param_value == 'NULL') {
        unset($query[$param_name]);
        continue;
      }
    $query[$param_name] = $list[(array_search($query[$param_name],$list)+1)%sizeof($list)];
		if ($query[$param_name] === NULL or $query[$param_name] == 'NULL') {
		  unset($query[$param_name]);
		}
    } else {
      if ($param_value !== NULL and $param_value != 'NULL' ) {
        $query[$param_name] = $list[0];
      }
    }
  }

  $sep = '&amp;';
  if ( function_exists('http_build_query') ) {
    echo http_build_query($query, '', $sep);
  } else {
    $ret = '';
    if ( is_array($query) ) {
      foreach ( $query as $k => $v ) {
        if ( $ret != '' ) $ret .= $sep;
        $ret .= urlencode($k).'='.urlencode($v);
      }
    }
  }<commit_msg>[FIX] smarty query function: add code for PHP4 compatibility (dont forget to return value for PHP4...).<commit_after><?php

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

function smarty_function_query($params, &$smarty) {
  parse_str(TikiLib::htmldecode($_SERVER['QUERY_STRING'], ENT_COMPAT, HTML_SPECIALCHARS), $query);
  foreach($params as $param_name=>$param_value) {
    $list = explode(",",$param_value);
    if (isset($query[$param_name])) {
      if ($param_value === NULL or $param_value == 'NULL') {
        unset($query[$param_name]);
        continue;
      }
    $query[$param_name] = $list[(array_search($query[$param_name],$list)+1)%sizeof($list)];
		if ($query[$param_name] === NULL or $query[$param_name] == 'NULL') {
		  unset($query[$param_name]);
		}
    } else {
      if ($param_value !== NULL and $param_value != 'NULL' ) {
        $query[$param_name] = $list[0];
      }
    }
  }

  $ret = '';
  $sep = '&amp;';
  if ( function_exists('http_build_query') ) {
    $ret = http_build_query($query, '', $sep);
  } else {
    if ( is_array($query) ) {
      foreach ( $query as $k => $v ) {
        if ( $ret != '' ) $ret .= $sep;
        $ret .= urlencode($k).'='.urlencode($v);
      }
    }
  }
  echo $ret;
{'fraction_non_alphanumeric': 0.19788119561104806, 'fraction_numerical': 0.0022701475595913734, 'mean_word_length': 3.473773265651438, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1667478', 'n_tokens_mistral': 934, 'n_tokens_neox': 919, 'n_words': 183}